<?php include('header.php');
$pickup_entry_ids=0;
if(isset($_GET['list_id'])){
    $pickup_entry_ids=$_GET['list_id'];
    $list_id=$_GET['list_id'];
}
$k=0;
function custom_echo($x, $length)
        {
          if(strlen($x)<=$length)
          {
            echo $x;
          }
          else
          {
            $y=substr($x,0,$length);
            echo $y."...";
          }
        }
        


function address_limit($addr){
      // strip tags to avoid breaking any html
    $string = strip_tags($addr);
    if (strlen($string) > 110) {
    
        // truncate string
        $stringCut = substr($string, 0, 110);
        $endPoint = strrpos($stringCut, ' ');
    
        //if the string doesn't contain any space then it will cut without word basis.
        $string = $endPoint? substr($stringCut, 0, $endPoint) : substr($stringCut, 0);
        $string .= '...';
    }
    echo $string;
}

function no_limit($addr){
      // strip tags to avoid breaking any html
    $string = strip_tags($addr);
    if (strlen($string) > 18) {
    
        // truncate string
        $stringCut = substr($string, 0, 18);
        $endPoint = strrpos($stringCut, ' ');
    
        //if the string doesn't contain any space then it will cut without word basis.
        $string = $endPoint? substr($stringCut, 0, $endPoint) : substr($stringCut, 0);
        $string .= '..';
    }
    echo $string;
}
?>
<script>
    setInterval(function(){ 
        $.ajax({
                url: 'api-error-log-list.php',
                type: 'post',
                data: {type:'error_log'},
                dataType: 'json',
                 success:function(response){
                     $('#error_log_msg').empty();
                   // alert(response[0]['status']);
                   // console.log(response);
                   if(response[0]['count']!=0){ $('#error_log_count').text(response[0]['count']);}
                   
                   
                   
                   var con='<ul class="menu" style="overflow: hidden; width: 100%; height: auto;"><li>'
                   for(var n=0;n<response[0]['count'];n++){
                       var msg=response[0]['status'][n]['text'];
                      // console.log(msg);
                       
                       con+='<a href="api-error_log.php" class="load_suspended">'+response[0]['status'][n]['created_at']+' '+response[0]['status'][n]['type']+'<br><strong>'+response[0]['status'][n]['text']+'</strong></a>';
                              
                   }
                   con+='</li></ul>';
                   $('#error_log_msg').append(con);
                }
        
            });    
}, 500);
</script>
  		<div style="background-color: white;"><div style="padding:10px;">


<br>
<center>
      <a class="btn btn-sm btn-danger " href="shipment-create.php"><i class="fa fa-plus"></i> Add New Cargo Entry</a>&ensp;
     <a href="booking-list.php"><button class="btn btn-sm btn-success"><i class="fa fa-list"></i> Back to List</button></a>
     &ensp;
    <a href="sls-shipment-invoice-label.php?list_id=<?php echo $list_id; ?>" target="_blank" ><button class="btn btn-sm btn-warning"> <i class="fa fa-print"></i> Invoice Label Print</button></a>
    <a href="sls-shipment-box-label.php?list_id=<?php echo $list_id; ?>" target="_blank" ><button class="btn btn-sm btn-danger"> <i class="fa fa-print"></i> Box Label Print</button></a>
    <a href="cargo-invoice.php?list_id=<?php echo $list_id; ?>" target="_blank"><button class="btn btn-sm btn-info"> <i class="fa fa-print"></i> Print Docket</button></a>
    </center><br>


<body >
    <?php 

$statement = $pdo->prepare("SELECT * FROM `pickup_entry` WHERE pickup_entry.id in ($pickup_entry_ids)");
$statement->execute();
$pickup_result = $statement->fetchAll(PDO::FETCH_ASSOC);

