| Server IP : 182.53.201.61 / Your IP : 216.73.217.175 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/Menu_Dent/ |
Upload File : |
<?php session_start();
include('Connections/dbnurse.php');
if (isset($_POST['btest'])) {
if ($_POST['btest']=='ทดสอบ'){
$resp =false;
/*
//with cURL
$url = 'https://mophconnect.go.th/api/alert';//--URL
mysqli_select_db($dbnurse,$database_dbnurse);
$sql_userline = "select * FROM user_line WHERE cid= '{$_POST['testcid']}' ";
$userline = mysqli_query($dbnurse,$sql_userline ) or die(mysqli_error());
$row_ID = mysqli_fetch_assoc($userline);
$totalRows_ID = mysqli_num_rows($userline );
if($totalRows_ID > 0){
do {
$data = array(
'userId' => $row_ID['line_id'],
'hospitalName' => 'โรงพยาบาลสัตหีบ กม.10',
'origin' => $_POST['hmsg'],
'queueNumber' => 'งาน '.$_SESSION['DeptName'],
'patientName' => $row_ID['pname'],
'appointmentDate' => '2000-02-22',
'appointmentTime' => 'เวลา 00:00 น.',
'backgroundColor' => '#FFFFFF',
'header' => 'ทดสอบแจ้งเตือนนัด',
'detailsLink' => 'http://www.km10.org',
'detailsLinkLabel' => 'Link รพ.สัตหีบ กม.10',
'currentQueueLink' =>'https://liff.line.me/1655816791-Z4Wd4PMn?&cid='.$_POST['testcid'] ,
'currentQueueLinkLabel' => 'Link 2 thaimit.com'
);
$data_string = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
//curl_setopt($ch, CURLOPT_SSLVERSION, 'all');
curl_setopt($ch, CURLOPT_SSLVERSION, '1'); //for server2003
$result = curl_exec($ch);
if(curl_errno($ch)== 0)$resp =true;
sleep(2);
} while ($row_ID = mysqli_fetch_assoc($userline));
}
//end with cURL
*/
/**************************
with UDP SERVER ( MP_MSG.exe)
***************************/
//mysqli_select_db($dbnurse,$database_dbnurse);
$sql_userline = "SELECT * FROM register_mn WHERE P_ID ='".$_POST['testcid']."'";
$userline = mysqli_query($dbnurse,$sql_userline ) or die(mysqli_error());
$row_ID = mysqli_fetch_assoc($userline);
$totalRows_ID = mysqli_num_rows($userline );
if($totalRows_ID > 0){
do {
$data = array(
'userId' => $row_ID['P_ID'],
'hospitalName' => 'โรงพยาบาลสัตหีบ กม.10',
'origin' => $_POST['hmsg'],
'queueNumber' => 'งาน '.$_SESSION['DeptName'],
'patientName' => $row_ID['prefix'].$row_ID['name_th'].' '.$row_ID['lastname_th'],
'appointmentDate' => '2000-02-22',
'appointmentTime' => 'เวลา 00:00 น.',
'backgroundColor' => '#FFFFFF',
'header' => 'ทดสอบแจ้งเตือนนัด',
'detailsLink' => 'http://www.km10.org',
'detailsLinkLabel' => 'Link รพ.สัตหีบ กม.10',
'currentQueueLink' =>'https://liff.line.me/1655816791-Z4Wd4PMn?&cid='.$_POST['testcid'] ,
'currentQueueLinkLabel' => 'Link 2 thaimit.com'
);
$data_string = json_encode($data);
$LineMsg = 'MSGLGeneral#'.$data_string ;
if ($sock = socket_create(AF_INET, SOCK_DGRAM, 0)) {
Socket_set_option ($sock, SOL_SOCKET, SO_RCVTIMEO, Array ("sec" => 3, "usec" => 100));//Receive
Socket_set_option ($sock, SOL_SOCKET, SO_SNDTIMEO, Array ("sec" => 5, "usec" => 0));//Send
$server = '192.168.1.14';
$port = 8088;
$LineMsg = iconv( 'UTF-8','TIS-620', $LineMsg); //แปลงเป็น TIS-620 เพราะ MP_MSG เป็น window_app
if (socket_sendto($sock, $LineMsg , strlen($LineMsg) , 0 , $server , $port)) $resp=true;
#if (socket_sendto($sock, $input , strlen($LineMsg) , 0 , $server , $port))
#if (socket_recv ( $sock , $reply , 2045 , MSG_WAITALL ) )$rResult = $reply;
}
/*echo "<script> alert('".$LineMsg."');</script>"; */
sleep(2);
} while ($row_ID = mysqli_fetch_assoc($userline));
}
//end of UDP to MP_MSG
if ($resp) echo "<script> alert('ส่งข้อความแล้ว'); window.history.back();</script>";
else echo "<script> alert('ส่งข้อความไม่สำเร็จ'); window.history.back();</script>";
// window.history.go(-1);
}
}
$que_date=mysqli_real_escape_string($dbnurse,$_POST['max_qdate']);
$que_max=mysqli_real_escape_string($dbnurse,$_POST['max_q']);
$que_save ='N';
$holiday='N';
if (isset($_POST['max_qsave'])) if ($_POST['max_qsave'] == 1) $que_save ='Y';
if (isset($_POST['holiday'])) if ($_POST['holiday'] == 1) $holiday ='Y';
$monthNames = Array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม",
"สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
function chYear($find){return date("Y",strtotime($find))+543;}
$dd =date("j",strtotime($que_date)).' '.$monthNames[date("m",strtotime( $que_date )) - 1].' '.chYear($que_date);
?>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=1;">
<title>ระบบคิว<?php echo $_SESSION['DeptName']; ?></title>
<link rel="shortcut icon" href="jquerymobile/demos/favicon.ico">
<link rel="stylesheet" href="jquerymobile/demos/css/themes/default/jquery.mobile-1.4.5.min.css">
<link rel="stylesheet" href="jquerymobile/demos/_assets/css/jqm-demos.css">
<script src="jquerymobile/demos/js/jquery.js"></script>
<script src="jquerymobile/demos/_assets/js/index.js"></script>
<script src="jquerymobile/demos/js/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<center>
<div data-role="page" data-dialog="true" >
<div data-role="header" data-theme="z" data-overlay-theme="e" ><br>
<?php include ("que_logo.php"); ?>
<table border="0" width =95%>
<tr>
<td ><font color="blue">
<?php
$tbl="que_max";
if ($que_save =='Y') {
$sql_chkque = "Delete FROM ".$tbl." WHERE date = '2000-02-22' AND clinic='{$_SESSION['Dept']}' ";
$chkque = mysqli_query( $dbnurse,$sql_chkque) or die(mysqli_error());
$insertSQL=" INSERT INTO ".$tbl." (date,clinic,max_que,dateset)VALUES('2000-02-22','{$_SESSION['Dept']}','{$que_max}',now())" ;
$Result1 = mysqli_query( $dbnurse,$insertSQL) or die(mysqli_error());
}
//-- Save message
$sql_chkque = "Delete FROM message WHERE clinic='{$_SESSION['Dept']}' ";
$chkque = mysqli_query( $dbnurse,$sql_chkque) or die(mysqli_error());
$insertSQL=" INSERT INTO message (clinic,header)VALUES('{$_SESSION['Dept']}','{$_POST['hmsg']}')" ;
//echo $insertSQL.'<br>';
$Result1 = mysqli_query( $dbnurse,$insertSQL) or die(mysqli_error());
//-----
//$sql_chkque = "Delete FROM ".$tbl." WHERE DATE(date) = '{$que_date}' AND clinic='{$_SESSION['Dept']}' ";
//$chkque = mysqli_query( $dbnurse,$sql_chkque) or die(mysqli_error());
$insertSQL=" INSERT INTO ".$tbl." (date,clinic,max_que,dateset)VALUES('{$que_date}','{$_SESSION['Dept']}','{$que_max}',now())" ;
$Result1 = mysqli_query( $dbnurse,$insertSQL) or die(mysqli_error());
//echo $insertSQL.'<br>';
//$thisday=time();
//if (date('Y-m-d', strtotime('+1 day', $thisday)) == $que_date){
if (date('Y-m-d') == $que_date){
//--- update Mit-Net h_serv.dbf
if ($_SESSION['Dept'] == 'DENT') $deptcode = 'IN03000';
else $deptcode = 'IN00099';
$DbfSys = odbc_connect ('mit','', '') or die('Could Not Connect to ODBC Database!');
date_default_timezone_set("Asia/Bangkok");
$strsql ="UPDATE h_serv.dbf SET credit={$que_max} where code ='{$deptcode}' ";
$objExec = odbc_exec($DbfSys, $strsql) or die (odbc_errormsg());
odbc_free_result($objExec);
$strsql ="select credit from h_serv.dbf where code ='{$deptcode}' ";
$objExec = odbc_exec($DbfSys, $strsql) or die (odbc_errormsg());
if ($que_max == odbc_result($objExec,1)) echo "<center><font color='purple'><br>
<h3>แก้ไขจำนวนคิววันนี้แล้ว!!</h3></font> <br>";
else echo "<center><font color='red'><br><h3>แก้ไขจำนวนคิวไม่สำเร็จ!!</h3></font> <br>";
odbc_free_result($objExec);
odbc_close($DbfSys);
}
echo "<center><font color='blue'><br>บันทึกจำนวนคิวแล้ว</font> <br>
ระบบคิว".$_SESSION['DeptName']."<br> <font color='#ff9900'><h1> ".$dd."</h1>
<h3>จำนวนคิวที่รับได้ ".$que_max."<br>";
if ($que_save =='Y') echo "<font color=' #0099ff'><br>และบันทึกเป็นค่าปกติด้วย</font> <br>";
$holiday_start = strtotime('2026-01-05');
$que_date_timestamp = strtotime($que_date);
if ($que_date_timestamp >= $holiday_start) {
$sql_auto_holiday = "SELECT * FROM holiday WHERE DATE(date) = '{$que_date}' LIMIT 1";
$chk_auto_holiday = mysqli_query($dbnurse, $sql_auto_holiday) or die(mysqli_error());
$total_auto = mysqli_num_rows($chk_auto_holiday);
if ($total_auto == 0) {
$insert_auto = "INSERT INTO holiday (date) VALUES ('{$que_date}')";
mysqli_query($dbnurse, $insert_auto) or die(mysqli_error());
echo "<font color='#00cc00'><br>ระบบได้บันทึกวันหยุดอัตโนมัติสำหรับวันที่ {$que_date}</font><br>";
}
}
$sql_chkque = "SELECT * FROM holiday WHERE DATE(date) = '{$que_date}' limit 1"; //HOLIDAY
$chkque = mysqli_query( $dbnurse,$sql_chkque) or die(mysqli_error());
$row_chkque = mysqli_fetch_assoc($chkque);
$totalRows = mysqli_num_rows($chkque);
if ($totalRows ==1) {
if ($holiday =='N') {
$insertSQL=" DELETE FROM holiday where date = '{$que_date}'" ;
$Result1 = mysqli_query( $dbnurse,$insertSQL) or die(mysqli_error());
echo "<font color=' #0099ff'><br>และยกเลิกวันหยุดด้วย</font> <br>";
}
} else {
if ($holiday =='Y') {
$insertSQL=" INSERT INTO holiday (date) VALUES ('{$que_date}')" ;
$Result1 = mysqli_query( $dbnurse,$insertSQL) or die(mysqli_error());
echo "<font color=' #0099ff'><br>และบันทึกเป็นวันหยุดด้วย</font> <br>";
}
}
echo "</h3></font><br>";
?>
<a href="que_calendar.php?Setup=Y" data-role="button" data-theme="b" data-ajax="false">กำหนดค่าวันอื่น</a></font>
</td>
</tr>
</table>
</div></div></center>
</body>
</html>