Exemplo n.º 1
0
 public function actionIndex($id)
 {
     $model = Pages::model()->findByPk($id);
     if (!$model || $model->status == 0) {
         throw new CHttpException(404, 'The page can not be found.');
     }
     //Титл и SEO
     $this->setSEO($model->url, mb_convert_case($model->title, MB_CASE_UPPER, "UTF-8"));
     $this->layout = '//layouts/' . $model->main_template;
     $modelCatalog = null;
     $modelNews = null;
     //Если главная - добавляю товары помеченые как на главную и новости
     if ($model->main_page == 1) {
         $modelCatalog = CatalogElements::model()->findAll('`status` = 1 AND `primary` = 1');
         $modelNews = NewsElements::gatPrimaryNews();
     }
     //Проверка прав доступа
     if ($model->access_lvl > 0) {
         if (Yii::app()->user->isGuest) {
             $this->redirect('/login');
         }
     }
     //Проверяем есть ли фотогалерея, если есть - меняем содержимое страницы
     $model->content = $this->addPhotogalery($model->content);
     //Проверяем есть ли форма, если есть - меняем содержимое страницы
     $model->content = $this->addForm($model->content);
     //Получаем вкладки если есть;
     $modelTabs = PagesTabs::model()->getTabsContent($id);
     $this->render('index', array('model' => $model, 'modelTabs' => $modelTabs, 'modelCatalog' => $modelCatalog, 'modelNews' => $modelNews));
 }
Exemplo n.º 2
0
 /**
  * Получение кода для 3D картинок товара
  * @param $id
  */
 public function actionGetcodethreed($id)
 {
     $model = CatalogElements::model()->findByPk((int) $id);
     header('Content-Type: application/json');
     echo CJSON::encode(!empty($model) ? $model->code_3d : '');
     Yii::app()->end();
 }
