public function loadModel($id)
 {
     if (($model = DictionaryData::model()->findByPk($id)) === null) {
         throw new CHttpException(404, Yii::t('DictionaryModule.dictionary', 'Requested page was not found'));
     }
     return $model;
 }
 public function loadModel($id)
 {
     if (($model = DictionaryData::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
 /**
  * Заявкм
  */
 public function actionOrder()
 {
     $type = DictionaryData::model()->findByCode('feedback-order');
     if (!$type) {
         throw new CHttpException(404);
     }
     $feedbackForm = $this->_processForm($type);
 }
 public function init()
 {
     // Check for required config options
     if ($this->type === null) {
         throw new CException("Config error: missing 'type'");
     }
     $this->_type = DictionaryData::model()->findByCode($this->type);
     if ($this->_type === null) {
         throw new CException("Config error: incorrect type");
     }
 }
Ejemplo n.º 5
0
 protected static function getCargoNameDict($code)
 {
     $dict = CHtml::listData(DictionaryData::model()->with(['group' => ['select' => false, 'condition' => 'group.code="' . $code . '"']])->findAll(), 'id', 'name_' . Yii::app()->language);
     asort($dict);
     $other = $dict[252];
     unset($dict[252]);
     array_push($dict, $other);
     return $dict;
 }
Ejemplo n.º 6
0
 public function getData()
 {
     return DictionaryData::model()->cache(Yii::app()->getModule('yupe')->coreCacheTime)->findAll(array('condition' => 'group_id = :group_id', 'params' => array(':group_id' => $this->id), 'order' => 'name DESC'));
 }
Ejemplo n.º 7
0
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = DictionaryData::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 8
0
 public function getColorActiveList()
 {
     $dictionaryGroup = DictionaryGroup::model()->findByCode('colors');
     if ($dictionaryGroup != null) {
         $criteria = new CDbCriteria();
         $criteria->compare('t.group_id', $dictionaryGroup->id);
         if ($this->category_id !== null) {
             $colorsIds = CHtml::listData(InteriorItem::model()->published()->category($this->category_id)->findAll(array('select' => 'color_id')), 'color_id', 'color_id');
         } else {
             $colorsIds = CHtml::listData(InteriorItem::model()->published()->findAll(array('select' => 'color_id')), 'color_id', 'color_id');
         }
         $criteria->addInCondition('t.id', array_keys($colorsIds));
         $criteria->order = 't.sort ASC';
         $list = DictionaryData::model()->active()->findAll($criteria);
         return CHtml::listData($list, 'id', 'name');
     }
     return array();
 }
Ejemplo n.º 9
0
 /**
  *  обавить
  * @param int $id
  * @param null $delivery
  * @throws CException
  * @throws CHttpException
  */
 public function actionAdd($id = 0, $delivery = null)
 {
     if (!empty($id)) {
         $Cargo = Cargo::model()->findByPk($id);
         if (!Yii::app()->user->checkAccess('admin') && ((Yii::app()->getUser()->getProfile()->modules->head != \UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $Cargo->user->company_id) && (Yii::app()->getUser()->getProfile()->modules->cargo != '1' || $Cargo->user_id != Yii::app()->user->id) || Yii::app()->getUser()->getProfile()->company->active == '0')) {
             throw new CHttpException(403);
         }
         $AddressesForm = $Cargo->getAddressForm();
         $CostForm = $Cargo->getCostForm();
         $ContentManager = null;
     } else {
         if (Yii::app()->user->getProfile()->content_manager == '0') {
             if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != \UserModules::DIRECTOR_COMPANY && Yii::app()->getUser()->getProfile()->modules->cargo != '1' || Yii::app()->getUser()->getProfile()->company->active == '0')) {
                 throw new CHttpException(403);
             } elseif (!Yii::app()->getUser()->getProfile()->company->validate) {
                 $this->redirect('/complete');
             }
             $ContentManager = null;
         } else {
             $ContentManager = new ContentManager();
         }
         $Cargo = new Cargo();
         $AddressesForm = new AddressesForm();
         if (isset($delivery)) {
             $product = Product::model()->findByPk($delivery);
             $AddressesForm->from_1_name = $product->getEavAttribute('adres_name');
             $AddressesForm->from_1_address_lat = $product->getEavAttribute('adres_adress_lat');
             $AddressesForm->from_1_address_long = $product->getEavAttribute('adres_adress_long');
             $AddressesForm->from_1_ind = '';
         }
         $CostForm = new CostForm();
     }
     $contacts = User::getContact();
     $Cargo->contact_id = Yii::app()->user->id;
     if (!empty($_POST)) {
         $Cargo->setAttributes($_POST['Cargo'], false);
         $AddressesForm->setAttributes($_POST['AddressesForm'], false);
         if ($Cargo->price_asc == '0') {
             $CostForm->setAttributes($_POST['CostForm'], false);
         }
         if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
             $ContentManager->setAttributes($_POST['ContentManager'], false);
             $contentValid = $ContentManager->validate();
         } else {
             $contentValid = true;
         }
         $valid = $AddressesForm->validate();
         $valid = $Cargo->validate() && $CostForm->validate() && $valid && $contentValid;
         if (!$valid) {
             Yii::import('bootstrap.widgets.TbActiveForm');
             if ($ContentManager) {
                 echo TbActiveForm::validate(array($Cargo, $AddressesForm, $CostForm, $ContentManager));
             } else {
                 echo TbActiveForm::validate(array($Cargo, $AddressesForm, $CostForm));
             }
             Yii::app()->end();
         } else {
             if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
                 $Cargo->user_id = User::createFakeUser($ContentManager);
                 $Cargo->contact_id = $Cargo->user_id;
             }
             $Cargo->save();
             $_POST['Cargo']['type_transport'] = '';
             if (isset($Cargo->transport_type_id)) {
                 switch ($Cargo->transport_type_id) {
                     case 20:
                         $_POST['Cargo']['type_transport'] = $_POST['Cargo']['sea_transport'];
                         break;
                     case 21:
                         $_POST['Cargo']['type_transport'] = $_POST['Cargo']['zhd_transport'];
                         break;
                     case 22:
                         $_POST['Cargo']['type_transport'] = $_POST['Cargo']['air_transport'];
                         break;
                     case 72:
                         $_POST['Cargo']['type_transport'] = $_POST['Cargo']['river_transport'];
                         break;
                     default:
                         break;
                 }
             }
             $Cargo->setRelations($_POST['Cargo']);
             $Cargo->setAddress($AddressesForm);
             $Cargo->setCost($CostForm);
             $Cargo->autosearch();
             if ($_POST['Cargo']['customs_clearance'] == 1) {
                 if ($_POST['AddressesForm']['from_1_ind'] == 'RU') {
                     $_POST['AddressesForm']['from_1_ind'] = 'RUS';
                 }
                 if ($_POST['AddressesForm']['to_1_ind'] == 'RU') {
                     $_POST['AddressesForm']['to_1_ind'] = 'RUS';
                 }
                 if ($_POST['AddressesForm']['from_1_ind'] == 'CH') {
                     $_POST['AddressesForm']['from_1_ind'] = 'CHE';
                 }
                 if ($_POST['AddressesForm']['to_1_ind'] == 'CH') {
                     $_POST['AddressesForm']['to_1_ind'] = 'CHE';
                 }
                 $from = DictionaryData::model()->findByAttributes(['code' => $_POST['AddressesForm']['from_1_ind']]);
                 $to = DictionaryData::model()->findByAttributes(['code' => $_POST['AddressesForm']['to_1_ind']]);
                 $Custom = new Custom();
                 $Custom->type_id = $_POST['Cargo']['name_id'];
                 $Custom->packing_id = $_POST['Cargo']['packing_id'];
                 $Custom->country_from = isset($from) ? $from->id : 0;
                 $Custom->country_to = isset($to) ? $to->id : 0;
                 $Custom->weight_netto = $_POST['Cargo']['weight'];
                 $Custom->weight_brutto = $_POST['Cargo']['weight'];
                 $Custom->volume = $_POST['Cargo']['volume'];
                 $Custom->date_from = $_POST['Cargo']['when_from'];
                 $Custom->date_to = $_POST['Cargo']['when_to'];
                 $Custom->user_id = Yii::app()->user->id;
                 $Custom->contact_id = $_POST['Cargo']['contact_id'];
                 $Custom->save();
                 $Custom->autosearch();
             }
             if ($_POST['Cargo']['cargo_insurance'] == 1) {
                 $addrId = Yii::app()->db->createCommand()->select('address_id')->from('site_cargo_address u')->where('cargo_id=:cargo_id', array(':cargo_id' => $Cargo->cargo_id))->order('cargo_id ASC')->limit(1)->queryRow();
                 $addr = Address::model()->findByPk($addrId);
                 $Insurance = new Insurance();
                 $Insurance->category_id = 147;
                 $Insurance->address_id = $addr->address_id;
                 $Insurance->description = '';
                 $Insurance->contact_id = $_POST['Cargo']['contact_id'];
                 $Insurance->create = date('Y-m-d H:i:s');
                 $Insurance->user_id = Yii::app()->user->id;
                 $Insurance->date_to = $_POST['Cargo']['when_to'] != '' ? $_POST['Cargo']['when_to'] : '0000-00-00';
                 $Insurance->save();
                 $Insurance->autosearch();
             }
             echo CJSON::encode(array('status' => '500', 'redirect' => '/cargoaddsuccess/' . $Cargo->cargo_id));
             Yii::app()->end();
         }
     }
     $DictionaryData = \DictionaryData::model()->findAll('group_id=3');
     $this->render('add', ['Cargo' => $Cargo, 'addreses' => $AddressesForm, 'CostForm' => $CostForm, 'contacts' => $contacts, 'ContentManager' => $ContentManager, 'DictionaryData' => $DictionaryData]);
 }
 /**
  * Manages FAQ.
  *
  * @return void
  */
 public function actionFaq()
 {
     $model = new Feedback('search');
     $model->unsetAttributes();
     // clear any default values
     $model->setAttributes(Yii::app()->getRequest()->getParam('Feedback', array()));
     // Фильтрация по типу сообщения (отзывы)
     $type = DictionaryData::model()->findByCode('feedback-faq');
     if ($type === null) {
         $this->redirect($this->createUrl('/backend'));
     }
     $model->type_id = $type->id;
     Yii::app()->user->setState('prevUrl', Yii::app()->request->url);
     $this->render('index', array('model' => $model));
 }
