public function loadModel($id) { $model = LbVendorInvoice::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionajaxUpdateFieldSubject() { $id = $_POST['pk']; $model = LbVendorInvoice::model()->findByPk($id); $model->lb_vd_invoice_subject = $_POST['value']; return $model->save(); }
//// 'type'=>'raw', //// 'value'=>'(SystemList::model()->getItem($data->lb_vd_invoice_category)->system_list_item_name)', //// 'htmlOptions'=>array('width'=>'150'), //// ), // array( // 'header'=>Yii::t('lang','Note'), // 'type'=>'raw', // 'value'=>'$data->lb_vendor_notes', // 'htmlOptions'=>array('width'=>'250'), // ), // array( // 'header'=>Yii::t('lang','Total'), // 'type'=>'raw', // 'value'=>'LbVendorTotal::model()->getVendorTotal($data->lb_record_primary_key,LbVendorTotal::LB_VENDOR_ITEM_TYPE_TOTAL)->lb_vendor_last_tax', // 'htmlOptions'=>array('align'=>'right'), // ), // ) // )); // //// //echo '</div>'; //Vendor Invoice echo '<div>'; echo '<div class="panel-header-title" style="margin-top: -12px;"> <div class="panel-header-title-left"> <h5>Bills</h5> </div> </div>'; $this->Widget('bootstrap.widgets.TbGridView', array('id' => 'lb_vendor_invoice_gridview', 'dataProvider' => LbVendorInvoice::model()->getVendorInvoice(5), 'type' => 'striped bordered condensed', 'columns' => array(array('header' => Yii::t('lang', 'Date'), 'name' => 'lb_customer_id', 'type' => 'raw', 'value' => '$data->lb_vd_invoice_date ? date("d M, Y", strtotime($data->lb_vd_invoice_date)) : ""', 'htmlOptions' => array('width' => '120')), array('header' => Yii::t('lang', 'Bill number'), 'type' => 'raw', 'value' => '"<a href=".Yii::app()->createUrl("lbVendor/supplier/viewSupplier/",array("id"=>$data->lb_record_primary_key)).">$data->lb_vd_invoice_no</a>"', 'htmlOptions' => array('width' => '180')), array('header' => Yii::t('lang', 'Supplier'), 'type' => 'raw', 'value' => 'LbCustomer::model()->customerInformation($data->lb_vd_invoice_supplier_id)->lb_customer_name', 'htmlOptions' => array('width' => '150')), array('header' => Yii::t('lang', 'Total'), 'type' => 'raw', 'value' => 'LbVendorTotal::model()->getVendorTotal($data->lb_record_primary_key,LbVendorTotal::LB_VENDOR_INVOICE_TOTAL)->lb_vendor_last_tax', 'htmlOptions' => array('align' => 'right')), array('header' => Yii::t('lang', 'Status'), 'type' => 'raw', 'value' => 'LbVendorInvoice::model()->getDisplayInvoiceStatus($data->lb_vd_invoice_status)', 'htmlOptions' => array('align' => 'right'))))); // echo '</div>';
echo '</div>'; // end attention echo '<br />'; //echo Yii::t('lang','Category');echo ' '; // $category_arr = SystemList::model()->getItemsForListCode('expenses_category'); // echo CHtml::dropDownList('lb_category_id', '', array(''=>'All')+CHtml::listData($category_arr, 'system_list_item_id', 'system_list_item_name'), array('style'=>'width:150px;'));echo ' '; ?> <div id="container-invoice-customer-subject"> <h4><?php echo Yii::t('lang', 'Subject'); ?> :</h4> <?php $this->widget('editable.EditableField', array('type' => 'textarea', 'inputclass' => 'input-large-textarea', 'emptytext' => 'Enter invoice subject', 'model' => $model, 'attribute' => 'lb_vd_invoice_subject', 'url' => LbVendor::model()->getActionURLNormalized('ajaxUpdateFieldSubject'), 'placement' => 'right', 'htmlOptions' => array('style' => 'text-decoration: none; border-bottom: none; color: rgb(91,183,91)'), 'options' => array())); $lb_invoice_customer_id = $model->lb_record_primary_key; $manage = LbVendorInvoice::model()->findByPk($lb_invoice_customer_id); ?> </div> <script language="javascript"> var lb_invoice_customer_id = "<?php echo $lb_invoice_customer_id; ?> "; var lb_invoice_status = "<?php echo $manage->lb_vd_invoice_status; ?> "; var lbInvoice_choose_customer = false; var lbInvoice_status_draft = false; if(lb_invoice_customer_id!="")
//echo CHtml::link(CHtml::image(Yii::app()->baseUrl . '/images/icons/icon_pdf.png','#', array('class'=>'lb-side-icon')), LbVendor::model()->getActionURL('Vendorpdf',array('id'=>$model->lb_record_primary_key)),array('target'=>'_blank','data-toggle'=>"tooltip",'title'=>"Generate PDF",'class'=>'lb-side-link-invoice'),array('model'=>$model)); ////echo LBApplication::workspaceLink( //// CHtml::image(Yii::app()->baseUrl . '/images/icons/icon_share_2.png', 'Share', array('class'=>'lb-side-icon')), //// Yii::app()->createAbsoluteUrl('lbInvoice/default/GetPublicPDF',array('id'=>$model->lb_record_primary_key)), //// array('data-toggle'=>"tooltip", 'title'=>"Get public URL", 'class'=>'lb-side-link-invoice','target'=>'_blank')); // //echo CHtml::link(CHtml::image(Yii::app()->baseUrl . '/images/icons/icon_share_2.png','#', array('class'=>'lb-side-icon')), //// Yii::app()->createAbsoluteUrl('',array('p'=>$model->lb_invoice_encode)), // '#', // array('target'=>'_blank','data-toggle'=>"tooltip",'onclick'=>'onclickFormGetPublicPDF();return false;','title'=>"Get public URL",'class'=>'lb-side-link-invoice')); // //## Next,Previous,Last,First ########## // // echo CHtml::link(CHtml::image(Yii::app()->baseUrl . '/images/icons/icon_invoice.png', 'Create invoice', array('class'=>'lb-side-icon')),'#', array('data-toggle'=>"tooltip",'onclick'=>'onclickCopyQuotationToInvoice();', 'title'=>"Create invoice", 'class'=>'lb-side-link-invoice')); $model->lb_vendor_status ? $quotation_status = $model->lb_vendor_status : ($quotation_status = ""); $modelInv = LbVendorInvoice::model()->getVendorInvoiceByVendor($model->lb_record_primary_key)->data; $countInv = count($modelInv); $invoiceNo = array(); if ($countInv > 0) { foreach ($modelInv as $modelInvItem) { $invoiceNo[] = $modelInvItem->lb_vendor_no; } } //echo '</div>'; ?> <script language="javascript"> var quotation_status = '<?php echo $quotation_status; ?> '; var quotaiton_status_accepted =false;
*/ //Da thu $total = array(); //Can thu $datatest = array(); //DA chi $datatest1 = array(); //Can chi $datatest2 = array(); $thang = array(); for ($i = 1; $i < 13; $i++) { //Da Thu $payment = LbPayment::model()->getPaymentTotalByMonth($year, $i); array_push($total, intval($payment)); //Can thu $oustanding_invoice = LbInvoice::model()->getTotalInvoiceByMonth($year, $i); array_push($datatest, intval($oustanding_invoice)); //Da chi=totalEx + totalVendor $totalExpenses = LbExpenses::model()->totalExByVDInMonth($i, $year); $totalVendor = LbPaymentVendor::model()->totalPaymentVendorInMonth($i, $year); array_push($datatest1, $totalExpenses + $totalVendor); //Can Chi $totalVendorInvoice = LbVendorInvoice::model()->getVendorInvoiceMonth($i, $year); $totalEx = LbExpenses::model()->getExByMonth($i, $year); array_push($datatest2, $totalVendorInvoice + $totalEx); array_push($thang, intval($i)); } $this->Widget('highcharts.HighchartsWidget', array('htmlOptions' => array(), 'options' => array('chart' => array('type' => 'column', 'colors' => array('#058DC7', '#5bb75b', '#ED561B', '#DDDF00')), 'yAxis' => array('title' => array('text' => '<b>$</b>'), 'style' => array('fontSize' => '14px')), 'xAxis' => array('title' => array('text' => '<b>Month</b>'), 'categories' => $thang, 'labels' => array('style' => array('fontSize' => '14px'))), 'plotOptions' => array('series' => array('pointWidth' => '13')), 'credits' => array('enabled' => false), 'series' => array(array('name' => 'Payment Received', 'data' => $total, 'stack' => 'male'), array('name' => 'Receivable', 'data' => $datatest, 'stack' => 'male'), array('name' => 'Bill Paid', 'data' => $datatest1, 'stack' => 'female'), array('name' => 'Payable', 'data' => $datatest2, 'stack' => 'female'))))); ?>
?> : <span style="font-weight: normal"><?php echo number_format(LbVendorTotal::model()->getTotalVendorPaidByCustomer($data->lb_record_primary_key, "Total Paid"), 2); ?> | </span> <?php echo Yii::t('lang', 'Total Due'); ?> : <span style="font-weight: normal"><?php echo number_format(LbVendorTotal::model()->getTotalVendorByCustomer($data->lb_record_primary_key, "Total Due"), 2); ?> </span> </div> </legend> <?php $invoice_arr = LbVendorInvoice::model()->getInvoicePaidByCustomer($data->lb_record_primary_key); foreach ($invoice_arr as $data_invocie) { $invoice_total = LbVendorTotal::model()->find('lb_vendor_invoice_id=' . intval($data_invocie->lb_record_primary_key)); // echo '<pre>'; // print_r($invoice_total); ?> <h5 style="margin: 20px 0px 5px 0px;font-weight: bold;"> <span> <input class="pdf_checkbox" name="<?php echo $data_invocie->lb_record_primary_key; ?> " type="checkbox" value="<?php echo $data_invocie->lb_record_primary_key; ?> " /> </span>
function actionAjaxCreateVendorInvoice($id) { $model = $this->loadModel($id); $quotationItem = LbVendorItem::model()->getVendorItems($id, LbVendorItem::LB_VENDOR_ITEM_TYPE_LINE, LbVendorItem::LB_QUERY_RETURN_TYPE_MODELS_ARRAY); $quotationDiscount = LbVendorDiscount::model()->getVendorDiscounts($id, LbVendorDiscount::LB_VENDOR_ITEM_TYPE_DISCOUNT, LbVendorDiscount::LB_QUERY_RETURN_TYPE_MODELS_ARRAY); $quotationTax = LbVendorTax::model()->getTaxByVendor($id, LbVendorTax::LB_VENDOR_ITEM_TYPE_TAX, LbVendorTax::LB_QUERY_RETURN_TYPE_MODELS_ARRAY); $quotationTotal = LbVendorTotal::model()->getVendorTotal($model->lb_record_primary_key, LbVendorTotal::LB_VENDOR_ITEM_TYPE_TOTAL); $invoiceModel = new LbVendorInvoice(); $invoice_number_int = LbVendorInvoice::model()->getVINextNum(); $invoiceModel->lb_vd_invoice_no = LbVendorInvoice::model()->formatVINextNumFormatted($invoice_number_int); $invoiceModel->lb_vd_invoice_status = LbVendorInvoice::LB_VD_CODE_OPEN; // invoice date $invoiceModel->lb_vd_invoice_date = date('Y-m-d'); $invoiceModel->lb_vd_invoice_due_date = date('Y-m-d'); // invoice group // $invoiceModel->lb_invoice_group = LbInvoice::LB_INVOICE_GROUP_INVOICE; // invoice base64_decode $invoiceModel->lb_vd_invoice_encode = LbVendorInvoice::model()->setBase64_decodePO(); // invoice note $invoiceModel->lb_vd_invoice_notes = $model->lb_vendor_notes; $invoiceModel->lb_vd_invoice_company_id = $model->lb_vendor_company_id; $invoiceModel->lb_vd_invoice_company_address_id = $model->lb_vendor_company_address_id; $invoiceModel->lb_vd_invoice_supplier_id = $model->lb_vendor_supplier_id; $invoiceModel->lb_vd_invoice_supplier_address_id = $model->lb_vendor_supplier_address; $invoiceModel->lb_vd_invoice_supplier_attention_id = $model->lb_vendor_supplier_attention_id; $invoiceModel->lb_vendor_id = $model->lb_record_primary_key; $invoiceModel->lb_vd_invoice_subject = $model->lb_vendor_subject; $invoiceModel->lb_vd_invoice_category = $model->lb_vendor_category; // invoice internal note // $invoiceModel->lb_invoice_internal_note = $model->lb_quotation_internal_note; if ($invoiceModel->insert()) { // copy line item foreach ($quotationItem as $q_item) { $vendorItem = new LbVendorItem(); $vendorItem->lb_vendor_id = $id; $vendorItem->lb_vendor_invoice_id = $invoiceModel->lb_record_primary_key; $vendorItem->lb_vendor_type = LbVendorItem::LB_VENDOR_INVOICE_ITEM_TYPE_LINE; $vendorItem->lb_vendor_item_quantity = $q_item->lb_vendor_item_quantity; $vendorItem->lb_vendor_item_price = $q_item->lb_vendor_item_price; $vendorItem->lb_vendor_item_amount = $q_item->lb_vendor_item_amount; $vendorItem->lb_vendor_item_description = $q_item->lb_vendor_item_description; $vendorItem->insert(); } // copy tax item foreach ($quotationTax as $q_tax) { $taxInvoiceVendor = new LbVendorTax(); $taxInvoiceVendor->lb_vendor_invoice_id = $invoiceModel->lb_record_primary_key; $taxInvoiceVendor->lb_vendor_id = $id; $taxInvoiceVendor->lb_vendor_type = LbVendorTax::LB_VENDOR_INVOICE_ITEM_TYPE_TAX; $taxInvoiceVendor->lb_vendor_tax_id = $q_tax->lb_vendor_tax_id; $taxInvoiceVendor->lb_tax_name = $q_tax->lb_tax_name; $taxInvoiceVendor->lb_vendor_tax_value = $q_tax->lb_vendor_tax_value; $taxInvoiceVendor->lb_vendor_tax_total = $q_tax->lb_vendor_tax_total; $taxInvoiceVendor->insert(); } // // // copy discount item foreach ($quotationDiscount as $q_discount) { $discountVendorInvoice = new LbVendorDiscount(); $discountVendorInvoice->lb_vendor_id = $id; $discountVendorInvoice->lb_vendor_invoice_id = $invoiceModel->lb_record_primary_key; $discountVendorInvoice->lb_vendor_description = $q_discount->lb_vendor_description; $discountVendorInvoice->lb_vendor_value = $q_discount->lb_vendor_value; $discountVendorInvoice->lb_vendor_type = LbVendorDiscount::LB_VENDOR_INVOICE_ITEM_TYPE_DISCOUNT; $discountVendorInvoice->insert(); } // // // Copy Total $vendorItem = new LbVendorTotal(); $vendorItem->lb_vendor_invoice_id = $invoiceModel->lb_record_primary_key; $vendorItem->lb_vendor_id = $id; $vendorItem->lb_vendor_type = LbVendorTotal::LB_VENDOR_INVOICE_TOTAL; $vendorItem->lb_vendor_subtotal = $quotationTotal->lb_vendor_subtotal; $vendorItem->lb_vendor_total_last_discount = $quotationTotal->lb_vendor_total_last_discount; $vendorItem->lb_vendor_last_tax = $quotationTotal->lb_vendor_last_tax; $vendorItem->lb_vendor_last_paid = $quotationTotal->lb_vendor_last_paid; $vendorItem->lb_vendor_last_outstanding = $quotationTotal->lb_vendor_last_outstanding; $vendorItem->insert(); // redirect Invoice // $url_invoice = $model->customer ? LbInvoice::model()->getViewURL($model->customer->lb_customer_name,null,$invoiceModel->lb_record_primary_key) : LbInvoice::model()->getViewURL("No customer",null,$invoiceModel->lb_record_primary_key); // $this->redirect($url_invoice); } }
/** * json data source for x-editable dropdown to get ADDRESSES */ public function actionDropdownJSON() { $allow_add = isset($_GET['allow_add']) ? $_GET['allow_add'] : NO; $customer_id = isset($_GET['customer_id']) ? $_GET['customer_id'] : 0; $invoice_id = isset($_GET['invoice_id']) ? $_GET['invoice_id'] : 0; $quotation_id = isset($_GET['quotation_id']) ? $_GET['quotation_id'] : 0; $vendor_id = isset($_GET['vendor_id']) ? $_GET['vendor_id'] : 0; $lb_vendor_invoice_id = isset($_GET['lb_vendor_invoice_id']) ? $_GET['lb_vendor_invoice_id'] : 0; // override customer id if invoice id is provided if ($invoice_id) { $invoice = LbInvoice::model()->findByPk($invoice_id); $customer_id = $invoice->lb_invoice_customer_id; } if ($vendor_id) { $vendor = LbVendor::model()->findByPk($vendor_id); $customer_id = $vendor->lb_vendor_supplier_id; } if ($lb_vendor_invoice_id) { $vendor_invoice = LbVendorInvoice::model()->findByPk($lb_vendor_invoice_id); $customer_id = $vendor_invoice->lb_vd_invoice_supplier_id; } // override customer id if quotation id is provided if ($quotation_id) { $quotation = LbQuotation::model()->findByPk($quotation_id); $customer_id = $quotation->lb_quotation_customer_id; } // get results; $results = LbCustomerAddress::model()->getAddresses($customer_id, LbCustomerAddress::LB_QUERY_RETURN_TYPE_DROPDOWN_ARRAY); // prepend new address link if allow add new if ($allow_add && $allow_add != 2) { $results = array('0' => 'Choose address', '-1' => '-- Add new address --') + $results; } if ($vendor_id || $lb_vendor_invoice_id) { $results = array('0' => 'Choose address') + $results; } // we want to preserve order $ordered_results = array(); foreach ($results as $key => $text) { $ordered_results[] = array('value' => $key, 'text' => $text); } LBApplication::renderPartial($this, '//layouts/plain_ajax_content', array('content' => CJSON::encode($ordered_results))); }
<?php /* @var $this VendorController */ /* @var $model LbVendor */ LBApplication::renderPartial($this, '_page_header', array('model' => $model)); $canAddInvoice = BasicPermission::model()->checkModules(LbVendorInvoice::model()->getEntityType(), 'add'); $this->renderPartial('_form', array('model' => $model)); // $this->renderPartial('_form_line_items', array('model' => $model, 'modelItemVendor' => $modelItemVendor, 'modelDiscountVendor' => $modelDiscountVendor, 'modelTax' => $modelTax, 'modelTotal' => $modelTotal)); echo '<div style="float: right; z-index: 9999; top: 150px; position: absolute; width: 60px; height: 300px; margin-left: 1030px; border-bottom-right-radius: 5px; border-top-right-radius: 5px; padding: 10px;">'; //if($canAddInvoice) // echo CHtml::link(CHtml::image(Yii::app()->baseUrl . '/images/icons/icon_invoice.png', 'Create invoice', array('class'=>'lb-side-icon')),'#', array('data-toggle'=>"tooltip",'onclick'=>'onclickCopyQuotationToInvoice();', 'title'=>"Create invoice", 'class'=>'lb-side-link-invoice')); echo '</div></div>';
public function actionAjaxUpdateFieldVD() { if ($_POST['name'] = 'lb_vd_invoice_no') { $id = $_POST['pk']; $model = LbVendorInvoice::model()->findByPk($id); $model->lb_vd_invoice_no = $_POST['value']; } return $model->save(); }
public function getVendorInvoiceMonth($month = false, $year = false) { $status = '("' . LbVendorInvoice::LB_VD_CODE_OPEN . '","' . LbVendorInvoice::LB_VD_CODE_OVERDUE . '")'; $modelInvoiceVendor = LbVendorInvoice::model()->findAll('YEAR(lb_vd_invoice_date) = ' . $year . ' AND MONTH(lb_vd_invoice_date) =' . $month . ' AND lb_vd_invoice_status IN ' . $status); $total = 0; foreach ($modelInvoiceVendor as $value) { $total += LbVendorTotal::model()->totalOustanding(LbVendorTotal::LB_VENDOR_INVOICE_TOTAL, $value->lb_record_primary_key); } return $total; }
<?php if (isset($_REQUEST['customer_id'])) { $customer_id = $_REQUEST['customer_id']; } $invoice = LbVendorInvoice::model()->getInvoiceAmountByCustomer($customer_id); $this->widget('bootstrap.widgets.TbGridView', array('id' => 'payment_invoice_grid', 'type' => 'bordered', 'dataProvider' => $invoice, 'columns' => array(array('header' => '#', 'type' => 'raw', 'value' => 'CHtml::checkBox("payment_check[]","",array( "id"=>"check_payment_invoice_{$data->lb_record_primary_key}", "onclick"=>"select_apply_invoice({$data->lb_record_primary_key})", "value"=>"{$data->lb_record_primary_key}"))', 'htmlOptions' => array('style' => 'width: 10px; '), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('header' => Yii::t('lang', 'Vendor Invoice No'), 'type' => 'raw', 'value' => 'CHtml::encode($data->lb_vd_invoice_no)', 'htmlOptions' => array('style' => 'width: 150px; '), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('header' => Yii::t('lang', 'Amount Due'), 'type' => 'raw', 'value' => 'CHtml::textField("amount_due_{$data->lb_record_primary_key}",LbVendorTotal::model()->getVendorTotal("{$data->lb_record_primary_key}",LbVendorTotal::LB_VENDOR_INVOICE_TOTAL)->lb_vendor_last_outstanding,array( "style"=>"width: 110px;text-align: right; padding-right: 0px; border: none;box-shadow: none;background:#ffffff;", "disabled"=>"disabled", "id"=>"amount_due_{$data->lb_record_primary_key}", ))', 'htmlOptions' => array('style' => 'width: 80px;text-align:right;'), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('header' => Yii::t('lang', 'Payment'), 'type' => 'raw', 'value' => 'CHtml::textField("payment[]", "0.00",array("onkeyup"=>"TotalPaymentAmount()", "style"=>"width: 110px;text-align: right; padding-right: 0px; border-top: none; border-left: none; border-right: none; box-shadow: none;", "id"=>"payment_{$data->lb_record_primary_key}", "disabled"=>"disabled", ))', 'htmlOptions' => array('style' => 'width: 130px;text-align: right; '), 'headerHtmlOptions' => array('class' => 'lb-grid-header')), array('header' => Yii::t('lang', 'Notes'), 'type' => 'raw', 'value' => 'CHtml::textArea("payment_note[]","",array( "style"=>"width: 250px; border-top: none; border-left: none; border-right: none; box-shadow: none;", "id"=>"payment_note_{$data->lb_record_primary_key}", ))', 'htmlOptions' => array('style' => 'width: 100px; '), 'headerHtmlOptions' => array('class' => 'lb-grid-header'))))); ?> <?php if (count($invoice->data)) { ?> <div style="width:100%;overflow:hidden;margin-bottom: 50px;text-align: right;font-weight: bold;"> <div style="float:left;width:245px;">Total:</div> <div style="float:left;width:167px;" id="total_payment_amount"><?php