

<?php 
ini_set('max_execution_time', 0); //300 seconds = 5 minutes 
date_default_timezone_set("Asia/Bangkok");
// echo $_SESSION['company_id'];
// include('../include/connect_MS2DB.php'); 

$currentdate = date('Y-m-d');

$yearY = date("Y"); 
$yearM = date("m"); 
$yearD = date("d");
$htime = date("H:i:sa"); 


function INSERT_SYNLOG($ConnLog,$ERROR_TEXT,$ERROR_TABLE,$ERROR_STATUS){

    $current_time = date("m-d-Y");

    if ($ConnLog) {
        sqlsrv_begin_transaction($ConnLog);
            try {

                    $sql_log = "INSERT into  SYN_LOG (ERROR_TABLE ,ERROR_TEXT ,ERROR_DATE, ERROR_STATUS )  
                                        values ('".$ERROR_TABLE."', '".$ERROR_TEXT."', '".$current_time."', '".$ERROR_STATUS."') "; 
                        // echo $sql_log;                    
                    $stm_log = sqlsrv_prepare ($ConnLog, $sql_log);
                    if (!$stm_log) {
                        throw new Exception("sql_log  Log#". $sql_log); 
                    }
                    if (!sqlsrv_execute($stm_log)) {
                        throw new Exception("sql_log นำเข้า Log ไม่สำเหร็จ#" . $sql_log);
                    }

            sqlsrv_commit($ConnLog);
        } catch (Exception $ex) {
            sqlsrv_close($ConnLog);
        }
    }

}

                
 ?>
	







