Viewing file: termConfig.php (2.96 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include("../include/class.mysqldb.php");
include("../include/config.inc.php");
function thai_date_fullmonth($time)
{ // 19 ธันวาคม 2556
$dayTH = array('อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์');
$monthTH = array(null, 'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม');
$monthTH_brev = array(null, 'ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.', 'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.', 'พ.ย.', 'ธ.ค.');
$thai_date_return = date("j", $time);
$thai_date_return .= " " . $monthTH_brev[date("n", $time)];
$thai_date_return .= " " . (date("Y", $time) + 543);
return $thai_date_return;
}
if($_REQUEST["action"] == "insertTmc"){
$sql = "INSERT INTO rg_TermConfig VALUES ('" . $_REQUEST["tmcAcY"] . "','" . $_REQUEST["tmcTmId"] . "','" . $_REQUEST["tmcFrDate"] . "','" . $_REQUEST["tmcToDate"] . "')";
$link->query($sql);
echo "Insert Success!!";
}
if($_REQUEST["action"] == "deleteTmc"){
$sql = "DELETE FROM rg_TermConfig WHERE tmcAcY = '" . $_REQUEST["tmcAcY"] . "' AND tmcTmId = '" . $_REQUEST["tmcTmId"] . "'";
$link->query($sql);
echo "Data deleted.";
}
if($_REQUEST["action"] == "getTmcById"){
$sql = "SELECT * FROM rg_TermConfig WHERE tmcAcY = '".$_REQUEST["tmcAcY"]."' AND tmcTmId = '".$_REQUEST["tmcTmId"]."'";
$link->query($sql);
echo json_encode($link->getnext());
}
if($_REQUEST["action"] == "getTmcAll"){
$sql = "SELECT * FROM rg_TermConfig rtmc
LEFT JOIN rg_Term rtm ON rtm.tmId = rtmc.tmcTmId
ORDER BY rtmc.tmcAcY Desc, rtmc.tmcTmId ASC";
$link->query($sql);
while($data = $link->getnext()){
$opt = "<button class='btn btn-primary btn-sm' data-toggle='modal' data-target='#editTmc' data-id='" . $data->tmcAcY . "' data-id2='" . $data->tmcTmId . "'>Edit</button>";
$opt .= " <button class='btn btn-danger btn-sm' data-toggle='modal' data-target='#modalDel' data-id='" . $data->tmcAcY . "' data-id2='" . $data->tmcTmId . "'>Del</button>";
$json["data"][] = array("tmcAcY"=>$data->tmcAcY,"tmName"=>$data->tmName,"tmcFrDate"=>thai_date_fullmonth(strtotime($data->tmcFrDate)),"tmcToDate"=>thai_date_fullmonth(strtotime($data->tmcToDate)), "opt"=>$opt);
}
echo json_encode($json);
}
if($_REQUEST["action"] == "updateTmc"){
$sql = "UPDATE rg_TermConfig SET tmcFrDate='" . $_REQUEST["tmcFrDate"] . "', tmcToDate='" . $_REQUEST["tmcToDate"] . "' WHERE tmcAcY = '".$_REQUEST["tmcAcY"]."' AND tmcTmId = '".$_REQUEST["tmcTmId"]."'";
$link->query($sql);
echo "Update Success!!";
}
?>
|