<?php
   ob_start();
   session_start();
   include("inc/config.php");
   include("inc/functions.php");
   include("inc/CSRF_Protect.php");
   ?>
<?php 
   $list_id=array();
   $list_id=$_GET['list_id'];
   
   
   $li=explode(",",$list_id);
   
   function custom_echo($x, $length)
   {
     if(strlen($x)<=$length)
     {
       echo $x;
     }
     else
     {
       $y=substr($x,0,$length);
       echo $y."....";
     }
   }
   $counts=1;
         foreach($li as $lid){
        $list_id1=100001;
               $i=0;
       			$statement = $pdo->prepare("SELECT pickup_entry.*,tbl_branch.name as branch_name,tbl_branch.mobile_no as branch_mobile,tbl_branch.alter_mobile_no as branch_alter_no,tbl_branch.address as branch_address,tbl_branch.gst_no as branch_gstno,tbl_branch.state as branch_state,tbl_branch.email as branch_email FROM `pickup_entry` INNER JOIN tbl_branch ON tbl_branch.id WHERE pickup_entry.id='$lid'");
       		
       		$statement->execute();
       		$result = $statement->fetchAll(PDO::FETCH_ASSOC);
       	// 	print_r($result);
        
        foreach ($result as $row) {
           // Location Details Starts Here
        $location_name = $row['branch_name'];
        $location_mobile = $row['branch_mobile']; 
        $location_address = $row['branch_address'];
        $location_state = $row['branch_state'];
        $location_email = $row['branch_email']; 
        $location_gst_no = $row['branch_gstno'];
        // Location Details Endsss Here
        
        $cust_address=$row['consignee_address'];
        $cust_phone=$row['consignee_phone'];
        $cust_name=$row['consignee_name'];
        $consignee_city=$row['consignee_city'];
        $consignee_state=$row['consignee_state'];
        $consignee_pincode=$row['consignee_pincode'];
        
        //$client_name=$row['consignee_name'];
        
        $shipper_name=$row['shipper_name'];
        $client_address=$row['shipper_address'];
        $client_city=$row['shipper_city'];
        $client_state=$row['shipper_state'];
        $client_phone=$row['shipper_phone'];
        $pincode=$row['shipper_pincode'];
        
        
       /* $is_return_awb=$row['is_return_awb'];
        $client_destination=$row['location'];*/
        
        $pieces=$row['boxes'];
        $c_weights=$row['c_weight'];
        $gst=$row['gst'];
        $a_weights=$row['a_weight'];
        $total_charges=$row['tc'];
        $other_charges=$row['oc'];
        $desc=$row['content'];
        $pay_mode=$row['pay_mode'];
        $dest=$row['dest'];
        $destination=$row['destination'];
        $picklist_no=$row['picklist_no'];
        $day=date_create($row['created']);
        $date=date_format($day,'d-m-Y');
        $bar=$row['cscs_awb'];
        //$code=$row['code'];
        $short_location=$row['short_location'];
        $location=$row['location'];
        $invoice_no=$row['id'];
        $invoice_nos=$row['invoice_no'];
        $invoice_value=$row['invoice_value'];
        $e_way_bill_no=$row['ewaybill'];
        $content_desc=$row['product_description'];
        
        $office_customer_name=$row['office_customer_name'];
        $office_customer_address=$row['office_customer_address'];
        $client_id=$row['client_id'];
        $entry_type=$row['business_mode'];
        $uni_client_only=$row['new_client_id'];
         
         
         
         $pickup_id_volumetric=$row['id'];
     
   }?>
<?php for($i=1;$i>0;$i--){
   ?>
<?php for($d=$pieces;$d>=1;$d--){
   //  	$statement34 = $pdo->prepare("SELECT id FROM `tbl_client_new` where id=163");
   // 		$statement34->execute();
   // 		$result34 = $statement34->fetch(PDO::FETCH_ASSOC);
        if(163==$uni_client_only){
    	 if($d!=$pieces){
   // 	 };
   
   ?>
<div style="min-width: 80mm !important; min-height:50mm;max-width: 80mm !important; max-height:50mm;font-size:9px;
   -ms-flex-align: center;
   -webkit-align-items: center;
   -webkit-box-align: center;
   ">
   <div style="padding:5px;">
      <table style="width:100%;">
         <tr>
            <td style="width:50%;">
               <center>
                  <!--<b style="font-size:9px;">
                     AWB No  </b><br>--> 
                  <img alt='Barcode' style="width:150px;max-width:150px;max-height:30px;padding-bottom:2px;" src='barcode/barcode.php?codetype=Code128&size=35&text=<?=$bar?>'/>
                  <br><b style="font-size:16px;letter-spacing:3px;"><?=$bar?></b>
               </center>
            </td>
            <td style="width:50%;">
               <center>
                  <img src="https://vka-logistics.fms-logistics.in.net/img/logo.png" width="120px" style="padding-left: 2px;height:40px;">
               </center>
            </td>
         </tr>
      </table>
      <table style="width:100%;">
         <tr>
            <td style="width:70%;">
               <b style="font-size:9px;">DP Code  &ensp;: </b><b style="font-size:11px;font-weight:700;">1239</b>
            </td>
            <td style="width:30%;">
               <b style="font-size:9px;">Date</b><b style="font-size:9px;font-weight:700;"> : <?php echo $date; ?></b>
            </td>
         </tr>
      </table>
      <table width="100%" style="font-size:9px;">
         <tr>
            <td width="20%" style="vertical-align:top;"><b>Name</b></td>
            <td> &ensp;:</td>
            <td><b><?=custom_echo($cust_name, 45); ?></b></td>
         </tr>
      </table>
      <?php if(isset($invoice_no) && $invoice_no!='' && $invoice_no!=' '){  //$client_id==80 &&  ?>      
      <table style="width:100%;">
         <tr>
            <td >
               <b style="font-size:9px;">Mobile No &ensp;: </b> <b style="font-size:9px;"><?php echo custom_echo(str_replace("$","",$cust_phone), 13); ?></b>
            </td>
            <td style="width:50%;">
               <b style="font-size:9px;">Inv No</b><b style="font-size:9px;font-weight:700;"> : <?php echo custom_echo($invoice_nos, 60); ?></b>
            </td>
         </tr>
      </table>
      <?php }else{ ?>
      <table style="width:100%;">
         <tr>
            <td >
               <b style="font-size:9px;">Mobile No &ensp;: </b> <b style="font-size:9px;"><?php echo custom_echo(str_replace("$","",$cust_phone), 40); ?></b>
            </td>
         </tr>
      </table>
      <?php } ?>
      <table width="100%" style="font-size:9px;">
         <tr>
            <td colspan="3"><b>Address : <span style="font-size:9px;"><?=custom_echo($cust_address, 120); ?> </span></b></td>
         </tr>
         <tr>
            <td >
               <b>
                  No Of Box
            </td>
            <td> &ensp;:</b></td>
            <td><b style="font-size:14px;">&ensp;<b style="font-size:14px;"><?php echo str_pad($d, 2, '0', STR_PAD_LEFT); ?>&ensp;/&ensp;<?php echo str_pad($pieces, 2, '0', STR_PAD_LEFT); ?></b> 
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <?php if($actual_wt_label==1){ ?>
               <span ><b>Wt :</b> <b style="font-size:14px;"><?=$a_weights?></b></span>
               <?php } ?>
            </td>
         </tr>
         <tr>
            <td ><b>City</b></td>
            <td width="1%"> &ensp;:</td>
            <td><b style="font-size:14px;"><?=$consignee_city?></b></td>
         </tr>
      </table>
   </div>
</div>
<?php 
   }  }
   else{
       
       ?>
       <div style="min-width: 80mm !important; min-height:50mm;max-width: 80mm !important; max-height:50mm;font-size:9px;
   -ms-flex-align: center;
   -webkit-align-items: center;
   -webkit-box-align: center;
   ">
   <div style="padding:5px;">
          <table style="width:100%;">
             <tr>
                <td style="width:50%;">
                   <center>
                      <!--<b style="font-size:9px;">
                         AWB No  </b><br>--> 
                      <img alt='Barcode' style="width:150px;max-width:150px;max-height:30px;padding-bottom:2px;" src='barcode/barcode.php?codetype=Code128&size=35&text=<?=$bar?>'/>
                      <br><b style="font-size:16px;letter-spacing:3px;"><?=$bar?></b>
                   </center>
                </td>
                <td style="width:50%;">
                   <center>
                      <img src="https://vka-logistics.fms-logistics.in.net/img/logo.png" width="120px" style="padding-left: 2px;height:40px;">
                   </center>
                </td>
             </tr>
          </table>
          <table style="width:100%;">
             <tr>
                <td style="width:70%;">
                   <b style="font-size:9px;">DP Code  &ensp;: </b><b style="font-size:11px;font-weight:700;">1239</b>
                </td>
                <td style="width:30%;">
                   <b style="font-size:9px;">Date</b><b style="font-size:9px;font-weight:700;"> : <?php echo $date; ?></b>
                </td>
             </tr>
          </table>
          <table width="100%" style="font-size:9px;">
             <tr>
                <td width="20%" style="vertical-align:top;"><b>Name</b></td>
                <td> &ensp;:</td>
                <td><b><?=custom_echo($cust_name, 45); ?></b></td>
             </tr>
          </table>
          <?php if(isset($invoice_no) && $invoice_no!='' && $invoice_no!=' '){  //$client_id==80 &&  ?>      
          <table style="width:100%;">
             <tr>
                <td >
                   <b style="font-size:9px;">Mobile No &ensp;: </b> <b style="font-size:9px;"><?php echo custom_echo(str_replace("$","",$cust_phone), 13); ?></b>
                </td>
                <td style="width:50%;">
                   <b style="font-size:9px;">Inv No</b><b style="font-size:9px;font-weight:700;"> : <?php echo custom_echo($invoice_nos, 60); ?></b>
                </td>
             </tr>
          </table>
          <?php }else{ ?>
          <table style="width:100%;">
             <tr>
                <td >
                   <b style="font-size:9px;">Mobile No &ensp;: </b> <b style="font-size:9px;"><?php echo custom_echo(str_replace("$","",$cust_phone), 40); ?></b>
                </td>
             </tr>
          </table>
          <?php } ?>
          <table width="100%" style="font-size:9px;">
             <tr>
                <td colspan="3"><b>Address : <span style="font-size:9px;"><?=custom_echo($cust_address, 120); ?> </span></b></td>
             </tr>
             <tr>
                <td >
                   <b>
                      No Of Box
                </td>
                <td> &ensp;:</b></td>
                <td><b style="font-size:14px;">&ensp;<b style="font-size:14px;"><?php echo str_pad($d, 2, '0', STR_PAD_LEFT); ?>&ensp;/&ensp;<?php echo str_pad($pieces, 2, '0', STR_PAD_LEFT); ?></b> 
                   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                   <?php if($actual_wt_label==1){ ?>
                   <span ><b>Wt :</b> <b style="font-size:14px;"><?=$a_weights?></b></span>
                   <?php } ?>
                </td>
             </tr>
             <tr>
                <td ><b>City</b></td>
                <td width="1%"> &ensp;:</td>
                <td><b style="font-size:14px;"><?=$consignee_city?></b></td>
             </tr>
          </table>
       </div>
    </div>
       <?php }
   
}

   }
   
   // }
   
     $counts++; 
   }
   ?>	 
<style type="text/css">
   td{
   line-height:11px;
   }
   body{
   margin:0px !important;
   font-family: sans-serif !important;
   }
   @media  print{
   @page  {
   size: 80mm 50mm;
   margin-top: 0in !important;
   margin-bottom: 0in !important;
   margin-left: 0in !important;
   margin-right: 0in !important;
   }
   }
</style>
<script> 
   setTimeout(function () { window.print(); }, 100);
          window.onfocus = function () { setTimeout(function () { window.close(); }, 100); }
</script>