<?php require_once('header.php'); 
 
$list_id=array();
$list_id=$_GET['list_id'];
$li=explode(",",$list_id);
?>

<section class="content-header">
	<div class="content-header-left form-group" >
		<center>
            <input type="button" class="btn btn-info" onclick="printDiv('printableArea')" value="Print Lable" />&ensp;
            <a href="awb_number_print.php?list_id=<?php echo $list_id; ?>" ><button class="btn btn-md btn-danger">Print AWB Number</button></a>
    </center><br>
	</div>
</section>
<input type="hidden" id="client_type" name="client_type" value="<?php echo $clientType; ?>">
<section class="content">
	 <?php
     
      function custom_echo($x, $length)
        {
          if(strlen($x)<=$length)
          {
            echo $x;
          }
          else
          {
            $y=substr($x,0,$length);
            echo $y;
          }
        }
     
      foreach($li as $lid){
     $list_id1=100001;
            $i=0;
    	
    		
    			$statement = $pdo->prepare("SELECT pk.*,tbu.gst_no,tbu.full_name as branchName FROM `pickup_entry`pk INNER JOIN tbl_user tbu ON pk.client_id=tbu.id WHERE pk.id=$lid");
    		
    		$statement->execute();
    		$result = $statement->fetchAll(PDO::FETCH_ASSOC);
     
     foreach ($result as $row) {
     $branchName=$row['branchName'];
     $pin_city=$row['consignee_city'];
     $cust_address=$row['rto_address'];
     $cust_phone=$row['rto_phone'];
     $cust_name=$row['rto_name'];
     $client_name=$row['consignee_name'];
     $client_address=$row['consignee_address'];
     $client_city=$row['consignee_city'];
     $client_state=$row['consignee_state'];
     $client_phone=$row['consignee_phone'];
     $pieces=$row['boxes'];
     $c_weights=$row['c_weight'];
     $gst=$row['gst_no'];
     $gst_amount=$row['gst_amount'];
     $a_weights=$row['a_weight'];
     $total_charges=$row['invoice_value'];
     $other_charges=$row['taxable_value'];
     $desc=$row['product_description'];
     $pay_mode=$row['gst_rate'];
     $dest=$row['consignee_city'];
     $day=date_create($row['date_added']);
     $date=date_format($day,'d-m-Y');
     $bar=$row['cscs_awb'];
     $code=$row['cscs_awb'];
     $mrp=$row['mrp'];
     }?>

	<div id="printableArea">
	  
	 <?php for($i=$pieces;$i>0;$i--){?>
	    <center>
	        <!--<div style="border: 1px solid black;">-->
<table style="width:70mm;height:38mm;margin-top:0px;">
    <tr>
        <td>
            <img src="img/cscs_logo.png"   style="padding-left: 0px;padding-top: 3px;width:90px;height:70px;">
        </td>
        <td style="margin-left:14px;">
            <!--<img src="unnamed.png" width="100px" height="20%" style="padding-left: 10px;padding-top: 3px">-->
             <?php 
                 echo "<img alt='testing' src='barcode/barcode.php?codetype=Code39&size=24&text=".$bar."&print=true'/>";
    		    ?>
        </td>
    </tr>
     <tr>
        <td><b>Date</b></td>
        <td><b> : <?php echo $date; ?></b></td>
    </tr>
    <tr>
        <td><b>Ref No</td>
        <td><b> : <?php echo $bar; ?></b></td>
    </tr>
    <tr>
        <td><b>Name</td>
        <td> <b>:
<?php custom_echo($client_name, 12);
        
        // echo $client_name;
        ?></b></td>
    </tr>
    <tr>
        <td><b>City</td>
        <td> <b>: <?php echo $dest; ?></b></td>
    </tr><tr>
        <td><b>Boxes</td>
        <td><b> :<?php echo $i; ?>/<?php echo $pieces; ?></b></td>
    </tr>
    
</table>
<!--</div>-->
<span class="brmedium"></span>


<?php 
 }?>
 
   
 <?php }
?>
</div>

</section>


<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Delete Confirmation</h4>
            </div>
            <div class="modal-body">
                <p>Are you sure want to delete this HSNCode ?</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-sucess" data-dismiss="modal">Cancel</button>
                <a class="btn btn-sucess btn-ok">Delete</a>
            </div>
        </div>
    </div>
</div>

<script>
var doc = new jsPDF();
var specialElementHandlers = {
    '#print-btn': function (element, renderer) {
        return true;
    }
};

$('#submit').click(function () {
    doc.fromHTML($('#print').html(), 15, 15, {
        'width': 1070,
            'elementHandlers': specialElementHandlers
    });
    doc.save('pdf-version.pdf');
});
 
  function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}

  $(function () {
    $("#example1").DataTable();
    $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false,
    });
  });
</script>

<?php require_once('footer.php'); ?>