/** * 会员登录 */ public function actionLogin() { $model = new Admin('login'); if (XUtils::method() == 'POST') { $model->attributes = $_POST['Admin']; if ($model->validate()) { $data = $model->find('username=:username', array('username' => $model->username)); if ($data === null) { $model->addError('username', '用户不存在'); AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,用户不存在:' . CHtml::encode($model->username), 'user_id' => 0)); } elseif (!$model->validatePassword($data->password)) { $model->addError('password', '密码不正确'); AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,密码不正确:' . CHtml::encode($model->username) . ',使用密码:' . CHtml::encode($model->password), 'user_id' => 0)); } elseif ($data->group_id == 2) { $model->addError('username', '用户被锁定,请联系网站管理'); } else { parent::_stateWrite(array('userId' => $data->id, 'userName' => $data->username, 'groupId' => $data->group_id, 'super' => $data->group_id == 1 ? 1 : 0), array('prefix' => '_admini')); $data->last_login_ip = XUtils::getClientIP(); $data->last_login_time = time(); $data->login_count = $data->login_count + 1; $data->save(); AdminLogger::_create(array('catalog' => 'login', 'intro' => '用户登录成功:' . CHtml::encode($model->username))); $this->redirect(array('default/index')); } } } $this->render('login', array('model' => $model)); }
/** * 批量操作 * */ public function actionBatch() { if (XUtils::method() == 'GET') { $command = trim($_GET['command']); $ids = intval($_GET['id']); } elseif (XUtils::method() == 'POST') { $command = trim($_POST['command']); $ids = $_POST['id']; is_array($ids) && ($ids = implode(',', $ids)); } else { XUtils::message('errorBack', '只支持POST,GET数据'); } empty($ids) && XUtils::message('error', '未选择记录'); switch ($command) { case 'delete': parent::_acl('position_delete'); $cityModel = new Position(); $cityModel->deleteAll('id IN(' . $ids . ')'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容,ID:' . $ids)); parent::_delete(new Position(), $ids, array('index')); break; default: throw new CHttpException(404, '错误的操作类型:' . $command); break; } }
/** * 批量操作 * */ public function actionBatch() { if (XUtils::method() == 'GET') { $command = trim($_GET['command']); $ids = intval($_GET['id']); } elseif (XUtils::method() == 'POST') { $command = trim($_POST['command']); $ids = $_POST['id']; is_array($ids) && ($ids = implode(',', $ids)); } else { XUtils::message('errorBack', '只支持POST,GET数据'); } empty($ids) && XUtils::message('error', '未选择记录'); switch ($command) { case 'delete': parent::_acl('attr_delete'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '属性删除,ID:' . $ids)); $attrModel = Attr::model()->findByPk($ids); Attr::clear(array('attrId' => $attrModel->id, 'attrName' => $attrModel->attr_name_alias, 'oldScope' => 'all')); parent::_delete(new Attr(), $ids, array('index')); break; default: throw new CHttpException(404, '错误的操作类型:' . $command); break; } }
/** * 会员登录 */ public function actionLogin() { try { $model = new EnergyAdmin('login'); if (XUtils::method() == 'POST') { $model->id = $_POST['id']; $model->password = $_POST['password']; $data = $model->find('id=:id', array('id' => $model->id)); if ($data === null) { $model->addError('id', '用户不存在'); AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,用户不存在:' . CHtml::encode($model->id), 'user_id' => 0)); } elseif (!$model->validatePassword($data->password)) { $model->addError('password', '密码不正确'); AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,密码不正确:' . CHtml::encode($model->id) . ',使用密码:' . CHtml::encode($model->password), 'user_id' => 0)); } else { parent::_stateWrite(array('userId' => $data->id, 'userName' => $data->name), array('prefix' => '_admini')); // $data->save(); AdminLogger::_create(array('catalog' => 'login', 'intro' => '用户登录成功:' . CHtml::encode($model->id))); $this->redirect(array('energy/index')); } } $this->render('login', array('model' => $model)); } catch (Exception $e) { echo var_dump($e); } }
/** * 上传 */ public function actionBasicExecute() { if (XUtils::method() == 'POST') { $adminiUserId = self::_sessionGet('adminiUserId'); $file = XUpload::upload($_FILES['imgFile']); if (is_array($file)) { $model = new Upload(); $model->user_id = intval($accountUserId); $model->file_name = $file['pathname']; $model->thumb_name = $file['paththumbname']; $model->real_name = $file['name']; $model->file_ext = $file['extension']; $model->file_mime = $file['type']; $model->file_size = $file['size']; $model->save_path = $file['savepath']; $model->hash = $file['hash']; $model->save_name = $file['savename']; $model->create_time = time(); if ($model->save()) { exit(CJSON::encode(array('state' => 'success', 'fileId' => $model->id, 'realFile' => $model->real_name, 'message' => '上传成功', 'file' => $file['pathname']))); } else { @unlink($file['pathname']); exit(CJSON::encode(array('state' => 'error', 'message' => '数据写入失败,上传错误'))); } } else { exit(CJSON::encode(array('error' => 1, 'message' => '上传错误'))); } } }
/** * 批量操作 */ public function actionBatch() { if (XUtils::method() == 'GET') { $command = trim($this->_gets->getParam('command')); $ids = intval($this->_gets->getParam('id')); } elseif (XUtils::method() == 'POST') { $command = $this->_gets->getPost('command'); $ids = $this->_gets->getPost('id'); is_array($ids) && ($ids = implode(',', $ids)); } else { throw new CHttpException(404, '只支持POST,GET数据'); } empty($ids) && XUtils::message('error', '未选择记录'); switch ($command) { case 'attachDelete': parent::_acl('attach_delete'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除附件,ID:' . $ids)); //日志 parent::_delete(new Upload(), $ids, array('attach'), array('file_name')); break; default: throw new CHttpException(404, '错误的操作类型:' . $command); break; } }
public function actionLogin() { $model = new Admin('login'); if (XUtils::method() == 'POST') { $model->attributes = $_POST['Admin']; if ($model->validate()) { $data = $model->find('username=:username', array('username' => $model->username)); if ($data === null) { $model->addError('username', '用户不存在'); parent::_backendLogger(array('catalog' => 'login', 'intro' => '登录失败,用户不存在:' . CHtml::encode($model->username), 'user_id' => 0)); } elseif (!$model->validatePassword($data->password)) { $model->addError('password', '密码不正确'); parent::_backendLogger(array('catalog' => 'login', 'intro' => '登录失败,密码不正确:' . CHtml::encode($model->username) . ',使用密码:' . CHtml::encode($model->password), 'user_id' => 0)); } elseif ($data->group_id == 2) { $model->addError('username', '用户已经锁定,请联系管理'); } else { $this->_sessionSet('_backendGroupId', $data->group_id); if (isset($data->group_id) && $data->group_id == 1) { $this->_sessionSet('_backendPermission', 'backendstrator'); } $data->last_login_ip = XUtils::getClientIP(); $data->last_login_time = time(); $data->login_count = $data->login_count + 1; $data->save(); parent::_sessionSet('uid', $data->id); parent::_sessionSet('uname', $data->username); parent::_backendLogger(array('catalog' => 'login', 'intro' => '用户登录成功:' . $data->username)); $this->redirect(array('default/index')); XUtils::message('success', '登录成功', $this->createUrl('default/index'), 2); } } } $this->render('login', array('model' => $model)); }
/** * 编辑器文件上传 */ public function actionUpload() { if (XUtils::method() == 'POST') { $file = XUpload::upload($_FILES['imgFile']); if (is_array($file)) { $model = new Upload(); $model->user_id = intval($admini['userId']); $model->file_name = CHtml::encode($file['pathname']); $model->thumb_name = CHtml::encode($file['paththumbname']); $model->real_name = CHtml::encode($file['name']); $model->file_ext = $file['extension']; $model->file_mime = $file['type']; $model->file_size = $file['size']; $model->save_path = $file['savepath']; $model->hash = $file['hash']; $model->save_name = $file['savename']; $model->create_time = time(); if ($model->save()) { exit(CJSON::encode(array('error' => 0, 'url' => Yii::app()->baseUrl . '/' . $file['pathname']))); } else { @unlink($file['pathname']); @unlink($file['paththumbname']); exit(CJSON::encode(array('error' => 1, 'message' => '上传错误'))); } } else { exit(CJSON::encode(array('error' => 1, 'message' => '上传错误:' . $file))); } } }
/** * 执行sql */ public function actionExecute() { if (XUtils::method() == 'POST') { parent::_acl('database_query', array('response' => 'text')); parent::_configParams(array('action' => 'allowExecuteSql', 'val' => 'Y', 'message' => '不允许执行SQL,请在 protected/config/params.php 中配置 allowExecuteSql 为 Y', 'response' => 'text')); $sql = $this->_gets->getParam('command'); $sqls = self::_sqlSplit($sql); foreach ($sqls as $execute) { self::_execute($execute); } } }
/** * 外借资产查询 * * @author 张钰 徐晨阳 * 该模块主要负责对申请资产进行显示,删除 */ public function actionIndex() { // 分页取数据 $criteria = new CDbCriteria(); $criteria->select = '*'; if (XUtils::method() == 'POST') { // 查询按钮 if (isset($_POST['subQuery'])) { // 判断是否获取content中的内容,内容为空是显示全部申请 if (isset($_POST['queryType']) && isset($_POST['content']) && $_POST['content'] != null) { $queryType = $_POST['queryType']; if ($queryType == 'ByApplyId') { $criteria->addCondition('applyId=:applyId'); // 查询条件,即where id = 1 $criteria->params[':applyId'] = $_POST['content']; } else { if ($queryType == 'ByStuId') { $criteria->addCondition('stuId=:stuId'); // 查询条件,即where id = 1 $criteria->params[':stuId'] = $_POST['content']; } else { if ($queryType == 'ByAssetName') { $criteria->addCondition('assetName=:assetName'); // 查询条件,即where id = 1 $criteria->params[':assetName'] = $_POST['content']; } else { echo "ERROR"; } } } } } } //分页获取 $count = AsApply::model()->count($criteria); $pages = new CPagination($count); $pages->pageSize = PAGESIZE; $pages->applyLimit($criteria); //echo var_dump($pages); $data = AsApply::model()->findAll($criteria); $data = json_decode(CJSON::encode($data), TRUE); is_array($data) ? null : ($data = array()); // 防止空数组 $this->render('index', array('data' => $data, 'pages' => $pages)); // $this->render ( 'index' ); }
public function actionUpdate($stuId) { if (XUtils::method() == 'POST') { $student = new StStudent(); $student->stuId = $stuId; $student->stuName = $_POST['stuName']; $student->profession = $_POST['profession']; $student->grade = $_POST['grade']; $student->phone = $_POST['phone']; $student->classId = $_POST['classId']; $count = AsAsset::model()->updateByPk($stuId, array('stuName' => $student->stuName, 'profession' => $student->profession, 'grade' => $student->grade, 'phone' => $student->phone, 'classId' => $student->classId)); if ($count > 0) { echo "<script language=\"JavaScript\">alert(\"更新成功\");</script>"; } else { echo "<script language=\"JavaScript\">alert(\"更新失败\");</script>"; } } $data = StStudent::model()->findByPk($stuId); $data = json_decode(CJSON::encode($data), TRUE); is_array($data) ? null : ($data = array()); // 防止空数组 $this->render('update', array('data' => $data)); }
function actionCache() { $dataList = array('pageCache' => '页面缓存', 'dataCache' => '数据缓存', 'allCache' => '全部缓存'); // ppr($dataList); $notice = '选择缓存类型'; if (XUtils::method() == 'POST') { $cacheType = reqPost('cacheType', NULL); $path = SITE_BACKEND_PATH . 'assets'; switch ($cacheType) { case 'pageCache': XUtils::delDirAndFile($path); break; case 'dataCache': cacheFlush(); break; case 'allCache': cacheFlush(); XUtils::delDirAndFile($path); break; } $notice .= '<br />清空完成!'; } $this->render('cache', array('dataList' => $dataList, 'notice' => $notice)); }
/** * 自定义字段 */ public function actionCustom() { parent::_acl(); if (XUtils::method() == 'POST') { foreach ((array) $_POST['attr'] as $key => $row) { $val = is_array($row['val']) ? implode(',', $row['val']) : $row['val']; $var = $row["name"]; $config = Config::model()->find('scope=:scope AND variable=:variable', array('scope' => 'custom', 'variable' => $var)); if ($config) { Config::model()->updateAll(array('value' => $val), 'scope=:scope AND variable=:variable', array('scope' => 'custom', 'variable' => $var)); } else { $config = new Config(); $config->scope = 'custom'; $config->variable = $var; $config->value = $val; $config->save(); } } XXcache::refresh('_config', 3600); AdminLogger::_create(array('catalog' => 'update', 'intro' => '更新系统配置,模块:' . $this->action->id)); XUtils::message('success', '更新完成', $this->createUrl($this->action->id)); } $attrModel = Attr::lists(0, 'config'); $this->render('custom', array('attrData' => self::loadData(), 'attrModel' => $attrModel)); }
public function actionIndex() { if (XUtils::method() == 'POST') { if (isset($_POST['analyseType'])) { // echo var_dump( $_POST ['analyseType']); // echo var_dump($_SESSION["name"]."......."); HDraw::deletePic(); //删除历史图片 $analyseType = $_POST['analyseType']; if ($analyseType == "1") { $sql = "SELECT assetName,COUNT(*) as c1 from as_analyse WHERE borrowTime>='" . $_POST['inTime'] . "' AND borrowTime<='" . $_POST['outTime'] . "' GROUP BY assetName ORDER BY COUNT(*) DESC LIMIT 0,10"; $data = Yii::app()->db->createCommand($sql)->queryAll(); $data = json_decode(CJSON::encode($data), TRUE); $data_x = array(); $data_y = array(); foreach ($data as $key => $value) { $data_x[] = $value['assetName']; $data_y[] = $value['c1']; } // echo var_dump($data); $x_title = x_name; // $y_title = " 数次出借"; $graph_title = "借出次数排序图前十(单位:次)"; // echo var_dump($data_x); // echo var_dump($data_y); // echo var_dump(empty($data_x)); if (empty($data_x)) { // 数据库表类的函数save(),存储是否成功,来自yii框架 echo "<script language=\"JavaScript\">alert(\"该段时间没有记录!\");</script>"; } else { $max_y = max($data_y); $name = HDraw::HistogramShow($data_x, $data_y, $x_title, $y_title, $graph_title, $max_y); } } elseif ($analyseType == "2") { $sql = "SELECT assetName,COUNT(*) as c1 from as_analyse WHERE borrowTime>='" . $_POST['inTime'] . "' AND borrowTime<='" . $_POST['outTime'] . "' GROUP BY assetName ORDER BY COUNT(*) ASC LIMIT 10"; $data = Yii::app()->db->createCommand($sql)->queryAll(); $data = json_decode(CJSON::encode($data), TRUE); $data_x = array(); $data_y = array(); foreach ($data as $key => $value) { $data_x[] = $value['assetName']; $data_y[] = $value['c1']; } // echo var_dump($data); $x_title = x_name; // $y_title = " 数次出借"; $graph_title = "借出次数排序图后十(单位:次)"; // echo var_dump($data_x); // echo var_dump($data_y); // echo var_dump(empty($data_x)); if (empty($data_x)) { // 数据库表类的函数save(),存储是否成功,来自yii框架 echo "<script language=\"JavaScript\">alert(\"该段时间没有记录!\");</script>"; } else { $max_y = max($data_y); $name = HDraw::HistogramShow($data_x, $data_y, $x_title, $y_title, $graph_title, $max_y); } } elseif ($analyseType == "3") { $sql = "SELECT assetName,COUNT(*) as c1 from as_asset WHERE assetName in(SELECT assetName from as_analyse) GROUP BY assetName"; $sql_ast = "SELECT assetName,borrowTime,returnTime from as_analyse WHERE borrowTime>='" . $_POST['inTime'] . "' AND borrowTime<='" . $_POST['outTime'] . "'"; $data1 = Yii::app()->db->createCommand($sql_ast)->queryAll(); $data1 = json_decode(CJSON::encode($data1), TRUE); // echo var_dump($data1); $data_x = array(); $data_y = array(); $data_name = array(); $data_num = array(); $date_each = array(); $date_sum = array(); if (empty($data1)) { // 数据库表类的函数save(),存储是否成功,来自yii框架 echo "<script language=\"JavaScript\">alert(\"该段时间没有记录!\");</script>"; } else { foreach ($data1 as $key => $value) { $data_name[] = $value['assetName']; if ($value['returnTime'] < $_POST['outTime']) { $date_each[] = (strtotime($value['returnTime']) - strtotime($value['borrowTime'])) / time + 1; } else { $date_each[] = (strtotime($_POST['outTime']) - strtotime($value['borrowTime'])) / time + 1; } } // echo var_dump($data_name); // echo var_dump($date_each); $date = strtotime($_POST['outTime']) - strtotime($_POST['inTime']); $date = $date / time; // echo var_dump($date); $flog = 0; $data2 = Yii::app()->db->createCommand($sql)->queryAll(); $data2 = json_decode(CJSON::encode($data2), TRUE); // echo var_dump($data2); foreach ($data2 as $key => $value) { if (in_array($value['assetName'], $data_name)) { $data_x[] = $value['assetName']; $data_num[] = $value['c1']; foreach ($data1 as $key1 => $value1) { // echo var_dump($date_each[$key]); if ($value1['assetName'] == $data_x[$flog]) { // echo var_dump($key1); // echo var_dump($flog); $date_sum[$flog] += $date_each[$key1]; // echo var_dump($date_sum[$flog]); } } $data_y[$flog] = $date_sum[$flog] / ($data_num[$flog] * $date); // echo var_dump($data_y[$key]); $flog++; } } array_multisort($data_y, SORT_DESC, $data_x); // echo var_dump($data_y); $max_y = max($data_y); $x_title = x_name; // $y_title = " 率用占"; $graph_title = "资产占用率排序图"; $name = HDraw::HistogramShow($data_x, $data_y, $x_title, $y_title, $graph_title, $max_y); } } elseif ($analyseType == "4") { $sql = "SELECT assetName,COUNT(*) as c1 from as_analyse WHERE borrowTime>='" . $_POST['inTime'] . "' AND returnTime<='" . $_POST['outTime'] . "' GROUP BY assetName ORDER BY COUNT(*) LIMIT 0,10"; $data = Yii::app()->db->createCommand($sql)->queryAll(); $data = json_decode(CJSON::encode($data), TRUE); $piedata = array(); $piename = array(); // var_dump($data); $location = 9; $ages = array(); foreach ($data as $value) { $ages[] = $value['c1']; } array_multisort($ages, SORT_DESC, $data); // echo var_dump($data); foreach ($data as $key => $value) { if ($key < $location) { $piename[] = $value['assetName']; $piedata[] = $value['c1']; } else { $piedata[$location] += $value['c1']; $piename[$location] = "其他"; } } // foreach ($data as $key => $value) { // $piename[]=$value['assetName']; // $piedata[]=$value['c1']; // } // echo var_dump($piedata); $title = "借出次数统计结果 "; if (empty($piedata)) { // 数据库表类的函数save(),存储是否成功,来自yii框架 echo "<script language=\"JavaScript\">alert(\"该段时间没有记录!\");</script>"; } else { $name = HDraw::pieShow($piedata, $piename, $title); } } elseif ($analyseType == "5") { $sql = "SELECT assetName,borrowTime,COUNT(*) as c1 from as_analyse WHERE assetName='" . $_POST['assetName'] . "' GROUP BY DATE_FORMAT(borrowTime, '%Y%M')"; // echo var_dump($_POST ['assetName']); $sql1 = "SELECT assetName FROM as_asset WHERE assetName='" . $_POST['assetName'] . "'"; $name1 = Yii::app()->db->createCommand($sql)->queryAll(); $name1 = json_decode(CJSON::encode($name1), TRUE); $name2 = Yii::app()->db->createCommand($sql1)->queryAll(); $name2 = json_decode(CJSON::encode($name2), TRUE); $judge = 1; if (empty($name1)) { if (!empty($name2)) { echo "<script language=\"JavaScript\">alert(\"该资产年内没有接出!\");</script>"; } else { $judge = 0; echo "<script language=\"JavaScript\">alert(\"资产名称输入有误,重新的输入!\");</script>"; } // $judge = 0; // echo "<script language=\"JavaScript\">alert(\"资产名称输入有误,重新的输入!\");</script>"; } else { $data_y = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $months = array(); foreach ($name1 as $key => $value) { $months[] = date("m", strtotime($value['borrowTime'])); $data_y[(int) $months[$key] - 1] = $value['c1']; } // echo var_dump($months); $x_title = "月份"; $y_title = "次数"; $graph_title = " " . $_POST['assetName'] . "年内每月借出次数变化图(单位:次)"; $data_x = array("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"); $name = HDraw::linerShow($data_x, $data_y, $x_title, $y_title, $graph_title); } } elseif ($analyseType == "7") { if (empty($_POST['inTime']) || empty($_POST['outTime'])) { echo "<script language=\"JavaScript\">alert(\"请输入时间!\");</script>"; } elseif ($_POST['inTime'] > $_POST['outTime']) { echo "<script language=\"JavaScript\">alert(\"开始时间大于截止日期,请重新输入!\");</script>"; } else { // $criteria = new CDbCriteria (); // $count = AsAsset::model ()->count ( $criteria ); // $pages = new CPagination ( $count ); // $pages->pageSize = PAGESIZE; // $pages->applyLimit ( $criteria ); $flog = 7; $sql = "SELECT assetName,RFID,storageId,specification,inTime FROM as_asset WHERE assetName not in(SELECT assetName FROM as_analyse WHERE borrowTime>='" . $_POST['inTime'] . "' AND returnTime<='" . $_POST['outTime'] . "') LIMIT 0,15"; $data7 = Yii::app()->db->createCommand($sql)->queryAll(); $data = json_decode(CJSON::encode($data7), TRUE); } } elseif ($analyseType == "8") { $sql1 = "SELECT assetName,scrapeTime,specification,COUNT(*) as c2 FROM as_asset WHERE assetName='" . $_POST['assetName'] . "' and scrapeTime<=CURDATE() and scrapeTime >=DATE_SUB(CURDATE(),INTERVAL dayofyear(now())-1 DAY) GROUP BY specification"; $test = Yii::app()->db->createCommand($sql1)->queryAll(); $test = json_decode(CJSON::encode($test), TRUE); // echo var_dump($test); $data_x = array(); $data_y = array(); foreach ($test as $key => $value) { $data_x[] = $value['specification']; $data_y[] = $value['c2']; } $x_title = ""; // $y_title = " 量数"; $graph_title = $_POST['assetName'] . "资产报废数据统计(单位:个)"; // echo var_dump($data_x); // echo var_dump($data_y); // echo var_dump(empty($data_x)); if (empty($data_x)) { // 数据库表类的函数save(),存储是否成功,来自yii框架 echo "<script language=\"JavaScript\">alert(\"没有记录!\");</script>"; } else { $max_y = max($data_y); $name = HDraw::HistogramShow($data_x, $data_y, $x_title, $y_title, $graph_title, $max_y); } } } } $this->render('index', array('data' => $data, 'flog' => $flog, 'pages' => $pages, 'analyseType' => $analyseType, 'inTime' => $_POST['inTime'], 'outTime' => $_POST['outTime'], 'assetName' => $_POST['assetName'], 'judge' => $judge, 'name' => $name)); }
/** * 批量操作 * */ public function actionBatch() { if (XUtils::method() == 'GET') { $command = trim($_GET['command']); $ids = intval($_GET['id']); } else { if (XUtils::method() == 'POST') { $command = trim($_POST['command']); $ids = $_POST['id']; is_array($ids) && ($ids = implode(',', $ids)); } else { XUtils::message('errorBack', '只支持POST,GET数据'); } } switch ($command) { case 'delete': parent::_acl('catalog_delete'); empty($ids) && XUtils::message('error', '未选择记录'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除全局分类,ID:' . $ids)); parent::_delete(new Catalog(), $ids, array('index')); break; case 'sortOrder': parent::_acl('catalog_sort_order'); $sortOrder = $this->_gets->getParam('sortOrder'); foreach ((array) $sortOrder as $id => $val) { $catalogModel = Catalog::model()->findByPk($id); if ($catalogModel) { $catalogModel->sort_order = $val; $catalogModel->save(); } } $this->redirect(array('index')); break; default: throw new CHttpException(404, '错误的操作类型:' . $command); break; } }
/** * 批量操作 * */ public function actionBatch() { if (XUtils::method() == 'GET') { $command = trim($_GET['command']); $ids = intval($_GET['id']); } else { if (XUtils::method() == 'POST') { $command = trim($_POST['command']); $ids = $_POST['id']; is_array($ids) && ($ids = implode(',', $ids)); } else { XUtils::message('errorBack', '只支持POST,GET数据'); } } empty($ids) && XUtils::message('error', '未选择记录'); switch ($command) { case 'linkDelete': parent::_acl('link_delete'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除链接,ID:' . $ids)); parent::_delete(new Link(), $ids, array('link'), array('attach_file')); break; case 'adDelete': parent::_acl('ad_delete'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除广告,ID:' . $ids)); parent::_delete(new Ad(), $ids, array('ad'), array('attach_file')); break; case 'linkVerify': parent::_acl('link_verify'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '链接状态变更为显示,ID:' . $ids)); parent::_verify(new Link(), 'verify', $ids, array('link')); break; case 'linkUnVerify': parent::_acl('link_verify'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '链接状态变更为隐藏,ID:' . $ids)); parent::_verify(new Link(), 'unVerify', $ids, array('link')); break; case 'adVerify': parent::_acl('ad_verify'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '广告状态变更为显示,ID:' . $ids)); parent::_verify(new Ad(), 'verify', $ids, array('ad')); break; case 'adUnVerify': parent::_acl('ad_verify'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '广告状态变更为隐藏,ID:' . $ids)); parent::_verify(new Ad(), 'unVerify', $ids, array('ad')); break; default: throw new CHttpException(404, '错误的操作类型:' . $command); break; } }
public function actionApplyQuery() { $model = parent::_dataLoad(new StAdmin(), $this->_admini['userId']); $stuId = $model->id; try { $sql = "SELECT * FROM st_apply,st_class_time,st_course WHERE st_apply.stuId ='{$stuId}' AND st_course.courseId=st_class_time.courseId AND st_class_time.classTimeId=st_apply.classTimeId"; if (XUtils::method() == 'POST') { // 查询按钮 if (isset($_POST['subQuery'])) { // 判断条件 if ($_POST['ByState'] != "3") { $sql = $sql . " AND st_apply.state ='" . $_POST['ByState'] . "'"; } if ($_POST['ByCourseName'] != "课程名称") { $sql = $sql . " AND st_course.courseName = '" . $_POST['ByCourseName'] . "'"; } if ($_POST['ByCourseId'] != "课程编号") { $sql = $sql . " AND st_course.courseId = '" . $_POST['ByCourseId'] . "'"; } } } // echo var_dump($sql); $data = Yii::app()->db->createCommand($sql)->queryAll(); $data = json_decode(CJSON::encode($data), TRUE); is_array($data) ? null : ($data = array()); // 防止空数组 // echo var_dump($data); $this->render('applyQuery', array('data' => $data)); } catch (Exception $e) { echo var_dump($e); } }
public function actionIndex() { if (XUtils::method() == 'POST') { if (isset($_POST['analyseType'])) { // echo var_dump( $_POST ['analyseType']); // echo var_dump($_SESSION["name"]."......."); HDraw::deletePic(); //删除历史图片 $analyseType = $_POST['analyseType']; if ($analyseType == "1") { $sql = "SELECT name,SUM(power) as c1 from energy_power WHERE time>='" . $_POST['inTime'] . "' AND time<='" . $_POST['outTime'] . "' GROUP BY name ORDER BY c1 DESC LIMIT 0,10"; $data = Yii::app()->db->createCommand($sql)->queryAll(); $data = json_decode(CJSON::encode($data), TRUE); $data_x = array(); $data_y = array(); foreach ($data as $key => $value) { $data_x[] = $value['name']; $data_y[] = $value['c1']; } // echo var_dump($data); $x_title = x_name; // $y_title = "n 数度"; $graph_title = "能耗排序图前十 (单位:度)"; // echo var_dump($data_x); // echo var_dump($data_y); // echo var_dump(empty($data_x)); if (empty($data_x)) { // 数据库表类的函数save(),存储是否成功,来自yii框架 echo "<script language=\"JavaScript\">alert(\"该段时间没有记录!\");</script>"; } else { $max_y = max($data_y); $name = HDraw::HistogramShow($data_x, $data_y, $x_title, $y_title, $graph_title, $max_y); } } elseif ($analyseType == "2") { $sql = "SELECT name,SUM(power) as c1 from energy_power WHERE time>='" . $_POST['inTime'] . "' AND time<='" . $_POST['outTime'] . "' GROUP BY name ORDER BY c1 ASC LIMIT 0,10"; $data = Yii::app()->db->createCommand($sql)->queryAll(); $data = json_decode(CJSON::encode($data), TRUE); $data_x = array(); $data_y = array(); foreach ($data as $key => $value) { $data_x[] = $value['name']; $data_y[] = $value['c1']; } // echo var_dump($data); $x_title = "房间号"; // $y_title = " 数度"; $graph_title = "能耗排序图后十 (单位:度)"; // echo var_dump($data_x); // echo var_dump($data_y); // echo var_dump(empty($data_x)); if (empty($data_x)) { // 数据库表类的函数save(),存储是否成功,来自yii框架 echo "<script language=\"JavaScript\">alert(\"该段时间没有记录!\");</script>"; } else { $max_y = max($data_y); $name = HDraw::HistogramShow($data_x, $data_y, $x_title, $y_title, $graph_title, $max_y); } } elseif ($analyseType == "3") { $sql = "SELECT roomId,SUM(power) as c1 FROM energy_power,energy_room WHERE energy_power.id in(SELECT energy_room.assetID FROM energy_room) GROUP BY energy_room.roomId DESC"; // $sql = "SELECT roomId,SUM(energy_power.power)" $name1 = Yii::app()->db->createCommand($sql)->queryAll(); $name1 = json_decode(CJSON::encode($name1), TRUE); // echo var_dump($name1); // $max_y = max($data_y); foreach ($name1 as $key => $value) { $data_x[] = "房间" . $value['roomId'] . ""; $data_y[] = $value['c1'] / 10; } $x_title = "房间号"; // $y_title = " 能耗占比"; $graph_title = "房间能耗排序图前十(单位:度)"; if (empty($name1)) { echo "<script language=\"JavaScript\">alert(\"该段时间没有记录!\");</script>"; } else { $max_y = max($data_y); $name = HDraw::horizontalBarShow($data_x, $data_y, $x_title, $y_title, $graph_title, $max_y); } } elseif ($analyseType == "4") { $sql = "SELECT name,SUM(power) as c1 from energy_power WHERE time>='" . $_POST['inTime'] . "' AND time<='" . $_POST['outTime'] . "' GROUP BY name ORDER BY c1"; $data = Yii::app()->db->createCommand($sql)->queryAll(); $data = json_decode(CJSON::encode($data), TRUE); $piedata = array(); $piename = array(); $location = 9; $ages = array(); foreach ($data as $value) { $ages[] = $value['c1']; } array_multisort($ages, SORT_DESC, $data); // echo var_dump($data); foreach ($data as $key => $value) { if ($key < $location) { $piename[] = $value['name']; $piedata[] = $value['c1']; } else { $piedata[$location] += $value['c1']; $piename[$location] = "其他"; } } // echo var_dump($piedata); $title = "资产能耗占比 "; if (empty($piedata)) { // 数据库表类的函数save(),存储是否成功,来自yii框架 echo "<script language=\"JavaScript\">alert(\"该段时间没有记录!\");</script>"; } else { $name = HDraw::pieShow($piedata, $piename, $title); } } elseif ($analyseType == "5") { // echo var_dump($_POST['inTime']); if (!empty($_POST['month'])) { $month = $_POST['month']; } $now = (int) $month; $thismonth = date('Y'); $thismonth .= "-" . $month; // $now1 = DATE_FORMAT('2015-08-09', '%Y%M'); // echo var_dump($thismonth); $sql = "SELECT power,time from energy_power WHERE date_format(time,'%Y-%m') ='" . $thismonth . "' and name='" . $_POST['assetName'] . "' ORDER BY time"; // echo var_dump($_POST ['assetName']); $sql1 = "SELECT power,time from energy_power WHERE date_format(time,'%Y-%m') ='" . $thismonth . "' and name='" . $_POST['assetName2'] . "' ORDER BY time"; $name1 = Yii::app()->db->createCommand($sql)->queryAll(); $name1 = json_decode(CJSON::encode($name1), TRUE); $name2 = Yii::app()->db->createCommand($sql1)->queryAll(); $name2 = json_decode(CJSON::encode($name2), TRUE); // echo var_dump(empty ( $name2)); $judge = 1; if (empty($name1) && empty($name2)) { $judge = 0; echo "<script language=\"JavaScript\">alert(\"名称或时间输入有误,请重新输入!\");</script>"; } else { foreach ($name1 as $key => $value) { $data_x[] = $value['time']; $data_y[] = $value['power']; } foreach ($name2 as $key => $value) { $data2_y[] = $value['power']; } // echo var_dump($months); $x_title = "日期"; $y_title = "度数"; $graph_title = " " . $_POST['assetName'] . " " . $_POST['assetName2'] . " " . $now . "月耗电量变化图(单位:度)"; // $data_x=array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"); $name = HDraw::liner2Show($data_x, $data_y, $data2_y, $x_title, $y_title, $graph_title); } } elseif ($analyseType == "6") { $flog = 6; //设置开关,动态刷新资产能耗走势图 // $thisTime = date("Y-m-d H:i:s",strtotime("- 45 minutes 2 seconds")); // echo var_dump($thisTime); // $now1 = DATE_FORMAT('2015-08-09', '%Y%M'); // echo var_dump($thismonth); $sql = " SELECT electric,time from energy_day WHERE name='" . $_POST['assetName'] . "' ORDER BY time DESC LIMIT 0,50"; // echo var_dump($_POST ['assetName']); // $sql1="SELECT power,time from energy_power WHERE date_format(time,'%Y-%m') ='".$thismonth."' and name='".$_POST ['assetName2']."' ORDER BY time"; $name1 = Yii::app()->db->createCommand($sql)->queryAll(); $name1 = json_decode(CJSON::encode($name1), TRUE); // echo var_dump($name1); // $name2 = Yii::app ()->db->createCommand($sql1)->queryAll(); // $name2 = json_decode ( CJSON::encode ( $name2 ), TRUE ); // echo var_dump(empty ( $name2)); // echo var_dump($name1); // var_dump($name1); $judge = 1; if (empty($name1)) { $judge = 0; echo "<script language=\"JavaScript\">alert(\"名称输入有误,请重新输入!\");</script>"; } else { foreach ($name1 as $key => $value) { $data_x[] = ""; $data_y[] = $value['electric']; $t = $value['time']; } $data_y = array_reverse($data_y); $data_x[count($name1) - 1] = $t; // echo var_dump($data_x[count($name1)-1]); $x_title = "日期"; $y_title = "度数"; $graph_title = " " . $_POST['assetName'] . $now . " 实时电流值(单位:mA)"; // $data_x=array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"); $name = HDraw::liner3Show($data_x, $data_y, $x_title, $y_title, $graph_title); } } } } $this->render('index', array('data' => $data, 'flog' => $flog, 'pages' => $pages, 'analyseType' => $analyseType, 'month' => $month, 'inTime' => $_POST['inTime'], 'outTime' => $_POST['outTime'], 'assetName' => $_POST['assetName'], 'assetName2' => $_POST['assetName2'], 'judge' => $judge, 'name' => $name)); }
/** * 批量操作 * */ public function actionBatch() { if (XUtils::method() == 'POST') { $ids = reqPost('id'); empty($ids) && XUtils::message('error', '未选择记录'); } else { XUtils::message('errorBack', '只支持POST数据'); } $upd = reqPost('upd', null); $del = reqPost('del', null); // ppr($ids); // ppr($_POST,1); if ($upd) { $sortOrder = reqPost('sort_order'); $title = reqPost('title'); $link = reqPost('link'); $img_link = reqPost('img_link'); $status = reqPost('status'); foreach ((array) $ids as $id) { $catalogModel = Links::model()->findByPk($id); if ($catalogModel) { $catalogModel->sort_order = $sortOrder[$id]; $catalogModel->title = $title[$id]; $catalogModel->link = $link[$id]; $catalogModel->image_link = $img_link[$id]; $catalogModel->status_is = $status[$id]; $catalogModel->create_time = time(); // ppr($catalogModel,1); $catalogModel->save(); } } parent::_backendLogger(array('links' => 'update_batch', 'intro' => '修改数据')); } elseif ($del) { foreach ((array) $ids as $id) { $catalogModel = Links::model()->findByPk($id); $catalogModel->delete(); } parent::_backendLogger(array('links' => 'delete_batch', 'intro' => '删除数据')); } XXcache::refresh('_catalogAllNum'); XUtils::message('success', '操作完成', Yii::app()->request->urlReferrer); }
/** * 批量操作 * */ public function actionBatch() { if (XUtils::method() == 'GET') { $command = trim($_GET['command']); $ids = intval($_GET['id']); } elseif (XUtils::method() == 'POST') { $command = trim($_POST['command']); $ids = $this->_gets->getPost('id'); is_array($ids) && ($ids = implode(',', $ids)); } else { XUtils::message('errorBack', '只支持POST,GET数据'); } empty($ids) && XUtils::message('error', '未选择记录'); switch ($command) { case 'adminDelete': parent::_acl('admin_delete'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除管理员,ID:' . $ids)); parent::_delete(new Admin(), $ids, array('index')); break; case 'groupDelete': parent::_acl('admin_group_delete'); parent::_groupPrivate($ids); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除管理员用户组,ID:' . $ids)); parent::_delete(new AdminGroup(), $ids, array('group')); break; default: throw new CHttpException(404, '错误的操作类型:' . $command); break; } }
/** * 会员登录 */ public function actionLogin() { $this->layout = " "; Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery-1.9.1.js'); Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/login.css'); $original = Yii::app()->request->getQuery('original'); $model = new User('login'); if (XUtils::method() == 'POST') { $model->attributes = $_POST['User']; $data = $model->find('username=:username OR email=:email', array(':username' => $model->username, ':email' => $model->username)); if ($data === null) { $model->addError('username', '用户不存在'); } elseif (!$model->validatePassword($data->password)) { $model->addError('password', '密码不正确'); } else { $userInfo = UserInfo::model()->find('userId=:userId', array(':userId' => $data->id)); parent::_stateWrite(array('userId' => $data->id, 'userName' => $data->username, 'nickname' => $userInfo->nickname), array('prefix' => '_account')); $data->last_login_ip = XUtils::getClientIP(); $data->last_login_time = time(); $data->login_count = $data->login_count + 1; $data->save(); if ($_REQUEST["houseid"] == "") { //判断登陆是否从预约看房那边进来的 if (!empty($original)) { $this->redirect($original); } else { $this->redirect(array('site/index')); } } else { $this->redirect(array('house/view&id=' . $_REQUEST[houseid] . '')); } } } $this->render('login', array('model' => $model)); }
private function groupEdite($data = null) { if (XUtils::method() == 'POST') { if (!empty($_POST['gname']) && !empty($_POST['auth'])) { $gid = reqPost('gid', null); $auth = '|' . implode('|', array_keys($_POST['auth'])) . '|'; $sis = !empty($_POST['sis']) && $_POST['sis'] == 'Y' ? 'Y' : 'N'; $attr = array('group_name' => $_POST['gname'], 'acl' => $auth, 'status_is' => $_POST['sis']); if (!empty($gid)) { $attr['id'] = $gid; } else { $attr['create_time'] = time(); } empty($data) && ($data = new AdminGroup()); $data->attributes = $attr; // ppr($data); // ppr($attr); // ppr($_POST,1); if ($data->save()) { //更新权限缓存 !empty($gid) && cacheDelete('_backendAcl' . $gid, ''); parent::_backendLogger(array('catalog' => 'create', 'intro' => '编辑管理员组及权限' . $data->group_name)); XXcache::refresh('_adminGroup'); $this->redirect(array('group')); } } else { $gid = reqPostNum('gid'); if ($gid > 0) { XUtils::message('error', '发生错误,请正确填写各项', $this->createUrl('admin/groupCreate', array('id' => $gid))); } else { XUtils::message('error', '发生错误,请正确填写各项', $this->createUrl('admin/group')); } } } }
/** * 首页 */ public function actionIndex() { $teacherModel = new Teacher(); $studentModel = new Student(); $hostModel = new Host(); if (XUtils::method() == 'POST') { /*switch($_POST){ case isset($_POST['Teacher']): $nowModel = new Teacher; $nowAttributes = $_POST['Teacher']; $nowRedirect = '/master'; break; case isset($_POST['Student']): $nowModel = new Student; $nowAttributes = $_POST['Student']; $nowRedirect = '/student/info/sinfo'; break; case isset($_POST['Host']): $nowModel = new Host; $nowAttributes = $_POST['Host']; $nowRedirect = '/host/default/Info'; break; default: $nowModel = 0; } if($nowModel){ $nowModel->attributes = $nowAttributes; if ($nowModel->validate() && $nowModel->save()) { parent::_stateWrite( array( 'masterId' => $nowModel->id, 'name' => $nowModel->name, ), array('prefix' => '_master') ); $cookie = new CHttpCookie('userName', $nowModel->name); Yii::app()->request->cookies['userName'] = $cookie; $this->redirect(array($nowRedirect)); } }*/ if (isset($_POST['Teacher'])) { $teacherModel->attributes = $_POST['Teacher']; if ($teacherModel->validate() && $teacherModel->save()) { parent::_stateWrite(array('masterId' => $teacherModel->id, 'name' => $teacherModel->name), array('prefix' => '_master')); if ($teacherModel->name == '') { $teacherModel->name = '导师'; } $cookie = new CHttpCookie('userName', $teacherModel->name); Yii::app()->request->cookies['userName'] = $cookie; $this->_cookiesSet('userId', $teacherModel->id); $this->_cookiesSet('userType', 'student'); Yii::app()->user->setFlash('TSSuccess', '注册成功!请完善个人信息并提交身份认证即可发布课程'); $this->redirect(array('/master')); } } else { if (isset($_POST['Student'])) { $studentModel->attributes = $_POST['Student']; //echo CActiveForm::validate($studentModel); if ($studentModel->validate() && $studentModel->save()) { parent::_stateWrite(array('studentId' => $studentModel->id, 'name' => $studentModel->name), array('prefix' => '_student')); if ($studentModel->name == '') { $studentModel->name = '学员'; } $cookie = new CHttpCookie('userName', $studentModel->name); Yii::app()->request->cookies['userName'] = $cookie; $this->_cookiesSet('userId', $studentModel->id); $this->_cookiesSet('userType', 'student'); $this->redirect(array('/student/info/sinfo')); } } else { if (isset($_POST['Host'])) { $hostModel->attributes = $_POST['Host']; //echo CActiveForm::validate($hostModel); if ($hostModel->validate() && $hostModel->save()) { parent::_stateWrite(array('hostId' => $hostModel->id, 'name' => $hostModel->name), array('prefix' => '_host')); if ($hostModel->name == '') { $hostModel->name = '场地主'; } $cookie = new CHttpCookie('userName', $hostModel->name); Yii::app()->request->cookies['userName'] = $cookie; $this->_cookiesSet('userId', $hostModel->id); $this->_cookiesSet('userType', 'host'); $this->redirect(array('/host')); } } } } } $this->render('index', array('teacherModel' => $teacherModel, 'studentModel' => $studentModel, 'hostModel' => $hostModel)); }
/** * 首页 */ public function actionIndex() { $teacherModel = new TeacherLogin(); $studentModel = new StudentLogin(); $hostModel = new HostLogin(); if (XUtils::method() == 'POST') { if (isset($_POST['TeacherLogin'])) { $teacherModel->attributes = $_POST['TeacherLogin']; //echo CActiveForm::validate($teacherModel); //exit; if ($teacherModel->validate()) { $data = $teacherModel->find('user=:user', array('user' => $teacherModel->user)); if ($data === null) { $teacherModel->addError('user', '用户不存在'); } elseif (!$teacherModel->validatePassword($data->password)) { $teacherModel->addError('password', '密码不正确'); } else { $this->_stateWrite(array('masterId' => $data->id, 'name' => $data->name), array('prefix' => '_master')); $this->_cookiesSet('userId', $data->id); $this->_cookiesSet('userName', $data->name); $this->_cookiesSet('userType', 'master'); $this->redirect(array('/master')); } } } else { if (isset($_POST['StudentLogin'])) { $studentModel->attributes = $_POST['StudentLogin']; //echo CActiveForm::validate($studentModel);检查何处不符合规则 //exit; if ($studentModel->validate()) { $data = $studentModel->find('user=:user', array('user' => $studentModel->user)); if ($data === null) { $studentModel->addError('user', '用户不存在'); } elseif (!$studentModel->validatePassword($data->password)) { $studentModel->addError('password', '密码不正确'); } else { $this->_stateWrite(array('studentId' => $data->id, 'name' => $data->name), array('prefix' => '_student')); $this->_cookiesSet('userId', $data->id); $this->_cookiesSet('userName', $data->name); $this->_cookiesSet('userType', 'student'); $this->redirect(array('/student')); } } } else { if (isset($_POST['HostLogin'])) { $hostModel->attributes = $_POST['HostLogin']; //echo CActiveForm::validate($hostModel);检查何处不符合规则 //exit; if ($hostModel->validate()) { $data = $hostModel->find('user=:user', array('user' => $hostModel->user)); if ($data === null) { $hostModel->addError('user', '用户不存在'); } elseif (!$hostModel->validatePassword($data->password)) { $hostModel->addError('password', '密码不正确'); } else { $this->_stateWrite(array('hostId' => $data->id, 'name' => $data->name), array('prefix' => '_host')); $this->_cookiesSet('userId', $data->id); $this->_cookiesSet('userName', $data->name); $this->_cookiesSet('userType', 'host'); $this->redirect(array('/host')); } } } } } } $this->render('index', array('teacherModel' => $teacherModel, 'studentModel' => $studentModel, 'hostModel' => $hostModel)); }
public function actionAttendance($classTimeId) { try { $sql = "SELECT * FROM st_class_time,st_course WHERE st_class_time.classTimeId = " . $classTimeId . " AND st_class_time.courseId=st_course.courseId"; $course = Yii::app()->db->createCommand($sql)->queryAll(); $sql = "SELECT * FROM st_student,st_student_course WHERE st_student_course.courseId = '" . $course[0]['courseId'] . "' AND st_student_course.stuId = st_student.stuId"; //分页获取 if (XUtils::method() == 'POST') { $data = $_POST; $class = StClassTime::model()->findByPk($classTimeId); if ($class->flag == 1) { $delete = "DELETE FROM st_absent WHERE st_absent.classTimeId = " . $classTimeId; $result = Yii::app()->db->createCommand($sql)->execute(); } foreach ($data as $key => $value) { if ($value == 'on') { $model = new StAbsent(); $model->stuId = $key; $model->classTimeId = $classTimeId; $model->state = "旷课"; $model->reason = "--"; $model->save(); // echo var_dump($model); } } StClassTime::model()->updateByPk($classTimeId, array('flag' => '1')); // XUtils::message('success', '考勤成功', $this->createUrl('teacherLogin/todayClass')); } $result = Yii::app()->db->createCommand($sql)->queryAll(); $count = count($result); $pages = new CPagination($count); $pages->pageSize = PAGESIZE; $pdata = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit"); $pdata->bindValue(':offset', $pages->currentPage * $pages->pageSize); $pdata->bindValue(':limit', $pages->pageSize); $data = $pdata->queryAll(); $data = json_decode(CJSON::encode($data), TRUE); // echo var_dump($data); is_array($data) ? null : ($data = array()); // 防止空数组 $this->render('attendance', array('data' => $data, 'pages' => $pages, 'courseName' => $course[0]['courseName'])); } catch (Exception $e) { var_dump($e); } }
public function actionAccess($applyId) { $model = parent::_dataLoad(new StAdmin(), $this->_admini['userId']); $teacherId = $model->id; // echo var_dump($model); try { $sql = "SELECT * FROM st_course,st_class_time,st_apply WHERE st_class_time.classTimeId = st_apply.classTimeId AND st_course.courseId=st_class_time.courseId AND st_apply.applyId='{$applyId}'"; if (XUtils::method() == 'POST') { if ($_POST['approve'] == "同意") { $state = 1; } if ($_POST['approve'] == "不同意") { $state = 2; } $count = StApply::model()->updateByPk($applyId, array('state' => $state)); if ($count > 0) { XUtils::message('success', '审批成功', $this->createUrl('exeTeacherLogin/applyQuery')); } else { XUtils::message('fail', '修改失败', $this->createUrl('exeTeacherLogin/access')); } } $data = Yii::app()->db->createCommand($sql)->queryAll(); $data = json_decode(CJSON::encode($data), TRUE); is_array($data) ? null : ($data = array()); // 防止空数组 // echo var_dump($data); $this->render('access', array('data' => $data)); } catch (Exception $e) { echo var_dump($e); } }
/** * 批量操作 * */ public function actionBatch() { if (XUtils::method() == 'GET') { $command = trim($_GET['command']); $ids = intval($_GET['id']); } elseif (XUtils::method() == 'POST') { $command = trim($_POST['command']); $ids = $_POST['id']; is_array($ids) && ($ids = implode(',', $ids)); } else { XUtils::message('errorBack', '只支持POST,GET数据'); } empty($ids) && XUtils::message('error', '未选择记录'); switch ($command) { case 'delete': parent::_acl('post_delete'); Post2tags::xdelete($ids); $commentModel = new PostComment(); $commentModel->deleteAll('post_id IN(' . $ids . ')'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容,ID:' . $ids)); parent::_delete(new Post(), $ids, array('index'), array('attach_file', 'attach_thumb')); break; case 'commentDelete': parent::_acl('post_comment_delete'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容评论,ID:' . $ids)); parent::_delete(new PostComment(), $ids, array('comment')); break; case 'commentVerify': parent::_acl('post_comment_verify'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '审核评论,ID:' . $ids)); parent::_verify(new PostComment(), 'verify', $ids, array('comment')); break; case 'commentUnVerify': parent::_acl('post_comment_verify'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '取消评论审核,ID:' . $ids)); parent::_verify(new PostComment(), 'unVerify', $ids, array('comment')); break; case 'verify': parent::_acl('post_verify'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量审核内容,ID:' . $ids)); parent::_verify(new Post(), 'verify', $ids, array('index')); break; case 'unVerify': parent::_acl('post_verify'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量取消内容审核,ID:' . $ids)); parent::_verify(new Post(), 'unVerify', $ids, array('index')); break; case 'commend': parent::_acl('post_commend'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量推荐内容,ID:' . $ids)); parent::_commend(new Post(), 'commend', $ids, array('index')); break; case 'unCommend': parent::_acl('post_commend'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量取消内容推荐,ID:' . $ids)); parent::_commend(new Post(), 'unCommend', $ids, array('index')); break; case 'specialDelete': parent::_acl('post_special_delete'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容,ID:' . $ids)); parent::_delete(new Special(), $ids, array('special'), array('attach_file', 'attach_thumb')); break; default: throw new CHttpException(404, '错误的操作类型:' . $command); break; } }
public function actionSearch() { $type = 'static'; if (XUtils::method() == 'POST') { // var_dump($_POST); if (isset($_POST['type'])) { $type = $_POST['type']; } if ($type == 'static') { $data = AsAsset::model()->findByPk($_POST['RFID']); } else { $data = AsConsume::model()->findByPk($_POST['assetID']); } $data = json_decode(CJSON::encode($data), TRUE); // is_array ( $data ) ? null : $data = array (); // 防止空数组 // $this->render ( 'search', array ( // 'data' => $data // ) ); } $this->render('search', array('data' => $data, 'type' => $type)); }
public function actionSumDetail() { $sql = "SELECT st_course.courseId,st_course.courseName,st_teacher.teacherName,st_teacher.teacherId FROM st_course,st_teacher WHERE st_course.teacherId=st_teacher.teacherId"; if (XUtils::method() == 'POST') { if (isset($_POST['queryType']) && isset($_POST['content']) && $_POST['content'] != null) { $queryType = $_POST['queryType']; $content = $_POST['content']; if ($queryType == 'queryById') { $sql = "SELECT st_course.courseId,st_course.courseName,st_teacher.teacherName,st_teacher.teacherId FROM st_course,st_teacher WHERE st_course.courseId like '%" . $content . "%' and st_course.teacherId=st_teacher.teacherId"; } elseif ($queryType == 'queryByName') { $sql = "SELECT st_course.courseId,st_course.courseName,st_teacher.teacherName,st_teacher.teacherId FROM st_course,st_teacher WHERE st_course.courseName like '%" . $content . "%' and st_course.teacherId=st_teacher.teacherId"; } elseif ($queryType == 'queryByTeaName') { $sql = "SELECT st_course.courseId,st_course.courseName,st_teacher.teacherName,st_teacher.teacherId FROM st_course,st_teacher WHERE st_teacher.teacherName like '%" . $content . "%' and st_course.teacherId=st_teacher.teacherId"; } } } $result = Yii::app()->db->createCommand($sql)->queryAll(); $count = count($result); $pages = new CPagination($count); $pages->pageSize = PAGESIZE; $pdata = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit"); $pdata->bindValue(':offset', $pages->currentPage * $pages->pageSize); $pdata->bindValue(':limit', $pages->pageSize); $data = $pdata->queryAll(); $rate = array(); foreach ($data as $key => $value) { $info = $this->countRate($value['courseId']); $temp = (double) array_sum($info['rate']) / count($info['rate']); $rate[] = $temp; } $data = json_decode(CJSON::encode($data), TRUE); is_array($data) ? null : ($data = array()); // 防止空数组 $this->render('sumDetail', array('data' => $data, 'pages' => $pages, 'type' => $queryType, 'content' => $content, 'rate' => $rate)); }
public function actionUpdate($sign, $condition) { //向日志文件中写入更新信息 $time = date('Y-m-d', time()); $logName = $time . '.log'; $logHandle = fopen('log/' . $logName, 'a'); if (XUtils::method() == 'POST') { if ($sign == 'RFID') { $asset = new AsAsset(); $asset->RFID = $conditon; $asset->assetName = $_POST['assetName']; $specification = $_POST['specification']; if ($specification == "小型") { $asset->specification = "small"; } elseif ($specification == "中型") { $asset->specification = "middle"; } else { $asset->specification = "big"; } $asset->state = $_POST['state']; $asset->Price = $_POST['Price']; $asset->storageId = $_POST['storageId']; $asset->inTime = $_POST['inTime']; $asset->outPrm = $_POST['outPrm']; $asset->brwPhone = $_POST['brwPhone']; $count = AsAsset::model()->updateByPk($condition, array('assetName' => $asset->assetName, 'specification' => $asset->specification, 'state' => $asset->state, 'Price' => $asset->Price, 'storageId' => $asset->storageId, 'inTime' => $asset->inTime, 'brwPhone' => $asset->brwPhone)); if ($count > 0) { //向日志中写入更新信息 fwrite($logHandle, '更新了数据库中RFID为' . $condition . '的信息' . "\r\n"); echo "<script language=\"JavaScript\">alert(\"更新成功\");</script>"; } else { echo "<script language=\"JavaScript\">alert(\"更新失败\");</script>"; } } else { $consume = new AsConsume(); $consume->assetId = $conditon; $consume->assetName = $_POST['assetName']; $specification = $_POST['specification']; if ($specification == "小型") { $consume->specification = "small"; } elseif ($specification == "中型") { $consume->specification = "middle"; } else { $consume->specification = "big"; } $consume->state = $_POST['state']; $consume->Price = $_POST['Price']; $consume->storageId = $_POST['storageId']; $consume->inTime = $_POST['inTime']; $consume->outPrm = $_POST['outPrm']; $consume->brwPhone = $_POST['brwPhone']; $count = AsConsume::model()->updateByPk($condition, array('assetName' => $consume->assetName, 'specification' => $consume->specification, 'state' => $consume->state, 'Price' => $consume->Price, 'storageId' => $consume->storageId, 'inTime' => $consume->inTime, 'brwPhone' => $consume->brwPhone)); if ($count > 0) { //向日志中写入更新信息 fwrite($logHandle, '更新了数据库中assetId为' . $condition . '的信息' . "\r\n"); echo "<script language=\"JavaScript\">alert(\"更新成功\");</script>"; } else { echo "<script language=\"JavaScript\">alert(\"更新失败\");</script>"; } } //更新文件 } if ($sign == 'RFID') { $data = AsAsset::model()->findByPk($condition); } else { $data = AsConsume::model()->findByPk($condition); } $data = json_decode(CJSON::encode($data), TRUE); is_array($data) ? null : ($data = array()); // 防止空数组 $this->render('update', array('data' => $data)); }