<!DOCTYPE html>
<html>
<head>
    <title>Packing List</title>
	<style type="text/css">
    .table td {
        border: 1px solid #1f67b2;
    }
	.table {
	border-collapse: collapse !important;
	font-size: 12px;
	color: #101010;
	width: 100%;
}
.table thead th{
	background: #e4e3e3;
	color: #000;
}
.table th,
.table td {
	border: 1px solid #000 !important;
	text-align: left;
	padding: 3px 6px;
    background-color: white;
}
.table th.text-left,
.table td.text-left{
	text-align: left;
	text-align: left !important;
}
.table th.text-right,
.table td.text-right{
	text-align: right;
	text-align: right !important;
}
.table th.text-center,
.table td.text-center{
	text-align: center;
	text-align: center !important;
}
.table tbody tr:nth-child(even){
	background: #e4e3e3;
}
.table th.Table-Title,
.table td.Table-Title{
    padding:7px 6px !important;
    font-size:1.15rem;
    color:green;
    font-weight:500;
    text-transform:uppercase;
}
.table th.total,
.table td.total{
	background: #e4e3e3;
	color: #fff;
	font-size: 11px;
}
	}
.border_top{
    border:1px solid #BF2121;
}
</style>
</head>
<body>
    <?php
        $document = SwitchDoc::model()->findByPk($id);
        $transport= array('1' => 'AIR', '2' => 'SEA', '3' => 'CARGO', '4' => 'LAND');
        $delivery = array(  '1' => array( 'name' => 'FOB', 'insurance' => 'COLLECT', 'freight' => 'COLLECT'),
                            '2' => array( 'name' => 'EX-WORKS', 'insurance' => 'COLLECT', 'freight' => 'COLLECT'),
                            '3' => array( 'name' => 'CIF', 'insurance' => 'PREPAID', 'freight' => 'PREPAID'),
                            '4' => array( 'name' => 'CFR', 'insurance' => 'COLLECT', 'freight' => 'PREPAID'),
                            '5' => array( 'name' => 'CPT', 'insurance' => 'COLLECT', 'freight' => 'PREPAID'),
                        );
    ?>
      <htmlpageheader name="myHeader">
