123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- /**
- * Created by PhpStorm.
- * User: north
- * Date: 2017/8/14
- * Time: 下午2:31
- */
- class REmployeController extends AdminController {
- public function actionIndex()
- {
- //$tmp = JEmploye::model()->findAll();
- //foreach ($tmp as $k => $v) {
- //$v->delete();
- //}
- $status = CommonFn::getComboboxData(JEmploye::$status_option, 100, true, 100);//人员状态
- $auth = CommonFn::getComboboxData(JEmploye::$auth_option, 1, true, 100);
- $this->render('index',array(
- 'status' => $status,
- 'auth' => $auth
- ));
- }
- public function actionList()
- {
- $pageParams = CommonFn::getPageParams();
- $status = intval(Yii::app()->request->getParam('status', 100));
- $criteria = new EMongoCriteria($pageParams);
- if ($status != 100 ) {
- $criteria->status('==',$status);
- }
- $cursor = JEmploye::model()->findAll($criteria);
- $rows = CommonFn::getRowsFromCursor($cursor);
- $parsedRows = JEmploye::model()->parse($rows);
- $total = $cursor->count();
- echo CommonFn::composeDatagridData($parsedRows, $total);
- }
- public function actionEdit()
- {
- $id = Yii::app()->request->getParam('id','');
- $status = intval(Yii::app()->request->getParam('status',100));
- $user_name = Yii::app()->request->getParam('user_name','');
- $mobile = Yii::app()->request->getParam('mobile','');
- $auth = intval(Yii::app()->request->getParam('auth',''));
- $owned_stores = Yii::app()->request->getParam('owned_stores','');
- $desc = Yii::app()->request->getParam('desc','');
- $flag1 = Yii::app()->request->getParam('flag','');
- if ($status == 100) {
- CommonFn::requestAjax(false,'状态没有修改');exit;
- }
- if ($auth == 100) {
- CommonFn::requestAjax(false,'角色没有修改');exit;
- }
- if (!CommonFn::isMongoId($id)) {
- CommonFn::requestAjax(false,'id错误');exit;
- }
- $flag = function () use ($owned_stores){
- $criteria = new EMongoCriteria();
- $criteria->store_id('==',intval($owned_stores));
- $store = Store::model()->find($criteria);
- if (empty($store)) {
- return true;
- } else {
- return false;
- }
- };
- if ($flag()) {
- CommonFn::requestAjax(false,'门店不存在');exit;
- }
- $employe = JEmploye::get(new MongoId($id));
- $employe->status = $status;
- $employe->user_name = $user_name;
- $employe->mobile = $mobile;
- $employe->auth = $auth;
- $employe->owned_stores = intval($owned_stores);
- $employe->desc = $desc;
- $employe->flag = intval($flag1);
- $employe->save();
- CommonFn::requestAjax(true,'保存成功');exit;
- }
- public function actionAdd()
- {
- $user_id = Yii::app()->request->getParam('user_id','');
- $user_name = Yii::app()->request->getParam('user_name','');
- $mobile = Yii::app()->request->getParam('mobile','');
- $auth = intval(Yii::app()->request->getParam('auth',''));
- $owned_stores = Yii::app()->request->getParam('owned_stores','');
- $desc = Yii::app()->request->getParam('desc','');
- $sex = Yii::app()->request->getParam('sex','');
- $status = intval(Yii::app()->request->getParam('status',100));
- if ($status == 100) {
- CommonFn::requestAjax(false,'状态没有修改');exit;
- }
- if (CommonFn::isMongoId($user_id)) {
- $user = RUser::get(new MongoId($user_id));
- if (empty($user)) {
- CommonFn::requestAjax(false,'id错误');exit;
- }
- }
- $employe = new JEmploye();
- $employe->user_id = $user->_id;
- $employe->user_name = $user_name;
- $employe->mobile = $mobile;
- $employe->auth = intval($auth);
- $employe->owned_stores = intval($owned_stores);
- $employe->desc = $desc;
- $employe->status = intval($status);
- $employe->sex = intval($sex);
- $employe->save();
- CommonFn::requestAjax(true,'保存成功');exit;
- }
- }
|