<script src="<?php echo MOD_URL . 'dashboard/assets/js/print.js'; ?>"></script>

<!-- Sales Report Start -->
<div class="content-wrapper">
	<section class="content-header">
	    <div class="header-icon">
	        <i class="pe-7s-note2"></i>
	    </div>
	    <div class="header-title">
	        <h1><?php echo display('non_active_customer') ?></h1>
	        <small><?php echo display('non_active_customer') ?></small>
	        <ol class="breadcrumb">
	            <li><a href="index.html"><i class="pe-7s-home"></i> <?php echo display('home') ?></a></li>
	            <li><a href="#"><?php echo display('report') ?></a></li>
	            <li class="active"><?php echo display('sales_report') ?></li>
	        </ol>
	    </div>
	</section>

	<section class="content">
		<div class="row">
            <div class="col-sm-12">
                <div class="column">
                	<?php if ($this->permission->check_label('purchase_report')->read()->access()) {?>
                  	<a href="<?php echo base_url('dashboard/Admin_dashboard/todays_purchase_report') ?>" class="btn btn-success m-b-5 m-r-2"><i class="ti-align-justify"> </i>  <?php echo display('non_active_customer') ?> </a>
                  	<?php }?>
                </div>
            </div>
        </div>

		<!-- Sales report -->
		<div class="row">
			<div class="col-sm-12">
		        <div class="panel panel-default">
		            <div class="panel-body">
		                <?php echo form_open('dashboard/Admin_dashboard/non_active_customer', array('class' => 'form-inline')) ?>
		                <?php date_default_timezone_set(DEF_TIMEZONE);
$today = date('Y-m-d');?>
		                  <!--   <div class="form-group">
		                        <label class="" for="from_date"><?php echo display('start_date') ?></label>
		                        <input type="text" name="from_date" class="form-control datepicker" id="from_date" placeholder="<?php echo display('start_date') ?>" autocomplete="off" required>
		                    </div>

		                    <div class="form-group">
		                        <label class="" for="to_date"><?php echo display('end_date') ?></label>
		                        <input type="text" name="to_date" class="form-control datepicker" id="to_date" placeholder="<?php echo display('end_date') ?>" value="<?php echo $today ?>"  autocomplete="off" required>
		                    </div> -->



		                 <!-- added gender -->
		                <!--  <br>
		                 <br>
		                 <div class="form-group">
		                        <label class="" for="from_date"><?php echo display('gender') ?></label>
		                         <select name="gender" id="gender">
		                         	<option value="">請選擇性別</option>

									<option value="M"><?php echo "男"; ?></option>
									<option value="F"><?php echo "女"; ?></option>

		                         </select>
		                       </div>
 -->
		                 <!-- end added gender -->

		                 <!-- added age range -->
		               <!--   <br>
		                 <br> -->
		                 <div class="form-group">
		                        <label class="" for="from_date"><?php echo display('non_active_range_name') ?></label>
		                         <select name="age_range" id="age_range" required="">
		                         	<option value="">請選擇非活躍範圍</option>

									<option value="1"><?php echo "3個月"; ?></option>
									<option value="2"><?php echo "6個月"; ?></option>
									<option value="3"><?php echo "12個月"; ?></option>
									<option value="4"><?php echo "24個月"; ?></option>
		                         </select>

		                           <button type="submit" class="btn btn-success"><?php echo display('search') ?></button>
		                    <a  class="btn btn-warning" href="#" onclick="printDiv('purchase_div')"><?php echo display('print') ?></a>

		                       </div>

		                 <!-- end added gender -->

		            </div>
		        </div>
		    </div>
		</div>

		<?php echo form_close() ?>
	    <!-- end category search -->


		<div class="row">
		    <div class="col-sm-12">
		        <div class="panel panel-bd lobidrag">
		            <div class="panel-heading">
		                <div class="panel-title">
		                    <h4><?php echo display('non_active_customer') ?> </h4>
		                </div>
		            </div>
		            <div class="panel-body">
		            	<div id="purchase_div" class="ml_2">
			            	<div class="text-center">
								{company_info}
								<h3> {company_name} </h3>
								<h4 >{address} </h4>
								{/company_info}
								<h4> <?php echo display('print_date') ?>: <?php echo date("d/m/Y h:i:s"); ?> </h4>
							</div>
			                <div class="table-responsive">
			                    <table class="table table-bordered table-striped table-hover">
			                        <thead>
			                            <tr>
			                            <!--     <th><?php echo display('sales_date') ?></th>
											<th><?php echo display('invoice_no') ?></th>
											<th><?php echo display('product_category') ?></th>
											<th><?php echo display('cart_items') ?></th> -->
											<th><?php echo display('customer_name') ?></th>
											<th><?php echo display('gender') ?></th>
											<th><?php echo display('age_range') ?></th>
											<!-- <th><?php echo display('total_amount') ?></th> -->
			                            </tr>
			                        </thead>
			                      <!--   <tfoot>
										<tr>
											<td></td>
											<td></td>
											<td colspan="3" class="text-right"><b><?php echo display('total_seles') ?></b></td>
											<td class="text-right"><b><?php echo (($position == 0) ? "$currency {sales_amount}" : "{sales_amount} $currency") ?></b></td>
										</tr>
									</tfoot> -->
			                        <tbody>
			                        <!-- new report details -->
			                       	<?php