Ejemplo n.º 11
0
 protected static function getDict($code)
 {
     return CHtml::listData(DictionaryData::model()->with(['group' => array('select' => false, 'condition' => 'group.code="' . $code . '"')])->findAll(), 'id', 'name');
 }
Ejemplo n.º 12
0
 protected function refreshProducts()
 {
     $categories = $this->productsArray;
     ItemToProduct::model()->deleteAllByAttributes(array('item_id' => $this->id));
     if (is_array($categories)) {
         foreach ($categories as $id) {
             if (DictionaryData::model()->exists('t.id = :id', array(':id' => $id))) {
                 $rel = new ItemToProduct();
                 $rel->item_id = $this->id;
                 $rel->dict_data_id = $id;
                 $rel->save();
             }
         }
     }
 }
Ejemplo n.º 13
0
 public function getCountryActiveList()
 {
     $dictionaryGroup = DictionaryGroup::model()->findByCode('country');
     if ($dictionaryGroup != null) {
         $criteria = new CDbCriteria();
         $criteria->compare('t.group_id', $dictionaryGroup->id);
         // Выбираем только те страны, которые присутствуют в каталоге
         $countryIds = array();
         $stones = Stone::model()->resetScope()->published()->type($this->type_id);
         if ($this->series_id !== null) {
             $stones = $stones->series($this->series_id);
         }
         if ($this->color_id !== null) {
             $stones = $stones->color($this->color_id);
         }
         $countryIds = CHtml::listData($stones->findAll(array('select' => 'country_id')), 'country_id', 'country_id');
         $criteria->addInCondition('t.id', array_keys($countryIds));
         // Сортировка
         $criteria->order = 't.sort ASC';
         $list = DictionaryData::model()->active()->findAll($criteria);
         return CHtml::listData($list, 'id', 'name');
     }
     return array();
 }
Ejemplo n.º 14
0
 public function getData()
 {
     return DictionaryData::model()->cache(Yii::app()->yupe->coreCacheTime)->findAll('group_id = :group_id', array(':group_id' => $this->id));
 }
Ejemplo n.º 15
0
 public function getData($order = 't.sort ASC')
 {
     return DictionaryData::model()->cache(Yii::app()->getModule('yupe')->coreCacheTime)->findAll(['condition' => 't.group_id = :group_id', 'params' => [':group_id' => $this->id], 'order' => $order]);
 }
 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));
     }
 }