You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
4.5 KiB
104 lines
4.5 KiB
<?php
|
|
include "header.php";
|
|
|
|
if (isset($_POST['update'])) {
|
|
foreach ($_POST as $k => $v) {
|
|
$$k = htmlspecialchars(stripslashes(trim($v)));
|
|
}
|
|
//print_r($_POST);exit;
|
|
|
|
// 僅限發起人有權限編輯
|
|
if ($creater != $user_id) {
|
|
echo "<script type='text/JavaScript'>";
|
|
echo "alert('無修改權限!');";
|
|
echo "history.go(-1);";
|
|
echo "</script>";
|
|
}
|
|
|
|
// 發信名單
|
|
/*
|
|
$mail_list = [];
|
|
// 與會人員名單:$attend_all
|
|
// 會議發起人也發系統通知及會議通知:$notice_list
|
|
if ($attend_all) {
|
|
$pos = strpos($attend_all, $user_id);
|
|
if ($pos === false) $notice_list = $attend_all.",".$user_id;
|
|
else $notice_list = $attend_all;
|
|
$notice_list_str = str_replace(",", "','", $notice_list);
|
|
$sql = "select name, email from account where accountid in ('$notice_list_str')";
|
|
$res = mysqli_query($link, $sql);
|
|
$mail_list = mysqli_fetch_all($res);
|
|
mysqli_free_result($res);
|
|
}
|
|
*/
|
|
|
|
// 會議時間是否重覆
|
|
$check_sdate = $mdate." ".$stime;
|
|
$check_edate = $mdate." ".$etime;
|
|
$db_query = "select count(*) from meeting where ( ";
|
|
$db_query .= "('$check_edate' >= concat(mdate, ' ', stime) && '$check_edate' <= concat(mdate, ' ', etime)) or ";
|
|
$db_query .= "('$check_sdate' >= concat(mdate, ' ', stime) && '$check_sdate' <= concat(mdate, ' ', etime))) and room = '$room' and status = 'Y' and id <> '$id'";
|
|
$result = mysqli_query($link, $db_query);
|
|
$row = mysqli_fetch_row($result);
|
|
if ($row[0] > 0) {
|
|
echo "<script type='text/JavaScript'>";
|
|
echo "alert('無法建立此會議,請確認會議時間是否衝突或會議室是否已有人預訂。');";
|
|
echo "history.go(-1);";
|
|
echo "</script>";
|
|
} else {
|
|
$mail_list = [];
|
|
// 原先與會人員
|
|
$db_query = "select attend from meeting where id = '$id'";
|
|
$res = mysqli_query($link, $db_query);
|
|
$row_a = mysqli_fetch_assoc($res);
|
|
$attend_all_ori = $row_a["attend"];
|
|
mysqli_free_result($res);
|
|
$attend_all_new = $attend_all.",".$attend_all_ori;
|
|
$pos = strpos($attend_all_new, $creater);
|
|
if ($pos === false) $notice_list = $attend_all_new.",".$creater;
|
|
else $notice_list = $attend_all_new;
|
|
$notice_list_arr = explode(",", $notice_list);
|
|
$notice_all_arr = array_unique($notice_list_arr); // 需要通知的人員
|
|
$notice_all = implode(",", $notice_all_arr);
|
|
$notice_all_str = implode("','", $notice_all_arr);
|
|
$sql = "select name, email from account where accountid in ('$notice_all_str')";
|
|
$res = mysqli_query($link, $sql);
|
|
$mail_list = mysqli_fetch_all($res);
|
|
mysqli_free_result($res);
|
|
|
|
// 更新會議資料
|
|
$db_query = "update meeting set title = '$title', mdate = '$mdate', stime = '$stime', etime = '$etime', room = '$room', content = '$content', ";
|
|
$db_query .= "equip = '$equip', attend = '$attend_all', create_at = '$create_at' ";
|
|
$db_query .= "where id = '$id'";
|
|
$res = mysqli_query($link, $db_query);
|
|
|
|
// 通知列表
|
|
if ($notice_all) {
|
|
$title_notice = "[會議異動]".$title;
|
|
$db_query = "insert into notice (kind, related_id, title, content, permission, creater, create_at) values (";
|
|
$db_query .= "'2', '$id', '$title_notice', '$content', '$notice_all', '$creater', '$create_at')";
|
|
$res = mysqli_query($link, $db_query);
|
|
|
|
// 寫入行事曆/會議:橘色
|
|
$db_query = "delete from events where related_id = '$id'";
|
|
$res = mysqli_query($link, $db_query);
|
|
foreach ($notice_all_arr as $accountid) {
|
|
$sql = "insert into events (related_id, accountid, title, description, color, date) values ('$id', '$accountid', '$title.', '$content', '#FF5809', '$check_sdate')";
|
|
$res = mysqli_query($link, $sql);
|
|
}
|
|
|
|
// 發信
|
|
include "class/Cmail.php";
|
|
$sendmail = new Cmail;
|
|
$sendmail->sendx($title_notice, $content, $mail_list);
|
|
}
|
|
|
|
mysqli_close($link);
|
|
|
|
echo "<script type ='text/JavaScript'>";
|
|
echo "alert('修改成功');";
|
|
echo "location.href='meeting-index.php?function_name=meeting&token=".$token."';";
|
|
echo "</script>";
|
|
}
|
|
}
|
|
?>
|