|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561 |
- <?php
- /**
- * Created by PhpStorm.
- * User: luocj
- * Date: 2017/1/18
- * Time: 13:17
- */
-
- namespace backend\modules\motorcade\controllers;
-
- use backend\modules\motorcade\models\BaseBus;
- use backend\modules\motorcade\models\BusSearch;
- use yii\data\SqlDataProvider;
- use backend\modules\zzcs\models\BaseResource;
- use common\models\zzcsUtils;
- use yii\bootstrap\BootstrapAsset;
- use backend\modules\motorcade\models\BusReport;
- use Yii;
- use yii\grid\GridView;
-
- class ResourceController extends BaseController
- {
- public $layout = "@backend/modules/motorcade/views/layouts/iframe_new";
-
- public function actionIndex()
- {
- return $this->render('index');
- }
-
- public function actionBusList()
- {
- // $bus_no = isset($_REQUEST['bus_no']) && $_REQUEST['bus_no'] != '' ? $_REQUEST['bus_no'] : '-1';
- // $bus_company = isset($_REQUEST['bus_company']) ? $_REQUEST['bus_company'] : '-1';
- // $bus_supply = isset($_REQUEST['bus_supply']) ? $_REQUEST['bus_supply'] : '-1';
- // $brand = isset($_REQUEST['brand']) && $_REQUEST['bus_no'] != '' ? $_REQUEST['brand'] : '-1';
- $searchModel = new BusSearch(['scenario' => 'search']);
- $queryParams = Yii::$app->request->queryParams;
- $queryParams['BusSearch']['ORG_ID'] = isset($queryParams['BusSearch']['ORG_ID']) ? $queryParams['BusSearch']['ORG_ID'] : $_COOKIE['user_org_id'];
- $dataProvider = $searchModel->search($queryParams);
-
- // return $this->render('index', [
- // 'searchModel' => $searchModel,
- // 'dataProvider' => $dataProvider,
- // ]);
-
- $obj = new BaseResource();
- // $data = $obj->getBusList($bus_no, $bus_company, $bus_supply, $brand);
- $brand = $obj->getBrand();
- $bus_company = $obj->getBusCompany();
- return $this->render('resource', [
- 'view' => '_busList',
- 'brand' => $brand,
- 'bus_company' => $bus_company,
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider
- ]);
- }
-
- public function actionBusDetail()
- {
- $obj = new BaseResource();
- $bus_id = isset($_REQUEST['bus_id']) ? $_REQUEST['bus_id'] : '';
- $data = $obj->getBusDetail($bus_id);
- $pic_type = $obj->getPicType();
- if (isset($data['data'][0]['bus_img_path_ori'])) {
- $path_tmp = explode(',', $data['data'][0]['bus_img_path_ori']);
- $type_tmp = explode(',', $data['data'][0]['bus_img_type']);
- foreach ($path_tmp as $k => $v) {
- $img_arr[$k]['img_path'] = $v;
- $img_arr[$k]['img_type'] = $type_tmp[$k];
- }
- }
- return $this->render('resource', ['view' => '_busDetail', 'data' => $data, 'img_arr' => isset($img_arr) ? $img_arr : '', 'pic_type' => $pic_type]);
- }
-
- public function actionBusDetailModify()
- {
- $get_seat_type = isset($_REQUEST['seat_type']) ? $_REQUEST['seat_type'] : '-1';
- $obj = new BaseResource();
- $bus_id = isset($_REQUEST['bus_id']) ? $_REQUEST['bus_id'] : '';
- if ($bus_id == '') {
- $json = array();
- $json["code"] = "2";
- $json["info"] = "获取信息失败!";
- return json_encode($json);
- }
- $data = $obj->getBusDetail($bus_id);
- if (isset($data['data'][0]['bus_img_path_ori'])) {
- $path_tmp = explode(',', $data['data'][0]['bus_img_path_ori']);
- $type_tmp = explode(',', $data['data'][0]['bus_img_type']);
- foreach ($path_tmp as $k => $v) {
- $img_arr[$k]['img_path'] = $v;
- $img_arr[$k]['img_type'] = $type_tmp[$k];
- }
- }
- $user_bus_company = $obj->getUserCompany();
- $brand = $obj->getBrand();
- $bus_company = $obj->getBusCompany();
- $seat_type = $obj->getSeatType();
- $fuel = $obj->getFuel();
- $color = $obj->getColor();
- $pic_type = $obj->getPicType();
- $seat_count = $obj->getSeatCount($get_seat_type == '-1' ? $data['data'][0]['seat_type'] : $get_seat_type);
- return $this->render('resource', ['view' => '_busDetailModify', 'data' => $data, 'img_arr' => isset($img_arr) ? $img_arr : '', 'brand' => $brand, 'bus_company' => $bus_company, 'seat_type' => $seat_type, 'seat_count' => $seat_count, 'fuel' => $fuel, 'color' => $color, 'pic_type' => $pic_type, 'user_bus_company' => $user_bus_company]);
- }
-
- public function actionModify()
- {
- //车子所属公司
- $bus_company_type = $_REQUEST['bus_company_type'] ? $_REQUEST['bus_company_type'] : '';
- $bus_company_tp = $_REQUEST['bus_company'] ? $_REQUEST['bus_company'] : '';
- $model = Yii::$app->user->id;
- if ($bus_company_type == '1') {
- $bus_company_sql = "select org_id from base_user where id = '$model'";
- $bus_company_do = Yii::$app->db->createCommand($bus_company_sql)->queryOne();
- $bus_company = $bus_company_do['org_id'];
- } else if ($bus_company_type == '2') {
- $bus_company = $bus_company_tp;
- }
- //判断车牌是否重复
- $bus_no = $_REQUEST['bus_no'] ? $_REQUEST['bus_no'] : '';
- $bus_id = $_REQUEST['bus_id'];
- $sql_temp = "select bus_no from base_bus where bus_id = '$bus_id'";
- $sql_temp1 = "select count(bus_id) as num from base_bus where BUS_NO = '$bus_no'";
- $old_bus_no = Yii::$app->db->createCommand($sql_temp)->queryAll();
- $num = Yii::$app->db->createCommand($sql_temp1)->queryAll();
- if ($old_bus_no[0]['bus_no']==$bus_no){
-
- }else{
- if ($num[0]) {
- $json = array();
- $json["code"] = "2";
- $json["info"] = "车牌号不能重复";
- return json_encode($json);
- }
- }
- //end
- $brand_id = $_REQUEST['brand_id'] ? $_REQUEST['brand_id'] : '';
- $bus_license = $_REQUEST['bus_license'];
- $buy_date = $_REQUEST['buy_date'];
- $seat_type = $_REQUEST['seat_type'] ? $_REQUEST['seat_type'] : '';
- $seat_desc = $_REQUEST['seat_desc'] ? $_REQUEST['seat_desc'] : '';
- $seat_count = $_REQUEST['seat_count'] ? $_REQUEST['seat_count'] : '';
- $seat_count_num_temp = isset($_REQUEST['seat_count_num']) ? $_REQUEST['seat_count_num'] : '';
- $seat_count_num = mb_substr($seat_count_num_temp,0,strlen($seat_count_num_temp)-3);
- $driver_count = $_REQUEST['driver_count'];
- $tour_count = $_REQUEST['tour_count'];
- $extra_count = $_REQUEST['extra_count'];
- $fuel_id = $_REQUEST['fuel_id'];
- $mpg = $_REQUEST['mpg'];
- $register_time = $_REQUEST['register_time'];
- $bus_color = $_REQUEST['bus_color'];
- $old_path = '';
- $old_type = '';
- $img_path_old_tp = $_REQUEST['bus_img_path_old'];
- $img_type_old_tp = $_REQUEST['bus_img_type_old'];
- $img_path_old = explode(',', $img_path_old_tp);
- $img_type_old = explode(',', $img_type_old_tp);
- if (isset($img_path_old)) {
- foreach ($img_path_old as $key => $item) {
- if ($item != '' || $img_type_old[$key] != '') {
- $type = $img_type_old[$key];
- if ($old_path == '') {
- $old_path .= $item;
- $old_type .= $type;
- } else {
- $old_path .= ',' . $item;
- $old_type .= ',' . $type;
- }
-
- }
- }
- }
- $imgType = '';
- $imgPath = '';
- $imgMeta = zzcsUtils::uploadMultiple('bus_img');
- if ($imgMeta) {
- $imgType = $imgMeta['type'];
- $imgPath = $imgMeta['path'];
- }
- $imgPath = $old_path == '' ? $imgPath : $old_path . ($imgPath != '' ? (',' . $imgPath) : '');
- $imgType = $old_type == '' ? $imgType : $old_type . ($imgType != '' ? (',' . $imgType) : '');
-
- $tmpArray = explode(',', $imgPath);
- $newArray = array_reverse($tmpArray);
- $csArray = array();
- foreach ($newArray as $k => $v) {
- if ($v) {
- $csArray[$k] = 'http://' . CS1_DOMAIN .'' . $v;
- }
- }
- $imgPath = implode(',', $newArray);
- $imgPath2 = implode(',', $csArray);
-
- $tmpArray = explode(',', $imgType);
- $newArray = array_reverse($tmpArray);
- $imgType = implode(',', $newArray);
- if ($bus_company_type == '' || $bus_no == '' || $bus_company == '' || $brand_id == '' || $seat_type == '' || $seat_count == '') {
- $json = array();
- $json["code"] = "2";
- $json["info"] = "缺少必要参数";
- return json_encode($json);
- } else {
- $sql = "update base_bus set update_user_id = '$model',bus_no = '$bus_no',org_id='$bus_company',brand_id='$brand_id',bus_license = '$bus_license',seat_count='$seat_count_num',
- buy_date = '$buy_date',seat_type = '$seat_type',seat_desc = '$seat_desc',bus_type_res_id = '$seat_count',driver_count='$driver_count',tour_count='$tour_count',
- extra_count = '$extra_count',fuel_form = '$fuel_id',mpg='$mpg',register_time ='$register_time',bus_color = '$bus_color', bus_img_path_ori = '$imgPath',bus_img_path = '$imgPath2',bus_img_type = '$imgType'
- where bus_id = '$bus_id'";
- try {
- $res = Yii::$app->db->createCommand($sql)->query();
- if (!$res) {
- $json = array();
- $json["code"] = "2";
- $json["info"] = "修改车辆信息失败!";
- return json_encode($json);
- }
- } catch (\Exception $e) {
- $json = array();
- $json["code"] = "1";
- $json["info"] = "修改车辆信息失败!";
- return json_encode($json);
- }
- $json = array();
- $json["code"] = "0";
- $json["info"] = "修改车辆信息成功!";
- return json_encode($json);
- }
- }
-
- // 删除车辆
- public function actionCancelBus()
- {
- $bus_id = isset($_REQUEST['bus_id']) ? $_REQUEST['bus_id'] : '';
- if ($bus_id == '') {
- $json = array();
- $json["code"] = "1";
- $json["info"] = "删除车辆失败!";
- return json_encode($json);
- } else {
- $obj = new BaseResource();
- $data = $obj->cancelBus($bus_id);
- return json_encode($data);
- }
- }
-
- // 删除车辆
- public function actionCancelDriver()
- {
- $driver_id = isset($_REQUEST['driver_id']) ? $_REQUEST['driver_id'] : '';
- if ($driver_id == '') {
- $json = array();
- $json["code"] = "1";
- $json["info"] = "删除车辆失败!";
- return json_encode($json);
- } else {
- $obj = new BaseResource();
- $data = $obj->cancelDriver($driver_id);
- return json_encode($data);
- }
- }
-
- // 获取添加车辆信息
- public function actionAddBus()
- {
- $get_seat_type = isset($_REQUEST['seat_type']) ? $_REQUEST['seat_type'] : '-1';
- $obj = new BaseResource();
- $brand = $obj->getBrand();
- $bus_company = $obj->getBusCompany();
- $seat_type = $obj->getSeatType();
- $fuel = $obj->getFuel();
- $color = $obj->getColor();
- $pic_type = $obj->getPicType();
- $seat_count = $obj->getSeatCount($get_seat_type);
- return $this->render('resource', ['view' => '_addBus', 'brand' => $brand, 'bus_company' => $bus_company, 'seat_count' => $seat_count, 'seat_type' => $seat_type, 'fuel' => $fuel, 'color' => $color, 'pic_type' => $pic_type]);
- }
-
- // 添加车辆信息
- public function actionCommitAdd()
- {
- $bus_company_type = $_REQUEST['bus_company_type'] ? $_REQUEST['bus_company_type'] : '';
- $bus_company_tp = $_REQUEST['bus_company'] ? $_REQUEST['bus_company'] : '';
- $model = Yii::$app->user->id;
- $obj = new BusReport;
- $main_corp = $obj->getUserMainCorp();
- $main_corp_id = $main_corp;
-
- if ($bus_company_type == '1') {
- $bus_company_sql = "select org_id from base_user where id = '$model'";
- $bus_company_do = Yii::$app->db->createCommand($bus_company_sql)->queryOne();
- $bus_company = $bus_company_do['org_id'];
- } else if ($bus_company_type == '2') {
- $bus_company = $bus_company_tp;
- }
- //判断车牌是否重复
- $bus_no = $_REQUEST['bus_no'] ? $_REQUEST['bus_no'] : '';
- $sql_temp = "select count(bus_id) as num from base_bus where BUS_NO = '$bus_no'";
- $num = Yii::$app->db->createCommand($sql_temp)->queryAll();
- if ($num[0]['num']) {
- $json = array();
- $json["code"] = "2";
- $json["info"] = "车牌号不能重复";
- return json_encode($json);
- }
- //end
- $brand_id = isset($_REQUEST['brand_id']) ? $_REQUEST['brand_id'] : '';
- $bus_license = $_REQUEST['bus_license'];
- $buy_date = $_REQUEST['buy_date'];
- $seat_type = isset($_REQUEST['seat_type']) ? $_REQUEST['seat_type'] : '';
- $seat_desc = isset($_REQUEST['seat_desc']) ? $_REQUEST['seat_desc'] : '';
- $seat_count = isset($_REQUEST['seat_count']) ? $_REQUEST['seat_count'] : '';
- $seat_count_num_temp = isset($_REQUEST['seat_count_num']) ? $_REQUEST['seat_count_num'] : '';
- $seat_count_num = mb_substr($seat_count_num_temp,0,strlen($seat_count_num_temp)-3);
- $driver_count = $_REQUEST['driver_count'];
- $tour_count = $_REQUEST['tour_count'];
- $extra_count = $_REQUEST['extra_count'];
- $fuel_id = $_REQUEST['fuel_id'];
- $mpg = $_REQUEST['mpg'];
- $register_time = $_REQUEST['register_time'];
- $bus_color = $_REQUEST['bus_color'];
- $old_path = '';
- $old_type = '';
- $imgType = '';
- $imgPath = '';
- $imgMeta = zzcsUtils::uploadMultiple('bus_img');
- if ($imgMeta) {
- $imgType = $imgMeta['type'];
- $imgPath = $imgMeta['path'];
- }
- $imgPath = $old_path == '' ? $imgPath : $old_path . ($imgPath != '' ? (',' . $imgPath) : '');
- $imgType = $old_type == '' ? $imgType : $old_type . ($imgType != '' ? (',' . $imgType) : '');
-
- $tmpArray = explode(',', $imgPath);
- $newArray = array_reverse($tmpArray);
- $csArray = array();
- foreach ($newArray as $k => $v) {
- if ($v) {
- $csArray[$k] = 'http://' . CS1_DOMAIN .'' . $v;
- }
- }
- $imgPath = implode(',', $newArray);
- $imgPath2 = implode(',', $csArray);
-
- $tmpArray = explode(',', $imgType);
- $newArray = array_reverse($tmpArray);
- $imgType = implode(',', $newArray);
- if ($bus_company_type == '' || $bus_no == '' || $bus_company == '' || $brand_id == '' || $seat_type == '' || $seat_count == '') {
- $json = array();
- $json["code"] = "2";
- $json["info"] = "缺少必要参数";
- return $json;
- } else {
- $sql = "insert into base_bus (main_corp_id,create_user_id,bus_no,org_id,brand_id,bus_license,buy_date,seat_type,seat_desc,seat_count,
- bus_type_res_id,driver_count,tour_count,extra_count,fuel_form
- , mpg,register_time,bus_color,bus_img_path_ori,bus_img_path,bus_img_type) values
- ('$main_corp_id','$model','$bus_no','$bus_company','$brand_id','$bus_license','$buy_date','$seat_type','$seat_desc','$seat_count_num','$seat_count','$driver_count','$tour_count','$extra_count','$fuel_id',
- '$mpg','$register_time','$bus_color','$imgPath','$imgPath2','$imgType')";
- try {
- $res = Yii::$app->db->createCommand($sql)->query();
- if (!$res) {
- $json = array();
- $json["code"] = "2";
- $json["info"] = "添加车辆信息失败!";
- return json_encode($json);
- }
- } catch (\Exception $e) {
- $json = array();
- $json["code"] = "1";
- $json["info"] = "添加车辆信息失败!";
- return json_encode($json);
- }
- $json = array();
- $json["code"] = "0";
- $json["info"] = "添加车辆信息成功!";
- return json_encode($json);
- }
- }
-
- // 司机列表
- public function actionDriverList()
- {
- $sex = isset($_REQUEST['sex']) ? $_REQUEST['sex'] : '-1';
- $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : '-1';
- $driver_number = isset($_REQUEST['driver_number']) ? $_REQUEST['driver_number'] : '-1';
- $phone_no = isset($_REQUEST['phone_no']) ? $_REQUEST['phone_no'] : '-1';
- $license_no = isset($_REQUEST['license_no']) ? $_REQUEST['license_no'] : '-1';
- $bus_supply = isset($_REQUEST['bus_supply']) ? $_REQUEST['bus_supply'] : '-1';
- $bus_company = isset($_REQUEST['bus_company']) ? $_REQUEST['bus_company'] : '-1';
- $obj = new BaseResource();
- $data = $obj->getDriverList($sex, $name, $driver_number, $phone_no, $license_no, $bus_supply, $bus_company);
- $bus_company = $obj->getBusCompany();
- $driver = $obj->getDriver();
- $dataProvider = new SqlDataProvider([
- 'sql' => $data['sql'],
- 'totalCount' => $data['total'],
- 'pagination' => ['pagesize' => 20],
- ]);
- return $this->render('resource', ['view' => '_driverList', 'dataProvider' => $dataProvider, 'bus_company' => $bus_company, 'driver' => $driver]);
- }
-
- // 添加司机
- public function actionAddDriver()
- {
- $get_area1 = isset($_REQUEST['area1']) ? $_REQUEST['area1'] : '';
- $get_area2 = isset($_REQUEST['area2']) ? $_REQUEST['area2'] : '';
- // $get_area3 = isset($_REQUEST['area3'])?$_REQUEST['area3']:'';
- $obj = new BaseResource();
- $bus_company = $obj->getBusCompany();
- $area1 = $obj->getArea();
- if ($get_area1 != '') {
- $area2 = $obj->getArea($get_area1);
- }
- if ($get_area2 != '') {
- $area3 = $obj->getArea($get_area2);
- }
- return $this->render('resource', ['view' => '_addDriver', 'bus_company' => $bus_company, 'area1' => $area1, 'area2' => isset($area2) ? $area2 : '', 'area3' => isset($area3) ? $area3 : '']);
- }
-
- //提交添加
- public function actionCommitDriver()
- {
- $bus_company_type = $_REQUEST['bus_company_type'] ? $_REQUEST['bus_company_type'] : '';
- $bus_company_tp = $_REQUEST['bus_company'] ? $_REQUEST['bus_company'] : '';
- $model = Yii::$app->user->id;
- $obj = new BusReport;
- $main_corp = $obj->getUserMainCorp();
- $main_corp_id = $main_corp;
-
- if ($bus_company_type == '1') {
- $bus_company_sql = "select org_id from base_user where id = '$model'";
- $bus_company_do = Yii::$app->db->createCommand($bus_company_sql)->queryOne();
- $bus_company = $bus_company_do['org_id'];
- } else if ($bus_company_type == '2') {
- $bus_company = $bus_company_tp;
- }
- $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : '';
- $status = isset($_REQUEST['status']) ? $_REQUEST['status'] : '';
- $driver_number = isset($_REQUEST['driver_number']) ? $_REQUEST['driver_number'] : '';
- $license_no = isset($_REQUEST['license_no']) ? $_REQUEST['license_no'] : '';
- $phone_no = isset($_REQUEST['phone_no']) ? $_REQUEST['phone_no'] : '';
- $sex = isset($_REQUEST['sex']) ? $_REQUEST['sex'] : '-1';
- $birth = isset($_REQUEST['birth']) ? $_REQUEST['birth'] : '';
- $first_date = isset($_REQUEST['first_date']) ? $_REQUEST['first_date'] : '';
- $address = isset($_REQUEST['address']) ? $_REQUEST['address'] : '';
- $license_start_date = isset($_REQUEST['license_start_date']) ? $_REQUEST['license_start_date'] : '';
- $valid_years = isset($_REQUEST['valid_years']) ? $_REQUEST['valid_years'] : '';
- $area = isset($_REQUEST['area']) ? $_REQUEST['area'] : '';
- $cur_time = date('Y-m-d h:i:s', time());
- if ($bus_company_type == '' || $name == '' || $bus_company == '' || $status == '' || $license_no == '' || $phone_no == '' || $sex == '-1') {
- $json = array();
- $json["code"] = "1";
- $json["info"] = "添加车辆信息失败!";
- return json_encode($json);
- } else {
- $sql = "insert into base_driver (main_corp_id,create_user_id,driver_name,driver_status,org_id,driver_number,license_no,
- phone_no,sex,driver_birthday,first_license_date,address,license_start_date,valid_years,area_id,create_time) values (
- '$main_corp_id','$model','$name','$status','$bus_company','$driver_number','$license_no','$phone_no','$sex','$birth','$first_date','$address','$license_start_date','$valid_years','$area','$cur_time')";
- $res = Yii::$app->db->createCommand($sql)->query();
- if (!$res) {
- $json = array();
- $json["code"] = "2";
- $json["info"] = "添加司机信息失败!";
- return json_encode($json);
- }
- $json = array();
- $json["code"] = "0";
- $json["info"] = "添加司机信息成功!";
- return json_encode($json);
- }
- }
-
- public function actionDriverDetail()
- {
- $driver_id = isset($_REQUEST['driver_id']) ? $_REQUEST['driver_id'] : '';
- $obj = new BaseResource();
- if ($driver_id == '') {
- return false;
- }
- $sql = "select driver_id,driver_name,if(driver_status=0,'正常','有请假') as status,(select res_name from base_resource where res_id = org_id) as bus_company,org_id,driver_number,license_no,
- phone_no,if(sex=1,'男','女') as sex,driver_birthday,first_license_date,address,license_start_date,valid_years,area_id,(select area_name from base_area_view a where a.area_id=b.area_id ) as area_name,(select parent_area_name from base_area_view a where a.area_id=b.area_id ) as parent_area_name,(select top_area_name from base_area_view a where a.area_id=b.area_id ) as top_area_name from base_driver b where cancel_flag=0 and driver_id = $driver_id";
- $data = Yii::$app->db->createCommand($sql)->queryAll();
- $user_bus_company = $obj->getUserCompany();
- return $this->render('resource', ['view' => '_driverDetail', 'data' => $data,'user_bus_company'=>$user_bus_company]);
- }
-
- public function actionDriverModify()
- {
- $driver_id = isset($_REQUEST['driver_id']) ? $_REQUEST['driver_id'] : '';
- if ($driver_id == '') {
- return false;
- }
- $get_area1 = isset($_REQUEST['area1']) ? $_REQUEST['area1'] : '';
- $get_area2 = isset($_REQUEST['area2']) ? $_REQUEST['area2'] : '';
- // $get_area3 = isset($_REQUEST['area3'])?$_REQUEST['area3']:'';
- $obj = new BaseResource();
- $bus_company = $obj->getBusCompany();
- $area1 = $obj->getArea();
- $sql = "select driver_id,driver_name,driver_status,org_id,driver_number,license_no,
- phone_no,sex,driver_birthday,first_license_date,address,license_start_date,valid_years,area_id,(select parent_area_id from base_area_view a where a.area_id=b.area_id ) as parent_area_id,(select top_area_id from base_area_view a where a.area_id=b.area_id ) as top_area_id from base_driver b where cancel_flag=0 and driver_id = $driver_id";
- $data = Yii::$app->db->createCommand($sql)->queryAll();
- if ($get_area1 != '') {
- $area2 = $obj->getArea($get_area1);
- } else {
- $area2 = $obj->getArea($data[0]['top_area_id']);
- }
- if ($get_area2 != '') {
- $area3 = $obj->getArea($data[0]['parent_area_id']);
- }
- $user_bus_company = $obj->getUserCompany();
- return $this->render('resource', ['view' => '_driverDetailModify', 'data' => $data, 'bus_company' => $bus_company, 'area1' => $area1, 'area2' => isset($area2) ? $area2 : '', 'area3' => isset($area3) ? $area3 : '','user_bus_company'=>$user_bus_company]);
- }
-
- public function actionCommitModifyDriver()
- {
- $bus_company_type = $_REQUEST['bus_company_type'] ? $_REQUEST['bus_company_type'] : '';
- $bus_company_tp = $_REQUEST['bus_company'] ? $_REQUEST['bus_company'] : '';
- $model = Yii::$app->user->id;
- if ($bus_company_type == '1') {
- $bus_company_sql = "select org_id from base_user where id = '$model'";
- $bus_company_do = Yii::$app->db->createCommand($bus_company_sql)->queryOne();
- $bus_company = $bus_company_do['org_id'];
- } else if ($bus_company_type == '2') {
- $bus_company = $bus_company_tp;
- }
- $driver_id = isset($_REQUEST['driver_id']) ? $_REQUEST['driver_id'] : '';
- $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : '';
- $status = isset($_REQUEST['status']) ? $_REQUEST['status'] : '';
- $driver_number = isset($_REQUEST['driver_number']) ? $_REQUEST['driver_number'] : '';
- $license_no = isset($_REQUEST['license_no']) ? $_REQUEST['license_no'] : '';
- $phone_no = isset($_REQUEST['phone_no']) ? $_REQUEST['phone_no'] : '';
- $sex = isset($_REQUEST['sex']) ? $_REQUEST['sex'] : '-1';
- $birth = isset($_REQUEST['birth']) ? $_REQUEST['birth'] : '';
- $first_date = isset($_REQUEST['first_date']) ? $_REQUEST['first_date'] : '';
- $address = isset($_REQUEST['address']) ? $_REQUEST['address'] : '';
- $license_start_date = isset($_REQUEST['license_start_date']) ? $_REQUEST['license_start_date'] : '';
- $valid_years = isset($_REQUEST['valid_years']) ? $_REQUEST['valid_years'] : '';
- $area = isset($_REQUEST['area']) ? $_REQUEST['area'] : '';
- $cur_time = date('Y-m-d h:i:s', time());
- if ($bus_company_type == '' || $driver_id == '' || $name == '' || $bus_company == '' || $status == '' || $license_no == '' || $phone_no == '' || $sex == '-1') {
- $json = array();
- $json["code"] = "1";
- $json["info"] = "修改司机信息失败!";
- return json_encode($json);
- } else {
- $sql = "update base_driver set UPDATE_USER_ID='$model',DRIVER_NAME= '$name',DRIVER_STATUS='$status',ORG_ID='$bus_company',DRIVER_NUMBER='$driver_number',LICENSE_NO='$license_no',
- PHONE_NO= '$phone_no',SEX= '$sex',DRIVER_BIRTHDAY='$birth',FIRST_LICENSE_DATE='$first_date',ADDRESS='$address',LICENSE_START_DATE='$license_start_date',
- VALID_YEARS='$valid_years',AREA_ID='$area' where DRIVER_ID = '$driver_id' and cancel_flag = 0";
- $res = Yii::$app->db->createCommand($sql)->query();
- if (!$res) {
- $json = array();
- $json["code"] = "2";
- $json["info"] = "修改司机信息失败!";
- return json_encode($json);
- }
- $json = array();
- $json["code"] = "0";
- $json["info"] = "修改司机信息成功!";
- return json_encode($json);
- }
- }
-
-
- }
|