$currentOrder_id = "";
$printLine = false;
foreach ($sales_report as $saled_detail) {
	// if ($currentOrder_id != $saled_detail['order_id']) {
	// 	$currentOrder_id = $saled_detail['order_id'];
	// 	$printLine = true;

	// }
	?>
	<?php
//if ($printLine == true) {
	?>
	<tr>
<!-- 		<td><?php echo $saled_detail['sales_date']; ?></td>
		<td>
												<a href="<?php echo base_url() . 'dashboard/Cinvoice/invoice_inserted_data/' . $saled_detail['invoice_id']; ?>">
                                                    <?php echo $saled_detail['invoice_id']; ?>  <i class="fa fa-tasks pull-right" aria-hidden="true"></i>
												</a>
											</td>
											<td><?php echo $saled_detail['category_name_ch']; ?> </td>
											<td><?php echo $saled_detail['product_name_ch']; ?> </td> -->
											<td><a href="<?php echo base_url() . 'dashboard/Ccustomer/customerledger/' . $saled_detail['customer_id']; ?>"> <?php echo $saled_detail['customer_name']; ?> <i class="fa fa-user pull-right" aria-hidden="true"></i></a></td>
											<td><?php echo $saled_detail['gender']; ?> </td>
											<td><?php
echo

		$saled_detail['birthday'];
	if (date_create_from_format('Y-m-d', $saled_detail['birthday']) >= date_create_from_format('Y-m-d', '1800-10-11')

		&&
		date_create_from_format('Y-m-d', $saled_detail['birthday']) <= date_create_from_format('Y-m-d', '1959-10-10')

	) {
		echo "(60-100)";

	}

	if (date_create_from_format('Y-m-d', $saled_detail['birthday']) >= date_create_from_format('Y-m-d', '1959-10-11')

		&&
		date_create_from_format('Y-m-d', $saled_detail['birthday']) <= date_create_from_format('Y-m-d', '1979-10-10')

	) {
		echo "(40-59)";

	}
	if (date_create_from_format('Y-m-d', $saled_detail['birthday']) >= date_create_from_format('Y-m-d', '1979-10-11')

		&&
		date_create_from_format('Y-m-d', $saled_detail['birthday']) <= date_create_from_format('Y-m-d', '1999-10-10')

	) {
		echo "(20-39)";

	}

	if (date_create_from_format('Y-m-d', $saled_detail['birthday']) >= date_create_from_format('Y-m-d', '1999-10-11')

		&&
		date_create_from_format('Y-m-d', $saled_detail['birthday']) <= date_create_from_format('Y-m-d', '2030-10-10')

	) {
		echo "(0-19)";

	}

	?>


											 </td>
											<!-- <td class="text-right"><?php echo (($position == 0) ? "$currency " . $saled_detail['total_amount'] : $saled_detail['total_amount'] . $currency) ?></td> -->
										</tr>
	<?php
//} //if($printLine==true){
	?>

<?php

} //foreach ($sales_report as $key => $value) {

?>
			                        <!-- end new report details -->



			                        </tbody>
			                    </table>
			                </div>
			            </div>
			            <div class="text-right"><?php echo htmlspecialchars_decode($links) ?></div>
		            </div>
		        </div>
		    </div>
		</div>
	</section>
</div>
 <!-- Sales Report End -->