<style type="text/css">

@media print {
  @page {
    margin-top: 4.2cm;
    margin-bottom: 4.4cm;
  }
}
</style>
<!DOCTYPE html>
<html>

    <head>
        <title>Goods Issue</title>
    </head>
<body>
 <?php
                 $model_issue = InventoryGoodsIssue::model()->findByPk($id);
            ?>
    <div class="">
    <?php  $this->renderPartial('//common/header');?>
        <div class="col-4">
          
                
                <div class="input-block">
                    <b><?php echo $model_issue->id;?></b>
                </div>
               
                              
                 &nbsp;<small><b><?php echo $model_issue->customer_name; ?></b><br/></small>
        </div>
        <div class="col-4">
        <div class="h3" style="margin-top: 0;margin-bottom: 0;text-align: center;font-size: 14px;">
                    <?php echo "GOODS ISSUE"; ?>
        </div>    
        </div>
        <div class="col-4" style="color:#101010;">
            
       <table class="table" style="width:100%">
                        <!-- <tr>
                            <td>Goods Issue#</td>

                            <td><?php //echo $model_issue->id; ?></td>
                        </tr> -->
                        <tr>
                            <td>Goods Issue Date</td>
                            <?php $req_date = date("d/m/Y", strtotime($model_issue->goods_issue_date)); ?>
                            <td><?php echo $req_date; ?></td>
                        </tr>
                        
                        <?php if($model_issue->issue_type=='S'){ ?>
                            <tr>
                            <td>Goods Issue Type</td>

                            <td><?php echo 'Sample'; ?></td>
                        </tr>
                        <?php }?>
                        <tr>
                            <td>Warehouse/Branch</td>

                            <td><?php echo $model_issue->warehouse_det->warehouse_name; ?></td>
                        </tr>
                        <?php if($model_issue->unit_id>0){ ?>
                            <tr>
                            <td>Unit No</td>

                            <td><?php echo $model_issue->unit_det->unit_name; ?></td>
                        </tr>
                        <?php }
                         if($model_issue->reference!=''){
    ?>
                          <tr>
                            <td>Reference</td>

                            <td><?php echo $model_issue->reference; ?></td>
                        </tr><?php  } ?>
            </table> 
        </div>
    </div>
    <br>
    <div class="col-md-12">
   
        <?php
        $model_items = InventoryGoodsIssueItem::model()->findAll(array('condition' => 'inventory_goods_issue_id = ' . $model->id . ' AND picked_qty!=0'));
        ?>



        <table id="tbl_enquiry_table" class="table table-fixed table-primary dataTable">
            <thead>
                <tr>
                    <th style="width:5%">No</th>  
                    <th style="width:25%">Product</th>
                    <th style="width:45%">Description</th>
                    <th> Qty</th>
                    <th>Unit</th>
                </tr>
            </thead>
            <tbody>
                <?php
                foreach ($model_items as $i => $rowItem) {
                    //$total_allocated_product = AllocatedMaterial::model()->find(array('select' => 'sum(quantity) as quantity', 'condition' => 'product_id="' . $rowItem->product_id . '"'));
                    //$total_available_product = StockLedger::model()->find(array('select' => 'sum(quantity) as quantity', 'condition' => 'product_id="' . $rowItem->product_id . '"'));
                    //$free_quantity = $total_available_product->quantity - $total_allocated_product->quantity;
                    ?>
                    <tr>
                        <td> <?php echo ($i + 1); ?> </td>
                        <td> <?php echo $rowItem->product_name; ?></td>
                        <td><?php echo $rowItem->description; ?></td>
                        <td class="text-right"><?php echo (int)$rowItem->picked_qty; ?></td>
                        <td><?php echo $rowItem->uom->name; ?></td>
                    </tr>
                    <?php
                }
                ?>



            </tbody></table>

        <?php // }   ?>
    </div> 
    <br>
    <?php if($model_issue->remarks!=''){ ?>
    <div class="box" style="width: 100%">
        <h5>Remarks</h5>
        <div class="h12sub-details">
            <?php echo nl2br($model_issue->remarks); ?>
        </div>
    </div>
    <?php  }   
    if($model_issue->notes!=''){
    ?>
    <div class="box"  style="width: 100%">
        <h5>Notes</h5>
        <div class="h12sub-details">
            <?php echo nl2br($model_issue->notes); ?>
        </div>
    </div>
    <?php } 
    if($model_issue->terms_and_conditions!=''){
    ?>
    <div class="box"  style="width: 100%">
        <h5>Terms and Conditions</h5>
        <div class="h12sub-details">
            <?php echo nl2br($model_issue->terms_and_conditions); ?>
        </div>
    </div>
    <?php } 
     ?>
 <br>
    <?php $this->renderPartial("//common/footer");?>

   
</body>

</html>