<div class="">
    <div class="">
    <br>
        <div class="col-12" style="color:#101010;">
            <div class="text-left">
                <img src="<?php echo 'images/pdf/' . Yii::app()->user->pdf_company_logo; ?>" class="logo" style="height:28px;">

            </div>
        </div>
		<div class="col-4">
		    <div class="text-left">
                <h5><?php echo Yii::app()->user->company_name; ?></h5>
				<h6 style="font-weight:300;margin-top:-5px;margin-bottom:3px;"><?php echo Yii::app()->user->billing_address; ?></h6>
			</div>
		</div>
		<div class="col-4 text-center border_top">
             <h2>Packing List</h2>
			   
			</div>
		<div class="col-4" style="margin-right:-30px;margin-top:20px;">
		    <div class="text-right">
			    <table class="table" style="width:100%">
				    <tr>

							<td class="bc-tl">Date</td>
							<td>
								<?php echo date('d/m/Y', strtotime($document->added_date)) ?>
							</td>
					</tr>
					<tr>

							<td class="bc-tl">Invoice No<br>&nbsp;</td>
							<td>
								<?php echo $document->invoice_no ?><br>&nbsp;
							</td>
					</tr>
					<!-- <tr>

							<td class="bc-tl">Container<br>&nbsp;</td>
							<td>
                                <?php //echo $document->containers(); ?><br>&nbsp;
							</td>
					</tr>
					<tr>

							<td class="bc-tl">Size</td>
							<td>
								&nbsp;
							</td>
					</tr> -->
                </table>
			</div>
		</div>
    </div>
	<br>
	<div class="col-md-12">
	   <div class="col-4" style="float:left;">
	       <table class="table" border="1" style="text-align:left;width:100%; border-collapse: collapse;">
            <tbody>
                <tr>
                    <td class="text-left" style="font-size:11.5px;background-color:#e1b7ff;"><b>Buyer / Applicant</b></td>
                </tr>
				<tr>
                    <td height="20" class="text-left" style="font-size:11.5px;background-color:none;"><?php echo $document->cus->name ?></td>
                </tr>
				<tr>
                    <td height="80" class="text-left" style="font-size:11.5px;"><?php echo nl2br($document->cus->billing_adds); ?></td>
                </tr>
			</tbody>
		   </table>
	   </div>
	   <div class="col-4" style="float:right;">
	        <table class="table" border="1" style="text-align:left;width:100%; border-collapse: collapse;">
            <tbody>
                <tr>
                    <td class="text-left" style="font-size:11.5px;background-color:#e1b7ff;"><b>Consignee</td>
                </tr>
				<tr>
                    <td height="20" class="text-left" style="font-size:11.5px;background-color:none;"><?php echo $document->cus->name ?></td>
                </tr>
				<tr>
                    <td height="80" class="text-left" style="font-size:11.5px;"><?php echo nl2br($document->cus->billing_adds); ?></td>
                </tr>
			</tbody>
		   </table>
	   </div>
    </div>
	</div>
    <div class="col-md-12" style="margin-top:10px;">
        <table border="1" style="border-collapse: collapse; text-align:center;width:100%;">
            <thead>
                <tr>
                    <th class="text-center" style="width:10%;font-size:12px;background-color:#e1b7ff;">From Port</th>
                    <th class="text-center" style="width:10%;font-size:12px;background-color:#e1b7ff;">To Port</th>
                    <th class="text-center" style="width:15%;font-size:12px;background-color:#e1b7ff;">Shipment Mode</th>
                    <th class="text-center" style="width:13%;font-size:12px;background-color:#e1b7ff;">Agent / Line</th>
                    <th class="text-center" style="width:18%;font-size:12px;background-color:#e1b7ff;">Mode of Payment</th>
                    <th class="text-center" style="width:14%;font-size:12px;background-color:#e1b7ff;">Delivery Terms</th>
                    <th class="text-center" style="width:10%;font-size:12px;background-color:#e1b7ff;">Insurance</th>
                    <th class="text-center" style="width:10%;font-size:12px;background-color:#e1b7ff;">Freight</th>
                </tr>
            </thead>
            <tbody style="font-size: 10%;">
            <tr>
                    <td style="font-size:11px;"><?php echo $document->from_port; ?></td>
                    <td style="font-size:11px;"><?php echo $document->destination; ?></td>
                    <td style="font-size:11px;"><?php echo $transport[$document->mode_of_transport]; ?></td>
                    <td style="font-size:11px;"><?php echo $document->agent; ?></td>
                    <td style="font-size:11px;"><?php echo $document->payment_term; ?></td>
                    <td style="font-size:11px;"><?php echo $delivery[$document->inco_terms]['name']; ?></td>
                    <td style="font-size:11px;"><?php echo $delivery[$document->inco_terms]['insurance']; ?></td>
                    <td style="text-align:center;font-size:11px;"><?php echo $delivery[$document->inco_terms]['freight']; ?></td>
                </tr>
            </tbody>
        </table>
    </div>
	<br>
    </htmlpageheader>
<sethtmlpageheader name="myHeader" page="ALL" value="1" show-this-page="1" />
	<div class="col-md-12">
        <table id="" class="table">
            <thead>
                <tr>
                    <th class="text-center" style="width:5%;background-color:#e1b7ff;color:#000;">S.No</th>
                    <th class="text-center" style="width:10%;background-color:#e1b7ff;color:#000;">GMC</th>
                    <th class="text-center" style="width:18%;background-color:#e1b7ff;color:#000;">Item No.</th>
                    <th class="text-center" style="width:25%;background-color:#e1b7ff;color:#000;">Description</th>
                    <th class="text-center" style="width:12%;background-color:#e1b7ff;color:#000;">HS Code</th>
                    <th class="text-center" style="width:8%;background-color:#e1b7ff;color:#000;">COO</th>
                    <th class="text-center" style="width:10%;background-color:#e1b7ff;color:#000;">Qty</th>
                    <th class="text-center" style="width:12%;background-color:#e1b7ff;color:#000;">Gross Wght (Kgs.)</th>
					<th class="text-center" style="width:12%;background-color:#e1b7ff;color:#000;">Volume (CBM)</th> 
                    <th class="text-center" style="width:10%;background-color:#e1b7ff;color:#000;">Carton</th>   
                    <th class="text-center" style="width:10%;background-color:#e1b7ff;color:#000;">Ctn.Grp</th>             
                </tr>
            </thead>
            <tbody>
                <?php 
                    $totalQty = 0;
                    $totalGross = 0;
                    $totalCbm = 0;
                    $totalCarton = 0;

                    $items = $document->items;
                  
                    foreach( $items as  $i => $each ) :  
                    
                    ?>
                 <tr>
                    <td><?php echo $i+1; ?></td>
                    <td><?php echo $each->part_number; ?></td>
                    <td><?php echo $each->item->description; ?></td>
                    <td><?php echo $each->category->category_name; ?></td>
                    <td><?php echo $each->hs_code; ?></td>
                    <td><?php echo $each->cooRelation->coo_name; ?></td>
                    <td class="text-right"><?php echo  (float)$each->quantity; ?></td>
                    <td class="text-right"><?php echo $each->gross_wt; ?></td>
					<td class="text-right"><?php echo $each->cbm; ?></td>
                    <td class="text-right"><?php echo $each->ctns; ?></td>
                    <td class="text-center"><?php echo  $each->ctn_group; ?></td>
                </tr>
                <?php 
                        $totalQty += $each->quantity;
                        $totalGross += $each->gross_wt;
                        $totalCbm += $each->cbm;
                        $totalCarton += $each->ctns;
                        endforeach; ?>

                 <tr>
                    <td colspan="6" class="text-right"><b>Total</b></td>
					<td class="text-right"><b><?php echo $totalQty; ?></b></td>
                    <td class="text-right"><b><?php echo number_format($totalGross, 2, '.', ''); ?></b></td>
                    <td class="text-right"><b><?php echo number_format($totalCbm, 3, '.', ''); ?></b></td>
                    <td class="text-right"><b><?php echo $totalCarton; ?></b></td>
                    <td></td>
                 </tr>

            </tbody>
        </table>

    </div>
