<?php 
	$header_file=APPPATH.'views/include/header.php';
	require($header_file);
	
	?>

    <!-- BEGIN: Content-->
    <div class="app-content content">
      <div class="content-overlay"></div>
      <div class="content-wrapper">
        <div class="content-header row">
          <div class="content-header-left col-md-12 col-12 mb-2 breadcrumb-new">
            <h3 class="content-header-title mb-0 d-inline-block">Invoice List</h3>
            <div class="row breadcrumbs-top d-inline-block">
              <div class="breadcrumb-wrapper col-12">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="#">Home</a>
                  </li>
                  <li class="breadcrumb-item"><a href="#">Invoice </a>
                  </li>
                  <li class="breadcrumb-item active">Invoice List
                  </li>
                </ol>
              </div>
            </div>
          </div>
        
        </div>
        <div class="content-body"><!-- Zero configuration table -->
<section id="configuration">
    <div class="justify-content-md-center">
       <div class="col-md-12">
            <div class="card">
               
                <div class="card-content collapse show">
                    <div class="card-body card-dashboard">
                       
                        
                        	<form method="post" autocomplete="off" action="<?php echo site_url('Invoice/search_invoice/');?>" method="POST">
                        	<div class="row justify-content-md-center">
							
								<div class="col-md-3">
									<div class="form-group">
										<input class="form-control pickadate datepicker picker__input picker__input--active" type="text" name="from_date"  id="uk_dp_1" required data-uk-datepicker="{format:'DD-MM-YYYY'}" placeholder="From Date">
									</div>
								</div>
								
								<div class="col-md-3">
									<div class="form-group">
										<input class="form-control pickadate datepicker picker__input picker__input--active" type="text" name="to_date"  id="uk_dp_1" required data-uk-datepicker="{format:'DD-MM-YYYY'}" placeholder="To Date">
										<input class="form-control" type="hidden" name="sub_mod_id"  id="sub_mod_id"   value="<?php  if(isset($_POST['sub_mod_id'])) { echo $_POST['sub_mod_id']; }else { echo $sub_mod_id; }?>">
									</div>
								</div>	
								<div class="col-md-2">
									<div class="form-group">
										<select id="outlet_name" name="outlet_name" class="select2 prm" required>
											<option value="">Select Customer</option>
											<option value="All">All</option>
											<?php
											
												foreach($getCustomer as $gc){
												?>
												<option value="<?php echo $gc->cust_name ?>"><?php echo $gc->cust_name ?></option>
												<?php
												}
											?>
										</select>
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<select id="item_name" name="item_name" class="select2"  >
											<option value="">Select Item...</option>
											<option value="All">All</option>
											<?php

												foreach($getItemList as $gi){
												?>
												<option value="<?php echo $gi->item_name ?>"><?php echo $gi->item_name ?></option>
												<?php
												}
											?>
										</select>
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<input type="submit" name="submit" class="btn btn-primary" value="Invoice Report">
									</div>
								</div>
							
						</div>
						</form>
						<div class="table-responsive">
                        	<?php
				if(isset($_POST['submit'])) {
					 
					if (isset($result_display)) {
						//echo "<p><u>Result</u></p>";
						if ($result_display == 'No record found !') {
							echo $result_display;
							} else {
						?>
					
								</br>
				<?php
				if($_POST['from_date']!="" && $_POST['to_date']!="" && $_POST['outlet_name']!="" && $_POST['item_name']==""){
					if($_POST['outlet_name'] != 'All') {
					?>
								   <table class="table table-striped table-bordered dataex-html5-export">
								<thead>
									<tr>
										<th>Issues No</th>
										<th>Issues Date</th>
										<th>Outlet Name</th>
										<th>Total</th>
										<th>View</th>
										<!--<th>Rejection</th>	-->
									</tr>
								</thead>
								<tbody>
									
										<?php
											if(isset($result_display) && is_array($result_display) && count($result_display)): $i=1;
											foreach ($result_display as $record) { 
											?>
											?>
											<tr>
												<td><?php echo $record['invoice_no']; ?></td>
												<td><?php echo $record['invoice_date']; ?></td>
												<td><?php echo $record['outlet_name']; ?></td>
												<td><?php echo $record['total']; ?></td>
												<td class="uk-text-nowrap">
													
													<a href="<?php echo site_url('Invoice/viewInvoice/'. $record['invoice_id'].'/'.$sub_mod_id); ?>"  id="view" name="view" class="btn btn-sm btn-primary">View</a>
													
												</td>
											</tr>
											<?php
												 $i++;
											}
											else:
										?>
										<tr>
											<td colspan="5" align="center" >No Records Found..</td>
										</tr>
										<?php
											endif;
										?>
									</tbody>
								</table>
							<?php 	
						
					}
					else if($_POST['outlet_name'] == 'All'){
					?>
					  <table class="table table-striped table-bordered dataex-html5-export">
								<thead>
									<tr>
										<th>Issues No</th>
										<th>Issues Date</th>
										<th>Outlet Name</th>
										<th>Total</th>
										<th>View</th>
										<!--<th>Rejection</th>	-->
									</tr>
								</thead>
								<tbody>
									<?php
											if(isset($result_display) && is_array($result_display) && count($result_display)): $i=1;
											foreach ($result_display as $record) { 
											?>
											<tr>
												<td><?php echo $record['invoice_no']; ?></td>
												<td><?php echo $record['invoice_date']; ?></td>
												<td><?php echo $record['outlet_name']; ?></td>
												<td><?php echo $record['total']; ?></td>
												<td class="uk-text-nowrap">
													<a href="<?php echo site_url('Invoice/viewInvoice/'. $record['invoice_id'].'/'.$sub_mod_id); ?>"  id="view" name="view" class="btn btn-sm btn-primary">View</a>
												</td>
											</tr>
											<?php
												 $i++;
											}
											else:
										?>
										<tr>
											<td colspan="5" align="center" >No Records Found..</td>
										</tr>
										<?php
											endif;
										?>
									</tbody>
								</table>		
						<?php 
					}
				}
				else if($_POST['from_date']!="" && $_POST['to_date']!="" && $_POST['outlet_name']!="" && $_POST['item_name']!=""){
					if($_POST['outlet_name'] != 'All' && $_POST['item_name'] == 'All'){
				?>
				
				  <table class="table table-striped table-bordered dataex-html5-export">
							<thead>
								<tr>
									<th>Product Name</th>
									<th>Quantity</th>
									<th>Total</th>
									<!--<th>Rejection</th>	-->
								</tr>
							</thead>
							<tbody>
								<?php
											if(isset($result_display) && is_array($result_display) && count($result_display)): $i=1;
											foreach ($result_display as $record) { 
											?>
										<tr>
											<td><?php echo $record['item_name']; ?></td>
											<td><?php echo $record['qty']; ?></td>
											<td><?php echo $record['total']; ?></td>
										</tr>
										<?php
												 $i++;
											}
											else:
										?>
										<tr>
											<td colspan="3" align="center" >No Records Found..</td>
										</tr>
										<?php
											endif;
										?>
								</tbody>
							</table>		
						<?php
					
				?>
				<?php }
				else if($_POST['outlet_name'] == 'All' && $_POST['item_name'] != 'All'){
				?>	
					  <table class="table table-striped table-bordered dataex-html5-export">
							<thead>
								<tr>
									<th>Outlet Name</th>
									<th>Quantity</th>
									<th>Total</th>
									<!--<th>Rejection</th>	-->
								</tr>
							</thead>
							<tbody>
								<?php
											if(isset($result_display) && is_array($result_display) && count($result_display)): $i=1;
											foreach ($result_display as $record) { 
											?>
										<tr>
											<td><?php echo $record['outlet_name']; ?></td>
											<td><?php echo $record['qty']; ?></td>
											<td><?php echo $record['total']; ?></td>
										</tr>
										
										<?php
												 $i++;
											}
											else:
										?>
										<tr>
											<td colspan="3" align="center" >No Records Found..</td>
										</tr>
										<?php
											endif;
										?>
								</tbody>
							</table>
							<?php
					 }
				else if($_POST['outlet_name'] != 'All' && $_POST['item_name'] != 'All'){?>
					  <table class="table table-striped table-bordered dataex-html5-export">
							<thead>
								<tr>
								    <th>Item Name</th>
									<th>Quantity</th>
									<th>Total</th>
									<!--<th>Rejection</th>	-->
								</tr>
							</thead>
							<tbody>
								<?php
											if(isset($result_display) && is_array($result_display) && count($result_display)): $i=1;
											foreach ($result_display as $record) { 
											?>
										<tr>
										    <td><?php echo $record['item_name'];?></td>
											<td><?php echo $record['qty']; ?></td>
											<td><?php echo $record['total']; ?></td>
										</tr>
										<?php
												 $i++;
											}
											else:
										?>
										<tr>
											<td colspan="2" align="center" >No Records Found..</td>
										</tr>
										<?php
											endif;
										?>
								</tbody>
							</table>
							<?php
					
				} 
				else if($_POST['outlet_name'] == 'All' && $_POST['item_name'] == 'All') { 
					echo "No Data Exists";
				}
			?>
				<?php
				}
				/*else{
					echo "Please Enter the Data";
				}*/ ?>
						<?php }
					}
				}else{ ?>
                            <table  id="myTable" class="table table-striped table-bordered ">
                                <thead>
									<tr>
									    	<th>Sl No</th>
										<th>Invoice No</th>
								<th>Invoice Date</th>
								<th>Outlet Name</th>
								<th>Total Amount</th>
								<th>View </th>
									
									</tr>
								</thead>
							<!--	<tbody>
									<?php
								/*		
									if(isset($invoice) && is_array($invoice) && count($invoice)) : $i=1;
									foreach($invoice as $data){ 
											?>
											<tr>
										<td><?php echo $data->invoice_no; ?></td>
										<td><?php echo $data->invoice_date; ?></td>
										<td><?php echo $data->outlet_name; ?></td>
										<td><?php echo $data->value; ?></td>
										<td class="uk-text-nowrap">
											
											<a href="<?php echo site_url('Invoice/viewInvoice/'. $data->invoice_id.'/'.$sub_mod_id); ?>"  id="view" name="view" class="btn btn-sm btn-primary">View</a>
										</td>
									</tr>
											<?php } $i++;
								else:*/
							?>
							<tr>
								<td colspan="5" align="center" >No Records Found..</td>
							</tr>-->
							
							<?php
							/*	endif;*/
							?> 
							<!--	</tbody>-->
                                </table>

                                <?php } ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<!--/ Zero configuration table -->



