function get_bus_establshment_by_barangay($dbLink, $post) { $clsSysRef = new EBPLSSysRef($dbLink, EBPLS_BARANGAY, $params["bDebug"]); $records = $clsSysRef->select($post["barangay"]); if (is_array($records) && count($records["result"]) > 0) { $res = $records["result"]; $brgy_desc = $res[0]->getDescription(); } else { $brgy_desc = $post["barangay"]; } $sqlSelect = "SELECT b.business_permit_code, a.business_name, a.business_category_code, d.business_nature_code as business_nature, concat( e.owner_first_name, ' ', e.owner_last_name ) as business_owner, a.business_phone_no, d.capital_investment as business_capital_investment, c.barangay_desc FROM ebpls_business_enterprise as a left join ebpls_business_enterprise_permit as b on a.business_id = b.business_id left join ebpls_barangay as c on a.business_barangay_code = c.barangay_code left join ebpls_business_enterprise_nature as d on a.business_id = d.business_id left join ebpls_owner as e on a.owner_id = e.owner_id WHERE a.business_barangay_code = '" . $post["barangay"] . "' and '" . $post["start_date"] . "' <= b.application_date and b.application_date <= '" . $post["end_date"] . "' and b.business_permit_code != ''"; //echo("SQL ($dbLink, $post) : $sqlSelect<BR>"); $res = mysql_query($sqlSelect, $dbLink); if ($res) { $records = NULL; while ($row = mysql_fetch_array($res)) { $records[] = $row; } return $records; } return NULL; }
global $ThUserData; $debug = false; $gDB_Details_Tables = array('ebpls_business_category' => 'Ownership Type', 'ebpls_business_nature' => 'Business Category/Type/Nature/Kind', 'ebpls_business_requirement' => 'Business Requirement', 'ebpls_business_status' => 'Business Status', 'ebpls_business_type' => 'Business Type', 'ebpls_city_municipality' => 'City / Municipality Codes', 'ebpls_district' => 'District Codes', 'ebpls_province' => 'Province Codes', 'ebpls_zip' => 'Zip Codes', 'ebpls_zone' => 'Zone Codes', 'ebpls_industry_sector' => 'Industry Sector Codes', 'ebpls_occupancy_type' => 'Occupancy Type Codes', 'ebpls_barangay' => 'Barangay Codes'); $gDB_Details_Tables_Map = array('ebpls_business_category' => EBPLS_BUSINESS_CATEGORY, 'ebpls_business_category_offc' => EBPLS_BUSINESS_CATEGORY_OFFC, 'ebpls_business_nature' => EBPLS_BUSINESS_NATURE, 'ebpls_business_requirement' => EBPLS_BUSINESS_REQUIREMENT, 'ebpls_business_status' => EBPLS_BUSINESS_STATUS, 'ebpls_business_type' => EBPLS_BUSINESS_TYPE, 'ebpls_city_municipality' => EBPLS_CITY_MUNICIPALITY, 'ebpls_district' => EBPLS_DISTRICT, 'ebpls_province' => EBPLS_PROVINCE, 'ebpls_zip' => EBPLS_ZIP, 'ebpls_zone' => EBPLS_ZONE, 'ebpls_industry_sector' => EBPLS_INDUSTRY_SECTOR, 'ebpls_occupancy_type' => EBPLS_OCCUPANCY_TYPE, 'ebpls_barangay' => EBPLS_BARANGAY); $gDB_Details_Levels_Map = array('ebpls_business_category' => 153, 'ebpls_business_category_offc' => 154, 'ebpls_business_nature' => 155, 'ebpls_business_requirement' => 156, 'ebpls_business_status' => 157, 'ebpls_business_type' => 158, 'ebpls_city_municipality' => 159, 'ebpls_district' => 160, 'ebpls_province' => 161, 'ebpls_zip' => 162, 'ebpls_zone' => 163, 'ebpls_industry_sector' => 164, 'ebpls_occupancy_type' => 165, 'ebpls_barangay' => 166); //--- what table to be searched ??? $selMode = trim($selMode); //--- paging params $page = strlen(trim($page)) == 0 ? 1 : $page; $maxpage = 200; //--- init the sysref object $refTable = $gDB_Details_Tables_Map["{$selMode}"]; $k = $refTable; $clsSysRef = new EBPLSSysRef($dbLink, $gDB_Details_Tables_Map["{$selMode}"], $debug); //--- then have a default search $retValue = $clsSysRef->select(NULL, $page, $maxpage, SYSREF_CODE, true); //--- get the total records $total_records = count($retValue["result"]); //--- headers $search_columns[$k . SYSREF_CODE] = "Code"; $search_columns[$k . SYSREF_DESC] = "Description"; if ($refTable == EBPLS_BUSINESS_NATURE) { $search_columns[SYSREF_NATURE_TAX_FEE_CODE] = "New App Tax/Fee Code"; $search_columns[SYSREF_NATURE_TAX_FEE_CODE2] = "Renew App Tax/Fee Code"; } $search_columns[$k . SYSREF_CREATE_TS] = "Date Created"; $search_columns[$k . SYSREF_UPDATE_TS] = "Date Updated"; $search_columns[SYSREF_ADMIN] = "Updated By"; //--- update_delete_chart_of_accounts('$code'); function createCommand($rec) {
function updateLineOfBusiness($nature_code, $capital, $last_gross = 0, $status = "PENDING") { // check if business type if (!isset($this->data_elems[TRANS_ID])) { $this->setError(-5, "Transaction not yet loaded, call loadTransaction before calling this function!"); $this->debug("Transaction not yet loaded, call loadTransaction before calling this function!"); return -5; } // check if transaction is business type of permit if (!isset($this->data_elems[TRANS_PERMIT_TYPE]) && $this->data_elems[TRANS_PERMIT_TYPE] != PERMIT_TYPE_BUSINESS) { $this->setError(-4, "Can't use function for non-business enterprise type of transactions!"); $this->debug("Can't use function for non-business enterprise type of transactions!"); return -4; } if (!($this->getData(TRANS_TRANSACTION_STATUS) == "ASSESSMENT" || $this->getData(TRANS_TRANSACTION_STATUS) == "APPLICATION")) { $this->setError(-5, "Can't use function on transactions if status is not assessment or application!"); $this->debug("Can't use function on transactions if status is not assessment or application!"); return -6; } // update transaction payment status with new line of business tax added $clsRef = new EBPLSSysRef($this->m_dbLink, EBPLS_BUSINESS_NATURE); $result = $clsRef->select($nature_code); if (is_array($result) && count($result["result"]) > 0) { ebpls_start_transaction($this->m_dbLink); // check if LOB exist already on transaction nature list // if exist return error else create LOB $clsNature = new EBPLSTransactionBusinessNature($this->m_dbLink, false); $clsNature->setData(TRANS_BUSNATURE_CAPITAL_INVESTMENT, $capital); $clsNature->setData(TRANS_BUSNATURE_LAST_GROSS, $last_gross); $clsNature->setData(TRANS_BUSNATURE_STATUS, $status); $ret = $clsNature->update($this->data_elems[TRANS_ID], $nature_code); if ($ret < 0) { $this->setError($ret, "updateLineOfBusiness : error on creation of business nature record."); $this->debug("updateLineOfBusiness : error on creation of business nature record"); ebpls_rollback_transaction($this->m_dbLink); } else { // delete line of business to business nature list!!! $clsBus = new EBPLSEnterprise($this->m_dbLink); $clsBus->updateBusinessNature($nature_code, $capital, $last_gross, $status); if ($clsBus->update($this->getData(TRANS_BUSINESS_ID), $admin, $user_level) < 0) { $this->debug("updateLineOfBusiness : error on deleting line of business {$nature_code} on enterprise table."); $this->setError(-5, "updateLineOfBusiness : error on deleting line of business {$nature_code} on enterprise table."); ebpls_rollback_transaction($this->m_dbLink); return $retAddFee; } $clsTransFee = new EBPLSTransactionFee($this->m_dbLink, false); if ($clsTransFee->view($this->data_elems[TRANS_ID], $result["result"][0]->getExtra()) > 0) { $clsLOBTax = new EBPLSTransactionFee($this->m_dbLink, false); $clsLOBTax->setData(TF_TAX_FEE_CODE, $result["result"][0]->getExtra()); $clsLOBTax->setData(TF_TAX_BUSINESS_NATURE_CODE, $nature_code); $clsLOBTax->m_BusTaxCapital = $capital; $clsLOBTax->m_BusTaxLastGross = $last_gross; $this->debug("LOB Details " . $result["result"][0]->getCode() . " = " . $result["result"][0]->getDescription() . " : " . $result["result"][0]->getExtra() . "!"); $retUpdateFee = $this->updateFee($clsTransFee->getData(TF_FEE_ID), $clsLOBTax, $admin, $user_level); if ($retUpdateFee < 0) { $this->debug("updateLineOfBusiness : error on update line of business fee."); $this->setError(-5, "updateLineOfBusiness : error on updating line of business fee."); ebpls_rollback_transaction($this->m_dbLink); return $retUpdateFee; } // if payment mode is set automatically recompute payment schedule if ($this->isPaymentModeSet()) { $this->setPaymentMode($this->getData(TRANS_PAYMENT_MODE), $this->getData(TRANS_PAYMENT_TAXFEE_DIVIDED), $admin, $user_level); } ebpls_commit_transaction($this->m_dbLink); } else { ebpls_rollback_transaction($this->m_dbLink); } } } else { $this->setError(-2, "Cant load nature code {$nature_code}!"); $this->debug("Cant load nature code {$nature_code}!"); return -2; } return $ret; }