Exemplo n.º 3
0
 public function actionUploaddata($id)
 {
     set_time_limit(0);
     $model = $this->loadModel($id);
     $catalog = null;
     //Для модуля Каталог, Двигатели, Трансмисия
     if ($model->module == 1) {
         $catalog = CatalogRubrics::model()->getRootIdAndName();
     }
     if ($model->module == 2) {
         $catalog = CatalogengineRubrics::model()->getRootIdAndName();
     }
     if ($model->module == 3) {
         $catalog = CatalogtransmissionRubrics::model()->getRootIdAndName();
     }
     if (isset($_POST['LoadxmlRubrics'])) {
         $err = 0;
         //$model->attributes = $_POST['LoadxmlRubrics'];
         $filepatch = YiiBase::getPathOfAlias('webroot') . '/../uploads/filestorage/loadxml/';
         $model->testedfile = CUploadedFile::getInstance($model, 'testedfile');
         if (!empty($model->testedfile)) {
             $ext = pathinfo($model->testedfile);
             $ext = $ext['extension'];
             if ($model->ext != $ext) {
                 if (($model->ext == 'xls' || $model->ext == 'xlsx') && ($ext == 'xls' || $ext == 'xlsx')) {
                     $err = 0;
                 } else {
                     $err = 1;
                     Yii::app()->user->setFlash('error', "Файл должен быть в формате: " . $model->ext);
                 }
             }
         } else {
             $err = 1;
             Yii::app()->user->setFlash('error', "Вы не выбрали файл");
         }
         if ($err == 0) {
             //Загружаем файл
             $filename = $model->testedfile->getName();
             $model->testedfile->saveAs($filepatch . $filename);
             //xls и xlsx
             if (preg_match("/.xls/i", $filename) || preg_match("/.xlsx/i", $filename)) {
                 $exel = new Parsfile();
                 $exel->pars_exel($filepatch . $filename);
                 $output = $exel->OutArr;
             }
             //xml
             if (preg_match("/.xml/i", $filename)) {
                 $xml = new Parsfile();
                 $xml->pars_xml($filepatch . $filename, $model->tag);
                 $output = $xml->XmlFieldsHash;
             }
             //csv
             if (preg_match("/.csv/i", $filename)) {
                 $csv = new Parsfile();
                 $splitter = LoadxmlRubrics::model()->getSplitter((int) $model->splitter);
                 $csv->pars_csv($filepatch . $filename, $splitter);
                 $output = $csv->OutArr;
             }
             //модуль каталог
             if ($model->module == 1 || $model->module == 2 || $model->module == 3) {
                 $table_pref = "tbl_";
                 if ($model->module == 1) {
                     $table = "catalog_elements";
                 }
                 //Для модуля Каталог
                 if ($model->module == 2) {
                     $table = "catalogengine_elements";
                 }
                 //Для модуля Двигатели
                 if ($model->module == 3) {
                     $table = "catalogtransmission_elements";
                 }
                 //Для модуля Трансмисия
                 // Вычисляем, какие столбцы нужно обходить циклом для группировки значений
                 $groups_need = array();
                 if (!empty($model->groups)) {
                     $list_groups = unserialize($model->groups);
                     $cnt_list = count($list_groups);
                     $group_i = 0;
                     for ($i = 1; $i <= $cnt_list; ++$i) {
                         if ($list_groups[$i]) {
                             $groups_need[$group_i] = $i;
                             // создаем массив с номерами нужных столбцов
                             ++$group_i;
                         }
                     }
                 }
                 $count_need = count($groups_need);
                 // кол-во нужных столбов
                 $count_table = count($output);
                 // кол-во строк в таблице
                 $val_arr_group = array();
                 // массив значений для группировки
                 $val_arr_cnt = array();
                 // массив для хранения кол-ва записей группировки
                 $val_arr_group_r = array();
                 // массив значений для группировки
                 if ($count_need > 0) {
                     for ($j = 1; $j <= $count_table; ++$j) {
                         for ($i = 0; $i <= $count_need; ++$i) {
                             $group_id = $groups_need[$i];
                             $group_cnt = intval($val_arr_cnt[$group_id]);
                             $read_vars = trim($output[$j][$group_id]);
                             $read_vars_alt = $this->totranslit($read_vars);
                             if (!in_array($read_vars_alt, $val_arr_group[$group_id]) and $read_vars_alt) {
                                 $val_arr_group[$group_id][$group_cnt] = $read_vars_alt;
                                 // записываем в массив значение
                                 $val_arr_group_r[$group_id][$group_cnt]['name'] = $read_vars;
                                 $val_arr_group_r[$group_id][$group_cnt]['alt_name'] = $read_vars_alt;
                                 ++$group_cnt;
                                 $val_arr_cnt[$group_id] = $group_cnt;
                                 // записываем в массив кол-во записей
                             }
                         }
                     }
                 }
                 //надо очищать каталог перед импортом - сдеать вызов тут
                 if (isset($_POST['LoadxmlRubrics']['clearsect']) && (int) $_POST['LoadxmlRubrics']['clearsect'] == 1 && (int) $_POST['LoadxmlRubrics']['parent_id'] > 0) {
                     if ($model->module == 1) {
                         CatalogElements::model()->deleteAll("`parent_id` = :parent_id", array(':parent_id' => (int) $_POST['LoadxmlRubrics']['parent_id']));
                     }
                     if ($model->module == 2) {
                         CatalogengineElements::model()->deleteAll("`parent_id` = :parent_id", array(':parent_id' => (int) $_POST['LoadxmlRubrics']['parent_id']));
                     }
                     if ($model->module == 3) {
                         CatalogtransmissionElements::model()->deleteAll("`parent_id` = :parent_id", array(':parent_id' => (int) $_POST['LoadxmlRubrics']['parent_id']));
                     }
                 }
                 /*
                 foreach ($val_arr_group_r as $keys_in ) {
                     foreach ( $keys_in as $test ) {
                         $nde = array();
                         $nde['name'] = trim($test['name']);
                         $nde['page_name'] = $test['name'];
                         $nde['url'] = strtolower($test['alt_name']);
                         if ((int)$_POST['LoadxmlRubrics']['parent_id']>0){
                             $category = new CatalogRubrics;
                             $category->name = $nde['name'];
                             $category->page_name = $nde['page_name'];
                             $category->url = $nde['url'];
                             $category->parent_id = (int)$_POST['LoadxmlRubrics']['parent_id'];
                             $root = CatalogRubrics::model()->findByPk($category->parent_id);
                             $category->appendTo($root);
                         }
                     }
                 }
                 */
                 $MainFields = null;
                 $fields = explode('|', $model->content2);
                 $FieldCount = 0;
                 foreach ($fields as $k => $v) {
                     if (isset($v[0]) && !empty($v[0])) {
                         $subfields = explode('%', $v);
                         $MainFields2[$k] = $subfields;
                         if ($model->ext == 'xml') {
                             $subfields[1] = $xml->XmlAntiMap[$subfields[1]];
                         }
                         $MainFields[$k] = $subfields;
                         $FieldCount++;
                     }
                 }
                 $uniqKey = '';
                 foreach ($MainFields as $mk => $mv) {
                     if ($mv[0] == $model->unique && $model->unique != '') {
                         $uniqKey = $model->unique;
                     }
                 }
                 //Пишем данные в таблицы
                 foreach ($output as $k => $v) {
                     $sett = '';
                     $setv = '';
                     $UniqField = '';
                     $WriteFlag = 1;
                     foreach ($MainFields as $K => $V) {
                         $val = '';
                         if ($model->ext == 'xml') {
                             $xml_field = $MainFields2[$K][1];
                             $val = $xml->XmlFieldsHash[$k][$xml_field];
                             if ($V[1] == 3) {
                                 $val = preg_replace("/[^1234567890.,]/", '', $val);
                                 $vall = preg_replace("/\\,]/", '.', $val);
                             }
                             if ($V[1] == 2) {
                                 if (trim($xml->XmlFieldsHash[$k][$xml_field]) == '') {
                                     $val = '';
                                 } else {
                                     $val = 1;
                                 }
                             }
                         } else {
                             $val = $v[$V[1]];
                             if ($V[2] == 3) {
                                 $val = preg_replace("/[^1234567890.,]/", '', $val);
                                 $vall = preg_replace("/\\,]/", '.', $val);
                             }
                             if ($V[2] == 2) {
                                 if (trim($v[$V[2] - 1]) == '') {
                                     $val = '';
                                 } else {
                                     $val = 1;
                                 }
                             }
                         }
                         //print $val."||||<br/>";
                         if ($sett == '') {
                             $sett .= " `{$V['0']}` ";
                         } else {
                             $sett .= ", `{$V['0']}` ";
                         }
                         if ($setv == '') {
                             $setv .= " '" . $val . "' ";
                         } else {
                             $setv .= ", '" . addslashes($val) . "' ";
                         }
                         if ($V[0] == $uniqKey && $V[0] != '') {
                             $UniqField = $uniqKey;
                             $resultU = Yii::app()->db->createCommand()->select('*')->from('{{' . $table . '}}')->where(" `" . $UniqField . "` = '" . $val . "'")->queryAll();
                             foreach ($resultU as $rowU) {
                                 if ($rowU['id'] != '') {
                                     Yii::app()->db->createCommand()->delete("`" . $table . "`", 'id=:id', array(':id' => $rowU['id']));
                                 }
                             }
                         }
                         if ($V[3] != '') {
                             //if($val == ''){$WriteFlag = 0;}
                         }
                     }
                     $sett .= ',`parent_id` ';
                     $setv .= ", '" . (int) $_POST['LoadxmlRubrics']['parent_id'] . "' ";
                     if ($WriteFlag != '0') {
                         $sql = "INSERT INTO " . $table_pref . $table . " ({$sett}) VALUES ({$setv})";
                         Yii::app()->db->createCommand($sql)->execute();
                     } else {
                         print "0 <br/>";
                     }
                 }
             }
             Yii::app()->user->setFlash('success', "Данные загружены");
         }
     }
     $this->render('uploaddata', array('model' => $model, 'catalog' => $catalog));
 }
