From 5b00b28782f2c773aa9b63ac61584b70a366526c Mon Sep 17 00:00:00 2001
From: colly_wyx <wangyixiong_007@163.com>
Date: Fri, 30 Mar 2018 16:59:44 +0800
Subject: [PATCH] 更新
---
application/modules/Ad/controllers/Ad.php | 142 +++++++++
application/modules/Ad/views/ad/edit.phtml | 104 ++++++
application/library/Service/Daily.php | 52 +++
application/modules/Ad/views/ad/add.phtml | 102 ++++++
application/modules/Ad/views/ad/index.phtml | 164 ++++++++++
application/library/Service/Ad.php | 71 ++++
application/library/Service/User.php | 2
application/library/FileUpload.php | 239 +++++++++++++++
application/models/Ad.php | 7
application/models/Hourly.php | 7
10 files changed, 888 insertions(+), 2 deletions(-)
diff --git a/application/library/FileUpload.php b/application/library/FileUpload.php
new file mode 100644
index 0000000..5f603f6
--- /dev/null
+++ b/application/library/FileUpload.php
@@ -0,0 +1,239 @@
+<?php
+ /**
+ file: fileupload.class.php ���������������FileUpload
+ ���������������������������������������������������������������������������������������������������������������
+ */
+class FileUpload {
+ private $path = "./uploads"; //���������������������������
+ private $allowtype = array('jpg','gif','png'); //���������������������������������
+ private $maxsize = 1000000; //������������������������������������
+ private $israndname = true; //������������������������������������ false���������
+
+ private $originName; //������������
+ private $tmpFileName; //���������������
+ private $fileType; //������������(������������)
+ private $fileSize; //������������
+ private $newFileName; //������������
+ private $errorNum = 0; //���������
+ private $errorMess=""; //������������������
+
+ /**
+ * ���������������������������$path, $allowtype,$maxsize, $israndname���
+ * ���������������������������������������������������
+ *@param string $key ���������������(������������������)
+ *@param mixed $val ���������������������������
+ *@return object ������������������$this���������������������������
+ */
+ function set($key, $val){
+ $key = strtolower($key);
+ if( array_key_exists( $key, get_class_vars(get_class($this) ) ) ){
+ $this->setOption($key, $val);
+ }
+ return $this;
+ }
+
+ /**
+ * ���������������������������
+ * @param string $fileFile ���������������������������
+ * @return bool ���������������������������true
+ */
+
+ function upload($fileField) {
+ $return = true;
+ /* ������������������������������ */
+ if( !$this->checkFilePath() ) {
+ $this->errorMess = $this->getError();
+ return false;
+ }
+ /* ������������������������������������������ */
+ $name = $_FILES[$fileField]['name']; //������������������������ 'Chrysanthemum.jpg'
+ $tmp_name = $_FILES[$fileField]['tmp_name']; //������������������������������������ 'D:\wamp\tmp\php71E6.tmp'
+ $size = $_FILES[$fileField]['size']; //��������������������� 879394 858 KB (879,394 ������)
+ $error = $_FILES[$fileField]['error']; //������������ 0
+
+ /* ������������������������������$file["name"]������������������ */
+ if(is_Array($name)){
+ $errors=array();
+ /*��������������������������������� ��� ��������������������������������������������������������������������� */
+ for($i = 0; $i < count($name); $i++){
+ /*������������������ */
+ if($this->setFiles($name[$i],$tmp_name[$i],$size[$i],$error[$i] )) {
+ if(!$this->checkFileSize() || !$this->checkFileType()){
+ $errors[] = $this->getError();
+ $return=false;
+ }
+ }else{
+ $errors[] = $this->getError();
+ $return=false;
+ }
+ /* ������������������������������������������ */
+ if(!$return)
+ $this->setFiles();
+ }
+
+ if($return){
+ /* ��������������������������������������������� */
+ $fileNames = array();
+ /* ������������������������������������������������������������������������������������ */
+ for($i = 0; $i < count($name); $i++){
+ if($this->setFiles($name[$i], $tmp_name[$i], $size[$i], $error[$i] )) {
+ $this->setNewFileName();
+ if(!$this->copyFile()){
+ $errors[] = $this->getError();
+ $return = false;
+ }
+ $fileNames[] = $this->newFileName;
+ }
+ }
+ $this->newFileName = $fileNames;
+ }
+ $this->errorMess = $errors;
+ return $return;
+ /*������������������������������*/
+ } else {
+ /* ������������������ */
+ if($this->setFiles($name,$tmp_name,$size,$error)) {
+ /* ������������������������������������������ */
+ if($this->checkFileSize() && $this->checkFileType()){
+ /* ��������������������������������� */
+ $this->setNewFileName();
+ /* ������������ ������0������������ ������0������������ */
+ if($this->copyFile()){
+ return true;
+ }else{
+ $return=false;
+ }
+ }else{
+ $return=false;
+ }
+ } else {
+ $return=false;
+ }
+ //������$return���false, ������������������������������������������errorMess���
+ if(!$return)
+ $this->errorMess=$this->getError();
+
+ return $return;
+ }
+ }
+
+ /**
+ * ������������������������������
+ * @param void ������������
+ * @return string ��������������������������������� ������������������������������������
+ */
+ public function getFileName(){
+ return $this->newFileName;
+ }
+
+ /**
+ * ���������������������������������������������������������������
+ * @param void ������������
+ * @return string ������������������������������������������������������������������������������
+ */
+ public function getErrorMsg(){
+ return $this->errorMess;
+ }
+
+ /* ������������������������ */
+ private function getError() {
+ $str = "������������<font color='red'>{$this->originName}</font>��������� : ";
+ switch ($this->errorNum) {
+ case 4: $str .= "���������������������"; break;
+ case 3: $str .= "���������������������������"; break;
+ case 2: $str .= "������������������������������HTML���������MAX_FILE_SIZE������������������"; break;
+ case 1: $str .= "������������������������php.ini���upload_max_filesize������������������"; break;
+ case -1: $str .= "���������������"; break;
+ case -2: $str .= "������������,���������������������������{$this->maxsize}���������"; break;
+ case -3: $str .= "������������"; break;
+ case -4: $str .= "������������������������������������������������������������������"; break;
+ case -5: $str .= "���������������������������������"; break;
+ default: $str .= "������������";
+ }
+ return $str.'<br>';
+ }
+
+ /* ���������$_FILES��������������� */
+ private function setFiles($name="", $tmp_name="", $size=0, $error=0) {
+ $this->setOption('errorNum', $error);
+ if($error)
+ return false;
+ $this->setOption('originName', $name);
+ $this->setOption('tmpFileName',$tmp_name);
+ $aryStr = explode(".", $name);
+ $this->setOption('fileType', strtolower($aryStr[count($aryStr)-1]));
+ $this->setOption('fileSize', $size);
+ return true;
+ }
+
+ /* ������������������������������ */
+ private function setOption($key, $val) {
+ $this->$key = $val;
+ }
+
+ /* ������������������������������ */
+ private function setNewFileName() {
+ if ($this->israndname) {
+ $this->setOption('newFileName', $this->proRandName());
+ } else{
+ $this->setOption('newFileName', $this->originName);
+ }
+ }
+
+ /* ��������������������������������������������� */
+ private function checkFileType() {
+ if (in_array(strtolower($this->fileType), $this->allowtype)) {
+ return true;
+ }else {
+ $this->setOption('errorNum', -1);
+ return false;
+ }
+ }
+
+ /* ��������������������������������������������� */
+ private function checkFileSize() {
+ if ($this->fileSize > $this->maxsize) {
+ $this->setOption('errorNum', -2);
+ return false;
+ }else{
+ return true;
+ }
+ }
+
+ /* ������������������������������������������ */
+ private function checkFilePath() {
+ if(empty($this->path)){
+ $this->setOption('errorNum', -5);
+ return false;
+ }
+ if (!file_exists($this->path) || !is_writable($this->path)) {
+ if (!@mkdir($this->path, 0755)) {
+ $this->setOption('errorNum', -4);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /* ��������������������� */
+ private function proRandName() {
+ $fileName = date('YmdHis')."_".rand(1000,9999);
+ return $fileName.'.'.$this->fileType;
+ }
+
+ /* ������������������������������������ */
+ private function copyFile() {
+ if(!$this->errorNum) {
+ $path = rtrim($this->path, '/').'/';
+ $path .= $this->newFileName;
+ if (@move_uploaded_file($this->tmpFileName, $path)) {
+ return true;
+ }else{
+ $this->setOption('errorNum', -3);
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ }
\ No newline at end of file
diff --git a/application/library/Service/Ad.php b/application/library/Service/Ad.php
new file mode 100644
index 0000000..4018f9f
--- /dev/null
+++ b/application/library/Service/Ad.php
@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * ���������������
+ */
+class Service_Ad{
+
+ public function __construct(){
+ $this->ad_model = new AdModel();
+ }
+
+ /**
+ * ������������������
+ * @param array $query [description]
+ * @param array $fields [description]
+ * @param array $sort [description]
+ * @param integer $limit [description]
+ * @param integer $skip [description]
+ * @return [type] [description]
+ */
+ public function getAdList($query=array(),$fields=array(),$sort=array(),$limit=0,$skip=0){
+ return $this->ad_model->getList($query, $fields, $sort, $limit, $skip);
+ }
+
+ /**
+ * ������������������
+ * @return [type] [description]
+ */
+ public function getAdTotal($query=array(),$limit=0,$skip=0){
+ return $this->ad_model->count($query, $limit, $skip);
+ }
+
+ /**
+ * ���������������������������
+ * @param array $query [description]
+ * @param array $field [description]
+ * @return [type] [description]
+ */
+ public function getAdInfo($query = array(), $field = array()){
+ return $this->ad_model->get($query, $field);
+ }
+
+ /**
+ * ������������
+ * @param [type] $data [description]
+ */
+ public function add($data){
+ return $this->ad_model->add($data);
+ }
+
+ /**
+ * ������������
+ * @param [type] $data [description]
+ * @param [type] $query [description]
+ * @return [type] [description]
+ */
+ public function update($data, $query){
+ return $this->ad_model->update($data, $query);
+ }
+
+ /**
+ * ������������
+ * @param [type] $query [description]
+ * @return [type] [description]
+ */
+ public function delete($query){
+ return $this->ad_model->delete($query);
+ }
+
+
+}
\ No newline at end of file
diff --git a/application/library/Service/Daily.php b/application/library/Service/Daily.php
index cec26f9..bdaa784 100644
--- a/application/library/Service/Daily.php
+++ b/application/library/Service/Daily.php
@@ -4,6 +4,7 @@
public function __construct(){
$this->daily_model = new DailyModel();
+ $this->hourly_model = new HourlyModel();
}
public function summary($day){
@@ -25,14 +26,63 @@
$time = date('Y-m-d H:i:s');
foreach ($datas as $data) {
$param['user_id'] = $data['user_id'];
- $param['day_avg'] = substr($data['day_avg'], 0, 5);
+ $param['day_avg'] = floatval(substr($data['day_avg'], 0, 5));
$param['date'] = $day;
$param['create_time'] = $time;
$this->daily_model->add($param);
unset($param);
+ for($i = 1; $i <= 8; $i ++){
+ if($i == 1){
+ $start_hour = '00:00:00';
+ $end_hour = '02:59:59';
+ }
+ elseif($i == 8){
+ $start_hour = '21:00:00';
+ $end_hour = '23:59:59';
+ }
+ else{
+ $hour = ($i - 1)*3;
+ $start_hour = $hour.':00:00';
+ $end_hour = ($hour + 2).':59:59';
+ if($hour < 10 ){
+ $start_hour = '0'.$start_hour;
+ }
+ if($hour + 2 < 10){
+ $end_hour = '0'.$end_hour;
+ }
+
+ }
+ $hourly_datas = $data_model->aggregate(
+ array(
+ array(
+ '$match' => array('create_time' => array('$gte' => $day.' '.$start_hour, '$lte' => $day.' '.$end_hour))
+ ),
+ array(
+ '$group' => array('_id' => '$user_id', 'avg' => array('$avg' => '$value'))
+ ),
+ array(
+ '$project' => array('_id' => 0, 'user_id' => '$_id', 'avg' => 1)
+ )
+ )
+ );
+ if($hourly_datas){
+ foreach ($hourly_datas as $hourly_data) {
+ $param['user_id'] = $hourly_data['user_id'];
+ $param['hour_avg'] = floatval(substr($hourly_data['avg'], 0, 5));
+ $param['date'] = $day;
+ $param['start_hour'] = $start_hour;
+ $param['end_hour'] = $end_hour;
+ $param['time_level'] = $i;
+ $param['create_time'] = $time;
+ $this->hourly_model->add($param);
+ unset($param);
+ }
+ }
+ }
}
$dailyLog_service = new Service_DailyLog();
$dailyLog_service->addLog($day);
+
return true;
}
else{
diff --git a/application/library/Service/User.php b/application/library/Service/User.php
index a3b6fda..768b7e5 100644
--- a/application/library/Service/User.php
+++ b/application/library/Service/User.php
@@ -98,4 +98,4 @@
}
return false;
}
-}
\ No newline at end of file
+}
diff --git a/application/models/Ad.php b/application/models/Ad.php
new file mode 100644
index 0000000..da81581
--- /dev/null
+++ b/application/models/Ad.php
@@ -0,0 +1,7 @@
+<?php
+
+class AdModel extends System_Model_Base{
+
+ public $table = "ad";
+
+}
\ No newline at end of file
diff --git a/application/models/Hourly.php b/application/models/Hourly.php
new file mode 100644
index 0000000..3598f9e
--- /dev/null
+++ b/application/models/Hourly.php
@@ -0,0 +1,7 @@
+<?php
+
+class HourlyModel extends System_Model_Base{
+
+ public $table = "data_hourly";
+
+}
\ No newline at end of file
diff --git a/application/modules/Ad/controllers/Ad.php b/application/modules/Ad/controllers/Ad.php
new file mode 100644
index 0000000..c35bc70
--- /dev/null
+++ b/application/modules/Ad/controllers/Ad.php
@@ -0,0 +1,142 @@
+<?php
+
+class AdController extends System_Controller_Admin{
+
+ public function init(){
+ parent::init();
+ $this->ad_service = new Service_Ad();
+ }
+
+ /**
+ * ������������
+ */
+ public function IndexAction(){
+ if($this->getRequest()->isXmlHttpRequest()){
+ $total = $this->ad_service->getAdTotal();
+ $data['draw'] = !empty($_REQUEST['draw'])?$_REQUEST['draw']:1;
+ $data['start'] = !empty($_REQUEST['start'])?$_REQUEST['start']:0;
+ $data['length'] = !empty($_REQUEST['length'])?$_REQUEST['length']:10;
+ $data['recordsTotal'] = $total;
+ $data['recordsFiltered'] = $total;
+ $data['data'] = $this->ad_service->getAdList(array(), array(), array(), $data['length'], $data['start']);
+ exit($this->sendToDataTable($data));
+ }
+ }
+
+ /**
+ * ������������
+ */
+ public function AddAction(){
+ if($this->getRequest()->isXmlHttpRequest()){
+ $data['name'] = $this->getRequest()->getPost('name');
+ if(FileUpload::upload('logo')){
+
+ }
+ $data['is_publish'] = $this->getRequest()->getPost('is_publish');
+ $data['content'] = $this->getRequest()->getPost('content');
+ $data['create_time'] = date('Y-m-d H:i:s');
+ if($this->ad_service->add($data)){
+ exit($this->showSuccess('������������������', true));
+ }
+ else{
+ exit($this->showError($this->user_service->error, 400, true));
+ }
+ }
+ $role_service = new service_Role();
+ $roles = $role_service->getRoleList();
+ $this->getView()->assign('roles', $roles);
+ }
+
+ /**
+ * ������������
+ */
+ public function EditAction($id){
+ $user = $this->user_service->getUserInfo(array('_id' => $id));
+ if($user){
+ if($this->getRequest()->isXmlHttpRequest()){
+ $data['nickname'] = $this->post('nickname');
+ $password = $this->post('password');
+ if(!empty($password))
+ $data['password'] = md5(md5($password).$user['encrypt']);
+ $data['refresh_frequency'] = $this->post('refresh_frequency');
+ $data['is_open_upload'] = $this->post('is_open_upload');
+ $data['video'] = $this->post('video');
+ $data['role'] = $this->post('role');
+ $data['edit_time'] = time();
+ $data['is_lock'] = $this->post('is_lock');
+ if($this->user_service->update($data, array('_id' => $id))){
+ exit($this->showSuccess('������������������', true));
+ }
+ else{
+ exit($this->showError($this->user_service->error, 400, true));
+ }
+ }
+ $role_service = new Service_Role();
+ $roles = $role_service->getRoleList();
+ $this->getView()->assign(array('user' => $user, 'roles' => $roles));
+ }
+ else{
+ $this->redirect('/error/show/type/no_data');
+ }
+ }
+
+ /**
+ * ������������������
+ */
+ public function MyAction(){
+ $user_id = $this->session['user']['user_id'];
+ $user = $this->user_service->getUserInfo(array('_id' => $user_id));
+ if($user){
+ if($this->getRequest()->isXmlHttpRequest()){
+ $data['nickname'] = $this->post('nickname');
+ $password = $this->post('password');
+ if(!empty($password))
+ $data['password'] = md5(md5($password).$user['encrypt']);
+ $data['refresh_frequency'] = $this->post('refresh_frequency');
+ $data['is_open_upload'] = $this->post('is_open_upload');
+ $data['video'] = $this->post('video');
+ $data['edit_time'] = time();
+ if($this->user_service->update($data, array('_id' => $user_id))){
+ exit($this->showSuccess('������������������', true));
+ }
+ else{
+ exit($this->showError($this->user_service->error, 400, true));
+ }
+ }
+ $role_service = new Service_Role();
+ $roles = $role_service->getRoleList();
+ $this->getView()->assign(array('user' => $user, 'roles' => $roles));
+ }
+ else{
+ $this->redirect('/error/show/type/no_data');
+ }
+ }
+
+ /**
+ * ������������������������������
+ */
+ public function CheckPhoneAction(){
+ $phone = $this->post('phone');
+ $result = $this->_checkPhone($phone);
+ if($this->isAjax()){
+ exit($this->send(array('valid' => $result)));
+ }
+ else{
+ return $result;
+ }
+ }
+
+ /**
+ * ������������������������
+ * @param [type] $phone [description]
+ * @return [type] [description]
+ */
+ public function _checkPhone($phone){
+ $user = $this->user_service->getUserInfo(array('phone' => $phone));
+ if($user)
+ return false;
+ else
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/application/modules/Ad/views/ad/add.phtml b/application/modules/Ad/views/ad/add.phtml
new file mode 100644
index 0000000..10d9fab
--- /dev/null
+++ b/application/modules/Ad/views/ad/add.phtml
@@ -0,0 +1,102 @@
+
+ <section class="content-header">
+ <h1>
+ ������������
+ </h1>
+ <ol class="breadcrumb">
+ <li><a href="/admin/index/index"><i class="fa fa-dashboard"></i> ������������</a></li>
+ <li><a href="/role/role/list">������������</a></li>
+ <li class="active">������������</li>
+ </ol>
+ </section>
+
+ <!-- Main content -->
+ <section class="content">
+ <div class="box-body pad">
+ <!-- general form elements -->
+ <div class="box box-primary">
+ <div class="box-header with-border">
+ <h3 class="box-title">������������</h3>
+ </div>
+ <!-- /.box-header -->
+ <!-- form start -->
+ <form role="form" id="validateform">
+ <div class="box-body">
+ <div class="form-group">
+ <label >������������</label>
+ <input type="text" class="form-control" id="name" name="name" placeholder="������������">
+ </div>
+ <div class="form-group">
+ <label >���������������</label>
+ <textarea class="form-control" id="description" name="description"></textarea>
+ </div>
+ <div class="form-group">
+ <label >���������������</label>
+ <?php
+ $first_modules = array();
+ $second_modules = array();
+ $third_modules = array();
+ foreach ($modules as $key => $module){
+ if($module['level'] == 1){
+ $first_modules[] = $module;
+ }
+ elseif($module['level'] == 2){
+ $second_modules[] = $module;
+ }
+ elseif($module['level'] == 3){
+ $third_modules[] = $module;
+ }
+ unset($modules[$key]);
+ }
+ ?>
+ <?php foreach ($first_modules as $f_module):?>
+ <div class="checkbox">
+ <label>
+ <input type="checkbox" class="minimal module" id="actions" name="actions[]" value="<?php echo $f_module['_id'];?>">
+ <?php echo $f_module['name'];?>
+ </label>
+
+ <?php foreach ($second_modules as $s_module):?>
+ <?php if($s_module['parent'] == $f_module['_id']):?>
+ <div class="checkbox">
+ ���
+ <label>
+ <input type="checkbox" class="minimal module" id="actions" name="actions[]" value="<?php echo $s_module['_id'];?>" >
+ <?php echo $s_module['name'];?>
+ </label>
+
+ <?php foreach ($third_modules as $t_module):?>
+ <?php if($t_module['parent'] == $s_module['_id']):?>
+ <div class="checkbox">
+ ���
+ <label>
+ <input type="checkbox" class="minimal module" id="actions" name="actions[]" value="<?php echo $t_module['_id'];?>" >
+ <?php echo $t_module['name'];?>
+ </label>
+ </div>
+ <?php endif;?>
+ <?php endforeach;?>
+ </div>
+ <?php endif;?>
+ <?php endforeach;?>
+ </div>
+ <?php endforeach;?>
+
+
+
+ </div>
+ </div>
+ <!-- /.box-body -->
+
+ <div class="box-footer">
+ <button type="submit" class="btn btn-primary" id="dosubmit">������</button>
+ </div>
+ </form>
+ </div>
+ </div>
+ </section>
+ <script src="/themes/AdminLTE/bootstrap/js/bootstrapValidator.min.js"></script>
+<script type="text/javascript">
+ var SITE_URL = '<?php echo Yaf_Registry::get('var')['site_url']; ?>';
+</script>
+<script src="/static/<?php echo $route['module']?>/<?php echo $route['controller']?>/js/<?php echo $route['action']?>.js"></script>
diff --git a/application/modules/Ad/views/ad/edit.phtml b/application/modules/Ad/views/ad/edit.phtml
new file mode 100644
index 0000000..2879114
--- /dev/null
+++ b/application/modules/Ad/views/ad/edit.phtml
@@ -0,0 +1,104 @@
+
+ <section class="content-header">
+ <h1>
+ ���������������
+ </h1>
+ <ol class="breadcrumb">
+ <li><a href="/admin/index/index"><i class="fa fa-dashboard"></i> ������������</a></li>
+ <li><a href="/role/role/list">���������������</a></li>
+ <li class="active">���������������</li>
+ </ol>
+ </section>
+
+ <!-- Main content -->
+ <section class="content">
+ <div class="box-body pad">
+ <!-- general form elements -->
+ <div class="box box-primary">
+ <div class="box-header with-border">
+ <h3 class="box-title">���������������</h3>
+ </div>
+ <!-- /.box-header -->
+ <!-- form start -->
+ <form role="form" id="validateform">
+ <div class="box-body">
+ <div class="form-group">
+ <label >������������</label>
+ <input type="text" class="form-control" id="name" name="name" placeholder="������������" value="<?php echo $role['name']?>">
+ </div>
+ <div class="form-group">
+ <label >���������������</label>
+ <textarea class="form-control" id="description" name="description"><?php echo $role['description']?></textarea>
+ </div>
+ <div class="form-group">
+ <label >���������������</label>
+ <?php
+ $role_auth = explode(',', $role['modules']);
+ $first_modules = array();
+ $second_modules = array();
+ $third_modules = array();
+ foreach ($modules as $key => $module){
+ if($module['level'] == 1){
+ $first_modules[] = $module;
+ }
+ elseif($module['level'] == 2){
+ $second_modules[] = $module;
+ }
+ elseif($module['level'] == 3){
+ $third_modules[] = $module;
+ }
+ unset($modules[$key]);
+ }
+ ?>
+ <?php foreach ($first_modules as $f_module):?>
+ <div class="checkbox">
+ <label>
+ <input type="checkbox" <?php echo in_array($f_module['_id'], $role_auth)?"checked":"";?> class="minimal module" id="actions" name="actions[]" value="<?php echo $f_module['_id'];?>">
+ <?php echo $f_module['name'];?>
+ </label>
+
+ <?php foreach ($second_modules as $s_module):?>
+ <?php if($s_module['parent'] == $f_module['_id']):?>
+ <div class="checkbox">
+ ���
+ <label>
+ <input type="checkbox" <?php echo in_array($s_module['_id'], $role_auth)?"checked":"";?> class="minimal module" id="actions" name="actions[]" value="<?php echo $s_module['_id'];?>" >
+ <?php echo $s_module['name'];?>
+ </label>
+
+ <?php foreach ($third_modules as $t_module):?>
+ <?php if($t_module['parent'] == $s_module['_id']):?>
+ <div class="checkbox">
+ ���
+ <label>
+ <input type="checkbox" <?php echo in_array($t_module['_id'], $role_auth)?"checked":"";?> class="minimal module" id="actions" name="actions[]" value="<?php echo $t_module['_id'];?>" >
+ <?php echo $t_module['name'];?>
+ </label>
+ </div>
+ <?php endif;?>
+ <?php endforeach;?>
+ </div>
+ <?php endif;?>
+ <?php endforeach;?>
+ </div>
+ <?php endforeach;?>
+
+
+
+ </div>
+ </div>
+ <!-- /.box-body -->
+
+ <div class="box-footer">
+ <button type="submit" class="btn btn-primary" id="dosubmit">������</button>
+ </div>
+ </form>
+ </div>
+ </div>
+ </section>
+ <script src="/themes/AdminLTE/bootstrap/js/bootstrapValidator.min.js"></script>
+<script type="text/javascript">
+ var SITE_URL = '<?php echo Yaf_Registry::get('var')['site_url']; ?>';
+ var ID = '<?php echo $role['_id'];?>';
+</script>
+<script src="/static/<?php echo $route['module']?>/<?php echo $route['controller']?>/js/<?php echo $route['action']?>.js"></script>
diff --git a/application/modules/Ad/views/ad/index.phtml b/application/modules/Ad/views/ad/index.phtml
new file mode 100644
index 0000000..a5c8180
--- /dev/null
+++ b/application/modules/Ad/views/ad/index.phtml
@@ -0,0 +1,164 @@
+
+ <link rel="stylesheet" href="/themes/AdminLTE/plugins/datatables/dataTables.bootstrap.css">
+
+ <section class="content-header">
+ <h1>
+ ������������
+ </h1>
+ <ol class="breadcrumb">
+ <li><a href="/admin/index/index"><i class="fa fa-dashboard"></i> ������������</a></li>
+ <li><a href="/article/manager/list">������������</a></li>
+ <li class="active">������������</li>
+ </ol>
+ </section>
+
+ <!-- Main content -->
+ <section class="content">
+ <div class="row">
+ <div class="col-xs-12">
+ <div class="box">
+ <div class="box-header">
+ <h3 class="box-title">������������</h3>
+ </div>
+
+ <!-- /.box-header -->
+ <div class="box-body">
+ <table id="table_list" class="table table-bordered table-hover">
+ <thead>
+ <tr>
+ <th>������logo</th>
+ <th>������������</th>
+ <th>������������</th>
+ <th>������������</th>
+ <th>���������</th>
+ <th>������</th>
+ </tr>
+ </thead>
+ </table>
+ </div>
+ <!-- /.box-body -->
+ </div>
+ <!-- /.box -->
+ </section>
+
+<script>
+ $(function () {
+
+ var config = {
+ "dom": 'l<"#toolbar">frtip',
+ /*
+ * ���������false
+ * ���������������������������������������������������������������������������...���
+ * ���������������������������������������������������������������������������������������������������������������������������������������������������
+ */
+ "processing":true,
+ /*
+ * ���������true
+ * ���������������������������������������������������������������������������������10���25���50���100���������������������bPaginate���������
+ */
+ "lengthChange":false,
+ "serverSide":true,
+ "autoWidth": true,
+ "language":{
+ "lengthMenu": "������������ _MENU_ ���",
+ "emptyTable": "������������������������",
+ "processing": "������������������...",
+ "search": "������ _INPUT_",
+ "info": "������ _START_ ��� _END_ ��������������� _TOTAL_ ���",
+ "zeroRecords": "������������������������������",
+ "sInfoEmpty": "",
+ "paginate": {
+ "first": "������",
+ "previous": "���������",
+ "next": "���������",
+ "last": "������"
+ },
+ },
+ "ajax":{
+ "url": "/ad/ad/index",
+ "type":"POST",
+ },
+ "columns":[
+ {
+ "data":"name",
+ "orderable":false
+ },
+ {
+ "data":"category",
+ "orderable":false
+ },
+ {
+ "data":"is_publish",
+ "orderable":false
+ },
+ {
+ "data":"create_time",
+ "orderable":false
+ },
+ {
+ "data":null,
+ "orderable":false
+ },
+ ],
+ "columnDefs": [
+ {
+ "targets":1,
+ "searchable":false,
+ },
+ {
+ "targets":2,
+ "searchable":false,
+ "render":function(data, type, row, meta){
+ if(data == 0) {
+ return "���������";
+ }
+ else{
+ return "���������";
+ }
+ }
+ },
+ {
+ "targets":4,
+ "searchable":false,
+ "render":function(data, type, row, meta){
+ return '<a class="btn btn-primary" href="/<?php echo $route['module']?>/<?php echo $route['controller']?>/edit/id/'+row['_id']+'">������</a> <a class="btn btn-danger del" data-id="'+row['_id']+'" data-target="/<?php echo $route['module']?>/<?php echo $route['controller']?>/del">������</a>'
+ }
+ }
+ ],
+ "initComplete": function(){
+ $("#toolbar").css("width", "100px").css("display", "inline").css("margin-left", "10px");
+ $("#toolbar").append('<a id="build" class="btn btn-success" data-toggle="modal" data-target="" href="/<?php echo $route['module']?>/<?php echo $route['controller']?>/add"> <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>������ <a> ');
+ $(".del").bind('click', function(){
+ if(confirm('���������������������������������')){
+ $.ajax({
+ type: "POST",
+ url: $(this).data('target'),
+ data: {id:$(this).data('id')},
+ success:function(response){
+ var dataObj=jQuery.parseJSON(response);
+ if(dataObj.code == 200)
+ {
+ $.scojs_message('������������', $.scojs_message.TYPE_OK);
+ setTimeout(function(){window.location.href = "/<?php echo $route['module']?>/<?php echo $route['controller']?>/<?php echo $route['action']?>";}, 600);
+ }else
+ {
+ $.scojs_message(dataObj.content, $.scojs_message.TYPE_ERROR);
+ }
+ },
+ error: function (request, status, error) {
+ $.scojs_message(request.responseText, $.scojs_message.TYPE_ERROR);
+ }
+ });
+ }
+ else{
+ return false;
+ }
+ });
+ }
+
+ }
+ $("#table_list").DataTable(config);
+
+
+ });
+</script>
--
Gitblit v1.8.0