<!DOCTYPE html>
<html>

<head>
    <title>Detailed Commodity Classification Form</title>
    <style type="text/css">
        td { background-color: white; }
    </style>
</head>

<body>
    <?php $outbound = OutboundInvoice::model()->findByPk($id); ?>
<htmlpageheader name="myHeader">
    <div class="col-9" style="color:#101010;">
        <br>
        <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-6">
		<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-6" style="margin-right:-30px;margin-top:20px;">
		<div class="text-right">
			<table class="table" style="width:100%">
				<tr>
                    <td class="bc-tl">Invoice No<br>&nbsp;</td>
                    <td> <?php echo $outbound->invoice_no; ?><br>&nbsp; </td>
				</tr>        
            </table>
		</div>
	</div>
    
    <br>
	<div class="col-12">
        <br>
        <div class="h3" style="margin-top: 0;margin-bottom: 0;border:1px solid #000;text-align:center;">
            <?php echo "DETAILED COMMODITY CLASSIFICATION FORM"; ?>
        </div>
        <div class="h3" style="margin-top: 0;margin-bottom: 0;border:1px solid #000;text-align:center;">
            <p class="text-left" style="font-size:11px;padding-left:10px;"> Ports, Customs & Free Zone Corporation </p>
			<p class="text-center" style="font-size:14px;padding-top:-30px;"> (FOR STATISTICAL USE) </p>
        </div>
    </div>
     <br>
     
</htmlpageheader>
<sethtmlpageheader name="myHeader" page="ALL" value="1" show-this-page="1" />

    <div class="col-md-12">
        <table class="table">
            <thead>
                <tr>
                    <th class="text-center" style="width:5%;background-color:#e1b7ff;color:#000;">NO</th>
                    <th class="text-center" style="width:10%;background-color:#e1b7ff;color:#000;">H.S. CODE</th>
                    <th class="text-center" style="width:30%;background-color:#e1b7ff;color:#000;">DESCRIPTION OF GOODS</th>
                    <th class="text-center" style="width:15%;background-color:#e1b7ff;color:#000;">COUNTRY OF <br>ORIGIN</th>
                    <th class="text-center" style="width:15%;background-color:#e1b7ff;color:#000;">QUANTITY & TYPE OF PACKING</th>
                    <th class="text-center" style="width:10%;background-color:#e1b7ff;color:#000;">WEIGHT IN KILOS</th>
                    <th class="text-center" style="width:14%;background-color:#e1b7ff;color:#000;">VALUE</th>
                   
                </tr>
            </thead>
            <tbody>
               
                    <?php
                    $totalQty =0;
                    $totalGross  =0;    
                    $totalValue =0;
                    $totalCtns = 0;

                    $items = Yii::app()->db->createCommand('SELECT * FROM ( SELECT 
                                                                OI.outb_hs_code, 
                                                                HC.description AS category_name,
                                                                COO.coo_name,
                                                                SUM(OI.outb_quantity) AS outb_quantity,
                                                                SUM(OI.outb_remarks) AS outb_remarks,
                                                                SUM(OI.outb_gross_wt) AS outb_gross_wt,
                                                                SUM(OI.outb_invoice_rate) AS outb_invoice_rate
                                                            FROM {{outbound_invoice_items}} OI 
                                                            LEFT JOIN {{mas_category}} CA ON CA.id = OI.category_id
                                                            LEFT JOIN {{item_master}} IM ON IM.part_number = OI.outb_part_number 
                                                            LEFT JOIN {{coo_master}} COO ON COO.coo_code = OI.outb_contry_of_origin 
                                                            LEFT JOIN {{hscode}} HC ON HC.hs_code = OI.outb_hs_code
                                                            WHERE OI.invoice_id='.(int) $outbound->id.'
                                                            GROUP BY OI.outb_hs_code,COO.coo_name) AS A WHERE A.outb_quantity> 0')->queryAll();
            
                foreach ( $items as $i =>  $eachItem) {  ?>
                 <tr>
                        <td>
                            <?php echo ($i+1);?>
                        </td>
                        <td>
                            <?php  echo $eachItem['outb_hs_code'];?>
                        </td>
                         <td>
                            <?php echo $eachItem['category_name'];?>
                        </td>
                        <td>
                            <?php  echo $eachItem['coo_name'];?>
                        </td>
                        <td class="text-right">
                            <?php echo  (float) $eachItem['outb_quantity'];?>
                        </td>
                        <td class="text-right">
                            <?php echo number_format($eachItem['outb_gross_wt'], 2);?>
                        </td>
                        <td class="text-right">
                            <?php  echo number_format($eachItem['outb_invoice_rate'], 2);?>
                        </td>
                    </tr>
                
                    <?php
                        $totalQty+=$eachItem['outb_quantity'];
                        $totalGross += $eachItem['outb_gross_wt'];
                        $totalValue+=$eachItem['outb_invoice_rate'];
                        $totalCtns += $eachItem['outb_remarks'];
        
                    }
                ?>
                 <tr>
                    <td colspan="4" class="text-right"><b>Total</b></td>
					<td class="text-right"><b><?php echo (float) $totalQty; ?></b></td>
                    <td class="text-right"><b><?php echo number_format($totalGross, 2); ?></b></td>
                    <td class="text-right"><b><?php echo $outbound->currency; ?>&nbsp;<?php echo number_format($totalValue, 2); ?></b></td>
                 </tr>

            </tbody>
        </table>
      
    </div>
	<div class="col-5 text-left">
	  <p style="font-family: Arial Narrow; font-size: 15px;">I certify the Information above is correct</p>
	</div>
	<div class="col-6 text-left" style="float:right;">
	  <p style="font-weight:bold;">Total: <?php echo $totalCtns; ?> CTNS (STC <?php echo $totalQty  ?>PCS)</p>
	</div>
	<div class="col-12 text-left">
	  <p style="text-decoration: underline;font-weight:bold;">Shippers Signature & Stamp</p>
	</div>




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