public static function toBase($company_id = false) { if (isset($_POST['Contractor'])) { if (!$_POST['Contractor']['id']) { unset($_POST['Contractor']['id']); } if (!isset($_POST['Contractor']['company_id']) && $company_id) { $_POST['Contractor']['company_id'] = $company_id; } $arContractorCity = $_POST['Contractor']['city']; unset($_POST['Contractor']['city']); $contractor_id = SaveData::model('Contractor', $_POST['Contractor']); $logo_name = UploadFile::save('Contractor', $contractor_id, 'contractor-logo'); $tContractor = Contractor::model()->findByPk($contractor_id); $tContractor->logo = $logo_name; $tContractor->update(); /* сохраняем города */ if ($arContractorCity) { foreach ($arContractorCity as $city_id) { $arLink = array('city_id' => $city_id, 'contractor_id' => $contractor_id); $link_id = SaveData::model('LinkCityContractor', $arLink); } } return $contractor_id; } return false; }
public static function fromContractor($id) { $contractor = Contractor::model()->findByPk($id); if ($contractor) { return self::$objects[$contractor->category_id]; } else { return false; } }
public function actionDelete($id) { $service = Service::model()->findAll('contractor_id=' . $id); if ($service) { foreach ($service as $serv) { WrapServTransport::Del($serv->id); ServCulture::model()->deleteAllByAttributes(array('service_id' => $serv->id)); $food = ServFood::model()->findAll('service_id=' . $serv->id); if ($food) { foreach ($food as $mFood) { LinkFoodServ::model()->deleteAllByAttributes(array('serv_food_id' => $mFood->id)); } } ServFood::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServIntensiv::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServOther::model()->deleteAllByAttributes(array('service_id' => $serv->id)); $personal = ServPersonal::model()->findAll('service_id=' . $serv->id); if ($personal) { foreach ($personal as $mPers) { LinkPersonalLanguage::model()->deleteAllByAttributes(array('serv_personal_id' => $mPers->id)); } } ServPersonal::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServPlatform::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServProgram::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServTicket::model()->deleteAllByAttributes(array('service_id' => $serv->id)); $live = ServLive::model()->findAll('service_id=' . $serv->id); if ($live) { foreach ($live as $mLive) { ServLiveRoom::model()->deleteAllByAttributes(array('serv_live_id' => $mLive->id)); } } ServLive::model()->deleteAllByAttributes(array('service_id' => $serv->id)); Photo::model()->deleteAllByAttributes(array('service_id' => $serv->id)); } } Service::model()->deleteAllByAttributes(array('contractor_id' => $id)); Comment::model()->deleteAllByAttributes(array('contractor_id' => $id)); LinkCityContractor::model()->deleteAllByAttributes(array('contractor_id' => $id)); Contractor::model()->deleteByPk($id); echo "ok"; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Contractor the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Contractor::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php $cont = Contractor::model()->findByPk($contractor); ?> <div class="panel panel-default comment service"> <div class="panel-heading"> <div class="row"> <div class="col-md-36 "> <label class="subCatHeader">Комментарий</label> <!-- <div class="pull-right butBlockService"> <a class="btn btn-default btn-lg windowControl copyService"><span class="glyphicon glyphicon-plus "></span></a> <a class="btn btn-default btn-lg windowControl"><span class="glyphicon glyphicon-remove"></span></a> </div> --> </div> </div> </div> <div class="panel-body" id="windowComment">