public function actionView($id) { $modelUser = User::findOne(['id' => $id, 'status' => User::STATUS_ACTIVE]); $modelUserProfile = UserProfile::findOne(['user_id' => $modelUser->id]); $queryProducts = CatalogProducts::find()->where(['published' => true]); $queryProducts->andWhere(['createdby' => $modelUser->id]); $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $queryProducts->count()]); $elements = $queryProducts->orderBy('publishedon' . ' ' . 'desc')->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('viewOwner', ['modelUser' => $modelUser, 'modelUserProfile' => $modelUserProfile, 'elements' => $elements, 'pagination' => $pagination]); }
/** * Updates an existing Gallery model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if (CatalogProducts::findOne($model->table_id)->createdby == \Yii::$app->user->getId()) { if ($model->load(Yii::$app->request->post())) { if ($model->save()) { $this->actionUpload($model); return $this->redirect(['index', 'table_id' => $model->table_id]); } else { return $this->render('update', ['model' => $model, 'table_id' => $model->table_id]); } } else { return $this->render('update', ['model' => $model, 'table_id' => $model->table_id]); } } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionSearch($q, $sortname = 'price', $sortdirection = 'asc', $pageSize = 20, $condition = '', $render = 'index', $tpl = 'main') { $ajax = Yii::$app->request->post('ajax'); $q_lower = mb_strtolower($q, 'UTF-8'); $qstring = " LOWER (`name`) LIKE '%{$q_lower}%'"; $qstring .= " OR LOWER (`price`) LIKE '%{$q_lower}%'"; $qstring .= " OR LOWER (`introtext`) LIKE '%{$q_lower}%'"; $qstring .= " OR LOWER (`content`) LIKE '%{$q_lower}%'"; $query = CatalogProducts::find()->where(['isparent' => false, 'status' => CatalogProducts::STATUS_PUBLISHED]); $query->andWhere($condition); $query->andWhere($qstring); $pagination = new Pagination(['defaultPageSize' => $pageSize, 'totalCount' => $query->count()]); $elements = $query->orderBy($sortname . ' ' . $sortdirection)->offset($pagination->offset)->limit($pagination->limit)->all(); if ($ajax) { return $this->renderAjax($render, ['elements' => $elements, 'pagination' => $pagination, 'parent' => $parent, 'sortname' => $sortname, 'sortdirection' => $sortdirection, 'tpl' => $tpl, 'condition' => $condition, 'search' => $q]); } else { return $this->render($render, ['elements' => $elements, 'pagination' => $pagination, 'parent' => $parent, 'sortname' => $sortname, 'sortdirection' => $sortdirection, 'tpl' => $tpl, 'condition' => $condition, 'search' => $q]); } }
$count = 0; } ?> <li><?php echo Html::a($element_name, ['/catalog/site/index', 'parent' => $element_id]); ?> </li> <?php } ?> </ul> </div> </div> <div class="col1"> <?php echo Html::img(File::thumb(CatalogProducts::findOne($category_id)['image'], 300, 300)); ?> </div> </div> </div> </li> <?php } ?> </ul> </div> <!-- <div class="cart box_1"> <a href="checkout.html"> <h3> <div class="total"> <span class="simpleCart_total"></span> (<span id="simpleCart_quantity" class="simpleCart_quantity"></span> items)</div> <img src="images/cart.png" alt=""/></h3>
relative f_xs_none m_xs_bottom_5"><?php echo Html::a('<b>Главная</b>', Yii::$app->homeUrl, ['class' => 'tr_delay_hover color_light tt_uppercase']); ?> </li> <li class="<?php echo Yii::$app->request->url === Url::to(['/content/site/view-by-url', 'url' => 'о-нас', 'view' => 'view']) ? 'current' : ''; ?> relative f_xs_none m_xs_bottom_5"><?php echo Html::a('<b>О нас</b>', ['/content/site/view-by-url', 'url' => 'о-нас', 'view' => 'view'], ['class' => 'tr_delay_hover color_light tt_uppercase']); ?> </li> <li class="relative f_xs_none m_xs_bottom_5"><a href="#" class="tr_delay_hover color_light tt_uppercase"><b>Каталог товаров</b></a> <div class="sub_menu_wrap top_arrow d_xs_none type_2 tr_all_hover clearfix r_corners"> <ul class="sub_menu"> <?php foreach (CatalogProducts::findAll(['parent' => 0, 'isparent' => true, 'status' => CatalogProducts::STATUS_PUBLISHED]) as $model) { ?> <?php echo Html::tag('li', Html::a($model->name, ['/catalog/site/index', 'parent' => $model->id], ['class' => 'color_dark tr_delay_hover'])); ?> <?php } ?> </ul> </div> </li> <li class="relative f_xs_none m_xs_bottom_5"><a href="#" class="tr_delay_hover color_light tt_uppercase"><b>Наши услуги</b></a> <!--sub menu--> <div class="sub_menu_wrap top_arrow d_xs_none type_2 tr_all_hover clearfix r_corners"> <ul class="sub_menu"> <?php
} ?> </div> </figure> <!--Bestsellers--> <figure class="widget shadow r_corners wrapper m_bottom_30"> <figcaption> <h3 class="color_light">Наши товары</h3> </figcaption> <div class="widget_content"> <?php $first = true; ?> <?php foreach (CatalogProducts::find()->where(['isparent' => false, 'status' => CatalogProducts::STATUS_PUBLISHED])->orderBy('RAND()')->limit(4)->all() as $model) { ?> <?php echo $first ? '<hr class="m_bottom_15">' : ''; ?> <?php $first = false; ?> <div class="clearfix m_bottom_15"> <?php echo Html::img(Image::thumb($model->image, 80, 80), ['class' => 'f_left m_right_15 m_sm_bottom_10 f_sm_none f_xs_left m_xs_bottom_0']); ?> <?php echo Html::a($model->name, ['/catalog/site/view-by-url', 'url' => $model->seo_url], ['class' => 'color_dark d_block bt_link']); ?>
<section class="products_container a_type_2 clearfix m_bottom_25"> <?php $parentid = 0; ?> <?php foreach ($elements as $model) { ?> <?php if ($parentid != $model->parent) { ?> <?php $parentid = $model->parent; ?> </section> <h2><?php echo CatalogProducts::findOne(['id' => $model->parent])->name; ?> </h2> <hr class="m_bottom_10 divider_type_3"> <section class="products_container a_type_2 clearfix m_bottom_25"> <?php } ?> <!--product item--> <div class="product_item w_xs_full"> <figure class="r_corners photoframe animate_ftb type_2 t_align_c tr_all_hover shadow relative"> <?php echo Html::a(Html::img(Image::thumb($model->image, 242, 242), ['class' => 'tr_all_hover']), ['view-by-url', 'url' => $model->seo_url], ['class' => '_block relative pp_wrap m_bottom_15']); ?> <figcaption>
<?php use yii\helpers\Html; use yii\helpers\Url; use common\modules\catalog\models\CatalogProducts; use common\modules\filemanager\models\File; $parentModel = CatalogProducts::findOne($model->parent); $this->title = \Yii::$app->name . ' - ' . $model->name; $this->params['breadcrumbs'][] = ['label' => $parentModel->name, 'url' => ['index', 'parent' => $parentModel->id]]; $this->params['breadcrumbs'][] = $model->name; ?> <div class="single"> <div class="col-md-9 top-in-single"> <div class="col-md-5 single-top"> <?php echo Html::img(File::thumb($model->image, 255, 255), ['class' => 'img-responsive']); ?> </div> <div class="col-md-7 single-top-in"> <div class="single-para"> <h4> <?php echo $model->name; ?> </h4> <p> <?php echo $model->introtext; ?>
</a> </div> <?php } ?> </section> <!--/products--> </div> <div class="clearfix m_bottom_10 m_sm_bottom_20" style="padding-top:30px;"> <h2 class="tt_uppercase color_dark f_left heading2 animate_fade f_mxs_none m_mxs_bottom_15">Акция дня <b>-30%</b></h2> </div> <section class="products_container a_type_2 clearfix m_bottom_25"> <?php foreach (CatalogProducts::find()->where(['isparent' => false, 'status' => CatalogProducts::STATUS_PUBLISHED, 'discont' => true])->limit(4)->all() as $model) { ?> <!--product item--> <div class="product_item w_xs_full"> <figure class="r_corners photoframe animate_ftb type_2 t_align_c tr_all_hover shadow relative"> <a href="#" class="d_block relative pp_wrap m_bottom_15"> <?php echo Html::img(File::thumb($model->image, 242, 242), ['class' => 'tr_all_hover']); ?> </a> <figcaption> <h5 class="m_bottom_10"><?php echo Html::a($model->name, ['/catalog/site/view-by-url' => $model->seo_url], ['class' => 'color_dark']); ?> </h5> <div class="clearfix m_bottom_15">
<?php use yii\helpers\Html; use yii\helpers\Url; use yii\widgets\LinkPager; use common\modules\filemanager\models\File; use common\modules\catalog\models\CatalogProducts; $name = CatalogProducts::findOne(['id' => $parent])->name; $this->title = \Yii::$app->name . ' - ' . $name; $this->registerJs("\n\$('input').change(function () {\n// alert(\$(this).val());\n\n\n});\n\n"); ?> <?php if (empty($elements)) { ?> <div class="page_content_offset" style="padding-top:0px;"> <div class="container"> <h4>К сожалению, мы ничего не нашли :(</h4> </div> </div> <?php } else { ?> <!--content--> <div class="page_content_offset" style="padding-top:0px;"> <div class="container"> <hr class="m_bottom_10 divider_type_3"> <div class="row clearfix m_bottom_15"> <div class="col-lg-5 col-md-5 col-sm-4 col-xs-12 t_align_r t_xs_align_l">
<?php use yii\helpers\Url; use yii\widgets\LinkPager; use common\modules\catalog\models\CatalogProducts; $this->title = 'Отзывы'; $element = CatalogProducts::findOne($id); if ($element->parent == 1) { $this->params['breadcrumbs'][] = ['label' => 'Каталог товаров', 'url' => ['/catalog/site/index-by-category', 'parent' => $element->parent, 'category' => $element->category]]; } else { $this->params['breadcrumbs'][] = ['label' => 'Каталог услуг', 'url' => ['/catalog/site/index-by-category', 'parent' => $element->parent, 'category' => $element->category]]; } $this->params['breadcrumbs'][] = ['label' => $element->title, 'url' => ['/catalog/site/view', 'id' => $id]]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="reviews"> <div class="title"><?php echo $this->title; ?> </div> <div class="reviews__add"><span class="reviews__add-icon"></span><a href="<?php echo Url::to(['/comments/site/create', 'table_id' => $id, 'table_name' => 'catalog']); ?> " class="dashed">Добавить отзыв</a></div> <div class="review-list"> <?php echo LinkPager::widget(['pagination' => $pagination]); ?>
public function getCatalogProducts() { return $this->hasOne(CatalogProducts::className(), ['category' => 'id'])->inverseOf('catalog_categorys'); }
//use kartik\datecontrol\DateControl; use common\themes\admin\widgets\ActiveForm; use andreosoft\summernote\Summernote; use common\modules\catalog\models\CatalogProducts; use common\modules\catalog\models\CatalogCategorys; use common\modules\filemanager\widgets\Image; use yii\grid\CheckboxColumn; use yii\widgets\ListView; use common\themes\admin\widgets\GridView; use common\themes\admin\widgets\GridViewEdited; use common\modules\comments\models\CommentsSearch; use common\modules\gallery\models\GallerySearch; use common\modules\gallery\widgets\Galleryinline; use common\themes\admin\widgets\ActionColumn; use common\modules\filemanager\widgets\ImageColumn; use yii\helpers\Url; ?> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data', 'boxTitle' => $options['title'], 'buttonUndo' => $options['buttonUndo']]]); ?> <?php echo Tabs::widget(['options' => ['class' => 'nav-tabs-custom'], 'items' => [['label' => \Yii::t('catalog/main', 'Main'), 'content' => $form->field($model, 'name')->textInput(['maxlength' => 255]) . $form->field($model, 'introtext')->widget(Summernote::className(), ['editorOptions' => ['height' => 200]]) . $form->field($model, 'content')->widget(Summernote::className(), ['editorOptions' => ['height' => 400]]), 'active' => true], ['label' => \Yii::t('catalog/main', 'Info'), 'content' => $form->field($model, 'tag')->textInput(['maxlength' => 255]) . $form->field($model, 'image')->widget(Image::className()) . $form->field($model, 'price')->textInput(['maxlength' => 11]) . $form->field($model, 'price_d')->textInput(['maxlength' => 11]) . $form->field($model, 'discont')->dropDownList([0 => Yii::t('catalog/main', 'No'), 1 => Yii::t('catalog/main', 'Yes')])], ['label' => \Yii::t('catalog/main', 'Seo'), 'content' => $form->field($model, 'seo_url')->textInput(['maxlength' => 255]) . $form->field($model, 'seo_title')->textInput(['maxlength' => 255]) . $form->field($model, 'seo_description')->textarea() . $form->field($model, 'seo_keyword')->textInput(['maxlength' => 255])], ['label' => \Yii::t('catalog/main', 'Manager'), 'content' => $form->field($model, 'isparent')->dropDownList([0 => Yii::t('catalog/main', 'No'), 1 => Yii::t('catalog/main', 'Yes')]) . $form->field($model, 'parent')->dropDownList(ArrayHelper::merge(['0' => 'No'], ArrayHelper::map(CatalogProducts::find()->where(['isparent' => '1'])->all(), 'id', 'fullname'))) . $form->field($model, 'status')->dropDownList(CatalogProducts::getStatusArray()) . $form->field($model, 'publishedondate')->widget(DatePicker::className()) . $form->field($model, 'publishedontime')->textInput() . $form->field($model, 'sort')->textInput()], ['label' => 'Comments', 'content' => isset($model->id) ? \common\themes\admin\widgets\GridViewEdited::widget(['dataProvider' => (new CommentsSearch())->search(['CommentsSearch' => ['table_name' => 'catalog', 'table_id' => $model->id]]), 'actionUpdate' => Url::to(['/comments/backend/update']), 'createModel' => new \common\modules\comments\models\Comments(), 'defaultValue' => ['Comments[table_id]' => $model->id, 'Comments[table_name]' => 'catalog'], 'columns' => [['attribute' => 'status', 'value' => function ($model) { return Html::activeDropDownList($model, 'status', ['Unpublished', 'Published'], ['class' => 'form-control', 'style' => 'width:100%;', 'prompt' => 'Выберите']); }], ['attribute' => 'content'], ['class' => \common\themes\admin\widgets\ActionColumn::className(), 'template' => '{delete}', 'controller' => '/comments/backend']]]) : '<div class="alert alert-warning alert-dismissable">' . '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . '<h4><i class="icon fa fa-warning"></i> Внимение!</h4>' . \Yii::t('catalog/main', 'Save befor use it') . '</div>' . Html::submitButton('Save', ['class' => 'btn btn-success'])], ['label' => \Yii::t('catalog/main', 'Gallery'), 'content' => isset($model->id) ? \common\themes\admin\widgets\GridViewEdited::widget(['dataProvider' => (new \common\modules\gallery\models\GallerySearch())->search(['GallerySearch' => ['table_name' => 'catalog', 'table_id' => $model->id]]), 'actionUpdate' => Url::to(['/gallery/backend/update']), 'createModel' => new \common\modules\gallery\models\Gallery(), 'defaultValue' => ['Gallery[table_id]' => $model->id, 'Gallery[table_name]' => 'catalog'], 'columns' => [['class' => common\modules\filemanager\widgets\ImageColumn::className(), 'attribute' => 'image'], ['attribute' => 'status', 'value' => function ($model) { return Html::activeDropDownList($model, 'status', \common\modules\gallery\models\Gallery::getStatusArray(), ['class' => 'form-control', 'style' => 'width:100%;', 'prompt' => 'Выберите']); }], 'content', 'sort', ['class' => \common\themes\admin\widgets\ActionColumn::className(), 'template' => '{delete}', 'controller' => '/gallery/backend']]]) : '<div class="alert alert-warning alert-dismissable">' . '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . '<h4><i class="icon fa fa-warning"></i> Внимение!</h4>' . \Yii::t('catalog/main', 'Save befor use it') . '</div>' . Html::submitButton('Save', ['class' => 'btn btn-success'])]]]); ?> <?php ActiveForm::end();
private function findFullName($model, $name) { if ($model->parent != 0) { $parent = CatalogProducts::findOne($model->parent); $name = $this->findFullName($parent, $parent->name . ' > ' . $name); } return $name; }
use common\modules\catalog\models\CatalogProducts; use yii\helpers\Html; use andreosoft\image\Image; ?> <div class="wrapper" style="padding-top: 70px;"> <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12"> <div class="kopa-related-posts"> <h3 class="widget-title style7">Недавние работы</h3> <div class="row"> <div style="opacity: 1; display: block;"> <?php foreach (CatalogProducts::find()->where(['parent' => 1, 'isparent' => false, 'status' => CatalogProducts::STATUS_PUBLISHED])->limit(3)->orderBy('publishedon desc')->all() as $model) { ?> <div class="col-md-4 col-sm-4 col-xs-12"> <div class="item"> <article class="entry-item"> <div class="entry-thumb"> <div class="entry-thumb-inner"> <?php echo Html::a('', ['/catalog/site/view-by-url', 'url' => $model->seo_url], ['class' => 'thumb-hover']); ?> <?php echo Html::img(Image::thumb($model->image, 303, 205)); ?> </div> </div> <div class="entry-content">
<hr class="mt-0 mb-0 "/> <!-- End Divider --> <!-- Related Products --> <section class="small-section blockup"> <div class="container relative"> <h2 class="section-title font-alt mb-70 mb-sm-40"> Смотрите также </h2> <!-- Products Grid --> <div class="row multi-columns-row"> <?php foreach (CatalogProducts::find()->where(['status' => CatalogProducts::STATUS_PUBLISHED, 'parent' => $model->parent])->andWhere('id <> ' . $model->id)->orderBy('RAND()')->limit(4)->all() as $model) { ?> <!-- Shop Item --> <div class="col-md-3 col-lg-3 mb-xs-40"> <div class="post-prev-img"> <?php echo Html::a(Html::img(Image::thumb($model->image, 370, 472)), ['view-by-url', 'url' => $model->seo_url]); ?> </div> <div class="post-prev-title font-alt align-center"> <?php echo Html::a($model->name, ['view-by-url', 'url' => $model->seo_url]); ?> </div> </div> <!-- End Shop Item -->