Exemplo n.º 4
0
 /**
  * @param null $id - id элемента
  * @param null $type_parent - тип элемента: 1-категория, 2-товар
  */
 public function actionListchars($id = null, $type_parent = 1)
 {
     $this->breadcrumbs = array($type_parent == 1 ? 'Группы товаров' : 'Список товаров' => array('/catalog/catalog/listgroup'), 'Свойства ' => array('/catalog/catalog/listchars?id=' . (int) $id . '&type_parent=' . $type_parent));
     $model = new CatalogChars('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['CatalogChars'])) {
         $model->attributes = $_GET['CatalogChars'];
     }
     $object_name = '';
     if (!empty($id)) {
         switch ($type_parent) {
             case 1:
                 $object_name = CatalogRubrics::model()->findByPk($id)->name;
                 break;
             case 2:
                 $object_name = CatalogElements::model()->findByPk($id);
                 //Применяем к выбраному товару все характеристики которые есть у родительского каталога
                 $modelCharsAppend = CatalogChars::model()->findAll('parent_id = ' . $object_name->parent_id);
                 foreach ($modelCharsAppend as $tmp_model_chrs) {
                     CatalogChars::model()->applyCategoryChars($id, $type_parent, $tmp_model_chrs);
                 }
                 $object_name = $object_name->name;
                 break;
         }
     }
     $param[] = 'is_deleted = 0';
     if (!empty($id)) {
         $param[] = 'parent_id = ' . $id;
     }
     $param[] = 'type_parent = ' . $type_parent;
     $data['sort'] = array('defaultOrder' => 'id DESC');
     $data['Pagination'] = array('PageSize' => 100);
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 4')) {
         $data['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 100);
     }
     $provider = new CActiveDataProvider('CatalogChars', $data);
     $param = implode(" AND ", $param);
     $provider->criteria = $model->search($param);
     $this->render('listchars', array('model' => $model, 'provider' => $provider, 'object_name' => $object_name, 'type_parent' => $type_parent));
 }
