/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $limit = 30; $p = (int) Yii::app()->request->getParam("p", 1); $catalog = Yii::app()->request->getParam("catalog", ""); Yii::app()->page->title = "Выставить слаг"; if (!empty($catalog)) { $catalogS = SiteHelper::getCamelCase($catalog); $items = $catalogS::fetchAll(DBQueryParamsClass::CreateParams()->setLimit($limit)->setCache(0)->setPage($p)); //echo sizeof( $items )."*"; //die; for ($i = 0; $i < sizeof($items); $i++) { if (strpos($items[$i]->description, "</xml>") !== false) { $arr = explode("</xml>", $items[$i]->description); $items[$i]->description = $arr[1]; if (empty($items[$i]->description)) { $items[$i]->description = " - "; } if (!$items[$i]->save()) { //print_r( $items[$i]->getErrors() ); //die; } } } if (sizeof($items) == $limit) { $this->redirect(SiteHelper::createUrl("/console/CheckDescription", array("catalog" => $catalog, "p" => $p + 1))); } } else { $items = array(); } $this->render("index", array("items" => $items)); }
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]; } } } if ($id > 0) { $item = CatalogHotels::fetch($id); if ($item->id > 0) { LogHelper::save("hotels", $item->id, "show"); Yii::app()->page->title = $item->name; $this->render('description', array("item" => $item, "otherHotels" => CatalogHotels::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND country_id=:country_id AND city_id=:city_id AND id!=:id")->setParams(array(":country_id" => $item->country_id->id, ":city_id" => $item->city_id->id, ":id" => $item->id))->setOrderBy("col DESC")->setLimit(8)), "hotelCount" => CatalogHotels::count(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country")->setParams(array(":country" => $item->country_id->id))))); } else { throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу")); } } else { throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу")); } }
public function actionEdit() { $message = ""; $lang = CatLang::fetchAll(); if (!empty($_POST["trans"])) { for ($n = 0; $n < sizeof($lang); $n++) { $trans = $_POST["trans"][$n]; if ($trans["id"] > 0 || $trans["translation"]) { if ($trans["id"] > 0) { $model = I18nTranslate::fetch($trans->id); } else { $model = new I18nTranslate(); } $model->setAttributesFromArray($trans); $model->i18n_id = $this->id; if (!$model->save()) { print_r($model->getErrors()); } } } } $list = array(); if (!empty($this->id)) { $item = I18n::fetch($this->id); $list = I18nTranslate::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("i18n_id=:id")->setParams(array(":id" => $item->id))->setLimit(-1)->setCache(0)); } else { $item = new I18n(); } $this->render('edit', array('form' => $item, 'list' => $list, 'lang' => $lang, 'message' => $message)); }
public static function getBannerByCategory($position, $firmId) { $cout = ""; $DBParams = DBQueryParamsClass::CreateParams()->setConditions("position_id=:position_id AND firm_id=:firmId AND active=1")->setParams(array(":position_id" => $position, ":firmId" => $firmId))->setOrderBy("col")->setLimit(1)->setCache(0); $bannerArray = CatalogFirmsBanners::fetchAll($DBParams); if (sizeof($bannerArray) > 0 && $bannerArray[0]->file) { $banner = $bannerArray[0]; $banner->col = $banner->col + 1; if (!$banner->save()) { print_r($banner->getErrors()); } $cout = '<div class="banerBlock">'; if ($banner->type_id->id == 1) { if ($banner->link) { $cout .= '<a href="' . $banner->link . '" title="">'; } $cout .= '<img src="' . $banner->file . '" alt="" />'; if ($banner->link) { $cout .= '</a>'; } } else { $width = $banner->width ? ' width="' . $banner->width . '"' : ' width="800"'; $height = $banner->height ? ' height="' . $banner->height . '"' : ' height="90"'; $cout .= '<br/><a href="' . $banner->href . '" title=""> <object ' . $width . ' ' . $height . ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param value="' . $banner->image . '" name="movie"/> <embed ' . $width . ' ' . $height . ' src="' . $banner->file . '" type="application/x-shockwave-flash"/> </object> </a>'; } $cout .= '</div>'; } return $cout; }
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 actionIndex() { if (!Yii::app()->user->isGuest) { $message = ""; Yii::app()->page->title = Yii::t("user", "Избранное"); $userModel = CatalogUsers::fetch(Yii::app()->user->id); $del = (int) Yii::app()->request->getParam("del", 0); if ($del > 0) { Yii::app()->favorites->delete($del, "catalog_items"); } $list = Yii::app()->favorites->getListId("catalog=:catalog", array(":catalog" => "catalog_items")); if (sizeof($list) > 0) { $sql = " ( "; foreach ($list as $key => $value) { if ($sql != " ( ") { $sql .= " OR "; } $sql .= "id='" . $value . "'"; } $sql .= " )"; $items = CatalogItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("status_id=1")->setConditions($sql)->setCache(0)); } else { $items = array(); } $this->render("index", array("message" => $message, "items" => $items, "userModel" => $userModel)); } }
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 ($id > 0) { $item = CatalogWork::fetch($id); $item->setColView(); if ($item->id > 0) { Yii::app()->page->title = $item->name; $this->render('description', array("item" => $item, "otherHotels" => CatalogWork::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("category_id=:category_id AND id!=:id")->setParams(array(":category_id" => $item->category_id->id, ":id" => $item->id))->setOrderBy("col DESC")->setLimit(8)), "usersOther" => CatalogWork::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("user_id=:user_id AND id!=:id")->setParams(array(":user_id" => $item->user_id->id, ":id" => $item->id))->setOrderBy("col DESC")->setLimit(8)))); } else { throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу")); } } else { throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу")); } }
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; } } $error = Yii::t("page", "Произошла ошибка перехода на страницу, проверьте правильно написания адреса страницы"); if ($id > 0) { $item = CatalogFirmsService::fetch($id); if ($item->id > 0) { CCModelHelper::colCounter($item); // Картинки тура $images = ImageHelper::getImages($item); Yii::app()->page->title = $item->name . " - " . Yii::t("page", "услуги от компании"); $this->render('description', array("item" => $item, "images" => $images, "firmsService" => CatalogFirmsService::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id AND id!=:id")->setParams(array(":firm_id" => $item->firm_id, ":id" => $item->id))->setCache(0)), "firmsItems" => CatalogFirmsItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id")->setParams(array(":firm_id" => $item->firm_id))->setCache(0)))); } else { throw new CHttpException("", $error); } } else { throw new CHttpException("", $error); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { Yii::app()->page->title = "Описание продукции"; $id = (int) Yii::app()->request->getParam("id", 0); if ($id > 0) { $item = CatalogItems::fetchParam($id); $otherItem = CatalogItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("id!=:id AND category_id=:cid")->setParams(array(":id" => $item->id, ":cid" => $item->category_id->id))->setOrderBy("price")->setLimit(10)); $hotItem = CatalogItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("id!=:id AND is_hot=:hot")->setParams(array(":id" => $item->id, ":hot" => 1))->setOrderBy("price")->setLimit(10)); if ($item->id > 0) { $favorites = Yii::app()->request->getParam("favorites", ""); if ($favorites == "add") { $res = Yii::app()->favorites->add("catalog_items", $item->id); } $newComment = new CatalogItemsCommentsAdd(); // Сохраняем комментарий if (!empty($_POST["sentComment"])) { $newComment->setAttributesFromArray($_POST["CatalogItemsCommentsAdd"]); $newComment->date = time(); $newComment->user_id = Yii::app()->user->id; $newComment->item_id = $id; if ($newComment->save()) { $newComment->formMessage = "Комментарий успешно отправлен."; $newComment->onNewComment(new CModelEvent($newComment), array("id" => $item->id, "name" => $item->name, "subject" => $newComment->subject, "link" => SiteHelper::createUrl("/user/items/index", array("id" => $newComment->item_id)))); } } $listComments = CatalogItemsComments::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("item_id=:item_id AND is_valid=1")->setParams(array(":item_id" => $item->id))->setOrderBy("date DESC")); $this->render("item", array("item" => $item, "otherItem" => $otherItem, "hotItem" => $hotItem, "addForm" => $newComment, "listComments" => $listComments)); } else { $this->redirect("/"); } } else { $this->redirect("/"); } }
public function actionDelete() { Yii::app()->page->title = Yii::t("user", "Запись удалена"); $message = ""; $id = (int) Yii::app()->request->getParam("id", 0); $catalog = Yii::app()->request->getParam("catalog"); if ($id > 0 && !empty($catalog)) { $item = $catalog::fetch($id); if ($item->user_id && $item->user_id->id > 0) { $id = $item->user_id->id; } else { $id = $item->firm_id->user_id->id; } if ($item->id > 0 && $id == Yii::app()->user->getId()) { foreach (CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions(" item_id=:itemId AND catalog=:catalog ")->setParams(array(":itemId" => $item->id, ":catalog" => $item->tableName()))) as $galItem) { $galItem->delete(); } $item->delete(); SiteHelper::setLog($item->tableName(), "delete", $item->id, Yii::app()->user->getId()); echo 1; return; } } return; }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { Yii::app()->page->title = "Банеры"; $banners = ExBanner::fetchAll(DBQueryParamsClass::CreateParams()->setOrderBy("name")->setLimit(-1)->setCache(0)); $bannersCategory = ExBannerCategory::fetchAll(DBQueryParamsClass::CreateParams()->setOrderBy("name")->setLimit(-1)->setCache(0)); $this->render("index", array("banners" => $banners, "bannersCategory" => $bannersCategory)); }
public function run($args) { $col = 50; $n = 0; // $listCatalog = array("CatalogContent"); //"CatalogTours", "CatalogInfoCategory", "CatalogToursCategory", "CatalogInfo", "CatalogCity", "CatalogFirms", "CatalogHotels", "CatalogKurorts", "CatalogUmor", "CatalogCountry", "CatalogItems", "CatalogItemsCategory", "CatalogContent", "CatalogFirmsItems", "CatalogFirmsService", "CatalogWork" ); for ($i = 0; $i < sizeof($listCatalog); $i++) { $class = $listCatalog[$i]; $list = $class::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("translate=0")->setLimit($col)->setCache(0)); echo $class . " - " . $n . "( " . sizeof($list) . " )<br/>"; foreach ($list as $model) { $model->translate = 1; if (!$model->save()) { print_r($model->getErrors()); } else { echo $model->id . "<br/>"; $n++; $transModel = TranslateHelper::getTranslateModel($class, $model->id, "en"); // ja en if (!$transModel->id) { @TranslateHelper::setTranslate($model, $transModel, "en"); } } } if (sizeof($list) == $col || $n >= $col) { break; } } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $limit = 30; $p = (int) Yii::app()->request->getParam("p", 1); $catalog = Yii::app()->request->getParam("catalog", ""); Yii::app()->page->title = "Выставить слаг"; if (!empty($catalog)) { $catalogS = SiteHelper::getCamelCase($catalog); $items = $catalogS::fetchAll(DBQueryParamsClass::CreateParams()->setLimit($limit)->setCache(0)->setPage($p)); //echo sizeof( $items )."*"; //die; foreach ($items as $item) { //echo "#".$item->id."<br/>"; $item->description = str_replace("< ", "<", $item->description); if (!$item->save()) { print_r($item->getErrors()); //die; } } if (sizeof($items) == $limit) { $this->redirect(SiteHelper::createUrl("/console/CheckDescriptionTag", array("catalog" => $catalog, "p" => $p + 1))); } } else { $items = array(); } $this->render("index", array("items" => $items)); }
public function actionTree() { $id = Yii::app()->request->getParam("id", 0); if (!empty($id)) { $images = CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("catalog=:catalog AND item_id=:item_id")->setParams(array(":catalog" => "catalog_gardens_tree", ":item_id" => $id))->setLimit(10)); $tree = CatalogGardensTree::fetch($id); $this->render("usertree", array("images" => $images, "tree" => $tree)); } }
public static function getRelationLeftItems(CCModel $model, $classRelation) { $leftClass = get_class($model); $res = CatRelations::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("leftClass=:leftClass AND rightClass=:rightClass AND leftId=:id")->setParams(array(":leftClass" => $leftClass, ":rightClass" => $classRelation, ":id" => $model->id))->setLimit(-1)->setCache(0)); $list = []; foreach ($res as $items) { $list[] = $items->rightId; } return $list; }
public function actionIndex() { if (!Yii::app()->user->isGuest) { Yii::app()->page->title = "Мои заказы"; $user = CatalogUsers::fetch(Yii::app()->user->id); $orders = OrderRequest::fetchAll(DBQueryParamsClass::CreateParams()->setCache(0)->setConditions("user_id=:user_id")->setParams(array(":user_id" => Yii::app()->user->id))->setLimit(200)->setOrderBy("date")); $this->render("index", array("user" => $user, "orders" => $orders)); } else { $this->redirect(SiteHelper::createUrl("/")); } }
public function run() { $conditions = "catalog=:catalog"; $params = array(":catalog" => $this->catalog); if (!empty($id)) { $conditions .= " sAND item_id=:item_id"; $params = array_merge($params, array(":id" => $id)); } $images = CatGallery::fetchAll(DBQueryParamsClass::CreateParams()->setConditions($conditions)->setParams($params)->setLimit(10)); $this->render("gallery", array('images' => $images)); }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { if (Yii::app()->user->isGuest) { Yii::app()->page->title = "Console авторизации"; $this->actionLogin(); } else { $list = CatLog::fetchAll(DBQueryParamsClass::CreateParams()->setOrderBy("id DESC")->setLimit(50)->setCache(0)); Yii::app()->page->title = "Административный кабинет"; $this->render("room", array("listStat" => $list)); } }
public function actionDescription() { $slug = Yii::app()->request->getParam("slug", ""); if (!empty($slug)) { $item = CatalogMaps::fetchBySlug("map-" . $slug); Yii::app()->page->setTitle($item->name); $list = CatalogWheters::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("city_id=:id")->setParams(array(":id" => $item->city_id->id))->setLimit(-1)); $this->render("description", array("item" => $item, "list" => $list)); } else { $this->redirect(SiteHelper::createUrl("/uzbekistanMaps")); } }
public function run() { if ($this->beginCache('widgetInfo_' . $this->class . $this->category_id . "_" . Yii::app()->getLanguage(), array('duration' => 3600))) { $className = $this->class; if ($this->category_id > 0) { $dopCondition = " AND category_id='" . (int) $this->category_id . "'"; } else { $dopCondition = ""; } $this->render("infoWidget", array('title' => $this->title, 'link' => SiteHelper::createUrl($this->link . "/description"), 'linkAll' => SiteHelper::createUrl($this->link), 'list' => $className::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>''" . $dopCondition)->setOrderBy("id DESC")->setLimit(9)))); $this->endCache(); } }
public function actionDescription() { $slug = Yii::app()->request->getParam("slug", ""); if (!empty($slug)) { $item = CatalogAttractions::fetchBySlug($slug); if ($item->id > 0) { Yii::app()->page->setTitle($item->name); $list = CatalogAttractions::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("city_id=:cid AND id!=:id")->setParams(array(":cid" => $item->city_id->id, ":id" => $item->id))->setLimit(4)); $images = ImageHelper::getImages($item); $this->render("description", array("item" => $item, "other" => $list, "images" => $images)); } } }
public function actionIndex() { if (!Yii::app()->user->isGuest) { $message = ""; Yii::app()->page->title = Yii::t("user", "Рабочий стол"); $userModel = CatalogUsers::fetch(Yii::app()->user->id); if (!empty($_POST["desktop_save"])) { $desktopID = (int) Yii::app()->request->getParam("desktopID", 0); $userModel->desktop = $desktopID; $userModel->save(); $userModel->formMessage = Yii::t("user", "Рабочий стол успешно сохранен"); } $items = CatalogDesktops::fetchAll(DBQueryParamsClass::CreateParams()->setCache(0)); $this->render("index", array("message" => $message, "items" => $items, "userModel" => $userModel)); } }
public function run($args) { $list = array("catalog_users", "catalog_firms", "catalog_tours", "catalog_firms_service", "catalog_firms_items"); for ($i = 0; $i < sizeof($list); $i++) { $catalog = SiteHelper::getCamelCase($list[$i]); $listItems = $catalog::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("!EXISTS(SELECT id FROM notifications_queue WHERE catalog='" . $list[$i] . "' AND item_id=" . $list[$i] . "_as.id)")->setLimit(50)->setOrderBy("rating")); //$listItems = $catalog::fetchAll( DBQueryParamsClass::CreateParams()->setConditions("id=13")->setLimit( 100 )->setOrderBy("rating") ); if (sizeof($listItems) > 0) { foreach ($listItems as $item) { $tableName = $item->tableName(); switch ($item->tableName()) { case "catalog_users": if ($item->active == 0) { AutoNotifier::onRegistration($item); } else { $countFirms = CatalogFirms::count(DBQueryParamsClass::CreateParams()->setConditions("user_id=:uid")->setParams(array(":uid" => $item->id))); if ($countFirms == 0) { $tableName = "catalog_users_con"; AutoNotifier::onRegistrationConfirm($item); } else { continue 2; } } break; case "catalog_firms": $item->onAddFirm(new CModelEvent($item), array("status" => "reminder")); break; case "catalog_tours": $item->onAddTour(new CModelEvent($item), array("status" => "reminder")); break; case "catalog_firms_items": $item->onAddFirmsItems(new CModelEvent($item), array("status" => "reminder")); break; case "catalog_firms_service": $item->onAddFirmsService(new CModelEvent($item), array("status" => "reminder")); break; case "catalog_firms_banner": $item->onAddFirmsBanners(new CModelEvent($item), array("status" => "reminder")); break; } AutoNotifier::addInNotificationsQueue($tableName, $item->id, 0); } return ""; } } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { Yii::app()->page->title = "Лог по турам"; if ($this->beginCache("console_log_tours", array('duration' => 3600 * 12))) { $listTours = CatLogToursAll::fetchAll(DBQueryParamsClass::CreateParams()->setOrderBy("date2")->setLimit(50)->setCache(0)); $listToursParams = CatLogToursParams::fetchAll(DBQueryParamsClass::CreateParams()->setOrderBy("date2")->setLimit(50)->setCache(0)); $rows = ""; for ($i = 0; $i < sizeof($listTours); $i++) { if (!empty($rows)) { $rows .= ","; } $rows .= "['" . date("d.m", strtotime($listTours[$i]->date2)) . "', " . $listTours[$i]->count . ", " . $listToursParams[$i]->count_category . ", " . $listToursParams[$i]->count_country . " ]"; } $this->render("index", array("rows" => $rows, "listToursParams" => $listToursParams)); $this->endCache(); } }
public static function run() { $userModel = CatalogUsers::fetch(Yii::app()->user->getId()); if ($userModel->id > 0) { // Надотпроверять какие данные пользователь уже ввел чтобы выдавать ему то чего он еще не ввел // 1. Типо пользователя ( если он не добавил ни фирму ни отель ни курорт ) // надо сделать так чтобы при добавлении отеля тур фирмы курорта пользователю выставлялось занчение поля trainings = 1 ( т.е. не выдавать ему заново выберите тип ) // Проверяем небыла ли открыта ссесия ранее $checkModel = CatalogTrainingSession::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("user_id=:user_id AND ( status_id=:status1 OR status_id=:status2 )")->setParams(array(":user_id" => Yii::app()->user->getId(), ":status1" => 1, ":status2" => 2))->setCache(-1)); if (sizeof($checkModel) == 0) { //// Определеяем на каком шагу находится пользователь $chechSession = CatalogTraining::sql("SELECT * FROM catalog_training WHERE `group` NOT IN ( SELECT `group` FROM catalog_training_session WHERE user_id='" . Yii::app()->user->getId() . "' ) ORDER BY `group` LIMIT 1 "); if (sizeof($chechSession) > 0) { if ($chechSession[0]["condition"]) { $chechSession[0]["condition"] = str_replace(":userId", Yii::app()->user->getId(), $chechSession[0]["condition"]); $checkCondition = CatalogUsers::sql($chechSession[0]["condition"]); if (sizeof($checkCondition) == 0) { // Если пользователь не отвечает требованию пользователю, то чтобы не проверять каждый раз, добавляем запись $newSession = new CatalogTrainingSession(); $newSession->user_id = Yii::app()->user->getId(); $newSession->training_id = $chechSession[0]["id"]; $newSession->group = $chechSession[0]["group"]; $newSession->status_id = 4; $newSession->date = time(); $newSession->save(); return; } } // Если нет то открываем её $newSession = new CatalogTrainingSession(); $newSession->user_id = Yii::app()->user->getId(); $newSession->training_id = $chechSession[0]["id"]; $newSession->group = $chechSession[0]["group"]; $newSession->status_id = 1; $newSession->date = time(); if (!$newSession->save()) { print_r($newSession->getErrors()); } } } else { $checkModel[0]->status_id = 1; $checkModel[0]->save(); } } }
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 actionListCity() { $countryId = !empty($_GET["country"]) && (int) $_GET["country"] > 0 ? (int) $_GET["country"] : null; if (!empty($countryId)) { $dbcriterii = DBQueryParamsClass::CreateParams()->setConditions("country=:country_id")->setParams(array(":country_id" => $countryId)); $cout = ""; $listCity = CatalogCity::fetchAll($dbcriterii); if (sizeof($listCity) > 0) { foreach ($listCity as $key => $data) { $cout .= "<option value='" . $data->id . "'>" . $data->name . "</option> "; } } else { $cout .= "<option value=''> --- --- --- </option> "; } echo $cout; } Yii::app()->end(); die; }
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", "Ошибка перехода на страницу")); } }
/** * 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 textFind($findText) { Yii::app()->page->title = "Поиск продукции"; if (!empty($findText)) { $arrayData = array(); $listCid = CatalogItemsCategory::sql("SELECT c2.name as cid_name, c.name, c.id, count(i.id) as c FROM catalog_items_category c, catalog_items_category c2, catalog_items i WHERE ( i.name like '%" . $findText . "%' OR i.description like '%" . $findText . "%' ) AND c.id=i.category_id AND c2.id = c.owner GROUP BY i.category_id"); for ($i = 0; $i < sizeof($listCid); $i++) { $cidName = $listCid[$i]["cid_name"]; if (!empty($arrayData[$cidName]["count"])) { $arrayData[$cidName]["count"] += $listCid[$i]["c"]; } else { $arrayData[$cidName]["count"] = $listCid[$i]["c"]; } $arrayData[$cidName]["items"][] = $listCid[$i]; } $items = CatalogItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("name like '%" . $findText . "%' OR description like '%" . $findText . "%'")->setLimit(10)); $this->render("index", array("arrayData" => $arrayData, "items" => $items)); } else { $this->redirect(SiteHelper::createUrl("/")); } }