Exemplo n.º 1
0
function update_jb_status($jb_sn = "", $jb_date = "", $jbt_sn = "", $jbi_sn = "")
{
    global $xoopsDB, $xoopsTpl, $xoopsUser, $isAdmin;
    $uid = $xoopsUser->uid();
    $itemArr = get_jill_booking_item($jbi_sn, 1);
    $checkapproval = explode(";", $itemArr['jbi_approval']);
    if (in_array($uid, $checkapproval)) {
        $sql = "update `" . $xoopsDB->prefix("jill_booking_date") . "` set\n                `jb_status` = '1'\n                where `jb_sn` = '{$jb_sn}' && `jb_date`='{$jb_date}' && `jbt_sn`='{$jbt_sn}' ";
        //die($sql);
        $xoopsDB->queryF($sql) or die('0');
    }
    die('1');
}
Exemplo n.º 2
0
function jbi_approval_form($jbi_sn = "")
{
    global $xoopsDB, $xoopsTpl;
    if (empty($jbi_sn)) {
        redirect_header("main.php", 3, "無此場地。");
    }
    $DBV = get_jill_booking_item($jbi_sn);
    if (empty($DBV)) {
        redirect_header("main.php", 3, "無此場地。");
    }
    //設定 jbi_approval 欄位的預設值
    $xoopsTpl->assign('approval', (int) $DBV['jbi_approval']);
    $op = "save_jbi_approval";
    $sql = "select `uid`,`name`,`uname` from `" . $xoopsDB->prefix("users") . "` order by `uname` ";
    $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
    $all_content = "";
    $all_content2 = "";
    $i = 0;
    while (list($uid, $name, $uname) = $xoopsDB->fetchRow($result)) {
        $jbi_approvalArr = explode(";", $DBV['jbi_approval']);
        if (in_array($uid, $jbi_approvalArr)) {
            $all_content2[$i]['uid'] = $uid;
            $all_content2[$i]['name'] = $name;
            $all_content2[$i]['uname'] = $uname;
        } else {
            $all_content[$i]['uid'] = $uid;
            $all_content[$i]['name'] = $name;
            $all_content[$i]['uname'] = $uname;
        }
        $i++;
    }
    //加入Token安全機制
    include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
    $token = new XoopsFormHiddenToken();
    $token_form = $token->render();
    $xoopsTpl->assign("token_form", $token_form);
    $xoopsTpl->assign('action', $_SERVER["PHP_SELF"]);
    $xoopsTpl->assign('all_content', $all_content);
    $xoopsTpl->assign('all_content2', $all_content2);
    $xoopsTpl->assign('jbi_title', sprintf(_MA_JILLBOOKIN_APPROVAL, $DBV['jbi_title']));
    $xoopsTpl->assign('jbi_sn', $jbi_sn);
    $xoopsTpl->assign('now_op', 'jbi_approval_form');
    $xoopsTpl->assign('jbi_approval', $DBV['jbi_approval']);
    $xoopsTpl->assign('next_op', $op);
}
Exemplo n.º 3
0
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']);
}
Exemplo n.º 4
0
function insert_jill_booking_date($jb_sn = "", $single = "", $jbi_sn = "")
{
    global $xoopsDB, $xoopsUser;
    if (empty($jb_sn)) {
        return;
    }
    $itemArr = get_jill_booking_item($jbi_sn, 1);
    $myts =& MyTextSanitizer::getInstance();
    //$_POST['jb_date']=$myts->addSlashes($_POST['jb_date']);
    //die(var_export($_POST['jb_date']));
    $jb_status = empty($itemArr['jbi_approval']) ? 1 : 0;
    //新增到jill_booking_date
    if ($single == 1) {
        $jb_waiting = jb_waiting_max_sort($jb_date, $_POST['jbt_sn']);
        $sql = "insert into `" . $xoopsDB->prefix("jill_booking_date") . "`\n      (`jb_sn` , `jb_date` , `jbt_sn` , `jb_waiting`,`jb_status`)\n      values('{$jb_sn}' , '{$_POST['jb_date']}' , '{$_POST['jbt_sn']}' , '{$jb_waiting}','{$jb_status}')";
        $xoopsDB->queryF($sql) or redirect_header($_SERVER['PHP_SELF'], 3, $sql);
        //return $xoopsUser->name();
    } else {
        foreach ($_POST['jb_date'] as $jbt_sn => $dateArr) {
            foreach ($dateArr as $jb_date) {
                $jb_waiting = jb_waiting_max_sort($jb_date, $jbt_sn);
                $sql = "insert into `" . $xoopsDB->prefix("jill_booking_date") . "`\n          (`jb_sn` , `jb_date` , `jbt_sn` , `jb_waiting`,`jb_status`)\n          values('{$jb_sn}' , '{$jb_date}' , '{$jbt_sn}' , '{$jb_waiting}','{$jb_status}')";
                $xoopsDB->queryF($sql) or redirect_header($_SERVER['PHP_SELF'], 3, $sql);
            }
        }
        return $_POST['jbi_sn'];
    }
}
Exemplo n.º 5
0
function jill_booking_item_form($jbi_sn = "")
{
    global $xoopsDB, $xoopsTpl;
    //抓取預設值
    if (!empty($jbi_sn)) {
        $DBV = get_jill_booking_item($jbi_sn);
    } else {
        $DBV = array();
    }
    //預設值設定
    $myts =& MyTextSanitizer::getInstance();
    //設定 jbi_sn 欄位的預設值
    $jbi_sn = !isset($DBV['jbi_sn']) ? $jbi_sn : $DBV['jbi_sn'];
    $xoopsTpl->assign('jbi_sn', $jbi_sn);
    //設定 jbi_start 欄位的預設值
    $jbi_start = !isset($DBV['jbi_start']) ? date("Y-m-d") : $DBV['jbi_start'];
    $yesterday = date("Y-m-d", strtotime('-1 day'));
    $xoopsTpl->assign('jbi_start', $jbi_start);
    $xoopsTpl->assign('yesterday', $yesterday);
    //設定 jbi_end 欄位的預設值
    $jbi_end = !isset($DBV['jbi_end']) ? "" : $DBV['jbi_end'];
    $xoopsTpl->assign('jbi_end', $jbi_end);
    //設定 jbi_title 欄位的預設值
    $jbi_title = !isset($DBV['jbi_title']) ? "" : $DBV['jbi_title'];
    $xoopsTpl->assign('jbi_title', $jbi_title);
    //設定 jbi_desc 欄位的預設值
    $jbi_desc = !isset($DBV['jbi_desc']) ? "" : $myts->displayTarea($DBV['jbi_desc'], $html = 1, $smiley = 1, $xcode = 1, $image = 1, $br = 0);
    if (!file_exists(TADTOOLS_PATH . "/ck.php")) {
        redirect_header("index.php", 3, _MD_NEED_TADTOOLS);
    }
    include_once TADTOOLS_PATH . "/ck.php";
    $Editor = new CKEditor("jill_booking", "jbi_desc", $jbi_desc);
    $Editor->setToolbarSet('myBasic');
    $Editor_code = $Editor->render();
    $xoopsTpl->assign('Editor_code', $Editor_code);
    //設定 jbi_approval 欄位的預設值
    $jbi_approval = !isset($DBV['jbi_approval']) ? "0" : $DBV['jbi_approval'];
    $xoopsTpl->assign('jbi_approval', $jbi_approval);
    //設定 jbi_sort 欄位的預設值
    $jbi_sort = !isset($DBV['jbi_sort']) ? jill_booking_item_max_sort() : $DBV['jbi_sort'];
    $xoopsTpl->assign('jbi_sort', $jbi_sort);
    //設定 jbi_enable 欄位的預設值
    $jbi_enable = !isset($DBV['jbi_enable']) ? "1" : $DBV['jbi_enable'];
    $xoopsTpl->assign('jbi_enable', $jbi_enable);
    $op = empty($jbi_sn) ? "insert_jill_booking_item" : "update_jill_booking_item";
    //$op="replace_jill_booking_item";
    //套用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('action', $_SERVER["PHP_SELF"]);
    $xoopsTpl->assign('formValidator_code', $formValidator_code);
    $xoopsTpl->assign('now_op', 'jill_booking_item_form');
    $xoopsTpl->assign('next_op', $op);
}
Exemplo n.º 6
0
function list_jill_booking($jb_sn = "", $jbi_sn = "")
{
    global $xoopsDB, $xoopsTpl;
    if (empty($jb_sn)) {
        return;
    }
    //取得jill_booking
    $DBV1 = get_jill_booking($jb_sn);
    $DBV2 = get_booking_weekArr($jb_sn);
    //die(var_export($DBV2['jbt_sn']));
    //可啟用場地資訊
    $itemArr = get_jill_booking_item($jbi_sn, 1);
    //die(var_export($itemArr));
    $xoopsTpl->assign("jbi_title", $itemArr['jbi_title']);
    $xoopsTpl->assign("jbi_sn", $jbi_sn);
    $dateweek = "";
    $i = 0;
    $str_jbt_sn = implode(",", $DBV2['jbt_sn']);
    $maxwaiting = get_maxwaiting_byrange($DBV1['jb_start_date'], $DBV1['jb_end_date'], $str_jbt_sn);
    //die("ads".$maxwaiting);
    $xoopsTpl->assign("maxwaiting", $maxwaiting);
    foreach ($DBV2 as $k => $jb_weekArr) {
        //die($jb_weekArr['jb_week']);
        //$jb_weekArr['jbt_sn'];
        $dateArr = getdateArr($jb_weekArr['jb_week'], $DBV1['jb_start_date'], $DBV1['jb_end_date']);
        $timeArr = get_jill_booking_time($jb_weekArr['jbt_sn']);
        $time[] = $jbt_sn;
        foreach ($dateArr as $date) {
            $dateweek[$i]['jb_date'] = $date;
            $dateweek[$i]['week'] = date('w', strtotime($date));
            $dateweek[$i]['jbt_title'] = $timeArr['jbt_title'];
            $dateweek[$i]['jbt_sn'] = $jb_weekArr['jbt_sn'];
            if (!empty($maxwaiting)) {
                $waitingArr = get_jbwaiting($jb_weekArr['jbt_sn'], $date);
                for ($j = 0; $j < $maxwaiting; $j++) {
                    $ok = "<span style='color:#D44950'><i class='fa fa-check'></i></span>";
                    $jb_exit = 0;
                    if (!empty($waitingArr)) {
                        foreach ($waitingArr as $key => $w) {
                            if ($w['jb_waiting'] == $j + 1) {
                                $ok = $w['name'];
                            }
                            $jb_exit = 1;
                        }
                        $dateweek[$i]['waitingArr'][$j]['name'] = $ok;
                        $dateweek[$i]['jb_exit'] = $jb_exit;
                    } else {
                        $dateweek[$i]['waitingArr'][0]['name'] = "<span style='color:#D44950'><i class='fa fa-check'></i></span>";
                        for ($j = 1; $j < $maxwaiting; $j++) {
                            $dateweek[$i]['waitingArr'][$j]['name'] = "";
                        }
                        $dateweek[$i]['jb_exit'] = 0;
                    }
                }
            } else {
                $dateweek[$i]['waitingArr'][0]['name'] = "<span style='color:#D44950'><i class='fa fa-check'></i></span>";
                $dateweek[$i]['jb_exit'] = 0;
            }
            ++$i;
        }
    }
    foreach ($dateweek as $key => $value) {
        $jb_date[$key] = strtotime($value['jb_date']);
    }
    array_multisort($jb_date, $dateweek);
    //die(var_export($dateweek));
    $xoopsTpl->assign("jb_sn", $jb_sn);
    $xoopsTpl->assign("dateweek", $dateweek);
    $xoopsTpl->assign('now_op', 'list_jill_booking');
    $xoopsTpl->assign('action', $_SERVER["PHP_SELF"]);
    $xoopsTpl->assign('next_op', "insert_jill_booking_date");
}
Exemplo n.º 7
0
function list_jill_booking_time($jbi_sn = "")
{
    global $xoopsDB, $xoopsTpl, $isAdmin;
    if (empty($jbi_sn)) {
        return;
    }
    $item = get_jill_booking_item($jbi_sn);
    include_once XOOPS_ROOT_PATH . "/modules/tadtools/jeditable.php";
    $jeditable = new jeditable();
    $myts =& MyTextSanitizer::getInstance();
    $sql = "select * from `" . $xoopsDB->prefix("jill_booking_time") . "`\n          where `jbi_sn`='{$jbi_sn}' order by `jbt_sort`";
    $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
    $total = $xoopsDB->getRowsNum($result);
    $all_content = "";
    $i = 0;
    while ($all = $xoopsDB->fetchArray($result)) {
        //以下會產生這些變數: $jbt_sn , $jbi_sn , $jbt_title , $jbt_sort
        foreach ($all as $k => $v) {
            ${$k} = $v;
        }
        //過濾讀出的變數值
        $jbt_title = $myts->htmlSpecialChars($jbt_title);
        $jeditable->setTextCol("#jbt_title_{$jbt_sn}", 'time.php', '100%', '11pt', "{'jbt_sn':{$jbt_sn},'op' : 'save_jbt_title'}", _TAD_EDIT . _MA_JILLBOOKIN_JBT_TITLE);
        $all_content[$i]['jbi_sn'] = $jbi_sn;
        $all_content[$i]['jbt_sn'] = $jbt_sn;
        $all_content[$i]['jbt_title_link'] = "<a href='{$_SERVER['PHP_SELF']}?jbt_sn={$jbt_sn}'>{$jbt_title}</a>";
        $all_content[$i]['jbt_title'] = $jbt_title;
        $all_content[$i]['jbt_sort'] = $jbt_sort;
        $all_content[$i]['jbt_week'] = strval($jbt_week);
        $booking_times = get_booking_times($jbt_sn);
        $all_content[$i]['booking_times'] = empty($booking_times) ? "" : sprintf(_MA_JILLBOOKIN_BOOKING_TIME, $booking_times);
        $w_arr = explode(',', $jbt_week);
        for ($j = 0; $j <= 7; $j++) {
            $name = "w{$j}";
            $pic = in_array($j, $w_arr) ? "yes.gif" : "no.gif";
            $all_content[$i][$name] = "<img src='../images/{$pic}' id='{$jbt_sn}_{$j}' onClick=\"change_enable({$jbt_sn},{$j});\" style='cursor: pointer;'>";
        }
        ++$i;
    }
    //die(var_export($all_content));
    //刪除確認的JS
    $xoopsTpl->assign('item', $item);
    $xoopsTpl->assign('bar', $bar);
    $xoopsTpl->assign('action', $_SERVER['PHP_SELF']);
    $xoopsTpl->assign('isAdmin', $isAdmin);
    $xoopsTpl->assign('all_content', $all_content);
    $xoopsTpl->assign('now_op', 'list_jill_booking_time');
    $xoopsTpl->assign('jbi_sn', $jbi_sn);
    if (!file_exists(XOOPS_ROOT_PATH . "/modules/tadtools/sweet_alert.php")) {
        redirect_header("index.php", 3, _MA_NEED_TADTOOLS);
    }
    include_once XOOPS_ROOT_PATH . "/modules/tadtools/sweet_alert.php";
    $sweet_alert = new sweet_alert();
    $delete_jill_booking_time_func = $sweet_alert->render('delete_jill_booking_time_func', "{$_SERVER['PHP_SELF']}?op=delete_jill_booking_time&jbi_sn={$jbi_sn}&jbt_sn=", "jbt_sn");
    $xoopsTpl->assign('delete_jill_booking_time_func', $delete_jill_booking_time_func);
    //套用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();
    $xoopsTpl->assign('formValidator_code', $formValidator_code);
    $jeditable_set = $jeditable->render();
    $xoopsTpl->assign('jeditable_set', $jeditable_set);
    //找出現有場地
    $i = 0;
    $place_time = "";
    $sql = "select a.* , count(b.jbt_sn) as counter from `" . $xoopsDB->prefix("jill_booking_item") . "` as a join `" . $xoopsDB->prefix("jill_booking_time") . "` as b on a.jbi_sn=b.jbi_sn where a.jbi_enable='1' group by b.jbi_sn";
    $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
    while ($data = $xoopsDB->fetchArray($result)) {
        $data['jbi_link'] = sprintf(_MA_JILLBOOKIN_IMPORT_PLACE, $data['jbi_title'], $data['counter']);
        $place_time[$i] = $data;
        $i++;
    }
    $xoopsTpl->assign('place_time', $place_time);
    $xoopsTpl->assign('jquery', get_jquery(true));
}