<?php
$warehouseNames = [];
        if (!empty($model->warehouse_id)) {
            $ids = explode(',', $model->warehouse_id);
            $warehouses = MasInventoryWarehouse::model()->findAllByPk($ids);

            foreach ($warehouses as $w) {
                $warehouseNames[] = $w->warehouse_name;
            }
        }
        $warehouseNameStr = implode(', ', $warehouseNames);
        ?>
<!DOCTYPE html>
<html>
    <head>
        <title>BUFFER REQUISITION</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;

        }
      @page {
        margin-top: 3.3cm;
        /*margin-bottom:2cm;*/
          margin-bottom:3.5cm;
        margin-left: .3cm;
        margin-right: .3cm;
        header: html_myHeader;
        header: html_otherpages;
        font-family:'Times New Roman';
        border:5px solid red;
          height: 280mm;

    }

        </style>
    <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 $model->file_id; ?></b>
            </div>
            <br>
            <small><?php  echo $model->file_title;?></small>
        </div>
        
        <div class="col-4">
       <div class="h3" style="margin-top: 0;margin-bottom: 0;text-align: center;font-size: 14px;">
        <?php echo "BUFFER REQUISITION"; ?>
        </div>
        </div>
        <div class="col-4" style="color:#101010;">
            <table class="table" style="width:100%">
                <tr>
                    <td style="width:40%">Requisition Date</td>
                    <td><?php echo date("d/m/Y", strtotime($model->requisition_date));?></td>
                </tr>
                <tr>
                    <td style="width:40%">Required Date</td>
                    <td><?php echo date("d/m/Y", strtotime($model->required_date));?></td>
                </tr>
                <?php if($model->reference!=""){    ?>
                 <tr>
                    <td style="width:40%">Reference</td>
                    <td><?php echo $model->reference;?></td>
                </tr>
                <?php  }   ?>  
                <tr>
                    <td style="width:40%">RMA Centre</td>
                    <td><?php echo $warehouseNameStr; ?></td>
                </tr>
                    
            </table>
        </div>
    </div>
 <div class="col-md-12">
  
    
    <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  $m=0;
               foreach ( $model->stockitems as $i => $each ) {
        ?>
                <tr>
                    <td><?php echo $i+1;?></td>
                    <td><?php echo $each->stock_item_name; ?></td>
                    <td><?php echo $each->stock_item_description;?></td>
                    <td class="text-center"><?php echo (int)$each->stock_item_quantity; ?></td>
                    <td><?php echo $each->uom->name; ?></td>
                </tr>
        <?php  $m=$i+1;  }   ?>

        <?php  $m=0;
               foreach ( $model->nonstockitems as $i => $each ) {
        ?>
                <tr>
                    <td><?php echo $m+$i+1;?></td>
                    <td><?php echo $each->non_stock_item_name; ?></td>
                    <td><?php echo $each->non_stock_item_description;?></td>
                    <td class="text-center"><?php echo Yii::app()->numberFormatter->formatCurrency($each->non_stock_item_quantity,"");?></td>
                    <td><?php echo $each->non_stock_item_unit; ?></td>
                </tr>
        <?php  $m++;  }   ?>
      
    
       </tbody>
    </table>
</div>
<div class="box" style="width: 100%">
                <h5>Remarks</h5>
                <div class="h12sub-details">
                    <?php echo  nl2br($model->remarks); ?>
                </div>
            </div>


 
  <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    
    

     <?php $this->renderPartial("//common/footer");?>
          </div>
</body>

</html>