<!--/ Language - Comma decimal place table -->

        </div>
      </div>
    </div>
    <!-- END: Content-->

   <?php //require('include/theme_customizer.php');?>
 <?php 
  $footer_file=APPPATH.'views/include/footer.php';
	require($footer_file);
	?>
<script>
	$('.param_check').each(function() { $(this).on( {'click contextmenu': function() {
		//contextmenu
		var i = $(this).data('value');
		var anchor = $("a");
		var anchorTarget = $(this).parent().find('.parmetre').val();
		var submodid = $(this).parent().find('.submod_id').val();
		var link = $(this).attr('href');
		$(this).attr("href", link + submodid +'/'+anchorTarget);

		location.reload();
	}
	})
	})
</script> 
<script type='text/javascript'>
    $(document).ready(function() {
        $("#myTable").DataTable({
           "ajax": '<?php echo base_url();?>index.php/Invoice/getInvoice',
            dom: "Bfrtip",
             displayLength: 25,
            buttons: ["copyHtml5", "excelHtml5", "csvHtml5", "pdfHtml5"]
    }) 
   });
</script>
  </body>
  <!-- END: Body-->

<!-- Mirrored from pixinvent.com/modern-admin-clean-bootstrap-4-dashboard-html-template/html/ltr/vertical-modern-menu-template/form-layout-basic.html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Apr 2020 09:38:02 GMT -->
</html>