function tad_cal_list($options) { global $xoopsDB, $xoopsUser, $xoopsTpl; include_once XOOPS_ROOT_PATH . "/modules/tad_cal/function_block.php"; //取得目前使用者可讀的群組 $ok_cate_arr = chk_tad_cal_cate_power('enable_group'); $all_ok_cate = implode(",", $ok_cate_arr); $and_ok_cate = empty($all_ok_cate) ? "and cate_sn='0'" : "and cate_sn in({$all_ok_cate})"; $and_ok_cate2 = empty($all_ok_cate) ? "and a.sn='0'" : "and b.cate_sn in({$all_ok_cate})"; $even_start = date("Y-m-d 00:00:00"); $even_end = date("Y-m-d 23:59:59", strtotime("+{$options[0]} days")); //抓出事件 $sql = "select * from " . $xoopsDB->prefix("tad_cal_event") . " where `start` >= '{$even_start}' and `end` <= '{$even_end}' {$and_ok_cate} order by `start` , `sequence`"; //die($sql); $result = $xoopsDB->query($sql) or web_error($sql); $i = 0; $all_event = ""; while ($all = $xoopsDB->fetchArray($result)) { //以下會產生這些變數: $sn , $title , $start , $end , $recurrence , $location , $kind , $details , $etag , $id , $sequence , $uid , $cate_sn foreach ($all as $k => $v) { ${$k} = $v; } if (!empty($recurrence)) { continue; } $start = substr($start, 0, 10); $all_event[$start][$sn] = $title; } //抓出重複事件 $sql = "select a.*,b.title,b.cate_sn from " . $xoopsDB->prefix("tad_cal_repeat") . " as a join " . $xoopsDB->prefix("tad_cal_event") . " as b on a.sn=b.sn where a.`start` >= '{$even_start}' and a.`end` <= '{$even_end}' {$and_ok_cate2} order by a.`start`"; //die($sql); $result = $xoopsDB->queryF($sql) or web_error($sql); while ($all = $xoopsDB->fetchArray($result)) { //以下會產生這些變數: $sn , $title , $start , $end , $recurrence , $location , $kind , $details , $etag , $id , $sequence , $uid , $cate_sn foreach ($all as $k => $v) { ${$k} = $v; } $start = substr($start, 0, 10); $all_event[$start][$sn] = $title; } $content = $event = ""; $i = 0; if (is_array($all_event)) { foreach ($all_event as $start => $arr) { $j = 0; foreach ($arr as $sn => $title) { $event[$j]['sn'] = $sn; $event[$j]['title'] = $title; $j++; } $content[$i]['start'] = $start; $content[$i]['event'] = $event; $event = ""; $i++; } } $block['content'] = $content; return $block; }
function get_event_title($start = "") { global $xoopsDB, $xoopsUser, $xoopsConfig; //取得目前使用者可讀的群組 $ok_cate_arr = chk_tad_cal_cate_power('enable_group'); $all_ok_cate = implode(",", $ok_cate_arr); $and_ok_cate = empty($all_ok_cate) ? "and cate_sn='0'" : "and cate_sn in({$all_ok_cate})"; $and_ok_cate2 = empty($all_ok_cate) ? "and a.sn='0'" : "and b.cate_sn in({$all_ok_cate})"; setTimezoneByOffset($xoopsConfig['default_TZ']); $even_start = date("Y-m-d 00:00:00", $start / 1000); $even_end = date("Y-m-d 23:59:59", $start / 1000); //抓出事件 $sql = "select * from " . $xoopsDB->prefix("tad_cal_event") . " where ((`start` >= '{$even_start}' and `start` <= '{$even_end}') or (`end` > '{$even_start}' and `end` <= '{$even_end}')) {$and_ok_cate} order by `start` , `sequence`"; //die($sql); $result = $xoopsDB->query($sql) or web_error($sql); while ($all = $xoopsDB->fetchArray($result)) { //以下會產生這些變數: $sn , $title , $start , $end , $recurrence , $location , $kind , $details , $etag , $id , $sequence , $uid , $cate_sn foreach ($all as $k => $v) { ${$k} = $v; } if (!empty($recurrence)) { continue; } $title_arr[$sn] = $title; } //抓出重複事件 $sql = "select a.*,b.title,b.cate_sn from " . $xoopsDB->prefix("tad_cal_repeat") . " as a join " . $xoopsDB->prefix("tad_cal_event") . " as b on a.sn=b.sn where ((a.`start` >= '{$even_start}' and a.`start` <= '{$even_end}') or (a.`end` > '{$even_start}' and a.`end` <= '{$even_end}')) {$and_ok_cate2} order by a.`start`"; //die($sql); $result = $xoopsDB->queryF($sql) or web_error($sql); while ($all = $xoopsDB->fetchArray($result)) { //以下會產生這些變數: $sn , $title , $start , $end , $recurrence , $location , $kind , $details , $etag , $id , $sequence , $uid , $cate_sn foreach ($all as $k => $v) { ${$k} = $v; } $title_arr[$sn] = $title; } $all = "\n <ul>"; foreach ($title_arr as $sn => $title) { $all .= "<li><a href='" . XOOPS_URL . "/modules/tad_cal/event.php?sn={$sn}' style='text-decoration:none;color:#202020;'>{$title}</a></li>"; } $all .= "</ul>"; return $all; }
function get_tad_cal_cate_menu_options($default_cate_sn = "0") { global $xoopsDB, $xoopsModule; //取得目前使用者可編輯的行事曆 $edit_cate_arr = chk_tad_cal_cate_power('enable_upload_group'); $all_ok_cate = implode(",", $edit_cate_arr); $and_ok_cate = empty($all_ok_cate) ? "cate_sn='0'" : "cate_sn in({$all_ok_cate})"; $sql = "select cate_sn,cate_title from " . $xoopsDB->prefix("tad_cal_cate") . " where {$and_ok_cate} order by `cate_sort`"; $result = $xoopsDB->query($sql) or web_error($sql); $total = $xoopsDB->getRowsNum($result); if (empty($total)) { return; } $option = ""; while (list($cate_sn, $cate_title) = $xoopsDB->fetchRow($result)) { $selected = $cate_sn == $default_cate_sn ? "selected=selected" : ""; $option .= "<option value={$cate_sn} {$selected}>{$cate_title}</option>"; } return $option; }
function get_event() { global $xoopsDB, $xoopsUser, $xoopsModuleConfig; $cate_sn = intval($_REQUEST['cate_sn']); //取得目前使用者可讀的群組 $ok_cate_arr = chk_tad_cal_cate_power('enable_group'); $all_ok_cate = implode(",", $ok_cate_arr); $and_ok_cate = empty($all_ok_cate) ? "and cate_sn='0'" : "and cate_sn in({$all_ok_cate})"; $and_ok_cate2 = empty($all_ok_cate) ? "and a.sn='0'" : "and b.cate_sn in({$all_ok_cate})"; $even_start = date("Y-m-d H:i", $_REQUEST['start'] / 1000); $even_end = $_REQUEST['end'] == "0000-00-00 00:00" ? "" : date("Y-m-d H:i", $_REQUEST['end'] / 1000); $and_cate_sn = empty($cate_sn) ? "" : "and `cate_sn` = '{$cate_sn}'"; $and_cate_sn2 = empty($cate_sn) ? "" : "and b.`cate_sn` = '{$cate_sn}'"; //抓出事件 $sql = "select * from " . $xoopsDB->prefix("tad_cal_event") . " where `start` >= '{$even_start}' and `end` <= '{$even_end}' {$and_ok_cate} {$and_cate_sn} order by `start` , `sequence`"; //die($sql); $result = $xoopsDB->query($sql) or web_error($sql); $i = 0; while ($all = $xoopsDB->fetchArray($result)) { //以下會產生這些變數: $sn , $title , $start , $end , $recurrence , $location , $kind , $details , $etag , $id , $sequence , $uid , $cate_sn foreach ($all as $k => $v) { ${$k} = $v; } if (!empty($recurrence)) { continue; } $allDay = $allday == '1' ? true : false; //正確顯示行事曆事件條 $startTime = userTimeToServerTime(strtotime($start)); $endTime = userTimeToServerTime(strtotime($end)); if (empty($endTime)) { $endTime = $startTime + 86400; } //計算應顯示數字用 $day = ceil(($endTime - $startTime) / 86400); if (empty($day)) { $day = 1; } $start = date('Y-m-d H:i', $startTime); $end = date('Y-m-d H:i', $endTime); if ($allDay) { $endTime = strtotime($end) - 86400; } //避免截掉半個中文字 $title_num = $xoopsModuleConfig['title_num'] * 3 * $day; $event_title = xoops_substr(strip_tags($title), 0, $title_num); $myEvents[$i]['id'] = $sn; $myEvents[$i]['title'] = "{$event_title}"; //$myEvents[$i]['url']="event.php?sn=$sn"; $myEvents[$i]['rel'] = XOOPS_URL . "/modules/tad_cal/event.php?op=view&sn={$sn}"; $myEvents[$i]['start'] = $startTime; if (!empty($end)) { $myEvents[$i]['end'] = $endTime; } $myEvents[$i]['allDay'] = $allDay; $myEvents[$i]['className'] = "my{$cate_sn}"; $i++; } //抓出重複事件 $sql = "select a.*,b.title,b.cate_sn from " . $xoopsDB->prefix("tad_cal_repeat") . " as a join " . $xoopsDB->prefix("tad_cal_event") . " as b on a.sn=b.sn where a.`start` >= '{$even_start}' and a.`end` <= '{$even_end}' {$and_ok_cate2} {$and_cate_sn2} order by a.`start`"; //die($sql); $result = $xoopsDB->queryF($sql) or web_error($sql); while ($all = $xoopsDB->fetchArray($result)) { //以下會產生這些變數: $sn , $title , $start , $end , $recurrence , $location , $kind , $details , $etag , $id , $sequence , $uid , $cate_sn foreach ($all as $k => $v) { ${$k} = $v; } $allDay = $allday == '1' ? true : false; //正確顯示行事曆事件條 $DBstartTime = strtotime($start); $startTime = userTimeToServerTime(strtotime($start)); $endTime = userTimeToServerTime(strtotime($end)); if (empty($endTime)) { $endTime = $startTime + 86400; } //計算應顯示數字用 $day = ceil(($endTime - $startTime) / 86400); if (empty($day)) { $day = 1; } $start = date('Y-m-d H:i', $startTime); $end = date('Y-m-d H:i', $endTime); if ($allDay) { $endTime = strtotime($end) - 86400; } //避免截掉半個中文字 $title_num = $xoopsModuleConfig['title_num'] * 3 * $day; //if(empty($title_num))$title_num=21; $event_title = xoops_substr(strip_tags($title), 0, $title_num); $myEvents[$i]['id'] = $sn; $myEvents[$i]['title'] = "* {$event_title}"; //$myEvents[$i]['url']="event.php?sn=$sn&stamp=$startTime"; $myEvents[$i]['rel'] = XOOPS_URL . "/modules/tad_cal/event.php?op=view&sn={$sn}&stamp={$DBstartTime}"; $myEvents[$i]['start'] = $startTime; if (!empty($end)) { $myEvents[$i]['end'] = $endTime; } $myEvents[$i]['allDay'] = $allDay; $myEvents[$i]['className'] = "my{$cate_sn}"; $i++; } return json_encode($myEvents); }
$PHPWord->addTitleStyle(1, $fontStyle); $section->addTitle($page_title, 1); $contentfontStyle = array('color' => '000000', 'size' => 9, 'bold' => false); $styleTable = array('borderColor' => '000000', 'borderSize' => 6, 'cellMargin' => 50); $styleFirstRow = array('bgColor' => 'CFCFCF'); //首行樣式 $PHPWord->addTableStyle('myTable', $styleTable, $styleFirstRow); //建立表格樣式 $table = $section->addTable('myTable'); //建立表格 $cellStyle = array('valign' => 'center'); //儲存格樣式(設定項:valign、textDirection、bgColor、borderTopSize、borderTopColor、borderLeftSize、borderLeftColor、borderRightSize、borderRightColor、borderBottomSize、borderBottomColor) $paraStyle = array('align' => 'center'); $headStyle = array('bold' => true); //取得目前使用者可讀的群組 $ok_cate_arr = chk_tad_cal_cate_power('enable_group'); if (!empty($_POST['cate_sn'])) { foreach ($_POST['cate_sn'] as $cate_sn) { if (in_array($cate_sn, $ok_cate_arr)) { $ok_arr[] = $cate_sn; } } } else { $ok_arr = $ok_cate_arr; } //標題行 if ($_POST['dl_type'] == "all_week") { //週簡曆 $table->addRow(); //新增一列 $cellStyle = array('bgColor' => 'FFFFFF');