foreach($pickup_result as $pr){  ?>
<?php for($t=1;$t<=2;$t++){ ?>
<div>
<table>
    <tr>
        <td style="width:10%;border-right:none;" rowspan="2">
            <img src="img/logo.png" style="width:120px;" />
        </td>
        <td style="width:40%;border-left:none;font-size:14px;" rowspan="2">
            VKA Logistics Private Limited.<br>
            # 1240, 2nd Floor, 2nd Block, BEL Layout,<br>
            Vidyaranyapura,<br>
            Bangalore-560097<br>
            info@vkalogistics.com
        </td>
        <td style="width:50%;text-align:center;" colspan="2">
            <!--<img src="barcode/barcode.php?codetype=Code39&amp;size=40&amp;text=<?=$pr['cscs_awb']?>"/>-->
            <img alt="testing" class="img_bar" src="barcode/barcode.php?codetype=Code128&amp;size=40&amp;text=<?=$pr['cscs_awb']?>" style="width: 50%;height:40px"><br><b style="font-size:20px;font-weight:900;"><?=$pr['cscs_awb']?>
        </td>
    </tr>
    <tr>
        <td style="width:25%;text-align:center;">
            <?=date("d-M-Y", strtotime($pr['date_added']))?>
        </td>
        <td style="width:25%;text-align:center;">
            <?=$pr['cscs_awb']?>
        </td>
    </tr>
</table> 
<table>
    <tr>
        <td style="width:37.5%;border-top:none;font-weight:bold;"> Consignor / Sender (Name & Address) </td>
        <td style="width:37.5%;border-top:none;font-weight:bold;"> Consignee / Receiver (Name & Address)</td>
        <td style="width:25%;text-align:center;border-top:none;font-weight:bold;">
            Mode
        </td>
    </tr>
    <tr>
        <td style="font-size:11px;" >
            <p style="height: 100px;display: flex;align-items: center;">
            <?php if(isset($pr['shipper_name'])){ echo $pr['shipper_name'];}?>
            <?php if(isset($pr['shipper_address'])){ echo "<br>".$pr['shipper_address'];}?>
            <?php if(isset($pr['shipper_city'])){ echo "<br>".$pr['shipper_city'];}?>
            <?php if(isset($pr['shipper_pincode'])){ echo "-".$pr['shipper_pincode'];}?>
            <?php if(isset($pr['shipper_state'])){ echo "<br>".$pr['shipper_state'];}?>
            <?php if(isset($pr['shipper_phone'])){ echo "<br>Mobile : ".$pr['shipper_phone'];}?>
            </p>
        </td>
        <td style="font-size:11px;" >
            <p style="height: 100px;display: flex;align-items: center;">
            <?php if(isset($pr['consignee_name'])){ echo $pr['consignee_name'];}?>
            <?php if(isset($pr['consignee_address'])){ echo "<br>".$pr['consignee_address'];}?>
            <?php if(isset($pr['consignee_city'])){ echo "<br>".$pr['consignee_city'];}?>
            <?php if(isset($pr['consignee_pincode'])){ echo "-".$pr['consignee_pincode'];}?>
            <?php if(isset($pr['consignee_state'])){ echo "<br>".$pr['consignee_state'];}?>
            <?php if(isset($pr['consignee_phone'])){ echo "<br>Mobile : ".$pr['consignee_phone'];}?>
            </p>
        </td>
        <td style="width:25%;text-align:center;vertical-align:top;padding:0px;" rowspan="5">
                <table style="border:none;">
                    <tr>
                        <td colspan="2" style="text-align:center;border:none;padding:10px 5px;"><?=strtoupper($pr['business_mode'])?></td>
                    </tr> 
                    <tr>
                        <td style="width:50%;padding:7px 5px;border-left:none;">Freight</td>
                        <td style="border-right:none;"></td>
                    </tr>
                    <tr>
                        <td style="padding:7px 5px;border-left:none;">Docket</td>
                        <td style="border-right:none;"></td>
                    </tr>
                    <tr>
                        <td style="padding:7px 5px;border-left:none;">ODA</td>
                        <td style="border-right:none;"></td>
                    </tr>
                    <tr>
                        <td style="padding:7px 5px;border-left:none;">Fov</td>
                        <td style="border-right:none;"></td>
                    </tr>
                    <tr>
                        <td style="padding:7px 5px;border-left:none;">Total</td>
                        <td style="border-right:none;"></td>
                    </tr>
                    <tr>
                        <td style="padding:7px 5px;border-left:none;">GST Tax</td>
                        <td style="border-right:none;"></td>
                    </tr>
                    <tr>
                        <td style="padding:7px 5px;border-left:none;border-bottom:none;">Grant Total</td>
                        <td style="border-bottom:none;border-right:none;"></td>
                    </tr>
                </table>
            
        </td>
    </tr>
    <tr>
        <td>From : <?=strtoupper($pr['shipper_location'])?></td>
        <td>To : <?=strtoupper($pr['consignee_location'])?></td>
    </tr>
    <tr>
        <td>GST NO : <?=strtoupper($pr['seller_gst'])?></td>
        <td>GST NO : <?=strtoupper($pr['buyer_gst'])?></td>
    </tr>
    <tr>
        <td colspan="2" style="padding:0px;vertical-align:top;">
            <table>
                <tr>
                    <td style="width:20%;border-top:none;border-left:none;">Contain</td>
                    <td style="width:20%;border-top:none;"><?=strtoupper($pr['product_description'])?></td>
                    <td style="text-align:center;font-weight:bold;border-top:none;border-right:none;">Acknowledgement</td>
                </tr>
                <tr>
                    <td style="width:20%;border-left:none;">PCS</td>
                    <td style="width:20%;"><?=$pr['boxes']?></td>
                    <td rowspan="4" style="border-right:none;border-bottom:none;padding-left:30px;">
                        Name
                        
                        <br><br><br>Stamp
                        
                    </td>
                </tr>
                <tr>
                    <td style="width:20%;border-left:none;">Book Type</td>
                    <td style="width:20%;"><?=strtoupper($pr['order_type'])?></td>
                </tr>
                <tr>
                    <td style="width:20%;border-left:none;">Amount</td>
                    <td style="width:20%;"><?=$pr['taxable_value']?></td>
                </tr>
                <tr>
                    <td style="width:20%;border-bottom:none;border-left:none;">Weight (Kg)</td>
                    <td style="width:20%;border-bottom:none;"><?php if($pr['c_weight']!=""){ echo $pr['c_weight'];}else{ echo $pr['a_weight'];}?></td>
                </tr>
            </table>
            
        </td>
    </tr>
</table>
<table>
    <tr>
        <td style="width:20%;border-top:none;">Remark</td>
        <td colspan="3" style="border-top:none;"><?=$pr['remarks']?></td>
    </tr>
    <tr>
        <td colspan="2" style="border-bottom:none;font-size:12px;text-align:center;">
            I/We declare that this consignment does not contain personal mail, cash, jewellery, contraband, illegal drugs,
            any prohibited items and commodities which can cause safety hazards while transporting declared value of
            goods is true and accurate.
        </td>
        <td style="width:30%;vertical-align:top;" rowspan="3">
            Invoice No  : &nbsp;<?=$pr['invoice_no']?><br>
            Invoice Value  : &nbsp;<?=$pr['invoice_value']?><br>
            Eway Bill  : &nbsp;<?=$pr['ewaybill']?>
        </td>
    </tr>
    <tr>
        <td colspan="2" style="border-top:none;font-size:10px;">
            <b>Consignor Signature :</b>
        </td>
    </tr>
    <tr>
        <td colspan="2" style="font-size:12px;text-align:center;">
            <b>T & C: </b>Incase the Consigments value is more than Rs: 1000/- The VKA Logistics recomends to get the same
            insured. the company liability on this shipment is limited to Rs. 100/- or cost of the reconstruction whichever is
            lower. customer are requested to please put right Pincode of Destination for timely delivery. weight taken in
            our company's permises. Actual or Valuemetric weight whichever is higher will be considered as the final
            weight.
        </td>
    </tr>
</table>
</div>
<?php if($t==1) { echo '<hr class="dashed">'; } ?>
<?php } ?>


<?php } ?>
</body >

<style>
    table{
        width:100%;
        border-collapse:collapse;
        font-size:14px;
    }
    td{
        border:1px solid black;
        border-collapse:collapse;
        padding:2px 5px;
    }
    .dashed {border-style: dashed;
    margin-top: 12px;
    margin-bottom: 12px;
   }
    
@page  
{    margin: 5mm 5mm 5mm 5mm;  } 
body  
{  margin: 0px;  } 
</style>

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