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',''); 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->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; } }