<!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 onload="window.print();">
		<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">
											<?php echo $this->session->company_name; ?>
											<small class="float-right">Date:<?php echo date_to_ui( $master[0]['purchase_date'] ); ?></small>
										</h2>
										<h3 class="text-center">Purchase Invoice</h3>
									</div>
								</div>

								<!-- info row -->
								<div class="row invoice-info">
									<div class="col-md-6 invoice-col">
										<strong>Purchase #</strong> <?php echo $master[0]['purchase_no']; ?><br>
										<strong>Notes:</strong> <?php echo $master[0]['notes']; ?><br>
									</div>
									<div class="col-md-6 invoice-col">
										<strong>Supplier Details</strong><br>
										<address>
											Name: <?php echo $master[0]['supplier_name']; ?><br>
											Address: <?php echo $master[0]['supplier_address']; ?><br>
											Mobile: <?php echo $master[0]['supplier_mobile']; ?><br>
										</address>
									</div>
								</div>

								<!-- Table row -->
								<div class="row">
									<div class="col-md-12">
										<table class="table table-bordered table-striped">
											<thead>
												<tr>
													<th>SL#</th>
													<th>ITEM DESCRIPTIONS</th>
													<th class="text-right">QTY</th>
													<th class="text-right">PRICE</th>
													<th class="text-right">TOTAL PRICE</th>
												</tr>
											</thead>
											<tbody>
												<?php
													$qty   = 0;
													$price = 0;
													$i     = 1;
													foreach ( $details as $detail ) {
													?>
													<tr>
														<td><?php echo $i; ?></td>
														<td><?php echo $detail['item_name']; ?></td>
														<td class="text-right"><?php echo $detail['quantity']; ?></td>
														<td class="text-right"><?php echo number_format( $detail['purchase_price'], 2 ); ?></td>
														<td class="text-right"><?php echo number_format( $detail['quantity'] * $detail['purchase_price'], 2 ); ?></td>
													</tr>
													<?php
														$qty += $detail['quantity'];
														$price += $detail['quantity'] * $detail['purchase_price'];
														$i++;
													}
												?>
											</tbody>
										</table>
									</div>
								</div>

								<!-- Table row -->
								<div class="row">
									<div class="col-md-8">
										&nbsp;
									</div>

									<div class="col-md-4">
										<table class="table table-striped">
											<tr>
												<th class="col-md-6">Sub - Total:</th>
												<th class="col-md-6 text-right">
													<?php if ( $this->session->currency_symbol_position == 'Before' ) {echo $this->session->currency_symbol;}?><?php echo number_format( $price, 2 ); ?><?php if ( $this->session->currency_symbol_position == 'After' ) {echo $this->session->currency_symbol;}?>
												</th>
											</tr>
											<tr>
												<th class="col-md-6">Grand Total:</th>
												<th class="col-md-6 text-right">
													<?php if ( $this->session->currency_symbol_position == 'Before' ) {echo $this->session->currency_symbol;}?><?php echo number_format( $price, 2 ); ?><?php if ( $this->session->currency_symbol_position == 'After' ) {echo $this->session->currency_symbol;}?>
												</th>
											</tr>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</section>
		</div>
	</body>
</html>