Exemplo n.º 5
0
 public function actionIndex()
 {
     //Не оформленые товары
     //$modelBasketOrder = BasketOrder::model()->find('status=0 AND user_id = '.(int)Yii::app()->user->id);
     //$modelBasket = BasketItems::model()->findAll('basket_order_id='.$modelBasketOrder->id);
     $modelBasketOrder = new BasketOrder();
     $modelBasket = new BasketItems();
     $product = array();
     //Тянем из куки заказаные товары
     $cookies = Yii::app()->request->cookies;
     $basket = array();
     if (isset($cookies['basket'])) {
         $basket = $cookies['basket']->value;
         $basket = unserialize($basket);
     }
     if (isset($_POST['BasketOrder']) || isset($cookies['basket_addres'])) {
         if (isset($_POST['BasketOrder'])) {
             $basket_addres = array();
             $basket_addres['address'] = $_POST['BasketOrder']['address'];
             $basket_addres['phone'] = $_POST['BasketOrder']['phone'];
             $basket_addres['comments'] = $_POST['BasketOrder']['comments'];
             $basket_addres = new CHttpCookie('basket_addres', serialize($basket_addres));
             $cookies['basket_addres'] = $basket_addres;
         }
         //Если пользователь не авторизован - перенаправляем на авторизацию
         if (Yii::app()->user->isGuest) {
             $this->redirect('/login');
         }
         //Получаем значения из куки
         $basket = $cookies['basket']->value;
         $basket = unserialize($basket);
         $basket_addres = $cookies['basket_addres']->value;
         $basket_addres = unserialize($basket_addres);
         //Убиваем куки
         unset($cookies['basket']);
         unset($cookies['basket_addres']);
         //Пишим в БД
         $modelBasketOrder->user_id = Yii::app()->user->id;
         $modelBasketOrder->address = $basket_addres['address'];
         $modelBasketOrder->phone = $basket_addres['phone'];
         $modelBasketOrder->comments = $basket_addres['comments'];
         $modelBasketOrder->status = 1;
         $modelBasketOrder->status_at = date('Y-m-d H:i:s');
         if ($modelBasketOrder->save()) {
             foreach ($basket as $key => $val) {
                 $modelBasket = new BasketItems();
                 $modelBasket->basket_order_id = $modelBasketOrder->id;
                 $modelBasket->module = $val['module'];
                 $modelBasket->url = $val['url'];
                 $modelBasket->quantity = (int) $val['quantity'];
                 $modelBasket->item = $val['item'];
                 //Цена есть в куки, но мы ее пересчитаем сами - защита от "умных" пользователей
                 $modelBasket->price = BasketItems::model()->returnPrice($modelBasket->item, $modelBasket->quantity);
                 $modelBasket->trueprice = CatalogElements::model()->findByPk($val['item'])->price;
                 $modelBasket->save();
             }
             //отправляем письмо админу о заказе
             $this->sendEmailAdmin($modelBasketOrder->id);
             $this->redirect('/basket/success');
         }
     }
     $i = 0;
     $discount = array();
     foreach ($basket as $key => $val) {
         //Получаем о товаре данные
         $table_name = 'catalog_elements';
         $requests = Yii::app()->db->createCommand()->select('name, code, qty, price, price_entering')->from('{{' . $table_name . '}}')->where('id = ' . (int) $val['item'])->queryRow();
         $product[$i]['element'] = (int) $val['item'];
         $product[$i]['key'] = $key;
         $product[$i]['quantity'] = $val['quantity'];
         $product[$i]['name'] = $requests['name'];
         $product[$i]['code'] = $requests['code'];
         $product[$i]['qty'] = $requests['qty'];
         $product[$i]['price'] = $val['price'];
         ++$i;
     }
     if (!Yii::app()->user->isGuest) {
         $user_data = User::model()->findByPk(Yii::app()->user->id);
         $modelBasketOrder->phone = $user_data->phone;
         $modelBasketOrder->address = !empty($modelBasketOrder->address) ? $modelBasketOrder->address : $user_data->fiz_addres;
     }
     $this->render('index', array('model' => $product, 'discount' => $discount, 'modelBasketOrder' => $modelBasketOrder));
 }
