<!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-md-12">
										<h4>
											<?php echo $this->session->company_name; ?>
											<small class="float-right">Date:<?php echo date_to_ui( $master['journal_date'] ); ?></small>
										</h4>
										<h3 class="text-center">Journal Voucher</h3>
									</div>
								</div>

								<!-- info row -->
								<div class="row invoice-info mb-4">
									<div class="col-md-12 invoice-col">
										<strong>Journal #</strong> <?php echo $master['journal_no']; ?><br>
										<strong>Notes:</strong> <?php echo $master['memo']; ?><br>
									</div>
								</div>

								<!-- Table row -->
								<div class="row">
									<?php
										$d = 0;
										$c = 0;
										foreach ( $details as $list ) {
											if ( $list['debit'] ) {
												$d++;
											} else {
												$c++;
											}
										}
									?>
									<div class="col-md-6">
										<table class="table table-bordered table-striped">
											<thead>
												<tr>
													<th>Debit Account</th>
													<th class="col-md-4">Amount</th>
												</tr>
											</thead>
											<tbody>
											<?php
												$debit_amount = 0;
												foreach ( $details as $list ) {
													if ( $list['debit'] ) {
													?>
													<tr>
														<td><?php echo $list['chart_name']; ?></td>
														<td class="right col-md-4"><?php echo number_format( $list['debit'], 2 ); ?></td>
													</tr>
													<?php
														$debit_amount += $list['debit'];
													}
												}
											?>
											</tbody>
										</table>
									</div>

									<div class="col-md-6">
										<table class="table table-bordered table-striped">
											<thead>
												<tr>
													<th>Credit Account</th>
													<th class="col-md-4">Amount</th>
												</tr>
											</thead>
											<tbody>
											<?php
												$credit_amount = 0;
												foreach ( $details as $list ) {
													if ( $list['credit'] ) {
													?>
													<tr>
														<td><?php echo $list['chart_name']; ?></td>
														<td class="right col-md-4"><?php echo number_format( $list['credit'], 2 ); ?></td>
													</tr>
													<?php
														$credit_amount += $list['credit'];
													}
												}
											?>
											</tbody>
										</table>
									</div>
								</div>

								<!-- Table row -->
								<div class="row">
									<div class="col-md-6">
										<table class="table table-bordered table-striped">
											<thead>
												<tr>
													<th class="text-center">Total</th>
													<th class="col-md-4 text-right">
														<?php if ( $this->session->currency_symbol_position == 'Before' ) {echo $this->session->currency_symbol;}?><?php echo number_format( $debit_amount, 2 ); ?><?php if ( $this->session->currency_symbol_position == 'After' ) {echo $this->session->currency_symbol;}?>
													</th>
												</tr>
											</thead>
										</table>
									</div>

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