getLesseeList($page,$pageLimit); return $this->render('index', array( 'dataList' => $result['dataList'], 'pages' => $result['pages'], 'page'=>$page )); } public function actionAdd() { if (Yii::app()->request->getIsPostRequest()) { $model = new AssistUser(); $realName=Req::post('real_name'); $userName=Req::post('user_name'); $password=Req::post('password'); $re_password=Req::post('re_password'); $status=Req::post('status'); $sex=Req::post('sex'); $cutting_limit=Req::post('cutting_limit'); $scan_limit=Req::post('scan_limit'); if(!$realName || !$userName || !$password){ Yii::app()->jump->error('请填写完整信息!'); } $check=AssistUser::model()->find('user_name=:un ',array(':un'=>$userName)); if($check){ Yii::app()->jump->error('手机号已经被使用!'); } $model->real_name=$realName; $model->user_name=$userName; $model->status=$status; $model->sex=$sex; $model->update_time=time(); if($password){ if($password!=$re_password){ Yii::app()->jump->error('确认密码不一致!'); } $model->password=$this->producePassword($password); } if($cutting_limit){ $model->cutting_limit=1; }else{ $model->cutting_limit=0; } if($scan_limit){ $model->scan_limit=1; }else{ $model->scan_limit=0; } if($model->save()){ $this->redirect(array('assistHome/index')); }else{ Yii::app()->jump->error('添加失败!'); } } return $this->render('add'); } public function actionEdit() { $lesseeId = (int)Req::get('lid'); $model = new AssistUser(); $model = $model->findByPk($lesseeId); if (Yii::app()->request->getIsPostRequest()) { $lesseeId = (int)Req::post('lid'); $realName=Req::post('real_name'); $userName=Req::post('user_name'); $password=Req::post('password'); $re_password=Req::post('re_password'); $status=Req::post('status'); $sex=Req::post('sex'); $cutting_limit=Req::post('cutting_limit'); $scan_limit=Req::post('scan_limit'); if(!$realName || !$userName){ Yii::app()->jump->error('请填写完整信息!'); } $check=AssistUser::model()->find('user_name=:un and user_id<>:id',array(':un'=>$userName,':id'=>$lesseeId)); if($check){ Yii::app()->jump->error('手机号已经被使用!'); } $updateArr=array(); $updateArr['real_name']=$realName; $updateArr['user_name']=$userName; $updateArr['status']=$status; $updateArr['sex']=$sex; $updateArr['update_time']=time(); if($password){ if($password!=$re_password){ Yii::app()->jump->error('确认密码不一致!'); } $updateArr['password']=$this->producePassword($password); } if($cutting_limit){ $updateArr['cutting_limit']=1; }else{ $updateArr['cutting_limit']=0; } if($scan_limit){ $updateArr['scan_limit']=1; }else{ $updateArr['scan_limit']=0; } if(AssistUser::model()->updateAll($updateArr,'user_id=:uid',array(':uid'=>$lesseeId))){ $this->redirect(array('assistHome/index')); } } return $this->render('edit', array( 'user' => $model )); } public function actionRemove() { $lesseeId = (int)Req::post('lesseeId'); if (!$lesseeId) { exit(json_encode(array('status'=>0))); } $lessee = AssistUser::model()->findByPk($lesseeId); if ($lessee) { $examNum=ATask::model()->find("operator=:uid",array(':uid'=>$lesseeId)); if ($examNum) { exit(json_encode(array('status'=>0,'msg'=>'当前账号已产生任务数据,禁止删除,谢谢!'))); } else { if (AssistUser::model()->deleteAll('user_id=:uid',array(':uid'=>$lesseeId))) { exit(json_encode(array('status'=>1))); } else { exit(json_encode(array('status'=>0))); } } } else { exit(json_encode(array('status'=>0,'msg'=>'未找到用户信息'))); } } }