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;
         } else {
             $arrId = explode("-", $_GET["slug"]);
             if (sizeof($arrId) > 0) {
                 $id = (int) $arrId[0];
             }
         }
     }
     $error = Yii::t("page", "Произошла ошибка перехода на страницу, проверьте правильно написания адреса страницы");
     if ($id > 0) {
         $item = CatalogTours::fetch($id);
         if ($item->id > 0) {
             LogHelper::saveCatLogTours($item->id);
             CCModelHelper::colCounter($item);
             // Картинки тура
             $images = ImageHelper::getImages($item);
             Yii::app()->page->title = $item->name . ", тур " . $item->category_id->name . ", " . $item->country_id->name;
             $this->render('description', array("item" => $item, "images" => $images, "otherTours" => CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND country_id=:country_id AND id!=:id AND firm_id!=:firm_id")->setParams(array(":country_id" => $item->country_id->id, ":id" => $item->id, ":firm_id" => $item->firm_id->id))->setOrderBy("col DESC")->setLimit(6)), "firmsTours" => CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND firm_id=:firm_id AND id!=:id")->setParams(array(":firm_id" => $item->firm_id->id, ":id" => $item->id))->setOrderBy("col DESC")->setLimit(6)), "tourCount" => CatalogTours::count(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country")->setParams(array(":country" => $item->country_id->id))), "firmCount" => CatalogFirms::count(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country")->setParams(array(":country" => $item->country_id->id)))));
         } else {
             throw new CHttpException("", $error);
         }
     } else {
         throw new CHttpException("", $error);
     }
 }
 public function actionDescription($gallError = "")
 {
     $this->firmId = (int) Yii::app()->request->getParam("fid", 0);
     $id = (int) Yii::app()->request->getParam("id", 0);
     // Если не указан ID фирмы, то берем ID из описания тура
     if ($id > 0 && $this->firmId == 0) {
         $tourModel = CatalogTours::fetch($id);
         if ($tourModel->id > 0 && $tourModel->firm_id && $tourModel->firm_id->id > 0) {
             $this->firmId = $tourModel->firm_id->id;
         }
     }
     if ($this->firmId == 0) {
         die("id==0");
         $this->redirect(SiteHelper::createUrl("/user/firms"));
     }
     $firmModel = CatalogFirms::fetch($this->firmId);
     if ($firmModel->id == 0) {
         die("id==not correct");
         $this->redirect(SiteHelper::createUrl("/user/firms"));
     }
     parent::init();
     $this->addModel = "CatalogToursAdd";
     $this->tableName = "catalog_tours";
     $this->name = Yii::t("user", "туры");
     $_POST["CatalogToursAdd"]["firm_id"] = $this->firmId;
     $_POST["CatalogToursAdd"]["user_id"] = Yii::app()->user->getId();
     parent::actionDescription();
 }
 public function actionTest()
 {
     // if( $this->beginCache( "ключ" , array('duration'=>3600) ) )
     // {$this->endCache();}
     $topShow = 2005;
     $topTorShow = 4742;
     $getKey = Yii::app()->request->getParam("key", "");
     $email = Yii::app()->request->getParam("email", "");
     //echo md5( substr( md5( $email.$this->securityKey ), 0, 15) );
     if ($getKey == md5(substr(md5($email . $this->securityKey), 0, 15))) {
         $cout = "";
         $list = CatLogFirms::sql("SELECT l.firm_id as `id`, l.action_show as `show`, l.date_from as `date`, f.name as fname, f.id as fid FROM cat_log_firms l, catalog_firms f WHERE l.firm_id=f.id AND f.email='" . $email . "'");
         if (!empty($list[0]["fid"])) {
             $tours = CatLogFirms::sql("SELECT sum(l.action_show) as tshow, sum( l.action_contact ) as tcont FROM cat_log_tours l WHERE l.tour_id in ( SELECT id FROM catalog_tours WHERE firm_id='" . $list[0]["fid"] . "')");
             $item = $list[0];
             $tour = $tours[0];
             $date = date("d.m.Y", $item["date"]);
             // Ессли вообще нету просмотром либо фирмы либо туров
             $nashBron = $tour["tcont"] + $tour["tshow"] / 5;
             if ($nashBron > 300) {
                 $nashBron = round($nashBron / 15, 0);
             } else {
                 $nashBron = round($nashBron / 10, 0);
             }
             $cout .= "<div style=\"background: #e4ddcd;padding: 0px 10px 10px 10px;\">\n                        <table width=\"590\" cellpadding=\"0\" cellspacing=\"0\" style=\"line-height: 18px;color:#000;font-size:14px;\">\n                        <tr style=\"overflow:hidden;text-align: justify;line-height: 16px;\">\n                        <td colspan=\"2\" style=\"line-height: 18px;font-size: 14px;font-family: times New Roman;padding:0px;\">\n                                    <h2>Статистика посещения страницы фирмы \"" . $item["fname"] . "\" на портале World-Travel.uz</h2>\n                                    <table>\n                        <tr>\n                            <th style='text-align:left'>Период статистики:</th>\n                            <td>от " . $date . " до " . date("d.m.Y") . "</td>\n                        </tr>\n                        <tr>\n                            <th style='text-align:left'>Просмотров страницы профиля компании:</th>\n                            <td>" . ($item["show"] > 0 ? $item["show"] : 0) . "</td>\n                        </tr>\n                         <tr>\n                            <th style='text-align:left'>Сумма просмотров всех Ваших туров:</th>\n                            <td>" . ($tour["tshow"] ? $tour["tshow"] : 0) . "</td>\n                        </tr>\n                         <tr>\n                            <th style='text-align:left'>Сумма нажатия кнопки бронирования, на всех турах:</th>\n                            <td>" . $nashBron . "</td>\n                        </tr>\n                    </table>";
             if ($tour["tcont"] < $tour["tshow"] / 2) {
                 $cout .= "<p>У вас очень низкий процент нажатия на кнопку бронирования Ваших туров.</p>";
             }
             $cout .= "</td></tr></table></div>";
             $cout .= "<div style=\"background: url(http://subscribes.uz/f/mails/world-travel/block_bg.jpg) no-repeat center;height:31px;\"></div>";
             if (empty($tour["tshow"]) || $tour["tshow"] == 0) {
                 $countTours = CatalogTours::findByAttributes(array("firm_id" => $list[0]["fid"]));
                 if (sizeof($countTours) == 0) {
                     $cout .= "<div style=\"background: #e4ddcd;padding: 0px 10px 10px 10px;\">\n                        <table width=\"590\" cellpadding=\"0\" cellspacing=\"0\" style=\"line-height: 18px;color:#000;font-size:14px;\">\n                        <tr style=\"overflow:hidden;text-align: justify;line-height: 16px;\">\n                        <td colspan=\"2\" style=\"line-height: 18px;font-size: 14px;font-family: times New Roman;padding:0px;\">\n                            <h2>В Вашей компании нету туров?</h2>\n                            <p>Вы не добавили не одного тура, если вы действительно хотите привлечь внимание к своей компании, туры неотъемлемая часть.<br/>Возможно у Вас возникли какие-то проблемы при добавлении? Персональный консультат поможет вам решить все проблемы.</p></td></tr></table></div>";
                     $cout .= "<div style=\"background: url(http://subscribes.uz/f/mails/world-travel/block_bg.jpg) no-repeat center;height:31px;\"></div>";
                 }
             }
             // Если низки процент бронирования
             // Если низки процент бронирования
             if ($tour["tshow"] < $topTorShow || $item["show"] < $topShow) {
                 $cout .= "<div style=\"background: #e4ddcd;padding: 0px 10px 10px 10px;\">\n                        <table width=\"590\" cellpadding=\"0\" cellspacing=\"0\" style=\"line-height: 18px;color:#000;font-size:14px;\">\n                        <tr style=\"overflow:hidden;text-align: justify;line-height: 16px;\">\n                        <td colspan=\"2\" style=\"line-height: 18px;font-size: 14px;font-family: times New Roman;padding:0px;\">\n                            <h2>Чем вы хуже своих конкурентов?</h2>\n                            <p>Статистика посещаемости одного из Ваших конкурентов (мы не называем название компании):<ul>";
                 if ($tour["tshow"] < $topTorShow) {
                     $cout .= "<li>Сумма просмотров всех туров конкурента <b>" . $topTorShow . "</b> в месяц, а у Вас <b>" . ($tour["tshow"] > 0 ? $tour["tshow"] : 0) . "</b> просмотров</li>";
                 }
                 if ($item["show"] < $topShow) {
                     $cout .= "<li>Просмотр страницы компании конкурента <b>" . $topShow . "</b> в месяц, а у Вас <b>" . ($item["show"] > 0 ? $item["show"] : 0) . "</b> просмотров</li>";
                 }
                 $cout .= "</ul></p></td></tr></table></div>";
                 $cout .= "<div style=\"background: url(http://subscribes.uz/f/mails/world-travel/block_bg.jpg) no-repeat center;height:31px;\"></div>";
             }
             echo $cout;
         }
     }
 }
 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", "Ошибка перехода на страницу"));
     }
 }
 public function actionIndex()
 {
     $page = (int) Yii::app()->request->getParam("p", 1);
     $this->layout = '//layouts/main-landing';
     if (!empty($_GET["country"])) {
         $model = CatalogCountry::fetchBySlug(trim($_GET["country"]));
     }
     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('index', array("item" => $item, "page" => $page, "tours" => CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND country_id=:id")->setParams(array(":id" => $item->id))->setOrderBy("rating DESC")->setLimit(12)), "gallerySlide" => CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog='catalog_country' AND type='slide-gallery' AND item_id=:id")->setParams(array(":id" => $item->id))->setOrderBy("pos")->setLimit(-1)), "gallery" => CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog='catalog_country' AND type='' AND item_id=:id")->setParams(array(":id" => $item->id))->setOrderBy("pos")->setLimit(9)), "info" => CatalogInfo::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("category_id=(SELECT id FROM catalog_info_category WHERE slug=:slug LIMIT 1)")->setParams(array(":slug" => $item->slug))), "monuments" => CatalogMonuments::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("country_id=:id")->setParams(array(":id" => $item->id)))));
         } else {
             throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу"));
         }
     } else {
         throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу"));
     }
 }
 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 "*";
 }
 public function run($args)
 {
     // Расчет ретинга фирмы
     /*
                     + Заполленность описания 40
                         если не заполнено - 30
            + Заполленность ПРОГРАММЫ 40
                         если не заполнено - 30
            + Заполленность ЦЕНЫ 80
                         если не заполнено - 30
            + Заполенность ЦЕНЫ И ВАЛЮТЫ 100
                         - если не заполнена цена - 100
                         не учитывать если не заполнено валюта
            + Заполенность ВКЛЮЧННО 40
                         если не заполнено - 30
            + Заполенность НЕ ВКЛЮЧННО 20
                     + Заполенность ВНИМАНИЕ 20
                     + Заполенность ДЛИТЕЛЬНОСТЬ 40
                         если не заполнено - 30
            + Галлерея + 10 за каждую, но учитывать только 5
                         Если нет не одной то -50
                         Если меньше 3 то -20
     */
     $count = 100;
     $lastFirm = CatCache::fetchBySlug("index_last_tours");
     if ($lastFirm->date != date("Y-m-d")) {
         $lastFirm->value = 0;
     }
     $list = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("id>:id")->setParams(array(":id" => $lastFirm->value))->setLimit($count));
     foreach ($list as $item) {
         $id = $item->id;
         $rating = 0;
         // Проверяем описание
         if ((int) $item->price > 0) {
             $rating += 100;
             if ($item->currency_id->id > 0) {
                 $rating += 50;
             }
         } else {
             $rating -= 50;
         }
         if ($item->description) {
             if (strlen(trim(strip_tags($item->description))) > 200) {
                 $rating += 100;
             }
         } else {
             $rating -= 30;
         }
         if ($item->program) {
             if (strlen(trim(strip_tags($item->program))) > 200) {
                 $rating += 40;
             }
         }
         //else $rating -= 30;
         if ($item->prices) {
             if (strlen(trim(strip_tags($item->prices))) > 100) {
                 $rating += 40;
             }
         }
         //else $rating -= 30;
         if ($item->included) {
             if (strlen(trim(strip_tags($item->included))) > 100) {
                 $rating += 40;
             }
         }
         //else $rating -= 30;
         if ($item->duration) {
             $rating += 40;
         }
         //else $rating -= 30;
         if ($item->not_included) {
             $rating += 20;
         }
         if ($item->attention) {
             $rating += 20;
         }
         // Галлерея
         $images = CatGallery::count(DBQueryParamsClass::CreateParams()->setConditions("catalog='catalog_tours' AND item_id=:id")->setParams(array(":id" => $id)));
         if ($images > 0) {
             if (sizeof($images) > 3) {
                 if (sizeof($images) > 5) {
                     $rating += 80;
                 } else {
                     $rating += sizeof($images) * 10;
                 }
             } else {
                 $rating -= 30;
             }
         }
         $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());
             }
         }
     }
 }
 static function onAddFirm($eventArray)
 {
     if (empty($eventArray["event"])) {
         return;
     }
     $firm = $eventArray["event"]->sender;
     $params = $eventArray["params"];
     if ($firm->id > 0) {
         /*
                Типы рекомендаций:
                  - по заполнению
                  -  - заполненные поля
                  -  - по объему заполненности полей
                  - -  Обязательно по цене`
                  -  - наличие картинок
         
                  -  добавьте также туры для других стран ( а вы знали что самым популярным местом для туризма в Малайзию )
         */
         $itemParam = array();
         $itemParam["recomFields"] = array("name", "description");
         $itemParam["recomSizeFields"] = array("description" => 500);
         $itemParam["image_count"] = 0;
         if (!empty($params["status"]) && $params["status"] == "reminder") {
             $itemParam["check_visible"] = true;
         }
         $reccomen = self::objectCheck($firm, $itemParam);
         $reccomenAdd = "";
         // Если нет рекомендации то написать что они могут добавить тур акцию и т.д.
         if (empty($reccomen) || strlen($reccomen) < 200) {
             $countTours = CatalogTours::count(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:fid")->setParams(array(":fid" => $firm->id)));
             $countFirmItems = CatalogFirmsItems::count(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:fid")->setParams(array(":fid" => $firm->id)));
             $countFirmService = CatalogFirmsService::count(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:fid")->setParams(array(":fid" => $firm->id)));
             $countFirmBanners = CatalogFirmsBanners::count(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:fid")->setParams(array(":fid" => $firm->id)));
             $reccomenAdd = "<br/><h2 style='text-align: center'>Вы можете добавить услуги Вашей компании</h2>";
             $reccomenAdd .= "<ul>";
             if ($countTours == 0) {
                 $reccomenAdd .= "<li>Добавляем ТУРЫ фирмы</li>";
             }
             if ($countFirmItems == 0) {
                 $reccomenAdd .= "<li>Добавляем \"АКЦИИ\" и \"СКИДКИ\" компании</li>";
             }
             if ($countFirmService == 0) {
                 $reccomenAdd .= "<li>Добавляем \"ДОПОЛНИТЕЛЬНЫЕ УСЛУГИ\" компании</li>";
             }
             if ($countFirmBanners == 0) {
                 $reccomenAdd .= "<li>Добавляем \"БЕСПЛАТНЫЙ БАННЕР\" компании</li>";
             }
             $reccomenAdd .= "\n                                </ul>\n                                <br/>\n                                <a href=\"" . SiteHelper::createUrl("/site/addFirm") . "\">Инструкция: \"Как правильно добавить фирму на сайт\".</a>";
         }
         if (empty($params["status"])) {
             $subject = !empty($reccomen) ? "Ваша фирма - " . $firm->name . " успешно сохранена, но ..." : "Поздравляем Ваша фирма - " . $firm->name . " успешно сохранена";
             $message = "<h2 style=\"margin: 5px 0px 15px 0px;text-align: center\">Ваша фирма - <b>" . $firm->name . "</b> успешно сохранена</h2>";
             $message .= !empty($reccomen) ? "Ваша фирма - <b>" . $firm->name . "</b> успешно сохранена, но мы советуем Вам сделать ее описание лучше. " : "Поздравляем Ваша фирма - <b>" . $firm->name . "</b> успешно сохранена";
         } else {
             if ($params["status"] == "reminder") {
                 $subject = "Объявление Вашей фирмы - " . $firm->name . " можно сделать лучше";
                 $message = "<h2 style=\"margin: 5px 0px 15px 0px;text-align: center\">Напоминаем, что объявление Вашей фирмы - " . $firm->name . " можно сделать лучше</h2>";
             }
         }
         $message .= "<br/>Для редактирования описания фирмы, необходимо перейти в раздел <a href=\"" . SiteHelper::createUrl("/user/firms") . "\">Мои фирмы</a>.";
         if (!empty($reccomen)) {
             $message .= "<br/><br/>Мы проверили введенные Вам данные и подготовили для Вас рекомендации по улучшению Вашей фирмы." . $reccomen;
         }
         if (!empty($reccomenAdd)) {
             $message .= "<br/>" . $reccomenAdd;
         }
         // Если это напоминание и нет рекомендаци то ничего не отправляем
         if (empty($params["status"]) || !empty($reccomen) || !empty($reccomenAdd)) {
             $res = SubscribesUzHelper::sendEmail($firm->user_id->name, $firm->user_id->email, $subject, "<div style=\"background: #e4ddcd;padding: 0px 10px 10px 10px;overflow: hidden;\">" . $message . "<br/></div>", 2, 1);
         }
     }
 }
Exemple #9
0
        </div>
    <?php 
    }
    ?>
    <?php 
    if (sizeof($otherCountry) > 0) {
        ?>
        <h2><?php 
        echo Yii::t("page", "Другие странны");
        ?>
</h2>
        <div class="hr">&nbsp;</div>
        <div class="ITBlock ITBFirms ITBOthCountry">
            <?php 
        foreach ($otherCountry as $CItem) {
            $tourCounts = CatalogTours::count(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country_id")->setParams(array(":country_id" => $CItem->id)));
            ?>
                <div class="IBItem">
                    <div class="IBIImage">
                        <a href="<?php 
            echo SiteHelper::createUrl("/country/description") . "/" . $CItem->slug;
            ?>
.html" title="<?php 
            echo $CItem->name;
            ?>
 - <?php 
            echo Yii::t("page", "Туристическая странна");
            ?>
"><img src="<?php 
            echo ImageHelper::getImage($CItem->image, 2);
            ?>
Exemple #10
0
            <li><b><?php 
    echo Yii::t("page", "На сайте");
    ?>
:</b></li>
            <li><?php 
    echo Yii::t("page", "туристических стран");
    ?>
: <u><?php 
    echo CatalogCountry::count();
    ?>
</u></li>
            <li><?php 
    echo Yii::t("page", "туров");
    ?>
: <u><?php 
    echo CatalogTours::count();
    ?>
</u></li>
            <li><?php 
    echo Yii::t("page", "курортов");
    ?>
: <u><?php 
    echo CatalogKurorts::count();
    ?>
</u></li>
            <li><?php 
    echo Yii::t("page", "гостиниц");
    ?>
: <u><?php 
    echo CatalogHotels::count();
    ?>
Exemple #11
0
 public function run()
 {
     $this->render("firm", array('tour' => $this->item, 'tourCounts' => CatalogTours::count(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id")->setParams(array(":firm_id" => $this->item->id)))));
 }
 public function actionShow($idIn = 0, $locatIn = "", $return = FALSE)
 {
     $id = (int) Yii::app()->request->getParam("id", 0);
     if ($id == 0 && $idIn > 0) {
         $id = $idIn;
     }
     $locat = Yii::app()->request->getParam("location", "");
     if (empty($locat) && !empty($locatIn)) {
         $locat = $locatIn;
     }
     /*
     График:
         По странам ( сортировка по цене ) 31
         По категориям ( сортировка по цене ) 30
         По странам ( сортировка по просмотрам)
         По категориям ( сортировка по просмотрам )
     
        Определям кандидата по очереди сначала города потом категории
            Выбираем по сортировке первую страну
            Проверяем по очередньсти
     
        Формируем письмо
            Заголовок ( зависит от того по стране или категории + от сортировки )
            указываем группу подписциков
            указываем группу рассылоку
     
        И полетели
     */
     $cout = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
         <meta http-equiv="Cache-Control" content="public"/>
         <meta http-equiv="Cache-Control" content="max-age=86400, must-revalidate"/>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     </head>
     <body>';
     $logTable = SubscribeTable::fetch($id);
     if ($logTable->id > 0) {
         if ($locat == "uzb" && $logTable->country_id->id == 1) {
             return "";
         }
         $countryId = 0;
         $categoryId = 0;
         if ($logTable->country_id->id > 0) {
             $countryId = $logTable->country_id->id;
             $countryModel = CatalogCountry::fetch($countryId);
         }
         if ($logTable->category_id->id > 0) {
             $categoryId = $logTable->category_id->id;
             $categoryModel = CatalogToursCategory::fetch($categoryId);
         }
         if ($countryId > 0 || $categoryId > 0) {
             $info = [];
             if ($countryId > 0) {
                 $toursMinPrice = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("country_id=:cid AND price>0 AND active=1")->setParams([":cid" => $countryModel->id])->setOrderBy("price")->setLimit(1)->setCache(0));
                 $tours = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("country_id=:cid AND id !=:id AND active=1")->setParams([":cid" => $countryModel->id, ":id" => $toursMinPrice[0]->id])->setLimit(7)->setOrderBy("rating DESC, price"));
                 $tours[] = $toursMinPrice[0];
                 $info = CatalogInfo::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("country_id=:cid")->setParams([":cid" => $countryModel->id])->setLimit(4)->setOrderBy("id DESC"));
                 $subject = $countryModel->title . ", от " . $tours[sizeof($tours) - 1]->price . ($tours[sizeof($tours) - 1]->currency_id->id ? $tours[sizeof($tours) - 1]->currency_id->title : "\$");
             } else {
                 $params = [":cid" => $categoryModel->id];
                 $condition = "category_id=:cid";
                 if ($locat == "uzb") {
                     echo $locat . "==uzb<br/>";
                     $params = array_merge($params, [":country" => 1]);
                     $condition .= " AND country_id!=:country";
                 } else {
                     $params = array_merge($params, [":country" => 1]);
                     $condition .= " AND country_id=:country";
                 }
                 echo $condition . "*";
                 $toursMinPrice = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions($condition)->setParams($params)->setOrderBy("price")->setLimit(1)->setCache(0));
                 $tours = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions($condition . " AND id !=:id")->setParams(array_merge($params, [":id" => $toursMinPrice[0]->id]))->setLimit(7)->setOrderBy("rating DESC, price"));
                 $tours[] = $toursMinPrice[0];
                 //$info = CatalogInfo::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("country_id=:cid")->setParams([":cid" => $categoryModel->id])->setLimit(4)->setOrderBy("id DESC"));
                 if ($tours[sizeof($tours) - 1]->price > 0) {
                     $subject = "Тур - " . $categoryModel->name . ", от " . $tours[sizeof($tours) - 1]->price . ($tours[sizeof($tours) - 1]->currency_id->id ? $tours[sizeof($tours) - 1]->currency_id->title : "\$");
                 } else {
                     $subject = "Тур - " . $categoryModel->name;
                 }
             }
             $message = "Предлагаем Вашему вниманию интересную подборку с нашего портала <a href=\"http://www.world-travel.uz\">World-Travel.uz</a>.<br/><br/><h1>" . $subject . "</h1><br/><table>";
             $n = 0;
             $reserveNum = 0;
             $reserveList = [];
             foreach ($tours as $tour) {
                 if ($tour->id == 0) {
                     continue;
                 }
                 $image = ImageHelper::getImages($tour, 1);
                 // Если картинки для тура нету, то берем её из резерва catalog_image_reserve
                 if (sizeof($image) == 0) {
                     if (sizeof($reserveList) == 0) {
                         $reserveList = CatalogImageReserve::findByAttributes(["country_id" => $tour->country_id->id]);
                     }
                     if (sizeof($reserveList) > 0) {
                         $new = new CatGallery();
                         if (!empty($reserveList[$reserveNum])) {
                             $new->image = $reserveList[$reserveNum]->image;
                         } else {
                             if ($tour->country_id->banner) {
                                 $new->image = $tour->country_id->banner;
                             } else {
                                 $new->image = $tour->country_id->image;
                             }
                         }
                         $image[] = $new;
                         $reserveNum++;
                     }
                 }
                 if ($n == 0 || $n == 2 || $n == 4 || $n == 6) {
                     $message .= "<tr>";
                 }
                 $message .= "<td style=\"width:50%;text-align:center;vertical-align: top;background-color: #EEE9DD;padding: 10px;border: 1px solid #fff;\">\n                            <table width=\"100%\">\n                                <tr>\n                                    <td style=\"background:#E4DDCD;font-size:13px;text-align: right;padding-right: 5px;vertical-align: middle;\"><b>" . $tour->name . "</b></td>";
                 if ($tour->price > 0) {
                     $message .= "<td style=\"background:#E4DDCD;vertical-align: top;line-height: 14px;text-align: center;\"><span style=\"font-size:10px;\">от</span><br/><b style=\"color:#ff4f00;font-size:24px;\"> " . $tour->price . ($tour->currency_id->id ? $tour->currency_id->title : "\$") . "</b><br/></td>";
                 }
                 $message .= "</tr>\n                            </table>";
                 if (sizeof($image) > 0) {
                     $message .= "<div style=\"max-height: 134px;overflow: hidden;\"><img src=\"" . (SiteHelper::createUrl("/") . ImageHelper::getImage($image[0]->image, 2)) . "\" style=\"max-width:200px\"/></div>";
                 }
                 //if( $tour->included )$message .= "<td>Включенно: ".$tour->included."</td></tr>";
                 if ($tour->duration) {
                     $message .= $tour->duration . "<br/>";
                 }
                 if ($tour->category_id->id > 0) {
                     $message .= "Тур - " . $tour->category_id->name2 . "<br/>";
                 }
                 $message .= "<div><a style=\"margin-top: 11px;background:#ff4f00;color:#fff;font-weight: bold;display: inline-block;padding: 5px 10px;border-radius: 4px;\" href=\"" . SiteHelper::createUrl("/tours/description") . "/" . $tour->slug . ".html\">Заказать</a></div></td>";
                 //
                 if ($n == 1 || $n == 3 || $n == 5 || $n == 7) {
                     $message .= "</tr>";
                 }
                 $n++;
             }
             $message .= '</table></div><br/>';
             if (sizeof($info) > 0) {
                 $message .= '<div style="background: #e4ddcd;padding: 0px 10px 10px 10px;overflow: hidden;"><table>';
                 foreach ($info as $item) {
                     $message .= "<tr><td colspan=\"2\"><h3 style=\"margin:10px 0px 5px 0px;\">" . $item->name . "</h3></td></tr>\n                                     <tr>\n                                        <td colspan=\"2\" style=\"border-bottom:1px solid #F4F1EA;padding-bottom:10px;\">\n                                            <table width=\"100%\">\n                                                <tr>\n                                                    <td><img src=\"" . SiteHelper::createUrl("/") . ImageHelper::getImage($item->image, 2) . "\" style=\"padding-right: 10px;\" alt=\"" . $item->name . "\" /></td>\n                                                    <td style=\"text-align: justify;vertical-align:top\">" . SiteHelper::getSubTextOnWorld($item->description, 350) . "<br/><div align=\"right\"><a href=\"" . SiteHelper::createUrl("/touristInfo/description") . $item->slug . ".html\">читайте подробнее >>></a></div></td>\n                                                </tr>\n                                            </table>\n                                        </td>\n                                     </tr>";
                     //
                 }
                 $message .= "</table></div>";
             }
             $cout .= $message . "</body></html>";
             //if( SubscribesUzHelper::sendEmails( array( 7, 35, 41 ), $subject, $message, 3 ) )echo "Ура отправил";
             //                                                                        else echo "Что-то пошло не так";
         }
     }
     if ($return) {
         return $cout;
     } else {
         echo $cout;
     }
 }
Exemple #13
0
    ?>

    <div id="CIHeader" class="overflowHidden">
        <?php 
    if (Yii::app()->controller->getId() == "tours") {
        ?>
            <div id="CIFind" class="panel panel-success panel-open">
                <div class="panel-heading">ИСКАТЬ ТУРЫ ПО СТРАННАМ&nbsp;<img src="themes/classic/images/menu_bg3.png" /></div>
                <div class="panel-body panel-display-block">
                    <?php 
        if ($this->beginCache("tours_country_" . Yii::app()->getLanguage(), array('duration' => 3600))) {
            ?>
                        <ul class="TFCountry">
                            <?php 
            foreach (CatalogCountry::fetchAll(DBQueryParamsClass::CreateParams()->setOrderBy("name")->setLimit(-1)) as $item) {
                $count = CatalogTours::count(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country")->setParams(array(":country" => $item->id))->setLimit(-1));
                ?>
                                <li><img src="<?php 
                echo $item->flag;
                ?>
"><a href="<?php 
                echo SiteHelper::createUrl("/tours/country") . "/" . $item->slug;
                ?>
.html" title="<?php 
                echo Yii::t("page", "туры");
                ?>
 <?php 
                echo $item->name_2;
                ?>
"><?php 
                echo $item->name;
Exemple #14
0
                </div>
                <div class="overflowHidden">
                    <?php 
    echo $line["tour_count"];
    ?>
 предложений
                </div>
            </div>
        <?php 
}
?>
    </div>
    <div class="ListTours2">
        <h2>Лучшие туры</h2>
        <?php 
foreach (CatalogTours::sql("SELECT t.*, g.image as image2 FROM catalog_tours t, cat_gallery g WHERE g.catalog='catalog_tours' AND g.item_id = t.id GROUP BY country_id ORDER BY t.rating DESC LIMIT 10") as $item) {
    ?>
            <div class="LTItem2">
                <div class="LTHover2"><a href="<?php 
    echo SiteHelper::createUrl("/tours/description") . "/" . $item["slug"] . ".html";
    ?>
" title="<?php 
    echo $item["name"];
    ?>
"><?php 
    echo $item["name"];
    ?>
</a></div>
                <div class="LTImag2"><a href="<?php 
    echo SiteHelper::createUrl("/tours/description") . "/" . $item["slug"] . ".html";
    ?>
Exemple #15
0
<?php

list($arr) = CatalogTours::sql("SELECT sum(col) as sum_ FROM catalog_tours WHERE firm_id='" . $item->id . "'");
$countTour = $arr["sum_"] > 0 ? $arr["sum_"] : 0;
list($arr) = CatalogTours::sql("SELECT sum(col) as sum_ FROM catalog_firms_banners WHERE firm_id='" . $item->id . "'");
$countBanners = $arr["sum_"] > 0 ? $arr["sum_"] : 0;
$listBanners = CatalogFirmsBanners::findByAttributes(array("firm_id" => $item->id));
?>
<h2><?php 
echo Yii::t("counter_page", "Статистика посещаемости");
?>
</h2>
<?php 
echo SiteHelper::getAnimateText("tekstovka-dlya-stranicy-kabinet-statistika");
?>
<table align="center">
    <tr>
        <th><?php 
echo Yii::t("counter_page", "Количество просмотров страниц о компании");
?>
: </th>
        <td><?php 
echo $item->col;
?>
</td>
    </tr>
    <tr>
        <th><?php 
echo Yii::t("counter_page", "Общее количество просмотров туров компании");
?>
:</th>
Exemple #16
0
<div id="innerPage">
<?php 
$this->widget('addressLineWidget', array('links' => array(Yii::t("user", "мои фирмы") => SiteHelper::createUrl("/user/firms"), Yii::t("page", "Описание"))));
$listComments = CatalogFirmsComments::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id")->setParams(array(":firm_id" => $item->id))->setOrderBy("id DESC")->setLimit(50)->setCache(0));
$listService = CatalogFirmsService::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id")->setParams(array(":firm_id" => $item->id))->setLimit(50)->setCache(0));
$listItems = CatalogFirmsItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id")->setParams(array(":firm_id" => $item->id))->setLimit(50)->setCache(0));
$listBanners = CatalogFirmsBanners::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id")->setParams(array(":firm_id" => $item->id))->setLimit(50)->setCache(0));
$listTours = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id")->setParams(array(":firm_id" => $item->id))->setLimit(50)->setCache(0));
$tab = Yii::app()->request->getParam("tab", "description");
$tabArray = array("description", "ptours", "items", "service", "reclame", "pcomments", "counter");
if (!in_array($tab, $tabArray)) {
    $tab = "description";
}
?>
<div class="sovetBlock"><a href="<?php 
echo SiteHelper::createUrl("/site/addFirm");
?>
" title="<?php 
echo Yii::t("user_firm", "Как правильно добавить фирму?");
?>
"><?php 
echo Yii::t("user_firm", "Как правильно добавить фирму?");
?>
</a></div>
<h1><font><?php 
echo Yii::t("user_firm", "Описание туристического агенства");
?>
</font> <?php 
echo $item->id > 0 ? " - " . $item->name : "";
?>
</h1>
Exemple #17
0
    }
    $sql = "SELECT count(id) as count_ FROM catalog_tours WHERE active=1";
    if ($item->category_id->id > 0) {
        $sql .= " AND category_id='" . $item->category_id->id . "'";
    }
    $worldCountArr = CatalogTours::sql($sql . " AND country_id='1' ");
    if (sizeof($worldCountArr) > 0) {
        $worldCount = $worldCountArr[0]["count_"];
    }
    if ($item->country_id->id > 1) {
        $uzCountArr = CatalogTours::sql($sql . " AND country_id='" . $item->country_id->id . "'");
        if (sizeof($uzCountArr) > 0) {
            $uzCount = $uzCountArr[0]["count_"];
        }
    } else {
        $uzCountArr = CatalogTours::sql($sql . " AND country_id!=1 ");
        if (sizeof($uzCountArr) > 0) {
            $uzCount = $uzCountArr[0]["count_"];
        }
    }
    ?>
    <tr>
        <td class="fieldID"><?php 
    echo $item->id;
    ?>
</td>
        <td><?php 
    echo $item->name;
    ?>
</td>
        <td><?php 
 public function fieldType()
 {
     return array_merge(parent::fieldType(), array("price" => "integer", "hot" => "checkbox", "is_newyear" => "checkbox"));
 }
Exemple #19
0
} else {
    $countryModel = new CatalogCountry();
}
$category = Yii::app()->request->getParam("category", "");
if (!empty($category)) {
    $categoryModel = CatalogToursCategory::fetchBySlug($category);
} else {
    $categoryModel = new CatalogToursCategory();
}
if ($countryModel->id > 0) {
    $toursCondition .= " AND country_id='" . $countryModel->id . "'";
}
if ($categoryModel->id > 0) {
    $toursCondition .= " AND category_id='" . $categoryModel->id . "'";
}
$listTours = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions($toursCondition)->setParams($tourParams)->setOrderBy("pos DESC")->setLimit(-1)->setCache(0));
$listItems = CatalogFirmsItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id AND active=1")->setParams(array(":firm_id" => $item->id))->setLimit(-1)->setCache(0));
?>
<div id="InnerText" class="innerPage">
    <br/>
    <?php 
SiteHelper::renderDinamicPartial("pageDescriptionTop");
?>
    <h1><?php 
echo $item->name;
?>
 <font>- <?php 
echo Yii::t("travelAgency", "туристическое агенство");
?>
 <?php 
echo $item->country_id->name_2;
 public function actionTest()
 {
     // Расчет ретинга фирмы
     /*
                     + Рейтинг фирмы
                         если рейтинг = 0 то - 100
            + Заполленность описания 40
                         если не заполнено - 30
            + Заполленность ПРОГРАММЫ 40
                         если не заполнено - 30
            + Заполленность ЦЕНЫ 40
                         если не заполнено - 30
            + Заполенность ЦЕНЫ И ВАЛЮТЫ 100
                         - если не заполнена цена - 100
                         не учитывать если не заполнено валюта
            + Заполенность ВКЛЮЧННО 40
                         если не заполнено - 30
            + Заполенность НЕ ВКЛЮЧННО 20
                     + Заполенность ВНИМАНИЕ 20
                     + Заполенность ДЛИТЕЛЬНОСТЬ 40
                         если не заполнено - 30
            + Галлерея + 10 за каждую, но учитывать только 5
                         Если нет не одной то -50
                         Если меньше 3 то -20
     */
     /*        $count = 20;
                   $lastFirm = CatCache::fetchBySlug("index_last_tours");
                   $list = CatalogTours::fetchAll( DBQueryParamsClass::CreateParams()->setConditions("id>:id")->setParams( array( ":id"=>$lastFirm->value ) )->setLimit( $count ) );
                   foreach( $list as $item )
                   {
                       $id = $item->id;
               */
     $id = (int) $_GET["id"];
     $item = CatalogTours::fetch($id);
     $rating = 0;
     // Рейтинг фирмы
     if ($item->firm_id->rating > 0) {
         $rating += $item->firm_id->rating;
     } elseif ($item->firm_id->rating == 0) {
         $rating -= 100;
     }
     // Проверяем описание
     if ((int) $item->price > 0) {
         if ($item->currency_id->id > 0) {
             $rating += 100;
         }
     } else {
         $rating -= 100;
     }
     if ($item->description) {
         if (strlen(trim(strip_tags($item->description))) > 200) {
             $rating += 40;
         }
     } else {
         $rating -= 30;
     }
     if ($item->program) {
         if (strlen(trim(strip_tags($item->program))) > 200) {
             $rating += 40;
         }
     } else {
         $rating -= 30;
     }
     if ($item->prices) {
         if (strlen(trim(strip_tags($item->prices))) > 100) {
             $rating += 40;
         }
     } else {
         $rating -= 30;
     }
     if ($item->included) {
         if (strlen(trim(strip_tags($item->included))) > 100) {
             $rating += 40;
         }
     } else {
         $rating -= 30;
     }
     if ($item->duration) {
         $rating += 40;
     } else {
         $rating -= 30;
     }
     if ($item->not_included) {
         $rating += 20;
     }
     if ($item->attention) {
         $rating += 20;
     }
     // Галлерея
     $images = CatGallery::count(DBQueryParamsClass::CreateParams()->setConditions("catalog='catalog_tours' AND item_id=:id")->setParams([":id" => $id]));
     if ($images > 0) {
         $rating += $images * 5;
     } else {
         $rating -= 10;
     }
     $item->rating = $rating;
     if (!$item->save()) {
         print_r($item->getErrors());
     }
     echo $item->id . "-" . $rating . "<br/>";
 }
 public function actionDescription()
 {
     Yii::app()->page->setInfo(array("description" => $this->description, "keyWord" => $this->keyWord));
     $id = 0;
     $class = $this->classModel;
     $slug = !empty($_GET["slug"]) ? $_GET["slug"] : "";
     if (!empty($_GET["slug"])) {
         $model = $class::fetchBySlug(trim($slug));
         if ($model->id > 0) {
             $_GET["id"] = $model->id;
             $id = $model->id;
         }
     }
     // Проверяем по ID
     if ($id == 0) {
         $ar = explode("-", $slug);
         if ((int) $ar[0] > 0) {
             $model = $class::fetch((int) $ar[0]);
             $id = $model->id;
         }
     }
     if ($id > 0) {
         if ($model->id > 0) {
             $item = $model;
         } else {
             $item = $class::fetch($id);
         }
         if ($item->id > 0) {
             $images = ImageHelper::getImages($item);
             $other = $class::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("category_id=:category_id AND id!=:id")->setParams(array(":category_id" => $item->category_id->id, ":id" => $item->id))->setOrderBy("id DESC")->setLimit(12));
             $tourCategory = $item->tour_category;
             if (!empty($tourCategory) && sizeof($tourCategory) > 0) {
                 $dopSQL = " AND ( ";
                 $m = 0;
                 foreach ($tourCategory as $tCategory) {
                     if ($m > 0) {
                         $dopSQL .= " OR ";
                     }
                     $dopSQL .= "category_id=" . $tCategory->id;
                     $m++;
                 }
                 $dopSQL .= ") ";
                 $tours = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country_id " . $dopSQL)->setParams(array(":country_id" => $item->country_id->id))->setOrderBy("rating DESC")->setLimit(9));
             } elseif ($item->country_id->id > 0) {
                 $tours = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country_id")->setParams(array(":country_id" => $item->country_id->id))->setOrderBy("rating DESC")->setLimit(10));
             } else {
                 $tours = array();
             }
             Yii::app()->page->title = $item->name;
             $this->render('description', array("item" => $item, "other" => $other, "images" => $images, "tours" => $tours, "hotelCount" => $class::count(DBQueryParamsClass::CreateParams()->setConditions("category_id=:category_id")->setParams(array(":category_id" => $item->category_id->id)))));
         } else {
             throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу"));
         }
     } else {
         throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу"));
     }
 }
 public function actionIndex()
 {
     $tab = Yii::app()->request->getParam("tab", "");
     $page = (int) Yii::app()->request->getParam("p", 1);
     $action = Yii::app()->request->getParam("action", "t");
     $country = Yii::app()->request->getParam("country", "");
     $category = Yii::app()->request->getParam("category", "");
     $ccategory = Yii::app()->request->getParam("ccategory", "");
     $icategory = Yii::app()->request->getParam("icategory", "");
     $slug = Yii::app()->request->getParam("slug", "");
     $activeTab = "";
     $t_page = 1;
     $i_page = 1;
     $c_page = 1;
     if ($action == "t") {
         $t_page = $page;
         $activeTab = "s_tours";
     }
     if ($action == "i" || $tab == "info") {
         $i_page = $page;
         $activeTab = "s_info";
     }
     if ($action == "c" || $tab == "curorts") {
         $c_page = $page;
         $activeTab = "s_curorts";
     }
     /*        foreach( $_GET as $key=>$item )
             {
                 echo "#";
                 if( empty( $_GET[$key] ) || $_GET[$key]=="null" )continue;
                 echo $key."*";
                 $item = CatalogSections::fetchBySlug( $key );
                 if( $item->id >0 )break;
             }*/
     if (!empty($slug)) {
         $item = CatalogSections::fetchBySlug($slug);
     } else {
         $item = CatalogSections::fetchBySlug("otdyh-v-gorah");
     }
     if ($item && $item->id > 0) {
         Yii::app()->page->setInfo(array("description" => $item->name . "," . $this->description, "keyWord" => $item->name . "," . $this->keyWord));
         if (!empty($item) && $item->id > 0) {
             $infoCategory = " 1=1 ";
             $infoSQL = " 1=1 ";
             if (!empty($icategory)) {
                 $infoCategory .= " AND category_id = ( SELECT id FROM catalog_info_category WHERE slug='" . $icategory . "' )";
             }
             $i = 0;
             if (sizeof($item->info) > 0) {
                 $infoCategory .= " AND ( ";
                 $infoSQL .= " AND ( ";
                 foreach ($item->info as $itemC) {
                     if ($i > 0) {
                         $infoCategory .= " OR ";
                         $infoSQL .= " OR ";
                     }
                     $infoCategory .= " category_id='" . $itemC->id . "' ";
                     $infoSQL .= " category_id='" . $itemC->id . "' ";
                     $i++;
                 }
                 $infoCategory .= " ) ";
                 $infoSQL .= " ) ";
             }
             $curortsCategory = " 1=1 ";
             $kurortsSQL = " 1=1 ";
             if (!empty($ccategory)) {
                 $curortsCategory .= " AND category_id = ( SELECT id FROM catalog_kurorts_category WHERE slug='" . $ccategory . "' )";
             }
             if (sizeof($item->curorts) > 0) {
                 $curortsCategory .= " AND ( ";
                 $kurortsSQL .= " AND ( ";
                 $i = 0;
                 foreach ($item->curorts as $itemC) {
                     if ($i > 0) {
                         $curortsCategory .= " OR ";
                         $kurortsSQL .= " OR ";
                     }
                     $curortsCategory .= " category_id='" . $itemC->id . "' ";
                     $kurortsSQL .= " category_id='" . $itemC->id . "' ";
                     $i++;
                 }
                 $curortsCategory .= " ) ";
                 $kurortsSQL .= " ) ";
                 $cororts = CatalogKurorts::fetchAll(DBQueryParamsClass::CreateParams()->setConditions($curortsCategory)->setOrderBy("col DESC")->setPage($c_page)->setLimit(15));
                 $curortsCount = CatalogKurorts::count(DBQueryParamsClass::CreateParams()->setConditions($curortsCategory));
             } else {
                 $cororts = array();
                 $curortsCount = 0;
             }
             $toursCategory = " 1=1 ";
             $toursSQL = " 1=1 ";
             if ($item->country_id->id > 0) {
                 $toursCategory .= " AND country_id = '" . $item->country_id->id . "'";
                 $toursSQL .= " AND country_id = '" . $item->country_id->id . "'";
             }
             if (!empty($country)) {
                 $toursCategory .= " AND country_id = ( SELECT id FROM catalog_country WHERE slug='" . $country . "' LIMIT 1 )";
             }
             if (!empty($category)) {
                 $toursCategory .= " AND category_id = ( SELECT id FROM catalog_tours_category WHERE slug='" . $category . "' LIMIT 1 )";
             }
             if (sizeof($item->tours) > 0) {
                 $toursCategory .= " AND ( ";
                 $toursSQL .= " AND ( ";
             }
             $i = 0;
             foreach ($item->tours as $itemC) {
                 if ($i > 0) {
                     $toursCategory .= " OR ";
                     $toursSQL .= " OR ";
                 }
                 $toursCategory .= " category_id='" . $itemC->id . "' ";
                 $toursSQL .= " category_id='" . $itemC->id . "' ";
                 $i++;
             }
             if (sizeof($item->tours) > 0) {
                 $toursCategory .= " ) ";
                 $toursSQL .= " ) ";
             }
             // Одно исключение для детских лагерей
             if ($item->id == 7) {
                 $detCount = CatalogKurorts::count(DBQueryParamsClass::CreateParams()->setConditions($curortsCategory));
             } else {
                 $detCount = 0;
             }
             Yii::app()->page->title = $item->name;
             $this->render('index', array("icategory" => $icategory, "ccategory" => $ccategory, "category" => $category, "country" => $country, "activeTab" => $activeTab, "item" => $item, "infoSQL" => $infoSQL, "info" => CatalogInfo::fetchAll(DBQueryParamsClass::CreateParams()->setConditions($infoCategory)->setOrderBy("col DESC")->setPage($i_page)->setLimit(15)), "infoCount" => CatalogInfo::count(DBQueryParamsClass::CreateParams()->setConditions($infoCategory)), "toursSQL" => $toursSQL, "tours" => CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions($toursCategory)->setOrderBy("col DESC")->setPage($t_page)->setLimit(15)), "tourCount" => CatalogTours::count(DBQueryParamsClass::CreateParams()->setConditions($toursCategory)), "kurortsSQL" => $kurortsSQL, "curorts" => $cororts, "curortsCount" => $curortsCount, "detCount" => $detCount, "t_page" => $t_page, "i_page" => $i_page, "c_page" => $c_page, "offset" => 15));
         } else {
             throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу"));
         }
     } else {
         throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу"));
     }
 }
        echo SiteHelper::createUrl("/country") . "/" . $item->country_id->slug;
        ?>
.html" title="<?php 
        echo $item->country_id->name;
        ?>
"><?php 
        echo Yii::t("page", "Страна");
        ?>
: <b><?php 
        echo $item->country_id->name;
        ?>
</b></a><br/><?php 
    }
    ?>
                Туров: <b><?php 
    echo CatalogTours::count(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id")->setParams(array(":firm_id" => $item->id)));
    ?>
</b><br/>
            </div>
            <div class="well well-lg"><div class="limitText">
                <?php 
    echo CCModelHelper::getLimitText($item->description, "30");
    ?>
            </div></div>
        </div>
    </div>
<?php 
}
if (!is_array($items) || sizeof($items) == 0) {
    ?>
    <center>--<?php