function booking_table($jbi_sn = "", $getdate = "") { global $xoopsDB, $xoopsTpl, $xoopsUser, $xoopsModuleConfig, $can_booking, $Isapproval; $uid = !empty($xoopsUser) ? $xoopsUser->uid() : ""; //場地設定 $item_opt = get_jill_booking_time_options($jbi_sn); if (!empty($jbi_sn)) { //可啟用場地資訊 $itemArr = get_jill_booking_item($jbi_sn, 1); $jbi_sn = empty($itemArr['jbi_sn']) ? "" : $itemArr['jbi_sn']; if (!empty($itemArr)) { //場地預約起始日期 $start = strtotime($itemArr['jbi_start']); $now = strtotime(date('Y-m-d')); $start = $start <= $now ? $now : $start; //設定可預約之週數及日期 $max_bookingweek = $xoopsModuleConfig['max_bookingweek']; //$show_range = date("Y-m-d", strtotime("+$max_bookingweek week")); if (empty($max_bookingweek)) { //場地預約結束日期 $end = $itemArr['jbi_end'] == '0000-00-00' ? 0 : strtotime($itemArr['jbi_end']); } else { $endtime = strtotime("+{$max_bookingweek} week"); if ($itemArr['jbi_end'] == '0000-00-00') { $end = $endtime; } else { $end = strtotime($itemArr['jbi_end']) >= $endtime ? $endtime : strtotime($itemArr['jbi_end']); } } //時段資訊 $timeArr = get_bookingtime_jbisn($jbi_sn); $xoopsTpl->assign('timeArr', $timeArr); //週曆 $getdate = empty($getdate) ? date("Y-m-d") : $getdate; $weekArr = weekArr($getdate); //產生預約者資訊表格狀態值 $bookingArr = ""; //比對產生表單的陣列 foreach ($timeArr as $t => $time) { $jbt_week = strval($time['jbt_week']); foreach ($weekArr as $wk => $weekinfo) { //預約日期 $item_date = strtotime($weekinfo['d']); //預約者資訊 $jbArr = get_booking_uid($time['jbt_sn'], $weekinfo['d']); //取得用了該日期時段的所有者 $usershtml = booking_users($time['jbt_sn'], $weekinfo['d']); //將 uid 編號轉換成使用者姓名(或帳號) $uid_name = XoopsUser::getUnameFromId($jbArr['jb_uid'], 1); if (empty($uid_name)) { $uid_name = XoopsUser::getUnameFromId($jbArr['jb_uid'], 0); } $uid_name = empty($jbArr['jb_status']) ? _MD_APPROVING . ":{$uid_name}" : $uid_name; $color = "transparent"; $content = $status = ""; //過去預約 if ($start > $item_date) { if (!empty($jbArr['jb_uid'])) { $content = $uid_name; $color = "#959595"; } } elseif ($start <= $item_date and $end >= $item_date or $end == 0) { //可預約期間 if (strpos($jbt_week, strval($wk)) !== false) { if (empty($jbArr['jb_sn'])) { if ($can_booking) { $content = ""; $status['func'] = "single_insert_booking"; $status['time'] = $time['jbt_sn']; $status['weekinfo'] = $weekinfo['d']; $status['jbi_sn'] = $jbi_sn; } else { $content = _MD_JILLBOOKIN_NO; $color = "#959595"; } } else { if ($uid == $jbArr['jb_uid'] or $Isapproval) { $content = delete_booking_icon($t, $wk, $time['jbt_sn'], $weekinfo['d'], $jbi_sn) . $usershtml; $color = "#000000"; } else { $content = "{$uid_name}{$usershtml}"; $color = "#000000"; } } } } $bookingArr[$t][$wk]['color'] = $color; $bookingArr[$t][$wk]['status'] = $status; $bookingArr[$t][$wk]['content'] = $content; } } $xoopsTpl->assign('bookingArr', $bookingArr); $xoopsTpl->assign('itemArr', $itemArr); $xoopsTpl->assign('weekArr', $weekArr); //die(var_export($bookingArr)); } } $xoopsTpl->assign('jbi_sn', $jbi_sn); $xoopsTpl->assign('item_opt', $item_opt); $xoopsTpl->assign('now_op', "booking_table"); $xoopsTpl->assign('action', $_SERVER['PHP_SELF']); }
function jill_booking_form($jbi_sn = "") { global $xoopsDB, $xoopsTpl, $xoopsModuleConfig; //場地設定 $item_opt = get_jill_booking_time_options($jbi_sn); if (!empty($jbi_sn)) { //場地資訊 $itemArr = get_jill_booking_item($jbi_sn, 1); $xoopsTpl->assign('itemArr', $itemArr); // array ('jbi_sn' => '2','jbi_title' =>'多功能教室','jbi_desc' => '<p>多功能教室多功能教室</p>','jbi_sort' => '1','jbi_start' => '2015-01-28','jbi_end' => '0000-00-00','jbi_enable' => '1','jbi_approval' => '0',) //die(var_export($itemArr)); //預設值設定 //設定 jb_booking_content 欄位的預設值 $xoopsTpl->assign('jb_booking_content', ""); //設定 jb_start_date 欄位的預設值 $jb_start_date = strtotime($itemArr['jbi_start']) <= strtotime(date("Y-m-d")) ? date("Y-m-d") : $itemArr['jbi_start']; $xoopsTpl->assign('jb_start_date', $jb_start_date); //設定 jb_end_date 欄位的預設值 $xoopsTpl->assign('jb_end_date', $jb_start_date); //設定可預約之週數及日期 $max_bookingweek = $xoopsModuleConfig['max_bookingweek']; //$show_range = date("Y-m-d", strtotime("+$max_bookingweek week")); if (empty($max_bookingweek)) { //場地預約結束日期 $end = $itemArr['jbi_end'] == '0000-00-00' ? 0 : strtotime($itemArr['jbi_end']); $max_date = $end == 0 ? '' : $itemArr['jbi_end']; } else { $endtime = strtotime("+{$max_bookingweek} week"); if ($itemArr['jbi_end'] == '0000-00-00') { $end = $endtime; } else { $end = strtotime($itemArr['jbi_end']) >= $endtime ? $endtime : strtotime($itemArr['jbi_end']); } $max_date = date("Y-m-d", $end); } //die($max_date); $xoopsTpl->assign('max_date', $max_date); //時段資訊 $timeArr = get_bookingtime_jbisn($jbi_sn); $xoopsTpl->assign('timeArr', $timeArr); //die(var_export($timeArr)); $weektime = ""; foreach ($timeArr as $t => $time) { for ($w = 0; $w < 7; $w++) { $jbt_sn = $time['jbt_sn']; $jbt_week = strval($time['jbt_week']); $weektime[$t][$w]['jbt_week'] = strpos($jbt_week, strval($w)) !== false ? "<input type='checkbox' name='jb_week[{$jbt_sn}][]' value='{$w}' >" : "<span style='color:#D44950'><i class='fa fa-times'></i></span>"; } } //die(var_export($weektime)); //套用formValidator驗證機制 if (!file_exists(TADTOOLS_PATH . "/formValidator.php")) { redirect_header("index.php", 3, _TAD_NEED_TADTOOLS); } include_once TADTOOLS_PATH . "/formValidator.php"; $formValidator = new formValidator("#myForm", true); $formValidator_code = $formValidator->render(); //加入Token安全機制 include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; $token = new XoopsFormHiddenToken(); $token_form = $token->render(); $xoopsTpl->assign("token_form", $token_form); $xoopsTpl->assign('formValidator_code', $formValidator_code); $xoopsTpl->assign('weektime', $weektime); $xoopsTpl->assign('next_op', "insert_jill_booking"); } $xoopsTpl->assign('item_opt', $item_opt); $xoopsTpl->assign('now_op', 'jill_booking_form'); $xoopsTpl->assign('action', $_SERVER["PHP_SELF"]); }