public function actionDescription() { if (!empty($_GET["slug"])) { $model = CatalogCountry::fetchBySlug(trim($_GET["slug"])); } if ($model && $model->id > 0) { $item = $model; Yii::app()->page->setInfo(array("description" => $item->name . "," . $this->description, "keyWord" => $item->name . "," . $this->keyWord)); if (!empty($item) && $item->id > 0) { Yii::app()->page->title = $item->name; $this->render('description', array("item" => $item, "tours" => CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND country_id=:id")->setParams(array(":id" => $item->id))->setOrderBy("col DESC")->setLimit(8)), "firms" => CatalogFirms::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND country_id=:id")->setParams(array(":id" => $item->id))->setOrderBy("rand()")->setLimit(12)), "otherCountry" => CatalogCountry::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("id!=:id")->setParams(array(":id" => $item->id))->setOrderBy("col DESC")->setLimit(8)), "tourCount" => CatalogTours::count(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country")->setParams(array(":country" => $item->id))), "firmCount" => CatalogFirms::count(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country")->setParams(array(":country" => $item->id))))); } else { throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу")); } } else { throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу")); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionCheckUsers() { $this->render("index"); $res = CatalogFirms::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("email!='' AND user_id=0")->setLimit(-1)->setCache(0)); $i = 0; foreach ($res as $item) { $email = ""; if (strpos($item->email, ",")) { $item->email = trim(mb_substr($item->email, 0, strpos($item->email, ","), "utf-8")); } echo $item->id . " | " . $item->name . " - " . $item->email . "<br/>"; $findUser = CatalogUsers::findByAttributes(array("email" => $item->email)); if (sizeof($findUser) == 0) { echo "Create"; $newUser = new CatalogUsers(); $newUser->name = $item->name; $newUser->email = trim($item->email); $newUser->image = $item->image; $newUser->pass = rand(100, 999); $newUser->password = md5($newUser->pass); $newUser->active = 1; $newUser->country_id = $item->country_id->id; $newUser->type_id = 1; $newUser->site = $item->www; $newUser->phone = $item->tel; if (!$newUser->save()) { print_r($newUser->getErrors()); } } else { echo "Find - " . $findUser[0]->id; $newUser = $findUser[0]; } if ($newUser->id > 0) { echo " save"; $item->user_id = $newUser->id; $item->save(); } echo "<br/>"; $i++; } }
public function actionDescription() { Yii::app()->page->setInfo(array("description" => $this->description, "keyWord" => $this->keyWord)); $id = 0; $class = $this->classModel; if (!empty($_GET["slug"])) { $model = $class::fetchBySlug(trim($_GET["slug"])); if ($model->id > 0) { $_GET["id"] = $model->id; $id = $model->id; } } if (empty($id)) { $id = (int) Yii::app()->request->getParam("id", 0); } $error = Yii::app()->request->getParam("error", ""); $tab = Yii::app()->request->getParam("tab", ""); $tabArray = array("description", "pcomments", "tours"); if (!in_array($tab, $tabArray)) { $tab = ""; } // Ошибка при не правельно ID $error = Yii::t("page", "Произошла ошибка перехода на страницу, проверьте правильно написания адреса страницы"); if (empty($id) && !empty($_GET["slug"])) { $ar = explode("-", $_GET["slug"]); $id = $ar[0]; } if ($id > 0) { $item = CatalogFirmsInfo::fetch($id); if (empty($tab)) { $activeTab = "description"; } else { $activeTab = $tab; } if ($item->id > 0) { LogHelper::save("firms", $item->id, "show"); CCModelHelper::colCounter($item); $commentModel = new CatalogFirmsCommentsAdd(); if (!empty($_POST["send_comment"])) { $activeTab = "pcomments"; $commentModel->setAttributesFromArray($_POST["CatalogFirmsCommentsAdd"]); $commentModel->firm_id = $id; if (Yii::app()->user && Yii::app()->user->getId() > 0) { $commentModel->user_id = Yii::app()->user->getId(); } $commentModel->date = time(); if ($commentModel->save()) { $item->onFirmNewComment(new CEvent($commentModel), array("subject" => $commentModel->name, "firm_name" => $item->name, "date" => date("d.m.Y H:i"), "user_name" => $commentModel->fio, "description" => $commentModel->message, "link" => SiteHelper::createUrl("/user/firms/description", array("id" => $item->id, "tab" => "pcomments")))); $commentModel = new CatalogFirmsCommentsAdd(); $commentModel->formMessage = Yii::t("tours", "Сообщение отправлено, после модерации оно будет Опубликовано."); } } Yii::app()->page->title = $item->name . " - " . Yii::t("page", "туристическое агенство") . " " . $item->country_id->name_2 . " " . $item->city_id->name; // Поля про поиско по турам $tourClass = new CatalogToursFirms(); $arrSearchFieldsTours = $tourClass->getSearchAttributes(); $this->render('description', array("item" => $item, "activeTab" => $activeTab, "commentModel" => $commentModel, "otherFirms" => CatalogFirms::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND id!=:id")->setParams(array(":id" => $item->id))->setOrderBy("col DESC")->setLimit(8)), "listGallery" => CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog=:catalog AND item_id=:items_id")->setParams(array(":catalog" => "catalog_firms", ":items_id" => $item->id))->setLimit(15)), "arrSearchFieldsTours" => $arrSearchFieldsTours)); } else { throw new CHttpException("", "К сожалению описание данного тура не найденно в базе"); } } else { throw new CHttpException("", "К сожалению описание данного тура не найденно в базе"); } }
public function run($args) { // Расчет ретинга фирмы /* * описание * Сайт, Контакты, Адрес, большой текст с описанем * если не описания то - бал * галлерея * + бал за каждую картинку * - бал если нет не одной каринки * туры * + бал за каждый тур ( если есть рейтинг тура то вмест бала сумируем его если нет то просто 10 ) * если нет не одного тура то выставляет бал 0 * акции * + бал за каждую акцию * Коментарии и отзывы * + бал за каждый комментарий */ $count = 30; $lastFirm = CatCache::fetchBySlug("index_last_firm"); if ($lastFirm->date != date("Y-m-d")) { $lastFirm->value = 0; } $list = CatalogFirms::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("id>:id")->setParams(array(":id" => $lastFirm->value))->setLimit($count)->setOrderBy("id")); foreach ($list as $item) { $id = $item->id; $rating = 0; // Проверяем описание if ($item->www) { $rating += 10; } if ($item->tel && $item->email) { $rating += 10; } if ($item->description) { $rating += 10; if (strlen($item->description) > 500) { $rating += 20; } } else { $rating -= 10; } if ($item->image) { $rating += 10; } else { $rating -= 10; } // end ( Проверяем описание ) // Галлрея $images = CatGallery::count(DBQueryParamsClass::CreateParams()->setConditions("catalog='catalog_firms' AND item_id=:id")->setParams(array(":id" => $id))); if ($images > 0) { $rating += $images * 5; } else { $rating -= 10; } // Туры $tours = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:id")->setParams(array(":id" => $id))->setLimit(-1)); foreach ($tours as $tour) { if ($tour->rating > 0) { $rating += $tour->rating; } else { $rating += 10; } } if (sizeof($tours) == 0) { $rating = 0; } // Туры $tours = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:id")->setParams(array(":id" => $id))->setLimit(-1)); foreach ($tours as $tour) { if ($tour->rating > 0) { $rating += $tour->rating; } else { $rating += 10; } } if (sizeof($tours) == 0) { $rating = 0; } // Акции $sales = CatalogFirmsItems::count(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:id")->setParams(array(":id" => $id))); if ($sales > 0) { $rating += $sales * 5; } // Коментарии $comments = CatalogFirmsComments::count(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:id")->setParams(array(":id" => $id))); if ($comments > 0) { $rating += $comments * 5; } $item->rating = $rating; if (!$item->save()) { print_r($item->getErrors()); } } if ($item->id > 0) { $lastFirm->value = $item->id; $lastFirm->date = date("Y-m-d", mktime(date("h") + 1, 0, 0, date("m"), date("d"), date("Y"))); //echo $lastFirm->date."*".mktime( date("h")+1,0,0,date("m"),date("d"), date("Y") ); if (!$lastFirm->save()) { print_r($lastFirm->getErrors()); } } //echo "*"; }