<!DOCTYPE html>
<html>

<head>
    <title>PURCHASE ENQUIRY</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;

    }

 

    body {
        font-size: 12px !important;
    }
</style>

<body style="font-family: 'Times New Roman' Times serif">

    <div style="padding: 35px;">
        <div class="">
         
            <div class="">
                <?php  $this->renderPartial("//common/header"); ?>
                <div class="col-4">
                    <?php
                    $model = PurchasingEnquiry::model()->findByPk($id);
                    //                   $model_cust = Customers::model()->findByPk($model->cust_id);
                    ?>
                    <?php
                    $year = date('y');
                    $formattedId = "$id";
                    ?>
                    <div class="input-block">
                        <b><?php echo $formattedId; ?></b>
                    </div>
                    <?php
                    $model_vendor = Vendor::model()->findByPk($vendor_id);
                    $city = '';
                    if ($model_vendor->vendor_location != '') {
                        $city .= $model_vendor->vendor_location . ', ';
                    }
                    if ($model_vendor->vendor_state != '') {
                        $city .= $model_vendor->vendor_state . ', ';
                    }
                    $city .= $model_vendor->country->country_name;
                    ?>
                    <br />
                    <b><?php echo strtoupper($model_vendor->vendor_name); ?></b>
                    <br><?php echo $model_vendor->vendor_address; ?><br>
                    <?php echo $model_vendor->vendor_phone_no; ?><br>
                    <?php echo $model_vendor->vendor_email_id; ?><br>
                    <small><?php echo $city; ?></small><br />

                </div>
                <div class="col-4">
                    <div class="h3" style="margin-top: 0;margin-bottom: 0;text-align: center;">
                        <?php echo "PURCHASE ENQUIRY"; ?>
                    </div>
                </div>
                <div class="col-4" 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 style="width:40%">Enquiry Date</td>
                            <?php $req_date = date("d/m/Y", strtotime($model->enquiry_date)); ?>
                            <td><?php echo $req_date; ?></td>
                        </tr>
                        <tr>
                            <td style="width:40%">Required Date</td>
                            <?php $required_date = date("d/m/Y", strtotime($model->required_date)); ?>
                            <td><?php echo $required_date; ?></td>
                        </tr>
                        <?php if ($model_vendor->vendor_trn_no != '') { ?>
                            <tr>
                                <td style="width:40%">Vendor TRN#</td>
                                <td><?php echo $model_vendor->vendor_trn_no; ?></td>
                            </tr>
                        <?php } ?>

                    </table>
                </div><br />
                <div class="col-12">
                    <?php
                    if (isset($model->start_text)) {

                        echo nl2br($model->start_text);
                    }
                    ?>
                </div>
            </div>

            <span>Dear Sir,</span><br />
            <span>Please quote us the best possible rates and delivery terms for the following items.</span>


            <br>
            <br>



            <table id="tbl_enquiry_table" class="table table-fixed table-primary dataTable">
                <thead>
                    <tr>
                        <th>No</th>
                        <th>Product</th>
                        <th>Description</th>
                        <th>Quantity</th>
                        <th>Unit</th>

                    </tr>
                </thead>
                <tbody>
                    <?php
                    $model_req_stock = PurchasingEnquiryStockItem::model()->findAll(array('condition' => 't.purchasing_enquiry_id="' . $model->id . '"'));
                    $model_req_non_stock = PurchasingEnquiryNonStockItem::model()->findAll(array('condition' => 't.purchasing_enquiry_id="' . $model->id . '"'));
                    foreach ($model_req_stock as $i => $modelstock) {
                        ?>
                        <tr>
                            <td><?php echo $i + 1; ?></td>
                            <td><?php echo $modelstock->stock_item_name; ?></td>
                            <td><?php echo $modelstock->stock_item_description; ?></td>
                            <td class="text-right"><?php echo (int)$modelstock->stock_item_quantity; ?></td>
                            <td><?php echo $modelstock->uom->name; ?></td>
                        </tr>

                        <?php
                    }
                    foreach ($model_req_non_stock as $j => $model1) {
                        ?>
                        <tr>
                            <td><?php echo $i + $j + 2; ?></td>
                            <td><?php echo $model1->non_stock_item_name; ?></td>
                            <td><?php echo $model1->non_stock_item_description; ?></td>
                            <td class="text-right">
                                <?php echo Yii::app()->numberFormatter->formatCurrency($model1->non_stock_item_quantity, ""); ?>
                            </td>
                            <td><?php echo $model1->non_stock_item_unit; ?></td>
                        </tr>
                    <?php }
                    ?>

                </tbody>
            </table>
            <?php
            if (!empty($model->remarks)) {
                ?>
                <div class="box" style="width:100%">
                    <h5>Remarks</h5>
                    <div class="h12sub-details">
                        <?php echo nl2br($model->remarks); ?>
                    </div>
                </div>
            <?php } ?>
            <?php $this->renderPartial("//common/footer"); ?>
        </div>
    </div>
</body>

</html>