<!DOCTYPE html>
<html>

<head>
    <title>Materil Receipt</title>
</head>
        <style>
            .table_box {
                border-collapse:separate!important;
                margin-top: 10px;
                padding: 10px;
                font-size:16px!important;
                border: 1px solid #0066ff;
                border-radius:6px;
            }
            
                             div {
         page-break-inside: auto;
            page-break-after: auto;

        }

  
        </style>
<?php
$modelOrder = PurchasingMaterialreceipt::model()->findByPk($id);
?>

<body>
     <div style="padding: 35px;">
           <div class="" >
       

        <div class="">
            <?php $this->renderPartial("//common/header"); ?>
            <div class="col-4">
                <div class="input-block">
                    <b><?php echo $id; ?></b>
                </div>
                <br>
                <b><?php echo strtoupper($modelOrder->vendor_details->vendor_name); ?></b>
                <br />
                <small><?php echo $modelOrder->vendor_details->vendor_address; ?></small><br />
                <?php
                if ($modelOrder->vendor_details->vendor_postal_code != "" || $modelOrder->vendor_details->vendor_location != "") {
                    ?>
                    <small>
                        <?php echo 'PO Box : ';
                        if (isset($modelOrder->vendor_details->vendor_postal_code) && $modelOrder->vendor_details->vendor_postal_code != "") {
                            echo $modelOrder->vendor_details->vendor_postal_code;
                        }
                        if ($modelOrder->vendor_details->vendor_postal_code != "" && $modelOrder->vendor_details->vendor_location != "") {
                            echo ", ";
                        }
                        if (isset($modelOrder->vendor_details->vendor_location) && $modelOrder->vendor_details->vendor_location != "") {
                            echo $modelOrder->vendor_details->vendor_location;
                        }
                        ?></small><br />
                <?php
                }
                ?>
                <small><?php echo ($modelOrder->vendor_details->vendor_city != "") ? $modelOrder->vendor_details->vendor_city . ', ' : "" . $modelOrder->vendor_details->country->country_name; ?></small><br />
                <small><?php echo $modelOrder->vendor_details->vendor_phone_no; ?></small><br />
            </div>

            <div class="col-4">
                <div class="h3" style="margin-top: 0;margin-bottom: 0;text-align: center;font-size: 14px;">
                    <?php if ($_REQUEST['type'] == 'qc') {
                        echo "QUALITY CHECK";
                    } else {
                        echo "MATERIAL RECEIPT";

                    } ?>

                </div>
            </div>
            <div class="col-4" style="color:#101010;">
                <table class="table" style="width:100%">

                    <tr>
                        <td style="width:40%">File ID #</td>
                        <td><?php echo $modelOrder->file_id; ?></td>
                    </tr>
                    <?php
                    if ($ticket_id > 0) { ?>
                        <tr>
                            <td style="width:40%">Job Order No</td>
                            <td><?php echo $modelOrder->ticket_id; ?></td>
                        </tr>
                    <? } ?>
                    <?php
                    if ($project_classification_id > 0) { ?>
                        <tr>
                            <td style="width:40%">Project</td>
                            <td><?php echo $modelOrder->project_classification_id; ?></td>
                        </tr>
                    <? } ?>

                    <!--            <tr>
                <td>Vendor</td>
                <td><?php //echo $modelOrder->vendor_details->id; ?></td>
            </tr>
          
             <tr>
                <td>Vendor TRN#</td>
                <td><?php //echo $modelOrder->vendor_details->vendor_trn_no; ?></td>
            </tr>-->
                    <tr>
                        <td style="width:40%">PO #</td>
                        <td><?php echo $modelOrder->po_id; ?></td>
                    </tr>
                    <tr>
                        <td style="width:40%">Order Date</td>
                        <td><?php echo date("d/m/Y", strtotime($modelOrder->purchaseorder->order_date)); ?></td>
                    </tr>
                    <tr>
                        <td style="width:40%">Delivery #</td>
                        <td><?php echo $modelOrder->dly_no; ?></td>
                    </tr>
                    <tr>
                        <td style="width:40%">MRV Date</td>
                        <td><?php echo date("d/m/Y", strtotime($modelOrder->mrv_receipt_date)); ?></td>
                    </tr>
                    <!-- <tr>
                <td>AWB #</td>
                <td><?php //echo  $modelOrder->awb_no; ?></td>
            </tr>-->


                </table>
            </div>
        </div>
        <br>
        <div class="col-md-12">

            <table id="tbl_order_table" class="table table-fixed table-primary dataTable">
                <thead>
                    <tr>
                        <th>No</th>
                        <th>Item</th>
                        <th>Description</th>
                        <th>Total</th>
                        <th>Balance</th>
                        <th>MR Qty</th>
                        <th>QC Qty</th>
                        <th>Unit</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    if ($type == "qc") {
                        $model_req_stock = PurchasingMaterialreceiptItem::model()->findAll(array('condition' => 'purchasing_materialreceipt_id="' . $id . '" AND qc_checked_quantity>0'));
                    } else {
                        $model_req_stock = PurchasingMaterialreceiptItem::model()->findAll(array('condition' => 'purchasing_materialreceipt_id="' . $id . '" AND received_quantity>0'));
                    }
                    foreach ($model_req_stock as $i => $model) {
                        $batch_no = '';
                        $sl_no = '';
                        $model_unit = UnitOfMeasurement::model()->findbypk($model->unit);

                        ?>
                        <tr>
                            <td><?php echo $i + 1; ?></td>
                            <td><?php echo $model->product_name; ?></td>
                            <td><?php echo $model->description; ?>
                                <?php if ($model->product->have_expiry_date == 'Y') {
                                    $batch_no = StockLedger::getBatchNoWithExpDate($model->purchasing_materialreceipt_id, $model->product_id, 'PURCHASE');
                                    ?>
                                    <hr style="width:100%;">
                                    <br />
                                    Batch No:<?php echo $batch_no; ?>
                                <?php } ?>
                                <?php if ($model->product->have_serial_no == 'Y') {
                                    $sl_no = StockLedger::getSerialNo($model->purchasing_materialreceipt_id, $model->product_id, 'PURCHASE');
                                    ?>
                                    <hr style="width:100%;">
                                    <br />
                                    Serial No:<?php echo $sl_no; ?>
                                <?php } ?>
                            </td>

                            <!-- <td class="text-right">
                                <?php //echo Yii::app()->numberFormatter->formatCurrency($model->quantity, ""); ?></td> -->
                                <td class="text-right"><?php echo number_format($model->quantity); ?></td>
                                <!-- <td class="text-right">
                                <?php //echo Yii::app()->numberFormatter->formatCurrency($model->remaining_quantity, ""); ?>
                            </td> -->
                                <td class="text-right"><?php echo number_format($model->remaining_quantity); ?></td>
                                <!-- <td class="text-right">
                                <?php //echo Yii::app()->numberFormatter->formatCurrency($model->received_quantity, ""); ?>
                            </td> -->
                                <td class="text-right"><?php echo number_format( $model->received_quantity); ?></td>
                                <!-- <td class="text-right">
                                <?php //echo Yii::app()->numberFormatter->formatCurrency($model->qc_checked_quantity, ""); ?>
                            </td> -->
                                <td class="text-right"><?php echo number_format($model->qc_checked_quantity); ?></td>

                            <td><?php echo $model->unit; ?></td>
                        </tr>
                    <?php } ?>

                </tbody>
            </table>
        </div>

        <?php if ($modelOrder->storekeeper_notes != '') {
            ?>
            <div class="box" style="width:100%">
                <h5>Storekeeper Notes</h5>
                <div class="h5sub-details">
                    <?php echo nl2br($modelOrder->storekeeper_notes); ?>
                </div>
            </div>
        <?php } ?>
        <?php if ($modelOrder->qc_check_notes != '') {
            ?>
            <div class="box" style="width:100%">
                <h5>QC Notes</h5>
                <div class="h5sub-details">
                    <?php echo nl2br($modelOrder->qc_check_notes); ?>
                </div>
            </div>
        <?php } ?>
        <?php if ($modelOrder->terms_and_conditions != '') {
            ?>
            <div class="box" style="width:100%">
                <h5>Terms And Conditions</h5>
                <div class="h5sub-details">
                    <?php echo nl2br($modelOrder->terms_and_conditions); ?>
                </div>
            </div>
        <?php } ?>
        <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;">
                    <?php //Take the color from css->pdf_style.css->.box color?>
                 <span style= "color: #046adb">   ___________________________________________ </span><br>
                    <span style="text-align: center;"><small>MR Verified By / Signature</small></span>
                </div>
                <div style="width: 20%;"></div>
                <?php if ($type == 'qc') { ?>
                    <div style="width: 40%;float: right;text-align: center;">
                        <?php //Take the color from css->pdf_style.css->.box color?>
                      <span style= "color: #046adb">  ___________________________________________ </span><br>
                        <span style="text-align: center;"><small>QC Verified By / Signature</small></span>
                    </div>
                <?php } ?>
            </div>
        </div>

      <?php $this->renderPartial("//common/footer", array('company_id' => $company_id)); ?>
    </div>   </div>
</body>

</html>