Exemplo n.º 6
0
 /**
  * Получение количества записей в категории
  *
  * @param $category
  * @return int|mixed
  */
 public static function getTotalCountElement($category)
 {
     $total = 0;
     if (is_int($category)) {
         $category = CatalogRubrics::model()->findByPk($category);
     }
     if (!empty($category)) {
         $branch = CatalogRubrics::getBranch($category->left_key, $category->right_key);
         foreach ($branch as $branchRow) {
             $ids[] = $branchRow->id;
         }
         if (!empty($ids)) {
             $total = Yii::app()->db->createCommand()->select('COUNT(*)')->from(CatalogElements::model()->tableName())->where(array('in', 'parent_id', $ids))->queryScalar();
         }
     }
     return $total;
 }
Exemplo n.º 7
0
<?php 
echo CHtml::activeDropDownList($model, 'filterData', $catalog, array('class' => 'span5', 'encode' => false));
?>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = CatalogElements::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'productlist-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'htmlOptions' => array('class' => 'content_table'), 'dataProvider' => $provider, 'filter' => $model, 'columns' => array(array('class' => 'CCheckBoxColumn', 'selectableRows' => 2, 'checkBoxHtmlOptions' => array('class' => 'selectProduct')), array('header' => 'Картинка', 'name' => "image", 'type' => 'raw', 'value' => function ($dataProvider) {
    $url_img = '/images/nophoto_100_100.jpg';
    if (file_exists(YiiBase::getPathOfAlias('webroot') . '/../uploads/filestorage/catalog/elements/admin-' . $dataProvider->id . '.' . $dataProvider->image)) {
        $url_img = '/../uploads/filestorage/catalog/elements/admin-' . $dataProvider->id . '.' . $dataProvider->image;
    }
    return '<img src="' . $url_img . '" style="width:80px" />';
}, 'filter' => ''), array('header' => 'Наименование элемента', 'name' => "serch_name_code", 'type' => 'raw', 'value' => function ($dataProvider) {
    $result = '<a class="page_url" href="/' . Pages::getBaseUrl(4) . CatalogElements::model()->getProductUrl($dataProvider) . '" style="margin-left: 20px;" target="_preview">' . $dataProvider->name . '</a></BR>';
    return $result;
}, 'filter' => CHtml::textField('CatalogElements[serch_name_code]', '', array('style' => 'width:100%', 'placeholder' => 'Введите название'))), array('header' => 'Цена', 'name' => "price", 'type' => 'raw', 'value' => function ($data) {
    return CHtml::textField('price_' . $data->id, $data->price, array("class" => "price", "data-id" => $data->id, "data-price" => $data->price));
}, 'filter' => ''), array('header' => 'Порядок', 'name' => 'order_id', 'value' => function ($data) {
    return CHtml::textField('order_' . $data->id, $data->order_id, array("class" => "order", "data-id" => $data->id, "data-order" => $data->order_id));
}, 'type' => 'raw'), array('header' => 'Статус', 'name' => "status", 'type' => 'raw', 'value' => function ($data) {
    return '
                    <a href="#" class="on-off-product" data-id="' . $data->id . '" data-status="' . $data->status . '">
                        <div style="margin-left:20px; width: 13px; height: 13px; border-radius: 3px; background:' . ($data->status == 1 ? 'green' : 'red') . '"></div>
                    </a>
                ';
}, 'filter' => ''), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update_product}  {edit_chars}  {discount}  {delete_product}', 'buttons' => array('update_product' => array('label' => '', 'options' => array('data-toggle' => 'tooltip', 'class' => 'icon-pencil', 'title' => 'Редактировать'), 'url' => 'Yii::app()->createUrl("' . Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/updateproduct", array("id"=>$data->id))'), 'edit_chars' => array('label' => '', 'options' => array('data-toggle' => 'tooltip', 'class' => 'icon-cog', 'title' => 'Редактировать свойства'), 'url' => 'Yii::app()->createUrl("' . Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/listchars", array("id"=>$data->id, "type_parent"=>2))'), 'discount' => array('label' => '', 'options' => array('data-toggle' => 'tooltip', 'class' => 'icon-gift', 'title' => 'Скидки на товар'), 'url' => 'Yii::app()->createUrl("' . Yii::app()->controller->module->id . '/catalogelementsdiscount/index", array("CatalogElementsDiscount[element_id]"=>$data->id))'), 'delete_product' => array('label' => '', 'options' => array('data-toggle' => 'tooltip', 'class' => 'icon-trash', 'title' => 'Удалить'), 'url' => 'Yii::app()->createUrl("' . Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/deleteproduct", array("id"=>$data->id))')), 'htmlOptions' => array('style' => 'white-space: nowrap')))));
?>

