public function actionServicedetail() { $id = $_GET['id']; //获取机构照片 $photo = ServicePhoto::model()->find("userId=:userId", array(":userId" => $id)); //获取修理厂基础信息 $model = Service::model()->find("userId=:userId", array(":userId" => $id)); $this->render('result', array('photo' => $photo, 'model' => $model)); }
public function actionSaveorgan() { $userId = Commonmodel::getOrganID(); //执行添加或修改操作 if ($_POST['Service']) { $userId = Commonmodel::getOrganID(); $service = $_POST['Service']; //获取营业时间、经营区域、地址 $openTime = $_POST['startWeek'] . "," . $_POST['endWeek'] . "," . $_POST['startTime'] . "," . $_POST['endTime']; $service['serviceOpenTime'] = $openTime; $service['serviceProvince'] = $_POST['serviceProvince']; $service['serviceCity'] = $_POST['serviceCity']; $service['serviceArea'] = $_POST['serviceArea']; $service['serviceRegionProvince'] = $_POST['serviceRegionProvince']; $service['serviceRegionCity'] = $_POST['serviceRegionCity']; $service['serviceRegionArea'] = $_POST['serviceRegionArea']; $rsType == false; // 添加机构照片 if ($_POST['organImages']) { $organImages = $_POST['organImages']; $imglegth = count($organImages); for ($i = 0; $i < $imglegth; $i++) { $organImg = new ServicePhoto(); $organImg->userId = $userId; $organImg->addTime = date("Y-m-d", time()); $organImg->photoName = $organImages[$i]; $organImg->save(); } $rsType = true; } else { $rsType = true; } // 删除机构照片 if (!empty($_POST['photoName'])) { $photoName = $_POST['photoName']; //该处传过来的其实是图片名称 $imagenames = explode(',', $photoName); foreach ($imagenames as $imagename) { $myfileurl = Yii::app()->params['uploadPath'] . $imagename; $oldpic = ServicePhoto::model()->find("photoName=:name", array(":name" => $imagename)); if ($oldpic) { //存入数据库后删除 $bools = ServicePhoto::model()->deleteAll("photoName=:name", array(":name" => $imagename)); if ($bools) { if (file_exists($myfileurl)) { unlink($myfileurl); } } } else { //添加时删除(未存入数据库) if (file_exists($myfileurl)) { unlink($myfileurl); } } } $rsType = true; } else { $rsType = true; } //判断机构信息是否存在,存在则修改,不存在则添加 $model = Service::model()->find("userId=:userId", array(":userId" => $userId)); if (!empty($service)) { if (empty($model)) { $model = new Service(); $model->userId = $userId; $model->attributes = $service; if ($model->save()) { $user = User::model()->findByPk($userId); $user->OrganID = $userId; $user->save(); } $rsType = true; } $model->attributes = $service; if ($model->updateByPk($userId, $service)) { $rsType = true; } } else { $rsType = true; } if ($rsType) { echo json_encode('OK'); } else { echo json_encode('NoOk'); } } }
public function actionServicedetail() { $id = $_GET['id']; $organID = Commonmodel::getOrganID(); //获取机构照片 $photo = ServicePhoto::model()->findAll("userId=:userId", array(":userId" => $id)); //获取修理厂基础信息(基础信息+联系方式) $model = Service::model()->find("userId=:userId", array(":userId" => $id)); //获取修理厂主营信息 $main = ServiceMain::model()->find("OrganID=:ID", array(":ID" => $id))->attributes; $routines = ServiceMainRoutine::model()->findAll("MainID=:ID AND OrganType=:Type", array(":ID" => $main['ID'], ":Type" => $main['OrganType'])); foreach ($routines as $rokey => $rovalue) { $routine[$rokey] = $rovalue->attributes; } $diagnos = ServiceMainDiagnos::model()->findAll("MainID=:ID AND OrganType=:Type", array(":ID" => $main['ID'], ":Type" => $main['OrganType'])); foreach ($diagnos as $dikey => $divalue) { $diagno[$dikey] = $divalue->attributes; } $parts = ServiceMainWearparts::model()->findAll("MainID=:ID AND OrganType=:Type", array(":ID" => $main['ID'], ":Type" => $main['OrganType'])); foreach ($parts as $pakey => $pavalue) { $part[$pakey] = $pavalue->attributes; } $repairs = ServiceMainRepair::model()->findAll("MainID=:ID AND OrganType=:Type", array(":ID" => $main['ID'], ":Type" => $main['OrganType'])); foreach ($repairs as $rekey => $revalue) { $repair[$rekey] = $revalue->attributes; } $record = RecommendRecord::model()->find("DealerID=:DealerID and ServiceID=:ServiceID", array(":DealerID" => $organID, ":ServiceID" => $id)); if (!empty($record)) { $users = Yii::app()->db->createCommand()->select("pro.truename,pro.phone")->from("tbl_user t")->join("tbl_profiles pro", "pro.user_id=t.id")->where("t.id!=:userid and t.OrganID=:userid", array(":userid" => $id))->queryAll(); } $this->render('servicerdetail', array('photo' => $photo, 'model' => $model, "main" => $main, "routine" => $routine, "diagno" => $diagno, "part" => $part, 'employs' => $users ? $users : array(), "repair" => $repair)); }