|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /home/pathumthani_integration/integration/application/pauper_surway/function/ |
Upload File : |
<?
function randigit($numchar){
$frchar = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z") ;
$ran_digit ="";
for ($ii = 0 ; $ii < $numchar ; $ii++ ){
$ran_digit .= $frchar[rand(1,26)] ;
}
return $ran_digit ;
} ## END function
/*function Check_subject_late($date_end,$date_late){
global $dbname;
$c_md = date("m-d");
$c_y = date("Y")+543;
$c_date = $c_y."-".$c_md;
$strSQL = "SELECT DATEDIFF('$date_end 23:59:59','$c_date') as t1";
$Result = mysql_db_query($dbname,$strSQL);
$Rs = mysql_fetch_object($Result);
if($Rs->t1 <= $date_late){
return true;
}else{
return false;
}
}*/
function Check_menu($status_pri){
if($status_pri == 1){
$disable_menu = "disabled='disabled'";
}else{
$disable_menu = "";
}
return $disable_menu;
}
function Check_subject_late($startdate, $enddate, $returntype,$runid) {
global $dbname;
if ($returntype == "s") #return value in second
$base = 1;
if ($returntype == "m") #return value in minute
$base = 60;
if ($returntype == "h") #return value in hour
$base = (60*60);
if ($returntype == "d") #return value in day
$base = (60*60*24);
$_date1 = explode("-", $startdate);
$d1 = $_date1[2];
$m1 = $_date1[1];
$y1 = $_date1[0] ; #543 Convert พ.ศ. เป็น ค.ศ.
$_date2 = explode("-", $enddate);
$d2 = $_date2[2];
$m2 = $_date2[1];
$y2 = $_date2[0]; #543 Convert พ.ศ. เป็น ค.ศ.
//echo $y1."---".$y2."<br>";
if (($y1 < 1970 || $y1 > 2037) || ($y2 < 1970 || $y2 > 2037)) {
return 0;
} else {
$today_stamp = mktime(0,0,0,$m1,$d1,$y1);
$end_date_stamp = mktime(0,0,0,$m2,$d2,$y2);
$difference = round(($end_date_stamp-$today_stamp)/$base);
//echo $difference;
//return $difference;
}
$strSQL = "SELECT * FROM tbl_complain_approve WHERE runid='$runid'";
$Result = mysql_db_query($dbname,$strSQL);
$Rs = mysql_fetch_assoc($Result);
if($difference <= $Rs[date_late]){
return true;
}else{
return false;
}
}
/*function Check_subject_late($runid){
global $dbname;
$xdate_start = date("Y-m-d");
$strSQL = "SELECT * FROM tbl_request WHERE runid='$runid'";
$Result = mysql_db_query($dbname,$strSQL);
$Rs = mysql_fetch_object($Result);
$arr_d = explode("-",$Rs->date_end);
$d1 = $arr_d[2];
$m1= $arr_d[1];
$y1 = $arr_d[0]-543;
$xdate_end = $y1."-".$m1."-".$d1;
$xtype_date = "d";
$check_time = datediff($xdate_start,$xdate_end,$xtype_date);
if($check_time <= $Rs->date_late){
return true;
}else{
return false;
}
}
*/
function Check_subject_count($startdate, $enddate, $returntype) {
global $dbname;
if ($returntype == "s") #return value in second
$base = 1;
if ($returntype == "m") #return value in minute
$base = 60;
if ($returntype == "h") #return value in hour
$base = (60*60);
if ($returntype == "d") #return value in day
$base = (60*60*24);
$_date1 = explode("-", $startdate);
$d1 = $_date1[2];
$m1 = $_date1[1];
$y1 = $_date1[0] ; #543 Convert พ.ศ. เป็น ค.ศ.
$_date2 = explode("-", $enddate);
$d2 = $_date2[2];
$m2 = $_date2[1];
$y2 = $_date2[0]; #543 Convert พ.ศ. เป็น ค.ศ.
//echo $y1."---".$y2."<br>";
if (($y1 < 1970 || $y1 > 2037) || ($y2 < 1970 || $y2 > 2037)) {
return 0;
} else {
$today_stamp = mktime(0,0,0,$m1,$d1,$y1);
$end_date_stamp = mktime(0,0,0,$m2,$d2,$y2);
$difference = round(($end_date_stamp-$today_stamp)/$base);
return $difference;
echo $difference;
}
}
########### gen รูปภาพ
// function gen รหัสรูป
function ranDomStr($length){
$str2ran = 'abcdefghijklmnopqrstuvwxyz0123456789'; //string ที่เป็นไปได้ที่จะใช้ในการ random ซึ่งสามารถเพิ่มลดได้ตามความต้องการ
$str_result = ""; //สตริงว่างสำหรับจะรับค่าจากการ random
while(strlen($str_result)<$length){ //วนลูปจนกว่าจะได้สตริงตามความยาวที่ต้องการ
$str_result .= substr($str2ran,(rand()%strlen($str2ran)),1); //ต่อ string จาก substring ที่ได้จากการ random ตำแหน่ง ทีละ 1 ตัว
//จนกว่าจะครบตรามความยาวที่ส่งมา
}
return($str_result);//ส่งค่ากลับ
}
//function addlog($action,$app_id = 1){ // ฟังก์ชั่น add log defult app_id == 1 คือ ระบบสารบัญอีเล็กทรอนิกส์
//global $session_staffid;
//
//$ip= getenv(REMOTE_ADDR);
//$sql_log="INSERT INTO `doc_log` (`logtime`,`staffid`,`action`,`ip`, app_id) VALUES (NOW() ,'$session_staffid' , '$action','$ip','$app_id')";
//$result_log = mysql_query($sql_log);
//}
function addlog($action,$app_id = 1,$act_id,$item_id=0){ // ฟังก์ชั่น add log defult app_id == 1 คือ ระบบสารบัญอีเล็กทรอนิกส์
global $session_staffid;
$ip= getenv(REMOTE_ADDR);
$sql_log="INSERT INTO `doc_log` (`logtime`,`staffid`,`action`,`ip`, app_id,item_id,act_id) VALUES (NOW() ,'$session_staffid' , '$action','$ip','$app_id','$item_id','$act_id')";
$result_log = mysql_query($sql_log)or die("Query line " . __LINE__ . " error<hr>".mysql_error());
}// end function addlog
/* ฟังก์ชั่นคำนวณร้อยละ Modified By : Aussy [2552-10-02 19:04] */
function percentage ( $arrVal, $intDec=2, $intPercent=100 ) {
if ( $arrVal && is_array($arrVal) ) {
#shwArray($arrVal);
$SumOfVal = array_sum($arrVal); #echo "Total of Value is : ".$SumOfVal."<br>";
foreach ( $arrVal as $Key => $Val ) {
$arrVal[$Key] = number_format((($Val * $intPercent) / $SumOfVal), $intDec + 1); // จำนวนร้อยละ ทศนิยม +1
// ชุดตัวแปร Array ร้อยละ จำนวนหลักทศนิยม
if ( substr($arrVal[$Key], -1, 1) < 5 ) { # A2
$arrA2Ori[$Key] = $arrVal[$Key];
$arrA2[$Key] = number_format($arrVal[$Key], $intDec);
$Ref = explode(".", $arrA2[$Key]);
$arrA2LastChar[$Key] = substr($arrA2Ori[$Key], -1, 1);
} else { # A1
$arrA1Ori[$Key] = $arrVal[$Key];
$arrA1[$Key] = number_format($arrVal[$Key], $intDec);
$Ref = explode(".", $arrA1[$Key]);
$arrA1LastChar[$Key] = substr($arrA1Ori[$Key], -1, 1);
}
$arrVInt[$Key] = $Ref[0]; // ชุดตัวแปรจำนวนเต็ม (ตัดทศนิยมทิ้ง)
$arrVDec[$Key] = $Ref[1]; // ชุดตัวแปรจำนวนทศนิยม
}
#shwArray($arrVal);
$x0 = array_sum($arrVInt); #echo "x0 = ".$x0."<br>";
$x1 = $intPercent - $x0; #echo "x1 = ".$x1."<br>";
$x2 = ($x1 * pow(10, $intDec)); #echo "x2 = ".$x2."<br>";
$x3 = array_sum($arrVDec); #echo "x3 = ".$x3."<br>";
$x4 = $x3 - $x2; #echo "x4 = ".$x4."<br>";
#shwArray($arrA1Ori);
#shwArray($arrA2Ori);
//echo (count($arrA1LastChar));
if(count($arrA1LastChar) > 0)
{
arsort($arrA1LastChar);
}
if(count($arrA2LastChar) > 0)
{
arsort($arrA2LastChar);
}
#shwArray($arrA1LastChar);
#shwArray($arrA2LastChar);
#shwArray($arrA1);
#shwArray($arrA2);
if ( $x4 == 0 ) {
if(is_array($arrA1))
{
foreach ( $arrA1 as $Key => $Val )
{
$arrResult[$Key] = $arrA1[$Key];
}
}
if(is_array($arrA2))
{
foreach ( $arrA2 as $Key => $Val )
{
$arrResult[$Key] = $arrA2[$Key];
}
}
} elseif ( $x4 > 0 ) {
$intA = 1;
foreach ( $arrA1LastChar as $Key => $Val ) {
if ( $intA <= (count($arrA1Ori) - $x4) ) $arrResult[$Key] = $arrA1[$Key]; else $arrResult[$Key] = substr($arrA1Ori[$Key], 0, strlen($arrA1Ori[$Key]) - 1);
$intA++;
}
foreach ( $arrA2 as $Key => $Val ) $arrResult[$Key] = $arrA2[$Key];
} elseif ( $x4 < 0 ) {
$intA = 1;
foreach ( $arrA2LastChar as $Key => $Val ) {
if ( $intA <= abs($x4) ) $arrResult[$Key] = $arrA2[$Key] + 1/(pow(10, $intDec)); else $arrResult[$Key] = $arrA2[$Key];
$intA++;
}
foreach ( $arrA1 as $Key => $Val ) $arrResult[$Key] = $arrA1[$Key];
}
#shwArray($arrResult);
#echo "Total of Percent is : ".number_format(array_sum($arrResult), 2)."<br>";
return $arrResult;
}
}
function dateFormat($value,$type){
if($type=="engthai"){
$day = explode("-",$value);
$date = $day[2].'-'.$day[1].'-'.($day[0]+543);
}else if($type=="thaieng"){
$day = explode("-",$value);
$date = ($day[2]-543).'-'.$day[1].'-'.$day[0];
}else if($type=="thaidot"){
$Month = array("", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
$day = explode("-",$value);
$Y = $day[0]+543;
$m = $day[1];
if($m<10){
$m = str_replace("0","",$m);
}
$d = (int)$day[2];
if($d==0){
$date="-";
}else{
$date = $d.' '.$Month[$m].' '.($Y);
}
}else if($type==""){
$date = explode("-",$value);
}
return $date;
}
function dateFormat2($value,$type){
if($type=="engthai"){
$day = explode("-",$value);
$date = $day[2].'-'.$day[1].'-'.($day[0]+543);
}else if($type=="thaieng"){
$day = explode("-",$value);
$date = ($day[2]-543).'-'.$day[1].'-'.$day[0];
}else if($type=="thaidot"){
$Month = array("", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
$day = explode("-",$value);
$Y = $day[0]+543;
$m = $day[1];
if($m<10){
$m = str_replace("0","",$m);
}
$d = (int)$day[2];
if($d==0){
$date="-";
}else{
$date = $d.' '.$Month[$m].' '.($Y);
}
}else if($type==""){
$date = explode("-",$value);
}
return $date;
}
function dateFormat3($value,$type){
if($type=="engthai"){
$day = explode("-",$value);
$date = $day[2].'-'.$day[1].'-'.($day[0]+543);
}else if($type=="thaieng"){
$day = explode("-",$value);
$date = ($day[2]-543).'-'.$day[1].'-'.$day[0];
}else if($type=="thaidot"){
$Month = array("", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
$day = explode("-",$value);
$Y = $day[2];
$m = $day[1];
if($m<10){
$m = str_replace("0","",$m);
}
$d = (int)$day[0]*1;
$date = $d.' '.$Month[$m].' '.($Y+543);
}else if($type==""){
$date = explode("-",$value);
}
return $date;
}
function make_link($url,$arr,$linkname)
{
if(isset($url)> 0)
{
if($linkname > 0)
{
$tagopen = "<a href='".$url."?action=0";
$tagclose = "</a>";
$link;
foreach($arr as $keyname => $keyvalue)
{
$link .= "&".$keyname."=".$keyvalue;
}
$link .= "' target='_blank'>";
return $tagopen.$link.$linkname.$tagclose;
}
else
{
return $linkname;
}
}
else
{
return 'funtion : make_link --> error';
}
}
$app_id = "5"; // $app_id == 5 คือ ระบบติดตามเรื่องร้องเรียน
$app10 = "10"; // สิทธิ admin
$app100 = "100"; // บันทึกเรื่องร้องเรียน
$app200 = "200"; // ตรวจสอบเรื่องร้องเรียนที่ได้รับจากประชาชน
$app300 = "300";// กำหนดหน่วยงานดำเนินการในแต่ละเรื่องร้องเรียน
$app400 = "400"; // ปรับปรุงความก้าวหน้า / สถานะของการตรวจสอบ แก้ไขตามข้อร้องเรียน
$app500 = "500"; // สิทธิสามารถเข้าดูรายงานเรื่องร้องเรียนได้
$act0 = "0"; // login เข้าสู่ระบบเรื่องร้องทุกข์
$act1 = "1"; // บันทึกข้อมูลเรื่องราวร้องทุกข์
$act2 = "2"; // แก้ไขข้อมูลเรื่องราวร้องทุกข์
$act3 = "3"; // ลบข้อมูลเรื่องราวร้องทุกข์
$act4 = "4"; // พิจารณาเรื่องราวร้องทุกข์เข้าสู่ระบบ
$act5 = "5"; // ส่งเรื่องราวร้องทุกข์ให้กับหน่วยงานที่เกี่ยวข้อง
$act6 = "6"; // บันทึกความก้าวหน้าการดำเนินการเรื่องราวร้องทุกข์
$act7 = "7"; // view หน้ารายงานระบบ
$act8 = "8"; // ค้นหา
function isemail($public_email)
{
// regx to test for valid e-mail adres
$regex = '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$';
if (eregi($regex, $email)) return true;
else return false;
}
?>