Пример #1
0
 public function actiondropdownJSONCategory($vendor_id = false, $vendor_invoice_id = false)
 {
     $vendor_id = isset($_GET['vendor_id']) ? $_GET['vendor_id'] : 0;
     $quotation_id = isset($_GET['vendor_invoice_id']) ? $_GET['vendor_invoice_id'] : 0;
     $category_arr = SystemList::model()->getItemsForListCode('expenses_category', LbVendor::LB_QUERY_RETURN_TYPE_DROPDOWN_ARRAY);
     $category_arr = SystemList::model()->findAll('system_list_code = "expenses_category"');
     $ordered_results = array();
     $ordered_results[0] = array('value' => '0', 'text' => 'Choose category') + $ordered_results;
     foreach ($category_arr as $value) {
         $ordered_results[] = array('value' => $value['system_list_item_id'], 'text' => $value['system_list_item_name']);
     }
     LBApplication::renderPlain($this, array('content' => CJSON::encode($ordered_results)));
 }
Пример #2
0
 function actionajaxDeletePayment()
 {
     if (isset($_GET['id'])) {
         $payment_item_id = $_GET['id'];
     }
     //delete payment item
     $payment = LbPaymentItem::model()->deleteByPk($payment_item_id);
     $invoice_id = $_GET['invoice_id'];
     $invoiceTotal = LbInvoiceTotal::model()->getInvoiceTotal($invoice_id);
     $taxRecord['paid'] = $invoiceTotal->calculateInvoicetotalPaid($invoice_id);
     $taxRecord['outstanding'] = $invoiceTotal->calculateInvoiceTotalOutstanding();
     if ($invoiceTotal->calculateInvoiceTotalOutstanding() <= 0) {
         $taxRecord['status'] = 'I_PAID';
     } else {
         $taxRecord['status'] = 'Open';
     }
     //update invoice total
     //                if($payment->delete())
     //                    echo 'success';
     LBApplication::renderPlain($this, array('content' => CJSON::encode($taxRecord)));
 }
Пример #3
0
 public function actionupdateComment()
 {
     $description = false;
     if (isset($_POST['id_comment'])) {
         $id_commment = $_POST['id_comment'];
     }
     if (isset($_POST['description'])) {
         $description = $_POST['description'];
     }
     $model = LbComment::model()->findByPk($id_commment);
     $model->lb_comment_description = $description;
     $date = date('Y-m-d');
     $model->lb_comment_date = $date;
     if ($model->update()) {
         $response = array();
         $response['success'] = YES;
         $response['lb_comment_description'] = nl2br($model->lb_comment_description);
         $response['lb_comment_date'] = $model->lb_comment_date;
         LBApplication::renderPlain($this, array('content' => CJSON::encode($response)));
     }
 }
Пример #4
0
 public function actionCreateBlankTax($id)
 {
     $invoiceItem = new LbInvoiceItem();
     $result = $invoiceItem->addBlankTax($id);
     if ($result) {
         $response = array();
         $response['success'] = YES;
         $response['invoice_item_id'] = $invoiceItem->lb_record_primary_key;
         LBApplication::renderPlain($this, array('content' => CJSON::encode($response)));
     }
 }
Пример #5
0
 public function actionajaxQuickCreateCurrency()
 {
     $invoice_id = isset($_REQUEST['invoice_id']) ? $_REQUEST['invoice_id'] : '';
     // $model = LbInvoice::model()->findByPk($invoice_id);
     $model = $this->loadModel($invoice_id);
     $GeneraModel = new LbGenera();
     if (isset($_POST['LbGenera'])) {
         $GeneraModel->attributes = $_POST['LbGenera'];
         if ($GeneraModel->save()) {
             $model->lb_invoice_currency = $GeneraModel->lb_record_primary_key;
             $model->save();
         }
         LBApplication::renderPlain($this, array('content' => CJSON::encode($GeneraModel)));
         return true;
     }
     LBApplication::renderPartial($this, '_form_currency', array('model' => $model, 'GeneraModel' => $GeneraModel));
 }
