serverConnection(); $db_bcorp = new db(BCORP_DB); $db_bcorp = $db_bcorp->serverConnection(); $db_crm = new db(BASISCRM_DB); $db_crm = $db_crm->serverConnection(); class common { var $date; // Validate a value function validatevalue(&$var, $type = "", $minlength = 0, $maxlength = 0) { if (!is_array($var)) $var = trim($var); if (isset($var) && (trim($var) != "")) { if ($minlength == 0 || ($minlength != 0 && strlen($var) >= $minlength)) { if ($maxlength == 0 || ($maxlength != 0 && strlen($var) <= $maxlength)) { if ($type != "") { switch (strtoupper($type)) { case "A": // array? return is_array($var); break; case "N": // numeric? return is_numeric($var); break; case "S": // string? return is_string($var); break; case "O": // object? return is_object($var); break; case "B": // boolean? return is_bool($var); break; case "E": // email? $email='/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i'; return preg_match($email,$var); break; case "D": // boolean? return common::is_dateformat($var); break; case "U": //valid username? $username = '/^[a-z0-9]{4,32}$/'; return preg_match($username, $var); break; case "CUSTUSERNAME": return true; break; case "USERUSERNAME": return true; break; case "USERPASSWORD": return true; break; default: return false; } } else { return true; } } else { return false; } } else { return false; } } else return false; } // paramisset() // Check whether a parameter is set // $var = name of the parameter variable // $value = value for the parameter to be true function paramisset (&$var, $value) { return (isset($var) && ($var == $value)) ? true : false; } function is_dateformat($date) { if((strlen($date)!=10) OR ((substr_count($date, "/"))<>2)) return false; else //validate the date $pos=strpos($date,"/"); $strdate=substr($date,0,($pos)); $result=ereg("^[0-9]+$",$strdate,$trashed); if(!($result) OR ($strdate<=0) OR ($strdate>31)) return false; //validate the month $month=substr($date,($pos+1),($pos)); if(($month<=0) OR ($month>12)) return false; else $result=ereg("^[0-9]+$",$month,$trashed); if(!($result)) return false; //validate the year $year=substr($date,($pos+4),strlen($date)); $result=ereg("^[0-9]+$",$year,$trashed); //if(!($result) OR ($year<1970) OR ($year>2038)) if(!($result)) { return false; } else return true; } function convertValidHtmltag($string) { $yow = str_replace ( '&', '&', $string); $yow = str_replace ( "?", ''', $yow); $yow = str_replace ( "'", ''', $yow); $yow = str_replace ( "?", 'µ', $yow); $yow = str_replace("\r\n", " ", $yow); $yow = str_replace('\r\n', " ", $yow); return $yow; } // prepareurlparamstring - prepare url parameter string function prepareurlparamstring($requestarray = array(), $toappend, $toskip = "") { $toreturn = ""; $first = true; if (trim($toappend) != "") { $toreturn = "?" . $toappend; $first = false; } $toskiparray = explode(",", $toskip); foreach ($toskiparray as $key => $value) $toskiparray[$key] = trim($value); foreach ($requestarray as $paramname => $paramvalue) { if (!in_array($paramname, $toskiparray)) { if (!is_array($paramvalue)) { $toreturn .= ($first == true ? "?" : "&") . urlencode($paramname) . "=" . urlencode($paramvalue); $first = false; } else { foreach ($paramvalue as $arraykey => $arrayvalue) { $toreturn .= ($first == true ? "?" : "&") . urlencode($paramname . "[" . $arraykey . "]") . "=" . urlencode($arrayvalue); $first = false; } } } } return $toreturn; } function datetotimestamp($date="") { if($date == "" || $date == "0000-00-00") $timestamp = "N/A"; else $timestamp = substr($date, 8, 2) . "/" . substr($date, 5, 2) . "/" . substr($date, 0, 4); //$timestamp = date('d M Y', strtotime($date)); return $timestamp; } function getreportfeatures($reportype="") { global $db_bcorp; $stmt_l_report = "SELECT l_report_title, l_report_value FROM l_report WHERE l_report_type ='".$reportype."'"; if (!$rs_l_report = $db_bcorp->Execute($stmt_l_report)) { trigger_error("Error: Execute SQL: $stmt_l_report. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $array_report_features =array(); while($rsa = $rs_l_report->FetchRow()) { $array_report_features[$rsa['l_report_title']] = $rsa['l_report_value']; } return $array_report_features; } function bankingNameList($localno) { global $db_bcorp; //VIEW BANKING { //FIRST CHECK THE ENC = YES AS 1ST PRIORITY, THEN IF NOT CHOOSE ENC = NO $stmt_bankingRelation = "SELECT DISTINCT(Name), Enc FROM bc_entity_operationbanker WHERE Localno='".$localno."' AND Enc='YES'"; if (!$rs_bankingRelation = $db_bcorp->Execute($stmt_bankingRelation)) { trigger_error("Error: Execute SQL: $stmt_bankingRelation. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if(!$rs_bankingRelation->EOF) { $codeEnc = "Banking With Encumbrance"; } else { $stmt_bankingRelation = "SELECT DISTINCT(Name), Enc FROM bc_entity_operationbanker WHERE Localno='".$localno."' AND (Enc='NO' OR Enc='')"; if (!$rs_bankingRelation = $db_bcorp->Execute($stmt_bankingRelation)) { trigger_error("Error: Execute SQL: $stmt_bankingRelation. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $codeEnc = "Banking Without Encumbrance"; } $bankingArray = array(); while($rsa_bankingRelation = $rs_bankingRelation->FetchRow()) { $stmt_lookupRemarkEnc = "SELECT Description FROM lookup_remark WHERE Code='".$codeEnc."'"; if (!$rs_lookupRemarkEnc = $db_bcorp->Execute($stmt_lookupRemarkEnc)) { trigger_error("Error: Execute SQL: $stmt_lookupRemarkEnc. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $descriptionBanking = $rs_lookupRemarkEnc->Fields('Description'); array_push($bankingArray, array("BankingName"=>$rsa_bankingRelation['Name'])); } return $bankingArray; } } function isBankingEncumbrances($localno) { global $db_bcorp; //VIEW BANKING { //FIRST CHECK THE ENC = YES AS 1ST PRIORITY, THEN IF NOT CHOOSE ENC = NO $stmt_bankingRelation = "SELECT DISTINCT(Name), Enc FROM bc_entity_operationbanker WHERE Localno='".$localno."' AND Enc='YES'"; if (!$rs_bankingRelation = $db_bcorp->Execute($stmt_bankingRelation)) { trigger_error("Error: Execute SQL: $stmt_bankingRelation. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if(!$rs_bankingRelation->EOF) { $codeEnc = "Banking With Encumbrance"; } else { $stmt_bankingRelation = "SELECT DISTINCT(Name), Enc FROM bc_entity_operationbanker WHERE Localno='".$localno."' AND (Enc='NO' OR Enc='')"; if (!$rs_bankingRelation = $db_bcorp->Execute($stmt_bankingRelation)) { trigger_error("Error: Execute SQL: $stmt_bankingRelation. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $codeEnc = "Banking Without Encumbrance"; } $stmt_lookupRemarkEnc = "SELECT Description FROM lookup_remark WHERE Code='".$codeEnc."'"; if (!$rs_lookupRemarkEnc = $db_bcorp->Execute($stmt_lookupRemarkEnc)) { trigger_error("Error: Execute SQL: $stmt_lookupRemarkEnc. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $descriptionBanking = $rs_lookupRemarkEnc->Fields('Description'); return $descriptionBanking; } } function reportfeatureslist() { $toreturn = array(0=>"cover_page", 1=>"executive_summary", 2=>"ES_litigation", 3=>"ES_financial_condition", 4=>"ES_payment", 5=>"ES_management_capability", 6=>"ES_commercial_risk", 7=>"ES_currency_exposure", 8=>"ES_general_reputation", 9=>"ES_business_trend", 10=>"ES_credit_limit", 11=>"ES_credit_rating", 12=>"history_background", 13=>"directors", 14=>"D_name", 15=>"D_interest_check", 16=>"D_credit_history_check",17=>"D_biodata", 18=>"D_address", 19=>"management_team", 20=>"auditor_co_secretary", 21=>"banking_details", 22=>"encumbrances", 23=>"legal_check_against_sc", 24=>"payment_records", 25=>"clientele", 26=>"operations", 27=>"projects", 28=>"recent_development", 29=>"current_investigation", 30=>"financial_comments", 31=>"notes_to_account", 32=>"economic_industry_outlook", 33=>"industry_comments", 34=>"basis_comment", 35=>"financial_account", 36=>"appendix"); return $toreturn; } function searchAuditedFinancialAcc($localno) { $latest = array(); //if ($handle = opendir('filedir')) if ($handle = opendir('/var/www/accountFile/')) { while (false !== ($files = readdir($handle))) { $localno_new = str_replace(strstr($files,'-'), "", $files);//find local no e.g: 2001 $removedash = substr(strstr($files,'-'),1); $latestdate = str_replace(strstr($removedash, '.'),"",$removedash);//find date e.g: 20071123 if($localno_new == $localno) { $latest[] = $latestdate; } } if( sizeof($latest) > 0) { $fulldate = max($latest); $latestAFADate = substr($fulldate, 6, 2) . "/" . substr($fulldate, 4, 2) . "/" . substr($fulldate, 0, 4); } else $latestAFADate = 0; closedir($handle); } else $latestAFADate = 0; return ($latestAFADate); } function generateOurRefOnline() { global $db_bn; $stmt = "SELECT MAX(ourRefOnline) AS ourRefOnline FROM bn_order WHERE onlineMode='online'"; if($rs = $db_bn->Execute($stmt)) { $currentIndex = $rs->Fields('ourRefOnline'); $newIndex = $currentIndex + 1; $OurRefNew = $newIndex; } if($rs->EOF) $OurRefNew = 1; return $OurRefNew; } function generateOurRefUpdate() { global $db_bn; $stmt = "SELECT MAX(ourRefUpdate) AS ourRefUpdate FROM bn_order WHERE updateMode !=''"; if($rs = $db_bn->Execute($stmt)) { $currentIndex = $rs->Fields('ourRefUpdate'); $newIndex = $currentIndex + 1; $OurRefNew = $newIndex; } if($rs->EOF) $OurRefNew = 1; return $OurRefNew; } function lookupPlace($place="") { global $db_bcorp; $stmt = "SELECT l_other_description FROM l_other WHERE l_other_type = 'PLACE' AND l_other_code='".$place."'"; if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF) $toreturn = $rs->Fields('l_other_description'); else $toreturn = $place; } return $toreturn; } function lookupPostcodeTownStateCountry($postcode="", $town="", $state="", $country="") { global $db_bcorp; $townNew = common::lookupPlace($town); $stateNew = common::lookupPlace($state); //echo $postcode."
"; if($town != "" && $townNew == "") $townNew = $town; if($state != "" && $stateNew == "") $stateNew = $state; if($postcode != "") { $stmt = "SELECT * FROM lookup_postcode WHERE postcode='".$postcode."'"; $fullAdd = 0; } elseif($postcode == "" && $townNew != "") { $stmt = "SELECT * FROM lookup_postcode WHERE town='".$townNew."'"; $fullAdd = 0; } elseif($postcode == "" && $townNew == "" && $stateNew != "") { $stmt = " SELECT DISTINCT(state), country FROM lookup_postcode WHERE state='".$stateNew."'"; $fullAdd = 1; } elseif($postcode == "" && $townNew == "" && $stateNew == "" && $country != "") { $stmt = " SELECT DISTINCT(country) FROM lookup_postcode WHERE country='".$country."'"; $fullAdd = 2; } elseif($postcode == "" && $townNew == "" && $stateNew == "" && $country == "") { return $toreturn = ""; } if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF) { if($fullAdd == 0) $toreturn = ", ".$rs->Fields('postcode')." ".$rs->Fields('town').", ".$rs->Fields('state')."."; elseif($fullAdd == 1) $toreturn = ", ".$rs->Fields('state')."."; else $toreturn = "."; } else { if($postcode != "" && $townNew == "" && $stateNew == "" && $country == "") $toreturn = ", ".$postcode; elseif($postcode != "" && $townNew != "" && $stateNew == "" && $country == "") $toreturn = ", ".$postcode." ".$townNew ; elseif($postcode != "" && $townNew != "" && $stateNew != "" && $country == "") $toreturn = ", ".$postcode." ".$townNew.", ".$stateNew; elseif($postcode != "" && $townNew != "" && $stateNew != "" && $country != "") $toreturn = ", ".$postcode." ".$townNew.", ".$stateNew.", ".$country."."; elseif($postcode == "" && $townNew != "" && $stateNew == "" && $country == "") $toreturn = ", ".$townNew; elseif($postcode == "" && $townNew != "" && $stateNew != "" && $country == "") $toreturn = ", ".$townNew.", ".$stateNew; elseif($postcode == "" && $townNew != "" && $stateNew != "" && $country != "") $toreturn = ", ".$townNew.", ".$stateNew.", ".$country."."; elseif($postcode == "" && $townNew == "" && $stateNew != "" && $country == "") $toreturn = ", ".$stateNew; elseif($postcode == "" && $townNew == "" && $stateNew != "" && $country != "") $toreturn = ", ".$stateNew.", ".$country."."; elseif($postcode == "" && $townNew == "" && $stateNew == "" && $country != "") $toreturn = ", ".$country."."; elseif($postcode == "" && $townNew != "" && $stateNew == "" && $country != "") $toreturn = ", ".$townNew.", ".$country."."; elseif($postcode != "" && $townNew == "" && $stateNew == "" && $country != "") $toreturn = ", ".$postcode.", ".$country."."; elseif($postcode != "" && $townNew == "" && $stateNew != "" && $country == "") $toreturn = ", ".$postcode.", ".$stateNew; elseif($postcode != "" && $townNew != "" && $stateNew == "" && $country != "") $toreturn = ", ".$postcode.", ".$townNew.", ".$country."."; elseif($postcode != "" && $townNew == "" && $stateNew != "" && $country != "") $toreturn = ", ".$postcode.", ".$stateNew.", ".$country."."; elseif($postcode == "" && $townNew == "" && $stateNew == "" && $country == "") $toreturn = ""; } } return $toreturn; } function countryNotFoundReplace($postcode="", $town="", $state="", $country="") { global $db_bcorp; $townNew = common::lookupPlace($town); $stateNew = common::lookupPlace($state); if($postcode != "") { $stmt = "SELECT * FROM lookup_postcode WHERE postcode='".$postcode."'"; $fullAdd = 0; } elseif($postcode == "" && $townNew != "") { $stmt = "SELECT * FROM lookup_postcode WHERE town='".$townNew."'"; $fullAdd = 0; } elseif($postcode == "" && $townNew == "" && $stateNew != "") { $stmt = " SELECT DISTINCT(state), country FROM lookup_postcode WHERE state='".$stateNew."'"; $fullAdd = 1; } elseif($postcode == "" && $townNew == "" && $stateNew == "" && $country != "") { $stmt = " SELECT DISTINCT(country) FROM lookup_postcode WHERE country='".$country."'"; $fullAdd = 2; } elseif($postcode == "" && $townNew == "" && $stateNew == "" && $country == "") { return $country = ""; } if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF) { if($fullAdd == 0) $toreturn = $rs->Fields('country'); elseif($fullAdd == 1) $toreturn = $rs->Fields('country'); else $toreturn = $rs->Fields('country'); } else $country = ""; } return $toreturn; } function townNotFoundReplace($postcode="", $town="", $state="", $country="") { global $db_bcorp; $townNew = common::lookupPlace($town); $stateNew = common::lookupPlace($state); if($postcode != "") { $stmt = "SELECT * FROM lookup_postcode WHERE postcode='".$postcode."'"; $fullAdd = 0; } elseif($postcode == "" && $townNew != "") { $stmt = "SELECT * FROM lookup_postcode WHERE town='".$townNew."'"; $fullAdd = 0; } elseif($postcode == "" && $townNew == "") { return $town = ""; } if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF) { if($fullAdd == 0) $toreturn = $rs->Fields('town'); } else $town = ""; } return $toreturn; } function stateNotFoundReplace($postcode="", $town="", $state="", $country="") { global $db_bcorp; $townNew = common::lookupPlace($town); $stateNew = common::lookupPlace($state); if($postcode != "") { $stmt = "SELECT * FROM lookup_postcode WHERE postcode='".$postcode."'"; $fullAdd = 0; } elseif($postcode == "" && $townNew != "") { $stmt = "SELECT * FROM lookup_postcode WHERE town='".$townNew."'"; $fullAdd = 0; } elseif($postcode == "" && $townNew == "") { return $state = ""; } if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF) { if($fullAdd == 0) $toreturn = $rs->Fields('state'); } else $state = ""; } return $toreturn; } function lookupCourt($code="") { global $db_bcorp; $stmt = "SELECT l_other_description FROM l_other WHERE l_other_type = 'COURT' AND l_other_code='".$code."'"; if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF) $toreturn = $rs->Fields('l_other_description'); else $toreturn = $code; } return $toreturn; } function lookupPostcode($postcode="") { global $db_bcorp; $stmt = "SELECT AreaCode FROM lookup_postcode WHERE postcode='".$postcode."'"; if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF) $toreturn = $rs->Fields('AreaCode'); else $toreturn = $postcode; } return $toreturn; } function findShortFormName($name) { global $db_bcorp; //-->CONVERT ALL THE NAME INTO SHORT FORM $nameWithoutTitle = explode(" ", trim($name)); for($j=0; $jExecute($stmt_similar_word)) { trigger_error("Error: Execute SQL: $stmt_similar_word. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if(!$rs_similar_word->EOF) { $nameWithoutTitle[$j] = $rs_similar_word->Fields('ReplaceWord'); } else $nameWithoutTitle[$j] = $nameWithoutTitle[$j]; } for($x=0; $xExecute($stmt)) { if(!$rs->EOF) { while($rsa = $rs->FetchRow()) { $pstrListName = common::findShortFormName($rsa['FormerName']); if($pstrList != "") $pstrList = $pstrList.",".$pstrListName; else $pstrList = $pstrListName; } $toreturn = $pstrList; //$toreturn = substr_replace($pstrList, "", -1); } else $toreturn = ""; } return $toreturn; } function compFormerName($localno) { global $db_bcorp; $stmt = "SELECT FormerName, LocalNo FROM company_former WHERE LocalNo='".$localno."'"; $toreturn = array(); if($rs = $db_bcorp->Execute($stmt)) { while($rsa = $rs->FetchRow()) { array_push($toreturn, array("FormerName"=>$rsa['FormerName'], "LocalNo"=>$rsa['LocalNo'])); } } return $toreturn; } function litigation_windup($localno) { global $db_bcorp; $stmt = "Select * from windup_details where LocalNo=" . $localno . " and windupdate!=''"; if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF) $pblnFound = true; else $pblnFound = false; } $litigation_windup = $pblnFound; return $litigation_windup; } function litigation_localno($pstrID, $mstrRegNo) { global $db_bcorp; $stmt = "SELECT * FROM suit_defendant WHERE ID=" . $pstrID . " AND ICPPRegNo=" .$mstrRegNo; if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF) $pblnFound = true; else $pblnFound = false; } if(!$pblnFound) //if not found with localno, then match company name { $stmt1 = "SELECT * FROM suit_defendant WHERE ID=" . $pstrID . " AND Name=" . $mstrRegName; if($rs1 = $db_bcorp->Execute($stmt1)) { if(!$rs1->EOF) $pblnFound = true; else $pblnFound = false; } } $litigation_localno = $pblnFound; return $litigation_localno; } function str2par($string) { $yow = str_replace ( '&', '&', $string); $yow = str_replace ( "", ''', $yow); $yow = str_replace ( "'", ''', $yow); $yow = str_replace ( "", 'µ', $yow); $yow = str_replace("\r\n", "", $yow); $yow = str_replace('\r\n', "", $yow); $toreturn1 = explode("", $yow); for($i=0; $i"; } $toreturn = explode("", $allText); return $toreturn; } function comma($string1, $string2) { if($string1 < sizeof($string2) - 1) return $toreturn = ", "; else return $toreturn ="."; } //GET THE REPORT FULL NAME. EG: BCR => BASIC CREDIT REPORT function reportFullname($string) { global $db_bn; $stmt = "SELECT product_name FROM bn_product WHERE product_code = '".$string."' GROUP BY product_code"; if($rs = $db_bn->Execute($stmt)) { $toreturn = $rs->Fields('product_name'); } return $toreturn; } function wordCombine($string) { if($string != ".") { $word .= $string." "; } /*else $word .= $string."\r\n";*/ return $word; } function orderDueDate($productCode, $updateMode) { global $db_bn; $stmt = "SELECT product_turnaround_normal, product_turnaround_express, product_turnaround_superflash FROM bn_company_price WHERE product_code = '".$productCode."' AND comp_idx='".$_SESSION['comp_idx']."'"; if($rs = $db_bn->Execute($stmt)) { if($updateMode == "normal") $duration = $rs->Fields('product_turnaround_normal'); elseif($updateMode == "express") $duration = $rs->Fields('product_turnaround_express'); else $duration = $rs->Fields('product_turnaround_superflash'); } $dt = date('d/m/Y'); $dy = $duration; $original = date('d M Y',basic::convertdate($dt)); $i=1; $add=0; while( $i<=($dy+$add) ) { if( date('l',strtotime($original." +".$i."days"))=='Saturday' || date('l',strtotime($original." +".$i."days"))=='Sunday' ) { $add++; } $pubholiday_sql = "SELECT * FROM bn_public_holiday WHERE ph_date = '".date('d/m/Y',strtotime($original." +".$i."days"))."'"; $pubholiday_data = $db_bn->Execute($pubholiday_sql) or die($db_bn -> ErrorMsg()); $pubholiday_row = $pubholiday_data -> RowCount(); if( $pubholiday_row > 0 ) { $add++; } $i++; } $dateNow = basic::convertdate($dt); $totalduration = $add + $dy; $dueDate = $dateNow + (60 * 60 * 24 * ($totalduration-1)); return($dueDate); } function AAFileName($localno, $lastUpdate) { $date = substr($lastUpdate, 6, 4) . substr($lastUpdate, 3, 2) . substr($lastUpdate, 0, 2); $path = $localno."-".$date; return $path; } // Bracket negative values, and return 'dash' for zero values // Use for economic/industry outlook, balance sheet and profit & loss function other_proper_value($number) { for ($x=0;$x<5;$x++) { if ($number[$x]==0 || $number[$x]==NULL) $number[$x] = '-'; else if ($number[$x]>0) $number[$x] = number_format($number[$x]); else if ($curr<0) { $number[$x] = "<" .number_format($number[$x]*-1). ">"; } } return $number; } //return true if found floating values with two decimal point function is_2_decimal ($number) { $limit = count($number); $counter = 0; for ($x=0;$x<$limit;$x++) { list ($before,$after) = split('[.]', $number[$x]); if (strlen($after) == 2) $counter++; } if ($counter>0) return true; else return false; } //return true if value has only 1 decimal number function is_1_decimal ($number) { $limit = count($number); $counter = 0; for ($x=0;$x<$limit;$x++) { list ($before,$after) = split('[.]', $number[$x]); if (strlen($after) == 1) $counter++; } if ($counter>0) return true; else return false; } //return true if decimal point dividable with 0.10 function is_decimal_ten($number) { $limit = count($number); $counter = 0; for ($x=0;$x<$limit;$x++) { list ($before, $after) = split('[.]', $number[$x]); $balance = $after % 10; if ($balance == 0 ) $counter++; } if ($counter>0) return true; else return false; } //return true if integer has no trailing zero decimals eg: (1 is true, 1.0 is false) function no_zero_decimals($number) { $limit = count($number); $counter = 0; for ($x=0;$x<$limit;$x++) { if ($number[$x]!=0 || $number[$x]!=NULL) { list ($before, $after) = split('[.]', $number[$x]); if ($after == '0' || $after == '00' || $after == NULL || $after = '' || $after == ' ') $counter++; } } if (round($counter/(--$limit))==1) return true; else return false; } //set value properly to print in report function proper_value ($number) { if (common::is_2_decimal($number)==true && common::is_decimal_ten($number)==false) { for ($x=0;$x<5;$x++) { if ($number[$x]>0) $number[$x] = number_format($number[$x],2); else if ($number[$x]<0) { $number[$x] = "<" .number_format(($number[$x]*-1),2). ">"; } else $number[$x] = "-"; } } else if (common::is_1_decimal($number)==true) { for ($x=0;$x<5;$x++) { if ($number[$x]==0) $number[$x]='-'; else if ($number[$x]> 0) $number[$x] = number_format($number[$x],1); else if ($number[$x]< 0) { $number[$x] = "<" .number_format(($number[$x]*-1),1). ">"; } else $number[$x] = "-"; } } else if (common::is_2_decimal($number)==true && common::is_decimal_ten($number)==true) { for ($x=0;$x<5;$x++) { if ($number[$x]==0) $number[$x]='-'; else if ($number[$x]>0) $number[$x] = number_format($number[$x],1); else if ($number[$x]<0) { $number[$x] = "<" .number_format(($number[$x]*-1),1). ">"; } else $number[$x] = "-"; } } else if (common::no_zero_decimals($number)==true) { for ($x=0;$x<5;$x++) { if ($number[$x]==0) $number[$x]='-'; else if ($number[$x]>0) $number[$x] = number_format($number[$x]); else if ($number[$x]<0) { $number[$x] = "<" .number_format(abs($number[$x])). ">"; } else $number[$x] = "-"; } } else for ($x=0;$x<5;$x++) { if ($number[$x]==0) $number[$x]='-'; if ($number[$x]>0) $number[$x] = number_format($number[$x],2); else if ($number[$x]<0) $number[$x] = "<" .number_format(($number[$x]*-1),2). ">"; else $number[$x] = "-"; } return $number; } // split text to paragraphs by tokenizing line feed latest function str2parag($string) { $yow = str_replace ( '&', '&', $string); $yow = str_replace ( "", ''', $yow); $yow = str_replace ( "'", ''', $yow); $yow = str_replace ("\r\n", "YOW", $yow);//USED WHEN THERE IS A NEWLINE $yow = str_replace ('\r\n', "YOW", $yow);//USED WHEN THERE IS A '\r\n' $yow = explode("YOW", $yow); return $yow; } // split text to paragraphs by tokenizing line feed latest for basis comment function str2parag_basic($string) { $yow = str_replace ( '&', '&', $string); $yow = str_replace ( "", ''', $yow); $yow = str_replace ("\r\n", "YOW", $yow);//USED WHEN THERE IS A NEWLINE $yow = str_replace ('\r\n', "YOW", $yow);//USED WHEN THERE IS A '\r\n' $yow = explode("YOW", $yow); return $yow; } // tokenize and then append string function append_comment ($string) { if (count($string)!=0) { $yow = implode(" ", $string); $yow = explode("YOW", $yow); } return $yow; } // return real value of OVERAL INDUSTRY VALUE according to it's short form function businesstrend ($string) { if ($string == "MG") return $bt = "Marginal Growth"; else if ($string == "M") return $bt = "Mature"; else if ($string == "D") return $bt = "Decline"; else if ($string == "SG") return $bt = "Strong Growth"; else if ($string == "AG") return $bt = "Average Growth"; else if ($string == "NY") return $bt = "Not Yet Determined"; else return $bt == "-"; } // check wether appropriate tags need to be echoed to xml function pnl_displayorhidetags ($numbers) { $count_numbers = count($numbers); $count_null = 0; for ($x=0;$x<$count_numbers;$x++) { if (is_null($numbers[$x]) || $numbers[$x]==0) ++$count_null; } if ($count_numbers==$count_null) return $result=1; else return $result=0; } // check wether appropriate tags need to be echoed to xml only for turnover function pnl_displayorhidetags_turnover($numbers) { $count_numbers = count($numbers); $count_null = 0; for ($x=0;$x<$count_numbers;$x++) { if (is_null($numbers[$x])) ++$count_null; } if ($count_numbers==$count_null) return $result=1; else return $result=0; } // check wether value need to be bracketed or not function pnl_displayorhidebrackets($number) { if ($number<0) $output = "<" .number_format($number*-1). ">"; else if (is_null($number) || $number==0) $output = "-"; else $output = number_format($number); return $output; } function pnl_displayorhidebrackets_turnover($number) { if ($number<0) $output = "<" .number_format($number*-1). ">"; else if (is_null($number)) $output = "-"; else $output = number_format($number); return $output; } function pnl_displayTagZero ($numbers) { $count_numbers = count($numbers); $count_null = 0; for ($x=0;$x<$count_numbers;$x++) { if (is_null($numbers[$x]) || $numbers[$x]==0) ++$count_null; } if ($count_numbers==$count_null) return $result=0; else return $result=0; } // check wether value need to be bracketed or not for fanancial ratio function pnl_displayorhidebrackets1 ($number) { if ($number<0) $output = "<" .number_format($number*-1). ">"; else if (is_null($number) || $number==0) $output = 0; else $output = number_format($number); return $output; } function proper_valueRatio($number) { if ($number > 0) return $number = number_format($number,2); else if ($number < 0 && $number != 0.00) { return $number = "<" .number_format(($number*-1),2). ">"; } else if (is_null($number) || $number==0 || $number == 0.00) { return $number = 0; } else return $number = 0; } // format date according to malaysian standard function pnl_formatdate ($date) { $string = explode('-',$date); if ($string[1]==01) $string[1]='January'; else if ($string[1]==02) $string[1]='February'; else if ($string[1]==03) $string[1]='March'; else if ($string[1]==04) $string[1]='April'; else if ($string[1]==05) $string[1]='May'; else if ($string[1]==06) $string[1]='June'; else if ($string[1]==07) $string[1]='July'; else if ($string[1]==08) $string[1]='August'; else if ($string[1]==09) $string[1]='September'; else if ($string[1]==10) $string[1]='October'; else if ($string[1]==11) $string[1]='November'; else if ($string[1]==12) $string[1]='December'; $new_date = array(); $new_date[0] = $string[2]; $new_date[1] = $string[1]; $new_date[2] = $string[0]; $new_date = implode('-',$new_date); return $new_date; } //return true if 1st date is newer than 2nd date function timeisbigger($date1,$date2) { if($date1 == "0000-00-00") $date1 = "1971-01-01"; elseif($date1 == "") $date1 = "1971-01-01"; if($date2 == "0000-00-00") $date2 = "1971-01-01"; elseif($date2 == "") $date2 = "1971-01-01"; $date1 = strtotime($date1); $date2 = strtotime($date2); if ( $date1 > $date2) return 1; elseif ($date1 == $date2) return 2; elseif ($date1 < $date2) return 0; } function timeIsBiggerFinancial($localno, $type) { global $db_bcorp; $stmt_sfr = "SELECT * FROM bc_cpo_pl WHERE LocalNo = '" .$localno. "' ORDER BY FinancialYear DESC"; if(!$rs_sfr = $db_bcorp->Execute($stmt_sfr)) { trigger_error("Error: Execute SQL: $stmt_sfr. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $sfr_date = $rs_sfr->fields['FinancialYear']; $stmt_fullfr = "SELECT * FROM bc_report_financial WHERE LocalNo = '" .$localno. "' ORDER BY Date DESC"; if(!$rs_fullfr = $db_bcorp->Execute($stmt_fullfr)) { trigger_error("Error: Execute SQL: $stmt_fullfr. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $fullfr_date = $rs_fullfr->fields['Date']; if(common::timeisbigger($sfr_date, $fullfr_date) == 1)//COMPARE SIMPLE SET='CP' WITH FULLSET { return $ratioType = "cpFr"; } else { if($type == "fr") { $financialGroup = "FRG2"; $financialCompany = "FRC2"; } elseif($type == "bs") { $financialGroup = "FBG"; $financialCompany = "FBC"; } elseif($type == "pl") { $financialGroup = "FPG"; $financialCompany = "FPC"; } //STARTED TO COMPARE GROUP WITH COMPANY, AND CHOOSE THE BIGGER .. $stmt_groupfr = "SELECT * FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$financialGroup."' ORDER BY Date DESC"; if(!$rs_groupfr = $db_bcorp->Execute($stmt_groupfr)) { trigger_error("Error: Execute SQL: $stmt_groupfr. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if(!$rs_groupfr->EOF) $groupfr_date = strtotime($rs_groupfr->fields['Date']); else $groupfr_date = 0; $stmt_companyfr = "SELECT * FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$financialCompany."' ORDER BY Date DESC"; if(!$rs_companyfr = $db_bcorp->Execute($stmt_companyfr)) { trigger_error("Error: Execute SQL: $stmt_companyfr. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if(!$rs_companyfr->EOF) $companyfr_date = strtotime($rs_companyfr->fields['Date']); else $companyfr_date = 0; if($groupfr_date > $companyfr_date ) return $ratioType = "groupFr"; elseif( $companyfr_date > $groupfr_date ) return $ratioType = "companyFr"; elseif($companyfr_date == $groupfr_date) return $ratioType = "groupFr"; } } function isDisplay2Set($localno, $type) { global $db_bcorp; $stmt_sfr = "SELECT * FROM bc_cpo_pl WHERE LocalNo = '" .$localno. "' ORDER BY FinancialYear DESC"; $rs_sfr = $db_bcorp->Execute($stmt_sfr); $sfr_date = $rs_sfr->fields['FinancialYear']; $stmt_fullfr = "SELECT * FROM bc_report_financial WHERE FinancialType != 'FRC2' AND LocalNo = '" .$localno. "' ORDER BY Date DESC"; $rs_fullfr = $db_bcorp->Execute($stmt_fullfr); if(!$rs_fullfr->EOF) $fullfr_date = $rs_fullfr->fields['Date']; else $fullfr_date = "0000-00-00"; if(common::timeisbigger($sfr_date, $fullfr_date) == 1)//COMPARE SIMPLE SET='CP' WITH FULLSET { $cp_year = date('Y', strtotime($sfr_date)); $fullset_year = date('Y', strtotime($fullfr_date)); $ratioType[0] = "cpFr"; if($cp_year - $fullset_year <= 1)//TO CHECK WHETHER THE RANGE WITHIN YEAR NOT MORE THAN ONE, EG: 2006,2005,2004 $isDisplay2set = 1; elseif($cp_year - $fullset_year > 1)//TO CHECK WHETHER THE RANGE WITHIN YEAR NOT MORE THAN ONE, EG: 2006,2004 $isDisplay2set = 2; } else { $isDisplay2set = 0; $ratioType[0] = ""; } if($isDisplay2set == 1) { if($type == "fr") { $financialGroup = "FRG2"; $financialCompany = "FRC2"; } elseif($type == "bs") { $financialGroup = "FBG"; $financialCompany = "FBC"; } elseif($type == "pl") { $financialGroup = "FPG"; $financialCompany = "FPC"; } //STARTED TO COMPARE GROUP WITH COMPANY, AND CHOOSE THE BIGGER .. $stmt_groupfr = "SELECT * FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$financialGroup."' ORDER BY Date DESC"; $rs_groupfr = $db_bcorp->Execute($stmt_groupfr); if(!$rs_groupfr->EOF) $groupfr_date = strtotime($rs_groupfr->fields['Date']); else $groupfr_date = 0; $stmt_companyfr = "SELECT * FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$financialCompany."' ORDER BY Date DESC"; $rs_companyfr = $db_bcorp->Execute($stmt_companyfr); if(!$rs_companyfr->EOF) $companyfr_date = strtotime($rs_companyfr->fields['Date']); else $companyfr_date = 0; if($groupfr_date > $companyfr_date ) { $yearnow = date('Y'); $groupYear = date('Y', $groupfr_date); $diferrentYear = $yearnow - $groupYear; if($diferrentYear >= 5) $ratioType[1] = ""; else $ratioType[1] = "groupFr"; } elseif( $companyfr_date > $groupfr_date ) { $yearnow = date('Y'); $companyYear = date('Y', $companyfr_date); $diferrentYear = $yearnow - $companyYear; if($diferrentYear >= 5) $ratioType[1] = ""; else $ratioType[1] = "companyFr"; } elseif($companyfr_date == $groupfr_date) { $yearnow = date('Y'); $groupYear = date('Y', $groupfr_date); $diferrentYear = $yearnow - $groupYear; if($diferrentYear >= 5) $ratioType[1] = ""; else $ratioType[1] = "groupFr"; } } elseif($isDisplay2set == 2) { $ratioType[0] = "cpFr"; $ratioType[1] = ""; } else { if($type == "fr") { $financialGroup = "FRG2"; $financialCompany = "FRC2"; } elseif($type == "bs") { $financialGroup = "FBG"; $financialCompany = "FBC"; } elseif($type == "pl") { $financialGroup = "FPG"; $financialCompany = "FPC"; } //STARTED TO COMPARE GROUP WITH COMPANY, AND CHOOSE THE BIGGER .. $stmt_groupfr = "SELECT * FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$financialGroup."' ORDER BY Date DESC"; $rs_groupfr = $db_bcorp->Execute($stmt_groupfr); if(!$rs_groupfr->EOF) $groupfr_date = strtotime($rs_groupfr->fields['Date']); else $groupfr_date = 0; $stmt_companyfr = "SELECT * FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$financialCompany."' ORDER BY Date DESC"; $rs_companyfr = $db_bcorp->Execute($stmt_companyfr); if(!$rs_companyfr->EOF) $companyfr_date = strtotime($rs_companyfr->fields['Date']); else $companyfr_date = 0; if($groupfr_date > $companyfr_date ) { $yearnow = date('Y'); $groupYear = date('Y', $groupfr_date); $diferrentYear = $yearnow - $groupYear; if($diferrentYear >= 5) $ratioType[1] = ""; else $ratioType[1] = "groupFr"; } elseif( $companyfr_date > $groupfr_date ) { $yearnow = date('Y'); $companyYear = date('Y', $companyfr_date); $diferrentYear = $yearnow - $companyYear; if($diferrentYear >= 5) $ratioType[1] = ""; else $ratioType[1] = "companyFr"; } elseif($companyfr_date == $groupfr_date) { $yearnow = date('Y'); $groupYear = date('Y', $groupfr_date); $diferrentYear = $yearnow - $groupYear; if($diferrentYear >= 5) $ratioType[1] = ""; else $ratioType[1] = "groupFr"; } } return $ratioType; } // check wether value need to be bracketed or not for simple function pnl_displayorhidebrackets2 ($number) { if ($number<0) $output = "<" .number_format($number*-1, 2). ">"; else if (is_null($number) || $number==0) $output = number_format($number, 2); else $output = number_format($number, 2); return $output; } // check wether value need to be bracketed or not for simple function pnl_displayorhidebrackets3 ($number) { if ($number<0) $output = "<" .number_format($number*-1). ">"; else if (is_null($number) || $number==0) $output = number_format($number); else $output = number_format($number); return $output; } //CHANGE COUNTRY CODE: MY ==> MALAYSIA function countryFullName($countryCode) { global $db_bn; $stmt = "SELECT l_country_name FROM l_country WHERE l_country_code='".$countryCode."'"; if($rs = $db_bn->Execute($stmt)) return $rs->Fields('l_country_name'); else return false; } //CHANGE LOCALN NO: 669929 ==> 669929-D function localNoFull($number) { global $db_bcorp; $stmt = "SELECT bc_entity_class, bc_entity_localNo FROM bc_entity WHERE bc_entity_localNo ='".$number."'"; if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF) { //if($rs->Fields('bc_entity_class') == "") $toreturn = $rs->Fields('bc_entity_localNo'); //else // $toreturn = $rs->Fields('bc_entity_localNo')."-".$rs->Fields('bc_entity_class'); } else $toreturn = $number; } return $toreturn; } //GET THE LATEST 3 YEAR DATA FROM BC FINANCIAL REPORT DETAIL FOR FINANCIAL PART /*function in3YearBefore($localno, $type) { global $db_bcorp; $validYearBefore = array(); $counter = $i = 0; $currentYear = date('Y', time()); if($currentYear - common::financialYear($localno) <= 4) { $financialLatestYear1 = common::financialYear($localno); $financialLatestYear2 = $financialLatestYear1 - 1; $financialLatestYear3 = $financialLatestYear2 - 1; while($i < 10) { if($counter != 3) { $yearBefore = $currentYear - $i; $stmt_frYearCheck = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$type."' AND Year ='".$yearBefore."' group by Year, YearCount ORDER BY 'Year' DESC"; $rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck) or die($db_bcorp->ErrorMSg()); if(!$rs_frYearCheck->EOF) { if($counter != 3) { if($currentYear - $yearBefore <= 4) { while($rsa = $rs_frYearCheck->FetchRow()) { $validYearBefore[$counter]['year']= $yearBefore; $validYearBefore[$counter]['yearCount']= $rsa['YearCount']; $counter++; } } } } } else break; $i++; } if($validYearBefore[0]['year']!= "" && $validYearBefore[1]['year']!= "" && $validYearBefore[2]['year']!= "") $yearBeforeText = "((Year=".$validYearBefore[0]['year']." AND YearCount=".$validYearBefore[0]['yearCount'].") OR (Year=".$validYearBefore[1]['year']." AND YearCount=".$validYearBefore[1]['yearCount'].") OR (Year=".$validYearBefore[2]['year']." AND YearCount=".$validYearBefore[2]['yearCount']."))"; elseif($validYearBefore[0]['year']!= "" && $validYearBefore[1]['year']!= "" && $validYearBefore[2]['year']== "") $yearBeforeText = "((Year=".$validYearBefore[0]['year']." AND YearCount=".$validYearBefore[0]['yearCount'].") OR (Year=".$validYearBefore[1]['year']." AND YearCount=".$validYearBefore[1]['yearCount']."))"; elseif($validYearBefore[0]['year']!= "" && $validYearBefore[1]['year']== "" && $validYearBefore[2]['year']== "") $yearBeforeText = "(Year=".$validYearBefore[0]['year']." AND YearCount=".$validYearBefore[0]['yearCount'].")"; elseif($validYearBefore[0]['year']== "" && $validYearBefore[1]['year']== "" && $validYearBefore[2]['year']== "") $yearBeforeText = "Year=-1"; } return $yearBeforeText; }*/ //GET THE LATEST 3 YEAR DATA FROM BC FINANCIAL REPORT DETAIL FOR FINANCIAL PART /*function in3YearBefore($localno, $type) { global $db_bcorp; $validYearBefore = array(); $counter = $i = 0; $currentYear = date('Y', time()); if($currentYear - common::financialYear($localno) <= 4) { $financialLatestYear1 = common::financialYear($localno); $financialLatestYear2 = $financialLatestYear1 - 1; $financialLatestYear3 = $financialLatestYear2 - 1; $yearBefore = "(".$financialLatestYear1.",".$financialLatestYear2.",".$financialLatestYear3.")"; $stmt_frYearCheck = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$type."' AND Year IN ".$yearBefore." group by Year, YearCount ORDER BY 'Year' DESC"; //$stmt_frYearCheck = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$type."' AND Year IN ".$yearBefore." group by YearCount ORDER BY 'Year' DESC"; if (!$rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck)) { trigger_error("Error: Execute SQL: $stmt_frYearCheck. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } //$rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck) or die($db_bcorp->ErrorMSg()); if(!$rs_frYearCheck->EOF) { while($rsa = $rs_frYearCheck->FetchRow()) { $validYearBefore[$counter]['year']= $yearBefore; $validYearBefore[$counter]['yearCount']= $rsa['YearCount']; } } if($validYearBefore[0]['year']!= "" && $validYearBefore[1]['year']!= "" && $validYearBefore[2]['year']!= "") $yearBeforeText = "((Year IN ".$validYearBefore[0]['year']." AND YearCount=".$validYearBefore[0]['yearCount'].") OR (Year=".$validYearBefore[1]['year']." AND YearCount=".$validYearBefore[1]['yearCount'].") OR (Year=".$validYearBefore[2]['year']." AND YearCount=".$validYearBefore[2]['yearCount']."))"; elseif($validYearBefore[0]['year']!= "" && $validYearBefore[1]['year']!= "" && $validYearBefore[2]['year']== "") $yearBeforeText = "((Year IN ".$validYearBefore[0]['year']." AND YearCount=".$validYearBefore[0]['yearCount'].") OR (Year=".$validYearBefore[1]['year']." AND YearCount=".$validYearBefore[1]['yearCount']."))"; elseif($validYearBefore[0]['year']!= "" && $validYearBefore[1]['year']== "" && $validYearBefore[2]['year']== "") $yearBeforeText = "(Year IN ".$validYearBefore[0]['year']." AND YearCount=".$validYearBefore[0]['yearCount'].")"; elseif($validYearBefore[0]['year']== "" && $validYearBefore[1]['year']== "" && $validYearBefore[2]['year']== "") $yearBeforeText = "Year=-1"; } return $yearBeforeText; }*/ //GET THE LATEST 3 YEAR DATA FROM BC FINANCIAL REPORT DETAIL FOR FINANCIAL PART function in3YearBefore($localno, $type) { global $db_bcorp; $validYearBefore = array(); $counter = $i = 0; $currentYear = date('Y', time()); if($currentYear - common::financialYear($localno) <= 4) { $financialLatestYear1 = common::financialYear($localno); $financialLatestYear2 = $financialLatestYear1 - 1; $financialLatestYear3 = $financialLatestYear2 - 1; $yearBefore = "(".$financialLatestYear1.",".$financialLatestYear2.",".$financialLatestYear3.")"; $stmt_frYearCheck = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$type."' AND Year IN ".$yearBefore." ORDER BY 'Year' DESC"; //$stmt_frYearCheck = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$type."' AND Year IN ".$yearBefore." group by YearCount ORDER BY 'Year' DESC"; if (!$rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck)) { trigger_error("Error: Execute SQL: $stmt_frYearCheck. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } //$rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck) or die($db_bcorp->ErrorMSg()); if(!$rs_frYearCheck->EOF) { while($rsa = $rs_frYearCheck->FetchRow()) { array_push($validYearBefore, array("year"=>$rsa['Year'], "yearCount"=>$rsa['YearCount'])); //$validYearBefore[$counter]['year']= $yearBefore; //$validYearBefore[$counter]['yearCount']= $rsa['YearCount']; } } $validYearBefore = common::sortmddata($validYearBefore,'year','DESC','str'); for($j =0; $j 669929 function localNoToDigit($localno) { if(substr($localno, -2, 1) == "-") $localNoDigit = trim(str_replace(substr($localno, -2, 2), " ", $localno)); else $localNoDigit = $localno; return $localNoDigit; } //CHECK IS DORMANT ? function isDormant($localno) { global $db_bcorp; $stmt = "SELECT IndustryCode FROM company_sic WHERE localno='".$localno."' AND IndustryCode=0"; if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF && $rs->Fields('IndustryCode')!="") $toreturn = 1; else $toreturn = 0; } return $toreturn; } //CHECK IS PRIVATE EXEMPT Co ? function isPrivateExempt($localno) { global $db_bcorp; $stmtEntity = "SELECT bc_entity_legalStatus FROM bc_entity WHERE bc_entity_localNo='".$localno."'"; if($rsEntity = $db_bcorp->Execute($stmtEntity)) { if(!$rsEntity->EOF) { $stmt = "SELECT Code FROM bc_status WHERE Code='".$rsEntity->Fields('bc_entity_legalStatus')."'"; if($rs = $db_bcorp->Execute($stmt)) { if($rs->fields('Code') == "E") $toreturn = 1; else $toreturn = 0; } } else $toreturn = 0; } return $toreturn; } //FIND FINANCIAL COMMENT BASE ON CODE, E.G: DORMANT, OUT DATED ACCOUNT function financialComment($comment, $year="") { global $db_bcorp; $stmt = "SELECT Description FROM l_financial_statement WHERE Code ='".$comment."'"; if($rs = $db_bcorp->Execute($stmt)) { if(!$rs->EOF) { if($comment == "Out Dated Accounts") { $financialComment = str_replace("", $year, $rs->Fields('Description')); } else $financialComment = $rs->Fields('Description'); } } return $financialComment; } //FIND CP/SIMPLE SHEET OF FINANCIAL LATEST YEAR function financialCPLatestYear($localno) { global $db_bcorp; $stmt_spnl = "SELECT FinancialYear FROM bc_cpo_pl WHERE LocalNo = '" .$localno. "' ORDER BY FinancialYear DESC"; $rs_spnl = $db_bcorp->Execute($stmt_spnl); if(!$rs_spnl->EOF) $fcpLatestYear = $rs_spnl->fields['FinancialYear']; else { $stmt_sbs = "SELECT FinancialYear FROM bc_cpo_bs WHERE LocalNo = '" .$localno. "' ORDER BY FinancialYear DESC"; $rs_sbs = $db_bcorp->Execute($stmt_sbs); $fcpLatestYear = $rs_sbs->fields['FinancialYear']; } return $fcpLatestYear; } //FIND CURRENT YEAR function currentYear() { $timeNow = time(); $yearNow = date('Y', $timeNow); return $yearNow; } //CHOOSE FORMAT OF REPORT, E.G: XML, HTML, PDF function reportFormat2View() { global $db_bn; $stmt = "SELECT comp_rpt_html, comp_rpt_xml, comp_rpt_pdf FROM bn_company WHERE comp_idx='".$_SESSION['comp_idx']."'"; if($rs = $db_bn->Execute($stmt)) { if($rs->Fields('comp_rpt_html') == 1 && ($rs->Fields('comp_rpt_xml') == 1 || $rs->Fields('comp_rpt_pdf') == 1)) $toreturn = "htmlXmlpdf"; elseif($rs->Fields('comp_rpt_xml') == 1 && ($rs->Fields('comp_rpt_html') == 1 || $rs->Fields('comp_rpt_pdf') == 1)) $toreturn = "htmlXmlpdf"; elseif($rs->Fields('comp_rpt_pdf') == 1 && ($rs->Fields('comp_rpt_xml') == 1 || $rs->Fields('comp_rpt_html') == 1)) $toreturn = "htmlXmlpdf"; elseif($rs->Fields('comp_rpt_html') == 1 && $rs->Fields('comp_rpt_xml') != 1 && $rs->Fields('comp_rpt_pdf') != 1) $toreturn = "html"; elseif($rs->Fields('comp_rpt_xml') == 1 && $rs->Fields('comp_rpt_html') != 1 && $rs->Fields('comp_rpt_pdf') != 1) $toreturn = "xml"; elseif($rs->Fields('comp_rpt_pdf') == 1 && $rs->Fields('comp_rpt_html') != 1 && $rs->Fields('comp_rpt_xml') != 1) $toreturn = "pdf"; } return $toreturn; } //FIND THE YEAR OF LATEST FINANCIAL function financialLatestYear($localno) { global $db_bcorp; //cp => COMPANY, gr => CONSOLIDATED if( (common::timeIsBiggerFinancial($localno, "pl") == "companyFr") || (common::timeIsBiggerFinancial($localno, "bs") == "companyFr") ) { $stmt_financialFPC = "SELECT Date FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType = 'FPC' ORDER BY Date DESC"; $rs_reportFPC = $db_bcorp->Execute($stmt_financialFPC) or die($db_bcorp->ErrorMSg()); $pnl_reportFPC_date = $rs_reportFPC->fields['Date']; if(!$rs_reportFPC->EOF && ($pnl_reportFPC_date !="" || $pnl_reportFPC_date !="0000-00-00")) { $latestYear = date('Y', strtotime($pnl_reportFPC_date)); } else { $stmt_financialFBC = "SELECT Date FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType = 'FBC' ORDER BY Date DESC"; $rs_reportFBC = $db_bcorp->Execute($stmt_financialFBC) or die($db_bcorp->ErrorMSg()); $pnl_reportFBC_date = $rs_reportFBC->fields['Date']; if(!$rs_reportFBC->EOF && ($pnl_reportFBC_date !="" || $pnl_reportFBC_date !="0000-00-00")) { $latestYear = date('Y', strtotime($pnl_reportFBC_date)); } } } elseif((common::timeIsBiggerFinancial($localno, "pl") == "groupFr") || (common::timeIsBiggerFinancial($localno, "bs") == "groupFr")) { $stmt_financialFPG = "SELECT Date FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType = 'FPG' ORDER BY Date DESC"; $rs_reportFPG = $db_bcorp->Execute($stmt_financialFPG) or die($db_bcorp->ErrorMSg()); $pnl_reportFPG_date = $rs_reportFPG->fields['Date']; if(!$rs_reportFPG->EOF && ($pnl_reportFPG_date !="" || $pnl_reportFPG_date !="0000-00-00")) { $latestYear = date('Y', strtotime($pnl_reportFPG_date)); } else { $stmt_financialFBG = "SELECT Date FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType = 'FBG' ORDER BY Date DESC"; $rs_reportFBG = $db_bcorp->Execute($stmt_financialFBG) or die($db_bcorp->ErrorMSg()); $pnl_reportFBG_date = $rs_reportFBG->fields['Date']; if(!$rs_reportFBG->EOF && ($pnl_reportFBG_date !="" || $pnl_reportFBG_date !="0000-00-00")) { $latestYear = date('Y', strtotime($pnl_reportFBG_date)); } } } elseif((common::timeIsBiggerFinancial($localno, "pl") == "cpFr") || (common::timeIsBiggerFinancial($localno, "bs") == "cpFr")) { $stmt_cpo = "SELECT * FROM bc_cpo_bs WHERE LocalNo = '" .$localno. "' ORDER BY FinancialYear DESC"; $rs_cpo = $db_bcorp->Execute($stmt_cpo) or die($db_bcorp->ErrorMSg()); $cpo_date = $rs_cpo->fields['FinancialYear']; $latestYear = date('Y', strtotime($cpo_date)); } return $latestYear; } //COUNT NUMBER OF TOTAL LATEST FINANCIAL YEAR EXISTED function totalLatestFinancialYear($localno, $type="") { global $db_bcorp; $validYearBefore = array(); $counter = $i = 0; $currentYear = date('Y', time()); /** COUNT THE WHETHER YEAR WAS 1 ? **/ if($type == "companyFr") { $stmt_frYearCheck_count = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FPC' AND (Year - YEAR(NOW()) < 6 ) ORDER BY 'Year' DESC"; $rs_frYearCheck_count = $db_bcorp->Execute($stmt_frYearCheck_count) or die($db_bcorp->ErrorMSg()); if($rs_frYearCheck_count->EOF) { $stmt_frYearCheck_count = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FBC' AND (Year - YEAR(NOW()) < 6 ) ORDER BY 'Year' DESC"; $rs_frYearCheck_count = $db_bcorp->Execute($stmt_frYearCheck_count) or die($db_bcorp->ErrorMSg()); if(!$rs_frYearCheck_count->EOF) { $counter = $rs_frYearCheck_count->RecordCount(); } else { $counter = 0; } } else { $counter = $rs_frYearCheck_count->RecordCount(); } } else { $stmt_frYearCheck_count = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FPG' AND (Year - YEAR(NOW()) < 6 ) ORDER BY 'Year' DESC"; $rs_frYearCheck_count = $db_bcorp->Execute($stmt_frYearCheck_count) or die($db_bcorp->ErrorMSg()); if($rs_frYearCheck_count->EOF) { $stmt_frYearCheck_count = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FBG' AND (Year - YEAR(NOW()) < 6 ) ORDER BY 'Year' DESC"; $rs_frYearCheck_count = $db_bcorp->Execute($stmt_frYearCheck_count) or die($db_bcorp->ErrorMSg()); $counter = $rs_frYearCheck_count->RecordCount(); } if(!$rs_frYearCheck_count->EOF) { $counter = $rs_frYearCheck_count->RecordCount(); } else { $counter = 0; } } if($counter > 1) { //cp => COMPANY, gr => CONSOLIDATED while($i < 10) { if($counter != 3) { $yearBefore = $currentYear - $i; $gotoGroup = 0; $stmt_frYearCheck = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FPC' AND Year ='".$yearBefore."' group by Year, YearCount ORDER BY 'Year' DESC"; $rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck) or die($db_bcorp->ErrorMSg()); if($rs_frYearCheck->EOF) { $stmt_frYearCheck = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FBC' AND Year ='".$yearBefore."' group by Year, YearCount ORDER BY 'Year' DESC"; $rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck) or die($db_bcorp->ErrorMSg()); if($rs_frYearCheck->EOF) $gotoGroup = 1; else $gotoGroup = 0; } if($gotoGroup == 1) { $stmt_frYearCheck = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FPG' AND Year ='".$yearBefore."' group by Year, YearCount ORDER BY 'Year' DESC"; $rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck) or die($db_bcorp->ErrorMSg()); if($rs_frYearCheck->EOF) { $stmt_frYearCheck = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FBG' AND Year ='".$yearBefore."' group by Year, YearCount ORDER BY 'Year' DESC"; $rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck) or die($db_bcorp->ErrorMSg()); } } if(!$rs_frYearCheck->EOF) { //if($counter != 3) //{ while($rsa = $rs_frYearCheck->FetchRow()) { $validYearBefore[$counter]['year']= $yearBefore; $validYearBefore[$counter]['yearCount']= $rsa['YearCount']; $counter++; } //} } } else break; $i++; } } elseif($counter == 1 ) $counter = 1; elseif($counter == 0 ) $counter = 0; return $counter; } //STORING ALL THE LATEST FINANCIAL YEAR AND THE YEAR COUNT E.G: 2005, 2006, 2007 function allLatestFinancialYear($localno) { global $db_bcorp; $validYearBefore = array(); $counter = $i = 0; $currentYear = date('Y', time()); while($i < 10) { if($counter != 3) { $yearBefore = $currentYear - $i; $gotoGroup = 0; //if( (common::timeIsBiggerFinancial($localno, "pl") == "companyFr") || (common::timeIsBiggerFinancial($localno, "bs") == "companyFr") ) //{ $stmt_frYearCheck = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FPC' AND Year ='".$yearBefore."' group by Year, YearCount ORDER BY 'Year' DESC"; $rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck) or die($db_bcorp->ErrorMSg()); if($rs_frYearCheck->EOF) { $stmt_frYearCheck1 = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FBC' AND Year ='".$yearBefore."' group by Year, YearCount ORDER BY 'Year' DESC"; $rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck1) or die($db_bcorp->ErrorMSg()); if($rs_frYearCheck->EOF) $gotoGroup = 1; else $gotoGroup = 0; } //} //elseif((common::timeIsBiggerFinancial($localno, "pl") == "groupFr") || (common::timeIsBiggerFinancial($localno, "bs") == "groupFr")) //{ if($gotoGroup == 1) { $stmt_frYearCheck = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FPG' AND Year ='".$yearBefore."' group by Year, YearCount ORDER BY 'Year' DESC"; $rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck) or die($db_bcorp->ErrorMSg()); if($rs_frYearCheck->EOF) { $stmt_frYearCheck1 = "SELECT Year, YearCount FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='FBG' AND Year ='".$yearBefore."' group by Year, YearCount ORDER BY 'Year' DESC"; $rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck1) or die($db_bcorp->ErrorMSg()); } } //} if(!$rs_frYearCheck->EOF) { if($counter != 3) { while($rsa = $rs_frYearCheck->FetchRow()) { $validYearBefore[$counter]['year']= $yearBefore; $validYearBefore[$counter]['yearCount']= $rsa['YearCount']; $counter++; } } } } else break; $i++; } return $validYearBefore; } //--> START USED FOR FINANCIAL COMMENT PART -- // function ProfitabilityLoop($bs="", $pl="", $localno) { global $db_bcorp; $financialArray = common::allLatestFinancialYear($localno); $profitArray = array(); //for($i = sizeof($financialArray)-1; $i >= 0; $i-- )//--> TEMPORARY CHANGE THIS SORT METHOD for($i = 0; $i Execute($stmt_profBs) or die($db_bcorp->ErrorMSg()); if(!$rs_profBs->EOF) { $prof136 = $rs_profBs->Fields('Amount'); if($prof136 != 0) { $stmt_profPl = "Select * from financial_details WHERE LocalNo= '".$localno."' ". "AND FinancialType='".$pl."' ". "AND Year='".$financialArray[$i]['year']."' ". "AND YearCount = '".$financialArray[$i]['yearCount']."' ". "AND SequenceNo IN (2,6,25) ORDER BY Year DESC "; $rs_profPl = $db_bcorp->Execute($stmt_profPl) or die($db_bcorp->ErrorMSg()); if(!$rs_profPl->EOF) { //$mintYCount = 0; while(!$rs_profPl->EOF) { if($rs_profPl->Fields('SequenceNo') == 2) { if($rs_profPl->Fields('Amount') > 0) { $profpl2 = $rs_profPl->Fields('Amount'); $turnover[$i] = $rs_profPl->Fields('Amount'); $mintYCount = $mintYCount + 1; } else break; } elseif($rs_profPl->Fields('SequenceNo') == 6) { if($profpl2 > 0) { $profitB4Tax[$i] = $rs_profPl->Fields('Amount'); } } elseif($rs_profPl->Fields('SequenceNo') == 25) { if($profpl2 > 0) { $shareholderfund[$i] = $rs_profPl->Fields('Amount'); } } $rs_profPl->moveNext(); }//END WHILE array_push($profitArray, array("mintYCount"=>$mintYCount,"turnover"=>$turnover[$i], "profitb4tax"=>$profitB4Tax[$i], "shareholderfund"=>$shareholderfund[$i])); $profpl2 = 0; }//END if } } }//exit;//print_r($profitArray); return $profitArray; } function ProfitabilityNotFound($profitabilityArray, $localno) { global $db_bcorp; $yearNow = common::currentYear(); $profitArray = $profitabilityArray; if(sizeof($profitArray) == 0 || common::isTurnOverNil($bs, $pl, $localno) == 1) { $stmt_profNotFound = "SELECT bc_entity_legalStatus FROM bc_entity WHERE bc_entity_localNo='".$localno."'"; if(!$rs_profNotFound = $db_bcorp->Execute($stmt_profNotFound)) { trigger_error("Error: Execute SQL: $stmt_profNotFound. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if(!$rs_profNotFound->EOF) { if($rs_profNotFound->Fields('bc_entity_legalStatus') != "") $legalStatus = $rs_profNotFound->Fields('bc_entity_legalStatus'); } if($legalStatus == "E") $profitComment = common::financialComment("Private Exempt Co."); else { if(sizeof($profitArray) == 0) { if(common::totalLatestFinancialYear($localno) == 0) $profitComment = common::financialComment("No Accounts"); else { if(common::pintQty($localno) >= 5) $profitComment = common::financialComment("No Accounts"); elseif(common::pintQty($localno) > 3) $profitComment = common::financialComment("Out Dated Accounts"); elseif(common::isTurnOverNil($bs, $pl, $localno) == 1) $profitComment = common::financialComment("Turnover = Nil"); } } elseif(common::isTurnOverNil($bs, $pl, $localno) == 1) $profitComment = common::financialComment("Turnover = Nil"); else $profitComment = common::financialComment("No Accounts"); } } if(sizeof($profitArray) == 1) $profitComment = common::financialComment("One year account only"); return $profitComment; } function isTurnOverNil($bs="", $pl="", $localno) { global $db_bcorp; $financialArray = common::allLatestFinancialYear($localno); $stmt_profBs = "Select * from financial_details WHERE LocalNo = '".$localno."' ". "AND FinancialType='".$bs."' ". "AND Year='".$financialArray[0]['year']."' ". "AND YearCount = '".$financialArray[0]['yearCount']."' ". "AND SequenceNo=136 ORDER BY Year DESC "; $rs_profBs = $db_bcorp->Execute($stmt_profBs) or die($db_bcorp->ErrorMSg()); if(!$rs_profBs->EOF) { $prof136 = $rs_profBs->Fields('Amount'); if($prof136 > 0) { $stmt_profPl = "Select * from financial_details WHERE LocalNo= '".$localno."' ". "AND FinancialType='".$pl."' ". "AND Year='".$financialArray[0]['year']."' ". "AND YearCount = '".$financialArray[0]['yearCount']."' ". "AND SequenceNo in (2,6,25) ORDER BY Year DESC "; $rs_profPl = $db_bcorp->Execute($stmt_profPl) or die($db_bcorp->ErrorMSg()); if(!$rs_profPl->EOF) { while(!$rs_profPl->EOF) { if($rs_profPl->Fields('SequenceNo') == 2) { if($rs_profPl->Fields('Amount') < 0) { return 1; } else return 0; } $rs_profPl->moveNext(); } }//END if } } else { return 1; } } function pintQty($localno) { //E.G: 2005-2002 = 3; $latestYear = common::financialYear($localno); if($latestYear == "" || $latestYear == 0) $toreturn = 5;//MORE THAN 4 YEARS REPORT, WILL NOT CONSIDER AS LATEST FINANCIAL. elseif($latestYear != "" || $latestYear != 0) { $currentYear = common::currentYear(); if($currentYear - $latestYear < 5) $toreturn = $currentYear - $latestYear; elseif($currentYear - $latestYear >= 5) $toreturn = 5;//MORE THAN 4 YEARS REPORT, WILL NOT CONSIDER AS LATEST FINANCIAL. } return $toreturn; } function ProfitTurnover($arrayProfit, $localno, $financialTRComment = "") { global $db_bcorp; //FROFIT TURNOVER STATEMENT $stmt_profitTurnOver = "Select * from l_financial_analysis where Title='Turnover' and Sequence="; $countProfit = $arrayProfit[sizeof($arrayProfit)-1]['mintYCount'];// IS COUNT THE TOTAL NUMBER OF FINANCIAL YEAR. E.G: mintYCount if($countProfit == 3) { $a = $arrayProfit[0]['turnover'] - $arrayProfit[1]['turnover']; $b = $arrayProfit[1]['turnover'] - $arrayProfit[2]['turnover']; if($a > 0 && $b > 0) { $pintCond = "2"; $_SESSION['Turnover_Increased'] = $Turnover_Increased = True; } elseif($a < 0 && $b < 0) { $pintCond = "3"; $_SESSION['Turnover_Decreased'] = $Turnover_Decreased = True; } else { $pintCond = "1"; $_SESSION['Turnover_Erratic'] = $Turnover_Erratic = True; } $stmt_profitTurnOverNow = $stmt_profitTurnOver.$pintCond; $rs_profitTurnOver = $db_bcorp->Execute($stmt_profitTurnOverNow) or die($db_bcorp->ErrorMSg()); if(!$rs_profitTurnOver->EOF) { $financialYear = common::allLatestFinancialYear($localno); $turnOverCond = $rs_profitTurnOver->fields('ProfitCode'); $turnOverYR = $financialYear[2]['year']." - ".$financialYear[0]['year']; $financialTRComment = $financialTRComment.$rs_profitTurnOver->fields('ProfitDesc'); } } elseif($countProfit == 2 || $countProfit == 1) { $a = $arrayProfit[0]['turnover'] - $arrayProfit[1]['turnover']; if($arrayProfit[1]['turnover'] == 0) $arrayProfit[0]['turnover'] = 0; else $pdblRatio = (abs($a) / $arrayProfit[1]['turnover']) * 100; if($a > 0) { $_SESSION['Turnover_Increased'] = $Turnover_Increased = True; if($pdblRatio > 30) $pintCond = 4; elseif($pdblRatio >= 10 And $pdblRatio <= 30) $pintCond = 5; elseif($pdblRatio < 10 ) $pintCond = 6; } else { $_SESSION['Turnover_Decreased'] = $Turnover_Decreased = True; if ($pdblRatio > 30) $pintCond = 7; elseif ($pdblRatio >= 10 && $pdblRatio <= 30) $pintCond = 8; elseif ($pdblRatio < 10) $pintCond = 9; } $stmt_profitTurnOverNow = $stmt_profitTurnOver.$pintCond; $rs_profitTurnOver = $db_bcorp->Execute($stmt_profitTurnOverNow) or die($db_bcorp->ErrorMSg()); if(!$rs_profitTurnOver->EOF) { $turnOverCond = $rs_profitTurnOver->fields('ProfitCode'); if($pdblRatio > 0) $turnOverYR = number_format($pdblRatio, 2). "%"; else $turnOverYR = "<" . number_format(abs($pdblRatio), 2) . "%>"; if($financialTRComment != "") $financialTRComment = $financialTRComment . " " . $rs_profitTurnOver->fields('ProfitDesc'); else $financialTRComment = $financialTRComment . $rs_profitTurnOver->fields('ProfitDesc'); } } elseif($countProfit == 0) { if ($financialTRComment = "") { $a = $arrayProfit[0]['turnover'] - $arrayProfit[1]['turnover']; if ($a == 0) $financialTRComment = common::financialComment("Turnover = Nil"); if ($arrayProfit[1]['turnover'] == 0 ) $arrayProfit[0]['turnover'] = 0; else $pdblRatio = (abs($a) / $arrayProfit[1]['turnover']) * 100; if ($a > 0 ) { $_SESSION['Turnover_Increased'] = $Turnover_Increased = True; if($pdblRatio > 30) $pintCond = 4; elseif($pdblRatio >= 10 && $pdblRatio <= 30) $pintCond = 5; elseif($pdblRatio < 10) $pintCond = 6; } else { $_SESSION['Turnover_Decreased'] = $Turnover_Decreased = True; if ($pdblRatio > 30) $pintCond = 7; elseif($pdblRatio >= 10 && $pdblRatio <= 30 ) $pintCond = 8; elseif($pdblRatio < 10) $pintCond = 9; } $stmt_profitTurnOverNow = $stmt_profitTurnOver.$pintCond; $rs_profitTurnOver = $db_bcorp->Execute($stmt_profitTurnOverNow) or die($db_bcorp->ErrorMSg()); if(!$rs_profitTurnOver->EOF) { $turnOverCond = $rs_profitTurnOver->fields('ProfitCode'); if($pdblRatio > 0) $turnOverYR = number_format($pdblRatio, 2). "%"; else $turnOverYR = "<" . number_format(abs($pdblRatio), 2) . "%>"; $financialTRComment = $financialTRComment.$rs_profitTurnOver->fields('ProfitDesc'); } } } $financialTRInfo = array("trCommnet"=>$financialTRComment, "turnoverYR"=>$turnOverYR, "turnoverCond"=>$turnOverCond); return $financialTRInfo; } function ProfitB4Tax($arrayProfit, $localno, $financialptaxComment = "") { global $db_bcorp; $countProfit = $arrayProfit[sizeof($arrayProfit)-1]['mintYCount'];// IS COUNT THE TOTAL NUMBER OF FINANCIAL YEAR. E.G: mintYCount $a = $arrayProfit[0]['profitb4tax'] - $arrayProfit[1]['profitb4tax']; if($arrayProfit[1]['profitb4tax'] == 0) $arrayProfit[0]['profitb4tax'] = 0; else $pdblRatio = (abs($a) / $arrayProfit[1]['profitb4tax']) * 100; if($arrayProfit[0]['profitb4tax'] > 0 && $arrayProfit[1]['profitb4tax'] > 0) { if($a > 0) { $_SESSION['Profit_Increased'] = $Profit_Increased = True; if($pdblRatio > 30) $pintCond = 1; elseif($pdblRatio >= 10 && $pdblRatio <= 30) $pintCond = 2; elseif($pdblRatio < 10) $pintCond = 3; } else { $_SESSION['Profit_Decreased'] = $Profit_Decreased = True; if($pdblRatio > 30) $pintCond = 4; elseif ($pdblRatio >= 10 && $pdblRatio <= 30) $pintCond = 5; elseif ($pdblRatio < 10) $pintCond = 6; } } elseif($arrayProfit[0]['profitb4tax'] < 0 && $arrayProfit[1]['profitb4tax'] < 0) { if( abs($arrayProfit[0]['profitb4tax']) > abs($arrayProfit[1]['profitb4tax']) ) { $pintCond = 1; $_SESSION['Loss_Increased'] = $Loss_Increased = True; } else { $pintCond = 2; $_SESSION['Loss_Decreased'] = $Loss_Decreased = True; } } else { if ($arrayProfit[0]['profitb4tax'] < $arrayProfit[1]['profitb4tax'] ) { $pintCond = 3; $_SESSION['Loss_Increased'] = $Loss_Increased = True; } else { $pintCond = 4; $_SESSION['Loss_Decreased'] = $Loss_Decreased = True; } } $stmt_profitb4Tax = "Select * from l_financial_analysis where Title='"; if ($arrayProfit[0]['profitb4tax'] > 0 && $arrayProfit[1]['profitb4tax'] > 0) $stmt_profitb4Tax = $stmt_profitb4Tax . "Profit' AND Sequence="; else $stmt_profitb4Tax = $stmt_profitb4Tax . "Loss' AND Sequence="; $stmt_profitb4TaxNow = $stmt_profitb4Tax . $pintCond; $rs_profitb4TaxNow = $db_bcorp->Execute($stmt_profitb4TaxNow) or die($db_bcorp->ErrorMSg()); if(!$rs_profitb4TaxNow->EOF) { $profitB4TaxCond = $rs_profitb4TaxNow->Fields('ProfitCode'); if($countProfit == 3) { $financialYear = common::allLatestFinancialYear($localno); $ProfitB4TaxYR = $financialYear[2]['year']." - ".$financialYear[0]['year']; } else { if($pdblRatio > 0) $ProfitB4TaxYR = number_format($pdblRatio, 2). "%"; else $ProfitB4TaxYR = "<" . number_format(abs($pdblRatio), 2) . "%>"; } if($financialptaxComment != "") $financialptaxComment = $financialptaxComment . " " . $rs_profitb4TaxNow->Fields('ProfitDesc'); else $financialptaxComment = $financialptaxComment . $rs_profitb4TaxNow->Fields('ProfitDesc'); } $profitb4TaxInfo = array("financialptaxComment"=>$financialptaxComment, "profitB4TaxCond"=>$profitB4TaxCond, "ProfitB4TaxYR"=>$ProfitB4TaxYR); return $profitb4TaxInfo; } function financialRatio($localno, $financialType, $Fyear, $FCountYear) { global $db_bcorp; $stmt_fRatio = "SELECT * FROM bc_report_financial_details WHERE LocalNo='".$localno."' ". "AND FinancialType='".$financialType."' ". "AND Year='".$Fyear."' ". "AND YearCount='".$FCountYear."' ". "AND SequenceNo IN (21,22,25,26,27,30,32,37,39) ORDER BY SequenceNo, YearCount"; $rs_fRatio = $db_bcorp->Execute($stmt_fRatio) or die($db_bcorp->ErrorMSg()); if(!$rs_fRatio->EOF) { $pblnRecordFound = True; $i = 0; while(!$rs_fRatio->EOF) { $pdblRatio[$i] = $rs_fRatio->Fields('Amount'); $rs_fRatio->moveNext(); $i = $i + 1; } } return $pdblRatio; } function ProfitReturnOnShareholderFund($arrayProfit, $returnOnShFund, $mstrProfitComment="", $localno) { global $db_bcorp; $countProfit = $arrayProfit[sizeof($arrayProfit)-1]['mintYCount']; $stmt_rOnShFund = "Select * from l_financial_analysis where Title='Return on shareholders'' funds @ return on net assets' and Sequence="; if($arrayProfit[0]['shareholderfund'] > 0) { if($returnOnShFund > 30) $pintCond = 1; elseif($returnOnShFund >= 10 && $returnOnShFund <= 30) $pintCond = 2; elseif($returnOnShFund >= 0 && $returnOnShFund <= 9.99) $pintCond = 3; Else $pintCond = 4; } else { if ($returnOnShFund > 10) $pintCond = 5; elseif($returnOnShFund >= 0 && $returnOnShFund <= 9.99) $pintCond = 3; else $pintCond = 4; } $stmt_rOnShFund = $stmt_rOnShFund.$pintCond; $rs_rOnShFund = $db_bcorp->Execute($stmt_rOnShFund) or die($db_bcorp->ErrorMSg()); if(!$rs_rOnShFund->EOF) { $ShareholderCond = $rs_rOnShFund->Fields('ProfitCode'); if($returnOnShFund > 0) $txtShareholderYR = number_format($returnOnShFund, 2)."%"; else $txtShareholderYR = "<".number_format(abs($returnOnShFund), 2)."%>"; if ($mstrProfitComment != "") $mstrProfitComment = $mstrProfitComment . " " . $rs_rOnShFund->fields('ProfitDesc'); else $mstrProfitComment = $mstrProfitComment . $rs_rOnShFund->fields('ProfitDesc'); } $ProfitReturnOnShareholderFund = array("mstrProfitComment"=>$mstrProfitComment, "ShareholderCond"=>$ShareholderCond, "ShareholderYR"=>$txtShareholderYR); return $ProfitReturnOnShareholderFund; } function ReturnOnNetAsset($arrayProfit, $returnOnNetAsset, $localno) { global $db_bcorp; $countProfit = $arrayProfit[sizeof($arrayProfit)-1]['mintYCount']; $stmt = "Select ProfitCode,left(ProfitDesc,65535) as ProfitDesc from l_financial_analysis where Title='Return on shareholders'' funds @ return on net assets' and Sequence="; if($arrayProfit[0]['profitb4tax'] > 0) { if($returnOnNetAsset > 30) $pintCond = 1; elseif($returnOnNetAsset >= 10 && $returnOnNetAsset <= 30 ) $pintCond = 2; elseif($returnOnNetAsset >= 0 && $returnOnNetAsset <= 9.99 ) $pintCond = 3; else $pintCond = 4; } else { if($returnOnNetAsset > 10) $pintCond = 5; elseif($returnOnNetAsset >= 0 && $returnOnNetAsset <= 9.99) $pintCond = 3; else $pintCond = 4; } $stmtNow = $stmt . $pintCond; $rs = $db_bcorp->Execute($stmtNow) or die($db_bcorp->ErrorMSg()); if(!$rs->EOF) { $NetAssetCond = $rs->fields('ProfitCode'); if($returnOnNetAsset > 0) $NetAssetYR = number_format($returnOnNetAsset, 2)."%"; else $NetAssetYR = "<".number_format(abs($returnOnNetAsset), 2)."%>"; //$mstrProfitComment = $mstrProfitComment . $rs->fields('ProfitDesc') The comment is omitted due to duplicate sentence as what generate by Return on Shareholder fund - Claimed by Francis } $ReturnOnNetAsset = array("NetAssetCond"=>$NetAssetCond, "NetAssetYR"=>$NetAssetYR); return $ReturnOnNetAsset; } function overallFinancialConCP($localno) { global $db_bcorp; $stmt_financialComCp = "SELECT FinancialCondition, FinancialComment FROM bc_cpo_financial WHERE LocalNo='".$localno."' AND FinancialYear='".common::financialCPLatestYear($localno)."'"; if (!$rs_financialComCp = $db_bcorp->Execute($stmt_financialComCp)) { trigger_error("Error: Execute SQL: $stmt_financialComCp. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if(!$rs_financialComCp->EOF) { $overallFinancial['comment'] = $rs_financialComCp->Fields('FinancialComment'); $overallFinancial['cond'] = $rs_financialComCp->Fields('FinancialCondition'); } return $overallFinancial; } function CapitalStock($pdblStock, $mstrCapitalComment="") { global $db_bcorp; $stmt = "Select * from l_financial_analysis where Title='Stocks' and Type='W' and Sequence="; if ($pdblStock == 0) $pintCond = 4; elseif ($pdblStock < 55) $pintCond = 1; elseif ($pdblStock >= 55 && $pdblStock <= 65 ) $pintCond = 2; elseif ($pdblStock > 65 ) $pintCond = 3; $stmt = $stmt . $pintCond; $rs_cStock = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs_cStock->EOF) { $txtStock = $rs_cStock->Fields('ProfitCode'); $txtStockDay = round($pdblStock) . " Days"; if ($mstrCapitalComment != "") $mstrCapitalComment = $mstrCapitalComment . " " . $rs_cStock->Fields('ProfitDesc'); else $mstrCapitalComment = $mstrCapitalComment . $rs_cStock->Fields('ProfitDesc'); } $capitalStock['cond'] = $txtStock; $capitalStock['day'] = $txtStockDay; $capitalStock['comment'] = $mstrCapitalComment; return $capitalStock; } function CapitalDebtor($pdblDebtor, $mstrCapitalComment="") { global $db_bcorp; $stmt = "Select * from l_financial_analysis where Title='Debtors' and Type='W' and Sequence="; if($pdblDebtor < 55 ) $pintCond = 1; elseif($pdblDebtor >= 55 && $pdblDebtor <= 65 ) $pintCond = 2; elseif($pdblDebtor > 65 && $pdblDebtor <= 85 ) $pintCond = 3; else $pintCond = 4; $stmt = $stmt . $pintCond; $rs_cDebtor = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs_cDebtor->EOF) { $txtDebtor = $rs_cDebtor->Fields('ProfitCode'); $txtDebtorDay = Round($pdblDebtor) . " Days"; if($mstrCapitalComment != "") $mstrCapitalComment = $mstrCapitalComment . " " . $rs_cDebtor->Fields('ProfitDesc'); else $mstrCapitalComment = $mstrCapitalComment . $rs_cDebtor->Fields('ProfitDesc'); } $capitalDebtor['cond'] = $txtDebtor; $capitalDebtor['day'] = $txtDebtorDay; $capitalDebtor['comment'] = $mstrCapitalComment; return $capitalDebtor; } function CapitalCreditor($pdblCreditor, $mstrCapitalComment="") { global $db_bcorp; $stmt = "Select * from l_financial_analysis where Title='Creditors' and Type='W' and Sequence="; if($pdblCreditor <= 60) $pintCond = 1; else $pintCond = 2; $stmt = $stmt . $pintCond; $rs_cCreditor = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs_cCreditor->EOF) { $txtCreditor = $rs_cCreditor->Fields('ProfitCode'); $txtCreditorDay = round($pdblCreditor) . " Days"; if ($mstrCapitalComment != "" ) $mstrCapitalComment = $mstrCapitalComment . " " . $rs_cCreditor->Fields('ProfitDesc'); else $mstrCapitalComment = $mstrCapitalComment . $rs_cCreditor->Fields('ProfitDesc'); } $capitalCreditor['cond'] = $txtCreditor; $capitalCreditor['day'] = $txtCreditorDay; $capitalCreditor['comment'] = $mstrCapitalComment; return $capitalCreditor; } function LiquidityLiquid($pdblLiquid, $mstrLiquidComment="") { global $db_bcorp; $stmt = "Select ProfitCode,left(ProfitDesc,65535) as ProfitDesc from l_financial_analysis where Title='Liquid Ratio' and Type='L' and Sequence="; if ($pdblLiquid >= 1) $pintCond = 1; elseif($pdblLiquid >= 0.8 && $pdblLiquid <= 0.9999 ) $pintCond = 2; elseif ($pdblLiquid <= 0.8) $pintCond = 3; $stmt = $stmt . $pintCond; $rs_LiquidityLiquid = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs_LiquidityLiquid->EOF) { $txtLiquid = $rs_LiquidityLiquid->Fields('ProfitCode'); if ($pdblLiquid < 0) $txtLiquidDay = "<" . number_format(abs($pdblLiquid), 2) . " Times" . ">"; else $txtLiquidDay = number_format($pdblLiquid, 2) . " Times"; if ($mstrLiquidComment != "") $mstrLiquidComment = $mstrLiquidComment . " " . $rs_LiquidityLiquid->Fields('ProfitDesc'); else $mstrLiquidComment = $mstrLiquidComment . $rs_LiquidityLiquid->Fields('ProfitDesc'); } $LiquidityLiquid['cond'] = $txtLiquid; $LiquidityLiquid['day'] = $txtLiquidDay; $LiquidityLiquid['comment'] = $mstrLiquidComment; return $LiquidityLiquid; } function LiquidityCurrent($pdblCurrent, $mstrLiquidComment="") { global $db_bcorp; $stmt = "Select ProfitCode,left(ProfitDesc,65535) as ProfitDesc from l_financial_analysis where Title='Current ratio' and Type='L' and Sequence="; if ($pdblCurrent >= 2) $pintCond = 1; else $pintCond = 2; $stmt = $stmt . $pintCond; $rs_LiquidityCurrent = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs_LiquidityCurrent->EOF) { $txtCurrent = $rs_LiquidityCurrent->Fields('ProfitCode'); if ($pdblCurrent < 0 ) $txtCurrentDay = "<" . number_format(abs($pdblCurrent), 2) . " Times" . ">"; else $txtCurrentDay = number_format($pdblCurrent, 2) . " Times"; //Check value not equal to x bcoz query return "x" when it is null if ($rs_LiquidityCurrent->Fields('ProfitDesc') != "x") $mstrLiquidComment = $mstrLiquidComment . $rs_LiquidityCurrent->Fields('ProfitDesc'); } $LiquidityCurrent['cond'] = $txtCurrent; $LiquidityCurrent['day'] = $txtCurrentDay; $LiquidityCurrent['comment'] = $mstrLiquidComment; return $LiquidityCurrent; } function SolvencyInterestCover($pdblInterest, $mstrSolvencyComment="") { global $db_bcorp; $stmt = "Select * from l_financial_analysis where Title='interest cover (STANDARD IS 10, THE HIGHER THE BETTER)' and Type='S' and Sequence="; if($pdblInterest > 10 ) $pintCond = 1; elseif($pdblInterest >= 3 && $pdblInterest <= 10) $pintCond = 2; elseif ($pdblInterest >= 0.01 && $pdblInterest <= 2.99) $pintCond = 3; elseif ($pdblInterest == 0) $pintCond = 4; else $pintCond = 5; $stmt = $stmt . $pintCond; $rs_SolvencyInterestCover = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs_SolvencyInterestCover->EOF) { $txtInterestCover = $rs_SolvencyInterestCover->Fields('ProfitCode'); if ($pdblInterest < 0 ) $txtInterestCoverDay = "<" . number_format(abs($pdblInterest), 2) . " Times" . ">"; else $txtInterestCoverDay = number_format($pdblInterest, 2) . " Times"; if ($mstrSolvencyComment!= "") $mstrSolvencyComment = $mstrSolvencyComment . " " . $rs_SolvencyInterestCover->Fields('ProfitDesc'); else $mstrSolvencyComment = $mstrSolvencyComment . $rs_SolvencyInterestCover->Fields('ProfitDesc'); } $SolvencyInterestCover['cond'] = $txtInterestCover; $SolvencyInterestCover['day'] = $txtInterestCoverDay; $SolvencyInterestCover['comment'] = $mstrSolvencyComment; return $SolvencyInterestCover; } function SolvencyGearing($pdblGearing, $mstrSolvencyComment="") { global $db_bcorp; $stmt = "Select * from l_financial_analysis where Title='Gearing' and Type='S' and Sequence="; if($pdblGearing >= 1) $pintCond = 1; elseif($pdblGearing >= 0.8 && $pdblGearing <= 1) $pintCond = 2; elseif($pdblGearing >= 0.01 && $pdblGearing <= 0.79) $pintCond = 3; elseif($pdblGearing >= 0) $pintCond = 4; else $pintCond = 5; $stmt = $stmt . $pintCond; $rs_SolvencyGearing = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs_SolvencyGearing->EOF) { $txtGearing = $rs_SolvencyGearing->Fields('ProfitCode'); if($pdblGearing < 0 ) $txtGearingDay = "<" . number_format(abs($pdblGearing), 2) . " Times" . ">"; else $txtGearingDay = number_format($pdblGearing, 2) . " Times"; if($mstrSolvencyComment != "" ) $mstrSolvencyComment = $mstrSolvencyComment . " " . $rs_SolvencyGearing->Fields('ProfitDesc'); else $mstrSolvencyComment = $mstrSolvencyComment . $rs_SolvencyGearing->Fields('ProfitDesc'); } $SolvencyGearing['cond'] = $txtGearing; $SolvencyGearing['day'] = $txtGearingDay; $SolvencyGearing['comment'] = $mstrSolvencyComment; return $SolvencyGearing; } function Assessment($mdblLiquid, $mdblTimesInterestEarned, $mdblGearing) { //profitability if($_SESSION['Turnover_Increased'] && $_SESSION['Profit_Increased']) $pintCond = 1; elseif($_SESSION['Turnover_Increased'] && $_SESSION['Loss_Decreased']) $pintCond = 2; elseif($_SESSION['Turnover_Increased'] && $_SESSION['Profit_Decreased']) $pintCond = 3; elseif($_SESSION['Turnover_Increased'] && $_SESSION['Loss_Increased']) $pintCond = 4; elseif($_SESSION['Turnover_Decreased'] && $_SESSION['Profit_Decreased']) $pintCond = 5; elseif($_SESSION['Turnover_Decreased'] && $_SESSION['Loss_Increased']) $pintCond = 6; elseif($_SESSION['Turnover_Decreased'] && $_SESSION['Profit_Increased']) $pintCond = 7; elseif($_SESSION['Turnover_Decreased'] && $_SESSION['Loss_Decreased']) $pintCond = 8; elseif($_SESSION['Turnover_Erratic'] && $_SESSION['Profit_Increased']) $pintCond = 9; elseif($_SESSION['Turnover_Erratic'] && $_SESSION['Profit_Decreased']) $pintCond = 10; elseif($_SESSION['Turnover_Erratic'] && $_SESSION['Loss_Increased']) $pintCond = 11; elseif($_SESSION['Turnover_Erratic'] && $_SESSION['Loss_Decreased']) $pintCond = 12; $pstrAssessment = common::AssessmentComment("Turnover & Profit", $pintCond); //Liquidity if($mdblLiquid >= 1) $pintCond = 1; elseif($mdblLiquid >= 0.8 && $mdblLiquid <= 0.99) $pintCond = 2; elseif($mdblLiquid <= 0.8) $pintCond = 3; $pstrAssessmentLiquid = common::AssessmentComment("Liquidity", $pintCond, $pstrAssessment); //Interest Cover if($mdblTimesInterestEarned > 10) $pintCond = 1; elseif($mdblTimesInterestEarned >= 3 && $mdblTimesInterestEarned <= 10) $pintCond = 2; elseif($mdblTimesInterestEarned >= 0.01 && $mdblTimesInterestEarned <= 2.99) $pintCond = 3; elseif($mdblTimesInterestEarned == 0) $pintCond = 4; elseif($mdblTimesInterestEarned <= 0) $pintCond = 5; $pstrAssessmentInterest = common::AssessmentComment("Interest Cover", $pintCond, $pstrAssessmentLiquid); //Gearing if($mdblGearing > 1) $pintCond = 1; elseif($mdblGearing >= 0.8 && $mdblGearing <= 1) $pintCond = 2; elseif($mdblGearing >= 0.01 && $mdblGearing <= 0.79) $pintCond = 3; elseif($mdblGearing == 0) $pintCond = 4; elseif($mdblGearing <= 0) $pintCond = 5; $pstrAssessmentGearing = common::AssessmentComment("Gearing", $pintCond, $pstrAssessmentInterest); if($pstrAssessment != "") $txtAssessment = $pstrAssessmentGearing; return $txtAssessment; } function AssessmentComment($code, $pintCond, $pstrAssessment="") { global $db_bcorp; $stmt = "Select * from l_financial_analysis where Title='".$code."' AND Sequence='".$pintCond."'"; $rs_AssessmentComment = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs_AssessmentComment->EOF) { if ($pstrAssessment != "" ) $pstrAssessment = $pstrAssessment . " " . $rs_AssessmentComment->Fields('ProfitDesc'); else $pstrAssessment = $pstrAssessment . $rs_AssessmentComment->Fields('ProfitDesc'); } unset($_SESSION['Turnover_Increased']); unset($_SESSION['Turnover_Decreased']); unset($_SESSION['Turnover_Erratic']); unset($_SESSION['Profit_Increased']); unset($_SESSION['Profit_Decreased']); unset($_SESSION['Loss_Increased']); unset($_SESSION['Loss_Decreased']); return $pstrAssessment; } function financialYear($localno) { global $db_bcorp; $stmt = "SELECT Year, YearCount FROM financial_details WHERE LocalNo = '".$localno ."' ". "GROUP BY Year, YearCount HAVING ABS(SUM(Amount)) > 0 order by Year desc limit 1"; $rs_financialYear = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs_financialYear->EOF) { $FinanceYear = $rs_financialYear->Fields('Year'); } elseif($rs_financialYear->EOF) { $stmt_sfr = "SELECT * FROM bc_cpo_pl WHERE LocalNo = '" .$localno. "' ORDER BY FinancialYear DESC"; if(!$rs_sfr = $db_bcorp->Execute($stmt_sfr)) { trigger_error("Error: Execute SQL: $stmt_sfr. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $sfr_date = $rs_sfr->fields['FinancialYear']; if($rs_sfr->fields['FinancialYear'] == "0000-00-00" || $rs_sfr->fields['FinancialYear'] == "") $isfinanceYearZero = 1; else $FinanceYear = date('Y', strtotime($sfr_date)); if($rs_sfr->EOF || $isfinanceYearZero == 1) { $stmt_fullfr = "SELECT * FROM bc_report_financial WHERE LocalNo = '" .$localno. "' ORDER BY Date DESC"; if(!$rs_fullfr = $db_bcorp->Execute($stmt_fullfr)) { trigger_error("Error: Execute SQL: $stmt_fullfr. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $fullfr_date = $rs_fullfr->fields['Date']; if($rs_fullfr->fields['Date'] == "0000-00-00" || $rs_fullfr->fields['Date'] == "") $isfinanceYearZero = 2; else $FinanceYear = date('Y', strtotime($fullfr_date)); } } return $FinanceYear; } //change by tiffany law function financialYear_lastupdate($localno) { global $db_online; $currentYear = date('Y', time()); $stmt_fullfr = "SELECT * FROM bc_report_financial WHERE LocalNo = '" .$localno. "' ORDER BY Date DESC"; if(!$rs_fullfr = $db_online->Execute($stmt_fullfr)) { trigger_error("Error: Execute SQL: $stmt_fullfr. ** Error message: " . $db_online->ErrorMsg() , E_USER_ERROR); exit(); } $fullfr_date = $rs_fullfr->fields['Date']; if($rs_fullfr->fields['Date'] == "0000-00-00" || $rs_fullfr->fields['Date'] == "") { $FinanceYear_1 = 0; } else { $FinanceYear_1 = strtotime($fullfr_date); $FinanceYearOnly_1 = date('Y', strtotime($fullfr_date)); $FinanceDate_1 = date('d M Y', strtotime($fullfr_date)); } //if($rs_fullfr->EOF || $isfinanceYearZero == 1) //{ $stmt_sfr = "SELECT * FROM bc_cpo_pl WHERE LocalNo = '" .$localno. "' ORDER BY FinancialYear DESC"; if(!$rs_sfr = $db_online->Execute($stmt_sfr)) { trigger_error("Error: Execute SQL: $stmt_sfr. ** Error message: " . $db_online->ErrorMsg() , E_USER_ERROR); exit(); } $sfr_date = $rs_sfr->fields['FinancialYear']; if($rs_sfr->fields['FinancialYear'] == "0000-00-00" || $rs_sfr->fields['FinancialYear'] == "") { $FinanceYear_2 = 0; } else { $FinanceYear_2 = strtotime($sfr_date); $FinanceYearOnly_2 = date('Y', strtotime($sfr_date)); $FinanceDate_2 = date('d M Y', strtotime($sfr_date)); } //} if($FinanceYear_1 > $FinanceYear_2) { if($currentYear - $FinanceYearOnly_1 < 5) $FinanceYear = $FinanceDate_1; elseif($currentYear - $FinanceYearOnly_1 > 4) $FinanceYear = ""; } else { if($currentYear - $FinanceYearOnly_2 < 5) $FinanceYear = $FinanceDate_2; elseif($currentYear - $FinanceYearOnly_2 > 4) $FinanceYear = ""; } return $FinanceYear; } function financialCondition4ES($localno, $pintFYear) { if($pintFYear > 0) { $pstrRatio = common::financialRatio4ES($localno, "FRG2", $pintFYear); $pstrRatioCount = sizeof($pstrRatio);//COUNT THE TOTAL SIZES if($pstrRatioCount == 0) { $pstrRatio = common::financialRatio4ES($localno, "FRC2", $pintFYear); $pstrRatioCount = sizeof($pstrRatio);//COUNT THE TOTAL SIZES } if($pstrRatioCount != 0) { $pdblShldFund = $pstrRatio[0]; if($pdblShldFund >= 0) { $pdblReturnOnShldFund = $pstrRatio[9]; $pdblLiquidRatio = $pstrRatio[1]; $pdblGearingRatio = $pstrRatio[6]; $pdblInterestCover = $pstrRatio[7]; $pstrCondition = common::chkRangeCondtion($pdblReturnOnShldFund, $pdblLiquidRatio, $pdblInterestCover, $pdblGearingRatio); } else $pstrCondition = "POOR"; } else $pstrCondition = "N/A"; } else $pstrCondition = "N/A"; $financialCondition4ES = $pstrCondition; return $financialCondition4ES; } function financialRatio4ES($localno, $financialType, $pintFYear) { global $db_bcorp; $stmt_fRatio = "SELECT * FROM bc_report_financial_details WHERE LocalNo='".$localno."' ". "AND FinancialType='".$financialType."' ". "AND Year='".$pintFYear."' ". "AND SequenceNo IN (15,21,22,25,26,27,30,32,37,39) ORDER BY SequenceNo"; $rs_fRatio = $db_bcorp->Execute($stmt_fRatio) or die($db_bcorp->ErrorMSg()); if(!$rs_fRatio->EOF) { $pblnRecordFound = True; $i = 0; while(!$rs_fRatio->EOF) { if(i <=10) $pdblRatio[$i] = $rs_fRatio->Fields('Amount'); $rs_fRatio->moveNext(); $i = $i + 1; } } return $pdblRatio; } function chkRangeCondtion($pdblReturnOnShldFund = 0, $pdblLiquidRatio = 0, $pdblInterestCover = 0, $pdblGearingRatio = 0) { global $db_bcorp; $stmt = "SELECT * FROM l_financial_condition_range ORDER BY Sequence"; $prs = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); While($rsa = $prs->FetchRow()) { if($rsa['Condition'] == "POOR") { if($pdblReturnOnShldFund < $rsa['ReturnOnShldFund'] || $pdblReturnOnShldFund > $rsa['ReturnOnShldFund']) $pReturnOnShldFundCond = "POOR"; if($pdblLiquidRatio < $rsa['LiquidRatio']) $pLiquidCond = "POOR"; if($pdblInterestCover < $rsa['InterestCover'] && $pdblInterestCover != 0) $pInterestCond = "POOR"; //'According to Table from Francis if($pdblGearingRatio > $rsa['GearingRatio'] || $pdblGearingRatio < $rsa['GearingRatio']) $pGearingCond = "POOR"; } elseif($rsa['Condition'] == "AVERAGE") { if($pdblReturnOnShldFund >= $rsa['ReturnOnShldFund'] && $pdblReturnOnShldFund <= $rsa['ReturnOnShldFund2']) $pReturnOnShldFundCond = "AVG"; if($pdblLiquidRatio >= $rsa['LiquidRatio'] && $pdblLiquidRatio <= $rsa['LiquidRatio2']) $pLiquidCond = "AVG"; if($pdblInterestCover >= $rsa['InterestCover'] && $pdblInterestCover <= $rsa['InterestCover2']) $pInterestCond = "AVG"; if($pdblGearingRatio >= $rsa['GearingRatio'] && $pdblGearingRatio <= $rsa['GearingRatio2']) $pGearingCond = "AVG"; } elseif($rsa['Condition'] == "GOOD") { if($pdblReturnOnShldFund > $rsa['ReturnOnShldFund']) $pReturnOnShldFundCond = "GOOD"; if($pdblLiquidRatio > $rsa['LiquidRatio']) $pLiquidCond = "GOOD"; if($pdblInterestCover > $rsa['InterestCover'] || $pdblInterestCover == 0) $pInterestCond = "GOOD"; //'According Francis's table if($pdblGearingRatio < $rsa['GearingRatio']) $pGearingCond = "GOOD"; } } $stmt_1 = "Select Condition1 from l_financial_condition where ReturnOnShldFund='".$pReturnOnShldFundCond."' ". "and LiquidRatio='".$pLiquidCond."' and GearingRatio='".$pGearingCond."' ". "and InterestCover='".$pInterestCond."'"; $prs_1 = $db_bcorp->Execute($stmt_1) or die($db_bcorp->ErrorMSg()); if(!$prs_1->EOF) $pstrCondition = $prs_1->Fields('Condition1'); else $pstrCondition = "N/A"; $chkRangeCondtion = $pstrCondition; return $chkRangeCondtion; } //--> END USED FOR FINANCIAL COMMENT PART -- // //CHECK UNUSED TOKEN IN TABLE FIELDS function checkUnusedToken($string) { if($string == "N/A") return 1; elseif($string == "-") return 1; elseif($string == "") return 1; elseif($string == "--") return 1; elseif($string == "\N") return 1; else return 0; } //CHANGE NEW IC NO TO DATE 15/06/1952 function splitIC2Date($string="") { if($string !="") $birthDate = substr($string, 4, 2)."/".substr($string, 2, 2)."/19".substr($string, 0, 2); else $birthDate = "N/A"; return $birthDate; } //FIND DIRECTOR QUALIFICATION function Qualification($pstrIcNo="", $pstrNewIc="") { global $db_bcorp; $mstrSql = "SELECT * FROM bc_individual_personal WHERE ICNo IN ("; if($pstrIcNo != "" && $pstrNewIc != "") $mstrSql = $mstrSql ."'".$pstrIcNo."'". "," ."'".$pstrNewIc."'". ")"; elseif($pstrIcNo != "") $mstrSql = $mstrSql ."'".$pstrIcNo."'". ")"; elseif($pstrNewIc != "") $mstrSql = $mstrSql ."'".$pstrNewIc."'". ")"; if($pstrIcNo != "" && $pstrNewIc != "") { $qrs = $db_bcorp->Execute($mstrSql) or die($db_bcorp->ErrorMSg()); if(!$qrs->EOF) { if($qrs->Fields('Qualification') != "") $ghQualification = 1; else $ghQualification = 0; $txtQualification = $qrs->Fields('Qualification'); $qualificationId = $qrs->Fields('ID'); } else { $ghQualification = 0; } } else { $ghQualification = 0; } $qualificationArray = array("qualificationExist"=>$ghQualification, "QualificationText"=>$txtQualification, "qualificationId"=>$qualificationId); return $qualificationArray; } //FIND DIRECTOR WORK EXPRIENCE function WorkExperience($pstrID) { global $db_bcorp; $stmt = "SELECT * FROM bc_individual_personal_experience WHERE ID='".$pstrID."' order by SequenceNo"; $workrs = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$workrs->EOF) { $txtWorkExperience = 1; while($rsa = $workrs->FetchRow()) { if($pstrExperience != "" ) { $pstrExperience = $pstrExperience . " "; $pstrExperience = $pstrExperience . $rsa['Experience']; } else $pstrExperience = $rsa['Experience']; } } else $txtWorkExperience = 0; $WorkExperienceArray = array("workExperienceExist"=>$txtWorkExperience, "WorkExperience"=>$pstrExperience); return $WorkExperienceArray; } //FIND DIRECTOR OTHERES INFO function OtherInfo($pstrID) { global $db_bcorp; $stmt = "SELECT * FROM bc_individual_personal_other where ID='" . $pstrID . "' ORDER BY SequenceNo"; $otherrs = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$otherrs->EOF) { $ghOtherInfo = 1; while($rsa = $otherrs->FetchRow()) { if($pstrInfo != "") { $pstrInfo = $pstrInfo . " "; $pstrInfo = $pstrInfo . $rsa['Description']; } else { $pstrInfo = $rsa['Description']; } } } else $ghOtherInfo = 0; $otherInfoArray = array("otherInfoExist"=>$ghOtherInfo, "pstrInfo"=>$pstrInfo); return $otherInfoArray; } //CALCULATE NUMBER OF DAY IN MONTHLY function is1month($time) { $m = date('m', time()); $y = date('Y', time()); $no_of_days = date('t',mktime(0,0,0,$m,1,$y)); $is1month = ($no_of_days * 60 * 60 * 24) + $time; return $is1month; } //CHECK CURRENT INVESTIGATION LATEST FINANCIAL function Investigation_CheckFinancial($localno) { global $db_bcorp; $stmt = "SELECT Year FROM financial WHERE LocalNo='".$localno."' ORDER BY Year DESC"; $rs = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs->EOF) { if(date('Y') - $rs->Fields('Year') > 2) return common::Summary_Check_BC_CPO_PL($localno); else return 1; } else return common::Summary_Check_BC_CPO_PL($localno); } function Summary_Check_BC_CPO_PL($localno) { global $db_bcorp; $stmt = "SELECT * FROM bc_cpo_pl WHERE LocalNo = '".$localno."' ORDER BY FinancialYear DESC"; $rs = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs->EOF) { if($rs->Fields('FinancialYear') == "" || $rs->Fields('FinancialYear') == "0000-00-00") $yearbcCPOPL = 0; else $yearbcCPOPL = date('Y', strtotime($rs->Fields('FinancialYear'))); if(date('Y') - $yearbcCPOPL > 2) return common::Summary_Check_CPO_PL($localno); else return 1; } else return common::Summary_Check_CPO_PL($localno); } function Summary_Check_CPO_PL($localno) { global $db_bcorp; $stmt = "SELECT * FROM cpo_pl WHERE LocalNo = '".$localno."' ORDER BY FinancialYear DESC"; $rs = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if(!$rs->EOF) { if($rs->Fields('FinancialYear') == "" || $rs->Fields('FinancialYear') == "0000-00-00") $yearbcCPOPL = 0; else $yearbcCPOPL = date('Y', strtotime($rs->Fields('FinancialYear'))); if(date('Y') - $yearbcCPOPL > 2) return 0; else return 1; } else return 0; } function petitionreffullname($string) { global $db_bcorp; $stmt = "SELECT l_other_description FROM l_other WHERE l_other_code = '".$string."' AND l_other_type='NEWSPAPER'"; $rs = $db_bcorp->Execute($stmt) or die($db_bcorp->ErrorMSg()); if($string != "" && !$rs->EOF) return $rs->fields("l_other_description"); else return ""; } function searchSampleReport($string)//SEARCH WHETHER REPORT SAMPLE WAS PROVIDED ? { $latest = array(); if ($handle = opendir('sampleReport/')) { while (false !== ($files = readdir($handle))) { $files_new = str_replace(strstr($files, '.'), "", $files); if($files_new == $string) { $is_report_exist = 1; break; } } if($is_report_exist == 1) return "Sample"; else return "N/A"; closedir($handle); } } function creditrating($localno)//CHECK WHETHER LOCAL NO CONTAINING CREDIT RATING { $stmt_company_rating = "SELECT CreditRating FROM bc_company_rating WHERE LocalNo='".$localno."'"; $rs_company_rating = $db_bcorp->Execute($stmt_company_rating)or die($db_bcorp -> ErrorMsg()); if(!$rs_company_rating->EOF) { if($rs_company_rating->fields("CreditRating") != "") return 1; else return 0; } else return 0; } function sentoutdate($localno)//CHECK WHETHER LOCAL NO CONTAINING sent out date { $stmt_viewcover = "SELECT SentDate FROM bc_company_cover WHERE LocalNo='".$localno."' ORDER BY SentDate DESC"; if(!$rs_viewcover = $db_bcorp->Execute($stmt_viewcover)) { echo $db_bcorp->ErrorMsg(); exit(); } if(!$rs_viewcover->EOF) { if($rs_viewcover->Fields("SentDate") != "" && $rs_viewcover->Fields("SentDate") != "0000-00-00") return 1; elseif($rs_viewcover->Fields("SentDate") == "" || $rs_viewcover->Fields("SentDate") == "0000-00-00") return 0; } else return 0; } function isupdatereport($report)//THIS FUNCTION REMOVE DUE TO, ADMIN CAN CONFIGURE IT THROUGH ADMIN SITE. { if($report == "BOR") return 1; elseif($report == "BORNA") return 1; elseif($report == "BORNI") return 1; //elseif($report == "CHK") //return 1; elseif($report == "COM") return 1; elseif($report == "CTC") return 1; elseif($report == "DOC") return 1; elseif($report == "EPC") return 1; elseif($report == "LMC") return 1; elseif($report == "OAA") return 1; elseif($report == "OA-N") return 1; elseif($report == "SCC") return 1; elseif($report == "SFF") return 1; elseif($report == "SFR") return 1; elseif($report == "SIC") return 1; elseif($report == "SS") return 1; elseif($report == "OAN") return 1; } function isind_company_business($string, $new_icno="", $name="", $localno) { global $db_bcorp; $array_data = array(); if($string == 'I') { if($new_icno != "") { $stmt_ind = "SELECT * FROM individual WHERE ICNo='".$new_icno."' OR NewICNo='".$new_icno."'"; if(!$rs_ind = $db_bcorp->Execute($stmt_ind)) { trigger_error("Error: Execute SQL: $stmt_ind. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if(!$rs_ind->EOF) { array_push($array_data, array("Name"=>$rs_ind->fields("Name"), "ICppNo"=>$rs_ind->fields("ICNo"), "NewICNo"=>$rs_ind->fields("NewICNo"), "EnglishName"=>$rs_ind->fields("EnglishName"), "Alias1"=>$rs_ind->fields("Alias1"), "Alias2"=>$rs_ind->fields("Alias2"), "Title"=>$rs_ind->fields("Title"), "Street"=>$rs_ind->fields("Street"), "PostCode"=>$rs_ind->fields("PostCode"), "Town"=>$rs_ind->fields("Town"), "State"=>$rs_ind->fields("State"), "Country"=>$rs_ind->fields("Country"), "BirthDate"=>$rs_ind->fields("BirthDate"), "Nationality"=>$rs_ind->fields("Nationality"))); } } if($new_icno == "" || $rs_ind->RecordCount() == 0) { $stmt_ind_entityname = "SELECT * FROM individual_entity_name WHERE Name='".$name."'"; if (!$rs_ind_entityname = $db_bcorp->Execute($stmt_ind_entityname)) { trigger_error("Error: Execute SQL: $stmt_ind_entityname. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if(!$rs_ind_entityname->EOF) { array_push($array_data, array("Name"=>$rs_ind_entityname->fields("Name"), "ICppNo"=>$rs_ind_entityname->fields("ICNo"), "NewICNo"=>$rs_ind_entityname->fields("NewICNo"), "EnglishName"=>$rs_ind_entityname->fields("EnglishName"), "Alias1"=>$rs_ind_entityname->fields("Alias1"), "Alias2"=>$rs_ind_entityname->fields("Alias2"), "Title"=>$rs_ind_entityname->fields("Title"), "Street"=>$rs_ind_entityname->fields("Street"), "PostCode"=>$rs_ind_entityname->fields("PostCode"), "Town"=>$rs_ind_entityname->fields("Town"), "State"=>$rs_ind_entityname->fields("State"), "Country"=>$rs_ind_entityname->fields("Country"), "BirthDate"=>$rs_ind_entityname->fields("BirthDate"), "Nationality"=>$rs_ind_entityname->fields("Nationality"))); } } } elseif($string == 'C' || $string == 'B') { $stmt_bc_entity = "SELECT * FROM bc_entity WHERE bc_entity_localNo='".$localno."'"; if (!$rs_bc_entity = $db_bcorp->Execute($stmt_bc_entity)) { trigger_error("Error: Execute SQL: $stmt_bc_entity. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if(!$rs_bc_entity->EOF) { array_push($array_data, array("bc_entity_incoporatedDate"=>$rs_bc_entity->fields("bc_entity_incoporatedDate"), "Street"=>$rs_bc_entity->fields("bc_entity_businessStreet"), "PostCode"=>$rs_bc_entity->fields("bc_entity_businessPostCode"), "Town"=>$rs_bc_entity->fields("bc_entity_businessTown"), "State"=>$rs_bc_entity->fields("bc_entity_businessState"), "Country"=>$rs_bc_entity->fields("bc_entity_businessCountry"), "BirthDate"=>"", "Nationality"=>"")); } else { $stmt_ind_entityname = "SELECT * FROM individual_entity_name WHERE Name='".$name."'"; if (!$rs_ind_entityname = $db_bcorp->Execute($stmt_ind_entityname)) { trigger_error("Error: Execute SQL: $stmt_ind_entityname. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if(!$rs_ind_entityname->EOF) { array_push($array_data, array("Name"=>$rs_ind_entityname->fields("Name"), "ICppNo"=>$rs_ind_entityname->fields("ICNo"), "NewICNo"=>$rs_ind_entityname->fields("NewICNo"), "EnglishName"=>$rs_ind_entityname->fields("EnglishName"), "Alias1"=>$rs_ind_entityname->fields("Alias1"), "Alias2"=>$rs_ind_entityname->fields("Alias2"), "Title"=>$rs_ind_entityname->fields("Title"), "Street"=>$rs_ind_entityname->fields("Street"), "PostCode"=>$rs_ind_entityname->fields("PostCode"), "Town"=>$rs_ind_entityname->fields("Town"), "State"=>$rs_ind_entityname->fields("State"), "Country"=>$rs_ind_entityname->fields("Country"), "BirthDate"=>$rs_ind_entityname->fields("BirthDate"), "Nationality"=>$rs_ind_entityname->fields("Nationality"))); } } } //print_r($array_data); return $array_data; } //GET ALL DEFENDANT NAME, ICPPREGNO FOR THIS LOCAL NO function suit_defendantName($id) { global $db_bcorp; $data_defendantName = array(); $stmt_suit_defendantName = "SELECT * FROM suit_defendant WHERE ID='".$id."'"; if (!$rs_suit_defendantName = $db_bcorp->Execute($stmt_suit_defendantName)) { trigger_error("Error: Execute SQL: $stmt_suit_defendantName. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } while($rsa_suit_defendantName = $rs_suit_defendantName->FetchRow()) { if($rsa_suit_defendantName['Street'] != "") $defendantAddress = htmlspecialchars($rsa_suit_defendantName['Street'].common::lookupPostcodeTownStateCountry($rsa_suit_defendantName['PostCode'], $rsa_suit_defendantName['Town'], $rsa_suit_defendantName['State'], $rsa_suit_defendantName['Country'])); else $defendantAddress = ""; if($rsa_suit_defendantName['NewICNo'] != "") $NewICNo = " /".$rsa_suit_defendantName['NewICNo']; else $NewICNo = ""; if($rsa_suit_defendantName['ICPPRegNo'] != "") $ICPPRegNo = " (".$rsa_suit_defendantName['ICPPRegNo'].$NewICNo.")"; else { if($rsa_suit_defendantName['NewICNo'] != "") $ICPPRegNo = " (".$NewICNo.")"; else $ICPPRegNo = ""; } $defendantName = $rsa_suit_defendantName['Name'].$ICPPRegNo."\r\n".$defendantAddress; array_push($data_defendantName, array("Name"=>$defendantName)); } return $data_defendantName; } //STORE THE REMAINING SHAREDHOLDERS IN LAST LINE function storeinlastline($name, $record, $SequenceNo) { $data = array(); if(trim($name) == "REMAINING SHAREHOLDERS") { $data = array("Address"=>$record['Address'], "LocalNo"=>$record['LocalNo'],"ICppNo"=>$record['ICppNo'], "ShareHolding"=>$record['ShareHolding'], "Remark"=>$record['Remark'], "PRINTDATETIME"=>$record['PRINTDATETIME'], "Name"=>$record['Name'], "SequenceNo"=>$SequenceNo + 1); return $data; } } //TO CHECK WHETHER THE FINANCIAL COMMENT WAS NIL? function isfinancial_comment_nil($financialTRYR="", $financialPTaxYR="", $ReturnOnShareholderFundYR="", $ReturnOnNetAssetYR="", $CapitalStockDay="", $CapitalDebtorDay="", $CapitalCreditorDay="", $LiquidityLiquidDay="", $LiquidityCurrentDay="", $SolvencyInterestCoverDay="", $SolvencyGearingDay="") { if(empty($financialTRYR) && empty($financialPTaxYR) && empty($ReturnOnShareholderFundYR) && empty($ReturnOnNetAssetYR) && empty($CapitalStockDay) && empty($CapitalDebtorDay) && empty($CapitalCreditorDay) && empty($LiquidityLiquidDay) && empty($LiquidityCurrentDay) && empty($SolvencyInterestCoverDay) && empty($SolvencyGearingDay)) $financialAll = 0; else $financialAll = 1; return $financialAll; } function financial_month_desc($year, $financial_type, $year_count, $localno) { global $db_bcorp; $stmt_frYearCheck = "SELECT MonthDesc FROM bc_report_financial WHERE LocalNo = '" .$localno. "' AND FinancialType='".$financial_type."' AND Year = ".$year." AND YearCount = ".$year_count." ORDER BY 'Year' DESC "; if (!$rs_frYearCheck = $db_bcorp->Execute($stmt_frYearCheck)) { trigger_error("Error: Execute SQL: $stmt_frYearCheck. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } return $rs_frYearCheck->Fields('MonthDesc'); } //TO SORT MULTIDEMENSIONAL ARRAY function sortmddata($array = array(), $by, $order, $type) { //$array: the array you want to sort //$by: the associative array name that is one level deep ////example: name //$order: ASC or DESC //$type: num or str $sortby = "sort$by"; //This sets up what you are sorting by $firstval = current($array); //Pulls over the first array $vals = array_keys($firstval); //Grabs the associate Arrays foreach ($vals as $init) { $keyname = "sort$init"; $$keyname = array(); } //This was strange because I had problems adding //Multiple arrays into a variable variable //I got it to work by initializing the variable variables as arrays //Before I went any further foreach ($array as $key => $row) { foreach ($vals as $names) { $keyname = "sort$names"; $test = array(); $test[$key] = $row[$names]; $$keyname = array_merge($$keyname,$test); } } //This will create dynamic mini arrays so that I can perform //the array multisort with no problem //Notice the temp array... I had to do that because I //cannot assign additional array elements to a //varaiable variable if ($order == "DESC") { if ($type == "num") { array_multisort($$sortby,SORT_DESC, SORT_NUMERIC,$array); } else { array_multisort($$sortby,SORT_DESC, SORT_STRING,$array); } } else { if ($type == "num") { array_multisort($$sortby,SORT_ASC, SORT_NUMERIC,$array); } else { array_multisort($$sortby,SORT_ASC, SORT_STRING,$array); } } //This just goed through and asks the additional arguments //What they are doing and are doing variations of //the multisort return $array; } function shareholder_reordering($array_data) { $last_data = array_pop($array_data); if($last_data['Name'] == "REMAINING SHAREHOLDERS") { $last_data_name = $last_data['Name']; $last_data_LocalNo = $last_data['LocalNo']; $last_data_Address = $last_data['Address']; $last_data_ICppNo = $last_data['ICppNo']; $last_data_Remark = $last_data['Remark']; $last_data_ShareHolding = $last_data['ShareHolding']; $data_afterDescSort = common::sortmddata($array_data,'ShareHolding','DESC','num'); array_push($data_afterDescSort, array("Name"=>$last_data_name, "LocalNo"=>$last_data_LocalNo, "Address"=>$last_data_Address, "ICppNo"=>$last_data_ICppNo, "Remark"=>$last_data_Remark, "ShareHolding"=>$last_data_ShareHolding)); } else { $last_data_name = $last_data['Name']; $last_data_LocalNo = $last_data['LocalNo']; $last_data_Address = $last_data['Address']; $last_data_ICppNo = $last_data['ICppNo']; $last_data_Remark = $last_data['Remark']; $last_data_ShareHolding = $last_data['ShareHolding']; if(count($array_data) > 0) { $data_afterDescSort = common::sortmddata($array_data,'ShareHolding','DESC','num'); array_push($data_afterDescSort, array("Name"=>$last_data_name, "LocalNo"=>$last_data_LocalNo, "Address"=>$last_data_Address, "ICppNo"=>$last_data_ICppNo, "Remark"=>$last_data_Remark, "ShareHolding"=>$last_data_ShareHolding)); } else { if(count($last_data) > 0) { $data_afterDescSort = array(); array_push($data_afterDescSort, array("Name"=>$last_data_name, "LocalNo"=>$last_data_LocalNo, "Address"=>$last_data_Address, "ICppNo"=>$last_data_ICppNo, "Remark"=>$last_data_Remark, "ShareHolding"=>$last_data_ShareHolding)); } else { $data_afterDescSort = array(); } } //print_r($array_data);exit; /*if(array_key_exists('ShareHolding', $array_data)) { $data_afterDescSort = common::sortmddata($array_data,'ShareHolding','DESC','num'); array_push($data_afterDescSort, array("Name"=>$last_data_name, "LocalNo"=>$last_data_LocalNo, "Address"=>$last_data_Address, "ICppNo"=>$last_data_ICppNo, "Remark"=>$last_data_Remark, "ShareHolding"=>$last_data_ShareHolding)); } else { $data_afterDescSort = array(); array_push($data_afterDescSort, array("Name"=>$last_data_name, "LocalNo"=>$last_data_LocalNo, "Address"=>$last_data_Address, "ICppNo"=>$last_data_ICppNo, "Remark"=>$last_data_Remark, "ShareHolding"=>$last_data_ShareHolding)); }*/ } return $data_afterDescSort; } //HISTORY CHECK IN COMPANY function interestCheckInCompany($newICNo, $oldICNo) { global $db_bcorp; $array_interestCheckCompany['interestInCompany'] = array(); if($newICNo != "N/A")//WHEN NEW IC NO NOT BLANK { $stmt_company_detail = "SELECT * FROM ind_entity_own_entity WHERE indEntity_icppregNo='".$newICNo."' AND own_entity_type='C' AND ( indEntity_dateWithdrawn = '0000-00-00' OR indEntity_dateWithdrawn = '') ORDER BY shareHolding DESC"; if (!$rs_company_detail = $db_bcorp->Execute($stmt_company_detail)) { trigger_error("Error: Execute SQL: $stmt_company_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } else { if(!$rs_company_detail->EOF)//WHEN NEW IC NUMBER CONTAIN DATA INSIDE { //CAPTURE ALL DATA while($rsa_company_detail = $rs_company_detail->FetchRow()) { $stmt_windup_detail = "SELECT Type FROM windup_details WHERE LocalNo='".$rsa_company_detail['own_entity_localNo']."' ORDER BY WindupDate DESC"; if (!$rs_windup_detail = $db_bcorp->Execute($stmt_windup_detail)) { trigger_error("Error: Execute SQL: $stmt_windup_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if($rs_windup_detail->fields('Type') != "") $court = $rs_windup_detail->fields('Type'); else $court = "-"; $companyLocalNo = $rsa_company_detail['own_entity_localNo']; $companyName = $rsa_company_detail['own_entity_name']; $companyDesignation = common::getPositionName($rsa_company_detail['indEntity_position']); $companyShareholding = number_format($rsa_company_detail['shareHolding'], 2, '.', ','); $companyAsAt = common::datetotimestamp($rsa_company_detail['verifyDate']); array_push($array_interestCheckCompany['interestInCompany'], array("companyLocalNo"=>$companyLocalNo, "companyName"=>$companyName, "companyDesignation"=>$companyDesignation, "companyShareholding"=>$companyShareholding, "court"=>$court, "companyAsAt"=>$companyAsAt)); } } else// WHEN NEW IC NUMBER CONTAIN NO DATA, GO SEARCH FOR OLD IC NUMBER { $stmt_company_detail = "SELECT * FROM ind_entity_own_entity WHERE indEntity_icppregNo='".$oldICNo."' AND own_entity_type='C' AND ( indEntity_dateWithdrawn = '0000-00-00' OR indEntity_dateWithdrawn = '') ORDER BY shareHolding DESC"; if (!$rs_company_detail = $db_bcorp->Execute($stmt_company_detail)) { trigger_error("Error: Execute SQL: $stmt_company_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } else { if(!$rs_company_detail->EOF)//WHEN OLD IC NUMBER CONTAIN DATA INSIDE { //CAPTURE ALL DATA while($rsa_company_detail = $rs_company_detail->FetchRow()) { $stmt_windup_detail = "SELECT Type FROM windup_details WHERE LocalNo='".$rsa_company_detail['own_entity_localNo']."' ORDER BY WindupDate DESC"; if (!$rs_windup_detail = $db_bcorp->Execute($stmt_windup_detail)) { trigger_error("Error: Execute SQL: $stmt_windup_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if($rs_windup_detail->fields('Type') != "") $court = $rs_windup_detail->fields('Type'); else $court = "-"; $companyLocalNo = $rsa_company_detail['own_entity_localNo']; $companyName = $rsa_company_detail['own_entity_name']; $companyDesignation = common::getPositionName($rsa_company_detail['indEntity_position']); $companyShareholding = number_format($rsa_company_detail['shareHolding'], 2, '.', ','); $companyAsAt = common::datetotimestamp($rsa_company_detail['verifyDate']); array_push($array_interestCheckCompany['interestInCompany'], array("companyLocalNo"=>$companyLocalNo, "companyName"=>$companyName, "companyDesignation"=>$companyDesignation, "companyShareholding"=>$companyShareholding, "court"=>$court, "companyAsAt"=>$companyAsAt)); } } else { $array_interestCheckCompany['interestInCompany'] = array(); } } } } } else // WHEN OLD IC NO NOT 'BLANK', BUT NEW IC NO 'BLANK' { $stmt_company_detail = "SELECT * FROM ind_entity_own_entity WHERE indEntity_icppregNo='".$oldICNo."' AND own_entity_type='C' AND ( indEntity_dateWithdrawn = '0000-00-00' OR indEntity_dateWithdrawn = '') ORDER BY shareHolding DESC"; if (!$rs_company_detail = $db_bcorp->Execute($stmt_company_detail)) { trigger_error("Error: Execute SQL: $stmt_company_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } else { if(!$rs_company_detail->EOF)//WHEN OLD IC NUMBER CONTAIN DATA INSIDE { //CAPTURE ALL DATA while($rsa_company_detail = $rs_company_detail->FetchRow()) { $stmt_windup_detail = "SELECT Type FROM windup_details WHERE LocalNo='".$rsa_company_detail['own_entity_localNo']."' ORDER BY WindupDate DESC"; if (!$rs_windup_detail = $db_bcorp->Execute($stmt_windup_detail)) { trigger_error("Error: Execute SQL: $stmt_windup_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if($rs_windup_detail->fields('Type') != "") $court = $rs_windup_detail->fields('Type'); else $court = "-"; $companyLocalNo = $rsa_company_detail['own_entity_localNo']; $companyName = $rsa_company_detail['own_entity_name']; $companyDesignation = common::getPositionName($rsa_company_detail['indEntity_position']); $companyShareholding = number_format($rsa_company_detail['shareHolding'], 2, '.', ','); $companyAsAt = common::datetotimestamp($rsa_company_detail['verifyDate']); array_push($array_interestCheckCompany['interestInCompany'], array("companyLocalNo"=>$companyLocalNo, "companyName"=>$companyName, "companyDesignation"=>$companyDesignation, "companyShareholding"=>$companyShareholding, "court"=>$court, "companyAsAt"=>$companyAsAt)); } } else { $array_interestCheckCompany['interestInCompany'] = array(); } } } return $array_interestCheckCompany; } // HISTORY CHECK IN BUSINESS function interestCheckInBusiness($newICNo, $oldICNo) { global $db_bcorp; $array_interestCheckBusiness['interestInBusiness'] = array(); if($newICNo != "N/A")//WHEN NEW IC NO NOT BLANK { $stmt_company_detail = "SELECT * FROM ind_entity_own_entity WHERE indEntity_icppregNo='".$newICNo."' AND own_entity_type='B' AND ( indEntity_dateWithdrawn = '0000-00-00' OR indEntity_dateWithdrawn = '') ORDER BY shareHolding DESC"; if (!$rs_company_detail = $db_bcorp->Execute($stmt_company_detail)) { trigger_error("Error: Execute SQL: $stmt_company_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } else { if(!$rs_company_detail->EOF)//WHEN NEW IC NUMBER CONTAIN DATA INSIDE { //CAPTURE ALL DATA while($rsa_company_detail = $rs_company_detail->FetchRow()) { $stmt_windup_detail = "SELECT Type FROM windup_details WHERE LocalNo='".$rsa_company_detail['own_entity_localNo']."' ORDER BY WindupDate DESC"; if (!$rs_windup_detail = $db_bcorp->Execute($stmt_windup_detail)) { trigger_error("Error: Execute SQL: $stmt_windup_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if($rs_windup_detail->fields('Type') != "") $court = $rs_windup_detail->fields('Type'); else $court = "-"; $companyLocalNo = $rsa_company_detail['own_entity_localNo']; $companyName = $rsa_company_detail['own_entity_name']; $companyDesignation = common::getPositionName($rsa_company_detail['indEntity_position']); $companyShareholding = number_format($rsa_company_detail['shareHolding'], 2, '.', ','); $companyAsAt = common::datetotimestamp($rsa_company_detail['verifyDate']); array_push($array_interestCheckBusiness['interestInBusiness'], array("companyLocalNo"=>$companyLocalNo, "companyName"=>$companyName, "companyDesignation"=>$companyDesignation, "companyShareholding"=>$companyShareholding, "court"=>$court, "companyAsAt"=>$companyAsAt)); } } else// WHEN NEW IC NUMBER CONTAIN NO DATA, GO SEARCH FOR OLD IC NUMBER { $stmt_company_detail = "SELECT * FROM ind_entity_own_entity WHERE indEntity_icppregNo='".$oldICNo."' AND own_entity_type='B' AND ( indEntity_dateWithdrawn = '0000-00-00' OR indEntity_dateWithdrawn = '') ORDER BY shareHolding DESC"; if (!$rs_company_detail = $db_bcorp->Execute($stmt_company_detail)) { trigger_error("Error: Execute SQL: $stmt_company_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } else { if(!$rs_company_detail->EOF)//WHEN OLD IC NUMBER CONTAIN DATA INSIDE { //CAPTURE ALL DATA while($rsa_company_detail = $rs_company_detail->FetchRow()) { $stmt_windup_detail = "SELECT Type FROM windup_details WHERE LocalNo='".$rsa_company_detail['own_entity_localNo']."' ORDER BY WindupDate DESC"; if (!$rs_windup_detail = $db_bcorp->Execute($stmt_windup_detail)) { trigger_error("Error: Execute SQL: $stmt_windup_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if($rs_windup_detail->fields('Type') != "") $court = $rs_windup_detail->fields('Type'); else $court = "-"; $companyLocalNo = $rsa_company_detail['own_entity_localNo']; $companyName = $rsa_company_detail['own_entity_name']; $companyDesignation = common::getPositionName($rsa_company_detail['indEntity_position']); $companyShareholding = number_format($rsa_company_detail['shareHolding'], 2, '.', ','); $companyAsAt = common::datetotimestamp($rsa_company_detail['verifyDate']); array_push($array_interestCheckBusiness['interestInBusiness'], array("companyLocalNo"=>$companyLocalNo, "companyName"=>$companyName, "companyDesignation"=>$companyDesignation, "companyShareholding"=>$companyShareholding, "court"=>$court, "companyAsAt"=>$companyAsAt)); } } else { $array_interestCheckBusiness['interestInBusiness'] = array(); } } } } } else // WHEN OLD IC NO NOT 'BLANK', BUT NEW IC NO 'BLANK' { $stmt_company_detail = "SELECT * FROM ind_entity_own_entity WHERE indEntity_icppregNo='".$oldICNo."' AND own_entity_type='B' AND ( indEntity_dateWithdrawn = '0000-00-00' OR indEntity_dateWithdrawn = '') ORDER BY shareHolding DESC"; if (!$rs_company_detail = $db_bcorp->Execute($stmt_company_detail)) { trigger_error("Error: Execute SQL: $stmt_company_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } else { if(!$rs_company_detail->EOF)//WHEN OLD IC NUMBER CONTAIN DATA INSIDE { //CAPTURE ALL DATA while($rsa_company_detail = $rs_company_detail->FetchRow()) { $stmt_windup_detail = "SELECT Type FROM windup_details WHERE LocalNo='".$rsa_company_detail['own_entity_localNo']."' ORDER BY WindupDate DESC"; if (!$rs_windup_detail = $db_bcorp->Execute($stmt_windup_detail)) { trigger_error("Error: Execute SQL: $stmt_windup_detail. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } if($rs_windup_detail->fields('Type') != "") $court = $rs_windup_detail->fields('Type'); else $court = "-"; $companyLocalNo = $rsa_company_detail['own_entity_localNo']; $companyName = $rsa_company_detail['own_entity_name']; $companyDesignation = common::getPositionName($rsa_company_detail['indEntity_position']); $companyShareholding = number_format($rsa_company_detail['shareHolding'], 2, '.', ','); $companyAsAt = common::datetotimestamp($rsa_company_detail['verifyDate']); array_push($array_interestCheckBusiness['interestInBusiness'], array("companyLocalNo"=>$companyLocalNo, "companyName"=>$companyName, "companyDesignation"=>$companyDesignation, "companyShareholding"=>$companyShareholding, "court"=>$court, "companyAsAt"=>$companyAsAt)); } } else { $array_interestCheckBusiness['interestInBusiness'] = array(); } } } return $array_interestCheckBusiness; } //GET ALL THE POSITION NAME, EG: 1=SCERETARY, 2=DIRECTOR function getPositionName($positionId) { if($positionId == 1) $position = "Secretary"; elseif($positionId == 2) $position = "Director"; elseif($positionId == 3) $position = "Shareholder"; elseif($positionId == "PT") $position = "PARTNERSHIP"; elseif($positionId == "SP") $position = "SOLE PROPRIETORSHIP"; return $position; } //CHECK WHETHER GOT INTEREST IN COMPANIES OR BUSINESS function isInterestCheckExist($totalInterestCheck) { if(count($totalInterestCheck) > 0) return "see below"; else return "none in our databank"; } //VIEW LEGAL CHECK AGAINST THE INDIVIDUAL function creditHistoryLegalAction($localno, $companyname) { global $db_bcorp; $pstrFormerName = common::NameList($localno); $mstrRipName = common::findShortFormName($companyname); if($pstrFormerName != "") $pstrNameList = "(" . $mstrRipName . "," . $pstrFormerName . ")"; else $pstrNameList = "(" . $mstrRipName . ")"; $stmt_legalCheckSuitDefendant = "SELECT ID, Name, Street, PostCode, Town, State, Country, ICPPRegNo FROM suit_defendant WHERE Name IN " .$pstrNameList. " OR ICPPRegNo='" . $localno . "' ORDER BY SequenceNo ASC"; if (!$rs_legalCheckSuitDefendant = $db_bcorp->Execute($stmt_legalCheckSuitDefendant)) { trigger_error("Error: Execute SQL: $stmt_legalCheckSuitDefendant. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $array_legalCheckDefendant = $arrayPlaintiff = $arrayLegalCheckRemark = array(); if(!$rs_legalCheckSuitDefendant->EOF) { $i = 0; while($rsa_legalCheckSuitDefendant = $rs_legalCheckSuitDefendant->FetchRow()) { //VIEW SUIT $stmt_legalCheckSuit = "SELECT * FROM suit WHERE ID='".$rsa_legalCheckSuitDefendant['ID']."'"; if (!$rs_legalCheckSuit = $db_bcorp->Execute($stmt_legalCheckSuit)) { trigger_error("Error: Execute SQL: $stmt_legalCheckSuit. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } //VIEW NATURE CLAIM $stmt_legalCheckNatureClaim = "SELECT * FROM suit_nature WHERE ID='".$rsa_legalCheckSuitDefendant['ID']."'"; if (!$rs_legalCheckNatureClaim = $db_bcorp->Execute($stmt_legalCheckNatureClaim)) { trigger_error("Error: Execute SQL: $stmt_legalCheckNatureClaim. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $suit_defendant_info = common::suit_defendantName($rsa_legalCheckSuitDefendant['ID']); $DateFiled = common::datetotimestamp($rs_legalCheckSuit->Fields('DateFiled')); $codeNoSuit = $rs_legalCheckSuit->Fields('Code'); $caseNoSuit = $rs_legalCheckSuit->Fields('CaseNo'); $yearSuit = $rs_legalCheckSuit->Fields('Year'); $placeSuit = htmlspecialchars(common::lookupPlace($rs_legalCheckSuit->Fields('Place'))); $courtSuit = htmlspecialchars(common::lookupCourt($rs_legalCheckSuit->Fields('Court'))); $solicitorsuit = htmlspecialchars($rs_legalCheckSuit->Fields('Solicitor')); $SolicitorRefSuit = htmlspecialchars($rs_legalCheckSuit->Fields('SolicitorRef')); if($rs_legalCheckNatureClaim->Fields('AmtClaim') != "") $amountClaimSuit = number_format($rs_legalCheckNatureClaim->Fields('AmtClaim'), 2, '.', ','); else $amountClaimSuit = ""; $natureClaimSuit = htmlspecialchars($rs_legalCheckNatureClaim->Fields('ClaimNature')); array_push($array_legalCheckDefendant, array("suit_defendant_info"=>$suit_defendant_info, "codeNo"=>$codeNoSuit, "caseNo"=>$caseNoSuit, "year"=>$yearSuit, "place"=>$placeSuit, "court"=>$courtSuit, "solicitor"=>$solicitorsuit, "amountClaim"=>$amountClaimSuit, "natureClaim"=>$natureClaimSuit, "SolicitorRef"=>$SolicitorRefSuit, "DateFiled"=>$DateFiled)); $creditHistoryLegalAction['legalCheckDefendant'] = $array_legalCheckDefendant; //--> VIEW PLAINTIFF $stmt_legalCheckPlaintiff = "SELECT Plaintiff FROM suit_plaintiff WHERE ID='".$rsa_legalCheckSuitDefendant['ID']."'"; if (!$rs_legalCheckPlaintiff = $db_bcorp->Execute($stmt_legalCheckPlaintiff)) { trigger_error("Error: Execute SQL: $stmt_legalCheckPlaintiff. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $rsa_legalCheckPlaintiff = $rs_legalCheckPlaintiff->GetArray(); $creditHistoryLegalAction['legalCheckPlaintiff'][$i] = $rsa_legalCheckPlaintiff; //<-- //-->VIEW THE DEFENDANT REMARKS THAT REMARK MAY BE MORE THAN 1 $stmt_legalCheckRemark = "SELECT Remark FROM suit_remarks WHERE ID='".$rsa_legalCheckSuitDefendant['ID']."'"; if (!$rs_legalCheckRemark = $db_bcorp->Execute($stmt_legalCheckRemark)) { trigger_error("Error: Execute SQL: $stmt_legalCheckRemark. ** Error message: " . $db_bcorp->ErrorMsg() , E_USER_ERROR); exit(); } $rsa_legalCheckRemark = $rs_legalCheckRemark->GetArray(); $creditHistoryLegalAction['legalCheckRemark'][$i] = $rsa_legalCheckRemark; //<-- $i++; } } //print_r($rsa_legalCheckPlaintiff);exit; return $creditHistoryLegalAction; //$legalCheckSuitDefendentIsExist = sizeof($array_legalCheckDefendant); } function lookupCountryName($country) { global $db_bn; $country_sql = "SELECT * FROM l_country where l_country_code = '".$country."'"; $country_data = $db_bn -> Execute($country_sql) or die($db_bn -> ErrorMsg()); $pass = $country_data -> fields['l_country_name']; return $pass; } function searchContainCurrentName($companyname) { global $db_bn; $checkchar = strchr($companyname,"-"); if(!empty($checkchar)) $search = explode("-",$companyname); else if(empty($checkchar)) $search = explode(" ",$companyname); $p=0; foreach($search as $key => $value){ if($p == $key){ $searchQ = " WHERE bc_entity_name LIKE '%".$value."%'"; }else if($p != $key){ $searchQ = $searchQ . " AND bc_entity_name LIKE '%".$value."%'"; } } return $searchQ; } function searchContainFormerName($companyname) { global $db_bn; $checkchar = strchr($companyname,"-"); if(!empty($checkchar)) $search = explode("-",$companyname); else if(empty($checkchar)) $search = explode(" ",$companyname); $p=0; foreach($search as $key => $value){ if($p == $key){ $searchQ = " WHERE FormerName LIKE '%".$value."%'"; }else if($p != $key){ $searchQ = $searchQ . " AND FormerName LIKE '%".$value."%'"; } } return $searchQ; } } ?> M1000 Business Directory Order Form
MALAYSIA 1000 directory is jointly published by BASIS Publications House Sdn Bhd, a subsidiary of BASIS Holdings Sdn Bhd in collaboration with the Malaysian National News Agency (BERNAMA) and Malaysia External Trade Development Corporation (MATRADE). It is an annual publication. It provides the domestic and foreign business community with complete, authentic and up-to-date information on businesses in Malaysia.
It also aims to provide recognition for top performing business organisations and their contribution to the industry at large.
It contains an index of 1000 top performers and industrial classifications with the companies ranked by turnover, profits, total assets, shareholders' funds, profit margin, return on capital, return on shareholders' funds, absolute/percentage increase in sales and absolute/percentage increase in profits.
MALAYSIA 1000 DIRECTORY Quantity Amount (MYR)
RM250 per copy
Delivery Mode :
Self Collection Courier
TOTAL
Company Name :
Address :
Postcode : Town : State :
Country :
Contact Person :
Designation :
Email :
Tel No :
Fax No :
Please click on Order Now to proceed with the payment by CREDIT CARD, ELECTRONIC TRANSFER or CHEQUE.
Cheque should be crossed and payable to BASIS PUBLICATIONS HOUSE SDN BHD.
BASIS PUBLICATIONS HOUSE SDN BHD (234040-A) is a subsidiary of BASIS HOLDINGS SDN BHD
WISMA BASIS, Metro Centre, No 11-15 Jalan 8/146, Bandar Tasik Selatan, Sungai Besi, 57000 Kuala Lumpur, Malaysia.
Tel. No. : 603-9051 6999 Fax. No. : 603-9051 6888
Email : m1000@basis.com.my Web Site : www.malaysia1000.com.my