public function addSupplier() { $this->lb_vd_invoice_no = 0; $this->lb_vd_invoice_no = $this->formatNumberNextNumFormatted($this->lb_vd_invoice_no); $this->lb_vd_invoice_date = date('Y-m-d'); $this->lb_vd_invoice_due_date = date('Y-m-d'); $this->lb_vd_invoice_status = self::LB_VD_STATUS_CODE_DRAFT; $this->lb_vd_invoice_encode = $this->setBase64_decodePO(); $this->lb_vd_invoice_notes = ''; $ownCompany = LbCustomer::model()->getOwnCompany(); $ownCompanyAddress = null; $customerCompany = new LbCustomer(); $customerCompany->lb_customer_name = 'Click to choose customer'; // get own company address if ($ownCompany->lb_record_primary_key) { // auto assign owner company $this->lb_vd_invoice_company_id = $ownCompany->lb_record_primary_key; $own_company_addresses = LbCustomerAddress::model()->getActiveAddresses($ownCompany->lb_record_primary_key, $ownCompany::LB_QUERY_RETURN_TYPE_MODELS_ARRAY); if (count($own_company_addresses)) { $ownCompanyAddress = $own_company_addresses[0]; // auto assign owner company's address $this->lb_vd_invoice_company_address_id = $ownCompanyAddress->lb_record_primary_key; } } if ($this->insert()) { return $this->lb_record_primary_key; } return false; }
if ($file_name_arr[0] == $subcription && $file_name_arr[1] == $company) { echo "<img src='" . $path . $file . "' style='max-height:120px' />"; } } $this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => 'uploadFile', 'config' => array('action' => $this->createUrl('uploadLogo', array('id' => $model->lb_record_primary_key, 'sub_cription' => $subcription, 'company_id' => $company)), 'allowedExtensions' => array("jpeg", "jpg", "gif", "png"), 'sizeLimit' => 10 * 1024 * 1024, 'minSizeLimit' => 1 * 1024, 'multiple' => true, 'onComplete' => "js:function(id, fileName, responseJSON){\n \$('#uploadFile .qq-upload-list').html('');\n //\$('#logo_wrapper img').attr('src','" . $path . "'+fileName);\n window,location.reload(true);\n }"))); echo '</div>'; //echo '<h3 id="po-number-container">'.$model->getDisplayPOStatus($model->lb_vendor_status).'</h3>'; echo '<div id="invoice-basic-info-container" style="float: left;width:36%;">'; echo '<h3 id="po-number-container">'; $this->widget('editable.EditableField', array('type' => 'text', 'model' => $model, 'attribute' => 'lb_vd_invoice_no', 'url' => LbVendor::model()->getActionURLNormalized('AjaxUpdateFieldVD'), 'placement' => 'right')); echo '</h3><br />'; //date echo Yii::t('lang', 'Date') . ': '; $this->widget('editable.EditableField', array('type' => 'text', 'model' => $model, 'attribute' => 'lb_vd_invoice_date', 'url' => LbVendor::model()->getActionURLNormalized('ajaxUpdateFieldInvoice'), 'placement' => 'right')); echo ' '; echo Yii::t('lang', 'Due Date') . ': '; $this->widget('editable.EditableField', array('type' => 'text', 'model' => $model, 'attribute' => 'lb_vd_invoice_due_date', 'url' => LbVendor::model()->getActionURLNormalized('ajaxUpdateFieldInvoice'), 'placement' => 'right')); echo '<br>'; echo '<div>'; echo Yii::t('lang', 'Status') . ': '; echo '<span id="lb_invocie_status">'; echo $model->getDisplayInvoiceStatus($model->lb_vd_invoice_status); echo '</span>'; echo '</div>'; echo '</div>'; echo '<div class="pull-right" style="text-align: right; margin-right: 25px;width:60%">'; $modelCustomer = LbCustomer::model()->find('lb_record_primary_key=' . $model->lb_vd_invoice_company_id); echo '<h3>' . $modelCustomer->lb_customer_name . '</h3><br/>'; echo 'Registration No: ' . $modelCustomer->lb_customer_registration . '. '; echo $modelCustomer->lb_customer_website_url != NULL ? 'Website: ' . $modelCustomer->lb_customer_website_url . '<br>' : ''; echo '</div>';
//Permission Quotation $quotation_canAdd = BasicPermission::model()->checkModules('lbQuotation', 'add'); $quotation_canView = BasicPermission::model()->checkModules('lbQuotation', 'view'); //Permission Bills $bill_canAdd = BasicPermission::model()->checkModules('lbVendor', 'add'); $bill_canView = BasicPermission::model()->checkModules('lbVendor', 'view'); //Permission Report $report_canView = BasicPermission::model()->checkModules('lbReport', 'view'); $home_img = CHtml::image(Yii::app()->request->baseUrl . '/images/logo_home.png', '', array('height' => 30, 'width' => 30, 'style' => "margin-top:-5px")); ?> <div class="container" id="page"> <div id="lb-top-menu"> <?php $ownCompany = LbCustomer::model()->getOwnCompany(); $this->widget('bootstrap.widgets.TbNavbar', array('brand' => false, 'brandUrl' => isset(Yii::app()->user) ? LbInvoice::model()->getActionURL('dashboard') : Yii::app()->createUrl('site/login'), 'items' => array(array('class' => 'bootstrap.widgets.TbMenu', 'items' => array()), array('class' => 'bootstrap.widgets.TbMenu', 'encodeLabel' => false, 'htmlOptions' => array('class' => 'pull-left'), 'items' => array(array('label' => $home_img, 'url' => LbInvoice::model()->getActionURL('dashboard')), array('label' => Yii::t('lang', 'Customers'), 'url' => LbCustomer::model()->getAdminURL(), 'visible' => !Yii::app()->user->isGuest && Modules::model()->checkHiddenModule('lbCustomer'), 'items' => array(array('label' => Yii::t('lang', '<i class="icon-plus"></i> New Customer'), 'url' => LbCustomer::model()->getCreateURL(), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $customer_canAdd), '---', array('label' => Yii::t('lang', 'All Customers'), 'url' => LbCustomer::model()->getAdminURL(), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $customer_canView), array('label' => Yii::t('lang', 'Contracts'), 'url' => LbContracts::model()->getActionURL('dashboard'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $customer_canView), array('label' => Yii::t('lang', 'My Company'), 'url' => LbCustomer::model()->getActionURLNormalized('view', array('id' => $ownCompany->lb_record_primary_key)), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $customer_canView))), array('label' => Yii::t('lang', 'Income'), 'url' => LbInvoice::model()->getActionURL('dashboard'), 'visible' => !Yii::app()->user->isGuest && Modules::model()->checkHiddenModule('lbInvoice'), 'items' => array(array('label' => Yii::t('lang', '<i class="icon-plus"></i> New Invoice'), 'url' => LbInvoice::model()->getCreateURLNormalized(array('group' => strtolower(LbInvoice::LB_INVOICE_GROUP_INVOICE))), 'visible' => $invoice_canAdd), array('label' => Yii::t('lang', '<i class="icon-plus"></i> New Quotation'), 'url' => LbQuotation::model()->getCreateURLNormalized(), 'visible' => $quotation_canAdd), array('label' => Yii::t('lang', '<i class="icon-plus"></i> Enter Payment'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbPayment::model()->getCreateURLNormalized(), 'visible' => $quotation_canAdd), '---', array('label' => Yii::t('lang', 'Outstanding Invoices and Quotations'), 'linkOptions' => array('href' => LbInvoice::model()->getActionURL('dashboard'), 'data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbInvoice::model()->getActionURL('dashboard'), 'visible' => $invoice_canView), array('label' => Yii::t('lang', 'All Invoices'), 'linkOptions' => array('href' => LbInvoice::model()->getActionURL('admin'), 'data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbInvoice::model()->getActionURL('admin'), 'visible' => $invoice_canView), array('label' => Yii::t('lang', 'All Quotations'), 'linkOptions' => array('href' => LbQuotation::model()->getActionURL('admin'), 'data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbQuotation::model()->getActionURL('admin'), 'visible' => $quotation_canView))), array('label' => Yii::t('lang', 'Expenses'), 'items' => array(array('label' => Yii::t('lang', 'All Expenses'), 'linkOptions' => array('href' => LbExpenses::model()->getActionURL('expenses'), 'data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbExpenses::model()->getActionURL('expenses'), 'visible' => $expenses_canView), array('label' => Yii::t('lang', 'All Payment voucher'), 'linkOptions' => array('href' => LbExpenses::model()->getActionURL('paymentVoucher'), 'data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'url' => LbExpenses::model()->getActionURL('paymentVoucher'), 'visible' => $expenses_canView))), array('label' => Yii::t('lang', 'Bills'), 'url' => LbVendor::model()->getActionURL('dashboard'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => !Yii::app()->user->isGuest && Modules::model()->checkHiddenModule('lbVendor'), 'items' => array(array('label' => Yii::t('lang', 'Outstanding'), 'url' => LbVendor::model()->getActionURL('dashboard'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $bill_canView), array('label' => Yii::t('lang', 'Make Payment'), 'url' => LbVendor::model()->getActionModuleURL('vendor', 'addPayment'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $bill_canAdd))), array('label' => Yii::t('lang', 'Payroll'), 'url' => LbEmployee::model()->getActionURL('dashboard'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => !Yii::app()->user->isGuest && Modules::model()->checkHiddenModule('lbVendor'), 'items' => array(array('label' => Yii::t('lang', 'All Employees'), 'url' => LbEmployee::model()->getActionURL('dashboard'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $bill_canView), array('label' => Yii::t('lang', 'Make Payment'), 'url' => LbEmployee::model()->getActionURL('EnterPayment'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $bill_canAdd), array('label' => Yii::t('lang', 'All Payment'), 'url' => LbEmployee::model()->getActionURL('ListPayment'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $bill_canView))), array('label' => Yii::t('lang', 'Report'), 'url' => array('/lbReport/default/index'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => !Yii::app()->user->isGuest && Modules::model()->checkHiddenModule('lbReport'), 'items' => array(array('label' => Yii::t('lang', 'All'), 'url' => array('/lbReport/default/index?tab=all'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Aging Report'), 'url' => array('/lbReport/default/index?tab=aging_report'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Cash Receipt'), 'url' => array('/lbReport/default/index?tab=cash_receipt'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Invoice Journal'), 'url' => array('/lbReport/default/index?tab=invoice_journal'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'GST Report'), 'url' => array('/lbReport/default/index?tab=gst_report'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Sales Report'), 'url' => array('/lbReport/default/index?tab=sales_report'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Customer Statement'), 'url' => array('/lbReport/default/index?tab=customer_statement'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Employee Report'), 'url' => array('/lbReport/default/index?tab=employee_report'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView), array('label' => Yii::t('lang', 'Payment Report'), 'url' => array('/lbReport/default/index?tab=payment_report'), 'linkOptions' => array('data-workspace' => '1', 'id' => uniqid(), 'live' => false), 'visible' => $report_canView)))))), 'htmlOptions' => array('class' => 'navbar'))); ?> </div> <div id="lb-top-shortcuts"> <?php $onwSubcriptAccount = AccountSubscription::model()->getSubscriptionOwnerID(LBApplication::getCurrentlySelectedSubscription()); $onwSubcrip = false; if ($onwSubcriptAccount == Yii::app()->user->id) { $onwSubcrip = true; } $linx_app_menu_subscription_items = array(); $selected_subscription_label = 'Subscription'; if (!Yii::app()->user->isGuest) { $linx_app_account_subscriptions = AccountSubscription::model()->findSubscriptions(Yii::app()->user->id); foreach ($linx_app_account_subscriptions as $sub_id => $subscription) {
} } $this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => 'uploadFile', 'config' => array('action' => $this->createUrl('uploadLogo', array('id' => $model->lb_record_primary_key, 'sub_cription' => $subcription, 'company_id' => $company)), 'allowedExtensions' => array("jpeg", "jpg", "gif", "png"), 'sizeLimit' => 10 * 1024 * 1024, 'minSizeLimit' => 1 * 1024, 'multiple' => true, 'onComplete' => "js:function(id, fileName, responseJSON){\n \$('#uploadFile .qq-upload-list').html('');\n //\$('#logo_wrapper img').attr('src','" . $path . "'+fileName);\n window,location.reload(true);\n }"))); echo '</div>'; //echo '<h3 id="po-number-container">'.$model->getDisplayPOStatus($model->lb_vendor_status).'</h3>'; echo '<div id="invoice-basic-info-container" style="float: left;width:36%;">'; echo '<h3 id="po-number-container">'; $this->widget('editable.EditableField', array('type' => 'text', 'model' => $model, 'attribute' => 'lb_vd_invoice_no', 'url' => LbVendor::model()->getActionURLNormalized('AjaxUpdateFieldVD'), 'placement' => 'right')); echo '</h3><br />'; //date echo Yii::t('lang', 'Date') . ': '; $this->widget('editable.EditableField', array('type' => 'text', 'model' => $model, 'attribute' => 'lb_vd_invoice_date', 'url' => LbVendor::model()->getActionURLNormalized('ajaxUpdateFieldInvoice'), 'placement' => 'right')); echo ' '; echo Yii::t('lang', 'Due Date') . ': '; $this->widget('editable.EditableField', array('type' => 'text', 'model' => $model, 'attribute' => 'lb_vd_invoice_due_date', 'url' => LbVendor::model()->getActionURLNormalized('ajaxUpdateFieldInvoice'), 'placement' => 'right')); echo '<br>'; echo '<div>'; echo Yii::t('lang', 'Status') . ': '; echo '<span id="lb_invocie_status">'; echo $model->getDisplayInvoiceStatus($model->lb_vd_invoice_status); echo '</span>'; echo '</div>'; echo '</div>'; echo '<div class="pull-right" style="text-align: right; margin-right: 25px;width:60%">'; $modelCustomer = LbCustomer::model()->findByPk($model->lb_vd_invoice_supplier_id); if (count($modelCustomer) > 0) { echo '<h3>' . $modelCustomer->lb_customer_name . '</h3><br/>'; echo 'Registration No: ' . $modelCustomer->lb_customer_registration . '. '; echo $modelCustomer->lb_customer_website_url != NULL ? 'Website: ' . $modelCustomer->lb_customer_website_url . '<br>' : ''; } echo '</div>';
public function actioncreatePo() { $model = new LbVendor(); // get basic info to assign to this record $ownCompany = LbCustomer::model()->getOwnCompany(); $ownCompanyAddress = null; $customerCompany = new LbCustomer(); $customerCompany->lb_customer_name = 'Click to choose customer'; // get own company address if ($ownCompany->lb_record_primary_key) { // auto assign owner company $model->lb_vendor_company_id = $ownCompany->lb_record_primary_key; $own_company_addresses = LbCustomerAddress::model()->getActiveAddresses($ownCompany->lb_record_primary_key, $ownCompany::LB_QUERY_RETURN_TYPE_MODELS_ARRAY); if (count($own_company_addresses)) { $ownCompanyAddress = $own_company_addresses[0]; // auto assign owner company's address $model->lb_vendor_company_address_id = $ownCompanyAddress->lb_record_primary_key; } } if ($model->save()) { $id = $_GET['id']; $invoiceVendor = LbVendorInvoice::model()->findByPk($id); $invoiceVendor->lb_vendor_id = $model->lb_record_primary_key; $invoiceVendor->save(); $this->redirect(array('view', 'id' => $model->lb_record_primary_key)); } }
$method = LbPaymentVendor::model()->method; $customer_id = false; if (isset($_POST['customer_id']) && $_POST['customer_id'] > 0) { $customer_id = $_POST['customer_id']; } //echo $customer_id; $date_from = date('Y-m-d'); $date_to = date('Y-m-d', strtotime("+1 month -1 day")); $customer_arr = false; if (isset($_POST['search_date_from']) && $_POST['search_date_from'] != "") { $date_from = date('Y-m-d', strtotime($_POST['search_date_from'])); } if (isset($_POST['search_date_to']) && $_POST['search_date_to'] != "") { $date_to = date('Y-m-d', strtotime($_POST['search_date_to'])); } $customer_arr = LbCustomer::model()->getCompaniesByPaymentVendor('lb_customer_name ASC', LbCustomer::LB_QUERY_RETURN_TYPE_MODELS_ARRAY, $customer_id, $date_from, $date_to); //echo '<pre>'; //print_r($customer_arr); ?> <!--<div class ="ab" style="float: right; z-index: 9999; top: 150px; position: fixed; width: 60px; height: 300px; margin-left: 1020px; border-bottom-right-radius: 5px; border-top-right-radius: 5px; padding: 10px;">--> <?php // if($canAdd) // echo LBApplication::workspaceLink( // CHtml::image(Yii::app()->baseUrl . '/images/icons/icon_new.png', 'Share', array('class'=>'lb-side-icon')) // ); // // echo LBApplication::workspaceLink( // CHtml::image(Yii::app()->baseUrl . '/images/icons/icon_payment.png', 'Payment', array('class'=>'lb-side-icon'))
public function actionCreateInvoice($id) { $model = LbContracts::model()->findByPk($id); //********* add new invoice *************/ $invoiceModel = new LbInvoice(); // get basic info to assign to this record $ownCompany = LbCustomer::model()->getOwnCompany(); $ownCompanyAddress = null; $customerCompany = new LbCustomer(); $customerCompany->lb_customer_name = 'Click to choose customer'; // get own company address if ($ownCompany->lb_record_primary_key) { // auto assign owner company $invoiceModel->lb_invoice_company_id = $ownCompany->lb_record_primary_key; $own_company_addresses = LbCustomerAddress::model()->getActiveAddresses($ownCompany->lb_record_primary_key, $ownCompany::LB_QUERY_RETURN_TYPE_MODELS_ARRAY); if (count($own_company_addresses)) { $ownCompanyAddress = $own_company_addresses[0]; // auto assign owner company's address $invoiceModel->lb_invoice_company_address_id = $ownCompanyAddress->lb_record_primary_key; } } // add infor customer in invoice $invoiceModel->lb_invoice_customer_id = $model->lb_customer_id; $invoiceModel->lb_invoice_customer_address_id = $model->lb_address_id; $invoiceModel->lb_invoice_attention_contact_id = $model->lb_contact_id; if ($invoiceModel->save()) { // Save Lien ket contract va invoice $contrctInvoiceModel = new LbContractInvoice(); $contrctInvoiceModel->lb_contract_id = $model->lb_record_primary_key; $contrctInvoiceModel->lb_invoice_id = $invoiceModel->lb_record_primary_key; $contrctInvoiceModel->save(); //Update invoice no vaf status I-OPEN $invoiceModel->confirm(); // add invoice to database right away. // other fields will be updated on the invoice page later on $invoiceModel->saveUnconfirmed(); // // == Prepare line items grid // add 1 line-item by default // $blankItem = new LbInvoiceItem(); $blankItem->lb_invoice_id = $invoiceModel->lb_record_primary_key; $blankItem->lb_invoice_item_description = "Contract payment for contract " . $model->lb_contract_no . ", " . $model->lb_contract_type . ", for period " . $model->lb_contract_date_start . " to " . $model->lb_contract_date_end; $blankItem->lb_invoice_item_quantity = 1; $blankItem->lb_invoice_item_value = 0; $blankItem->lb_invoice_item_total = 0; $blankItem->lb_invoice_item_type = LbInvoiceItem::LB_INVOICE_ITEM_TYPE_LINE; $blankItem->save(); // add tax $blankTax = new LbInvoiceItem(); $default_tax = LbTax::model()->getDefaultTax(); //$value_tax = ($default_tax->lb_tax_value/100) * $model->lb_contract_amount; $blankTax->lb_invoice_id = $invoiceModel->lb_record_primary_key; $blankTax->lb_invoice_item_description = $default_tax !== null ? $default_tax->lb_record_primary_key : 'Tax'; $blankTax->lb_invoice_item_quantity = 1; $blankTax->lb_invoice_item_value = $default_tax !== null ? $default_tax->lb_tax_value : '0'; $blankTax->lb_invoice_item_total = 0; $blankTax->lb_invoice_item_type = LbInvoiceItem::LB_INVOICE_ITEM_TYPE_TAX; $blankTax->save(); $invoiceItemModel = new LbInvoiceItem('search'); $invoiceItemModel->unsetAttributes(); // clear any default values $invoiceItemModel->lb_invoice_id = $invoiceModel->lb_record_primary_key; // totals - create a blank total record, set everything to zero: subtotal, after disc, after tax, paid, outstanding.... $invoiceTotal = new LbInvoiceTotal(); $invoiceTotal->lb_invoice_id = $invoiceModel->lb_record_primary_key; $invoiceTotal->lb_invoice_revision_id = 0; // latest version $invoiceTotal->lb_invoice_subtotal = 0; $invoiceTotal->lb_invoice_total_after_discounts = 0; $invoiceTotal->lb_invoice_total_after_taxes = 0; $invoiceTotal->lb_invoice_total_outstanding = 0; $invoiceTotal->lb_invoice_total_paid = 0; $invoiceTotal->save(); // == end items grid data prep // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $invoiceDiscountModel = new LbInvoiceItem(); $invoiceDiscountModel->lb_invoice_item_type = LbInvoiceItem::LB_INVOICE_ITEM_TYPE_DISCOUNT; $invoiceTaxModel = new LbInvoiceItem(); $invoiceTaxModel->lb_invoice_item_type = LbInvoiceItem::LB_INVOICE_ITEM_TYPE_TAX; //*** End add invoice **/ //LBApplication::redire(array('lbInvoice/default/view','id'=>$invoiceModel->lb_record_primary_key)); $this->redirect(array('view', 'id' => $model->lb_record_primary_key)); } }
public function savePaymentVoucher($pv_no = false, $pv_title = false, $pv_date = false, $pv_description = false, $pv_id = false) { $model = new LbPaymentVoucher(); //company $ownCompany = LbCustomer::model()->getOwnCompany(); $ownCompanyAddress = null; if ($ownCompany->lb_record_primary_key) { // auto assign owner company $model->lb_pv_company_id = $ownCompany->lb_record_primary_key; $own_company_addresses = LbCustomerAddress::model()->getActiveAddresses($ownCompany->lb_record_primary_key, $ownCompany::LB_QUERY_RETURN_TYPE_MODELS_ARRAY); if (count($own_company_addresses)) { $ownCompanyAddress = $own_company_addresses[0]; // auto assign owner company's address $model->lb_pv_company_address_id = $ownCompanyAddress->lb_record_primary_key; } } if ($pv_id) { $model = LbPaymentVoucher::model()->findByPk($pv_id); } if ($pv_no) { $model->lb_payment_voucher_no = $pv_no; } if ($pv_title) { $model->lb_pv_title = $pv_title; } if ($pv_date) { $model->lb_pv_date = DateTime::createFromFormat('d-m-Y', $pv_date)->format('Y-m-d'); } if ($pv_date) { $model->lb_pv_description = $pv_description; } $model->lb_pv_create_by = Yii::app()->user->id; if ($pv_id) { $model->update(); return $pv_id; } if ($model->insert()) { return $model->lb_record_primary_key; } }
<?php //echo LbContracts::model()->getContractCustomer(5); echo '<br/>'; echo '<div style="display: inline">'; // NEW BUTTON //if($canAdd) //{ // LBApplicationUI::newButton(Yii::t('lang','New Customer'), array( // 'url'=>LbCustomer::model()->getCreateURL(), // )); // echo "<br><br><br>"; //} // SEARCH $subcription = LbCustomer::model()->getOwnCompany(); $this->widget('bootstrap.widgets.TbGridView', array('id' => 'lb-customer-grid', 'type' => 'bordered', 'dataProvider' => $model->search($canList), 'filter' => $model, 'columns' => array(array('name' => 'lb_customer_name', 'type' => 'raw', 'value' => 'LBApplication::workspaceLink($data->lb_customer_name, $data->getViewURLNormalized($data->lb_customer_name),array("id"=>$data->lb_record_primary_key))', 'htmlOptions' => array('width' => '40%'), 'headerHtmlOptions' => array('width' => '250', 'id' => '$data->lb_customer_name'), 'filter' => CHtml::activeTextField($model, 'lb_customer_name', array('class' => 'input-mini', 'style' => 'width:90%'))), array('htmlOptions' => array('width' => '20%'), 'headerHtmlOptions' => array('width' => '120'), 'name' => 'lb_customer_registration', 'filter' => CHtml::activeTextField($model, 'lb_customer_registration', array('class' => 'input-mini', 'style' => 'width:90%'))), array('name' => 'lb_customer_website_url', 'htmlOptions' => array('width' => '30%'), 'headerHtmlOptions' => array('width' => '135'), 'filter' => CHtml::activeTextField($model, 'lb_customer_website_url', array('class' => 'input-mini', 'style' => 'width:90%'))), array('class' => 'bootstrap.widgets.TbButtonColumn')))); ?> </div> <style> /* function($data){ return '<span class="badge badge-success">My company</span> ';*/ /*},*/ </style> <script> $('#<?php echo $subcription->lb_record_primary_key; ?> ').append(" <span class='badge badge-success'>My company</span>"); </script>
<?php /* @var $this LbCustomerAddressController */ /* @var $model LbCustomerAddress */ $this->breadcrumbs = array('Lb Customer Addresses' => array('index'), 'Create'); $this->menu = array(array('label' => 'List LbCustomerAddress', 'url' => array('index')), array('label' => 'Manage LbCustomerAddress', 'url' => array('admin'))); ?> <div style="overflow: hidden;"> <div style="float: left;width: 300px;"> <h1>New Address</h1> </div> <div style="text-align: right;"> <h3><?php echo LbCustomer::model()->findByPk($customer_id)->lb_customer_name; ?> </h3> </div> </div> <?php $this->renderPartial('_form', array('model' => $model));
// 'lb_record_primary_key', // 'lb_category_id', // 'lb_expenses_amount', // 'lb_expenses_date', // 'lb_expenses_recurring_id', // 'lb_expenses_brank_account_id', // 'lb_expenses_note', // ), //)); //echo '<div style="float: left; width: 49%;">'; $this->widget('editable.EditableDetailView', array('id' => 'expenses-detail', 'data' => $model, 'url' => $model->getActionURL('ajaxUpdateField'), 'placement' => 'right', 'attributes' => array(array('name' => 'lb_expenses_no', 'editable' => false), array('name' => 'lb_category_id', 'editable' => array('type' => 'select', 'source' => array('0' => 'Choose Category') + CHtml::listData(SystemList::model()->getItemsForListCode('expenses_category'), 'system_list_item_id', 'system_list_item_name'))), array('name' => 'lb_expenses_date', 'editable' => array('type' => 'date', 'viewformat' => 'dd-mm-yyyy', 'format' => 'yyyy-mm-dd')), 'lb_expenses_amount', array('name' => 'lb_expenses_note', 'editable' => array('type' => 'textarea')), array('name' => 'lb_expenses_recurring_id', 'editable' => array('type' => 'select', 'source' => array('0' => 'Choose Recurring') + CHtml::listData(UserList::model()->getItemsForListCode('recurring'), 'system_list_item_id', 'system_list_item_name'))), array('name' => 'lb_expenses_bank_account_id', 'editable' => array('type' => 'select', 'source' => array('' => 'Choose bank account') + CHtml::listData(UserList::model()->getItemsForListCode('BankAcount'), 'system_list_item_id', 'system_list_item_name')))))); $customers = LbExpensesCustomer::model()->getCustomerExpenses($model->lb_record_primary_key); $customer_view = ''; if (count($customers) > 0) { foreach ($customers as $cus) { $client = LbCustomer::model()->findByPk($cus->lb_customer_id); $customer_view .= $client['lb_customer_name'] . '; '; } } $invoices = LbExpensesInvoice::model()->getExpensesInvoice($model->lb_record_primary_key); $invoice_view = ''; if (count($invoices) > 0) { foreach ($invoices as $inv) { $invoice = LbInvoice::model()->findByPk($inv->lb_invoice_id); $invoice_view .= $invoice['lb_invoice_no'] . '; '; } } // echo '</div><div style="float: right; width: 49%;">'; // echo '</div>'; $id = $model->lb_record_primary_key; ?>
<b>Registration No: </b>' . $modelCustomer->lb_customer_registration . '. ' . ($modelCustomer->lb_customer_website_url != NULL ? '<b>Website: </b>' . $modelCustomer->lb_customer_website_url . '<br>' : '') . ' </td> </tr> <tr> <td><b>Status: </b>' . $model->lb_vendor_status . '</td> </tr> </table> '; echo $tbl; $customerName = false; if ($model->lb_vendor_supplier_id) { $customerName = LbCustomer::model()->findByPk($model->lb_vendor_supplier_id)['lb_customer_name']; } $billingName = false; if ($model->lb_vendor_supplier_address) { $informationAdd = LbCustomerAddress::model()->findByPk($model->lb_vendor_supplier_address); $billingName = $informationAdd['lb_customer_address_line_1'] . '. ' . $informationAdd['lb_customer_address_line_2'] . '<br />'; // $billingName .=$informationAdd['lb_customer_address_postal_code'].'<br>'; // $billingName .=$informationAdd['lb_customer_address_website_url'].'<br>'; } $attentionInformation = false; if ($model->lb_vendor_supplier_attention_id) { $attention = LbCustomerContact::model()->findByPk($model->lb_vendor_supplier_attention_id); $attentionInformation = $attention['lb_customer_contact_first_name'] . ' ' . $attention['lb_customer_contact_last_name']; } $list_name = false; if ($model->lb_vendor_category) {
// 'value'=> number_format($model->lb_contract_amount, 2), // ) //// 'lb_customer_id', //// 'lb_address_id', //// 'lb_contact_id', //// 'lb_contract_no', //// 'lb_contract_notes', //// 'lb_contract_date_start', //// 'lb_contract_date_end', //// 'lb_contract_type', //// 'lb_contract_amount', //// 'lb_contract_parent', //// 'lb_contract_status', // ), //)); $this->widget('editable.EditableDetailView', array('id' => 'user-details', 'data' => $model, 'url' => $model->getActionURL('ajaxUpdateField'), 'placement' => 'right', 'attributes' => array(array('name' => 'lb_customer_id', 'editable' => array('type' => 'select', 'source' => CHtml::listData(LbCustomer::model()->findAll(), 'lb_record_primary_key', 'lb_customer_name'))), array('name' => 'lb_address_id', 'editable' => array('type' => 'select', 'source' => CHtml::listData(LbCustomerAddress::model()->findAll(), 'lb_record_primary_key', 'lb_customer_address_line_1'))), array('name' => 'lb_contact_id', 'editable' => array('type' => 'select', 'source' => CHtml::listData(LbCustomerContact::model()->getResultsAsFindAll(), 'lb_record_primary_key', 'lb_customer_contract_name'))), array('name' => 'lb_contract_date_start', 'editable' => array('type' => 'date', 'viewformat' => 'dd-mm-yyyy', 'format' => 'yyyy-mm-dd')), array('name' => 'lb_contract_date_end', 'editable' => array('type' => 'date', 'viewformat' => 'dd-mm-yyyy', 'format' => 'yyyy-mm-dd')), array('name' => 'lb_contract_type', 'editable' => array('type' => 'text')), array('name' => 'lb_contract_notes', 'editable' => array('type' => 'textarea')), array('name' => 'lb_contract_status', 'editable' => array('type' => 'select', 'source' => LbContracts::$ContractStatusArray)), 'lb_contract_amount'))); ?> <div style="margin-top: 30px;"> <h4><?php echo Yii::t('lang', 'Document'); ?> </h4> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'lb-contracts-documnet_grid', 'dataProvider' => LbContractDocument::model()->getContractDocument($model->lb_record_primary_key), 'template' => '{items}', 'hideHeader' => true, 'htmlOptions' => array('width' => '500'), 'columns' => array(array('type' => 'raw', 'value' => '"<a href=\'".Yii::app()->getBaseUrl().$data->lb_document_url."\'><img border=\'0\' alt=\'\' src=\'".Yii::app()->getBaseUrl().$data->lb_document_url_icon."\' />".$data->lb_document_name."</a>"'), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => "{delete}", 'deleteButtonUrl' => 'Yii::app()->createUrl("lbContract/default/deleteDocument",array("id"=>$data->lb_record_primary_key))', 'htmlOptions' => array('width' => '20'))))); ?> <div> <?php if ($canEdit) { $this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => 'uploadFile', 'config' => array('action' => $this->createUrl('uploadDocument', array('id' => $model->lb_record_primary_key)), 'allowedExtensions' => array("jpeg", "jpg", "gif", "png", "pdf", "odt", "docx", "doc", "dia"), 'sizeLimit' => 10 * 1024 * 1024, 'minSizeLimit' => 1 * 1024, 'onComplete' => "js:function(id, fileName, responseJSON){\n \$.fn.yiiGridView.update('lb-contracts-documnet_grid');\n \$('#uploadFile .qq-upload-list').html('');\n }"))); } ?>
</div> <style> /* function($data){ return '<span class="badge badge-success">My company</span> ';*/ /*},*/ </style> <script> $('#<?php echo $subcription->lb_record_primary_key; ?> ').append(" <span class='badge badge-success'>My company</span>"); function search_name(name) { name = replaceAll(name," ", "%"); if(name.length >= 3){ $('#show_customer').load('<?php echo LbCustomer::model()->getActionURLNormalized('_search_customer'); ?> ',{name:name}); } } function replaceAll(string, find, replace) { return string.replace(new RegExp(escapeRegExp(find), 'g'), replace); } function escapeRegExp(string) { return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); } </script>
<?php foreach ($a as $data) { $customer_id = false; if (LbCustomer::model()->isCustomer($data->lb_invoice_customer_id) != null) { $invoice_information = LbInvoiceTotal::model()->getInvoiceById($data->lb_record_primary_key); $invoiceTax = LbInvoiceItem::model()->getInvoiceTaxById($data->lb_record_primary_key, "TAX"); $PDFInvoice .= '<tr>'; $PDFInvoice .= '<td>' . $data->lb_invoice_no . '</td>'; $PDFInvoice .= '<td>' . $data->lb_invoice_date . '</td>'; $PDFInvoice .= '<td>'; if ($data->lb_invoice_customer_id) { $customer_id = $data->lb_invoice_customer_id; $PDFInvoice .= LbCustomer::model()->customerInformation($customer_id)->attributes['lb_customer_name']; } $PDFInvoice .= '</td>'; $PDFInvoice .= '<td>$' . number_format($invoice_information->lb_invoice_total_after_discounts, 2) . '</td>'; $PDFInvoice .= '<td>'; $totalTax = 0; if ($invoiceTax) { $totaltax = $invoice_information->lb_invoice_total_after_taxes - $invoice_information->lb_invoice_total_after_discounts; $PDFInvoice .= '$' . number_format($totaltax, 2); } else { $PDFInvoice .= '$0.00'; } $PDFInvoice .= '</td>'; $PDFInvoice .= '<td>$' . number_format($invoice_information->lb_invoice_total_after_taxes, 2) . '</td>'; $PDFInvoice .= '</tr>'; $subtotal = $subtotal + $invoice_information->lb_invoice_total_after_discounts;
?> <tbody> <?php $a = LbInvoice::model()->getInvoiceMonth($customer['lb_record_primary_key'], $date_from, $date_to); foreach ($a as $data) { $customer_id = false; $invoice_information = LbInvoiceTotal::model()->getInvoiceById($data->lb_record_primary_key); $invoiceTax = LbInvoiceItem::model()->getInvoiceTaxById($data->lb_record_primary_key, "TAX"); $invoiceValue = $invoiceValue + $invoice_information->lb_invoice_total_after_discounts; echo '<tr>'; echo '<td>' . $data->lb_invoice_no . '</td>'; echo '<td>' . $data->lb_invoice_date . '</td>'; echo '<td>'; if ($data->lb_invoice_customer_id) { $customer_id = $data->lb_invoice_customer_id; echo LbCustomer::model()->customerInformation($customer_id)->attributes['lb_customer_name']; } echo '</td>'; echo '<td>$' . $invoice_information->lb_invoice_total_after_discounts . '</td>'; echo '<td>'; $totalTax = 0; if ($invoiceTax) { $totaltax = $invoice_information->lb_invoice_total_after_taxes - $invoice_information->lb_invoice_total_after_discounts; echo '$' . $totaltax; } else { echo '$0.00'; } echo '</td>'; echo '</tr>'; $gst = $gst + ($invoice_information->lb_invoice_total_after_taxes - $invoice_information->lb_invoice_total_after_discounts); }
<style> span a{ color: #000; } .chzn-container{ top: 7px; } </style> <?php $current_data = date('d-m-Y'); $lastMonth_data = date('d-m-Y', strtotime("+1 month -1 day")); $customer_option = LbCustomer::model()->getCompanies($sort = 'lb_customer_name ASC', LbCustomer::LB_QUERY_RETURN_TYPE_DROPDOWN_ARRAY); $customer_option = array(0 => 'All') + $customer_option; $Time_Range = array(0 => 'All', 1 => '0-30 days', '31-60 days', '61-90 days', '90 + days'); ?> <?php $this->widget('ext.EChosen.EChosen', array('target' => '#select_customer')); ?> <div style="margin-bottom: 15px;"> <span style="font-size: 16px;"><?php echo Yii::t('lang', 'Customer name'); ?> :</span> <?php echo CHtml::dropDownList('customer', '', $customer_option, array('class' => 'span4')); ?> <span style="font-size: 16px;"><?php
$day = dateMY($FromDate)[2]; $dayTo = dateMY($Todate)[2]; $month = dateMY($FromDate)[1]; $year = dateMY($FromDate)[0]; $AmountMonth = 0; for ($i = 0; $i < 5; $i++) { if ($YStart == $YEnd && $MStart == $MEnd) { $PaymentAll = LbPayment::model()->getAllPayment($FromDate, $Todate, $customer_id, false, false, $i); } else { $PaymentAll = LbPayment::model()->getAllPayment($FromDate, $numberDate, $customer_id, false, false, $i); } if (count($PaymentAll) > 0) { $paymentAmount = 0; foreach ($PaymentAll as $data) { if (LbCustomer::model()->isCustomer($data->attributes['lb_payment_customer_id']) != null) { $customer_information = LbCustomer::model()->find('lb_record_primary_key=' . intval($data->attributes['lb_payment_customer_id'])); $customer_name = $customer_information->lb_customer_name; echo '<tr>'; echo '<td>' . $data->attributes['lb_payment_date'] . '</td>'; echo '<td>' . $customer_name . '</td>'; echo '<td>' . $data->attributes['lb_payment_notes'] . '</td>'; $payment_item = LbPaymentItem::model()->getAllPaymentInvoice($data->lb_record_primary_key); echo '<td>'; foreach ($payment_item as $payment) { // echo $payment->lb_invoice_id; $invoiceNo = LbInvoice::model()->find('lb_record_primary_key=' . intval($payment->lb_invoice_id)); if (isset($invoiceNo->lb_record_primary_key)) { echo $invoiceNo->lb_invoice_no . ':$' . $payment->lb_payment_item_amount . '; '; $paymentAmount = $paymentAmount + $payment->lb_payment_item_amount; $AmountMonth = $AmountMonth + $payment->lb_payment_item_amount; }
public function actionDeleteContact() { $error = array(); $contact_id = $_POST['id']; $customer_id = $_POST['customer_id']; $invoiceContact = LbInvoice::model()->getInvoiceByContact($contact_id); if (count($invoiceContact->data) > 0) { $error['exist'] = 'Contact cannot be deleted. This contact is already in use by an invoice or quotation.'; $model = LbCustomer::model()->findByPk($customer_id); $customer_addresses = LbCustomerAddress::model()->getAddresses($customer_id, LbCustomerAddress::LB_QUERY_RETURN_TYPE_MODELS_ARRAY); $customer_contacts = LbCustomerContact::model()->getContacts($customer_id, LbCustomerContact::LB_QUERY_RETURN_TYPE_MODELS_ARRAY); LBApplication::renderPartial($this, '//layouts/plain_ajax_content', array('content' => CJSON::encode($error))); } else { $contact = LbCustomerContact::model()->findByPk($contact_id); $contact->delete(); } }
/** * Quick create contact from a modal form * over invoice main page * * @param $id invoice id * @return bool * @throws ChttpException if customer is not selected */ public function actionAjaxQuickCreateContact($id) { $model = $this->loadModel($id); $customerModel = LbCustomer::model()->findByPk($model->lb_invoice_customer_id); $customerContact = new LbCustomerContact(); // a customer must have been assigned first if ($customerModel === null) { throw new CHttpException(404, 'Please select a customer first.'); } if (isset($_POST['LbCustomerContact'])) { // save customer data $customerContact->attributes = $_POST['LbCustomerContact']; $customerContact->lb_customer_id = $customerModel->lb_record_primary_key; if ($customerContact->save()) { // assign this contact to this invoice $model->lb_invoice_attention_contact_id = $customerContact->lb_record_primary_key; $model->save(); } //return JSON record of customer address LBApplication::renderPlain($this, array('content' => CJSON::encode($customerContact))); return true; } // show quick create form LBApplication::render($this, '_form_contact', array('model' => $model, 'customerModel' => $customerModel, 'customerContactModel' => $customerContact)); }