Viewing file: emt_helper.php (4.08 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php function al_to_th($data) { $pt = array(); $pt[0] = '/0/'; $pt[1] = '/1/'; $pt[2] = '/2/'; $pt[3] = '/3/'; $pt[4] = '/4/'; $pt[5] = '/5/'; $pt[6] = '/6/'; $pt[7] = '/7/'; $pt[8] = '/8/'; $pt[9] = '/9/'; $rp = array(); $rp[0] = '๐'; $rp[1] = '๑'; $rp[2] = '๒'; $rp[3] = '๓'; $rp[4] = '๔'; $rp[5] = '๕'; $rp[6] = '๖'; $rp[7] = '๗'; $rp[8] = '๘'; $rp[9] = '๙';
$result = preg_replace($pt,$rp,$data); return $result; }
function th_to_al($data) { $pt = array(); $pt[0] = '/๐/'; $pt[1] = '/๑/'; $pt[2] = '/๒/'; $pt[3] = '/๓/'; $pt[4] = '/๔/'; $pt[5] = '/๕/'; $pt[6] = '/๖/'; $pt[7] = '/๗/'; $pt[8] = '/๘/'; $pt[9] = '/๙/'; $rp = array(); $rp[0] = '0' ; $rp[1] = '1'; $rp[2] = '2'; $rp[3] = '3'; $rp[4] = '4'; $rp[5] = '5'; $rp[6] = '6'; $rp[7] = '7'; $rp[8] = '8'; $rp[9] = '9'; $result = preg_replace($pt,$rp,$data); return $result; }
function th_date($date,$sp) { list($yy,$mm,$dd) = preg_split('['.$sp.']',$date); $yy = al_to_th($yy+ 543) ; $mm = get_month_th($mm); $dd = al_to_th((int)$dd); return $dd.' '.$mm.' '.$yy; }
function get_date_th($dd) { $day = array(0=>'อาทิตย์',1=>'จันทร์',2=>'อังคาร',3=>'พุธ',4=>'พฤหัสบดี',5=>'ศุกร์',6=>'อาทิตย์'); return 'วัน'.$day[(int)$dd]; }
function get_month_th($mm,$full=0) { $month = array( 1=>'ม.ค.', 2=>'ก.พ.',3=>'มี.ค.',4=>'เม.ย.',5=>'พ.ค.',6=>'มิ.ย.',7=>'ก.ค.',8=>'ส.ค.',9=>'ก.ย.',10=>'ต.ค.',11=>'พ.ย.',12=>'ธ.ค.'); $fmonth = array(1=>'มกราคม',2=>'กุมภาพันธ์',3=>'มีนาคม',4=>'เมษายน',5=>'พฤษภาคม',6=>'มิถุนายน',7=>'กรกฏาคม',8=>'สิงหาคม',9=>'กันยายน',10=>'ตุลาคม',11=>'พฤศจิกายน',12=>'ธันวาคม'); if($full) return $fmonth[(int)$mm]; else return $month[(int)$mm]; }
function num_meeting($no,$year,$type) { return al_to_th($no.'/'.($year+543).'('.$type.')'); }
function name_cms($cms_name,$cms_year) { $CI = &get_instance(); $text = $cms_name.$CI->config->item('emt_cp_year').($cms_year+543); return al_to_th($text); }
function name_meeting($name,$date) { $CI = &get_instance(); list($yy,$mm,$dd) = preg_split('[/|-]',$date); $time = mktime(0,0,0,$mm,$dd,$yy); $month = date('m',$time); $year = date('Y',$time); $text = $name.' '.$CI->config->item('emt_cp_month').get_month_th($month,1).' '.$CI->config->item('emt_cp_syear').($year+543); return al_to_th($text); }
function detail_meeting($obj) { $text = '- '; list($sh,$sm,$ss) = preg_split('[:]',$obj->ag_start_time); list($eh,$em,$es) = preg_split('[:]',$obj->ag_end_time); list($yy,$mm,$dd) = preg_split('[-|/]',$obj->mt_date_start); list($eyy,$emm,$edd) = preg_split('[-|/]',$obj->mt_date_stop); if($obj->mt_num_day ==1) { $day = date('w',mktime(0,0,0,$mm,$dd,$yy)); $text .= get_date_th($day).'ที่ '.((int)$dd).' '.get_month_th($mm,1).' '.($obj->mt_year+543); } else { $text .= 'ในระหว่างวันที่ ' ; $text .= (int)$dd.' - '.(int)$edd.' '.get_month_th($emm,1).' '.($obj->mt_year+543); } $text .= ' เวลา '; $text .= ((int)$sh).':'.$sm.' น. - '.((int)$eh).':'.$em.' น. ณ '.$obj->building.' '.$obj->room; return al_to_th($text); }
function emt_form_date($date,$sign='-') { list($dd,$mm,$yy) = preg_split('[/|-]',$date); return $yy.$sign.$mm.$sign.$dd; }
function emt_db_date($date,$sign='/',$th=0) { list($yy,$mm,$dd) = preg_split('[/|-]',$date); if($th) $yy += 543; return $dd.$sign.$mm.$sign.$yy; } function time_range($obj) { $CI = &get_instance(); $text = ($obj->cms_unstart_date ==1)?$CI->config->item('emt_nodate'):th_date($cms->cms_start_date,'-'); $text .= ' - '; $text .= ($obj->cms_unend_date ==1)?$CI->config->item('emt_nodate'):th_date($cms->cms_end_date,'-'); return $text; }
?>
|