<!DOCTYPE html>
<html>

<head>
    <title>Packing List</title>
   
</head>

<body>

    <div class="">
        <div class="col-6">
            <br>
            <?php
                         $model_Delivery = DeliveryNote::model()->findByPk($id);
?>
                <!--<span style="color:#1e62a3;font-size: 18px;margin-bottom: 25px"><b><?php// echo $title." # ".$model->id;?></b></span><br>-->
                <div class="h3" style="margin-top: 0;margin-bottom: 0;">
                    <?php echo "PACKING LIST"; ?>
                </div>
                <div class="input-block">
                    <b><?php echo $id;?></b>
                </div>
                <b><?php echo $model_Delivery->customer->customer_name; ?></b>
                <br/>
                  <?php if($model_Delivery->billing_address != '') {     ?>       
                <small><?php echo strtoupper(nl2br($model_Delivery->billing_address)); ?></small><br>
                    <?php } ?>   
                <small><?php echo  $model_Delivery->customer->customer_city.PHP_EOL.$model_Delivery->customer->country->country_name; ?></small><br>
                <small><?php echo  $model_Delivery->customer->customer_phone_no; ?></small><br>
        </div>
        <div class="col-5 offset-1" style="color:#101010;">
            <div class="text-right">
                <img src="<?php echo Yii::app()->baseUrl . '/images/logo/'.Yii::app()->user->pdf_company_logo; ?>" class="logo">
            </div>
            <br>
            <table class="table" style="width:100%">
                <tr>
                    <?php
            $model_lead=Lead::model()->find(array('condition'=>'file_id="'.$model_Delivery->file_id.'"'));
            ?>
                        <td class="bc-tl">File ID</td>
                        <td>
                            <?php echo $model_Delivery->file_id;?>
                        </td>
                </tr>
                <tr>
                    <td>Customer ID</td>
                    <td>
                        <?php echo $model_Delivery->company_id;?>
                    </td>
                </tr>
                <tr>
                    <td>Customer TRN #</td>
                    <td>
                        <?php echo $model_Delivery->customer->customer_trn_no;?>
                    </td>
                </tr>
                <tr>
                    <td>Customer Shj. Imp. Code</td>
                    <td>
                        <?php echo $model_Delivery->customer->customer_shj_imp_code;?>
                    </td>
                </tr>
                 <tr>
                    <td>Order #</td>
                    <td>
                        <?php echo $model_Delivery->order_id;?>
                    </td>
                </tr>

                <tr>
                    <td>Delivery Date</td>
                    <td>
                        <?php echo date('d/m/Y',STRTOTIME($model_Delivery->delivery_date));?>
                    </td>
                </tr>
                <tr>
                    <td>Currency</td>
                    <td>
                        <?php echo "AED";?>
                    </td>
                </tr>
                 <tr>
                    <td>LPO</td>
                    <td>
                          <?php echo $model_Delivery->lpo;?>
                    </td>
                </tr>
                <?php
                if(isset($model_lead->leadowner->first_name) && $model_lead->leadowner->first_name!="") {
                    ?>
                <tr>
                    <td colspan="2">
                        <?php echo $model_lead->leadowner->first_name.' '.$model_lead->leadowner->last_name.' , '.$model_lead->leadowner->phno;?>
                    </td>
                </tr>
                <?php 
                }
                ?>
            </table>
        </div>
    </div>
    <br>
    <div class="col-md-12">
        <table id="" class="table">
            <thead>
                <tr>
                    <th class="text-center" style="width:5%">No</th>
                    <th class="text-center" style="width:15%">Part No</th>
                    <th class="text-center" style="width:30%">Description</th>
                    <th class="text-center" style="width:5%">Ord. Qty</th>
                    <th class="text-center" style="width:5%">Unit</th>
                    <th class="text-center" style="width:5%">Delivered Qty</th>
                </tr>
            </thead>
            <tbody>
               
                    <?php
                $m=1;
                $condition .= '1=1';
                $condition .= ' AND t.delivery_note_id ="' . $id.'"';
                $total=0;
                $model_DeliveryItems = DeliveryNoteItem::model()->findAll(array('condition'=>$condition,'order' => 'id ASC'));
                foreach ( $model_DeliveryItems as $i =>  $each_DeliveryItem) {
                    
                    if($each_DeliveryItem->product->inventory_type == '2'){
                        ?>
                        <tr style="background: red;">
                            <td colspan="7"><?php echo $each_DeliveryItem->description;?></td>
                        </tr>
                
                        <?php
                    }                    
                    else
                    { 
                  
                ?>
                 <tr>
                        <td>
                            <?php echo ($i+1);?>
                        </td>
                        <td>
                            <?php echo $each_DeliveryItem->product->part_number;?>
                        </td>
                        <td>
                            <?php echo nl2br($each_DeliveryItem->description);?>
                        </td>

                        <td class="text-right">
                            <?php echo Yii::app()->numberFormatter->formatCurrency($each_DeliveryItem->quantity," ");?>
                        </td>
                        <td>
                            <?php echo $each_DeliveryItem->unitdetails->name;?>
                        </td>
                        <td>
                            <?php  echo $each_DeliveryItem->picked_qty;?>
                        </td>
                        
                </tr>
                
                    <?php
       
        } 
        }
        ?>
                 

            </tbody>
        </table>
      
    </div><br>
      <?php if($model_Delivery->remarks!='')
       {
       ?>
         <div class="box" style="width: 100%">
            <h5>Remarks</h5><br/>
            <div class="h5sub-details">
                <?php echo nl2br($model_Delivery->remarks); ?>
            </div>
        </div><br>
        <?php } ?>
        <?php if($model_Delivery->terms_and_conditions!='')
       {
       ?>
       <div class="box" style="width: 100%">
            <h5>Terms and Conditions</h5><br/>
            <div class="h5sub-details">
                <?php echo $model_Delivery->terms_and_conditions; ?>
            </div>
       </div><br>
        <?php
       }
      ?>
    <?php if($model_Delivery->shipping_conditions!='')
        {      ?>
        <div class="box" style="width: 100%">
            <h5>Shipping Condition</h5><br/>
            <div class="h5sub-details">
                <?php echo  nl2br($model_Delivery->shipping_conditions); ?>
            </div>
        </div>
    <?php } ?>
    <div class="box" style="width: 100%">
        <?php if($model_Delivery->awb_no!=''){ ?>
        <h5>AWB No : </h5>
        <div class="h5sub-details">
            <?php echo  $model_Delivery->awb_no; ?>
        </div><br/>
        <?php } ?>
        <?php if($model_Delivery->tracking_no!=''){ ?>
        <h5>Tracking No : </h5>
        <div class="h5sub-details">
            <?php echo  $model_Delivery->tracking_no; ?>
        </div><br/>
        <?php } ?>
        <?php if($model_Delivery->no_of_boxes!=''){ ?>
        <h5>No of Boxes : </h5>
        <div class="h5sub-details">
            <?php echo  $model_Delivery->no_of_boxes; ?>
        </div><br/>
        <?php } ?>
        <?php if($model_Delivery->total_weight!=''){ ?>
        <h5>Total Weight : </h5>
        <div class="h5sub-details">
            <?php echo  $model_Delivery->total_weight; ?>
        </div><br/>
        <?php } ?>
        <?php if($model_Delivery->total_volume!=''){ ?>
        <h5>Total Volume : </h5>
        <div class="h5sub-details">
            <?php echo  $model_Delivery->total_volume; ?>
        </div><br/>
        <?php } ?>
        <?php if($model_Delivery->packed_by!=''){ ?>
        <h5>Packed By : </h5>
        <div class="h5sub-details">
            <?php echo  $model_Delivery->packed_by; ?>
        </div>
        <?php } ?>
        
    </div>
 