<div id="ajax_loader" style="display: none;"><img width="40px;" style="position:absolute; margin-top:10px; margin-left:-40px;" src="/images/admin/ajaxloader.gif"></div>
Exemplo n.º 8
0
		<div class="clear"></div>
	</div>

<h1 class="lined nopaddingtop" style="margin-top: 10px;"><?php 
echo Pages::getTitle();
?>
</h1>



<div class="tovar_container">
	<?php 
foreach ($elements as $data) {
    ?>
		<?php 
    $url_product = CatalogElements::model()->getProductUrl($data);
    ?>
		<div class="items-block-item">
			<a href="<?php 
    echo $url_product;
    ?>
" class="items-block-item-img">
				<div class="rollover">
					<?php 
    if ($data->shares == 1) {
        ?>
						<div class="shares"></div>
					<?php 
    }
    ?>
					<img src="<?php 
Exemplo n.º 9
0
 /**
  * Расчитывает цену товара УЖЕ со скидками, если они предоставлены
  * $element_id - ID товара
  * $count - количество товаров заказное пользователем (нужно для получения данных о скидках)
  */
 public function returnPrice($element_id, $count)
 {
     $return_price = CatalogElements::model()->findByPk((int) $element_id)->price;
     $price = $return_price;
     //Расчитываем цену 1единицы товара  (с учетом скидок)
     foreach (CatalogElementsDiscount::model()->findAll('element_id = ' . (int) $element_id . ' AND status = 1') as $data_discount) {
         $price = $price - CatalogElementsDiscount::model()->returnDiscount($return_price, $count, $data_discount);
     }
     $return_price = $price;
     return $return_price;
 }
Exemplo n.º 10
0
 public function actionIndex()
 {
     $model = array();
     $data[] = array();
     $data['model_elements'] = array();
     if (isset($_GET['s']) && !empty($_GET['s']) && strlen(trim($_GET['s']))) {
         $pattern = trim($_GET['s']);
         $pattern_orig = $pattern;
         $pattern = '/' . $pattern . '/i';
         $page = isset($_GET['page']) ? intval($_GET['page']) : 0;
         $data['page'] = $page;
         //Ищем в каталоге
         $crubrics = CatalogRubrics::model()->findAll('status=1');
         $data['allow_rubrics'] = array();
         foreach ($crubrics as $datas) {
             if ($this->compares($pattern_orig, $datas->name)) {
                 $data['allow_rubrics'][] = $datas->id;
             }
         }
         foreach ($data['allow_rubrics'] as $allow_rubric) {
             $celements = CatalogElements::model()->findAll('status=1 AND parent_id = ' . intval($allow_rubric));
             foreach ($celements as $datas) {
                 if ($this->compares($pattern_orig, $datas->name) && !isset($data['model_elements'][$datas->id])) {
                     $data['model_elements'][$datas->id] = $datas;
                 }
             }
             foreach ($celements as $datas) {
                 if ($this->compares($pattern_orig, $datas->description) && !isset($data['model_elements'][$datas->id])) {
                     $data['model_elements'][$datas->id] = $datas;
                 }
             }
         }
         $celements = CatalogElements::model()->findAll('status=1');
         foreach ($celements as $datas) {
             if ($this->compares($pattern_orig, $datas->name) && !isset($data['model_elements'][$datas->id])) {
                 $data['model_elements'][$datas->id] = $datas;
             }
         }
         foreach ($celements as $datas) {
             if ($this->compares($pattern_orig, $datas->description) && !isset($data['model_elements'][$datas->id])) {
                 $data['model_elements'][$datas->id] = $datas;
             }
         }
         $count = count($data['model_elements']) - 12;
         $criteria = new CDbCriteria();
         $pages = new CPagination($count);
         $pages->pageSize = 12;
         $pages->applyLimit($criteria);
         $data['pages'] = $pages;
     }
     $this->render('index', $data);
 }
Exemplo n.º 11
0
<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'catalog-elements-discount-form', 'enableAjaxValidation' => false, 'enableClientValidation' => false, 'type' => 'horizontal'));
?>

    <!-- Fields with <span class="required">*</span> are required. -->
	<!--<p class="help-block"><?php 
