123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/4/3
- * Time: 下午5:14
- */
- namespace backend\controllers;
- use Yii;
- use backend\base\Help;
- use backend\base\CommonController;
- use common\models\CategoryTel;
- use common\models\CategoryTelCity;
- use common\models\CategoryCity;
- class OthertelController extends CommonController
- {
- /*
- * 其他管理-电话管理-首页
- * */
- public function actionHome()
- {
- $cityModel = $this->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;
- }
- }
|