public function IsTaxExistInvoiceORQuotation($tax_id) { $tax_invoice = LbInvoiceItem::model()->find('lb_invoice_item_description=' . $tax_id); $tax_quotation = LbQuotationTax::model()->find('lb_quotation_tax_id=' . $tax_id); if (count($tax_quotation) > 0 || count($tax_invoice) > 0) { return true; } return false; }
function calculateQuotationAfterTotalTax($id) { $quotation_line_tax = LbQuotationTax::model()->getTaxQuotation($id); $afterTotalTax = 0; foreach ($quotation_line_tax->data as $tax) { $afterTotalTax += $tax->lb_quotation_tax_total; } $quotation_total = $this->model()->find('lb_quotation_id=' . $id); $quotation_total->lb_quotation_total_after_tax = $afterTotalTax; $quotation_total->save(); }
public function actionAjaxCopyQuotation($id) { //Add thong tin quotation $quo_new = new LbQuotation(); $quotation = LbQuotation::model()->findByPk($id); $quo_new->lb_quotation_no = LbQuotation::model()->formatQuotationNextNumFormatted(0); $quo_new->lb_quotation_date = date('Y-m-d'); $quo_new->lb_quotation_due_date = date('Y-m-d'); $quo_new->lb_quotation_status = LbQuotation::LB_QUOTATION_STATUS_CODE_DRAFT; $quo_new->lb_company_id = $quotation->lb_company_id; $quo_new->lb_company_address_id = $quotation->lb_company_address_id; $quo_new->lb_quotation_customer_id = $quotation->lb_quotation_customer_id; $quo_new->lb_quotation_customer_address_id = $quotation->lb_quotation_customer_address_id; $quo_new->lb_quotation_attention_id = $quotation->lb_quotation_attention_id; $quo_new->lb_quotation_internal_note = $quotation->lb_quotation_internal_note; $quo_new->lb_quotation_subject = $quotation->lb_quotation_subject; $quo_new->lb_quotation_note = $quotation->lb_quotation_note; $quo_new->lb_quotation_encode = LbQuotation::model()->setBase64_decodeQuotation(); if ($quo_new->save()) { // Add thong tin tax $quotation_tax_arr = LbQuotationTax::model()->getTaxQuotation($quotation->lb_record_primary_key); foreach ($quotation_tax_arr->data as $tax_item) { $quo_tax_new = new LbQuotationTax(); $quo_tax_new->lb_quotation_id = $quo_new->lb_record_primary_key; $quo_tax_new->lb_quotation_tax_id = $tax_item->lb_quotation_tax_id; $quo_tax_new->lb_quotation_tax_value = $tax_item->lb_quotation_tax_value; $quo_tax_new->lb_quotation_tax_total = $tax_item->lb_quotation_tax_total; $quo_tax_new->save(); } //END //Add thong tin discount $quotation_discount_arr = LbQuotationDiscount::model()->getQuotationDiscounts($quotation->lb_record_primary_key); foreach ($quotation_discount_arr->data as $discount_item) { $quo_discount_new = new LbQuotationDiscount(); $quo_discount_new->lb_quotation_id = $quo_new->lb_record_primary_key; $quo_discount_new->lb_quotation_discount_description = $discount_item->lb_quotation_discount_description; $quo_discount_new->lb_quotation_discount_total = $discount_item->lb_quotation_discount_total; $quo_discount_new->lb_quotation_discount_value = $discount_item->lb_quotation_discount_value; $quo_discount_new->save(); } //END //Add Thong tin total $quotation_total = LbQuotationTotal::model()->getQuotationTotal($quotation->lb_record_primary_key); $quo_total_new = new LbQuotationTotal(); $quo_total_new->lb_quotation_id = $quo_new->lb_record_primary_key; $quo_total_new->lb_quotation_subtotal = $quotation_total->lb_quotation_subtotal; $quo_total_new->lb_quotation_total_after_discount = $quotation_total->lb_quotation_total_after_discount; $quo_total_new->lb_quotation_total_after_tax = $quotation_total->lb_quotation_total_after_tax; $quo_total_new->lb_quotation_total_after_total = $quotation_total->lb_quotation_total_after_total; $quo_total_new->save(); //Add thong tin item $quotation_item_arr = LbQuotationItem::model()->getquotationItems($quo_new->lb_record_primary_key); foreach ($quotation_item_arr->data as $item) { $quo_item_new = new LbQuotationItem(); $quo_item_new->lb_quotation_id = $quo_new->lb_record_primary_key; $quo_item_new->lb_quotation_item_price = $item->lb_quotation_item_price; $quo_item_new->lb_quotation_item_description = $item->lb_quotation_item_description; $quo_item_new->lb_quotation_item_quantity = $item->lb_quotation_item_quantity; $quo_item_new->lb_quotation_item_total = $item->lb_quotation_item_total; $quo_item_new->save(); } //END } }
function delete() { $quotation_id = $this->lb_record_primary_key; $result = parent::delete(); if ($result) { $quotation_item = LbQuotationItem::model()->getquotationItems($quotation_id); foreach ($quotation_item->data as $item) { $item->delete(); } $quotation_discount = LbQuotationDiscount::model()->getQuotationDiscounts($quotation_id); foreach ($quotation_discount->data as $discount) { $discount->delete(); } $quotation_tax = LbQuotationTax::model()->getTaxQuotation($quotation_id); foreach ($quotation_tax->data as $tax) { $tax->delete(); } $quotation_total = LbQuotationTotal::model()->getQuotationTotal($quotation_id); $quotation_total->delete(); } }