123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?php
- class AssistHomeController extends AssistController
- {
- public function actionIndex()
- {
- $page=Req::get('page');
- if(!$page) $page=1;
- $pageLimit=10;
- $userModel=new AssistUser();
- $result = $userModel->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'=>'未找到用户信息')));
- }
- }
- }
|