db->createCommand('select b.org_id,r.res_name from base_bus as b,base_resource as r where b.org_id = r.res_id GROUP BY b.org_id')->queryAll(); foreach ($arr as $key => $vel) { $final[$vel['org_id']] = $vel['res_name']; } $arr = Yii::$app->db->createCommand('select d.org_id,r.res_name from base_driver as d,base_resource as r where d.org_id = r.res_id GROUP BY d.org_id')->queryAll(); foreach ($arr as $key => $vel) { $final[$vel['org_id']] = $vel['res_name']; } echo '
'; print_r($final); die; //return $this->render('index'); } /** * Function Description:司机信息列表 * Function Name: actionList * * @return string * * @author 张帅 */ public function actionList() { $base_supplier = new BaseSupplier; $base_driver = new BaseDriver(); #region 获取用户信息 //获取cookies $cookies = Yii::$app->request->cookies; //账号权限 $user_id = $cookies->getValue('user_id'); $user_info = BaseUser::find() ->select('opera_org_id') ->where(['id' => $user_id, 'cancel_flag' => 0]) ->asArray() ->one(); $opera_org_id = $user_info['opera_org_id']; #endregion //创建一个数组 $data = []; //1.获取所有的车队名称和车队代码 $motorcade = $base_supplier->getMotorcadeCodeAndName(); //2.性别 $sex_array = ["男","女"]; //3.司机姓名 $sql_where = [ 'and', ['=','cancel_flag',0] ]; //用户权限 if(!empty($opera_org_id)){ $sql_where[] = ['in','org_id',explode(',',$opera_org_id)]; } $driver_name_arr = BaseDriver::find()->select('driver_name')->where($sql_where)->groupBy('driver_name')->asArray()->all(); //4.获取司机列表 $driver_result = $base_driver->getDriverList(); $driver_list = $driver_result['rows']; $page_arr = $driver_result['page_arr']; $page = $driver_result['page']; //把需要传递的值传送给视图 $view = Yii::$app->view; $view->title = '司机信息管理'; $data['sex_array'] = $sex_array; $data['motorcade'] = $motorcade; $data['driver_name_arr'] = $driver_name_arr; $data['driver_list'] = $driver_list; $data['page_arr'] = $page_arr; $data['page'] = $page; return $this->render('list', $data); } /** * Function Description:添加司机 * Function Name: actionAddDriver * * @return string * * @author 张帅 */ public function actionAddDriver() { $base_supplier = new BaseSupplier; Yii::$app->view->title = '添加司机'; //1.获取公司列表 $motorcade_list = $base_supplier->getMotorcadeInfo(); //2.司机状态 $driver_status = ['正常','有请假']; //3.性别 $sex_array = ["男","女"]; //4.获取一级区域 $range = BaseArea::find()->select('id as area_id,area_name')->where(['parent_id' => 0, 'cancel_flag' => 0, 'poi_type1' => 401])->asArray()->all(); //5.有效期限 $active_year_array = ['6'=>'6年', '10' => '10年', '20' => '20年']; $data['opera'] = 'add'; $data['motorcade_list'] = $motorcade_list; $data['driver_status'] = $driver_status; $data['sex_array'] = $sex_array; $data['range'] = $range; $data['active_year_array'] = $active_year_array; return $this->render('driver-info', $data); } /** * Function Description:修改司机信息 * Function Name: actionUpdateInfo * * @return string * * @author 张帅 */ public function actionUpdateInfo(){ $base_supplier = new BaseSupplier; $base_driver = new BaseDriver(); Yii::$app->view->title = '司机修改'; #region 获取参数 $driver_id = Yii::$app->request->get('driver_id');//司机id #endregion //1.获取公司列表 $motorcade_list = $base_supplier->getMotorcadeInfo(); //2.司机状态 $driver_status = ['正常','有请假']; //3.性别 $sex_array = ["男","女"]; //4.获取一级区域 $range = BaseArea::find()->select('id as area_id,area_name')->where(['parent_id' => 0, 'cancel_flag' => 0, 'poi_type1' => 401])->asArray()->all(); //5.有效期限 $active_year_array = ['6'=>'6年', '10' => '10年', '20' => '20年']; //6.获取司机详情 $driver_info = $base_driver->getDriverInfo($driver_id); $data['opera'] = 'update'; $data['motorcade_list'] = $motorcade_list; $data['driver_status'] = $driver_status; $data['sex_array'] = $sex_array; $data['range'] = $range; $data['active_year_array'] = $active_year_array; $data['driver_info'] = $driver_info; return $this->render('driver-info', $data); } /** * Function Description:展示司机详情 * Function Name: actionShowInfo * * @return string * * @author 张帅 */ public function actionShowInfo(){ $base_driver = new BaseDriver(); Yii::$app->view->title = '查看司机信息'; #region 1.获取参数 $driver_id = Yii::$app->request->get('driver_id');//司机id #endregion //2.获取司机详情 $driver_info = $base_driver->getShowDriverInfo($driver_id); $data['opera'] = 'show'; $data['driver_info'] = $driver_info; return $this->render('driver-info', $data); } /*============================ajax================================ajax=================================ajax======================================*/ /** * Function Description:检索车辆列表 * Function Name: actionSearchList * * @return string * * @author 张帅 */ public function actionSearchList(){ $base_driver = new BaseDriver(); #region 1.获取参数 $motorcade_name = Yii::$app->request->post('motorcade_name');//车队名称 $motorcade_code = Yii::$app->request->post('motorcade_code');//车队代码 $sex = Yii::$app->request->post('sex');//性别 $driver_name = Yii::$app->request->post('driver_name');//司机名称 $driver_code = Yii::$app->request->post('driver_code');//司机工号 $driver_mobile = Yii::$app->request->post('driver_mobile');//司机手机号 $driver_license = Yii::$app->request->post('driver_license');//司机驾驶证号 $page_size = Yii::$app->request->post('page_size');//每页展示数据 $current_page = Yii::$app->request->post('current_page');//当前页 #endregion //2.获取数据 $driver_list = $base_driver->getDriverList($motorcade_name,$motorcade_code,$sex,$driver_name,$driver_code,$driver_mobile,$driver_license,$page_size,$current_page); $json['code'] = '0'; $json['info'] = '返回数据成功'; $json['list'] = $driver_list; return json_encode($json); } /** * Function Description:添加司机 * Function Name: actionDriverAdd * * @return string * * @author 张帅 */ public function actionDriverAdd(){ $base_driver = new BaseDriver(); #region 1.获取参数 $driver_name = Yii::$app->request->post('driver_name');//司机名称 $motorcade_id = Yii::$app->request->post('motorcade_id');//车队id $driver_status = Yii::$app->request->post('driver_status');//司机状态 $driver_code = Yii::$app->request->post('driver_code');//司机工号 $driver_license = Yii::$app->request->post('driver_license');//驾驶证号 $driver_mobile = Yii::$app->request->post('driver_mobile');//手机号 $driver_sex = Yii::$app->request->post('driver_sex');//司机性别 $driver_birthday = Yii::$app->request->post('driver_birthday');//出生日期 $first_license_date = Yii::$app->request->post('first_license_date');//初次领证日期 $area_id = Yii::$app->request->post('area_id');//居住区域 $driver_address = Yii::$app->request->post('driver_address');//详细住址 $license_start_date = Yii::$app->request->post('license_start_date');//有效起至日期 $valid_years = Yii::$app->request->post('valid_years');//有效期限 #endregion $result = $base_driver->addDriver($driver_name,$motorcade_id,$driver_status,$driver_code,$driver_license,$driver_mobile,$driver_sex,$driver_birthday,$first_license_date,$area_id,$driver_address,$license_start_date,$valid_years); return json_encode($result); } /** * Function Description:修改司机信息 * Function Name: actionDriverUpdate * * @return string * * @author 张帅 */ public function actionDriverUpdate(){ $base_driver = new BaseDriver(); #region 1.获取参数 $driver_id = Yii::$app->request->post('driver_id');//司机id $driver_name = Yii::$app->request->post('driver_name');//司机名称 $motorcade_id = Yii::$app->request->post('motorcade_id');//车队id $driver_status = Yii::$app->request->post('driver_status');//司机状态 $driver_code = Yii::$app->request->post('driver_code');//司机工号 $driver_license = Yii::$app->request->post('driver_license');//驾驶证号 $driver_mobile = Yii::$app->request->post('driver_mobile');//手机号 $driver_sex = Yii::$app->request->post('driver_sex');//司机性别 $driver_birthday = Yii::$app->request->post('driver_birthday');//出生日期 $first_license_date = Yii::$app->request->post('first_license_date');//初次领证日期 $area_id = Yii::$app->request->post('area_id');//居住区域 $driver_address = Yii::$app->request->post('driver_address');//详细住址 $license_start_date = Yii::$app->request->post('license_start_date');//有效起至日期 $valid_years = Yii::$app->request->post('valid_years');//有效期限 #endregion $result = $base_driver->updateDriver($driver_id,$driver_name,$motorcade_id,$driver_status,$driver_code,$driver_license,$driver_mobile,$driver_sex,$driver_birthday,$first_license_date,$area_id,$driver_address,$license_start_date,$valid_years); return json_encode($result); } /** * Function Description:删除司机 * Function Name: actionDeleteDriver * * @return string * * @author 张帅 */ public function actionDeleteDriver(){ $base_driver = new BaseDriver(); #region 1.获取参数 $driver_id = Yii::$app->request->post('driver_id');//司机id #endregion $result = $base_driver->deleteDriver($driver_id); return json_encode($result); } }