<html>

<head>
    <title>Direct Transfer Receipt</title>
</head>

<body>

    <div class="">
        <div class="col-6">
            <br>
            <?php $model = InventoryDirectTransfer::model()->findByPk($id); ?>
            <div class="h3" style="margin-top: 0;margin-bottom: 0;">
                <?php echo "Direct Transfer"; ?>
            </div>
            <div class="input-block">
                <b><?php echo $id; ?></b>
            </div>
           
        </div>
        <div class="col-5 offset-1" style="color:#101010;">
            <div class="text-right">
                <img src="<?php echo 'images/logo/' . Yii::app()->user->pdf_company_logo; ?>" class="logo">
            </div>
            <br>
            <table class="table" style="width:100%">
                <tr>
                  
                    <td class="bc-tl">Transfer No</td>
                    <td>
                        <?php echo $model->id; ?>
                    </td>
                </tr>
                <tr>
                    <td>Date</td>
                    <td>
                        <?php echo date('d/m/Y', STRTOTIME($model->transfer_date)); ?>
                    </td>
                </tr>
                <tr>
                    <td>From</td>
                    <td>
                        <?php echo $model->warehouseFrom->warehouse_name; ?>
                    </td>
                </tr>
                <tr>
                    <td>To</td>
                    <td>
                        <?php echo $model->warehouseTo->warehouse_name; ?>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <br>
    <div class="col-md-12">
        <table id="" class="table">
            <thead>
                <tr>
                    <th class="text-center bc-tl">No</th>
                    <th class="text-center">Product</th>
                    <th class="text-center" style="width:40%">Description</th>
                    <th class="text-center" style="width:15%">Transfer Qty</th>
                    <th class="text-center" style="width:10%">Sample Qty</th>
                      <th class="text-center" style="width:15%">Total Transferred</th>
                    <th class="text-center" style="width:8%">Unit</th>
                </tr>
            </thead>
            <tbody>

                <?php
                $m = 1;
                $total_sample_qty = $total_qty =$total_transfer= 0;
                $condition .= '1=1';
                $condition .= ' AND t.direct_transfer_id ="' . $id . '"';
                $model_Items = InventoryDirectTransferItem::model()->findAll(array('condition' => $condition));
                foreach ($model_Items as $i =>  $each_Item) {

                ?>
                    <tr>
                        <td>
                            <?php echo $m; ?>
                        </td>
                        <td>
                            <?php echo $each_Item->item_name; ?>
                        </td>
                        <td>
                            <?php echo $each_Item->item_description; ?>
                        </td>

                       <td class="text-right">
                            <?php 
                           $total_transffered =  $each_Item->transfer_qty-$each_Item->sample_qty;
                            echo Yii::app()->numberFormatter->formatCurrency($total_transffered, " ");
                            $total_transfer += $total_transffered;
                            ?>
                        </td>

                        <td class="text-right">
                            <?php echo Yii::app()->numberFormatter->formatCurrency($each_Item->sample_qty, " ");
                            $total_sample_qty += $each_Item->sample_qty;
                            ?>
                        </td>
                        
                         <td class="text-right">
                            <?php echo Yii::app()->numberFormatter->formatCurrency($each_Item->transfer_qty, " ");
                            $total_qty += $each_Item->transfer_qty;
                            ?>
                        </td>
                        <td class="text-right">
                            <?php echo $each_Item->unitdetails->name; ?>
                        </td>


                    </tr>

                <?php $m++;
                }
                ?>
                <tr>
                    <td colspan="3">Total </td>
                    <td class="text-right"><b> <?php echo Yii::app()->numberFormatter->formatCurrency($total_transfer, " ");     ?></b> </td>

                    <td class="text-right"><b> <?php echo Yii::app()->numberFormatter->formatCurrency($total_sample_qty, " ");     ?></b> </td>
                    <td class="text-right"><b> <?php echo Yii::app()->numberFormatter->formatCurrency($total_qty, " ");     ?></b> </td>

                    <td class="text-right"></td>
                    </td>

                </tr>

            </tbody>
        </table>
        

        <?php if ($model->direct_transfer_description != '') {
        ?>
          

            <div class="box" >
                <h5>Description</h5>
                <div class="h5sub-details">
                    <?php echo nl2br($model->direct_transfer_description); ?>
                </div>
            </div>

        <?php } ?>
        <?php if ($model->reference != '') {
        ?>

            <div class="box" >
                <h5>Reference</h5>
                <div class="h5sub-details">
                    <?php echo nl2br($model->reference); ?>
                </div>
            </div>
        <?php
        }
        ?>
</div>



    </div>

    <br />
    <div style="width: 100%; height: 80px; border: 1px solid #1f67b2; margin-top: 5px;padding: 1px;">
        <div style="float:left; width: 50%;text-align: center;">
            <br>
            <br>
            <br>
            ___________________________________ <br>
            <span style="text-align: center;"><small>Issued</small></span>
        </div>
        <div style="float:left; width: 50%;text-align: center;">
            <br>
            <br>
            <br>
            ___________________________________ <br>
            <span style="text-align: center;"><small>Received</small></span>
        </div>
        <div style="float:left; width: 50%;text-align: center;">
            <br>
            <br>
            <br>
            ___________________________________ <br>
            <span style="text-align: center;"><small>Packed</small></span>
        </div>
        <div style="float:left; width: 50%;text-align: center;">
            <br>
            <br>
            <br>
            ___________________________________ <br>
            <span style="text-align: center;"><small>Verified</small></span>
        </div>

        <br>

    </div>


    <htmlpagefooter name="myfooter">


        <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>
</body>

</html>