<br>
	<div class="col-md-12" style="margin-bottom:5px;">
	    <table class="table">
		   <tr>
		       <td style="height:18px;"></td>
		   </tr>
		</table>
	</div>
	<div class="col-md-12" style="margin-bottom:5px;">
	    <table class="table">
		   <?php if( $document->description_of_goods != '' ){  ?>
                <tr>
                    <td style="width:24%;"><b><u>DESCRIPTION OF GOODS :</u><br>&nbsp;</b></td>
                    <td><?php echo $document->description_of_goods; ?></td>
                </tr>
           <?php } ?>
		   <tr>
		       <td style="width:24%;"><b><u>COUNTRY OF ORIGIN: </u><br>&nbsp;</b></td>
               <td><?php echo $document->country_origins_labels() ?></td>
		   </tr>
		</table>
	</div>
    <?php if( $document->cus->need_manufacure == 'Y' ){  ?>
        <div class="col-md-12" style="margin-bottom:5px;">
            <table class="table">
            <tr>
                <td><b><u>MANUFACTURERS FULL NAME & ADDRESS:</u><br>&nbsp;</b></td>
            </tr>
            <?php 
                $condition = 'header_id='.(int) $document->id;
                foreach( SwitchItems::model()->findAll( array( 'select' => 'DISTINCT coo', 'condition' => $condition )) as $each ) : 
                        if( $each->coo != '') :

                            if( $each->coo == 'CN' && $document->currency == 'EUR' )
                                $each->coo = 'CNN';
                    ?>
                        <tr>
                            <td><?php echo strtoupper($each->cooRelation->address); ?> </td>
                        </tr>
                        <?php endif; ?>
            <?php endforeach; ?>
            </table>
        </div>
    <?php } ?>
  
    <div class="col-md-12" >
        <br>
        <table style="border-collapse: collapse;">
            <tr>
                <td class="text-right"><b>Total Quantity :</b> </td>
                <td><?php echo $document->Total_cartons ?> CTNS (STC <?php echo $document->total_quantity ?>PCS)</td>
            </tr>
            <tr>
                <td  class="text-right"><b>Total Weight :</b> </td>
                <td><?php echo number_format($document->Total_weight , 2, '.', '') ?> Kgs.</td>
            </tr>
            <tr>
                <td class="text-right"><b>Total Volume :</b> </td>
                <td><?php echo number_format($document->Total_volume , 3, '.', '') ?> m&sup3;</td>
            </tr>
            <tr>
                <td class="text-right"><b>Containers :</b> </td>
                <td><?php echo $document->containers() ?>
            </tr>
            <tr>
                <td class="text-right"><b>Container Size :</b> </td>
                <td><?php echo $document->get_container_data(); ?><br></td>
            </tr>
        </table>
    </div>
    <br><br><br>
    <div class="col-md-12" class="text-right">
            <h4>_____________________________</h4>
            <h4>YAMAHA MUSIC GULF FZE</h4>
    </div>
</div>
<htmlpagefooter name="myfooter">

                <div style="border-top: 1px dotted #000000; font-size: 12px; text-align: center; padding-top: 10px;">
                    <div style="text-align:center;width:100%">
                    </div>
                    <div style="text-align:center;width:100%">Page {PAGENO} of {nb} </div>
                </div>
            </htmlpagefooter>
<sethtmlpagefooter name="myfooter" page="all" value="on" />
</body>

</html>