Пример #6
0
 public function actionAjaxQuickCreateTax($id)
 {
     $model = new LbTax();
     $submission_type = isset($_GET['form_type']) ? $_GET['form_type'] : 'default';
     $quotationModel = LbQuotation::model()->findByPk($id);
     if (isset($_POST['LbTax'])) {
         $model->attributes = $_POST['LbTax'];
         $lbtax_arr = $_POST['LbTax'];
         if (!LbTax::model()->IsNameTax($lbtax_arr['lb_tax_name'])) {
             $error['error'] = "Tax Name Exist.";
             LBApplication::renderPlain($this, array('content' => CJSON::encode($error)));
             return false;
         }
         if ($model->save()) {
             $result['yes'] = true;
             if ($submission_type == 'ajax') {
                 // auto add this tax item into this invoice
                 $quotaitonTax = new LbQuotationTax();
                 if ($quotaitonTax->addTaxToQuotation($id, $model)) {
                     $this->actionAjaxUpdateTaxs($id);
                 }
                 // print json result of this quotation item
                 //LBApplication::renderPlain($this, array('content'=>CJSON::encode($result)));
                 return true;
             }
         }
     }
     $submission_details = array();
     $submission_details["type"] = $submission_type;
     LBApplication::render($this, '_form_tax', array('model' => $model, 'quotationModel' => $quotationModel, 'submission_details' => $submission_details));
 }
Пример #7
0
 public function actionsavePaymentVoucher()
 {
     $model = new LbPaymentVoucher();
     $pv_no = false;
     $pv_title = false;
     $pv_date = false;
     $pv_description = false;
     if ($_POST['pv_no']) {
         $pv_no = $_POST['pv_no'];
     }
     $issetPv = LbPaymentVoucher::model()->find('lb_payment_voucher_no = "' . $pv_no . '"');
     //            if(count($issetPv) > 0)
     //            {
     //                $response = array();
     //                $response['success'] = NO;
     //
     //
     //                LBApplication::renderPlain($this, array('content'=>  CJSON::encode($response)));
     //                return;
     //            }
     if ($_POST['pv_title']) {
         $pv_title = $_POST['pv_title'];
     }
     if ($_POST['pv_date']) {
         $pv_date = $_POST['pv_date'];
     }
     if ($_POST['pv_description']) {
         $pv_description = $_POST['pv_description'];
     }
     $idPv = false;
     if (isset($_REQUEST['idPv'])) {
         $idPv = $_REQUEST['idPv'];
     }
     //company
     $id = $model->savePaymentVoucher($pv_no, $pv_title, $pv_date, $pv_description, $idPv);
     $count = count($_POST['iem_ex_arr']);
     $expenses_item = $_POST['iem_ex_arr'];
     for ($i = 0; $i < $count; $i++) {
         if ($expenses_item[$i] > 0) {
             $PvExpenses = new LbPvExpenses();
             $PvExpenses->lb_expenses_id = $expenses_item[$i];
             $PvExpenses->lb_payment_voucher_id = $id;
             if (LbPvExpenses::model()->getExpensesPV($expenses_item[$i], $id) == false) {
                 $PvExpenses->insert();
             }
         }
     }
     if ($id) {
         $response = array();
         $response['success'] = YES;
         $response['id'] = $id;
         LBApplication::renderPlain($this, array('content' => CJSON::encode($response)));
     }
 }
 public function actionCreateDefaultNote()
 {
     $model = new LbDefaultNote();
     $lastDefaultNote = LbDefaultNote::model()->getFullRecords();
     if (count($lastDefaultNote) > 0) {
         return false;
     } else {
         if ($model->save()) {
             return LBApplication::renderPlain($this, array('content' => CJSON::encode($model)));
         }
     }
 }
