$id = !empty($_GET['categoryarea_id']) ? $_GET['categoryarea_id'] : null; $act = $id == null ? 'add' : 'edit'; switch ($act) { case 'add': $data = ['categoryarea_id' => null, 'categoryarea_name' => null, 'categoryarea_priority' => 0, 'categoryarea_status' => 'close', 'categoryarea_description' => null, 'categoryarea_insert_time' => null, 'categoryarea_modify_time' => null]; $cover = null; $cover_dir = URL_IMG_ROOT . "default_bg.png"; break; case 'edit': $query = 'select * from `categoryarea` where categoryarea_id = ' . $id; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $data = $row; } if (empty($data)) { js_location(URL_ADMIN2_ROOT . 'categoryarea', '[Error]找不到資料'); } $cover_dir = !empty($data['categoryarea_cover']) ? ADMIN_IMG_UPLOAD . P_CLASS . '/' . $data['categoryarea_cover'] : null; $cover = !empty($data['categoryarea_cover']) ? $data['categoryarea_cover'] : null; break; } ?> <div class="content-wrapper"> <section class="content-header"> <div class="box-body"><h2>產品類別管理</h2></div> <h1> <small><p class="text-light-blue"></p></small> </h1> <ol class="breadcrumb"> <li><a href="<?php echo URL_ADMIN2_ROOT;
</table> </form> <div id="del_form"></div> <?php return; } } //edit end //編輯標籤的view if ($act == 'tags') { echo '<div class="page_title">產品標籤管理</div><hr>'; $query = 'select * from product where product_id = ' . $_GET['id'] . ';'; $query = query_despace($query); $result = mysql_query($query); if (mysql_num_rows($result) < 1) { js_location(URL_ADMIN_ROOT . 'product'); } while ($row = mysql_fetch_array($result)) { $product_name = $row['product_name']; $product_tags = json_decode($row['product_tags']); } echo '<div>產品名稱:<span class="product_name">' . $product_name . '</span></div><br>'; echo '<input type="button" onclick="add_tags()" value="新增欄位" class="btn btn-success"> <input type="button" onclick="edit_tags()" value="送出" class="btn btn-primary"> <br><br>'; ?> <div id="tag_area"> <ul> <?php if (!empty($product_tags) && $product_tags != '') { foreach ($product_tags as $k => $v) {
$d_category['category_cover'] = ADMIN_IMG_UPLOAD . 'category/' . $row['category_cover']; $category[] = $d_category; } } /** * 1206 若項目僅有一項且與類別同名稱,視為可直接跳轉進入項目顯示區塊 */ $nav['show_type'] = 'category'; if (count($category) == 1) { $query = 'select * from `categoryarea` where `categoryarea_id` = ' . $d_category['categoryarea_id'] . ';'; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $chech_categoryare = $row; } if ($d_category['name'] == $chech_categoryare['categoryarea_name']) { js_location(URL_ROOT . 'product/?goods=' . base64_encode($chech_categoryare['categoryarea_id']) . '&category=' . base64_encode($d_category['id'])); } } } //顯示"產品"的列表 if (!empty($nav['categoryarea_id']) && !empty($g_category) && empty($g_items)) { //組出產品 $num = 15; $__category = get_nav_category($nav['categoryarea_id']); $start_page = (int) ($g_pages - 1) * $num; $query = 'select * from `product` where `product_category_id` = ' . $nav['category_id'] . ' and `product_status` = "open" order by `product_priority` asc limit ' . $start_page . ',' . $num . ' ;'; $query = query_despace($query); $result = mysql_query($query); $n_query = 'select * from `product` where `product_category_id` = ' . $nav['category_id'] . ' and `product_status` = "open" order by `product_priority` asc ;'; $n_query = query_despace($n_query); $n_result = mysql_query($n_query);
} $data['reader'] = $_SESSION['admin']['name']; $data['read_time'] = date("Y-m-d G:i:s"); } //不同status if ($data['status'] == 'open') { //底色標籤不同 $status_text = '<div><span style="font-weight:bold;" class="bg-green color-palette">Open</span></div>'; //回上頁後呈現的標籤位置 $tab = 'tab1'; } else { $status_text = '<div><span style="font-weight:bold;" class="bg-light-blue color-palette">Archive</span></div>'; $tab = 'tab2'; } } else { js_location(URL_ADMIN2_ROOT, '[Error]未取得id'); } ?> <div class="content-wrapper"> <section class="content-header"> <div class="box-body"><h2>聯繫我們</h2></div> <h1> <small><p class="text-light-blue"></p></small> </h1> <ol class="breadcrumb"> <li><a href="<?php echo URL_ADMIN2_ROOT; ?> "><i class="fa fa-dashboard"></i> Home</a></li> <li><a href="<?php echo URL_ADMIN2_ROOT . 'contact/';
<!DOCTYPE html> <?php include './../../../config/global.php'; include './../../../config/function.php'; if (empty($_SESSION['admin']['id'])) { js_location(URL_ROOT . 'admin'); } ?> <html> <head> <meta name="robots" content="noindex"> <meta name="robots" content="nofollow" /> <meta name="googlebot" content="noindex"> <meta charset="UTF-8"> <title>品利興國際有限公司 - 後台管理系統</title> <link rel="stylesheet" href="<?php echo URL_LIB_ROOT . 'css/style_admin.css'; ?> "> <link rel="stylesheet" href="<?php echo URL_LIB_ROOT . 'css/bootstrap.css'; ?> "> <link href="<?php echo URL_LIB_ROOT . 'js/jbox/jbox.css'; ?> " rel="stylesheet" type="text/css"/> <script type="text/javascript" src="<?php echo URL_LIB_ROOT . 'js/jquery-1.11.2.min.js'; ?>
//first read if ($inquiry['read'] == 'unread') { $query = 'UPDATE `inquiry` SET `read` = "read", `reader` = "' . $_SESSION['admin']['id'] . '", `read_time` = NOW() where `id` = "' . $inquiry['id'] . '"'; $query = query_despace($query); if (!mysql_query($query)) { js_location(URL_ADMIN_ROOT . 'inquiry'); } $inquiry['reader'] = $_SESSION['admin']['name']; $inquiry['read_time'] = date("Y-m-d H:i:s"); } else { //has read 轉換ID為名稱 $query = 'SELECT * from admin where id = "' . $inquiry['reader'] . '"'; $query = query_despace($query); $result = mysql_query($query); if (!$result) { js_location(URL_ADMIN_ROOT . 'inquiry'); } while ($row = mysql_fetch_assoc($result)) { $inquiry['reader'] = $row['admin_name']; } } $inquiry['demand'] = $inquiry['demand'] == 'true' ? 'Required' : 'Not required'; //預設的onclick $onclick = 'archive_issue(' . $inquiry['id'] . ')'; $class = 'btn-warning'; $value = 'Archive'; if ($inquiry['status'] == 'archive') { //要還原的onclick $onclick = 'recover_issue(' . $inquiry['id'] . ')'; $class = 'btn-success'; $value = 'Recover';
<meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Pindelta.com | <?php echo strtoupper(P_CLASS) . '-' . P_FUNCTION; ?> | Admin System</title> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> <?php /** * 1228 不同CLASS及FUNCTION 載入不同靜態檔案,避免影響速度 */ $p_class = P_CLASS; $p_function = P_FUNCTION; $obj = !class_exists($p_class) ? redirect_php(URL_ADMIN2_ROOT) : new $p_class(); if (P_CLASS == 'system' && P_FUNCTION == 'admin' && $_SESSION['admin']['id'] != 1) { js_location(URL_ADMIN2_ROOT . 'about/', '您並非最高管理員,目前沒有訪問此頁面的權限'); } if (P_CLASS != 'index' && P_FUNCTION != 'login' && !isset($_SESSION['admin'])) { redirect_php(URL_ADMIN2_ROOT . 'index/login.php'); } $common_css = array('bootstrap/css/bootstrap.min.css', 'adminlte/css/AdminLTE.min.css', 'adminlte/css/_all-skins.min.css', 'plugins/icheck/all.css', 'plugins/font-awesome/css/font-awesome.css', '../../lib/jbox/jBox.css'); $common_js = array('js/jquery_2.1.4.min.js', 'bootstrap/js/bootstrap.min.js', 'adminlte/js/app.min.js', 'adminlte/js/demo.js', '../../lib/jbox/jBox.js'); //Display css&js html tag list($css_file, $js_file) = $obj::$p_function($common_css, $common_js); admin_set_css($css_file); admin_set_js($js_file); ?> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
/** ====================== **/ function awesimreport() { /* load resources */ $this->load->model('awesimreport_model', 'awe'); $this->load->model('characters_model', 'char'); $this->load->model('positions_model', 'pos'); $this->load->model('depts_model', 'dept'); $this->load->model('users_model', 'user'); $archnum = $this->awe->count_archive(); $pages = ceil((int) $archnum / 10); $pg = '1'; $min = 0; $data['archnum'] = $archnum; if ($this->uri->segment(4, 0, TRUE) > 1) { $pg = $this->uri->segment(4, 0, TRUE); } if ($pg > $pages) { $pg = $pages; } $min = $pg * 10 - 10; $data['pg'] = $pg; $data['pages'] = $pages; $data['images']['icons']['loading'] = array('src' => img_location('loading-circle.gif', $this->skin, 'admin'), 'alt' => '', 'class' => 'image'); //go over archive list: $archive = $this->awe->get_archived_reports('published', $min); if ($archive->num_rows() > 0) { foreach ($archive->result() as $item) { $curruserid = $item->report_author; $currchar = $this->char->get_character($curruserid); $curruser = $this->user->get_user($curruserid); //get the current user (reporting officer): $posts = $this->pos->get_position($currchar->position_1); $positions = $posts !== FALSE ? $posts->pos_name : ''; if ((int) $currchar->position_2 > 0) { $positions .= " & " . $this->pos->get_position($currchar->position_2, 'pos_name'); } if (empty($item->report_date_start) || empty($item->report_date_end)) { $dStart = ''; $dEnd = ''; } else { $dStart = date($aweSettings['awe_txtDateFormat'], $item->report_date_start); $dEnd = date($aweSettings['awe_txtDateFormat'], $item->report_date_end); } $data['archive'][$item->report_id] = array('id' => $item->report_id, 'date_start' => $dStart, 'date_end' => $dEnd, 'repofficer' => $this->char->get_character_name($curruserid, TRUE), 'repofficer_userid' => $item->arch_repofficer_userid, 'repofficer_charid' => $curruser->main_char, 'repofficer_position' => $positions, 'display' => $item->report_status, 'template' => $item->report_template, 'date_sent' => $item->report_date_sent, 'date_sent_visual' => date($aweSettings['awe_txtDateFormat'], $item->report_date_sent)); $pubcheck = ''; if ($item->report_status == 'published') { $pubcheck = 'checked'; } $data['chkPublish'][$item->report_id] = array('name' => 'chkPublish', 'id' => 'chkPublish', 'checked' => $pubcheck, 'value' => $item->report_id); } //end foreach } else { $data['archive'] = ''; } //end if archive exists /** SETUP VIEW **/ $data['header'] = 'aweSimReport: Public Archive'; /* view locations */ $currpage = 'sim_awesimreport'; $currpage_js = 'sim_awesimreport_js'; $view_loc = view_location($currpage, $this->skin, 'main'); $js_loc = js_location($currpage_js, $this->skin, 'main'); /* produce write the header */ $this->template->write('title', $data['header']); /* produce view */ $this->template->write_view('javascript', $js_loc, $js_data); $this->template->write_view('content', $view_loc, $data); /* render the template */ $this->template->render(); }
<?php //0521 改成只抓ID=3的關於公司 $about = array(); $query = 'select * from about where id = 3;'; $query = query_despace($query); $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $data = $row; } $commit = !empty($_POST['about_btn']) ? $_POST['about_btn'] : null; if ($commit == 'Save') { $new_value = $_POST['about_value']; $new_id = 3; if (empty($new_value)) { //輸入的值為空白 js_location($URL_ROOT . 'admin/dashboard/about'); } else { //不為空白時進行更新 $new_value = stripslashes(htmlspecialchars($new_value)); $query = 'UPDATE `about` SET `value` = \'' . $new_value . '\' , `modify_name` = "' . $_SESSION['admin']['name'] . '" ,`modify_time` = NOW() WHERE `about`.`id` = "' . $new_id . '" LIMIT 1 ; '; $query = query_despace($query); $result = mysql_query($query); if ($result) { php_call_jbox('success', '修改成功', URL_ADMIN_ROOT . 'about'); } else { php_call_jbox('error', '修改失敗,請確認您輸入的資料是否有誤', URL_ADMIN_ROOT . 'about'); } } }
/** * Display list of links within a particular category */ function show_links() { global $sql, $qs, $rs, $ns, $tp, $from; $number = "20"; $LINK_CAT_NAME = ''; // May be appropriate to add a shortcode later if ($qs[2] == "all") { // Show all categories $caption = LCLAN_ITEM_38; $qry = " link_id != '' ORDER BY link_category ASC, link_order ASC"; } else { // Show single category if ($sql->db_Select("links_page_cat", "link_category_name", "link_category_id='" . intval($qs[2]) . "' ")) { $row = $sql->db_Fetch(); $caption = LCLAN_ITEM_2 . " " . $row['link_category_name']; } $qry = " link_category=" . intval($qs[2]) . " ORDER BY link_order, link_id ASC"; } $link_total = $sql->db_Select("links_page", "*", " " . $qry . " "); if (!$sql->db_Select("links_page", "*", " " . $qry . " LIMIT " . intval($from) . "," . intval($number) . " ")) { js_location(e_SELF . "?link"); } else { // Display the individual links $text = $rs->form_open("post", e_SELF . (e_QUERY ? "?" . e_QUERY : ""), "myform_{$row['link_id']}", "", ""); $text .= "<div style='text-align:center'>\n <table class='fborder' style='" . ADMIN_WIDTH . "'>\n <tr>\n <td class='fcaption' style='width:5%'>" . LCLAN_ITEM_25 . "</td>\n <td class='fcaption' style='width:65%'>" . LCLAN_ITEM_26 . "</td>\n <td class='fcaption' style='width:10%'>" . LCLAN_ITEM_27 . "</td>\n <td class='fcaption' style='width:10%'>" . LCLAN_ITEM_28 . "</td>\n <td class='fcaption' style='width:10%'>" . LCLAN_ITEM_29 . "</td>\n </tr>"; while ($row = $sql->db_Fetch()) { $linkid = $row['link_id']; $img = ""; if ($row['link_button']) { if (strpos($row['link_button'], "http://") !== FALSE) { $img = "<img src='" . $row['link_button'] . "' alt='" . $LINK_CAT_NAME . "' />"; } else { if (strstr($row['link_button'], "/")) { $img = "<img src='" . e_BASE . $row['link_button'] . "' alt='" . $LINK_CAT_NAME . "' />"; } else { $img = "<img src='" . e_PLUGIN_ABS . "links_page/link_images/" . $row['link_button'] . "' alt='" . $LINK_CAT_NAME . "' />"; } } } $name_suffix = URL_SEPARATOR . $linkid . URL_SEPARATOR . $row['link_order'] . URL_SEPARATOR . $row['link_category']; if ($row['link_order'] == "1") { $up = " "; } else { //$up = "<input type='image' src='".LINK_ICON_ORDER_UP_BASE."' value='".$linkid.".".$row['link_order'].".".$row['link_category']."' name='inc' />"; $up = "<input type='image' src='" . LINK_ICON_ORDER_UP_BASE . "' name='inc" . $name_suffix . "' />"; } if ($row['link_order'] == $link_total) { $down = " "; } else { //$down = "<input type='image' src='".LINK_ICON_ORDER_DOWN_BASE."' value='".$linkid.".".$row['link_order'].".".$row['link_category']."' name='dec' />"; $down = "<input type='image' src='" . LINK_ICON_ORDER_DOWN_BASE . "' name='dec" . $name_suffix . "' />"; } $text .= "\n <tr>\n <td class='forumheader3' style='width:5%; text-align: center; vertical-align: middle'>" . $img . "</td>\n <td style='width:65%' class='forumheader3'>\n <a href='" . e_PLUGIN_ABS . "links_page/links.php?" . $row['link_id'] . "' rel='external'>" . LINK_ICON_LINK . "</a> " . $row['link_name'] . "\n </td>\n <td style='width:10%; text-align:center; white-space: nowrap' class='forumheader3'>\n <a href='" . e_SELF . "?link.edit." . $linkid . "' title='" . LCLAN_ITEM_31 . "'>" . LINK_ICON_EDIT . "</a>\n <input type='image' title='delete' name='delete[main_{$linkid}]' alt='" . LCLAN_ITEM_32 . "' src='" . LINK_ICON_DELETE_BASE . "' onclick=\"return jsconfirm('" . $tp->toJS(LCLAN_ITEM_33 . " [ " . $row['link_name'] . " ]") . "')\" />\n </td>\n <td style='width:10%; text-align:center; white-space: nowrap' class='forumheader3'>\n " . $up . "\n " . $down . "\n </td>\n <td style='width:10%; text-align:center' class='forumheader3'>\n <select name='link_order[]' class='tbox'>"; //".$rs -> form_select_open("link_order[]"); for ($a = 1; $a <= $link_total; $a++) { $text .= $rs->form_option($a, $row['link_order'] == $a ? "1" : "0", $linkid . "." . $a, ""); } $text .= $rs->form_select_close() . "\n </td>\n </tr>"; } $text .= "\n <tr>\n <td class='forumheader' colspan='4'> </td>\n <td class='forumheader' style='width:5%; text-align:center'>\n " . $rs->form_button("submit", "update_order", LCLAN_ITEM_30) . "\n </td>\n </tr>\n </table></div>\n " . $rs->form_close(); } $ns->tablerender($caption, $text); $this->ShowNextPrev($from, $number, $link_total); }
function displayLinkComment() { global $qs, $cobj, $tp, $sql, $linkbutton_count, $lc, $rowl, $link_shortcodes, $ns, $linkspage_pref, $LINK_TABLE_START, $LINK_TABLE, $LINK_TABLE_END, $LINK_APPEND; if (!(isset($linkspage_pref["link_comment"]) && $linkspage_pref["link_comment"])) { js_location(e_SELF); } else { $qry = "\n\t\tSELECT l.*, lc.*, COUNT(c.comment_id) AS link_comment\n\t\tFROM #links_page AS l\n\t\tLEFT JOIN #links_page_cat AS lc ON lc.link_category_id = l.link_category\n\t\tLEFT JOIN #comments as c ON c.comment_item_id=l.link_id AND comment_type='links_page'\n\t\tWHERE l.link_id = '" . intval($qs[1]) . "' AND lc.link_category_class REGEXP '" . e_CLASS_REGEXP . "' AND l.link_class REGEXP '" . e_CLASS_REGEXP . "'\n\t\tGROUP BY l.link_id"; $link_comment_table_string = ""; if (!($linkcomment = $sql->db_Select_gen($qry))) { js_location(e_SELF); } else { $rowl = $sql->db_Fetch(); $linkbutton_count = $rowl['link_button'] ? $linkbutton_count + 1 : $linkbutton_count; $LINK_APPEND = $lc->parse_link_append($rowl); $subject = $rowl['link_name']; $text = $tp->parseTemplate($LINK_TABLE_START, FALSE, $link_shortcodes); $text .= $tp->parseTemplate($LINK_TABLE, FALSE, $link_shortcodes); $text .= $tp->parseTemplate($LINK_TABLE_END, FALSE, $link_shortcodes); $ns->tablerender(LAN_LINKS_36, $text); $cobj->compose_comment("links_page", "comment", $qs[1], $width, $subject, $showrate = FALSE); } } return; }
//first read if ($contact['read'] == 'unread') { $query = 'UPDATE `contact` SET `read` = "read", `reader` = "' . $_SESSION['admin']['id'] . '", `read_time` = NOW() where `id` = "' . $contact['id'] . '"'; $query = query_despace($query); if (!mysql_query($query)) { js_location(URL_ADMIN_ROOT . 'contact'); } $contact['reader'] = $_SESSION['admin']['name']; $contact['read_time'] = date("Y-m-d H:i:s"); } else { //has read 轉換ID為名稱 $query = 'SELECT * from admin where id = "' . $contact['reader'] . '"'; $query = query_despace($query); $result = mysql_query($query); if (!$result) { js_location(URL_ADMIN_ROOT . 'contact'); } while ($row = mysql_fetch_assoc($result)) { $contact['reader'] = $row['admin_name']; } } //預設的onclick $onclick = 'archive_issue(' . $contact['id'] . ')'; $class = 'btn-warning'; $value = 'Archive'; if ($contact['status'] == 'archive') { //要還原的onclick $onclick = 'recover_issue(' . $contact['id'] . ')'; $class = 'btn-success'; $value = 'Recover'; }
/** ====================== **/ function awesimreport() { /* load resources */ $this->load->model('awesimreport_model', 'awe'); $this->load->model('characters_model', 'char'); $this->load->model('positions_model', 'pos'); $this->load->model('depts_model', 'dept'); $this->load->model('personallogs_model', 'logs'); $this->load->model('posts_model', 'posts'); $this->load->model('ranks_model', 'ranks'); $this->load->model('news_model', 'news'); $this->load->model('users_model', 'user'); $data['images']['loading'] = array('src' => img_location('loading-bar.gif', $this->skin, 'admin'), 'alt' => 'Loading', 'class' => 'image'); /** SET UP MENU **/ $data['images']['menu'] = array('generator' => array('src' => asset_location('images/awesimreport', 'awe_menu_generator.png'), 'class' => 'image inline_img_left', 'height' => 48, 'alt' => 'Generator', 'title' => 'Generator'), 'archive' => array('src' => asset_location('images/awesimreport', 'awe_menu_archive.png'), 'class' => 'image inline_img_left', 'height' => 48, 'alt' => 'Archive'), 'sections' => array('src' => asset_location('images/awesimreport', 'awe_menu_sections.png'), 'class' => 'image inline_img_left', 'height' => 48, 'alt' => 'Sections'), 'settings' => array('src' => asset_location('images/awesimreport', 'awe_menu_settings.png'), 'class' => 'image inline_img_left', 'height' => 48, 'alt' => 'Settings'), 'templates' => array('src' => asset_location('images/awesimreport', 'awe_menu_templates.png'), 'class' => 'image inline_img_left', 'height' => 48, 'alt' => 'Templates')); /* grab the settings */ $settings_array = array('awe_txtSimStart', 'awe_txtSimEnd', 'awe_txtDateFormat', 'awe_txtEmailSubject', 'awe_txtReportTitle', 'awe_txtEmailRecipients', 'awe_chkPresenceTags', 'awe_txtReportDuration', 'awe_txtStatOccurences', 'awe_txtPresenceTag_Present', 'awe_txtPresenceTag_Unexcused', 'awe_txtPresenceTag_Excused', 'awe_chkShowRankImagesRoster', 'awe_chkShowRankImagesCOC', 'awe_ActiveTemplate', 'awe_txtTemplateFooter'); $aweSettings = $this->settings->get_settings($settings_array); //info about email: $mail_uid = $this->session->userdata('userid'); $charid = $this->user->get_main_character($mail_uid); $myaddress = $this->user->get_email_address($mail_uid); $myname = $this->char->get_character_name($charid, TRUE); $mailsubject = $aweSettings['awe_txtEmailSubject']; $mailrecipients = explode(',', $aweSettings['awe_txtEmailRecipients']); if ($myaddress == FALSE) { $myaddress = '*****@*****.**'; } $js_data['email']['myaddress'] = $myaddress; $js_data['email']['myname'] = $myname; $js_data['email']['mailsubject'] = $mailsubject; $js_data['email']['mailrecipients'] = $mailrecipients; switch ($this->uri->segment(3)) { default: case "generator": /* set the variables */ $id = $this->uri->segment(4, FALSE, TRUE); $data['debug']['id'] = $id; $data['reportid'] = $id; //DEAL WITH POST REQUESTS: if (isset($_POST['submit'])) { $action = strtolower($this->input->post('submit', TRUE)); switch ($action) { case 'save report': $dateStart = $this->input->post('txtReportDateStart'); $dateEnd = $this->input->post('txtReportDateEnd'); $chkShowUsers = $this->input->post('chkRosterShowUsers', TRUE); $customSections = $this->input->post('sections', TRUE); $dataArray = array('CustomSections' => $customSections, 'ShowUsers' => $chkShowUsers); /* build the insert array */ $insert_array = array('report_date_start' => strtotime($dateStart), 'report_date_end' => strtotime($dateEnd), 'report_author' => $this->session->userdata('userid'), 'report_data' => serialize($dataArray), 'report_status' => 'saved', 'report_template' => $aweSettings['awe_ActiveTemplate'], 'report_saved_date' => now()); /* do the insert */ $insert = $this->awe->add_saved_report($insert_array); /* grab the insert id */ $insert_id = $this->db->insert_id(); /* optimize the table */ $this->sys->optimize_table('awe_saved_reports'); if ($insert > 0) { $message = 'Report saved successfully. Please wait to be redirected to your saved report...'; $flash['status'] = 'success'; $flash['message'] = text_output($message); } else { $message = '201: An error occured while saving this report. Please try again later.'; $flash['status'] = 'error'; $flash['message'] = text_output($message); } /* add a quick redirect */ $this->template->add_redirect('report/awesimreport/generator/' . $insert_id); break; //save //save case 'update report': $dateStart = $this->input->post('txtReportDateStart'); $dateEnd = $this->input->post('txtReportDateEnd'); $chkShowUsers = $this->input->post('chkRosterShowUsers', TRUE); $customSections = $this->input->post('sections', TRUE); $dataArray = array('CustomSections' => $customSections, 'ShowUsers' => $chkShowUsers); /* if there is an ID, it is a previously saved report */ $update_array = array('report_date_start' => strtotime($dateStart), 'report_date_end' => strtotime($dateEnd), 'report_author' => $this->session->userdata('userid'), 'report_data' => serialize($dataArray), 'report_status' => 'saved', 'report_template' => $aweSettings['awe_ActiveTemplate'], 'report_saved_date' => now()); /* do the update */ $update = $this->awe->update_saved_report($id, $update_array); if ($update > 0) { $message = 'Report updated successfully.'; $flash['status'] = 'success'; $flash['message'] = text_output($message); } else { $message = 'An error occured while trying to update this report. Please try again later.'; $flash['status'] = 'error'; $flash['message'] = text_output($message); } break; //update //update case 'generate report': //get all variables $tDateStart = $this->input->post('txtReportDateStart', TRUE); $tDateEnd = $this->input->post('txtReportDateEnd', TRUE); $arrRosterUsers = $this->input->post('chkRosterShowUsers', TRUE); $arrRosterAttendance = $this->input->post('rAttendance', TRUE); $arrSections = $this->input->post('sections', TRUE); //get current template $tmplID = $aweSettings['awe_ActiveTemplate']; $template = $this->awe->get_template_content($tmplID); //prepare output array: $tOutput = array(); //get section order: $sectionQuery = $this->awe->get_section_order(); $c = 1; if ($sectionQuery->num_rows() > 0) { foreach ($sectionQuery->result() as $sID) { $sec = $this->awe->get_section_details($sID->section_id); if ($sec->num_rows() > 0) { //get section info: $section = $sec->row(); $tOutput[$c]['title'] = $section->section_title; switch (strtolower($section->section_name)) { case 'chain of command': $plaintext = ''; $coc = $this->char->get_coc(); $defaultRankset = $this->ranks->get_rank_default(); $rank_ext = $this->ranks->get_rankcat($defaultRankset, 'rankcat_location', 'rankcat_extension'); if ($coc->num_rows() > 0) { $cocHtml = '<table cellspacing="0" cellpadding="0" class="coctable">'; foreach ($coc->result() as $item) { $cocHtml .= '<tr>'; if ($item->crew_type == 'active' && empty($item->user)) { // skip } else { if ($aweSettings['awe_chkShowRankImagesCOC'] == 'checked') { $charinf = $this->char->get_character($item->charid); //get rank image: $rankdata = $this->ranks->get_rank($charinf->rank, array('rank_name', 'rank_image')); $img_rank = array('src' => rank_location($defaultRankset, $item->rank_image, $rank_ext), 'alt' => $item->rank_name, 'class' => 'image', 'border' => 0); $cocHtml .= '<td width="80" class="coc_rank">' . img($img_rank) . '</td>'; } $coc_id = $item->charid; $coc_name = $this->char->get_character_name($item->charid, TRUE); $coc_position = $item->pos_name; $coc_item['id'] = $item->charid; $coc_item['coc_name'] = $this->char->get_character_name($item->charid, TRUE); $coc_item['coc_position'] = $item->pos_name; $cocHtml .= '<td class="coc_char">'; $cocHtml .= '<strong>' . anchor('personnel/character/' . $item->charid, $coc_name) . '</strong><br />'; $cocHtml .= '<span style="size: 90%;">(' . $coc_position . ')</span>'; $cocHtml .= '</td>'; $cocPlain = "* " . $coc_name . " (" . $coc_position . ")\r\n"; } $cocHtml .= '</tr>'; } //foreach coc item $cocHtml .= '</table>'; } //end if coc has records $html = $cocHtml; $plaintext = $cocPlain; break; case 'report date': $html = '<span class="reportDate">Dates: ' . strftime($aweSettings['awe_txtDateFormat'], $tDateStart) . ' to ' . strftime($aweSettings['awe_txtDateFormat'], $tDateEnd) . '</span>'; $plaintext = 'Dates: ' . strftime($aweSettings['awe_txtDateFormat'], $tDateStart) . ' to ' . strftime($aweSettings['awe_txtDateFormat'], $tDateEnd) . "\r\n"; break; case 'reporting officer': $uid = $this->session->userdata('userid'); $charid = $this->user->get_main_character($uid); $curr_char = $this->char->get_character($charid); $posts = $this->pos->get_position($curr_char->position_1); $positions = $posts !== FALSE ? $posts->pos_name : ''; if ((int) $curr_char->position_2 > 0) { $positions .= " & " . $this->pos->get_position($curr_char->position_2, 'pos_name'); } $html = '<span class="reportingOfficer">'; $html .= $this->char->get_character_name($charid, TRUE) . '<br />'; $html .= $positions . '<br />'; $html .= $aweSettings['sim_name']; $html .= '</span>'; $plaintext = $this->char->get_character_name($charid, TRUE) . "\r\n"; $plaintext .= $positions . "\r\n"; $plaintext .= $aweSettings['sim_name'] . "\r\n"; break; case 'roster': $arrRosterAttendanceTags = ''; //go over the 'checked users' checkboxes: if ($aweSettings['awe_chkPresenceTags'] == 'checked') { $arrRosterAttendanceTags['P'] = $aweSettings['awe_txtPresenceTag_Present']; $arrRosterAttendanceTags['U'] = $aweSettings['awe_txtPresenceTag_Unexcused']; $arrRosterAttendanceTags['E'] = $aweSettings['awe_txtPresenceTag_Excused']; } $depts = $this->dept->get_all_depts('asc', ''); if ($depts->num_rows() > 0) { foreach ($depts->result() as $d) { $characters[$d->dept_id]['deptname'] = $d->dept_name; $subdepts = $this->dept->get_sub_depts($d->dept_id); if ($subdepts->num_rows() > 0) { foreach ($subdepts->result() as $subd) { $characters[$d->dept_id]['subdept'][$subd->dept_id]['deptname'] = $subd->dept_name; } } } } if (count($arrRosterUsers) > 0) { foreach ($arrRosterUsers as $uid => $val) { $charid = $this->user->get_main_character($uid); $charinf = $this->char->get_character($charid); //get rank image: $rankdata = $this->ranks->get_rank($charinf->rank, array('rank_name', 'rank_image')); $defaultRankset = $this->ranks->get_rank_default(); $rank = $this->ranks->get_rankcat($defaultRankset); /* build the rank image array */ $rank_img = array('src' => rank_location($defaultRankset, $rankdata['rank_image'], $rank->rankcat_extension), 'alt' => $rankdata['rank_name'], 'class' => 'image'); $posts = $this->pos->get_position($charinf->position_1); $positions = $posts !== FALSE ? $posts->pos_name : ''; if ((int) $charinf->position_2 > 0) { $positions .= " & " . $this->pos->get_position($charinf->position_2, 'pos_name'); } $currdept = $this->dept->get_dept($posts->pos_dept); $cdept = $currdept->dept_id; $parentDep = $currdept->dept_parent; $u = $this->user->get_user($uid); $loa = $u->loa; if ((int) $parentDep > 0) { //there is a 'parent' to the dept $characters[$parentDep]['subdept'][$cdept]['chars'][$uid] = array('id' => $uid, 'name' => $u->name, 'email' => $u->email, 'char_name' => $this->char->get_character_name($charid, TRUE), 'position' => $positions, 'rank_name' => $rankdata['rank_name'], 'rank_img' => $rank_img, 'charid' => $charid, 'attendance' => $arrRosterAttendance[$uid], 'logcount' => $this->awe->count_user_log_post($uid, strtotime($tDateStart), strtotime($tDateEnd), 'logs'), 'postcount' => $this->awe->count_user_log_post($uid, strtotime($tDateStart), strtotime($tDateEnd), 'posts'), 'totalcount' => $this->awe->count_user_log_post($uid, strtotime($tDateStart), strtotime($tDateEnd))); // $departments[$charid] = $cdept; } else { //the dept is the parent $characters[$cdept]['chars'][$uid] = array('id' => $uid, 'name' => $u->name, 'email' => $u->email, 'char_name' => $this->char->get_character_name($charid, TRUE), 'position' => $positions, 'rank_img' => $rank_img, 'charid' => $charid, 'attendance' => $arrRosterAttendance[$uid], 'logcount' => $this->awe->count_user_log_post($uid, strtotime($tDateStart), strtotime($tDateEnd), 'logs'), 'postcount' => $this->awe->count_user_log_post($uid, strtotime($tDateStart), strtotime($tDateEnd), 'posts'), 'totalcount' => $this->awe->count_user_log_post($uid, strtotime($tDateStart), strtotime($tDateEnd))); // $departments[$charid] = $cdept; } } //end foreach users } $html = ''; $out = $this->awe->template_make_roster_html($characters, $aweSettings['awe_chkPresenceTags'], $arrRosterAttendanceTags, $aweSettings['awe_chkShowRankImagesRoster']); $html = $out['html']; $plaintext = $out['plain']; break; case 'statistics': $dates = array(); $result = array(); $sPeriod = $aweSettings['awe_txtReportDuration']; if (empty($sPeriod)) { $sPeriod = 30; //approx a month } $rawStatPeriod = $sPeriod * 86400; //turn into seconds $counter = 0; if ($aweSettings['awe_txtStatOccurences'] < 1) { $repOccurences = 10; } else { $repOccurences = $aweSettings['awe_txtStatOccurences']; } $endDate = now(); while ($counter <= $repOccurences) { $startDate = (int) ($endDate - $rawStatPeriod); $curr_month = date('n', $endDate); $result[] = $this->awe->stats_total_logcount($startDate, $endDate) + 1; $dates[] = date('Mj', $endDate); $endDate = $startDate - 1; //next occurence start a month ago, a second earlier $counter++; } $maxval = max($result); $newresult = array(); foreach ($result as $sig) { //turn it into percentages: $newresult[] = $sig / $maxval * 100; } $data['dates'] = $dates; $data['result'] = $newresult; $halfmaxvalue = $maxval / 2; $imgsrc = "http://chart.apis.google.com/chart?"; $imgsrc .= "chxl=0:|" . implode('|', $dates); $imgsrc .= "&chxr=0,0,0|1,0," . (int) $maxval; $imgsrc .= "&chxs=0,AA0033,11.5,0,lt,676767|1,676767,11.5,0,lt,676767"; $imgsrc .= "&chxt=x,y"; $imgsrc .= "&chbh=a,5"; $imgsrc .= "&chs=500x400"; $imgsrc .= "&cht=bvg"; $imgsrc .= "&chd=t:" . implode(',', $newresult); $imgsrc .= "&chds=a"; $imgsrc .= "&chdlp=b"; $imgsrc .= "&chp=0"; $imgsrc .= "&chg=10,10,0,9"; $imgsrc .= "&chma=5"; $imgsrc .= "&chtt=Total+Log+Count"; $imggraph = array('src' => $imgsrc, 'alt' => 'Total Log Count', 'class' => 'image'); $html = img($imggraph); $plaintext = 'To view statistics graph, please visit: ' . $imgsrc; break; default: //freetext $html = nl2br($arrSections[$section->section_id]); $plaintext = $arrSections[$section->section_id]; break; } $tOutput[$c]['html'] = $html; $tOutput[$c]['plaintext'] = $plaintext; } //end if sec->num_rows >0 $c++; //counter } //end foreach section } //end if sectionquery //print out the html result: $htmlMail = $this->awe->template_replace_tag($template['header'], '%%reporttitle%%', $aweSettings['awe_txtReportTitle']); $txtMail = $aweSettings['awe_txtReportTitle'] . '\\r\\n'; $txtMail .= "========================================\r\n\r\n\r\n"; //print out sections: foreach ($tOutput as $sec) { if (!empty($sec['html'])) { $htmlMail .= $this->awe->template_replace_tag($template['section_title'], '%%section_title%%', $sec['title']); $htmlMail .= $this->awe->template_replace_tag($template['section_content'], '%%section_content%%', $sec['html']); } if (!empty($sec['plaintext'])) { $txtMail .= $sec['title']; $txtMail .= "========================================\r\n"; $txtMail .= $sec['plaintext']; $txtMail .= "\r\n\r\n"; } } $credits = '<div style="font-size: 80%;">Report generated by <a href="https://github.com/mooeypoo/aweSimReport-2.0" target="_blank">aweSimReport Generator.</a></div>'; $htmlMail .= $this->awe->template_replace_tag($template['section_content'], '%%section_content%%', $credits); $htmlMail .= $this->awe->template_replace_tag($template['footer'], '%%footer%%', $aweSettings['awe_txtTemplateFooter']); $txtMail .= "--\r\n"; $txtMail .= $aweSettings['awe_txtTemplateFooter']; $txtMail .= "--\r\n"; $txtMail .= "Report Generated by aweSimReport (https://github.com/mooeypoo/aweSimReport-2.0)\r\n"; $txtMail .= "--\r\n"; /** Put this report in the archives **/ $dataArray = array('CustomSections' => $arrSections, 'UserAttendance' => $arrRosterUsers, 'ShowUsers' => $arrRosterAttendance); /* build the insert array */ $insert_array = array('report_date_start' => strtotime($tDateStart), 'report_date_end' => strtotime($tDateEnd), 'report_author' => $this->session->userdata('userid'), 'report_data' => serialize($dataArray), 'report_status' => 'published', 'report_template' => $aweSettings['awe_ActiveTemplate'], 'report_date_sent' => now()); if ($id > 0) { //this report exists /* do the update */ $update = $this->awe->update_saved_report($id, $insert_array); if ($update > 0) { $message = 'Report sent to your lists and updated in the archive.'; $flash['status'] = 'success'; $flash['message'] = text_output($message); } else { $message = 'An error occured while trying to update this report. Please try again later.'; $flash['status'] = 'error'; $flash['message'] = text_output($message); } } else { //new report. insert into the system /* do the insert */ $insert = $this->awe->add_saved_report($insert_array); /* grab the insert id */ $insert_id = $this->db->insert_id(); /* optimize the table */ $this->sys->optimize_table('awe_saved_reports'); if ($insert > 0) { $message = 'Report sent to your lists and inserted into the archive.'; $flash['status'] = 'success'; $flash['message'] = text_output($message); } else { $message = '201: An error occured while saving this report to the archives. Please try again later.'; $flash['status'] = 'error'; $flash['message'] = text_output($message); } } /** PREPARE TO SEND EMAIL **/ $this->load->library('email'); $this->email->from($myaddress, $myname); $this->email->to($mailrecipients); $this->email->subject($mailsubject); $this->email->message($htmlMail); $this->email->set_alt_message($txtMail); $this->email->send(); break; //generate //generate case 'delete saved report': //get info: $reportRow = $this->awe->get_saved_report_details($id); if ($reportRow !== FALSE) { if ($reportRow->report_status == 'saved') { //exists, and not a published report. //go ahead an delete: $delete = $this->awe->delete_saved_report($id); if ($delete > 0) { $message = 'Report deleted successfully. Please wait to be redirected...'; $flash['status'] = 'success'; $flash['message'] = text_output($message); } else { $message = '102: There was an error deleting this report. Try again later.'; $flash['status'] = 'error'; $flash['message'] = text_output($message); } } else { //this is a published report $message = 'Cannot delete published report.'; $flash['status'] = 'еrror'; $flash['message'] = text_output($message); } /* add an automatic redirect */ $this->template->add_redirect('report/awesimreport'); } else { //report doesn't exist $message = 'There was a problem deleting this report. It appears the ID doesn\'t exist anymore! Please try again later.'; $flash['status'] = 'еrror'; $flash['message'] = text_output($message); } break; //delete //delete default: $flash['status'] = 'error'; $flash['message'] = lang_output('error_generic', ''); } /* write everything to the template */ $this->template->write_view('flash_message', '_base/admin/pages/flash', $flash); } //end if 'isset submit' $chkShowUsers = array(); $customSections = array(); $inputVal['txtReportDateStart'] = ''; $inputVal['txtReportDateStart'] = ''; if ($id !== FALSE) { /* if there is an ID, it is a previously saved report */ //load the report: $report = $this->awe->get_saved_report_details($id); if ($report !== FALSE) { //it exists! $repdata = unserialize($report->report_data); $chkShowUsers = $repdata['ShowUsers']; $customSections = $repdata['CustomSections']; $inputVal['txtReportDateStart'] = $report->report_date_start > 0 ? date('n/j/Y', $report->report_date_start) : ''; $inputVal['txtReportDateEnd'] = $report->report_date_end > 0 ? date('n/j/Y', $report->report_date_end) : ''; } } $data['debug']['action'] = $action; //set up inputs: $data['inputs'] = array('formAttributes' => array('name' => 'frmGenerate', 'id' => 'frmGenerate'), 'txtReportDateStart' => array('style' => 'width:150px;', 'name' => 'txtReportDateStart', 'id' => 'txtReportDateStart', 'value' => $inputVal['txtReportDateStart']), 'txtReportDateEnd' => array('style' => 'width:150px;', 'name' => 'txtReportDateEnd', 'id' => 'txtReportDateEnd', 'value' => $inputVal['txtReportDateEnd']), 'butGenerate' => array('type' => 'submit', 'class' => 'button-main', 'name' => 'submit', 'value' => 'generate', 'id' => 'submitGenerate', 'content' => ucwords('Generate Report')), 'preview' => array('type' => 'submit', 'class' => 'button-sec', 'name' => 'preview', 'value' => 'preview', 'id' => 'preview', 'content' => ucwords('Preview Report')), 'save' => array('type' => 'submit', 'class' => 'button-sec', 'name' => 'submit', 'value' => 'save', 'id' => 'save', 'content' => ucwords('Save Report')), 'update' => array('type' => 'submit', 'class' => 'button-sec', 'name' => 'submit', 'value' => 'update', 'id' => 'save', 'content' => ucwords('Update Report')), 'delete' => array('type' => 'submit', 'class' => 'button-sec', 'name' => 'submit', 'value' => 'delete', 'id' => 'submitDelete', 'content' => ucwords('Delete Saved Report'))); /** ROSTER! **/ $secID = $this->awe->get_section_by_name('Roster'); $isActive = $this->awe->check_section_active($secID); $js_data['RosterActive'] = $isActive; if ($isActive > 0) { //roster exists. //get settings: $data['roster']['Enabled'] = (int) $isActive; $data['roster']['UseTags'] = $aweSettings['awe_chkPresenceTags']; $data['roster']['Present'] = $aweSettings['awe_txtPresenceTag_Present']; $data['roster']['Unexcused'] = $aweSettings['awe_txtPresenceTag_Unexcused']; $data['roster']['Excused'] = $aweSettings['awe_txtPresenceTag_Excused']; $data['roster']['ShowRankImages'] = $aweSettings['awe_chkShowRankImagesRoster']; if ($aweSettings['awe_chkShowRankImagesRoster'] == 'checked') { $sRosterImages = true; } $rank = $this->ranks->get_rankcat($this->rank); /* build the blank image array */ $blank_img = array('src' => rank_location($this->rank, 'blank', $rank->rankcat_extension), 'alt' => '', 'class' => 'image'); $data['debug']['chkShowUsers'] = $chkShowUsers; $depts = $this->dept->get_all_depts('asc', ''); if ($depts->num_rows() > 0) { foreach ($depts->result() as $d) { $data['characters'][$d->dept_id]['deptname'] = $d->dept_name; $subdepts = $this->dept->get_sub_depts($d->dept_id); if ($subdepts->num_rows() > 0) { foreach ($subdepts->result() as $subd) { $data['characters'][$d->dept_id]['subdept'][$subd->dept_id]['deptname'] = $subd->dept_name; } } } } $users = $this->user->get_users(); if ($users->num_rows() > 0) { /* set the posting requirement threshold */ foreach ($users->result() as $p) { if (empty($id)) { $chkVal = 'checked'; } else { if (empty($chkShowUsers[$p->userid])) { $chkVal = ''; } else { $chkVal = $chkShowUsers[$p->userid]; } } // $chkValue = ((empty($chkShowUsers[$p->userid])) ? $chkShowUsers[$p->userid] : 'checked'); $data['chkRosterShowUsers'][$p->userid] = array('name' => 'chkRosterShowUsers[' . $p->userid . ']', 'id' => 'chkRosterShowUsers[' . $p->userid . ']', 'value' => 'checked', 'checked' => $chkVal); $charinf = $this->char->get_character($p->main_char); $posts = $this->pos->get_position($charinf->position_1); $positions = $posts !== FALSE ? $posts->pos_name : ''; if ((int) $charinf->position_2 > 0) { $positions .= " & " . $this->pos->get_position($charinf->position_2, 'pos_name'); } $currdept = $this->dept->get_dept($posts->pos_dept); $cdept = $currdept->dept_id; //$this->dept->get_dept($posts->pos_dept, 'dept_id'); $parentDep = $currdept->dept_parent; //$this->dept->get_dept($posts->pos_dept, 'dept_parent'); //get rank image: $rankdata = $this->ranks->get_rank($charinf->rank, array('rank_name', 'rank_image')); /* build the rank image array */ $rank_img = array('src' => rank_location($this->rank, $rankdata['rank_image'], $rank->rankcat_extension), 'alt' => $rankdata['rank_name'], 'class' => 'image'); if ((int) $parentDep > 0) { //there is a 'parent' to the dept $data['characters'][$parentDep]['subdept'][$cdept]['chars'][$p->userid] = array('id' => $p->userid, 'name' => $p->name, 'email' => $p->email, 'char_name' => $this->char->get_character_name($p->main_char, TRUE), 'position' => $positions, 'rank_img' => $rank_img, 'charid' => $p->main_char, 'loa' => $p->loa != 'active' ? '[' . strtoupper($p->loa) . ']' : ''); $data['department'][$p->main_char] = $cdept; } else { //the dept is the parent $data['characters'][$cdept]['chars'][$p->userid] = array('id' => $p->userid, 'name' => $p->name, 'email' => $p->email, 'char_name' => $this->char->get_character_name($p->main_char, TRUE), 'position' => $positions, 'rank_img' => $rank_img, 'charid' => $p->main_char, 'loa' => $p->loa != 'active' ? '[' . strtoupper($p->loa) . ']' : ''); $data['department'][$p->main_char] = $cdept; } if ($p->loa == 'active') { $data['radAttendance'][$p->main_char] = array('U' => array('name' => 'rAttendance[' . $p->main_char . ']', 'id' => 'rAttendance[' . $p->main_char . ']', 'value' => 'U'), 'E' => array('name' => 'rAttendance[' . $p->main_char . ']', 'id' => 'rAttendance[' . $p->main_char . ']', 'value' => 'E'), 'P' => array('name' => 'rAttendance[' . $p->main_char . ']', 'checked' => 'checked', 'id' => 'rAttendance[' . $p->main_char . ']', 'value' => 'P')); } else { $data['radAttendance'][$p->main_char] = array('LOA' => array('name' => 'rAttendance[' . $p->main_char . ']', 'checked' => 'checked', 'id' => 'rAttendance[' . $p->main_char . ']', 'value' => 'LOA'), 'ELOA' => array('name' => 'rAttendance[' . $p->main_char . ']', 'id' => 'rAttendance[' . $p->main_char . ']', 'value' => 'ELOA')); } } } /* sort the keys */ ksort($data['characters']); } //end if -- roster exists /* CUSTOM SECTIONS */ //check the active sections: $cSections = $this->awe->get_all_userdefined_sections(); if ($cSections->num_rows() > 0) { foreach ($cSections->result() as $sec) { if ($id !== FALSE) { /* if there is an ID, it is a previously saved report */ $secVal = $customSections[$sec->section_id]; } else { $secVal = $this->awe->get_section_default($sec->section_id); } /* $secVal = (empty($customSections[$sec->section_id]) ? $customSections[$sec->section_id] : $this->awe->get_section_default($sec->section_id));*/ if ($this->awe->check_section_active($sec->section_id) > 0) { $data['sections'][$sec->section_id]['title'] = $sec->section_title; $data['sections'][$sec->section_id]['input'] = array('name' => 'sections[' . $sec->section_id . ']', 'secname' => 'sections[' . $sec->section_id . ']', 'secID' => $sec->section_id, 'id' => 'sections', 'rows' => 5, 'value' => $secVal); } //end if active section } //end foreach custom section } //end if custom sections //display saved reports: $savedReports = $this->awe->get_saved_reports('saved'); $sReports = array(); if ($savedReports !== FALSE) { if ($savedReports->num_rows() > 0) { foreach ($savedReports->result() as $row) { $author_id = 0; $author = $this->user->get_user($row->report_author); if ($author !== FALSE) { $author_id = $author->name; } $sel = ''; if ($id == $row->report_id) { $sel = 'selected'; } $sReports[$row->report_id] = array('id' => $row->report_id, 'dateStart' => strftime('n/j/Y', $row->report_date_start), 'dateEnd' => strftime('n/j/Y', $row->report_date_end), 'author' => $author_id, 'selected' => $sel); } } } $data['savedReports'] = $sReports; /** SETUP VIEW **/ $data['header'] = 'aweSimReport: Generator'; /* view locations */ $currpage = 'reports_awesimreport_generator'; $currpage_js = 'report_awesimreport_generator_js'; break; /* GENERATOR */ /* GENERATOR */ case "sections": //DEAL WITH POST REQUESTS: if (isset($_POST['submit'])) { switch ($this->uri->segment(4)) { case 'add': $secName = trim($this->input->post('secName', TRUE)); $secTitle = trim($this->input->post('secTitle', TRUE)); $secDefaultContent = trim($this->input->post('secDefaultContent', TRUE)); //make sure both aren't empty, just in case: if (empty($secName)) { /* set the content of the message */ $message = '101: There was a problem adding this section. Please try again later.'; $flash['status'] = 'error'; $flash['message'] = text_output($message); /* write everything to the template */ $this->template->write_view('flash_message', '_base/admin/pages/flash', $flash); } else { //not empty //check that section name doesn't exist: $check = $this->awe->get_section_by_name($secName); if ($check === FALSE) { //it doesn't exist. GOOD! ADD! $secName = str_replace('&', '&', $secName); $secTitle = str_replace('&', '&', $secTitle); $secDefaultContent = str_replace('&', '&', $secDefaultContent); //if (empty($secTitle)) { $secTitle = $secName; } $insert_array = array('section_name' => $secName, 'section_title' => $secTitle, 'section_default' => $secDefaultContent, 'section_added_user' => $this->session->userdata('userid'), 'section_added_date' => time(), 'section_userdefined' => 1); /* insert the record */ $insert = $this->awe->add_new_section($insert_array); if ($insert > 0) { $message = "Section added successfully."; $flash['status'] = 'success'; $flash['message'] = text_output($message); } else { $message = '102: There was a problem adding the requested section. Please try again later.'; $flash['status'] = 'error'; $flash['message'] = text_output($message); } } else { $message = sprintf(lang('flash_duplicate_key'), lang('labels_site') . ' ' . lang('labels_message')); $flash['status'] = 'error'; $flash['message'] = text_output($message); } /* write everything to the template */ $this->template->write_view('flash_message', '_base/admin/pages/flash', $flash); } break; case 'edit': $secID = (int) $this->input->post('secID', TRUE); $secName = trim($this->input->post('secName', TRUE)); $secTitle = trim($this->input->post('secTitle', TRUE)); $secDefaultContent = trim($this->input->post('secDefaultContent', TRUE)); //make sure both aren't empty, just in case: if (empty($secName)) { /* set the content of the message */ $message = 'Err 101: There was a problem adding this section. Please try again later.'; /* $message .= '<br>secDefaultContent: '.$secDefaultContent; $message .= '<br>secName: '.$secName;*/ $flash['status'] = 'error'; $flash['message'] = text_output($message); /* write everything to the template */ $this->template->write_view('flash_message', '_base/admin/pages/flash', $flash); } else { //not empty //check that ID is valid: $section = $this->awe->get_section_details($secID); if ($section != false) { if ($section->num_rows() > 0) { $row = $section->row(); $secName = str_replace('&', '&', $secName); $secTitle = str_replace('&', '&', $secTitle); $secDefaultContent = str_replace('&', '&', $secDefaultContent); if (empty($secTitle)) { $secTitle = $secName; } $update_array = array('section_name' => $secName, 'section_title' => $secTitle, 'section_default' => $secDefaultContent, 'section_last_edit_user' => $this->session->userdata('userid'), 'section_last_edit_date' => time(), 'section_userdefined' => 1); /* insert the record */ $insert = $this->awe->update_section($secID, $update_array); if ($insert > 0) { $message = "Section edited successfully."; $flash['status'] = 'success'; $flash['message'] = text_output($message); } else { $message = 'Err 102: There was a problem editing the requested section. Please try again later.'; $flash['status'] = 'error'; $flash['message'] = text_output($message); } } else { $message = 'Error: This section seems to not exist anymore. If this persists, please submit a bug report.'; $message .= '<br>[DEBUG] SecID: ' . $secID; $flash['status'] = 'error'; $flash['message'] = text_output($message); } } else { $message = 'Error: This section seems to not exist anymore. If this persists, please submit a bug report.'; $message .= '<br>[DEBUG] SecID: ' . $secID; $flash['status'] = 'error'; $flash['message'] = text_output($message); } /* write everything to the template */ $this->template->write_view('flash_message', '_base/admin/pages/flash', $flash); } break; case 'sysedit': $secID = (int) $this->input->post('secID', TRUE); $secName = trim($this->input->post('secName', TRUE)); $secTitle = trim($this->input->post('secTitle', TRUE)); //make sure both aren't empty, just in case: if (empty($secName)) { /* set the content of the message */ $message = 'Err 201: There was a problem editing this section. Please try again later.'; $flash['status'] = 'error'; $flash['message'] = text_output($message); /* write everything to the template */ $this->template->write_view('flash_message', '_base/admin/pages/flash', $flash); } else { //not empty //check that ID is valid: $section = $this->awe->get_section_details($secID); if ($section != false) { if ($section->num_rows() > 0) { $row = $section->row(); $secName = str_replace('&', '&', $secName); $secDefaultContent = str_replace('&', '&', $secDefaultContent); if (empty($secTitle)) { $secTitle = $secName; } $update_array = array('section_title' => $secTitle, 'section_last_edit_user' => $this->session->userdata('userid'), 'section_last_edit_date' => time()); /* insert the record */ $insert = $this->awe->update_section($secID, $update_array); if ($insert > 0) { $message = "Section edited successfully."; $flash['status'] = 'success'; $flash['message'] = text_output($message); } else { $message = 'Err 202: There was a problem editing the requested section. Please try again later.'; $flash['status'] = 'error'; $flash['message'] = text_output($message); } } else { $message = 'Error: There was an error reading the fields information. If this persists, please submit a bug report.'; $message .= '<br>[DEBUG] SecID: ' . $secID; $flash['status'] = 'error'; $flash['message'] = text_output($message); } } else { $message = 'Error: There was an error reading the fields information. If this persists, please submit a bug report.'; $message .= '<br>[DEBUG] SecID: ' . $secID; $flash['status'] = 'error'; $flash['message'] = text_output($message); } /* write everything to the template */ $this->template->write_view('flash_message', '_base/admin/pages/flash', $flash); } break; } } //get sections: $allsections = $this->awe->get_all_sections(); if ($allsections->num_rows() > 0) { foreach ($allsections->result() as $row) { $chkactive = $this->awe->check_section_active($row->section_id); $data['sections'][$chkactive][$row->section_id] = array('id' => $row->section_id, 'userdefined' => $row->section_userdefined, 'name' => $row->section_name, 'title' => $row->section_title, 'default' => $row->section_default); } } //get section order: $data['reorganize'] = $this->awe->renumber_sections_order(); $sectionorder = $this->awe->get_section_order(); if ($sectionorder->num_rows() > 0) { foreach ($sectionorder->result() as $row) { //make sure these are active sections: if ($this->awe->check_section_active($row->section_id) > 0 && $this->awe->get_section_details($row->section_id) > 0) { $data['sections']['order'][$row->section_order] = $row->section_id; } // $data['sections']['order'][$row->section_order] = 1; } } $data['inputs'] = array('txtAddSection' => array('style' => 'width:100px;', 'name' => 'txtAddSection', 'id' => 'txtAddSection', 'value' => ''), 'txtDefaultContent' => array('rows' => 5, 'cols' => 15, 'name' => 'txtDefaultContent', 'id' => 'txtDefaultContent', 'value' => ''), 'addSection' => array('type' => 'submit', 'class' => 'button-main', 'name' => 'submit', 'value' => 'addSection', 'id' => 'addSection', 'content' => ucwords('Add Section')), 'saveSections' => array('type' => 'button', 'class' => 'button-main', 'name' => 'saveSections', 'id' => 'saveSections', 'content' => ucwords('Save Order'))); /** SETUP VIEW **/ $data['header'] = 'aweSimReport: Custom Sections'; /* view locations */ $currpage = 'reports_awesimreport_sections'; $currpage_js = 'report_awesimreport_sections_js'; break; /* SECTIONS */ /* SECTIONS */ case "settings": $data['inputs'] = array('txtSimStart' => array('style' => 'width:100px;', 'name' => 'txtSimStart', 'id' => 'txtSimStart', 'value' => $aweSettings['awe_txtSimStart']), 'txtSimEnd' => array('style' => 'width:100px;', 'name' => 'txtSimEnd', 'id' => 'txtSimEnd', 'value' => $aweSettings['awe_txtSimEnd']), 'txtDateFormat' => array('style' => 'width:250px;', 'name' => 'txtDateFormat', 'id' => 'txtDateFormat', 'value' => $aweSettings['awe_txtDateFormat']), 'txtReportDuration' => array('style' => 'width:70px;', 'name' => 'txtReportDuration', 'id' => 'txtReportDuration', 'value' => $aweSettings['awe_txtReportDuration']), 'txtStatOccurences' => array('style' => 'width:70px;', 'name' => 'txtStatOccurences', 'id' => 'txtStatOccurences', 'value' => $aweSettings['awe_txtStatOccurences']), 'txtTemplateFooter' => array('rows' => '5', 'name' => 'txtTemplateFooter', 'id' => 'txtTemplateFooter', 'value' => $aweSettings['awe_txtTemplateFooter']), 'txtEmailSubject' => array('style' => 'width:400px;', 'name' => 'txtEmailSubject', 'id' => 'txtEmailSubject', 'value' => $aweSettings['awe_txtEmailSubject']), 'txtReportTitle' => array('style' => 'width:400px;', 'name' => 'txtReportTitle', 'id' => 'txtReportTitle', 'value' => $aweSettings['awe_txtReportTitle']), 'txtEmailRecipients' => array('style' => 'width:400px;', 'name' => 'txtEmailRecipients', 'id' => 'txtEmailRecipients', 'value' => $aweSettings['awe_txtEmailRecipients']), 'chkPresenceTags' => array('name' => 'chkPresenceTags', 'id' => 'chkPresenceTags', 'value' => 'checked', 'checked' => $aweSettings['awe_chkPresenceTags']), 'txtPresenceTag_Present' => array('style' => 'width:100px;', 'name' => 'txtPresenceTag_Present', 'id' => 'txtPresenceTag_Present', 'value' => $aweSettings['awe_txtPresenceTag_Present']), 'txtPresenceTag_Unexcused' => array('style' => 'width:100px;', 'name' => 'txtPresenceTag_Unexcused', 'id' => 'txtPresenceTag_Unexcused', 'value' => $aweSettings['awe_txtPresenceTag_Unexcused']), 'txtPresenceTag_Excused' => array('style' => 'width:100px;', 'name' => 'txtPresenceTag_Excused', 'id' => 'txtPresenceTag_Excused', 'value' => $aweSettings['awe_txtPresenceTag_Excused']), 'chkShowRankImagesRoster' => array('name' => 'chkShowRankImagesRoster', 'id' => 'chkShowRankImagesRoster', 'value' => 'checked', 'checked' => $aweSettings['awe_chkShowRankImagesRoster']), 'chkShowRankImagesCOC' => array('name' => 'chkShowRankImagesCOC', 'id' => 'chkShowRankImagesCOC', 'value' => 'checked', 'checked' => $aweSettings['awe_chkShowRankImagesCOC']), 'saveSettings' => array('type' => 'button', 'class' => 'button-main', 'name' => 'saveSettings', 'id' => 'saveSettings', 'content' => ucwords('Save Settings')), 'saveSettings2' => array('type' => 'button', 'class' => 'button-main', 'name' => 'saveSettings', 'id' => 'saveSettings', 'content' => ucwords('Save Settings'))); /** SETUP VIEW **/ $data['header'] = 'aweSimReport: Settings'; /* view locations */ $currpage = 'reports_awesimreport_settings'; $currpage_js = 'report_awesimreport_settings_js'; break; /* SETTINGS */ /* SETTINGS */ case "templates": /* get all templates */ $templatelist = $this->awe->get_all_templates(); $templates = array(); if ($templatelist->num_rows() > 0) { foreach ($templatelist->result() as $row) { $isActive = 'no'; if ($row->template_id == $aweSettings['awe_ActiveTemplate']) { $isActive = 'yes'; } /* $templatefolder = 'aweSimReportTemplates/'.$row->template_folder; */ $templates[$row->template_id] = array('id' => $row->template_id, 'name' => $row->template_name, 'author' => $row->template_author, 'author_email' => $row->template_author_email, 'author_url' => $row->template_author_url, 'version' => $row->template_version, 'created_date' => $row->template_created_date, 'description' => $row->template_description, 'imagefolder' => $row->template_imagefolder, 'active' => $isActive, 'thumbnail' => array('src' => asset_location('aweSimReportTemplates/' . $row->template_folder, 'thumbnail.png'), 'class' => 'image', 'alt' => $row->template_name, 'title' => $row->template_name, 'id' => 'templ_img')); } } $data['templates'] = $templates; /** SETUP VIEW **/ $data['header'] = 'aweSimReport: Templates'; /* view locations */ $currpage = 'reports_awesimreport_templates'; $currpage_js = 'report_awesimreport_templates_js'; break; /* TEMPLATES */ /* TEMPLATES */ case "archive": $archnum = $this->awe->count_archive(); $pages = ceil((int) $archnum / 10); $pg = '1'; $min = 0; $data['archnum'] = $archnum; if ($this->uri->segment(4, 0, TRUE) > 1) { $pg = $this->uri->segment(4, 0, TRUE); } if ($pg > $pages) { $pg = $pages; } $min = $pg * 10 - 10; $data['pg'] = $pg; $data['pages'] = $pages; $data['images']['icons']['loading'] = array('src' => img_location('loading-circle.gif', $this->skin, 'admin'), 'alt' => '', 'class' => 'image'); //go over archive list: $archive = $this->awe->get_archived_reports('', $min); $dateFormat = $aweSettings['awe_txtDateFormat']; if ($archive->num_rows() > 0) { foreach ($archive->result() as $item) { $curruserid = $item->report_author; $currchar = $this->char->get_character($curruserid); $curruser = $this->user->get_user($curruserid); //get the current user (reporting officer): $posts = $this->pos->get_position($currchar->position_1); $positions = $posts !== FALSE ? $posts->pos_name : ''; if ((int) $currchar->position_2 > 0) { $positions .= " & " . $this->pos->get_position($currchar->position_2, 'pos_name'); } if ($item->report_date_start <= 100 || $item->report_date_end <= 100) { $dStart = ''; $dEnd = ''; } else { $dStart = strftime($dateFormat, (int) $item->report_date_start); $dEnd = strftime($dateFormat, (int) $item->report_date_end); } $data['archive'][$item->report_id] = array('id' => $item->report_id, 'date_start' => $dStart, 'date_end' => $dEnd, 'repofficer' => $this->char->get_character_name($curruserid, TRUE), 'repofficer_userid' => $item->arch_repofficer_userid, 'repofficer_charid' => $curruser->main_char, 'repofficer_position' => $positions, 'display' => $item->report_status, 'template' => $item->report_template, 'date_sent' => $item->report_date_sent); $pubcheck = ''; if ($item->report_status == 'published') { $pubcheck = 'checked'; } $data['chkPublish'][$item->report_id] = array('name' => 'chkPublish', 'id' => 'chkPublish', 'checked' => $pubcheck, 'value' => $item->report_id); } //end foreach } else { $data['archive'] = ''; } //end if archive exists /* build the images array */ $data['images']['icons'] = array('hidden' => array('src' => img_location('user-reject.png', $this->skin, 'admin'), 'class' => 'image', 'title' => 'Hidden (Click to make public)'), 'published' => array('src' => img_location('user-accept.png', $this->skin, 'admin'), 'class' => 'image', 'title' => 'Published (Click to make private)'), 'delete' => array('src' => img_location('minus-circle.png', $this->skin, 'admin'), 'class' => 'image', 'title' => 'Delete')); $data['inputs'] = array('submit' => array('type' => 'submit', 'class' => 'button-main', 'name' => 'submit', 'id' => 'submit', 'content' => ucwords('Apply All'))); $data['currReportTemplate'] = $aweSettings['awe_ActiveTemplate']; /** SETUP VIEW **/ $data['header'] = 'aweSimReport: Archive'; /* view locations */ $currpage = 'reports_awesimreport_archive'; $currpage_js = 'report_awesimreport_archive_js'; break; /* ARCHIVE */ /* ARCHIVE */ case "stats": $dates = array(); $result = array(); $sPeriod = $aweSettings['awe_txtReportDuration']; if (empty($sPeriod)) { $sPeriod = 30; //approx a month } $rawStatPeriod = $sPeriod * 86400; //turn into seconds $counter = 0; if ($aweSettings['awe_txtStatOccurences'] < 1) { $repOccurences = 10; } else { $repOccurences = $aweSettings['awe_txtStatOccurences']; } $endDate = now(); while ($counter <= $repOccurences) { $startDate = (int) ($endDate - $rawStatPeriod); $curr_month = date('n', $endDate); $result[] = $this->awe->stats_total_logcount($startDate, $endDate) + 1; $dates[] = date('Mj', $endDate); $endDate = $startDate - 1; //next occurence start a month ago, a second earlier $counter++; } $maxval = max($result); $newresult = array(); foreach ($result as $sig) { //turn it into percentages: $newresult[] = $sig / $maxval * 100; } $data['dates'] = $dates; $data['result'] = $newresult; $halfmaxvalue = $maxval / 2; $imgsrc = "http://chart.apis.google.com/chart?"; $imgsrc .= "chxl=0:|" . implode('|', $dates); $imgsrc .= "&chxr=0,0,0|1,0," . (int) $maxval; $imgsrc .= "&chxs=0,AA0033,11.5,0,lt,676767|1,676767,11.5,0,lt,676767"; $imgsrc .= "&chxt=x,y"; $imgsrc .= "&chbh=a,5"; $imgsrc .= "&chs=500x400"; $imgsrc .= "&cht=bvg"; $imgsrc .= "&chd=t:" . implode(',', $newresult); $imgsrc .= "&chds=a"; $imgsrc .= "&chdlp=b"; $imgsrc .= "&chp=0"; $imgsrc .= "&chg=10,10,0,9"; $imgsrc .= "&chma=5"; $imgsrc .= "&chtt=Total+Log+Count"; $data['imggraph'] = array('src' => $imgsrc, 'alt' => 'Total Log Count', 'class' => 'image'); /** SETUP VIEW **/ $data['header'] = 'aweSimReport: Stats'; $currpage = 'reports_awesimreport_stats'; $currpage_js = 'report_awesimreport_stats_js'; break; } /* END SWITCH URI SEGMENT */ /** DISPLAY VIEW **/ $view_loc = view_location($currpage, $this->skin, 'admin'); $js_loc = js_location($currpage_js, $this->skin, 'admin'); /* produce write the header */ $this->template->write('title', $data['header']); /* produce view */ $this->template->write_view('javascript', $js_loc, $js_data); $this->template->write_view('content', $view_loc, $data); /* render the template */ $this->template->render(); }
<?php $act = !empty($_GET['act']) ? $_GET['act'] : 'login'; if (!empty($_SESSION['admin']['id']) && $act != 'logout') { js_location('./dashboard'); } if ($act == 'logout') { include './login/logout.php'; } else { include './login/login.php'; }
">管理後台</a></b></span> <hr> </div> <div class="model_navbar_list"> <?php include './../navlist.php'; ?> </div> </div> <?php $query = 'select * from `system` ; '; $query = query_despace($query); $result = mysql_query($query); if (!$result) { js_location(URL_ADMIN_ROOT); } $row = mysql_fetch_assoc($result); $flat_check = null; $birman_check = null; $classic_check = null; $single_check = null; $horizontal_check = null; switch ($row['social_skin']) { case 'flat': $flat_check = 'checked="true"'; break; case 'birman': $birman_check = 'checked="true"'; break; default:
<?php unset($_SESSION['admin']); js_location("./?act=login");
<!DOCTYPE html> <?php include './../../../config/global.php'; include './../../../config/function.php'; if (empty($_SESSION['admin']['id'])) { js_location(URL_ROOT . "admin"); } ?> <html> <head> <meta name="robots" content="noindex"> <meta name="robots" content="nofollow" /> <meta name="googlebot" content="noindex"> <meta charset="UTF-8"> <title>品利興國際有限公司 - 後台管理系統</title> <link rel="stylesheet" href="<?php echo URL_LIB_ROOT . 'css/style_admin.css'; ?> "> <link rel="stylesheet" href="<?php echo URL_LIB_ROOT . 'css/bootstrap.css'; ?> "> <link href="<?php echo URL_LIB_ROOT . 'footable/css/footable.core.css'; ?> " rel="stylesheet" type="text/css"/> <link href="<?php echo URL_LIB_ROOT . 'footable/css/footable.standalone.css'; ?>
$a_category = null; $query = 'select * from `category` where `category`.`category_status` != "delete"'; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $a_category[] = $row; } break; case 'edit': /* tab1 */ $query = 'select * from `product` where `product_status` != "delete" and product_id = ' . $id; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $data = $row; } if (empty($data)) { js_location(URL_ADMIN2_ROOT . 'product', '[Error]找不到資料'); } $cover_dir = !empty($data['product_cover']) ? ADMIN_IMG_UPLOAD . P_CLASS . '/' . $data['product_cover'] : null; $cover = !empty($data['product_cover']) ? $data['product_cover'] : null; $category_name = null; $query = 'select category_name from `category` where `category`.`category_id` = "' . $data['product_category_id'] . '" and `category`.`category_status` != "delete"'; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $category_name = $row['category_name']; } /* tab2 */ $tags = json_decode($data['product_tags'], true); /* tab3 */ $query = 'select * from `product_meta` where product_id = ' . $id; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) {