include "../admin/etc/lib.loginCheck.php" ?>
############ ±âº»°ª ·Îµù ######################
$ROOT = "../admin/";
require $ROOT."etc/config.cfg.php";
require $ROOT."etc/lib.general.php";
require $ROOT."db/open_DB.class.php";
$dbb = new main_DB;
$sh = new main_DB;
$shh = new main_DB;
$db = new main_DB;
$m1 = new main_DB;
$us = new open_DB;
$dbt = new open_DB;
$s2 = new sms2_DB;
$today = date("Ymd", time());
$a = "select user_tel1 from ${MID}_user where user_id = '$UID'";
$dbt -> query($a);
$dbt -> next_record();
if($tflag=="")$tflag="0";
$user_tel = $dbt -> f("user_tel1");
//echo strlen($user_tel)."|".$user_tel;
//--------------- ÀúÀåµÈ ÀüȹøÈ£ ±æÀÌ¿¡ µû¶ó ÀÚ¸£±â.... -----------//
if(strlen($user_tel) == 10){ // 000-123-1234
$tel1 = substr($user_tel,0,3);
$tel2 = substr($user_tel,3,3);
$tel3 = substr($user_tel,6,4);
}else{ // 000-1234-1234
$tel1 = substr($user_tel,0,3);
$tel2 = substr($user_tel,3,4);
$tel3 = substr($user_tel,7,4);
}
$dbt -> free();
if($goMode == "MODIFY"){
$q = "select seq_no, user_id, user_name, title, contents, reg_date, proc_date, tflag from tbl_schedule where seq_no = ${seq_no} ORDER BY seq_no DESC";
$sh -> query($q);
$sh -> next_record();
$seq_no = $sh -> f("seq_no");
$user_id = $sh -> f("user_id");
$user_name = $sh -> f("user_name");
$title = $sh -> f("title");
$contents = $sh -> f("contents");
$reg_date = $sh -> f("reg_date");
$tflag = $sh -> f("tflag");
}
if($goMode == "MODIFY" || $goMode == ""){
?>
ÀÏÁ¤µî·Ï
if($day_now == "")
$day_now = date('Ymd')
?>
}else if($goMode == "LIST"){
?>
ÀÏÁ¤¸ñ·Ï
|
|
}
if($goMode == "INSERT") {
if($hour != "" AND $minute != "" AND $tel_1 != "" AND $tel_2 != "" AND $tel_3 != "") {
$sflag = "Y";
} else {
$sflag = "N";
}
$sms_date = $sms_day.$hour.$minute."00";
$tableName = "tbl_schedule";
$subject = addslashes($iljung_subject);
$content = addslashes($iljung_content);
$reg_date = $iljung_date;
$fieldName = array("agentcode", "agentname", "user_id", "user_name", "title", "contents", "reg_date", "proc_date", "sflag", "tflag");
$valueName = array($MID, $MNM, $UID, $UNM, $subject, $content, $reg_date, $today, $sflag, $tflag);
$dbb -> insert($tableName,$fieldName,$valueName);
$dbb -> free();
if($sflag == "Y") {
$q = "SELECT sms_use, sms_notuse FROM tbl_agentlist WHERE agentcode = '${MID}'";
$m1 -> query($q);
$m1 -> next_record();
$sms_notuse = $m1 -> f("sms_notuse");
if($sms_notuse - 1 < 0) {
?>
exit;
}
$send_time = dateFormat($sms_day, "-")." ".$hour.":".$minute.":00";
$tel_total = $tel_1.$tel_2.$tel_3; //³ª´²Áø¹øÈ£ ÇÕÄ¡±â
//------------------- SMSº¸³»´Â°÷ ½ÃÀÛ --------------------------------->
/*
$dbTableName = "smslist";
$fieldNames = "";
$fieldValue = "";
$tel_total = $tel_1.$tel_2.$tel_3; //³ª´²Áø¹øÈ£ ÇÕÄ¡±â
$fieldNames[0] = "from_num"; //º¸³»´Â¹øÈ£
$fieldNames[1] = "to_num"; //¹Þ´Â¹øÈ£
$fieldNames[2] = "msg"; //º¸³»´Â³»¿ë
$fieldNames[3] = "rsv_time"; //º¸³»´Â½Ã°£
$fieldNames[4] = "agentcode"; //´ë¸®Á¡¾ÆÀ̵ð
$fieldNames[5] = "proc_id"; //º¸³»´Â»ç¶÷¾ÆÀ̵ð
// $rsv_time = date("YmdHis", time());
// $rsv_time = "0000"; //¿¹¾àÀü¼ÛÀº YYYYMMDDHHMISS ÇüÅ·ΠÀÔ·Â, Áï½Ã´Â 0000
$fieldValue[0] = $tel_total;
$fieldValue[1] = $tel_total;
$fieldValue[2] = $subject;
$fieldValue[3] = $sms_date;
$fieldValue[4] = $MID;
$fieldValue[5] = $UID;
// echo($sh -> getInsQuery($dbTableName,$fieldNames,$fieldValue)."
");
$sh -> insert($dbTableName,$fieldNames,$fieldValue);
$sh -> free();
*/
$q = "SELECT MAX(RIGHT(cmid, 6)) FROM uds_msg"; //¾Õ8ÀÚ¸®·Î »ý¼ºµÈ ÃÖ´ë ·ÎÆ®¹øÈ£ °¡Á®¿À±â
$q = $q." WHERE LEFT(cmid, 8) = '${sms_day}'";
$s2 -> query($q);
if($s2 -> next_record()) {
if(substr($s2 -> f(0), 0, 1) > 0) {
$new_num = $s2 -> f(0) + 1;
} else {
$new_num = 100000 + $s2 -> f(0) + 1;
}
} else {
$new_num = 100001;
}
$cmid = $sms_day.$new_num;
$q = "INSERT INTO uds_msg";
$q = $q." (msg_type, cmid, request_time, send_time, dest_phone, dest_name,";
$q = $q." send_phone, msg_body, etc1, etc2, whereis)";
$q = $q." VALUES (0, $cmid, now(), '$send_time', '$tel_total', 'TELKIT',";
$q = $q." '$tel_total', '$subject', '$MID', '$UID', 'TELKIT')";
// echo($q);
$s2 -> query($q);
//------------------- SMSº¸³»´Â°÷ ³¡ --------------------------------->
$q = "UPDATE tbl_agentlist SET sms_use = sms_use + 1, sms_notuse = sms_notuse - 1";
$q = $q." WHERE agentcode = '$MID'";
$m1 -> query($q);
}
?>
} else if($goMode == "EDIT") {
$tableName = "tbl_schedule";
if($hour != "" AND $minute != "" AND $tel_1 != "" AND $tel_2 != "" AND $tel_3 != "") {
$sflag = "Y";
} else {
$sflag = "N";
}
$subject = addslashes($iljung_subject);
$content = addslashes($iljung_content);
$reg_date = $iljung_date;
$fieldName = array("title", "contents", "reg_date", "proc_date", "sflag", "tflag");
$valueName = array($subject, $content, $reg_date, $today, $sflag, $tflag);
$dbWhere = "seq_no = $seq_no";
$db -> update($tableName,$fieldName,$valueName,$dbWhere);
if($sflag == "Y"){
$q = "SELECT sms_use, sms_notuse FROM tbl_agentlist WHERE agentcode = '${MID}'";
$m1 -> query($q);
$m1 -> next_record();
$sms_notuse = $m1 -> f("sms_notuse");
if($sms_notuse - 1 < 0) {
?>
exit;
}
$send_time = dateFormat($sms_day, "-")." ".$hour.":".$minute.":00";
$tel_total = $tel_1.$tel_2.$tel_3; //³ª´²Áø¹øÈ£ ÇÕÄ¡±â
//------------------- SMSº¸³»´Â°÷ ½ÃÀÛ --------------------------------->
/*
$dbTableName = "smslist";
$fieldNames = "";
$fieldValue = "";
$tel_total = $tel_1.$tel_2.$tel_3; //³ª´²Áø¹øÈ£ ÇÕÄ¡±â
$sms_date = $sms_day.$hour.$minute."00";
$fieldNames[0] = "from_num"; //º¸³»´Â¹øÈ£
$fieldNames[1] = "to_num"; //¹Þ´Â¹øÈ£
$fieldNames[2] = "msg"; //º¸³»´Â³»¿ë
$fieldNames[3] = "rsv_time"; //º¸³»´Â½Ã°£
$fieldNames[4] = "agentcode"; //´ë¸®Á¡¾ÆÀ̵ð
$fieldNames[5] = "proc_id"; //º¸³»´Â»ç¶÷¾ÆÀ̵ð
// $rsv_time = date("YmdHis", time());
// $rsv_time = "0000"; //¿¹¾àÀü¼ÛÀº YYYYMMDDHHMISS ÇüÅ·ΠÀÔ·Â, Áï½Ã´Â 0000
$fieldValue[0] = $tel_total;
$fieldValue[1] = $tel_total;
$fieldValue[2] = $subject;
$fieldValue[3] = $sms_date;
$fieldValue[4] = $MID;
$fieldValue[5] = $UID;
// echo($sh -> getInsQuery($dbTableName,$fieldNames,$fieldValue)."
");
$sh -> insert($dbTableName,$fieldNames,$fieldValue);
*/
$q = "INSERT INTO uds_msg";
$q = $q." (msg_type, cmid, request_time, send_time, dest_phone, dest_name,";
$q = $q." send_phone, msg_body, etc1, etc2, whereis)";
$q = $q." VALUES (0, now()+0, now(), '$send_time', '$tel_total', 'TELKIT',";
$q = $q." '$tel_total', '$subject', '$MID', '$UID', 'TELKIT')";
// echo($q);
$s2 -> query($q);
//------------------- SMSº¸³»´Â°÷ ³¡ --------------------------------->
$q = "UPDATE tbl_agentlist SET sms_use = sms_use + 1, sms_notuse = sms_notuse - 1";
$q = $q." WHERE agentcode = '$MID'";
$m1 -> query($q);
}
?>
} else if($goMode == "DEL") {
$q = "DELETE FROM tbl_schedule WHERE seq_no = $seq_no";
$shh->query($q);
$shh -> free();
?>
// echo("");
exit;
}
?>