<!DOCTYPE html>
<html>
	<head>
		<title><?php echo $title; ?></title>
		<base href="<?php echo base_url(); ?>">
		<meta charset="utf-8">
		<!-- Tell the browser to be responsive to screen width -->
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

		<link rel="shortcut icon" href="assets/images/favicon.png" type="image/x-icon">

		<!-- Theme style -->
		<link rel="stylesheet" href="assets/AdminLTE-3.2.0/dist/css/adminlte.min.css">

		<!-- Google Font: Source Sans Pro -->
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
	</head>

	<body>
		<div class="wrapper">
			<!-- Main content -->
			<section class="content">
				<div class="container-fluid">
					<!-- Small boxes (Stat box) -->
					<div class="row">
						<div class="col-md-12">
							<!-- Invoice content -->
							<div class="invoice p-3 mb-3">
								<!-- title row -->
								<div class="row mb-4">
									<div class="col-12">
										<h2 class="page-header">
											<img src="<?php echo $this->session->company_logo; ?>" width="115" class="img">
											<small class="float-right"><?php echo $this->session->company_name; ?></small>
										</h2>
										<h3 class="text-center">Inventory Report</h3>
									</div>
								</div>

								<!-- info row -->
								<div class="row invoice-info mb-4">
									<div class="col-md-6 invoice-col">
										<strong>Date From:</strong> <?php echo date( 'jS M, Y ', strtotime( date_to_db( $start_date ) ) ); ?><br>
										<strong>Date To:</strong> <?php echo date( 'jS M, Y ', strtotime( date_to_db( $end_date ) ) ); ?>
									</div>
								</div>

								<!-- Table row -->
								<div class="row">
									<div class="col-md-12">
										<table class="table table-striped table-bordered table-hover">
											<thead>
												<tr>
													<th>SL #</th>
													<th>Date</th>
													<th>Opening Balance</th>
													<th>Purchase</th>
													<th>Purchase Return</th>
													<th>Sales</th>
													<th>Sales Return</th>
													<th>Closing Balance</th>
												</tr>
											</thead>
											<?php
											if ( count( $reports['inv'] ) > 0 ) {
												$item = [];
											?>
											<tbody>
												<?php
													$i = 1;
													foreach ( $reports['inv'] as $report ) {
													?>
													<tr>
														<td><?php echo $i; ?></td>
														<td class="text-left"><?php echo date_to_ui( $report['date'] ); ?></td>
														<td class="text-left">
															<?php
																foreach ( $report['details'] as $details ) {
																	echo $details['item_name'] . ' : ' . $details['open_qty'] . '<br>';
																}
															?>
														</td>
														<td>
															<?php
																foreach ( $report['details'] as $details ) {
																	echo $details['item_name'] . ' : ' . $details['purchase_qty'] . '<br>';
																}
															?>
														</td>
														<td>
															<?php
																foreach ( $report['details'] as $details ) {
																	echo $details['item_name'] . ' : ' . $details['purchase_return_qty'] . '<br>';
																}
															?>
														</td>
														<td>
															<?php
																foreach ( $report['details'] as $details ) {
																	echo $details['item_name'] . ' : ' . $details['sales_qty'] . '<br>';
																}
															?>
														</td>
														<td>
															<?php
																foreach ( $report['details'] as $details ) {
																	echo $details['item_name'] . ' : ' . $details['sales_return_qty'] . '<br>';
																}
															?>
														</td>
														<td class="text-left">
															<?php
																foreach ( $report['details'] as $details ) {
																	echo $details['item_name'] . ' : ' . $details['close_qty'] . '<br>';
																}
															?>
														</td>
													</tr>
													<?php
														$i++;
													}
												?>
											</tbody>
											<tfoot>
												<tr>
													<td class="text-center" colspan="8">&nbsp;</td>
												</tr>
											</tfoot>
											<?php
												} else {
												?>
											<tbody>
												<tr>
													<td class="text-center" colspan="8">&nbsp;</td>
												</tr>
											</tbody>
											<tfoot>
												<tr>
													<td class="text-center" colspan="8">&nbsp;</td>
												</tr>
											</tfoot>
											<?php
												}
											?>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</section>
		</div>
	</body>
</html>