City(); $idarr = []; foreach ($cityModel as $key=>$val){ if($val['abroad']==2){ $idarr[] = $val['id']; unset($cityModel[$key]); } } $cityModel[] = ['id'=>implode(',',$idarr),'city_name'=>'海外']; return $this->render('home',['city'=>$cityModel]); } /* * 其他管理-电话管理-首页数据 * */ public function actionHomeform() { $model = new CategoryTel(); $input = Yii::$app->request->post(); $rows = $model->getList($input); if($rows != null) { return Help::JsonData(0,'成功',0,$rows); } return Help::JsonCode(Help::ERROR,'暂无数据'); } /* * 其他管理-电话管理-修改电话数据 * */ public function actionEditform() { $model = new CategoryTel(); $input = Yii::$app->request->post('data'); $input['name'] =Yii::$app->request->post('data')['name']; $input['tel'] =trim(Yii::$app->request->post('data')['tel'],','); $rows = $model->Authenticator($input); if(is_object($rows)) { $row = $model->FindById($input['id']); if($row != null) { $authMoel = Help::SetAttr($input,$rows,$row); if($authMoel->save()) return Help::JsonCode(Help::SUCCESS,'修改成功'); } } return Help::JsonCode(Help::ERROR,'修改失败',$rows); } /* * 其他管理-电话管理-修改电话页面 * */ public function actionEdit() { $model = new CategoryTel(); $row = $model->FindById(Yii::$app->request->get('id')); $cityModel = $this->City(); if($row != null) return $this->render('edit',['model'=>$row,'city'=>$cityModel]); } /* * 其他管理-电话管理-添加电话页面 * */ public function actionAdd() { $cityModel = $this->City(); return $this->render('add',['city'=>$cityModel]); } /* * 其他管理-电话管理-添加电话数据 * */ public function actionAddform() { $model = new CategoryTel(); $input['name'] =Yii::$app->request->post('data')['name']; $input['tel'] =trim(Yii::$app->request->post('data')['tel'],','); $rows = $model->Authenticator($input); if(is_object($rows)) { if($rows->save() == true) return Help::JsonCode(Help::SUCCESS,'添加成功'); } return Help::JsonCode(Help::ERROR,'添加失败',$rows); } /* * 其他管理-电话管理-删除 * */ public function actionDel() { $model = new CategoryTel(); $row = $model->FindById(Yii::$app->request->post('id')); if($row != null) { $row->del = 2; if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'删除成功'); } return Help::JsonCode(Help::ERROR,'删除失败'); } /* * 其他管理-区域电话列表显示页面 * */ public function actionCitytelhome() { $city = new CategoryCity(); $city = $city->SortgetList([]); return $this->render('citytelhome',['city'=>$city]); } /* * 其他管理-区域电话列表数据 * */ public function actionCitytelhomeform() { $input = Yii::$app->request->get(); $model = new CategoryCity(); $query = $model->telList($input); if(!empty($query)) { return Help::JsonData(0,'成功', $model->telTotal(),$query); } return Help::JsonCode(Help::ERROR,'暂无数据'); } /* * 其他管理-区域电话归属 * */ public function actionCityascription() { $model = new CategoryTel(); $rows = $model->getList(); $TelCity= new \common\models\CategoryTelCity(); $TelCity->cid = Yii::$app->request->get('id'); $city = $TelCity->findByOne(); foreach ($rows as &$val) { if($val['id'] == $city['tid']){ $val['checked'] = 'checked'; } } return $this->render('cityascription',['id'=>Yii::$app->request->get('id'),'tellist'=>$rows]); } /* * 其他管理-添加区域电话归属 * */ public function actionAddcityascription() { $model = new \common\models\CategoryTelCity(); // $model->tid = Yii::$app->request->post('tid'); $model->cid = Yii::$app->request->post('cid'); $row = $model->findByOne(); if($row != null) { $row->tid = Yii::$app->request->post('tid'); $result = $row->save(false); } else { $model->tid = Yii::$app->request->post('tid'); $model->cid = Yii::$app->request->post('cid'); $result = $model->save(); } if($result == true) return Help::JsonCode(Help::SUCCESS,'操作成功'); return Help::JsonCode(Help::ERROR,'操作失败'); } //------------------------------------------------------------------------------------------------- private function City() { $city = new \common\models\CategoryCity(); $city->state = 1; $city->pid = 0; $cityModel = $city->getList([]); return $cityModel; } }