Ejemplo n.º 1
0
 /**
  * AJAX
  * Добавление товара в корзину
  * REQUEST
  * - id - int - идентификатор товара gs_unions_shop_product.id
  *
  * @return string
  */
 public function actionBasket_add()
 {
     $id = self::getParam('id');
     $product = Product::find($id);
     if (is_null($product)) {
         return self::jsonErrorId(101, 'Не найден товар');
     }
     $count = Basket::add($product);
     return self::jsonSuccess($count);
 }
Ejemplo n.º 2
0
 public function index()
 {
     $userCount = User::count();
     $productCount = Product::count();
     $fieldCount = Field::count();
     $lastUsers = User::take(5)->get();
     $lastProducts = Product::take(5)->get();
     $lastFields = Field::take(5)->get();
     return view('backend.index', compact('userCount', 'categoryCount', 'productCount', 'lastUsers', 'lastProducts', 'fieldCount', 'lastFields'));
 }
Ejemplo n.º 3
0
<?php

/* @var $this yii\web\View */
/* @var $model \cs\base\BaseForm */
/* @var $id int product_id bog_shop_product.id */
$this->title = 'Заказ';
$product = \app\models\Shop\Product::find($id);
$productPrice = $product->getField('price');
$this->registerJs(<<<JS
    \$('.field-request-address').hide();
    \$('input[name="Request[dostavka]"]').on('change', function() {
        var newPrice;
        if (\$(this).val() == 3 || \$(this).val() == 4) {
            \$('.field-request-address').show();
            newPrice = productPrice + 300;
        } else if (\$(this).val() == 5) {
            \$('.field-request-address').show();
            newPrice = productPrice + 1000;
        } else {
            \$('.field-request-address').hide();
            newPrice = productPrice;
        }
        \$('#productPriceForm').attr('value', newPrice);
        \$('#productPrice').html(newPrice);
    });
    \$('.paymentType').click(function () {
        \$('#paymentType').attr('value', \$(this).data('value'));
        if (!\$(this).hasClass('active')) {
            \$('.paymentType').removeClass('active');
            \$(this).addClass('active');
        }
Ejemplo n.º 4
0
<div class="container">

    <div class="col-lg-12">
        <h1 class="page-header"><?php 
echo \yii\helpers\Html::encode($this->title);
?>
</h1>
    </div>


    <div class="col-lg-12">
        <input type="text" class="form-control" size="20"/>
    </div>

    <?php 
$shopList = \app\models\Shop\Product::query()->groupBy('gs_unions_shop.id')->innerJoin('gs_unions_shop_tree', 'gs_unions_shop_tree.id = gs_unions_shop_product.tree_node_id')->innerJoin('gs_unions_shop', 'gs_unions_shop.id = gs_unions_shop_tree.shop_id')->select(['gs_unions_shop.*'])->all();
?>
    <?php 
foreach ($shopList as $i) {
    ?>
        <p><?php 
    echo $shopList['name'];
    ?>
</p>
    <?php 
}
?>

    <div class="col-lg-12">
        <hr>
        <?php 
Ejemplo n.º 5
0
 /**
  * Product store
  *
  * @param ShopProductStoreRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(ShopProductStoreRequest $request)
 {
     $product = Product::create($request->only('name', 'content', 'price', 'active'));
     if ($request->has('photos')) {
         $photos = Photo::whereIn('id', $request->get('photos'))->get();
         $product->photos()->saveMany($photos);
     }
     if ($request->has('category_id')) {
         $product->categories()->attach($request->get('category_id'));
     }
     //@Todo check field before save
     $product->fields()->attach(array_keys($request->field));
     foreach ($request->get('field') as $fieldId => $value) {
         if (!empty($value)) {
             $field = Field::findOrFail($fieldId);
             FieldValue::create([$field->type => $value[$field->type], 'product_id' => $product->id, 'field_id' => $field->id]);
         }
     }
     if ($request->has('fields')) {
         $product->fields()->attach($request->get('fields'));
     }
     Session::flash('message', 'Товар добавлен');
     return redirect()->route('manager.shop.product.edit', $product->id);
 }
Ejemplo n.º 6
0
            <h1><?php 
echo Html::encode($this->title);
?>
</h1>
        </div>



        <?php 
$ids = [];
foreach (\app\modules\Shop\services\Basket::get() as $item) {
    $ids[] = $item['id'];
}
$unionRows = \app\models\Shop\Product::query(['in', 'gs_unions_shop_product.id', $ids])->innerJoin('gs_unions', 'gs_unions.id = gs_unions_shop_product.union_id')->select(['gs_unions.*'])->groupBy(['gs_unions_shop_product.union_id'])->all();
for ($i = 0; $i < count($unionRows); $i++) {
    $unionRows[$i]['productList'] = \app\models\Shop\Product::query(['union_id' => $unionRows[$i]['id']])->andWhere(['in', 'gs_unions_shop_product.id', $ids])->all();
    for ($j = 0; $j < count($unionRows[$i]['productList']); $j++) {
        foreach (\app\modules\Shop\services\Basket::get() as $d) {
            if ($unionRows[$i]['productList'][$j]['id'] == $d['id']) {
                $unionRows[$i]['productList'][$j]['count'] = $d['count'];
                continue;
            }
        }
    }
}
?>

        <table class="table table-striped table-hover">
            <tr>
                <th>
                    #
Ejemplo n.º 7
0
 public function index()
 {
     $products = Product::with('fields')->take(4)->get();
     return view('frontend.home', compact('products'));
 }
Ejemplo n.º 8
0
use app\models\UnionCategory;
/* @var $this yii\web\View */
/* @var $union_id int */
$this->title = 'Товары';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="container">
    <div class="page-header">
        <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    </div>

    <?php 
echo \yii\grid\GridView::widget(['tableOptions' => ['class' => 'table tableMy table-striped table-hover'], 'dataProvider' => new \yii\data\ActiveDataProvider(['query' => \app\models\Shop\Product::query(['union_id' => $union_id])->select(['id', 'name', 'image'])->orderBy(['sort_index' => SORT_ASC]), 'pagination' => ['pageSize' => 50]]), 'columns' => ['id', ['header' => 'Картинка', 'content' => function ($item) {
    $i = \yii\helpers\ArrayHelper::getValue($item, 'image', '');
    if ($i == '') {
        return '';
    }
    return Html::img($i, ['width' => 100]);
}], 'name', ['header' => 'Редактировать', 'content' => function ($item) {
    return Html::a('Редактировать', ['cabinet_shop/product_list_edit', 'id' => $item['id']], ['class' => 'btn btn-primary']);
}]]]);
?>
    <hr>
    <a href="<?php 
echo \yii\helpers\Url::to(['cabinet_shop/product_list_add', 'id' => $union_id]);
?>
" class="btn btn-default">Добавить</a>
</div>
Ejemplo n.º 9
0
 /**
  * @return \app\models\Shop\Product
  */
 public function getProduct()
 {
     $product = Product::find($this->getField('product_id'));
     return $product;
 }
Ejemplo n.º 10
0
 /**
  * Продукт
  *
  * @param $category string id_string
  * @param $union_id int идентификатор объединения
  * @param $id int идентификатор продукта gs_unions_shop_product.id
  *
  * @return string
  * @throws \cs\web\Exception
  */
 public function actionProduct($category, $union_id, $id)
 {
     $item = Union::find($union_id);
     if (is_null($item)) {
         throw new Exception('Нет такого объединения');
     }
     $categoryObject = UnionCategory::find(['id_string' => $category]);
     if (is_null($categoryObject)) {
         throw new Exception('Не найдена категория');
     }
     $product = Product::find($id);
     if (is_null($product)) {
         throw new Exception('Не найден товар');
     }
     $treeNode = TreeNode::find($product->getField('tree_node_id'));
     $breadcrumbs = $categoryObject->getBreadCrumbs();
     $breadcrumbs = ArrayHelper::merge($breadcrumbs, [['url' => ['page/union_item', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string')], 'label' => $item->getName()], ['url' => ['union_shop/index', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string')], 'label' => 'Магазин'], ['url' => ['union_shop/category', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string'), 'shop_category' => $product->getField('tree_node_id')], 'label' => $treeNode->getField('name')], $product->getField('name')]);
     return $this->render(['union' => $item, 'shop' => $item->getShop(), 'breadcrumbs' => $breadcrumbs, 'category' => $categoryObject, 'treeNode' => $treeNode, 'product' => $product]);
 }
Ejemplo n.º 11
0
/* @var $this yii\web\View */
/* @var $list array */
/* @var $pagesCount int */
/* @var $page int */
$this->title = 'Наши подарки';
?>

<!-- About Section -->
<section id="about" class="container content-section" style="margin-top: 50px;">
    <div class="row">
        <div class="col-lg-8 col-lg-offset-2">
            <h2 class="text-center">Наши подарки</h2>
            <p>Мы предлагаем вам всевозможные варианты сотрудничества с нами. Выберите наиболее подходящий для вас и получите его.</p>

            <?php 
$all = \app\models\Shop\Product::query()->orderBy(['price' => SORT_ASC])->all();
for ($i = 0; $i < count($all); $i++) {
    $item =& $all[$i];
    ?>
                <div class="row">
                    <div class="col-lg-4">
                        <p><img src="<?php 
    echo $item['image'];
    ?>
" width="100%" style="border-radius: 10px;"></p>
                    </div>
                    <div class="col-lg-8">
                        <p><b><?php 
    echo $item['name'];
    ?>
</b></p>
Ejemplo n.º 12
0
    \$('.rowTable').click(function() {
        window.location = '/admin/products/' + \$(this).data('id');
    });


JS
);
?>

<div class="container">
    <h1 class="page-header">Продукты</h1>


    <?php 
echo \yii\grid\GridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => \app\models\Shop\Product::query()->orderBy(['price' => SORT_ASC]), 'pagination' => ['pageSize' => 20]]), 'tableOptions' => ['class' => 'table table-hover table-striped'], 'rowOptions' => function ($item) {
    return ['role' => 'button', 'data-id' => $item['id'], 'class' => 'rowTable'];
}, 'columns' => ['id', ['header' => 'Картинка', 'content' => function ($item) {
    if (\yii\helpers\ArrayHelper::getValue($item, 'image', '') == '') {
        return '';
    }
    return Html::img($item['image'], ['width' => 50, 'class' => 'thumbnail', 'style' => 'margin-bottom: 0px;']);
}], 'name', 'price', ['header' => 'Удалить', 'content' => function ($item) {
    return Html::button('Удалить', ['class' => 'btn btn-danger btn-xs buttonDelete', 'data-id' => $item['id']]);
}]]]);
?>


    <div class="col-lg-6">
        <div class="row">
            <!-- Split button -->