  <div class="panel">
     <div class="panel-heading panel-theme clearfix report-head"> Purchase Invoices <div class="pull-right">
             <div class="filter_details"> <?php if ($order_from_date != '') {                    ?> <div class="filter-item"> <label>Order From :</label> <?php echo $order_from_date ?> </div> <?php                }            ?> <?php if ($order_to_date != '') {                    ?> <div class="filter-item"> <label>Order To :</label> <?php echo $order_to_date ?> </div> <?php                }            ?> <?php if ($vendor_id != '') {                    ?> <div class="filter-item"> <label>Supplier :</label> <?php $v = Vendor::model()->findByPK($vendor_id);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        echo $v->vendor_name; ?> </div> <?php                }            ?> </div>
         </div>
     </div>
     <div class="panel-body">
         <div class="table-responsive">
             <table id="tbl_order_table" class="table table-fixed table-bordered table-primary dataTable html_table">
                 <thead>
                     <tr>
                         <th>No</th>
                         <th>File No.</th>
                         <th>PO No</th>
                         <th>Inv No</th>
                         <th>Invoice Date</th>
                         <th>Supplier</th>
                         
                         <th class="text-center">Value</th>
                         <th class="text-center">Value(BC)</th>
                     </tr>
                 </thead>
                 <tbody> <?php $condition = '1=1';;
                            if ($order_from_date != '') {
                                $order_from_date = str_replace('/', '-', $order_from_date);
                                $order_from_date = date('Y-m-d', strtotime($order_from_date));
                                $condition .= ' AND t.invoice_date >="' . $order_from_date . '"';
                            }
                            if ($order_to_date != '') {
                                $order_to_date = str_replace('/', '-', $order_to_date);
                                $order_to_date = date('Y-m-d', strtotime($order_to_date));
                                $condition .= ' AND t.invoice_date <="' . $order_to_date . '"';
                            }
                            if ($vendor_id != '') {
                                $condition .= ' AND t.vendor_id ="' . $vendor_id . '"';
                            }
                            $total = 0;
                            $model_order = PurchasingInvoice::model()->with('vendor_details')->findAll(array('condition' => $condition, 'order' => 't.id DESC'));
                            foreach ($model_order as $i => $model) {            ?> <input type="hidden" id="order_from_date" name="order_from_date" value="<?php echo $order_from_date; ?>"> <input type="hidden" id="order_to_date" name="order_to_date" value="<?php echo $order_to_date; ?>"> <input type="hidden" id="project_id" name="project_id" value="<?php echo $project_id; ?>"> <input type="hidden" id="vendor_id" name="vendor_id" value="<?php echo $vendor_id; ?>">
                         <tr>
                             <td> <?php echo $i + 1; ?> </td>
                             <td> <?php echo $model->file_id; ?> </td>
                             <td> <?php echo $model->po_id; ?> </td>
                             <td> <?php echo $model->id; ?> </td>
                             <?php if ($model->invoice_date != '0000-00-00') { ?> <td> <?php echo date("d/m/Y", strtotime($model->invoice_date)); ?> </td> <?php } else { ?> <td>&nbsp;</td>  <?php } ?>
                             <td class="nw"> <?php echo $model->vendor_details->vendor_name; ?> </td> <td class="text-right"> <?php echo $model->currencyname->currency_code . " "; ?><?php echo Yii::app()->numberFormatter->formatCurrency($model->grand_total, ""); ?> </td> <?php $model_currency = MasCurrency::model()->findByPk($model->currencyname->id);
                                                                                                                                                                                                                                                                                                                                                                                                                                                $grand_total = $model->grand_total;
                                                                                                                                                                                                                                                                                                                                                                                                                                                $total_bc = $grand_total * $model_currency->exchange_rate;
                                                                                                                                                                                                                                                                                                                                                                                                                                                $total += $total_bc ?> <td class="text-right"> <?php echo Yii::app()->numberFormatter->formatCurrency($total_bc, " "); ?> </td>
                         </tr> <?php }  ?> <tr>
                         <td colspan="7" class="text-right"><b> Total</b></td>
                         <td class="text-right"><b> <?php echo Yii::app()->numberFormatter->formatCurrency($total, " "); ?></b> </td>
                     </tr>
                 </tbody>
             </table> <br>
             <!-- Pdf & Excel btn moved to filter page -- commented --- Ambika --->
<!--             <div class="btn-wrap text-center"> 
                 <?php echo CHtml::link('Export PDF', array('reports/PrintInvoiceListReportPDF', 'order_from_date' => $order_from_date, 'order_to_date' => $order_to_date, 'vendor_id' => $vendor_id, 'project_id' => $project_id), array('title' => 'Print Purchase Order List', 'target' => '_blank', 'class' =>  'btn btn-theme')); ?> 
                 <button type="button" class="btn btn-theme" onclick="excelPurchaseInvoiceList();">Export Excel</button> 
             </div>-->
         </div>
     </div>
 </div><?php $cs = Yii::app()->getClientScript();
 // --- excelPurchaseInvoiceList() -- moved to filter page --- commented ---- Ambika --->
//        $cs->registerScript("excelPurchaseInvoiceList", "function excelPurchaseInvoiceList(){  var url= '" . Yii::app()->createUrl('reports/PrintPurchaseInvoiceExcel') . "';            var order_from_date = $('#order_from_date').val();            var order_to_date = $('#order_to_date').val();                        var vendor_id = $('#vendor_id').val();    window.open($('#liveSite').val()+'index.php?r=reports/PrintPurchaseInvoiceExcel&order_from_date='+order_from_date+'&order_to_date='+order_to_date+'&vendor_id='+vendor_id, '_blank');}", CClientScript::POS_HEAD);
        $cs->registerScript("excelOrderList", "function excelOrderList(){  var url= '" . Yii::app()->createUrl('reports/PrintOrderExcel') . "';  var order_from_date = $('#order_from_date').val();            var order_to_date = $('#order_to_date').val();            var delivery_from_date = $('#delivery_from_date').val();            var delivery_to_date = $('#delivery_to_date').val();            var customer_id = $('#customer_id').val();            var sales_group = $('#sales_group').val();            var payment_terms = $('#payment_terms').val();            var type_of_contract = $('#type_of_contract').val();    window.open($('#liveSite').val()+'index.php?r=reports/PrintOrderExcel&order_from_date='+order_from_date+'&order_to_date='+order_to_date+'&delivery_from_date='+delivery_from_date+'&delivery_to_date='+delivery_to_date+'&customer_id='+customer_id+'&sales_group='+sales_group+'&payment_terms='+payment_terms+'&type_of_contract='+type_of_contract, '_blank');}", CClientScript::POS_HEAD);
        $cs->registerScript("excelEnquiryListId", "function excelEnquiryListId(id){    var url= '" . Yii::app()->createUrl('reports/PrintEnquiryExcelId') . "';    var enquiry_id = id;    var start_date = $('#start_date').val();    var end_date = $('#end_date').val();    var status = $('#status').val();    window.open($('#liveSite').val()+'index.php?r=reports/PrintEnquiryExcelId&start_date='+start_date+'&end_date='+end_date+'&status='+status+'&enquiry_id='+enquiry_id, '_blank');}", CClientScript::POS_HEAD);
