284 lines
7.7 KiB
PHP
284 lines
7.7 KiB
PHP
<?php
|
|
|
|
class MYUTIL
|
|
{
|
|
|
|
|
|
|
|
|
|
public static function numtowords($number)
|
|
{
|
|
|
|
$no = round($number);
|
|
$point = ($number - $no) == 0 ? '' : round($number - $no, 2) * 100;
|
|
$hundred = null;
|
|
$digits_1 = strlen($no);
|
|
$i = 0;
|
|
$str = array();
|
|
$words = array('0' => '', '1' => 'One', '2' => 'Two',
|
|
'3' => 'Three', '4' => 'Four', '5' => 'Five', '6' => 'Six',
|
|
'7' => 'Seven', '8' => 'Eight', '9' => 'Nine',
|
|
'10' => 'Ten', '11' => 'Eleven', '12' => 'Twelve',
|
|
'13' => 'Thirteen', '14' => 'Fourteen',
|
|
'15' => 'Fifteen', '16' => 'Sixteen', '17' => 'Seventeen',
|
|
'18' => 'Eighteen', '19' =>'Nineteen', '20' => 'Twenty',
|
|
'30' => 'Thirty', '40' => 'Forty', '50' => 'Fifty',
|
|
'60' => 'Sixty', '70' => 'Seventy',
|
|
'80' => 'Eighty', '90' => 'Ninety');
|
|
$digits = array('', 'Hundred', 'Thousand', 'Lakh', 'Crore');
|
|
while ($i < $digits_1) {
|
|
$divider = ($i == 2) ? 10 : 100;
|
|
$number = floor($no % $divider);
|
|
$no = floor($no / $divider);
|
|
$i += ($divider == 10) ? 1 : 2;
|
|
if ($number) {
|
|
$plural = (($counter = count($str)) && $number > 9) ? 's' : null;
|
|
$hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
|
|
$str [] = ($number < 21) ? $words[$number] .
|
|
" " . $digits[$counter] . $plural . " " . $hundred
|
|
:
|
|
$words[floor($number / 10) * 10]
|
|
. " " . $words[$number % 10] . " "
|
|
. $digits[$counter] . $plural . " " . $hundred;
|
|
} else $str[] = null;
|
|
}
|
|
$str = array_reverse($str);
|
|
$result = implode('', $str);
|
|
$points = ($point) ?
|
|
"." . $words[$point / 10] . " " .
|
|
$words[$point = $point % 10] : '';
|
|
$res = $result;
|
|
if($points != "")
|
|
{
|
|
$res.=$points . "";
|
|
}
|
|
return $result;
|
|
|
|
}
|
|
|
|
public static function findCompanyName($array,$companyid,$type)
|
|
{
|
|
if($array != null && $type==1)
|
|
{
|
|
foreach($array as $key => $value)
|
|
{
|
|
|
|
if($companyid == $value['company_order_id'])
|
|
{
|
|
return $value['company_name'];
|
|
}
|
|
}
|
|
}
|
|
if($array != null && $type==2)
|
|
{
|
|
foreach($array as $key => $value)
|
|
{
|
|
//print_r($value);die();
|
|
// echo date("d-m-Y", strtotime($value['business_date_object']) );
|
|
// die();
|
|
if($companyid == $value['company_order_id'])
|
|
{
|
|
$data['company_name'] = $value['company_name'];
|
|
//$getSentense .=' is a ';
|
|
$data['type_of_activity'] = $value['business_entity_type']==1 ? $value['business_entity_type_other'] : $value['business_entity_type_master'];
|
|
//$getSentense .=' formed on ';
|
|
//echo $data['type_of_activity'];
|
|
$CI=& get_instance();
|
|
$CI->load->model('PD_Model');
|
|
$business_entity_type = $CI->PD_Model->selectCustomRecords(array('*'),array('isactive' => 1),BUSINESSENTITYTYPE);
|
|
foreach($business_entity_type as $bn_key => $bn_value)
|
|
{
|
|
if($value['business_entity_type'] == $bn_value['business_entity_type_id'])
|
|
{
|
|
$data['partners_title_name'] = $bn_value['section_label'];
|
|
break;
|
|
}
|
|
}
|
|
// switch($value['business_entity_type'])
|
|
// {
|
|
// case 1:
|
|
// case 6:
|
|
// case 9:
|
|
// $data['partners_title_name'] = "Member Details";
|
|
// break;
|
|
// case 2:
|
|
// $data['partners_title_name'] = "Director / Shareholder Details";
|
|
// break;
|
|
// case 3:
|
|
// //echo '3';
|
|
// $data['partners_title_name'] = "Proprietor Details";
|
|
// break;
|
|
// case 4:
|
|
// $data['partners_title_name'] = "Karta Details";
|
|
// break;
|
|
// case 5:
|
|
// case 7:
|
|
// $data['partners_title_name'] = "Partner Details";
|
|
// break;
|
|
// case 8:
|
|
// case 11:
|
|
// $data['partners_title_name'] = "Director Details";
|
|
// break;
|
|
|
|
// case 10:
|
|
// $data['partners_title_name'] = "Trustee Details";
|
|
// break;
|
|
// }
|
|
$data['year_and_month']= $value['business_years'] . ' Year(s)';
|
|
$data['year_and_month'] .= isset($value['business_month']) && $value['business_month'] != "" ? ' and '.$value['business_month'] . ' Month(s)': '';
|
|
|
|
$data['formed_on'] = $value['business_date_object'] ? date("d-m-Y", strtotime($value['business_date_object'])) : null;
|
|
|
|
return $data;
|
|
//return $value['company_name'].' is a '.$value['business_entity_type']==1 ? $value['business_entity_type_other'] : $value['business_entity_type_master'] .' formed on '.date("d-m-Y", strtotime($value['business_date_object']));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 'Company Not Found';
|
|
}
|
|
}
|
|
|
|
public static function applicantTitleName($applicant_array,$id)
|
|
{
|
|
$t = null;
|
|
foreach($applicant_array as $applicant)
|
|
{
|
|
if($applicant['pd_co_applicant_id'] == $id)
|
|
{
|
|
$t = $applicant['title_name'];
|
|
}
|
|
}
|
|
|
|
return $t;
|
|
}
|
|
|
|
public static function findQuestionByKey($array,$qkey)
|
|
{
|
|
foreach($array as $key => $value)
|
|
{
|
|
//echo $value['key'].'--'.$qkey;
|
|
|
|
if(!strcmp(trim($value['key']),trim($qkey)))
|
|
{
|
|
// echo "\n";
|
|
// echo 'IF'.$value['key'].'--'.$qkey;
|
|
return $value['question'];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public static function customIndianNumberFormat($value)
|
|
{
|
|
$indian_num_format = numfmt_create( 'en_IN', NumberFormatter::DECIMAL );
|
|
//echo numfmt_format_currency($indian_num_format,$value, "INR");
|
|
//return numfmt_format_currency($indian_num_format,$value,"INR");
|
|
return numfmt_format($indian_num_format,$value);
|
|
}
|
|
|
|
public static function applicantNameCamelCaseConvertion($name)
|
|
{
|
|
$name = explode(' ',$name);
|
|
$final_name = null;
|
|
foreach($name as $n){ $final_name.= ' '.ucfirst(strtolower($n)); }
|
|
return $final_name;
|
|
}
|
|
|
|
public static function addOrdinalNumberSuffix($num)
|
|
{
|
|
if (!in_array(($num % 100),array(11,12,13)))
|
|
{
|
|
switch ($num % 10)
|
|
{
|
|
// Handle 1st, 2nd, 3rd
|
|
case 1: return $num.'st';
|
|
case 2: return $num.'nd';
|
|
case 3: return $num.'rd';
|
|
}
|
|
}
|
|
return $num.'th';
|
|
}
|
|
|
|
public static function dispatchDisclaimer($array,$discliamer_type)
|
|
{
|
|
foreach ($array as $key => $value)
|
|
{
|
|
if($value['type'] == $discliamer_type )
|
|
{
|
|
return $array[$key];
|
|
}
|
|
}
|
|
}
|
|
|
|
//generate finance year by give date (date format : Y-m-d)
|
|
//second param 1 means for sales PD
|
|
public static function getFinYears($sales_pd_created_date,$flag = null)
|
|
{
|
|
$sales_pd_created_date = explode('-',$sales_pd_created_date);
|
|
$year = $sales_pd_created_date[0];
|
|
$month = $sales_pd_created_date[1];
|
|
|
|
if($flag == 1)//sales pd
|
|
{
|
|
if($month < 4)
|
|
{
|
|
$cur_finyr_start = ($year-1);$cur_finyr_end = ($year);
|
|
}
|
|
else
|
|
{
|
|
$cur_finyr_start = ($year);$cur_finyr_end = ($year+1);
|
|
}
|
|
$fin_yr_array = array();
|
|
for($i = 4;$i >=1;$i--)
|
|
{
|
|
array_push($fin_yr_array, (($cur_finyr_start-$i).'-'.($cur_finyr_end-$i)));
|
|
}
|
|
return $fin_yr_array;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public static function reOrderFinYrsData($section5,$last_four_finyrs)
|
|
{
|
|
$ordered_fy_data = array();
|
|
foreach ($last_four_finyrs as $fin_key => $fin_yr)
|
|
{
|
|
foreach ($section5 as $key => $value)
|
|
{
|
|
if(is_numeric($key) && !strcasecmp($fin_yr, $value['fy']))
|
|
{
|
|
array_push($ordered_fy_data, $value);
|
|
unset($section5[$key]);
|
|
}
|
|
|
|
}
|
|
}
|
|
return $ordered_fy_data;
|
|
}
|
|
|
|
public static function isDateExpired($received_date,$days_to_compare)
|
|
{
|
|
$converted_real_date = strtotime($received_date);
|
|
$converted_real_date = date('Y-m-d',$converted_real_date);
|
|
|
|
// $format = "Y-m-d";
|
|
// $received_date = DateTime::createFromFormat($format, $converted_real_date);
|
|
// $today = DateTime::createFromFormat($format, date('Y-m-d'));
|
|
|
|
$received_date=date_create($converted_real_date);
|
|
$today=date_create(date('Y-m-d'));
|
|
$diff=date_diff($received_date,$today);
|
|
// echo $diff->format("%R%a days");
|
|
$different = $diff->format("%a");
|
|
//echo $different;
|
|
return ($different >= $days_to_compare);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
?>
|