public function run() { if (empty($this->model) || empty($this->type)) { return; } // Определяем тип товара для поиска товаров данного типа $productType = ProductType::model()->published()->findByAlias($this->type); if (!$productType) { return; } // Определяем товар данного типа с таким же названием, как заданный $relatedProduct = Stone::model()->published()->type($productType->id)->with('series')->findByAttributes(array('title' => $this->model->title)); // Получаем список рандомных товаров данного типа, похожих на заданный по цвету и виду камня $criteria = new CDbCriteria(); $criteria->compare('t.series_id', $this->model->series_id); $criteria->compare('t.color_id', $this->model->color_id); $notSearchIds = array($this->model->id); if ($relatedProduct !== null) { $notSearchIds[] = $relatedProduct->id; } $criteria->addNotInCondition('t.id', $notSearchIds); $criteria->order = 'RAND()'; $criteria->limit = 7; $models = Stone::model()->published()->type($productType->id)->with('series')->findAll($criteria); if ($relatedProduct !== null) { $models = array($relatedProduct) + $models; } $this->render($this->view, array('productType' => $productType, 'models' => $models, 'model' => $this->model)); }
public function loadModel($id) { if (($model = ProductType::model()->findByPk($id)) === null) { throw new CHttpException(404, 'Страница не найдена'); } return $model; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return ProductType the loaded model * @throws CHttpException */ public function loadModel($id) { $model = ProductType::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionDelete($id) { ProductType::model()->findByPk($id)->delete(); $this->redirect(Yii::app()->createUrl('/type/index')); }
public static function getTypes() { $model = ProductType::model()->findAll(); return CHtml::listData($model, 'id', 'name'); }
public function actionSuggestion() { $criteria = new CDbCriteria(); $criteria->select = array('t.id,t.name'); $pro_type = ProductType::model()->findAll($criteria); $products = array(); if (isset($_POST['sel_pro'])) { $customer = Customer::model()->findByPk(getCurCusId()); $customer->sel_products = $_POST['sel_pro']; if ($customer->save()) { $this->redirect(array('customer/customerreply')); } } foreach ($pro_type as $type) { $pro = Product::model()->findAll(array('condition' => "type_id = {$type->id}")); // $products[$type->name] = $pro; $products[] = $pro; } $this->render('suggestion', array('products' => $products, 'types' => $pro_type)); }
public function getTypeList() { return CHtml::listData(ProductType::model()->findAll(), 'id', 'title'); }
<tr> <td><img src="http://vvfy.me/img/gambar.png"></td> <td></td> <td></td> </tr> <tr > <td style="padding:20px"> <p style="color:white !important"> Thanks for submiting your data :)<br><br> <?php $pt = ProjectType::model()->findByPk($data->project_type)->name; $reference = $data->reference == 1 ? "Conceptual Renders" : $data->reference == 2 ? "Realistic Renders" : "Highest Quality Renders"; $deadline = $data->deadline; $style = $data->project_style == 1 ? "Modern" : "Classic"; $productType = ProductType::model()->findByPk($data->product_type)->name; ?> Project type : <?php echo $pt; ?> <br> <?php if ($data->project_type == 1) { ?> Views count : <?php echo $data->views_count; ?> <br> Style of project : <?php echo $style;
public function actionDeleteType() { $typeID = $_POST['typeID']; $sql = "SELECT * FROM `product_type` WHERE id=" . $typeID; $type = ProductType::model()->findBySql($sql); $result = false; if ($type) { $type->delete(); $result = true; } echo $result; }
public function actionSuggestion() { $criteria = new CDbCriteria(); $criteria->select = array('t.id,t.name'); $pro_type = ProductType::model()->findAll($criteria); $products = array(); DynamicCall::GetEdit1stPdf(getCurCusId()); if (isset($_GET['id'])) { $typeid = $_GET['id']; if (isset($_POST['sel_pro'])) { $customer = Customer::model()->findByPk(getCurCusId()); $customer->sel_products = $_POST['sel_pro']; if ($customer->save()) { $this->redirect(array('customer/customerreply')); } } $pro = Product::model()->findAll(array('condition' => "type_id =" . $typeid)); $products[] = $pro; $pro_desc = array(); $i = 1; foreach ($pro as $p) { $product = array('name' => $p->name, 'desc' => $p->desc); $pro_desc[$i] = $product; $i++; } } $products = isset($products[0]) ? $products[0] : array(); // e($products); $this->render('suggestion', array('products' => $products, 'types' => $pro_type, 'pro_desc' => $pro_desc)); }
<?php echo $form->radioButton($calc, 'project_style', array('value' => 2, 'uncheckValue' => null, 'id' => 'radio12')); ?> <!-- <input type="radio" id="radio12" name="style"> --> <label for="radio12"><span></span> CLASSIC</label> </div> <div style="clear:both"></div> </div> <div class="calc-error" id="calc-error-sop"></div> </div> </div> <div class="row" id="row-product-type" style="display:none"> <div class="label"><span class="helper">Product Type</span></div> <div class="value"> <?php echo $form->dropDownList($calc, 'product_type', CHtml::listData(ProductType::model()->findAll(), 'id', 'name'), array('empty' => 'Choose Product Type', 'class' => 'product-type')); ?> <!-- <select class="product-type"> <option>Choose Product Type</option> <option>Furniture</option> <option>Fixture</option> </select> --> <div class="calc-error" id="calc-error-pt"></div> </div> </div> <div class="row" id="row-number-views" style="display:none"><!-- if architecture --> <div class="label"><span class="helper">Number of views</span></div> <div class="value"> <?php echo $form->textField($calc, 'number_views', array("onkeypress" => "return AllowNumbersOnly(event)"));
/** * getProductType * @author wjh 2014-12-30 * @param $id * @param string $returnType * @return mixed */ public static function getProductType($id, $returnType = 'array', $data = null) { $types = empty($data) ? self::getProductTypes() : $data; return BCacheHelper::find($id, $types, $returnType, ProductType::model()); }
public function actionSync() { function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return (double) $usec + (double) $sec; } $begin = getmicrotime(); $typeAlias = $_GET['type']; $type = ProductType::model()->findByAlias($typeAlias); if (!$type) { throw new CHttpException(404); } $items = Stone::model()->resetScope()->type($type->id)->findAll(array('order' => 't.sort ASC')); $counter = 0; foreach ($items as $item) { $stone = Stone::model()->resetScope()->type(1)->findByAttributes(array('title' => $item->title)); if (!$stone) { //echo '<b style="color: red">' . $counter . '. ' . $item->title . ' - камень не найден</b><br />'; continue; } $item->color_id = $stone->color_id; $item->country_id = $stone->country_id; $item->title_rus = $stone->title_rus; //$item->alt_titles = $item->getTitle_eng(); //echo '<span style="color: green">' . $counter . '. ' . $item->title . ' - ' . $item->title_rus . '</span><br />'; $result = $item->update(array('color_id', 'country_id', 'title_rus')); if (!$result) { $counter++; echo '<b style="color: red">' . $counter . '. ' . $item->title . ' - ошибка сохранения</b><br />'; } } //$this->render('sync'); $end = getmicrotime(); $time = $end - $begin; echo "Время выполнения скрипта: " . $time . "с."; echo '<hr>'; }
<?php $this->layout = '//layouts/catalog'; $this->pageTitle = $page->title; $this->metaTitle = $page->metatitle; $this->description = $page->description; $this->keywords = $page->keywords; $this->breadcrumbs = array($page->title); $this->slides = $page->slides; $fullText = $page instanceof Page ? $page->body : $page->full_text; $productTypes = ProductType::model()->published()->findAll(array('order' => 't.sort ASC')); ?> <?php if (!empty($productTypes)) { ?> <div class="catalog_type" style="margin: 20px 0;"> <ul> <?php foreach ($productTypes as $pt) { ?> <li class="<?php if ($pt->id == $productType->id) { echo 'active'; } ?> "> <?php echo CHtml::link($pt->title, $pt->url, array('title' => $pt->title)); ?> </li>
public function actionIndex($type = '', $series = '') { $type = trim($type); $type = $type == '' ? 'stone' : $type; $productType = ProductType::model()->published()->findByAlias($type); if (!$productType) { throw new CHttpException(404); } $page = $productType; //$this->processPageRequest('page'); $series = trim($series); $filter = array(); $seoFilter = array('series_id' => null, 'color_id' => null, 'country_id' => null); $seoFlag = false; // Список видов камней $seriesList = Series::model()->published()->findAll(array('order' => 't.sort ASC')); // Определяем, выбран или нет вид камня $currentSeries = null; $currentColor = null; $currentCountry = null; if (!empty($series)) { // Если выбран вид камня $currentSeries = Series::model()->published()->with(array('slides' => array('scopes' => 'published', 'order' => 'slides.sort ASC'), 'images' => array('scopes' => 'published', 'order' => 'images.sort ASC')))->find('t.alias = :alias', array(':alias' => $series)); if (!$currentSeries) { throw new CHttpException(404); } $filter['series_id'] = $currentSeries->id; $seoFilter['series_id'] = $currentSeries->id; $seoFlag = true; // Если выбран цвет или страна if (isset($_GET['colorCountry'])) { $code = trim($_GET['colorCountry']); $currentDictData = DictionaryData::model()->active()->with('group')->findByCode($code); if ($currentDictData !== null) { if ($currentDictData->group->code == 'colors') { $currentColor = $currentDictData; $seoFilter['color_id'] = $currentColor->id; } elseif ($currentDictData->group->code == 'country') { $currentCountry = $currentDictData; $seoFilter['country_id'] = $currentCountry->id; } } } // Если выбран только цвет if (isset($_GET['color'])) { $code = trim($_GET['color']); $currentColor = DictionaryData::model()->active()->findByCode($code); if ($currentColor !== null) { $seoFilter['color_id'] = $currentColor->id; } } // Если выбрана только страна if (isset($_GET['country'])) { $code = trim($_GET['country']); $currentCountry = DictionaryData::model()->active()->findByCode($code); if ($currentCountry !== null) { $seoFilter['country_id'] = $currentCountry->id; } } } if ($seoFlag) { $seoPage = StoneSeoPage::model()->published()->type($productType->id)->findByAttributes($seoFilter); $page = $seoPage !== null ? $seoPage : $page; } // Список товаров $model = new Stone('user_search'); $model->unsetAttributes(); $model->type_id = $productType->id; // Если выбран вид камня if (!empty($currentSeries)) { $model->series_id = $currentSeries->id; } // Если выбран цвет камня if (!empty($currentColor)) { $model->color_id = $currentColor->id; $filter['color_id'] = $currentColor->id; } // Если выбрана страна if (!empty($currentCountry)) { $model->country_id = $currentCountry->id; $filter['country_id'] = $currentCountry->id; } if (isset($_GET['Stone'])) { $model->attributes = $_GET['Stone']; if ($model->title != '') { $filter['title'] = $model->title; } if (!empty($model->color_id)) { $filter['color_id'] = $model->color_id; } if (!empty($model->country_id)) { $filter['country_id'] = $model->country_id; } } // Поиск товаров $dataProvider = $model->user_search(); // Сохраняем ссылку для возврата Yii::app()->user->setState('stoneCatalogReturnUrl', Yii::app()->request->requestUri); //var_dump(Yii::app()->user->getState('stoneCatalogReturnUrl')); // Сохраняем данные фильтра в сессии //$filter['page'] = (int) Yii::app()->request->getParam('page', 1); Yii::app()->user->setState('stoneCatalogFilter', $filter); if (Yii::app()->request->isAjaxRequest) { // Обновление списка для бесконечной загрузки элементов if (isset($_GET['showMore'])) { $this->renderPartial('_list_ajax', array('dataProvider' => $dataProvider, 'pageNumber' => (int) Yii::app()->request->getParam('page', 1))); } else { $this->renderPartial('_list', array('dataProvider' => $dataProvider, 'productType' => $productType), false, true); } Yii::app()->end(); } else { // Вывод каталога $this->render('index', array('page' => $page, 'model' => $model, 'dataProvider' => $dataProvider, 'seriesList' => $seriesList, 'series' => $currentSeries, 'productType' => $productType)); } }