| Server IP : 172.67.216.113 / Your IP : 104.23.243.33 [ Web Server : Apache System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64 User : cp648411 ( 1354) PHP Version : 7.2.34 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home2/cp648411/public_html/ilawasia.onnud20.com/class_old/ |
Upload File : |
<?php
class coreClass extends Viewdata
{
//$con=$this->setconnect();
public function GenDocumentNumberOnlyYear($id,$isUpdate = "false")
{
$con = $this->setconnect();
$date_year = date("Y");
$date_month = date("m");
$name_table = " ct_document_number t";
$secrch = " DocumentNumberId = '".$id."'";
$sql = array('table'=>$name_table,'where'=>$secrch);
$view = $this->view($sql);
$row = $this->q($view);
$running = $row['Number'];
if(@$date_year!=$row['Year']){
$running = 1;
$date_year = $date_year;
$date_month = $date_month;
$prefix = (@$row['Prefix']!='')?$row['Prefix']:"";
//echo $date_year;
$sql = " UPDATE `ct_document_number` SET `Year` = '".$date_year."' ,`Month` = '".$date_month."' ,`Number` = '".$running."' WHERE `DocumentNumberId` = ".$id ;
$result = mysqli_query($con,$sql);
}
if($isUpdate=='true') {
$running=$running+1;
$sql = " UPDATE `ct_document_number` SET `Number` = '".$running."' WHERE `DocumentNumberId` = ".$id ;
$result = mysqli_query($con,$sql);
}
$gdn = $prefix.substr($date_year,2)."-".str_pad($date_month,1,"0",STR_PAD_LEFT)."-".str_pad($running,5,"0",STR_PAD_LEFT);
$gdn2 = $prefix.substr($date_year,0)."-".str_pad($date_month,1,"0",STR_PAD_LEFT)."-".str_pad($running,5,"0",STR_PAD_LEFT);
$gdn3 = $prefix.substr($date_year,0)."-".str_pad($running,6,"0",STR_PAD_LEFT);
//$running=$running+1;
$data = array(
"gdn" => $gdn,
"gdn2" => $gdn2,
"gdn3" => $gdn3,
"running" => $running,
"date_year" => $date_year,
"date_month" => $date_month,
"prefix" => $prefix,
"sql" => $view,
);
return $data;
}
public function ReplaceNull($obj)
{
if($obj!=''){
}
}
public function GenDocumentNumber($id,$isUpdate = "false")
{
$con = $this->setconnect();
$date_year = date("Y");
$date_month = date("m");
$name_table = " ct_document_number t";
$secrch = " DocumentNumberId = '".$id."'";
$sql = array('table'=>$name_table,'where'=>$secrch);
$view = $this->view($sql);
$row = $this->q($view);
$running = $row['Number'];
if(@$date_year!=$row['Year'] || @$date_month!=$row['Month']){
$running = 1;
$date_year = $date_year;
$date_month = $date_month;
$prefix = (@$row['Prefix']!='')?$row['Prefix']:"";
}else{
$running=$running+1;
$sql = " UPDATE `ct_document_number` SET `Number` = '3' WHERE `DocumentNumberId` = " .$running ;
$result = mysqli_query($con,$sql);
}
$gdn = $prefix.substr($date_year,2)."-".str_pad($date_month,1,"0",STR_PAD_LEFT)."-".str_pad($running,5,"0",STR_PAD_LEFT);
$gdn2 = $prefix.substr($date_year,0)."-".str_pad($date_month,1,"0",STR_PAD_LEFT)."-".str_pad($running,5,"0",STR_PAD_LEFT);
$gdn3 = $prefix.substr($date_year,0)."-".str_pad($running,5,"0",STR_PAD_LEFT);
$data = array(
"gdn" => $gdn,
"gdn2" => $gdn2,
"gdn3" => $gdn3,
"running" => $running,
"date_year" => $date_year,
"date_month" => $date_month,
"prefix" => $prefix,
"sql" => $view,
);
return $data;
}
public function GenInvoiceFormatNumber($id,$isUpdate = "false"){
$con = $this->setconnect();
$date_year = date("Y");
$date_month = date("m");
$name_table = "ct_document_number";
$secrch = " DocumentNumberId = '".$id."'";
$sql = array('table'=>$name_table,'where'=>$secrch);
$view = $this->view($sql);
$row = $this->q($view);
$running = $row['Number'];
$prefix = (@$row['Prefix']!='')?$row['Prefix']:"";
if(@$date_year!=$row['Year'])
{
$running = 1;
$date_year = $date_year;
$sql = " UPDATE `ct_document_number` SET `Year` = '".$date_year."' ,`Month` = '".$date_month."' ,`Number` = '".$running."' WHERE `DocumentNumberId` = ".$id ;
$result = mysqli_query($con,$sql);
}
if($isUpdate=='true') {
$running=$running+1;
$sql = " UPDATE `ct_document_number` SET `Number` = '".$running."' WHERE `DocumentNumberId` = ".$id ;
$result = mysqli_query($con,$sql);
}
$gdn = $prefix.substr($date_year,0)."/".str_pad($running,3,"0",STR_PAD_LEFT);
//$running=$running+1;
$data = array(
"gdn" => $gdn,
"running" => $running,
"date_year" => $date_year,
"date_month" => $date_month,
"prefix" => $prefix,
"sql" => $view,
"row" => $row,
);
return $data;
}
public function ThaiBahtText($strNumber,$IsTrillion=0)
{
$BahtText = "";
$strTrillion = "";
$strThaiNumber = ["ศูนย์", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า", "สิบ"];
$strThaiPos = ["", "สิบ", "ร้อย", "พัน", "หมื่น", "แสน", "ล้าน"];
$decNumber = 0;
if(floatval($strNumber) == 0){
$data['return'] = "ศูนย์บาทถ้วน";
}
//$strNumber = number_format($decNumber,2);
$strNumber_explode = explode(".",$strNumber);
$strInteger = $strNumber_explode[0];
$strSatang = $strNumber_explode[1];
//echo $strInteger;
if(strlen($strInteger) > 13){
$data['return'] = "รองรับตัวเลขได้เพียง ล้านล้าน เท่านั้น!";
}
$_IsTrillion = (strlen($strInteger) > 7)?1:0;
$_IsTrillion = boolval($_IsTrillion)? 'true' : 'false';
if($_IsTrillion)
$data['return'] = $_IsTrillion;
return $data;
}
public function ThaiBahtText2($num)
{
$cnum = array();
$thnum1 = array("ศูนย์","หนึ่ง","สอง","สาม","สี่","ห้า","หก","เจ็ด","แปด","เก้า","เอ็ด","ยี่");
$thnum2 = array("สิบ","ร้อย","พัน","หมื่น","แสน","ล้าน","สิบ","ร้อย","พัน","หมื่น","แสน");
$thnum3 = array("", "สิบ", "ร้อย", "พัน", "หมื่น", "แสน", "ล้าน");
$num_ex = explode(".",$num);
$countnum = strlen($num_ex[0]); //นับจำนวนตัวอักษร
$numpos = ($countnum-1); // เลขประจำหลัก
$strInteger = $num_ex[0];
$strSatang = $num_ex[1];
for($i=0;$i<$countnum;$i++) //ตัวเลขแต่ละหลักไปคูณค่าประจำหลัก
{
$pow = pow(10,$numpos);
$position = $pow*(substr($num,$i,1));
$cnum[$i] = $position; //เก็บไว้ที่ array $cnum
$numpos-=1; //ลดค่าประจำหลัก
}
$strth="";
for($j=0;$j<$countnum-2;$j++)
{
if($j==$countnum-7 && substr($cnum[$countnum-7],0,1)==1&&$countnum>7)
{
$strth .= $thnum1[10];
$pos = strlen($cnum[$j]);
$pos -=2;
$strth .= $thnum2[$pos];
}
elseif($j==$countnum-7 && substr($cnum[$countnum-7],0,1)==0&&$countnum>7)
{
$strth .= $thnum2[5];
}
elseif($j==$countnum-8 && substr($cnum[$countnum-8],0,1)==1)
{
$strth .= $thnum2[0];
}
elseif($j==$countnum-8 && substr($cnum[$countnum-8],0,1)==2)
{
$twenty = $thnum1[11].$thnum2[0];
$strth .= $twenty;
}
else
{
$first = substr($cnum[$j],0,1);
if($first ==0)
{
$strth .= "";
}
else
{
$strth .= $thnum1[$first];
$pos = strlen($cnum[$j]);
$pos -=2;
$strth .= $thnum2[$pos];
}
}
}
if(substr($cnum[$countnum-2],0,1)==0)
{
$strth .= "";
}
elseif(substr($cnum[$countnum-2],0,1)==1)
{
$strth .= $thnum2[0];
}
elseif(substr($cnum[$countnum-2],0,1)==2)
{
$twenty = $thnum1[11].$thnum2[0];
$strth .= $twenty;
}
else
{
$value = substr($cnum[$countnum-2],0,1);
$strth .= $thnum1[$value];
$pos = strlen($cnum[$countnum-2]);
$pos-=2;
$strth .= $thnum2[$pos];
}
if(substr($cnum[$countnum-1],0,1)==0 && $countnum>1)
{
$strth .= "";
}
elseif(substr($cnum[$countnum-1],0,1)==1&& $countnum>1)
{
$strth .= $thnum1[10];
}
else
{
$value = substr($cnum[$countnum-1],0,1);
$strth .= $thnum1[$value];
}
if($strInteger != "0"){
$strth = $strth . "บาท";
}
if($strSatang=="00"){
$strth = $strth . "ถ้วน";
}else {
$strLength = strlen($strSatang);
for ($i=0; $i < strlen($strSatang); $i++) {
$number = substr($strSatang, $i, 1);
/*
echo "<br>";
echo $number;
echo "<br>";
*/
if($number != "0"){
if($i == $strLength - 1 && $number == "2"){
$strth = $strth . "เอ็ด";
}
else if($i == $strLength - 2 && $number == "2"){
$strth = $strth . "ยี่";
}
else if ($i != $strLength - 2 || $number != "1")
{
if($number=="1"){
$strth = $strth . "เอ็ด";
}else {
$strth = $strth . $thnum1[$number];
}
}
$strth = $strth . $thnum3[($strLength - $i)-1];
}
}
$strth = $strth . "สตางค์";
}
return $strth;
}
public function GetBankAccount($currency)
{
if ($currency == "thb"){
$data = "<span style=\"font-size:18px;\">ข้อมูลที่ใช้ในกรณีโอนเงินผ่านธนาคาร</span><br/>".
"<span style = \"font-size:18px;\" ><strong>ชื่อบัญชี: </strong> บริษัท ไอลอว์เอเชีย จำกัด</span ><br />".
"<span style = \"font-size:18px;\" ><strong>เลขที่บัญชี:</strong> 939-022895-6 </span ><br /> ".
"<span style = \"font-size:18px;\" > ".
"<strong> ธนาคาร:</strong> ธนาคารกรุงเทพ จำกัด(มหาชน) ".
"</span ><br />".
"<span style = \"font-size:18px;\" ><strong> สาขา:</strong > จามจุรีสแควร์ </span ><br /> " .
"<span style = \"font-size:18px;\" ><strong> Swift Code:</strong > BKKBTHBK </span > ";
}else {
$data = "<span style=\"font-size:18px;\">For wire transfer, please refer to our bank details mentioned belows:</span><br/>" .
"<span style = \"font-size:18px;\" ><strong>Account Name: </strong>ILAWASIA.CO.,LTD</span><br />" .
"<span style = \"font-size:18px;\" ><strong>Account Number:</strong> 939-022895-6 </span ><br /> " .
"<span style = \"font-size:18px;\" > " .
"<strong> Bank Name:</strong> Bangkok Bank PCL. " .
"</span ><br />" .
"<span style = \"font-size:18px;\" ><strong> Bank Branch :</strong > Chamchuri Square </span ><br /> " .
"<span style = \"font-size:18px;\" ><strong> Swift Code:</strong > BKKBTHBK </span > ";
}
return $data;
}
public function bahtEng2($thb) {
list($thb, $ths) = explode('.', $thb);
$ths = substr($ths.'00', 0, 2);
$thb = Currency::engFormat(intval($thb)).' Baht';
if (intval($ths) > 0) {
$thb .= ' '.Currency::engFormat(intval($ths)).' Satang';
}
return $thb;
}
public function bahtEng($thb) {
list($thb, $ths) = explode('.', $thb);
$ths = substr($ths.'00', 0, 2);
$thb = coreClass::EngBahtText(intval($thb)).' Baht';
if (intval($ths) > 0) {
$thb .= ' '.coreClass::EngBahtText(intval($ths)).' Satang';
}
return $thb;
}
public function dollarsEng($thb) {
list($thb, $ths) = explode('.', $thb);
$ths = substr($ths.'00', 0, 2);
$thb = coreClass::EngBahtText(intval($thb)).' dollars';
if (intval($ths) > 0) {
$thb .= ' '.coreClass::EngBahtText(intval($ths)).' cents';
}
return $thb;
}
public function EngBahtText($number)
{
// $ths = substr($ths.'00', 0, 2);
$max_size = pow(10, 18);
if (!$number)
return "zero";
if (is_int($number) && $number < abs($max_size)) {
switch ($number) {
case $number < 0:
$prefix = "negative";
$suffix = coreClass::EngBahtText(-1 * $number);
$string = $prefix." ".$suffix;
break;
case 1:
$string = "one";
break;
case 2:
$string = "two";
break;
case 3:
$string = "three";
break;
case 4:
$string = "four";
break;
case 5:
$string = "five";
break;
case 6:
$string = "six";
break;
case 7:
$string = "seven";
break;
case 8:
$string = "eight";
break;
case 9:
$string = "nine";
break;
case 10:
$string = "ten";
break;
case 11:
$string = "eleven";
break;
case 12:
$string = "twelve";
break;
case 13:
$string = "thirteen";
break;
case 15:
$string = "fifteen";
break;
case $number < 20:
$string = coreClass::EngBahtText($number % 10);
if ($number == 18) {
$suffix = "een";
} else {
$suffix = "teen";
}
$string .= $suffix;
break;
case 20:
$string = "twenty";
break;
case 30:
$string = "thirty";
break;
case 40:
$string = "forty";
break;
case 50:
$string = "fifty";
break;
case 60:
$string = "sixty";
break;
case 70:
$string = "seventy";
break;
case 80:
$string = "eighty";
break;
case 90:
$string = "ninety";
break;
case $number < 100:
$prefix = coreClass::EngBahtText($number - $number % 10);
$suffix = coreClass::EngBahtText($number % 10);
$string = $prefix."-".$suffix;
break;
case $number < pow(10, 3):
$prefix = coreClass::EngBahtText(intval(floor($number / pow(10, 2))))." hundred";
if ($number % pow(10, 2))
$suffix = " ".coreClass::EngBahtText($number % pow(10, 2));
$string = $prefix.$suffix;
break;
case $number < pow(10, 6):
$prefix = coreClass::EngBahtText(intval(floor($number / pow(10, 3))))." thousand";
if ($number % pow(10, 3))
$suffix = coreClass::EngBahtText($number % pow(10, 3));
$string = $prefix." ".$suffix;
break;
case $number < pow(10, 9):
$prefix = coreClass::EngBahtText(intval(floor($number / pow(10, 6))))." million";
if ($number % pow(10, 6))
$suffix = coreClass::EngBahtText($number % pow(10, 6));
$string = $prefix." ".$suffix;
break;
case $number < pow(10, 12):
$prefix = coreClass::EngBahtText(intval(floor($number / pow(10, 9))))." billion";
if ($number % pow(10, 9))
$suffix = coreClass::EngBahtText($number % pow(10, 9));
$string = $prefix." ".$suffix;
break;
case $number < pow(10, 15):
$prefix = coreClass::EngBahtText(intval(floor($number / pow(10, 12))))." trillion";
if ($number % pow(10, 12))
$suffix = coreClass::EngBahtText($number % pow(10, 12));
$string = $prefix." ".$suffix;
break;
case $number < pow(10, 18):
$prefix = coreClass::EngBahtText(intval(floor($number / pow(10, 15))))." quadrillion";
if ($number % pow(10, 15))
$suffix = coreClass::EngBahtText($number % pow(10, 15));
$string = $prefix." ".$suffix;
break;
}
}
return $string;
}
}