<!DOCTYPE html>
<html>

    <head>
        <title>Invoice List</title>
    </head>

    <body>
        <div class="heading">
            <div class="logo col-6">
                <img src="<?php echo 'images/logo/' . Yii::app()->user->pdf_company_logo; ?>" class="logo">
            </div>

        <?php 
            $modelDemo = DemoItemGeneral::model()->findByPK($id);
            $modelDemoItems = DemoItemDetails::model()->findAll(array('condition' =>'demo_monitoring_id = '.$id.' '));
        
        ?>

        </div>
        <div class="clearfix"></div>
        <div class="title">
            <div class="col-6">
                <div style="height: 10px;"></div>
            </div>
            <div class="col-6 text-right">
                <h1>SAMPLE TRACKING</h1>
                <div class="details-box">
                    <div class="pull-right">
                        <div class="filter_details">

                            <?php
                        
                                ?>
                                <div class="filter-item">
                                    <label>Issue Date : </label>
                                    <?php echo date('d/m/Y',strtotime($modelDemo->item_issue_date)) ?>
                                </div>
                                <?php
                            
                            ?>
                            <?php
                          
                                ?>
                                <div class="filter-item">
                                    <label>Reference:</label>
                                    <?php echo $modelDemo->reference ?>
                                </div>
                                <?php
                           
                            ?>
                            <?php
                           
                                ?>
                                <!-- <div class="filter-item ">
                                    <label>Terms Conditions :</label>
                                    <?php // echo $modelDemo->terms_conditions; ?>
                                </div> -->
                                <?php
                            
                            ?>
                          

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="clearfix"></div><br>
        <div class="table-body">
            <table id="tbl_enquiry_table" class="table ">
                <thead>
                    <tr>
                            <th>Sl No</th><th>Item No</th>
							<th>Description</th>
							<th>Serial No</th>
							<th>Qty</th>
						

                    </tr>
                </thead>
                <tbody>
                  <?php
						$j=0;
						foreach ($modelDemoItems as $i => $model) { 
                                                    $SQL="SELECT SUM(return_qty) AS returned_qty FROM crm_demo_item_details_return WHERE demo_item_id=".$model->id;
						$arr_returned_qty=Yii::app()->db->createCommand($SQL)->queryAll();
						$returned_qty =  $arr_returned_qty[0]['returned_qty'];
						
						$balance_qty = (int) ($model->picked_qty-$returned_qty);
                                                    ?>
						<tr>
							<td><label><?php echo ($i)+1 ?></label></td>
							<td>
							<label><?php echo $model->product->part_number; ?></label>

						</td>
						<td>
							<label><?php echo $model->description; ?></label>
						</td>
						<td>
							<label><?php echo $model->item_serial_no; ?></label>
						</td>
						<td>
							<label><?php echo $model->picked_qty; ?></label>
						</td>
					
					</tr>
					<?php } ?>
                </tbody>
            </table>
        </div>
        
    <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>

    
        <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>
