doudoudzj 6 年之前
父节点
当前提交
94b07d1336

+ 9 - 24
admin/controllers/news.php

@@ -7,31 +7,16 @@ if (!defined('IN_SYS')) {
 }
 
 
-$tickets = [
+$news = [
     "total" => 10,
     "pages" => 4,
     "page" => 1,
-    "list" => [
-        [
-            "date" => "Saturday, August 11th, 2018 (04:50)",
-            "department" => "Saturday, August 11th, 2018 (04:50)",
-            "subject" => "Invoice Payment Confirmation",
-            "status" => "",
-            "lastupdated" => ""
-        ],
-        [
-            "date" => "Friday, August 10th, 2018 (12:00)",
-            "department" => "Friday, August 10th, 2018 (12:00)",
-            "subject" => "Customer Invoice",
-            "status" => "",
-            "lastupdated" => ""
-        ],
-        [
-            "date" => "Tuesday, April 3rd, 2018 (00:51)",
-            "department" => "Tuesday, April 3rd, 2018 (00:51)",
-            "subject" => "Your password has been reset",
-            "status" => "",
-            "lastupdated" => ""
-        ]
-    ]
+    "list" => []
 ];
+
+$status_types = [
+    "关闭",
+    "打开"
+];
+
+$news["list"] = $dbpdo->select_and("news");

+ 39 - 0
admin/controllers/news_add.php

@@ -5,3 +5,42 @@ if (!defined('IN_SYS')) {
     header("Location: ../../admin.php");
     exit;
 }
+
+$err = getMsg("errors");
+$data = getMsg("form_data");
+
+$status_types = [
+    "关闭",
+    "打开"
+];
+
+if (isset($_POST["do_add_news"])) {
+    $title = filter_input(INPUT_POST, "title", FILTER_SANITIZE_STRING);
+    $status = filter_input(INPUT_POST, "status", FILTER_SANITIZE_STRING);
+    $content = filter_input(INPUT_POST, "content", FILTER_SANITIZE_STRING);
+    $errors = array();
+
+    $data = [
+        "title" => $title,
+        "status" => $status,
+        "content" => $content
+    ];
+    if (!count($errors)) {
+        $data["date"] = time();
+        $data["lastupdated"] = "";
+        $res = $dbpdo->add("news", $data);
+        print_r($res);
+        if ($res) {
+            setMsg("msg_notify", "Add News successfully.", "success");
+            redirect("admin", "news_details", ["id" => $res]);
+        } else {
+            setMsg("form_data", $data);
+            setMsg("msg_notify", "Add News failed.", "warning");
+            redirect("admin", "news_add");
+        }
+    } else {
+        setMsg("form_data", $data);
+        setMsg("errors", $errors);
+        redirect("admin", "news");
+    }
+}

+ 28 - 0
admin/controllers/news_details.php

@@ -0,0 +1,28 @@
+<?php
+
+if (!defined('IN_SYS')) {
+    // exit('禁止访问');
+    header("Location: ../../admin.php");
+    exit;
+}
+
+$err = getMsg("errors");
+$data = getMsg("form_data");
+
+if (empty($_GET["id"])) {
+    redirect("admin", "news");
+}
+
+$status_types = [
+    "关闭",
+    "打开"
+];
+
+$news_id = filter_input(INPUT_GET, "id", FILTER_SANITIZE_STRING);
+$res = $dbpdo->find_and('news', ["id" => $news_id]);
+if ($res) {
+    $data = $res;
+} else {
+    setMsg("msg_notify", "The News Not found.", "warning");
+    redirect("admin", "news");
+}

+ 7 - 1
admin/controllers/tickets.php

@@ -15,6 +15,12 @@ $tickets = [
     "page" => 1,
     "list" => [],
 ];
-
+$ticket_types = [
+    "技术支持", "销售财务", "管理员信箱"
+];
+$status_types = [
+    "关闭",
+    "打开"
+];
 // $tickets["list"] = $dbpdo->select('SELECT * FROM `tickets` WHERE `user_id` = ?', [$user->id]);
 $tickets["list"] = $dbpdo->select_and("tickets");

+ 60 - 0
admin/controllers/tickets_details.php

@@ -0,0 +1,60 @@
+<?php
+
+if (!defined('IN_SYS')) {
+    // exit('禁止访问');
+    header("Location: ../../admin.php");
+    exit;
+}
+
+$err = getMsg("errors");
+$data = getMsg("form_data");
+
+$ticket_types = [
+    "技术支持", "销售财务", "管理员信箱"
+];
+$status_types = [
+    "关闭",
+    "打开"
+];
+if (empty($_GET["id"])) {
+    redirect("admin", "tickets");
+}
+$tickets_id = filter_input(INPUT_GET, "id", FILTER_SANITIZE_STRING);
+
+if (isset($_POST["do_comment_tickets"])) {
+    $comment = filter_input(INPUT_POST, "comment", FILTER_SANITIZE_STRING);
+    $errors = array();
+
+    $data = [
+        "tickets_id" => $tickets_id,
+        "comment" => $comment
+    ];
+    if (!count($errors)) {
+        $data["date"] = time();
+        $data["user_type"] = "admin";
+        if ($dbpdo->find_and('tickets', ["id" => $tickets_id, "user_id" => $user->id])) {
+            if ($dbpdo->add("tickets_comment", $data)) {
+                $dbpdo->update("tickets", ["lastupdated" => $data["date"]]);
+                setMsg("msg_notify", "Add Comment successfully.", "success");
+            } else {
+                setMsg("msg_notify", "Add Comment failed.", "warning");
+            }
+            redirect("admin", "tickets_details", ["id" => $res]);
+        } else {
+            setMsg("msg_notify", "The Tickets Not found.", "warning");
+            redirect("admin", "tickets");
+        }
+    } else {
+        setMsg("form_data", $data);
+        setMsg("errors", $errors);
+        redirect("admin", "tickets_details", ["id" => $res]);
+    }
+} else {
+    $res = $dbpdo->find_and('tickets', ["id" => $tickets_id]);
+    if ($res) {
+        $data = $res;
+    } else {
+        setMsg("msg_notify", "The Tickets Not found.", "warning");
+        redirect("admin", "tickets");
+    }
+}

+ 10 - 12
admin/views/news.php

@@ -14,7 +14,7 @@ if (!defined('IN_SYS')) {
                 <div class="panel-heading">
                     <span class="panel-title"><?php echo I18N('news'); ?></span>
                     <div class="pull-right">
-                        <a class="btn btn-default btn-xs" href="<?php echo setRouter('admin', 'news_add'); ?>">Add</a>
+                        <a class="btn btn-default btn-xs" href="<?php echo setRouter('admin', 'news_add'); ?>"><?php echo I18N('add'); ?></a>
                     </div>
                 </div>
                 <div class="panel-body">
@@ -23,21 +23,19 @@ if (!defined('IN_SYS')) {
                             <thead>
                                 <tr>
                                     <th>Date</th>
-                                    <th>Department</th>
-                                    <th>Subject</th>
+                                    <th>Title</th>
                                     <th>Status</th>
-                                    <th>Last Updated</th>
+                                    <th></th>
                                 </tr>
                             </thead>
                             <tbody>
-                                <?php if ($tickets["total"]) {
-                                    foreach ($tickets["list"] as $key => $value) { ?>
+                                <?php if ($news["total"] && $news["list"]) {
+                                    foreach ($news["list"] as $key => $value) { ?>
                                         <tr>
-                                            <th><?php echo $value["date"]; ?></th>
-                                            <td><?php echo $value["department"]; ?></td>
-                                            <td><?php echo $value["subject"]; ?></td>
-                                            <td><?php echo $value["status"]; ?></td>
-                                            <td><?php echo $value["lastupdated"]; ?></td>
+                                            <td><?php echo cTime($value["date"]); ?></td>
+                                            <td><?php echo $value["title"]; ?></td>
+                                            <td><?php echo $status_types[$value['status']]; ?></td>
+                                            <td><a class="btn btn-default btn-xs pull-right" href="<?php echo setRouter('admin', 'news_details', ['id' => $value['id']]); ?>">Details</a></td>
                                         </tr>
                                     <?php }
                             } else { ?>
@@ -50,7 +48,7 @@ if (!defined('IN_SYS')) {
                     </div>
                 </div>
                 <div class="panel-footer">
-                    <span><?php echo $tickets["total"]; ?> Records Found, Page <?php echo $tickets["page"]; ?> of <?php echo $tickets["pages"]; ?></span>
+                    <span><?php echo $news["total"]; ?> Records Found, Page <?php echo $news["page"]; ?> of <?php echo $news["pages"]; ?></span>
                 </div>
             </div>
         </div>

+ 25 - 12
admin/views/news_add.php

@@ -13,21 +13,34 @@ if (!defined('IN_SYS')) {
             <div class="panel panel-default">
                 <div class="panel-heading">
                     <span class="panel-title">News Add</span>
-                    <!-- <div class="pull-right">
-                        <a class="btn btn-default btn-xs" href="<?php echo setRouter('admin', 'news'); ?>">Add News</a>
-                    </div> -->
+                    <div class="pull-right">
+                        <a class="btn btn-default btn-xs" href="<?php echo setRouter('admin', 'news'); ?>"><?php echo I18N('list'); ?></a>
+                    </div>
                 </div>
                 <div class="panel-body">
                     <form action="" method="POST">
-                        <label>
-                            <span>Title:</span>
-                            <input type="text" name="title" value="" class="form-control" maxlength="8" placeholder="Title">
-                        </label>
-                        <label>
-                            <span>Content:</span>
-                            <textarea name="content" class="form-control" rows="10" maxlength="5000" placeholder="Content"></textarea>
-                        </label>
-                        <button type="submit" name="do_add_news" class="btn btn-primary">Add</button>
+                        <div class="form-group">
+                            <label for="title">Title: <sup>*</sup></label>
+                            <input type="text" name="title" id="title" value="<?php echo ($data['title']); ?>" class="form-control <?php echo (isset($err['title_err'])) ? 'is-invalid' : ''; ?>" maxlength="100" placeholder="Title">
+                            <span class="text-warning"><?php echo isset($err["title_err"]) ? $err["title_err"] : ""; ?></span>
+                        </div>
+                        <div class="form-group">
+                            <label for="content">Content: <sup>*</sup></label>
+                            <textarea name="content" id="content" value="<?php echo ($data['content']); ?>" class="form-control <?php echo (isset($err['content_err'])) ? 'is-invalid' : ''; ?>" rows="10" maxlength="5000" placeholder="Content"></textarea>
+                            <span class="text-warning"><?php echo isset($err["content_err"]) ? $err["content_err"] : ""; ?></span>
+                        </div>
+                        <div class="form-group">
+                            <label for="status">Status: <sup>*</sup></label>
+                            <select name="status" id="status" class="form-control <?php echo (isset($err['status_err'])) ? 'is-invalid' : ''; ?>">
+                                <?php foreach ($status_types as $key => $value) { ?>
+                                    <option value="<?php echo $key; ?>"><?php echo $value; ?></option>
+                                <?php } ?>
+                            </select>
+                            <span class="text-warning"><?php echo isset($err["status_err"]) ? $err["status_err"] : ""; ?></span>
+                        </div>
+                        <div class="form-group">
+                            <button type="submit" name="do_add_news" class="btn btn-primary"><?php echo I18N('add'); ?></button>
+                        </div>
                     </form>
                 </div>
                 <div class="panel-footer"></div>

+ 31 - 0
admin/views/news_details.php

@@ -0,0 +1,31 @@
+<?php
+if (!defined('IN_SYS')) {
+    // exit('禁止访问');
+    header("Location: ../../admin.php");
+    exit;
+}
+?>
+
+<div class="container">
+    <div class="row">
+        <div class="col-md-12">
+            <?php echo (getMsg("msg_notify")); ?>
+            <div class="panel panel-default">
+                <div class="panel-heading">
+                    <span class="panel-title">News Details</span>
+                    <div class="pull-right">
+                        <a class="btn btn-default btn-xs" href="<?php echo setRouter('admin', 'news'); ?>"><?php echo I18N('list'); ?></a>
+                        <a class="btn btn-default btn-xs" href="<?php echo setRouter('admin', 'news_add'); ?>"><?php echo I18N('add'); ?></a>
+                    </div>
+                </div>
+                <div class="panel-body">
+                    <p>Status: <?php echo $status_types[$data['status']]; ?></p>
+                    <p>Date: <?php echo cTime($data['date']); ?></p>
+                    <p>Title: <?php echo $data['title']; ?></p>
+                    <p>Content: <?php echo $data['content']; ?></p>
+                </div>
+                <div class="panel-footer"></div>
+            </div>
+        </div>
+    </div>
+</div>

+ 3 - 3
admin/views/tickets.php

@@ -31,10 +31,10 @@ if (!defined('IN_SYS')) {
                                 <?php if ($tickets["total"]) {
                                     foreach ($tickets["list"] as $key => $value) { ?>
                                         <tr>
-                                            <th><?php echo cTime($value["date"]); ?></th>
-                                            <td><?php echo $value["department"]; ?></td>
+                                            <td><?php echo cTime($value["date"]); ?></td>
+                                            <td><?php echo $ticket_types[$value["department"]]; ?></td>
                                             <td><?php echo $value["subject"]; ?></td>
-                                            <td><?php echo $value["status"]; ?></td>
+                                            <td><?php echo $status_types[$value["status"]]; ?></td>
                                             <td><?php echo cTime($value["lastupdated"]); ?></td>
                                             <td><a class="btn btn-default btn-xs pull-right" href="<?php echo setRouter('admin', 'tickets_details', ['id' => $value['id']]); ?>">Details</a></td>
                                         </tr>

+ 41 - 0
admin/views/tickets_details.php

@@ -0,0 +1,41 @@
+<?php
+if (!defined('IN_SYS')) {
+    // exit('禁止访问');
+    header("Location: ../../admin.php");
+    exit;
+}
+?>
+
+<div class="container">
+    <div class="row">
+        <div class="col-md-12">
+            <?php echo (getMsg("msg_notify")); ?>
+            <div class="panel panel-default">
+                <div class="panel-heading">
+                    <span class="panel-title">Tickets Details</span>
+                    <div class="pull-right">
+                        <a class="btn btn-default btn-xs" href="<?php echo setRouter('admin', 'tickets'); ?>"><?php echo I18N('list'); ?></a>
+                    </div>
+                </div>
+                <div class="panel-body">
+                    <p>Type: <?php echo $ticket_types[$data['department']]; ?></p>
+                    <p>Status: <?php echo $status_types[$data['status']]; ?></p>
+                    <p>Subject: <?php echo $data['subject']; ?></p>
+                    <p>Content: <?php echo $data['content']; ?></p>
+                    <form action="" method="POST">
+                        <div class="form-group">
+                            <label for="Comment">Comment: <sup>*</sup></label>
+                            <textarea name="comment" id="comment" value="<?php echo ($data['comment']); ?>" class="form-control <?php echo (isset($err['comment_err'])) ? 'is-invalid' : ''; ?>" rows="10" maxlength="5000" placeholder="Comment"></textarea>
+                            <span class="text-warning"><?php echo isset($err["comment_err"]) ? $err["comment_err"] : ""; ?></span>
+                        </div>
+                        <div class="form-group">
+                            <button type="submit" name="do_comment_tickets" class="btn btn-primary">Add Comment</button>
+                            <button type="submit" name="do_close_tickets" class="btn btn-primary">Close Tickets</button>
+                        </div>
+                    </form>
+                </div>
+                <div class="panel-footer"></div>
+            </div>
+        </div>
+    </div>
+</div>

+ 1 - 1
clientarea/views/header.php

@@ -6,7 +6,7 @@ if (!defined('IN_SYS')) {
 }
 ?>
 <!DOCTYPE html>
-<html lang="en">
+<html lang="<?php echo $current_lang; ?>">
 
 <head>
     <meta charset="utf-8" />

+ 3 - 1
clientarea/views/tickets.php

@@ -13,7 +13,9 @@ if (!defined('IN_SYS')) {
             <div class="panel panel-default">
                 <div class="panel-heading">
                     <span class="panel-title">Support Tickets</span>
-                    <a class="btn btn-default btn-xs pull-right" href="<?php echo setRouter('clientarea', 'tickets_add'); ?>">Add Ticket</a>
+                    <div class="pull-right">
+                        <a class="btn btn-default btn-xs" href="<?php echo setRouter('clientarea', 'tickets_add'); ?>"><?php echo I18N('add'); ?></a>
+                    </div>
                 </div>
                 <div class="panel-body">
                     <div class="table-responsive">

+ 4 - 2
clientarea/views/tickets_add.php

@@ -13,7 +13,9 @@ if (!defined('IN_SYS')) {
             <div class="panel panel-default">
                 <div class="panel-heading">
                     <span class="panel-title">Tickets Add</span>
-                    <a class="btn btn-default btn-xs pull-right" href="<?php echo setRouter('clientarea', 'tickets'); ?>">Tickets List</a>
+                    <div class="pull-right">
+                        <a class="btn btn-default btn-xs" href="<?php echo setRouter('clientarea', 'tickets'); ?>"><?php echo I18N('add'); ?></a>
+                    </div>
                 </div>
                 <div class="panel-body">
                     <form action="" method="POST">
@@ -37,7 +39,7 @@ if (!defined('IN_SYS')) {
                             <span class="text-warning"><?php echo isset($err["content_err"]) ? $err["content_err"] : ""; ?></span>
                         </div>
                         <div class="form-group">
-                            <button type="submit" name="do_add_tickets" class="btn btn-primary">Add</button>
+                            <button type="submit" name="do_add_tickets" class="btn btn-primary"><?php echo I18N('add'); ?></button>
                         </div>
                     </form>
                 </div>

+ 4 - 1
clientarea/views/tickets_details.php

@@ -13,7 +13,10 @@ if (!defined('IN_SYS')) {
             <div class="panel panel-default">
                 <div class="panel-heading">
                     <span class="panel-title">Tickets Details</span>
-                    <a class="btn btn-default btn-xs pull-right" href="<?php echo setRouter('clientarea', 'tickets'); ?>">Tickets List</a>
+                    <div class="pull-right">
+                        <a class="btn btn-default btn-xs" href="<?php echo setRouter('clientarea', 'tickets'); ?>"><?php echo I18N('list'); ?></a>
+                        <a class="btn btn-default btn-xs" href="<?php echo setRouter('clientarea', 'tickets_add'); ?>"><?php echo I18N('add'); ?></a>
+                    </div>
                 </div>
                 <div class="panel-body">
                     <p>Type: <?php echo $ticket_types[$data['department']]; ?></p>

+ 9 - 0
data/demo.sql

@@ -55,3 +55,12 @@ CREATE TABLE IF NOT EXISTS `tickets_comment`(
     PRIMARY KEY(`id`)
 ) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 100;
 
+CREATE TABLE IF NOT EXISTS `news`(
+    `id` INT(11) NOT NULL AUTO_INCREMENT,
+    `date` VARCHAR(255) NOT NULL,
+    `title` VARCHAR(255) NOT NULL,
+    `content` VARCHAR(5000) NOT NULL,
+    `status` TINYINT(4) NOT NULL,
+    `lastupdated` VARCHAR(255) NOT NULL,
+    PRIMARY KEY(`id`)
+) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 100;

+ 2 - 0
library/language/en-US/language.php

@@ -64,4 +64,6 @@ $LANG = [
     'about' => 'About',
     'aboutus' => 'About',
     'clientarea' => 'Client Area',
+    'add' => 'Add',
+    'list' => 'List'
 ];

+ 2 - 0
library/language/ko/language.php

@@ -64,4 +64,6 @@ $LANG = [
     'about' => '정보',
     'aboutus' => '회사 소개',
     'clientarea' => '고객센터',
+    'add' => '더하다',
+    'list' => '명부'
 ];

+ 2 - 0
library/language/zh-CN/language.php

@@ -64,4 +64,6 @@ $LANG = [
     'about'             => '关于',
     'aboutus'           => '关于我们',
     'clientarea'        => '客户中心',
+    'add'               => '新增',
+    'list'              => '列表'
 ];

+ 2 - 0
library/language/zh-HK/language.php

@@ -64,4 +64,6 @@ $LANG = [
     'about' => '關於',
     'aboutus' => '關於我們',
     'clientarea' => '客戶中心',
+    'add' => '新增',
+    'list' => '列表'
 ];

+ 2 - 0
library/language/zh-SG/language.php

@@ -64,4 +64,6 @@ $LANG = [
     'about' => '关于',
     'aboutus' => '关于我们',
     'clientarea' => '客户中心',
+    'add' => '新增',
+    'list' => '列表'
 ];

+ 2 - 0
library/language/zh-TW/language.php

@@ -64,4 +64,6 @@ $LANG = [
     'about' => '關於',
     'aboutus' => '關於我們',
     'clientarea' => '客戶中心',
+    'add' => '新增',
+    'list' => '列表'
 ];