Ejemplo n.º 1
0
 function create()
 {
     $organ = new Organ();
     $organ->name = $this->params('name');
     $organ->description = $this->params('description');
     $organ->document_id = $this->session('document_id');
     if ($organ->save()) {
         $this->redirect('/documents/' . $this->session('document_id') . '/organs', 'Salvo com sucesso!');
     } else {
         $this->redirect('/documents/' . $this->session('document_id') . '/organs', 'Ocorreu algum erro.');
     }
 }
 function create()
 {
     $organ = new Organ();
     $organ->name = $this->params('name');
     $organ->description = $this->params('description');
     $organ->document_id = $this->session('document_id');
     if ($organ->save()) {
         $this->redirect('/documents/' . $this->session('document_id') . '/organs', 'Criado com sucesso!');
     } else {
         $this->redirect('/documents/' . $this->session('document_id') . '/organs', 'Falha na criação!');
     }
 }
 public function testOrganSuccess()
 {
     $organ = new Organ();
     $organ->name = "liver";
     $this->assertTrue($organ->save());
 }
Ejemplo n.º 4
0
 /**
  * 公司信息保存
  */
 public function actionSavedealerorgan()
 {
     $OrganID = Yii::app()->user->getOrganID();
     $Organ = Yii::app()->request->getParam("Organ");
     $arr = Yii::app()->request->getParam("telPhone");
     $TelPhone = "";
     foreach ($arr as $key => $val) {
         if (empty($val)) {
             continue;
         }
         $TelPhone .= $val . ",";
     }
     $model = Organ::model()->findByPK($OrganID);
     if (empty($model)) {
         $model = new Organ();
     }
     //保存organ数据
     $model->attributes = $Organ;
     $model->TelPhone = trim($TelPhone, ',');
     //判断基本信息是否为空,为空则不提交
     if ($Organ) {
         //接收删除图片的地址
         $photoId = Yii::app()->request->getParam("photoId");
         //判断是否删除图片
         if (!empty($photoId)) {
             $imageids = explode(',', $photoId);
             foreach ($imageids as $imageid) {
                 $picture = OrganPhoto::model()->find('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
                 //判断该图片路径是否存在数据库中
                 if (empty($picture)) {
                     $ftp = new Ftp();
                     $res = $ftp->delete_file($imageid);
                     $ftp->close();
                 } else {
                     OrganPhoto::model()->deleteAll('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
                     $ftp = new Ftp();
                     $res = $ftp->delete_file($picture->Path);
                     $ftp->close();
                 }
             }
         }
         //接收上传图片地址
         $goodsImages = Yii::app()->request->getParam("goodsImages");
         //判断是否有上传图片
         if (!empty($goodsImages)) {
             $imglegth = count($goodsImages);
             for ($i = 0; $i < $imglegth; $i++) {
                 $goodsImg = new OrganPhoto();
                 $goodsImg->OrganID = $OrganID;
                 $goodsImg->Path = $goodsImages[$i];
                 $goodsImg->save();
             }
         }
         //判断是否上传营业执照
         $BLPoto = Yii::app()->request->getParam("BLPoto");
         if ($model->BLPoto != $BLPoto) {
             if (!empty($model->BLPoto)) {
                 $ftp = new Ftp();
                 $res = $ftp->delete_file($model->BLPoto);
                 $ftp->close();
             }
             $model->BLPoto = $BLPoto;
         }
         //接收dealer数据
         $dealer = Yii::app()->request->getParam("Dealer");
         //保存dealer数据
         $dealermodel = Dealer::model()->find("OrganID=:organid", array(":organid" => $OrganID));
         if (empty($dealermodel)) {
             //判断是否第一次添加
             $dealermodel = new Dealer();
             $dealermodel->OrganID = $OrganID;
         }
         $dealermodel->SaleMoney = $dealer['SaleMoney'];
         $dealermodel->SaleDomain = $dealer['SaleDomain'];
         $dealermodel->ShopArea = $dealer['ShopArea'];
         if ($dealermodel->save() && $model->save()) {
             //保存成功
             $this->redirect(array('index'));
         } else {
             var_dump($dealermodel->errors);
             var_dump($model->errors);
             die;
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * 公司信息保存
  */
 public function actionSaveserviceorgan()
 {
     $OrganID = Yii::app()->user->getOrganID();
     $Organ = Yii::app()->request->getParam("Organ");
     $arr = Yii::app()->request->getParam("telPhone");
     $TelPhone = "";
     foreach ($arr as $key => $val) {
         if (empty($val)) {
             continue;
         }
         $TelPhone .= $val . ",";
     }
     $model = Organ::model()->findByPK($OrganID);
     if (empty($model)) {
         $model = new Organ();
     }
     //保存organ数据
     $model->attributes = $Organ;
     $model->TelPhone = trim($TelPhone, ',');
     //判断基本信息是否为空,为空则不提交
     if ($Organ) {
         //接收删除图片的地址
         $photoId = Yii::app()->request->getParam("photoId");
         //判断是否删除图片
         if (!empty($photoId)) {
             $imageids = explode(',', $photoId);
             foreach ($imageids as $imageid) {
                 $picture = OrganPhoto::model()->find('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
                 //判断该图片路径是否存在数据库中
                 if (empty($picture)) {
                     $ftp = new Ftp();
                     $res = $ftp->delete_file($imageid);
                     $ftp->close();
                 } else {
                     OrganPhoto::model()->deleteAll('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
                     $ftp = new Ftp();
                     $res = $ftp->delete_file($picture->Path);
                     $ftp->close();
                 }
             }
         }
         //接收上传图片地址
         $goodsImages = Yii::app()->request->getParam("goodsImages");
         //判断是否有上传图片
         if (!empty($goodsImages)) {
             $imglegth = count($goodsImages);
             for ($i = 0; $i < $imglegth; $i++) {
                 $goodsImg = new OrganPhoto();
                 $goodsImg->OrganID = $OrganID;
                 $goodsImg->Path = $goodsImages[$i];
                 $goodsImg->save();
             }
         }
         //判断是否上传营业执照
         $BLPoto = Yii::app()->request->getParam("BLPoto");
         if ($model->BLPoto != $BLPoto) {
             if (!empty($model->BLPoto)) {
                 $ftp = new Ftp();
                 $res = $ftp->delete_file($model->BLPoto);
                 $ftp->close();
             }
             $model->BLPoto = $BLPoto;
         }
         //接收service数据
         $service = Yii::app()->request->getParam("Service");
         $opentime = Yii::app()->request->getParam("OpenTime");
         //保存service数据
         $servicemodel = Service::model()->find("OrganID=:organid", array(":organid" => $OrganID));
         if (empty($servicemodel)) {
             //判断是否第一次添加
             $servicemodel = new Service();
             $servicemodel->OrganID = $OrganID;
         }
         $servicemodel->PositionCount = $service['PositionCount'];
         $servicemodel->TechnicianCount = $service['TechnicianCount'];
         $servicemodel->ParkingDigits = $service['ParkingDigits'];
         $servicemodel->ReservationMode = $service['ReservationMode'];
         $servicemodel->ShopArea = $service['ShopArea'];
         $servicemodel->OpenTime = $opentime[0] . ',' . $opentime[1] . ',' . $opentime[2] . ',' . $opentime[3];
         //$model->attributes = $Organ;
         if ($servicemodel->save() && $model->save()) {
             //保存成功
             //$file->saveAs(Yii::app()->params['uploadPath'].$model->Logo, true);
             $this->redirect(array('index'));
         } else {
             var_dump($goodsImg->errors);
             die;
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * 公司信息保存
  */
 public function actionSaveorgan()
 {
     $OrganID = Yii::app()->user->getOrganID();
     $identity = Yii::app()->user->identity;
     $Organ = Yii::app()->request->getParam("Organ");
     $arr = Yii::app()->request->getParam("telPhone");
     $TelPhone = "";
     foreach ($arr as $val) {
         if (empty($val)) {
             continue;
         }
         $TelPhone .= $val . ",";
     }
     $model = Organ::model()->findByPK($OrganID);
     if (empty($model)) {
         $model = new Organ();
     }
     //保存organ数据
     $model->attributes = $Organ;
     $model->TelPhone = trim($TelPhone, ',');
     //判断基本信息是否为空,为空则不提交
     if ($Organ) {
         //接收删除图片的地址
         $photoId = Yii::app()->request->getParam("photoId");
         //判断是否删除图片
         if (!empty($photoId)) {
             $this->delorganphoto($photoId);
         }
         //接收上传图片地址
         $goodsImages = Yii::app()->request->getParam("goodsImages");
         //判断是否有上传图片
         if (!empty($goodsImages)) {
             $this->saveorganphoto($goodsImages);
         }
         //判断是否上传营业执照
         $BLPoto = Yii::app()->request->getParam("BLPoto");
         if ($model->BLPoto != $BLPoto) {
             if (!empty($model->BLPoto)) {
                 $ftp = new Ftp();
                 $ftp->delete_file($model->BLPoto);
                 $ftp->close();
             }
             $model->BLPoto = $BLPoto;
         }
         //判断是否上传门店照片
         $ShopPoto = trim(Yii::app()->request->getParam("ShopPoto"), ",");
         $delShopPoto = trim(Yii::app()->request->getParam("delShopPoto"), ",");
         if ($ShopPoto) {
             $ShopPotos = explode(",", $ShopPoto);
             $delShopPotos = explode(",", $delShopPoto);
             foreach ($ShopPotos as $val) {
                 if (!in_array($val, $delShopPotos)) {
                     $this->savePhotoInfoToMysql($val, $OrganID, 2);
                 }
             }
         }
         $model->Status = 1;
         if ($identity == 1) {
             $this->savemakerdata();
         } elseif ($identity == 2) {
             $this->savedealerdata();
         } elseif ($identity == 3) {
             $this->saveservicedata();
         }
         if (!$model->save()) {
             //var_dump($model->errors);die;
             throw new CHttpException(400, '保存机构信息失败!');
         }
     }
     $this->redirect(array("activation/finish"));
 }
Ejemplo n.º 7
0
 /**
  * 公司信息保存
  */
 public function actionSavemakeorgan()
 {
     $OrganID = Yii::app()->user->getOrganID();
     $Organ = Yii::app()->request->getParam("Organ");
     $model = Organ::model()->findByPK($OrganID);
     if (empty($model)) {
         $model = new Organ();
     }
     //保存organ数据
     $model->attributes = $Organ;
     //判断基本信息是否为空,为空则不提交
     if ($Organ) {
         //接收删除图片的地址
         $photoId = Yii::app()->request->getParam("photoId");
         //判断是否删除图片
         if (!empty($photoId)) {
             $imageids = explode(',', $photoId);
             foreach ($imageids as $imageid) {
                 $picture = OrganPhoto::model()->find('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
                 //判断该图片路径是否存在数据库中
                 if (empty($picture)) {
                     $myfileurl = Yii::app()->params['uploadPath'] . $imageid;
                     if (file_exists($myfileurl)) {
                         $result = unlink($myfileurl);
                     }
                 } else {
                     $myfileurl = Yii::app()->params['uploadPath'] . $picture->Path;
                     OrganPhoto::model()->deleteAll('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
                     if (file_exists($myfileurl)) {
                         $result = unlink($myfileurl);
                     }
                 }
             }
         }
         //接收上传图片地址
         $goodsImages = Yii::app()->request->getParam("goodsImages");
         //判断是否有上传图片
         if (!empty($goodsImages)) {
             $imglegth = count($goodsImages);
             for ($i = 0; $i < $imglegth; $i++) {
                 $goodsImg = new OrganPhoto();
                 $goodsImg->OrganID = $OrganID;
                 $goodsImg->Path = $goodsImages[$i];
                 $goodsImg->save();
             }
         }
         //判断是否上传营业执照
         $BLPoto = Yii::app()->request->getParam("BLPoto");
         if ($model->BLPoto != $BLPoto) {
             if (!empty($model->BLPoto)) {
                 $filePath = Yii::app()->params['uploadPath'] . $model->BLPoto;
                 if (file_exists($filePath)) {
                     unlink($filePath);
                 }
             }
             $model->BLPoto = $BLPoto;
         }
         //接收make数据
         $make = Yii::app()->request->getParam("Make");
         //保存make数据
         $makemodel = Make::model()->find("OrganID=:organid", array(":organid" => $OrganID));
         if (empty($makemodel)) {
             //判断是否第一次添加
             $makemodel = new Make();
             $makemodel->OrganID = $OrganID;
         }
         $makemodel->SaleMoney = $make['SaleMoney'];
         $makemodel->SaleDomain = $make['SaleDomain'];
         if ($makemodel->save() && $model->save()) {
             //保存成功
             $this->redirect(array('index'));
         } else {
             var_dump($makemodel->errors);
             var_dump($model->errors);
             die;
         }
     }
 }
Ejemplo n.º 8
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new User();
     $organ = new Organ();
     //$profile = new Profile;
     $this->performAjaxValidation(array($model, $organ));
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         //用户名
         $model->UserName = $_POST['User']['UserName'];
         $organ->attributes = $_POST['organ'];
         //$model->activkey = $model->encrypting(microtime() . $model->password);
         //$model->activkey=Yii::app()->controller->module->encrypting(microtime().$model->password);
         //邮箱
         $organ->OrganName = $_POST['Organ']['OrganName'];
         $organ->Email = $_POST['Organ']['Email'];
         //机构类型
         $organ->Identity = $_POST['Organ']['Identity'];
         $organ->Type = $_POST['Organ']['Type'];
         $organ->Phone = $_POST['Organ']['Phone'];
         //是否激活 默认已经激活
         $organ->Status = $_POST['Organ']['Status'];
         $organ->CreateTime = time();
         $organ->LastVisitTime = time();
         $organ->Province = $_POST['Organ']['Province'];
         $organ->City = $_POST['Organ']['City'];
         $organ->Area = $_POST['Organ']['Area'];
         $organ->Sort = $_POST['Organ']['Sort'];
         $organ->Recommend = $_POST['Organ']['Recommend'];
         if ($model->validate() && $organ->validate()) {
             if ($organ->save()) {
                 $organID = Yii::app()->jpdb->getLastInsertID();
                 $model->LastVisitTime = time();
                 $model->OrganID = $organID;
                 $model->PassWord = $model->encrypting($model->PassWord);
                 $model->verifyPassword = $model->encrypting($model->verifyPassword);
                 $model->IsMain = '1';
                 //主帐号
                 //激活码
                 $model->ActiveKey = $model->encrypting(microtime() . $model->PassWord);
                 $result = Yii::app()->jpdb->createCommand()->insert('{{user}}', array('UserName' => $model->UserName, 'PassWord' => $model->PassWord, 'OrganID' => $model->OrganID, 'LastVisitTime' => $model->LastVisitTime, 'ActiveKey' => $model->ActiveKey, 'IsMain' => $model->IsMain));
                 //添加到推荐记录里面,现只支持修理厂start
                 if ($_POST['Organ']['Identity'] == 3 && $_POST['Organ']['Recommend']) {
                     $record['RecomTime'] = time();
                     $record['BeFormalTime'] = 0;
                     $record['MemberStatus'] = 0;
                     $organ_factid = Organ::model()->find('OrganName=:OrganName', array(':OrganName' => $_POST['Organ']['Recommend']));
                     $record['DealerID'] = $organ_factid ? $organ_factid->ID : '';
                     $record['ServiceID'] = $organID;
                     $lms = Yii::app()->jpdb->createCommand()->insert('jpd_recommend_record', $record);
                 }
                 //添加到推荐记录里面,现只支持修理厂end
                 if ($result) {
                     $this->redirect(array('admin/admin'));
                 }
             }
         } else {
             $organ->validate();
         }
     }
     $this->render('create', array('model' => $model, 'organ' => $organ));
 }