public function getPVNextNum() { $next_invoice_number = 0; $last_used = LbNextId::model()->getOneRecords(); // TODO: if more than 1 record, something is wrong if (count($last_used) > 1) { return 0; // something is wrong } // If no record, probably first time generation // generate first record if (count($last_used) <= 0) { $nextInvoiceNo = new LbNextId(); $nextInvoiceNo->lb_next_invoice_number = 1; $nextInvoiceNo->lb_next_quotation_number = 1; $nextInvoiceNo->lb_next_payment_number = 1; $nextInvoiceNo->lb_next_contract_number = 1; $nextInvoiceNo->lb_next_po_number = 1; $nextInvoiceNo->lb_next_supplier_invoice_number = 1; $nextInvoiceNo->lb_next_supplier_payment_number = 1; if ($nextInvoiceNo->save()) { $next_po_number = $nextInvoiceNo->lb_next_pv_number; } } else { $nextInvoiceNo = $last_used; $next_invoice_number = $nextInvoiceNo->lb_next_pv_number; } // advance next invoice number $nextInvoiceNo->lb_next_pv_number++; $nextInvoiceNo->save(); return $next_invoice_number; //trigger_error('Not Implemented!', E_USER_WARNING); }
/** * Retrieve invoice next number * Return it for usage * Advance it by +1 and save to the database * * @return string invoice number to use * @access public */ public function getInvoiceNextNum() { $next_invoice_number = 0; // get last used number /** $criteria=new CDbCriteria(); $criteria->join = "LEFT JOIN lb_core_entities ON lb_entity_type = '" . $this->getEntityType() . "'" . " AND lb_entity_primary_key = t.lb_record_primary_key" . " AND lb_subscription_id = " . LBApplication::getCurrentlySelectedSubscription(); **/ //$last_used = LbNextId::model()->getFullRecords(); //$last_used = LbNextId::model()->findAll(); $last_used = LbNextId::model()->getOneRecords(); // TODO: if more than 1 record, something is wrong if (count($last_used) > 1) { return 0; // something is wrong } // If no record, probably first time generation // generate first record if (count($last_used) <= 0) { $nextInvoiceNo = new LbNextId(); $nextInvoiceNo->lb_next_invoice_number = 1; $nextInvoiceNo->lb_next_quotation_number = 1; $nextInvoiceNo->lb_next_payment_number = 1; $nextInvoiceNo->lb_next_contract_number = 1; $nextInvoiceNo->lb_next_po_number = 1; $nextInvoiceNo->lb_next_supplier_invoice_number = 1; $nextInvoiceNo->lb_next_supplier_payment_number = 1; if ($nextInvoiceNo->save()) { $next_invoice_number = $nextInvoiceNo->lb_next_invoice_number; } } else { $nextInvoiceNo = $last_used; $next_invoice_number = $nextInvoiceNo->lb_next_invoice_number; } // advance next invoice number $nextInvoiceNo->lb_next_invoice_number++; $nextInvoiceNo->save(); return $next_invoice_number; //trigger_error('Not Implemented!', E_USER_WARNING); }
public function getNextIdSubscription() { $lastNextID = $this->getFullRecords(); if (count($lastNextID) <= 0) { $nextInvoiceNo = new LbNextId(); $nextInvoiceNo->lb_next_invoice_number = 1; $nextInvoiceNo->lb_next_quotation_number = 1; $nextInvoiceNo->lb_next_payment_number = 1; $nextInvoiceNo->lb_next_contract_number = 1; $nextInvoiceNo->lb_next_expenses_number = 1; $nextInvoiceNo->lb_next_po_number = 1; $nextInvoiceNo->lb_next_supplier_invoice_number = 1; $nextInvoiceNo->lb_next_supplier_payment_number = 1; $nextInvoiceNo->lb_payment_vendor_number = 1; if ($nextInvoiceNo->save()) { $lastNextID = $this->getFullRecords(); } } $NextID = $lastNextID[0]->lb_record_primary_key; $dataProvider = LbNextId::model()->findByPk($NextID); return $dataProvider; }
public function getExpensesNextNum() { $next_expenses_number = 0; $last_used = LbNextId::model()->getFullRecords(); // TODO: if more than 1 record, something is wrong if (count($last_used) > 1) { return 0; // something is wrong } // If no record, probably first time generation // generate first record if (count($last_used) <= 0) { $next_expenses_number = 1; $nextexpensesNo = new LbNextId(); $nextexpensesNo->lb_next_invoice_number = 1; $nextexpensesNo->lb_next_quotation_number = 1; $nextexpensesNo->lb_next_payment_number = 1; $nextexpensesNo->lb_next_contract_number = 1; $nextexpensesNo->lb_next_expenses_number = 1; if ($nextexpensesNo->save()) { $next_expenses_number = $nextexpensesNo->lb_next_expenses_number; } } else { $nextexpensesNo = $last_used[0]; $next_expenses_number = $nextexpensesNo->lb_next_expenses_number; } return $next_expenses_number; //trigger_error('Not Implemented!', E_USER_WARNING); }
function getNextQuotationNumber() { $next_quotation_number = 0; $last_used = LbNextId::model()->getOneRecords(); if (count($last_used) > 1) { return false; } if (count($last_used) <= 0) { $nextQuotationNo = new LbNextId(); $nextQuotationNo->lb_next_quotation_number = 1; $nextQuotationNo->lb_next_invoice_number = 1; $nextQuotationNo->lb_next_payment_number = 1; $nextQuotationNo->lb_next_contract_number = 1; $nextQuotationNo->lb_next_po_number = 1; $nextQuotationNo->lb_next_supplier_invoice_number = 1; $nextQuotationNo->lb_next_supplier_payment_number = 1; if ($nextQuotationNo->save()) { $next_quotation_number = $nextQuotationNo->lb_next_quotation_number; } } else { $nextQuotationNo = $last_used; $next_quotation_number = $nextQuotationNo->lb_next_quotation_number; } $nextQuotationNo->lb_next_quotation_number++; $nextQuotationNo->save(); return $next_quotation_number; }