<!-- <div class="box" style="width: 100%; margin-bottom: 21rem;">
<div class="col-12">
    <div class="row" style="margin-top: 1rem; margin-left: 2px;"><h5>Acknowledge Receipt: Goods Received in Good Condition</h5></div>
</div><br><br>


<div style="position:relative">
    
    <div style="float:left; width: 40%;text-align: center;"> 
         ___________________________________________  <br>
         <span style="text-align: center;"><small>Received By / Signature</small></span>
    </div>
    <div style="width: 20%;"></div>
    <div style="width: 40%;float: right;text-align: center;"> 
        ___________________________________________ <br>
        <span style="text-align: center;"><small>Prepared By / Signature</small></span>
    </div>
</div>
</div>-->


    <htmlpagefooter name="myfooter" class="newfoot">

            <div style="text-align:center;width:100%;font-size:10px;"><?= Yii::app()->user->footer_autogenerated; ?>
        <?php
                  date_default_timezone_set("Asia/Dubai");
                 echo date('d/m/Y')." ".date("h:i:sa"); ?>
    </div>

    
        <div style="border-top: 1px dotted #000000; font-size: 12px; text-align: center; padding-top: 10px; background-color: #d7faeb;">
            <div style="text-align:center;width:100%">
                <b><?= Yii::app()->user->footer_line_1 ?></b><br>
                <?= Yii::app()->user->footer_line_2 ?>
            </div>
            <div style="text-align:center;width:100%">Page {PAGENO} of {nb} </div>
        </div>
    </htmlpagefooter>




    <style type="text/css">
    .box h5{
        width: 20%;
        display: inline;
        float: left;
    }
        .h5sub-details{
            display: inline;
            width: 80%;
            float: left;
        }
    </style>
</body>

</html>
