<!-- Content Wrapper. Contains page content -->
<?php
$userRol = $_SESSION['USERS_DATA']['userType'];
$userId = $_SESSION['USERS_DATA']['userId'];
if($userRol==1){
    $userName = "Wholesaler Name";
}
?>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header mb_6">
      <h1><?php if(!empty($cancelCustomer)){ echo $cancelCustomer." ";} ?>Cancelled Orders</h1>
    </section>
    <section class="content-header cancelled_data">
        <div class="row align_items_end">
            <div class="col-lg-8 col-md-8 col-sm-6 col-xs-12">
                <div class="date_filter">
                    <form id="flight" class="datefilter" method="post" action="directsales/cancelled_orders">
                       <input type="hidden" id="customer_id" value="<?php if(!empty($customer_id)){echo $customer_id;} ?>" >
                       <input type="hidden" id="customerRol" value="<?php if(!empty($cancelCustomer)){echo 'customer';} ?>" >
                      <label>
                        From date <br/>
                        <input type="text" class="form_date form-control hasDatepicker" name="arrival"  value="<?php if(!empty($from)){echo $from;} ?>"/>
                      </label>
                     
                      <label>
                        To date <br/>
                        <input type="text" name="departure" class="to_date form-control hasDatepicker" value="<?php if(!empty($to)){echo $to;} ?>" />
                      </label>
                      <label>
                        <br/>
                        <input type="submit" value="submit" class="btn btn-primary" />
                      </label>
                    </form>
                </div>
            </div>
            <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                 <select id="cancelCustomer" class="form-control status_control mt_20 max_width">
                    <option disabled selected>Select Order status</option>
                    <option <?php if(!empty($cancelCustomer) && $cancelCustomer=="Customers"){echo "selected";} ?> value="Customers">Customer Order</option>
                 </select>
            </div>
        </div>
    </section>
    <!-- Main content -->
    <section class="content">
		<div class="row">			
	<div class="col-lg-12">
		<div class="box">
            <div class="box-body">
			<div class="table-responsive">
              <table id="hdlOrderCancel" class="table table-bordered table-striped">
				<thead>
                <tr>
                  <th>No.</th>
                  <th>Order No.</th>
                  <th>Order Date</th>
                  <th>Cancelled Date</th>
                  <?php if(!empty($userName)){ echo "<th>".$userName."</th>";} ?>
                  <th>Customer Name</th>
				  <th>Total Amount</th>
				  <th>View</th>  
                </tr>
                </thead> 
                <tbody id="invoice_list">
				<?php  $total_amount = 0; if(!empty($allsales_invoice)){ 
					$countsales = count($allsales_invoice);
					$i = $countsales;
					$a =1;
					foreach($allsales_invoice as $sales_invoice){ 
				?>
                <tr>
					<td><?php if(!empty($sales_invoice['id'])){ echo $a; }?></td>
					<td><?php if(!empty($sales_invoice['id'])){ echo $sales_invoice['id']; }?></td>
					<td><?php if(!empty($sales_invoice['saleDate'])){
					    $date = $sales_invoice['saleDate'];
                    $rdate = str_replace("/","-",$date);
                    $datem =date_create($rdate);
                    echo date_format($datem,"d-M-Y");
					
					} ?></td>
					<td><?php if(!empty($sales_invoice['deliveryDate'])){ 
					$date=date_create($sales_invoice['deliveryDate']);
                    echo date_format($date,"d-M-Y");
					}?></td>
			    	<?php if(!empty($userName)){ echo "<td>".$sales_invoice['wholName']."</td>"; }?>
					<td><?php if(!empty($sales_invoice['userName'])){ echo $sales_invoice['userName']; }?>
					</td>
					
					<td><?php if(!empty($sales_invoice['totalAmount'])){ echo $sales_invoice['totalAmount']; }?></td>
					
					<td class="text-center">
					
					<button class="btn-success icon_btn wholesales_InvoiceViewbtn" data-saleinvoiceid="<?php echo $sales_invoice['id']; ?>" title="View"><i class="fa fa-eye"></i></button>
					
					</td>
                </tr> 
				<?php 
				$a++;
				$i--;  
				}
				?>
				<?php
				
				} 
				
				?> 
                </tbody>
                <tfoot> 
                <tr>
                  <th>No.</th>
                  <th>Order No.</th>
                  <th>Order Date</th>
                  <th>Cancelled Date</th>
                  <?php if(!empty($userName)){ echo "<th>".$userName."</th>";} ?>
                  <th>Customer Name</th>
				  <th>Total Amount</th>
				  <th>View</th>  
                </tr>
                </tfoot>
              </table>
			  <input type="hidden" value="<?php echo $total_amount; ?>" name="total_subtotal">
            </div>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
		</div>
	<!-------------------------- Sale Invoice Table End------------------------------->	
	</section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->


  
  
<!---------------------- View Invoice Popup ---------------->

		 
		<div class="modal fade" id="mfw_wholesales_invoice">
			<div class="modal-dialog modal-lg">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close mfwPopUpClose"  id="mfw_salepartyclose" data-dismiss="modal" aria-label="Close">
						<i class="fa fa-remove" class="remover"></i></button> 
						<h4 class="modal-title">Order Invoice</h4>
					</div>
			  
					<div class="box-footer">
						<button  class="btn btn-primary pull-right" onclick="printDiv()" id="mfwGenerateInvoice">Print</button>
					</div>
					<div class="modal-body" id="purchase_report_modal">
					  
					</div> 
				</div>
            <!-- /.modal-content -->
          </div>
          <!-- /.modal-dialog -->
        </div>
        <!-- /.modal --> 
<!---------------------- View Invoice Popup ----------------> 
 
  
  
  
  
  