Пример #9
0
 /**
  * json data source for x-editable dropdown to get contacts
  */
 public function actionDropdownJSON()
 {
     $allow_add = isset($_GET['allow_add']) ? $_GET['allow_add'] : NO;
     $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;
     $vendor_invoice_id = isset($_GET['lb_vendor_invoice_id']) ? $_GET['lb_vendor_invoice_id'] : 0;
     // override customer id if invoice id is provided
     if ($vendor_id) {
         $vendor = LbVendor::model()->findByPk($vendor_id);
         $customer_id = $vendor->lb_vendor_supplier_id;
     }
     if ($vendor_invoice_id) {
         $vendor_invoice = LbVendorInvoice::model()->findByPk($vendor_invoice_id);
         $customer_id = $vendor_invoice->lb_vd_invoice_supplier_id;
     }
     if ($invoice_id) {
         $invoice = LbInvoice::model()->findByPk($invoice_id);
         $customer_id = $invoice->lb_invoice_customer_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 contacts;
     $results = LbCustomerContact::model()->getContacts($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 contact', '-1' => '-- Add new contact --') + $results;
     }
     if ($vendor_id || $vendor_invoice_id) {
         $results = array('0' => 'Choose contact') + $results;
     }
     // we want to preserve order
     $ordered_results = array();
     foreach ($results as $key => $text) {
         $ordered_results[] = array('value' => $key, 'text' => $text);
     }
     LBApplication::renderPlain($this, array('content' => CJSON::encode($ordered_results)));
 }
Пример #10
0
 public function actionExpensesNewCustomer()
 {
     //   $model = $this->loadModel($id);
     $expenses_id = isset($_REQUEST['expenses_id']) ? $_REQUEST['expenses_id'] : 0;
     //    $submission_type = isset($_GET['form_type']) ? $_GET['form_type'] : 'default';
     $expensesModel = LbExpenses::model()->findByPk($expenses_id);
     $customerModel = new LbCustomer();
     $addressModel = new LbCustomerAddress();
     $contactModel = new LbCustomerContact();
     $own = false;
     if (isset($_POST['LbCustomer'])) {
         $customerModel->attributes = $_POST['LbCustomer'];
         //    $customerModel->lb_customer_is_own_company = 0;
         if ($customerModel->save()) {
             //   if($submission_type == 'ajax'){
             if (isset($expenses_id) && $expenses_id > 0) {
                 $expenses_customer = new LbExpensesCustomer();
                 $expenses_customer->lb_expenses_id = $expenses_id;
                 $expenses_customer->lb_customer_id = $customerModel->lb_record_primary_key;
                 $expenses_customer->save();
                 LBApplication::renderPlain($this, array('content' => CJSON::encode($expenses_customer)));
             }
             if (isset($_POST['LbCustomerAddress'])) {
                 $addressModel->attributes = $_POST['LbCustomerAddress'];
                 $addressModel->lb_customer_id = $customerModel->lb_record_primary_key;
                 $addressModel->save();
             }
             // save contact if any
             if (isset($_POST['LbCustomerContact'])) {
                 $contactModel->attributes = $_POST['LbCustomerContact'];
                 $contactModel->lb_customer_id = $customerModel->lb_record_primary_key;
                 if ($contactModel->save()) {
                     // automatically assign this contact to submitted address
                     $contactAddressModel = new LbCustomerAddressContact();
                     $contactAddressModel->lb_customer_address_id = $addressModel->lb_record_primary_key;
                     $contactAddressModel->lb_customer_contact_id = $contactModel->lb_record_primary_key;
                     $contactAddressModel->save();
                 }
             }
         }
     }
     LBApplication::render($this, 'addCustomer', array('expensesModel' => $expensesModel, 'own' => $own, 'customerModel' => $customerModel, 'addressModel' => $addressModel, 'contactModel' => $contactModel));
 }