<!DOCTYPE html>
<html>

    <head>
        <title>New Order Movement Analysis</title>
    </head>

    <body>

        <div class="">
    <div class="header" style="width:100%;float: left;padding-bottom:0;">
    <img src="<?php echo  'images/logo/'.Yii::app()->user->pdf_company_logo; ?>"/>
    </div>
            <div class="col-4">
                <?php
                $model = PurchaseMovementAnalysis::model()->findByPk($id);
                ?>
                <div class="input-block">
                    <b><?php echo $id; ?></b>
                </div>
                         	

            </div>
        <div class="col-4">
        <div class="h3" style="margin-top: 0;margin-bottom: 0;text-align: center;color: #0000b3;font-size: 18px;">
        <?php echo "New Order Movement Analysis"; ?>
        </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>Analysis Date</td>
                        <?php $analysis_date = date("d/m/Y", strtotime($model->analysis_date)); ?>
                        <td><?php echo $analysis_date; ?></td>
                    </tr>

                </table>
            </div><br/>
        </div>

       <br>

        <table id="tbl_movement_analysis" class="table table-fixed table-primary dataTable">
            <thead>
                <tr>
                        <th>SI.No</th>
                        <!--th>Part Number</th-->
                        <th>Description</th>
                        <th>Unit</th>
                        <th>365 Days</th>
                        <th>180 Days</th>
                        <th>90 Days</th>
                        <th>30 Days</th>
                        <th>Closing Stock</th>
                        <th>Upcoming Shipment Qty</th>
                        <th>Average Movement</th>
                        <th>Expected 2 Months Movement</th>
                        <th>Expected Closing Stock After 2 Months</th>
                        <th>New Order Proposal Quantity</th>
                        <th>Remarks</th>
                    </tr>
            </thead>
            <tbody>
                <?php
                if((int) $model->approved_by > 0){
                    $model_po_movement_analysis_details = PurchaseMovementAnalysisDetails::model()->findAll(array('condition' => 't.analysis_id="' . $model->id . '" AND proposal_qty > 0'));
                }
                else{
                     $model_po_movement_analysis_details = PurchaseMovementAnalysisDetails::model()->findAll(array('condition' => 't.analysis_id="' . $model->id . '"'));
                }
                /*echo '<pre>';
                print_r($model_po_movement_analysis_details);
                exit;*/
                foreach ($model_po_movement_analysis_details as $i => $eachItem) {
                    ?>
                     <tr>
                                <td><?php echo ($i+1); ?></td>
                                <!--td><?php //echo $eachItem->part_number; ?></td-->
                                <td><?php echo substr($eachItem->description,0,40).'..'; ?></td>
                                <td><?php echo $eachItem->unitdetails->symbol; ?></td>
                                <td class="text-right"><?php echo round($eachItem->days_365); ?></td>
                                <td class="text-right"><?php echo round($eachItem->days_180); ?></td>
                                <td class="text-right"><?php echo round($eachItem->days_90); ?></td>
                                <td class="text-right"><?php echo round($eachItem->days_30); ?></td>
                                <td class="text-right"><?php echo round($eachItem->current_stock); ?></td>
                                <td class="text-right"><?php echo round($eachItem->upcoming_shipment_qty); ?></td>
                                <td class="text-right"><?php echo round($eachItem->average_movement); ?></td>
                                <td class="text-right"><?php echo round($eachItem->expected_2_months_movement); ?></td>
                                <td class="text-right"><?php echo round($eachItem->expected_closing_stock_after_2_months); ?></td>
                                <td class="text-right"><?php echo round($eachItem->proposal_qty); ?></td>
                                <td class="text-right"><?php echo $eachItem->remarks; ?></td>
                            </tr>

<?php
}
?>

            </tbody>
        </table>

    <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>
<img src="<?php echo  'images/logo/pdf_logo_footer.png'; ?>"/>
<!--        <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>