echo Yii::t("Bootstrap", "PHRASE.FIELDS_REQUIRED");
?>
</p>-->

	<?php 
echo $form->errorSummary($model);
?>

<?php 
echo $form->dropDownListRow($model, "element_id", CHtml::listData(CatalogElements::model()->findAll(), "id", "name"), array('class' => 'span5', "empty" => "Не выбран"));
?>


<?php 
echo $form->textFieldRow($model, 'count', array('class' => 'span5', 'maxlength' => 11));
?>

<?php 
echo $form->textFieldRow($model, 'values', array('class' => 'span5', 'maxlength' => 10));
?>

<?php 
echo $form->dropDownListRow($model, "type", CatalogElementsDiscount::model()->getType(), array('class' => 'span5'));
?>
Exemplo n.º 12
0
    </main>




<div class="tovar_container">
<?php 
    $i = 0;
    foreach ($model_elements as $data) {
        $i++;
        //echo 'i = '.$i.'<br>';
        if ($i <= $page * 12 || $i > ($page + 1) * 12) {
            //echo 'continue<br>';
            continue;
        }
        $url = Yii::app()->urlManager->createUrl('/catalog/catalog') . CatalogElements::model()->getProductUrl($data);
        $url_img = '/images/nophoto_100_100.jpg';
        $filename = YiiBase::getPathOfAlias('webroot') . '/uploads/filestorage/catalog/elements/' . $data->id . '.' . $data->image;
        if (file_exists($filename)) {
            $url_img = '/uploads/filestorage/catalog/elements/' . $data->id . '.' . $data->image;
        }
        $name_noqoutes = $data->name;
        $name_noqoutes = str_replace("'", '', $name_noqoutes);
        $name_noqoutes = str_replace('"', '', $name_noqoutes);
        $name_noqoutes = htmlspecialchars($name_noqoutes, ENT_QUOTES);
        $name_noqoutes = str_replace('&#039;', '', $name_noqoutes);
        ?>
	<div class="items-block-item">
		<a href="<?php 
        echo $url;
        ?>
Exemplo n.º 13
0
<legend>
    Скидки на товары.
    <?php 
if (!empty($model->element_id)) {
    ?>
            <BR>Товар: <a href="/admin/catalog/catalog/updateproduct?id=<?php 
    echo (int) $model->element_id;
    ?>
" target="_blank"><?php 
    echo CatalogElements::model()->findByPk((int) $model->element_id)->name;
    ?>
</a>
    <?php 
}
?>
</legend>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = CatalogElementsDiscount::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'catalog-elements-discount-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->search(), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array("id", array('header' => $labels["element_id"], 'name' => "element_id", 'type' => 'raw', 'value' => function ($data) {
    return !empty($data->element) ? CHtml::link($data->element->name, '/admin/catalog/catalog/updateproduct?id=' . $data->element_id) : '-';
}, 'filter' => ''), "count", "values", array('header' => $labels["type"], 'name' => "type", 'value' => 'CatalogElementsDiscount::model()->getType($data->type)'), array('header' => $labels["user_role_id"], 'name' => "user_role_id", 'value' => '$data->user_role_id==0?"Все":CatalogElementsDiscount::model()->getUserRole($data->user_role_id)'), array('header' => 'Статус', 'name' => "status", 'type' => 'raw', 'value' => function ($data) {
    return '
                    <a href="#" class="on-off-product" data-id="' . $data->id . '" data-status="' . $data->status . '">
                        <div style="margin-left:20px; width: 13px; height: 13px; border-radius: 3px; background:' . ($data->status == 1 ? 'green' : 'red') . '"></div>
                    </a>
                ';
}, 'filter' => ''), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update}  {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap')))));
?>
Exemplo n.º 14
0
 public function getFeeldsContent2($module)
 {
     //$module: 1- каталог, 2-двигатели, 3-коробка передач
     $result = array();
     switch ($module) {
         case 1:
             $result = CatalogElements::model()->attributeLabels();
             break;
         case 2:
             $result = CatalogengineElements::model()->attributeLabels();
             break;
         case 3:
             $result = CatalogtransmissionElements::model()->attributeLabels();
             break;
     }
     if (isset($result['id'])) {
         unset($result['id']);
     }
     return $result;
 }
Exemplo n.º 15
0


                        </div>
                    </div>
-->
                    <div class="items-block-new">
                        <h1 class="lined">Новинки рынка</h1>
                        <div class="tovar_container">



<?php 
$model_CatalogElements = CatalogElements::model()->findAll('status = 1 ORDER BY order_id LIMIT 0,12');
foreach ($model_CatalogElements as $element_item) {
    $element = CatalogElements::model()->getProduct($element_item->id);
    if (isset($element['url'])) {
        $url = '/catalog' . $element['url'] . '/' . $element_item->id;
    }
    $modelRubric = CatalogRubrics::model()->find('id=' . $element_item->parent_id);
    $filename = '/uploads/filestorage/catalog/elements/' . $element_item->id . '.' . $element_item->image;
    $name_noqoutes = $element_item->name;
    $name_noqoutes = str_replace("'", '', $name_noqoutes);
    $name_noqoutes = str_replace('"', '', $name_noqoutes);
    $name_noqoutes = htmlspecialchars($name_noqoutes, ENT_QUOTES);
    $name_noqoutes = str_replace('&#039;', '', $name_noqoutes);
    ?>
	<div class="items-block-item">
		<div class="item-label new-product">new</div>
		<a href="<?php 
    echo $url;