/** * 主营登记 */ public function actionMainbusiness() { $this->pageTitle = Yii::app()->name . '-' . "主营登记"; $userID = Commonmodel::getOrganID(); $model = Dealer::model()->findByAttributes(array('userID' => $userID)); if (empty($model)) { //$model = new Dealer(); } // 显示车系 $showvehicle = DealerVehicle::model()->findAll('userid=:userid', array(':userid' => $userID)); // 显示主营品类 $showcpname = DealerCpname::model()->findAll('OrganID=:userID', array(':userID' => $userID)); //$sqlveh = "select * from jpd_dealer_vehicle where userid = $userID"; //$showvehicle = DBUtil::queryAll($sqlveh); //ajax校验 if (isset($_POST['ajax']) && $_POST['ajax'] === 'dealer-form') { echo CActiveForm::validate($model); Yii::app()->end(); } if (isset($_POST)) { $make = $_POST['make']; $car = $_POST['car']; $year = $_POST['year']; $model2 = $_POST['model']; // var_dump($_POST['make']); // 把主营车系添加到数据库 $vehlegth = count($make); for ($i = 0; $i < $vehlegth; $i++) { $dealerVehicle = new DealerVehicle(); $dealerVehicle->userid = $userID; $dealerVehicle->businessMake = $make[$i]; $dealerVehicle->businessCar = $car[$i]; $dealerVehicle->businessYear = $year[$i]; $dealerVehicle->businessCarModel = $model2[$i]; $bool1 = $dealerVehicle->save(); } //主营品类(标准名称) $BigName = $_POST['BigName']; $SubName = $_POST['SubName']; $CpName = $_POST['CpName']; $BigpartsID = $_POST['BigpartsID']; $SubCodeID = $_POST['SubCodeID']; $CpNameID = $_POST['CpNameID']; // 把主营车系添加到数据库 $cplegth = count($BigName); for ($j = 0; $j < $cplegth; $j++) { $mogr = new DealerCpname(); $mogr->OrganID = $userID; $mogr->BigName = $BigName[$j]; $mogr->SubName = $SubName[$j]; $mogr->CpName = $CpName[$j]; $mogr->BigpartsID = $BigpartsID[$j]; $mogr->SubCodeID = $SubCodeID[$j]; $mogr->CpNameID = $CpNameID[$j]; $bool2 = $mogr->save(); } // $model->attributes = $_POST['Dealer']; // $model->businessCar = ''; // $model->CreateTime = time(); // $model->userID = $userID; //$model->save(); // if ($bool1 || $bool2) if ($_POST['returnok'] == "ok" || $bool1 || $bool2) { $this->redirect('mainbusupdate'); } } $this->render('mainbusiness', array('model' => $model, 'showvehicles' => $showvehicle, 'showcpnames' => $showcpname)); }
/** * 主营信息管理 */ public function actionMainbusiness() { $this->pageTitle = Yii::app()->name . '-' . "主营登记"; $userID = Commonmodel::getOrganID(); if ($_POST['brand'] || $_POST['cp_name'] || $_POST['delcpids']) { $message = "保存成功"; } else { $message = ''; } // if (!empty($_POST['brand'])) { // $model = MakeOrgan::model()->updateAll(array('businessBrand' => $_POST['brand']), 'userID=:userID', array(':userID' => $userID)); // } if ($_POST) { $BigName = $_POST['BigName']; $SubName = $_POST['SubName']; $CpName = $_POST['CpName']; $BigpartsID = $_POST['BigpartsID']; $SubCodeID = $_POST['SubCodeID']; $CpNameID = $_POST['CpNameID']; $cplegth = count($BigpartsID); if ($cplegth > 0) { for ($j = 0; $j < $cplegth; $j++) { $mogr = new DealerCpname(); $mogr->OrganID = $userID; $mogr->BigName = $BigName[$j]; $mogr->SubName = $SubName[$j]; $mogr->CpName = $CpName[$j]; $mogr->BigpartsID = $BigpartsID[$j]; $mogr->SubCodeID = $SubCodeID[$j]; $mogr->CpNameID = $CpNameID[$j]; $mogr->save(); } } } if (!empty($_POST['delcpids'])) { $result = DealerCpname::model()->deleteAll("ID in ({$_POST['delcpids']})"); } $model = MakeOrgan::model()->find('userID=:userID', array(':userID' => $userID)); $showcpname = DealerCpname::model()->findAll('OrganID=:userID', array(':userID' => $userID)); $this->render('mainbusiness', array('model' => $model, 'showcpnames' => $showcpname, 'message' => $message)); }