Commit 07c45ae4580b4ee082eb60c6ed762e39e1911140
Merge branch 'master' of gitlab.artweb.com.ua:root/baucenter
Showing
20 changed files
with
732 additions
and
234 deletions
Show diff stats
common/models/OrderItems.php
| @@ -14,7 +14,7 @@ use Yii; | @@ -14,7 +14,7 @@ use Yii; | ||
| 14 | * @property double $price | 14 | * @property double $price |
| 15 | * | 15 | * |
| 16 | * @property Orders $order | 16 | * @property Orders $order |
| 17 | - * @property Product $item | 17 | + * @property ProductVariant $item |
| 18 | */ | 18 | */ |
| 19 | class OrderItems extends \yii\db\ActiveRecord | 19 | class OrderItems extends \yii\db\ActiveRecord |
| 20 | { | 20 | { |
| @@ -35,7 +35,7 @@ class OrderItems extends \yii\db\ActiveRecord | @@ -35,7 +35,7 @@ class OrderItems extends \yii\db\ActiveRecord | ||
| 35 | [['order_id', 'item_id', 'item_count'], 'integer'], | 35 | [['order_id', 'item_id', 'item_count'], 'integer'], |
| 36 | [['price'], 'number'], | 36 | [['price'], 'number'], |
| 37 | [['order_id'], 'exist', 'skipOnError' => true, 'targetClass' => Orders::className(), 'targetAttribute' => ['order_id' => 'order_id']], | 37 | [['order_id'], 'exist', 'skipOnError' => true, 'targetClass' => Orders::className(), 'targetAttribute' => ['order_id' => 'order_id']], |
| 38 | - [['item_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['item_id' => 'product_id']], | 38 | + [['item_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductVariant::className(), 'targetAttribute' => ['item_id' => 'product_variant_id']], |
| 39 | ]; | 39 | ]; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| @@ -66,6 +66,6 @@ class OrderItems extends \yii\db\ActiveRecord | @@ -66,6 +66,6 @@ class OrderItems extends \yii\db\ActiveRecord | ||
| 66 | */ | 66 | */ |
| 67 | public function getItem() | 67 | public function getItem() |
| 68 | { | 68 | { |
| 69 | - return $this->hasOne(Product::className(), ['product_id' => 'item_id']); | 69 | + return $this->hasOne(ProductVariant::className(), ['product_variant_id' => 'item_id']); |
| 70 | } | 70 | } |
| 71 | } | 71 | } |
common/models/Orders.php
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | namespace common\models; | 3 | namespace common\models; |
| 4 | 4 | ||
| 5 | use Yii; | 5 | use Yii; |
| 6 | - | 6 | +use yii\behaviors\TimestampBehavior; |
| 7 | /** | 7 | /** |
| 8 | * This is the model class for table "orders". | 8 | * This is the model class for table "orders". |
| 9 | * | 9 | * |
| @@ -31,6 +31,7 @@ class Orders extends \yii\db\ActiveRecord | @@ -31,6 +31,7 @@ class Orders extends \yii\db\ActiveRecord | ||
| 31 | return 'orders'; | 31 | return 'orders'; |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | + | ||
| 34 | /** | 35 | /** |
| 35 | * @inheritdoc | 36 | * @inheritdoc |
| 36 | */ | 37 | */ |
| @@ -38,7 +39,7 @@ class Orders extends \yii\db\ActiveRecord | @@ -38,7 +39,7 @@ class Orders extends \yii\db\ActiveRecord | ||
| 38 | { | 39 | { |
| 39 | return [ | 40 | return [ |
| 40 | [['customer_id', 'delivery', 'payment', 'status', 'created_at', 'updated_at'], 'integer'], | 41 | [['customer_id', 'delivery', 'payment', 'status', 'created_at', 'updated_at'], 'integer'], |
| 41 | - [['name', 'email', 'phone', 'created_at', 'updated_at'], 'required'], | 42 | + [['name', 'email', 'phone'], 'required'], |
| 42 | [['name', 'email', 'code'], 'string', 'max' => 255], | 43 | [['name', 'email', 'code'], 'string', 'max' => 255], |
| 43 | [['phone'], 'string', 'max' => 32], | 44 | [['phone'], 'string', 'max' => 32], |
| 44 | ]; | 45 | ]; |
| @@ -47,6 +48,16 @@ class Orders extends \yii\db\ActiveRecord | @@ -47,6 +48,16 @@ class Orders extends \yii\db\ActiveRecord | ||
| 47 | /** | 48 | /** |
| 48 | * @inheritdoc | 49 | * @inheritdoc |
| 49 | */ | 50 | */ |
| 51 | + public function behaviors() | ||
| 52 | + { | ||
| 53 | + return [ | ||
| 54 | + TimestampBehavior::className(), | ||
| 55 | + ]; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * @inheritdoc | ||
| 60 | + */ | ||
| 50 | public function attributeLabels() | 61 | public function attributeLabels() |
| 51 | { | 62 | { |
| 52 | return [ | 63 | return [ |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace common\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * This is the model class for table "product_variant". | ||
| 9 | + * | ||
| 10 | + * @property integer $product_variant_id | ||
| 11 | + * @property integer $product_id | ||
| 12 | + * @property string $name | ||
| 13 | + * @property string $sku | ||
| 14 | + * @property double $price | ||
| 15 | + * @property double $price_old | ||
| 16 | + * @property double $stock | ||
| 17 | + * @property integer $product_unit_id | ||
| 18 | + * | ||
| 19 | + * @property OrderItems[] $orderItems | ||
| 20 | + * @property ProductUnit $productUnit | ||
| 21 | + */ | ||
| 22 | +class ProductVariant extends \yii\db\ActiveRecord | ||
| 23 | +{ | ||
| 24 | + /** | ||
| 25 | + * @inheritdoc | ||
| 26 | + */ | ||
| 27 | + public static function tableName() | ||
| 28 | + { | ||
| 29 | + return 'product_variant'; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * @inheritdoc | ||
| 34 | + */ | ||
| 35 | + public function rules() | ||
| 36 | + { | ||
| 37 | + return [ | ||
| 38 | + [['product_id', 'sku'], 'required'], | ||
| 39 | + [['product_id', 'product_unit_id'], 'integer'], | ||
| 40 | + [['price', 'price_old', 'stock'], 'number'], | ||
| 41 | + [['name', 'sku'], 'string', 'max' => 255], | ||
| 42 | + [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']], | ||
| 43 | + ]; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * @inheritdoc | ||
| 48 | + */ | ||
| 49 | + public function attributeLabels() | ||
| 50 | + { | ||
| 51 | + return [ | ||
| 52 | + 'product_variant_id' => Yii::t('app', 'Product Variant ID'), | ||
| 53 | + 'product_id' => Yii::t('app', 'Product ID'), | ||
| 54 | + 'name' => Yii::t('app', 'Name'), | ||
| 55 | + 'sku' => Yii::t('app', 'Sku'), | ||
| 56 | + 'price' => Yii::t('app', 'Price'), | ||
| 57 | + 'price_old' => Yii::t('app', 'Price Old'), | ||
| 58 | + 'stock' => Yii::t('app', 'Stock'), | ||
| 59 | + 'product_unit_id' => Yii::t('app', 'Product Unit ID'), | ||
| 60 | + ]; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * @return \yii\db\ActiveQuery | ||
| 65 | + */ | ||
| 66 | + public function getOrderItems() | ||
| 67 | + { | ||
| 68 | + return $this->hasMany(OrderItems::className(), ['item_id' => 'product_variant_id']); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * @return \yii\db\ActiveQuery | ||
| 73 | + */ | ||
| 74 | + public function getProductUnit() | ||
| 75 | + { | ||
| 76 | + return $this->hasOne(ProductUnit::className(), ['product_unit_id' => 'product_unit_id']); | ||
| 77 | + } | ||
| 78 | +} |
common/modules/product/models/ProductVariant.php
| @@ -68,6 +68,14 @@ class ProductVariant extends \yii\db\ActiveRecord | @@ -68,6 +68,14 @@ class ProductVariant extends \yii\db\ActiveRecord | ||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | /** | 70 | /** |
| 71 | + * @return \yii\db\ActiveQuery | ||
| 72 | + */ | ||
| 73 | + public function getProduct() | ||
| 74 | + { | ||
| 75 | + return $this->hasOne(Product::className(), ['product_id' => 'product_id']); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 71 | * @inheritdoc | 79 | * @inheritdoc |
| 72 | * @return ProductVariantQuery the active query used by this AR class. | 80 | * @return ProductVariantQuery the active query used by this AR class. |
| 73 | */ | 81 | */ |
common/widgets/BasketModal.php
| 1 | <?php | 1 | <?php |
| 2 | namespace common\widgets; | 2 | namespace common\widgets; |
| 3 | 3 | ||
| 4 | +use common\modules\product\models\ProductVariant; | ||
| 4 | use yii\base\Widget; | 5 | use yii\base\Widget; |
| 5 | 6 | ||
| 6 | class BasketModal extends Widget | 7 | class BasketModal extends Widget |
| @@ -16,12 +17,26 @@ class BasketModal extends Widget | @@ -16,12 +17,26 @@ class BasketModal extends Widget | ||
| 16 | public function run() | 17 | public function run() |
| 17 | { | 18 | { |
| 18 | $sessionData = \Yii::$app->session->get('order'); | 19 | $sessionData = \Yii::$app->session->get('order'); |
| 20 | + unset($sessionData['order_id']); | ||
| 19 | $count = count($sessionData); | 21 | $count = count($sessionData); |
| 22 | + $price = 0; | ||
| 20 | if(is_array($sessionData) && !empty($sessionData)){ | 23 | if(is_array($sessionData) && !empty($sessionData)){ |
| 24 | + | ||
| 25 | + $variant = ProductVariant::find()->where(['product_variant_id'=>array_keys($sessionData)])->indexBy('product_variant_id')->all(); | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + foreach ($sessionData as $k => $item) { | ||
| 29 | + $sessionData[$k]['item'] = $variant[$k]; | ||
| 30 | + $price += $variant[$k]->price * $sessionData[$k]['num']; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + | ||
| 21 | return $this->render('busket_modal',[ | 34 | return $this->render('busket_modal',[ |
| 22 | 'items'=>$sessionData, | 35 | 'items'=>$sessionData, |
| 23 | - 'count' => $count | 36 | + 'count' => $count, |
| 37 | + 'price' => $price | ||
| 24 | ]); | 38 | ]); |
| 39 | + | ||
| 25 | } | 40 | } |
| 26 | 41 | ||
| 27 | } | 42 | } |
common/widgets/views/busket_modal.php
| @@ -3,30 +3,38 @@ | @@ -3,30 +3,38 @@ | ||
| 3 | * @var $items array data from session | 3 | * @var $items array data from session |
| 4 | * @var $count integer count items in basket | 4 | * @var $count integer count items in basket |
| 5 | */ | 5 | */ |
| 6 | +use yii\helpers\Html; | ||
| 6 | 7 | ||
| 7 | ?> | 8 | ?> |
| 8 | <div class="order_list"> | 9 | <div class="order_list"> |
| 9 | <ul> | 10 | <ul> |
| 10 | - <?php foreach($items as $item){ ?> | 11 | + <?php foreach($items as $item){ |
| 12 | + | ||
| 13 | + ?> | ||
| 14 | + | ||
| 11 | <li> | 15 | <li> |
| 12 | - <div class="order_list_li" data-id="1"> | 16 | + <div class="order_list_li" data-id="<?= $item['item']->product_variant_id?>"> |
| 13 | <div class="delete_item_btn"><i class="fa fa-times"></i></div> | 17 | <div class="delete_item_btn"><i class="fa fa-times"></i></div> |
| 14 | <div class="little_img"> | 18 | <div class="little_img"> |
| 15 | - <img src="/images/items/01.jpg" alt=""> | 19 | + <?php if (empty($item['item']->product->image)) :?> |
| 20 | + <img src="/images/no_photo.png"> | ||
| 21 | + <?php else :?> | ||
| 22 | + <img src="/images/<?= $item['item']->product->image->image?>" alt="<?= $item['item']->product->image->alt ? $item['item']->product->image->alt : $item['item']->product->name?>"> | ||
| 23 | + <?php endif?> | ||
| 16 | </div> | 24 | </div> |
| 17 | <div class="name_and_code"> | 25 | <div class="name_and_code"> |
| 18 | - <span class="name">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</span> | 26 | + <span class="name"><?= $item['item']->name?></span> |
| 19 | <span class="code"> Код: 45885-01016049</span> | 27 | <span class="code"> Код: 45885-01016049</span> |
| 20 | </div> | 28 | </div> |
| 21 | <div class="count_block_wrap"> | 29 | <div class="count_block_wrap"> |
| 22 | <div class="count_block"> | 30 | <div class="count_block"> |
| 23 | - <input type="text" name="" class="form-control buy_one_item" value="1"> | 31 | + <input type="text" name="" class="form-control buy_one_item" value="<?= $item['num']?>"> |
| 24 | <div class="count_buttons"> | 32 | <div class="count_buttons"> |
| 25 | <div class="button_plus">+</div> | 33 | <div class="button_plus">+</div> |
| 26 | <div class="button_minus">-</div> | 34 | <div class="button_minus">-</div> |
| 27 | </div> | 35 | </div> |
| 28 | </div> | 36 | </div> |
| 29 | - <div class="price">102.05 <span class="price_text">грн.</span></div> | 37 | + <div class="price"><span class="price_val" data-price="<?= $item['item']->price ?>"><?= $item['item']->price * $item['num'] ?></span><span class="price_text">грн.</span></div> |
| 30 | </div> | 38 | </div> |
| 31 | </div> | 39 | </div> |
| 32 | </li> | 40 | </li> |
| @@ -36,10 +44,10 @@ | @@ -36,10 +44,10 @@ | ||
| 36 | <hr> | 44 | <hr> |
| 37 | <div class="all_price"> | 45 | <div class="all_price"> |
| 38 | <p>Всего товаров: <span class="all_count"><?= $count ?></span></p> | 46 | <p>Всего товаров: <span class="all_count"><?= $count ?></span></p> |
| 39 | - <p>Сумма: <span class="all_price">306.15</span> грн.</p> | 47 | + <p>Сумма: <span class="all_price all_price_span"><?= $price ?></span> грн.</p> |
| 40 | </div> | 48 | </div> |
| 41 | <div class="busket_bottom_btn"> | 49 | <div class="busket_bottom_btn"> |
| 42 | - <a href="#">продолжить покупки</a> | ||
| 43 | - <button>оформить заказ</button> | 50 | + <a class = "close" href="#">продолжить покупки</a> |
| 51 | + <?= Html::a('оформить заказ', ['orders/first'], ['class'=> 'button']);?> | ||
| 44 | </div> | 52 | </div> |
| 45 | </div> | 53 | </div> |
console/migrations/m160304_065108_product.php
| @@ -96,19 +96,30 @@ class m160304_065108_product extends Migration | @@ -96,19 +96,30 @@ class m160304_065108_product extends Migration | ||
| 96 | 'code' => $this->string(50)->notNull(), | 96 | 'code' => $this->string(50)->notNull(), |
| 97 | 'is_default' => $this->boolean() | 97 | 'is_default' => $this->boolean() |
| 98 | ], $tableOptions); | 98 | ], $tableOptions); |
| 99 | - | 99 | +// |
| 100 | $this->addForeignKey('product_variant_product_unit_fkey', 'product_variant', 'product_unit_id', 'product_unit', 'product_unit_id', 'CASCADE', 'NO ACTION'); | 100 | $this->addForeignKey('product_variant_product_unit_fkey', 'product_variant', 'product_unit_id', 'product_unit', 'product_unit_id', 'CASCADE', 'NO ACTION'); |
| 101 | $this->addForeignKey('category_product_unit_fkey', 'category', 'product_unit_id', 'product_unit', 'product_unit_id', 'NO ACTION', 'NO ACTION'); | 101 | $this->addForeignKey('category_product_unit_fkey', 'category', 'product_unit_id', 'product_unit', 'product_unit_id', 'NO ACTION', 'NO ACTION'); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | public function down() | 104 | public function down() |
| 105 | { | 105 | { |
| 106 | + $this->dropForeignKey('category_name_fkey', 'category'); | ||
| 107 | + $this->dropForeignKey('category_name_category_fkey', 'category_name'); | ||
| 108 | + $this->dropForeignKey('brand_name_fkey', 'brand'); | ||
| 109 | + $this->dropForeignKey('brand_name_brand_fkey', 'brand_name'); | ||
| 110 | + $this->dropForeignKey('fki_product_id', 'product_category'); | ||
| 111 | + $this->dropForeignKey('fki_category_id', 'product_category'); | ||
| 112 | + $this->dropForeignKey('fki_brand_id', 'product'); | ||
| 113 | + $this->dropForeignKey('product_variant_product_unit_fkey', 'product_variant'); | ||
| 114 | + $this->dropForeignKey('category_product_unit_fkey', 'category'); | ||
| 106 | $this->dropTable('{{%category}}'); | 115 | $this->dropTable('{{%category}}'); |
| 107 | $this->dropTable('{{%category_name}}'); | 116 | $this->dropTable('{{%category_name}}'); |
| 108 | $this->dropTable('{{%product_category}}'); | 117 | $this->dropTable('{{%product_category}}'); |
| 109 | $this->dropTable('{{%product}}'); | 118 | $this->dropTable('{{%product}}'); |
| 110 | $this->dropTable('{{%product_variant}}'); | 119 | $this->dropTable('{{%product_variant}}'); |
| 111 | $this->dropTable('{{%product_unit}}'); | 120 | $this->dropTable('{{%product_unit}}'); |
| 121 | + $this->dropTable('{{%brand_name}}'); | ||
| 122 | + $this->dropTable('{{%brand}}'); | ||
| 112 | } | 123 | } |
| 113 | 124 | ||
| 114 | /* | 125 | /* |
console/migrations/m160324_114404_orders_items_items_fk.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +class m160324_114404_orders_items_items_fk extends Migration | ||
| 6 | +{ | ||
| 7 | + public function up() | ||
| 8 | + { | ||
| 9 | + | ||
| 10 | + $this->dropForeignKey('orders_items_items_fk', '{{%order_items}}'); | ||
| 11 | + $this->addForeignKey('orders_items_items_fk', '{{%order_items}}', 'item_id', '{{%product_variant}}', 'product_variant_id', 'RESTRICT', 'RESTRICT'); | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + public function down() | ||
| 15 | + { | ||
| 16 | + $this->dropForeignKey('orders_items_items_fk', '{{%order_items}}'); | ||
| 17 | + $this->addForeignKey('orders_items_items_fk', '{{%order_items}}', 'item_id', '{{%product}}', 'product_id', 'RESTRICT', 'RESTRICT'); | ||
| 18 | + | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | +} |
frontend/assets/AppAsset.php
| @@ -41,7 +41,8 @@ class AppAsset extends AssetBundle | @@ -41,7 +41,8 @@ class AppAsset extends AssetBundle | ||
| 41 | 'js/jquery.jcarousellite-1.0.1.js', | 41 | 'js/jquery.jcarousellite-1.0.1.js', |
| 42 | 'js/owl.carousel.js', | 42 | 'js/owl.carousel.js', |
| 43 | 'js/script.js', | 43 | 'js/script.js', |
| 44 | - 'js/my_scripts.js' | 44 | + 'js/my_scripts.js', |
| 45 | + 'js/basket.js', | ||
| 45 | 46 | ||
| 46 | ]; | 47 | ]; |
| 47 | public $depends = [ | 48 | public $depends = [ |
frontend/controllers/OrdersController.php
| @@ -2,6 +2,10 @@ | @@ -2,6 +2,10 @@ | ||
| 2 | 2 | ||
| 3 | namespace frontend\controllers; | 3 | namespace frontend\controllers; |
| 4 | 4 | ||
| 5 | +use common\models\Customers; | ||
| 6 | +use common\models\OrderItems; | ||
| 7 | +use common\models\Orders; | ||
| 8 | +use common\modules\product\models\ProductVariant; | ||
| 5 | use common\widgets\BasketModal; | 9 | use common\widgets\BasketModal; |
| 6 | use Yii; | 10 | use Yii; |
| 7 | 11 | ||
| @@ -27,78 +31,183 @@ class OrdersController extends Controller | @@ -27,78 +31,183 @@ class OrdersController extends Controller | ||
| 27 | return true; | 31 | return true; |
| 28 | } | 32 | } |
| 29 | 33 | ||
| 30 | - /** | ||
| 31 | - * Lists all Order models. | ||
| 32 | - * @return mixed | ||
| 33 | - */ | ||
| 34 | - public function actionIndex() | ||
| 35 | - { | 34 | + public function actionFirst(){ |
| 36 | 35 | ||
| 37 | - if (Yii::$app->request->post()) { | ||
| 38 | - $item = $items_id = array(); | 36 | + $array = Yii::$app->session->get('order'); |
| 39 | 37 | ||
| 40 | - $i = 0; | ||
| 41 | - $order = Yii::$app->request->post(); | 38 | + if(isset($array['order_id']) ) { |
| 39 | + $model = Orders::findOne($array['order_id']); | ||
| 40 | + }else { | ||
| 41 | + $model = new Orders(); | ||
| 42 | + } | ||
| 42 | 43 | ||
| 43 | - $orderData['Order'] = $order['OrderForm']; | ||
| 44 | 44 | ||
| 45 | - foreach($order['OrderForm']['one_item'] as $k => $v ){ | ||
| 46 | - $item[$k]['num'] = $v['num']; | ||
| 47 | - $items_id[] = $k; | ||
| 48 | - $i++; | ||
| 49 | - } | 45 | + if(Yii::$app->request->post() && $model->load(Yii::$app->request->post())){ |
| 50 | 46 | ||
| 51 | - $items = Items::find()->where(['id'=>$items_id])->all(); | 47 | + if($model->save()){ |
| 52 | 48 | ||
| 49 | + $array['order_id'] = $model->order_id; | ||
| 53 | 50 | ||
| 54 | - $orderModel = new Order(); | ||
| 55 | - $orderModel->load($orderData); | ||
| 56 | - $orderModel->save(); | 51 | + Yii::$app->session->set('order', $array ); |
| 57 | 52 | ||
| 53 | + return $this->redirect(['orders/second']); | ||
| 54 | + } | ||
| 58 | 55 | ||
| 59 | - foreach($items as $one_item){ | ||
| 60 | - $ItemOrderModel = new ItemOrder(); | ||
| 61 | - $ItemOrderModel->order_id = $orderModel->id; | ||
| 62 | - $ItemOrderModel->num = $item[$one_item->id]['num']; | ||
| 63 | - $ItemOrderModel->item_id = $one_item->id; | ||
| 64 | - $ItemOrderModel->price = $one_item->price * $item[$one_item->id]['num']; | ||
| 65 | - $ItemOrderModel->item_name = $one_item->name; | ||
| 66 | - $ItemOrderModel->save(); | 56 | + } else { |
| 57 | + if (!Yii::$app->user->isGuest) { | ||
| 58 | + $customer = Yii::$app->user->identity; | ||
| 59 | + $model->name = $customer->name; | ||
| 60 | + $model->email = $customer->email; | ||
| 61 | + $model->phone = $customer->phone; | ||
| 67 | } | 62 | } |
| 68 | - Yii::$app->session->set('order', [] ); | ||
| 69 | - return $this->redirect(['order/complete']); | ||
| 70 | } | 63 | } |
| 71 | - $total_price = 0; | ||
| 72 | 64 | ||
| 73 | - $items_id = []; | ||
| 74 | 65 | ||
| 75 | - $orders = Yii::$app->session->get('order'); | 66 | + return $this->render('basket-step-01',[ |
| 67 | + 'model' => $model | ||
| 68 | + ]); | ||
| 69 | + } | ||
| 76 | 70 | ||
| 77 | - if(!empty($orders)){ | ||
| 78 | - foreach($orders as $k => $v) { | ||
| 79 | - $items_id[] = $k; | ||
| 80 | - } | ||
| 81 | - } | 71 | + public function actionSecond(){ |
| 82 | 72 | ||
| 73 | + $sessionData = \Yii::$app->session->get('order'); | ||
| 83 | 74 | ||
| 84 | - $items = Items::find()->where(['id'=>$items_id])->all(); | 75 | + $order_id = $sessionData['order_id']; |
| 85 | 76 | ||
| 86 | - foreach($items as $item) { | ||
| 87 | - $total_price += $orders[$item['id']]['num'] * $item['price']; | 77 | + if(!empty($order_id)){ |
| 78 | + $order_model = Orders::findOne($order_id); | ||
| 79 | + } else{ | ||
| 80 | + $order_model = new Orders; | ||
| 88 | } | 81 | } |
| 89 | 82 | ||
| 83 | + unset($sessionData['order_id']); | ||
| 90 | 84 | ||
| 91 | - $dataProvider = new ArrayDataProvider([ | ||
| 92 | - 'allModels' => $items | ||
| 93 | - ]); | 85 | + $variant = ProductVariant::find()->where(['product_variant_id'=>array_keys($sessionData)])->indexBy('product_variant_id')->all(); |
| 86 | + | ||
| 87 | + | ||
| 88 | + if(Yii::$app->request->post()){ | ||
| 89 | + | ||
| 90 | + foreach ($sessionData as $k => $item) { | ||
| 91 | + $itemModel = OrderItems::find()->where(['order_id'=>$order_id, 'item_id'=> $variant[$k]->product_variant_id])->one(); | ||
| 92 | + if($itemModel instanceof OrderItems){ | ||
| 93 | + $itemModel->order_id = $order_id; | ||
| 94 | + $itemModel->item_id = $variant[$k]->product_variant_id; | ||
| 95 | + $itemModel->item_count = $sessionData[$k]['num']; | ||
| 96 | + $itemModel->price = $variant[$k]->price; | ||
| 97 | + $itemModel->save(); | ||
| 98 | + } else { | ||
| 99 | + $itemModel = new OrderItems(); | ||
| 100 | + $itemModel->order_id = $order_id; | ||
| 101 | + $itemModel->item_id = $variant[$k]->product_variant_id; | ||
| 102 | + $itemModel->item_count = $sessionData[$k]['num']; | ||
| 103 | + $itemModel->price = $variant[$k]->price; | ||
| 104 | + $itemModel->save(); | ||
| 105 | + } | ||
| 94 | 106 | ||
| 95 | - return $this->render('index', [ | ||
| 96 | - 'dataProvider' => $dataProvider, | ||
| 97 | - 'total_price'=> $total_price, | ||
| 98 | - 'model' => new OrderForm() | 107 | + } |
| 108 | + Yii::$app->session->set('order', [] ); | ||
| 109 | + return $this->redirect(['orders/third']); | ||
| 110 | + | ||
| 111 | + } else { | ||
| 112 | + | ||
| 113 | + $price = 0; | ||
| 114 | + | ||
| 115 | + $count = count($sessionData); | ||
| 116 | + | ||
| 117 | + foreach ($sessionData as $k => $item) { | ||
| 118 | + $sessionData[$k]['item'] = $variant[$k]; | ||
| 119 | + $price += $variant[$k]->price * $sessionData[$k]['num']; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + return $this->render('basket-step-02',[ | ||
| 125 | + 'items'=>$sessionData, | ||
| 126 | + 'count' => $count, | ||
| 127 | + 'price' => $price, | ||
| 128 | + 'order_id' => $order_id, | ||
| 129 | + 'order_model' => $order_model, | ||
| 99 | ]); | 130 | ]); |
| 131 | + | ||
| 100 | } | 132 | } |
| 101 | 133 | ||
| 134 | + public function actionThird(){ | ||
| 135 | + return $this->render('basket-step-03'); | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + | ||
| 139 | +// /** | ||
| 140 | +// * Lists all Order models. | ||
| 141 | +// * @return mixed | ||
| 142 | +// */ | ||
| 143 | +// public function actionIndex() | ||
| 144 | +// { | ||
| 145 | +// | ||
| 146 | +// if (Yii::$app->request->post()) { | ||
| 147 | +// $item = $items_id = array(); | ||
| 148 | +// | ||
| 149 | +// $i = 0; | ||
| 150 | +// $order = Yii::$app->request->post(); | ||
| 151 | +// | ||
| 152 | +// $orderData['Order'] = $order['OrderForm']; | ||
| 153 | +// | ||
| 154 | +// foreach($order['OrderForm']['one_item'] as $k => $v ){ | ||
| 155 | +// $item[$k]['num'] = $v['num']; | ||
| 156 | +// $items_id[] = $k; | ||
| 157 | +// $i++; | ||
| 158 | +// } | ||
| 159 | +// | ||
| 160 | +// $items = Items::find()->where(['id'=>$items_id])->all(); | ||
| 161 | +// | ||
| 162 | +// | ||
| 163 | +// $orderModel = new Order(); | ||
| 164 | +// $orderModel->load($orderData); | ||
| 165 | +// $orderModel->save(); | ||
| 166 | +// | ||
| 167 | +// | ||
| 168 | +// foreach($items as $one_item){ | ||
| 169 | +// $ItemOrderModel = new ItemOrder(); | ||
| 170 | +// $ItemOrderModel->order_id = $orderModel->id; | ||
| 171 | +// $ItemOrderModel->num = $item[$one_item->id]['num']; | ||
| 172 | +// $ItemOrderModel->item_id = $one_item->id; | ||
| 173 | +// $ItemOrderModel->price = $one_item->price * $item[$one_item->id]['num']; | ||
| 174 | +// $ItemOrderModel->item_name = $one_item->name; | ||
| 175 | +// $ItemOrderModel->save(); | ||
| 176 | +// } | ||
| 177 | +// Yii::$app->session->set('order', [] ); | ||
| 178 | +// return $this->redirect(['order/complete']); | ||
| 179 | +// } | ||
| 180 | +// $total_price = 0; | ||
| 181 | +// | ||
| 182 | +// $items_id = []; | ||
| 183 | +// | ||
| 184 | +// $orders = Yii::$app->session->get('order'); | ||
| 185 | +// | ||
| 186 | +// if(!empty($orders)){ | ||
| 187 | +// foreach($orders as $k => $v) { | ||
| 188 | +// $items_id[] = $k; | ||
| 189 | +// } | ||
| 190 | +// } | ||
| 191 | +// | ||
| 192 | +// | ||
| 193 | +// $items = Items::find()->where(['id'=>$items_id])->all(); | ||
| 194 | +// | ||
| 195 | +// foreach($items as $item) { | ||
| 196 | +// $total_price += $orders[$item['id']]['num'] * $item['price']; | ||
| 197 | +// } | ||
| 198 | +// | ||
| 199 | +// | ||
| 200 | +// $dataProvider = new ArrayDataProvider([ | ||
| 201 | +// 'allModels' => $items | ||
| 202 | +// ]); | ||
| 203 | +// | ||
| 204 | +// return $this->render('index', [ | ||
| 205 | +// 'dataProvider' => $dataProvider, | ||
| 206 | +// 'total_price'=> $total_price, | ||
| 207 | +// 'model' => new OrderForm() | ||
| 208 | +// ]); | ||
| 209 | +// } | ||
| 210 | + | ||
| 102 | 211 | ||
| 103 | public function actionComplete() | 212 | public function actionComplete() |
| 104 | { | 213 | { |
frontend/controllers/PuttyController.php
| @@ -27,13 +27,7 @@ class PuttyController extends Controller | @@ -27,13 +27,7 @@ class PuttyController extends Controller | ||
| 27 | return $this->render('manufacturers'); | 27 | return $this->render('manufacturers'); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | - public function actionBasketStepFirst(){ | ||
| 31 | - return $this->render('basket-step-01'); | ||
| 32 | - } | ||
| 33 | 30 | ||
| 34 | - public function actionBasketStepSecond(){ | ||
| 35 | - return $this->render('basket-step-02'); | ||
| 36 | - } | ||
| 37 | 31 | ||
| 38 | 32 | ||
| 39 | public function actionContacts(){ | 33 | public function actionContacts(){ |
frontend/views/catalog/product_item.php
| 1 | <?php | 1 | <?php |
| 2 | /** @var \common\modules\product\models\Product $product */ | 2 | /** @var \common\modules\product\models\Product $product */ |
| 3 | + | ||
| 3 | ?> | 4 | ?> |
| 4 | <div class="item" data-id="<?= $product->product_id?>"> | 5 | <div class="item" data-id="<?= $product->product_id?>"> |
| 5 | <!--<div class="new">АКЦИЯ</div> | 6 | <!--<div class="new">АКЦИЯ</div> |
frontend/views/layouts/main.php
| @@ -66,14 +66,15 @@ AppAsset::register($this); | @@ -66,14 +66,15 @@ AppAsset::register($this); | ||
| 66 | <div class="phone_desc">Звоните с 9.00 до 18.00 по будням</div> | 66 | <div class="phone_desc">Звоните с 9.00 до 18.00 по будням</div> |
| 67 | </div> | 67 | </div> |
| 68 | </div> | 68 | </div> |
| 69 | + | ||
| 69 | <div class="basket_head"> | 70 | <div class="basket_head"> |
| 70 | <img src="/images/ico_basket.png" class="bh_cell img"> | 71 | <img src="/images/ico_basket.png" class="bh_cell img"> |
| 71 | <div class="bh_cell text"> | 72 | <div class="bh_cell text"> |
| 72 | <div class="basket_head_title">Корзина</div> | 73 | <div class="basket_head_title">Корзина</div> |
| 73 | - <div class="basket_head_desc">2 товара</div> | ||
| 74 | </div> | 74 | </div> |
| 75 | <i class="head-down bh_cell"></i> | 75 | <i class="head-down bh_cell"></i> |
| 76 | </div> | 76 | </div> |
| 77 | + | ||
| 77 | </div> | 78 | </div> |
| 78 | 79 | ||
| 79 | <!-- MODAL BUSKET WINDOW HEAD --> | 80 | <!-- MODAL BUSKET WINDOW HEAD --> |
frontend/views/putty/basket-step-01.php renamed to frontend/views/orders/basket-step-01.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\helpers\Url; | ||
| 5 | +use yii\widgets\ActiveForm; | ||
| 6 | + | ||
| 3 | $this->title = 'Оформление заказа'; | 7 | $this->title = 'Оформление заказа'; |
| 4 | $this->params['breadcrumbs'][] = $this->title; | 8 | $this->params['breadcrumbs'][] = $this->title; |
| 5 | 9 | ||
| @@ -8,34 +12,34 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -8,34 +12,34 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 8 | 12 | ||
| 9 | <h1 class="basket_main_title">Оформление заказа</h1> | 13 | <h1 class="basket_main_title">Оформление заказа</h1> |
| 10 | 14 | ||
| 11 | -<form name="basket_order_01_form"><!-- начало формы заказа --> | 15 | + |
| 16 | + <?php $form = ActiveForm::begin([ | ||
| 17 | + 'class' => 'basket_order_01_form' | ||
| 18 | + ]); ?><!-- начало формы заказа --> | ||
| 19 | + | ||
| 12 | 20 | ||
| 13 | <div class="privet_info_block"> | 21 | <div class="privet_info_block"> |
| 14 | 22 | ||
| 15 | <h3>Личные данные</h3> | 23 | <h3>Личные данные</h3> |
| 16 | 24 | ||
| 17 | <div class="padding_cust"> | 25 | <div class="padding_cust"> |
| 18 | - <label>Ф.И.О.<span class="red">*</span> | ||
| 19 | - <input type="text" name="first_name" required> | ||
| 20 | - <span class="placehold">На это имя будут оформлены документы</span> | ||
| 21 | - </label> | 26 | + <?= $form->field($model, 'name',[ |
| 27 | + 'template' => '<label>'.Yii::t('app', 'Ф.И.О.').'<span class="red">*</span>{input}<span class="placehold">На это имя будут оформлены документы</span>{error}{hint}</label>', | ||
| 28 | + ])->textInput() ?> | ||
| 22 | </div> | 29 | </div> |
| 23 | 30 | ||
| 24 | <div class="padding_cust"> | 31 | <div class="padding_cust"> |
| 25 | - <label>E-mail<span class="red">*</span> | ||
| 26 | - <input type="text" name="first_name" required> | ||
| 27 | - <span class="placehold">Сюда пришлем подробности заказа</span> | ||
| 28 | - </label> | 32 | + <?= $form->field($model, 'email',[ |
| 33 | + 'template' => '<label>'.Yii::t('app', 'E-mail').'<span class="red">*</span>{input}<span class="placehold">Сюда пришлем подробности заказа</span>{error}{hint}</label>', | ||
| 34 | + ])->textInput() ?> | ||
| 29 | </div> | 35 | </div> |
| 30 | - | 36 | + |
| 31 | <div class="padding_cust"> | 37 | <div class="padding_cust"> |
| 32 | - <label>Телефон<span class="red">*</span> | ||
| 33 | - <input type="text" name="first_name" required> | ||
| 34 | - <span class="placehold">Уточним важное</span> | ||
| 35 | - </label> | 38 | + <?= $form->field($model, 'phone',[ |
| 39 | + 'template' => '<label>'.Yii::t('app', 'Телефон').'<span class="red">*</span>{input}<span class="placehold">Уточним важное</span>{error}{hint}</label>', | ||
| 40 | + ])->textInput() ?> | ||
| 36 | </div> | 41 | </div> |
| 37 | 42 | ||
| 38 | - | ||
| 39 | </div> | 43 | </div> |
| 40 | 44 | ||
| 41 | <div class="separator"></div> | 45 | <div class="separator"></div> |
| @@ -86,8 +90,9 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -86,8 +90,9 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 86 | </div> | 90 | </div> |
| 87 | 91 | ||
| 88 | </div> | 92 | </div> |
| 93 | + | ||
| 89 | <div class="for_margin"> | 94 | <div class="for_margin"> |
| 90 | - <button type="submit" class="order_01_btn">продолжить оформление</button> | 95 | + <?= Html::submitButton(Yii::t('app', 'продолжить оформление'), ['class' => 'order_01_btn', 'name' => 'signup-button']) ?> |
| 91 | </div> | 96 | </div> |
| 92 | 97 | ||
| 93 | -</form><!-- конец формы заказа --> | ||
| 94 | \ No newline at end of file | 98 | \ No newline at end of file |
| 99 | +<?php ActiveForm::end(); ?><!-- конец формы заказа --> | ||
| 95 | \ No newline at end of file | 100 | \ No newline at end of file |
frontend/views/putty/basket-step-02.php renamed to frontend/views/orders/basket-step-02.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\ActiveForm; | ||
| 5 | + | ||
| 3 | $this->title = 'Оформление заказа'; | 6 | $this->title = 'Оформление заказа'; |
| 4 | $this->params['breadcrumbs'][] = $this->title; | 7 | $this->params['breadcrumbs'][] = $this->title; |
| 5 | 8 | ||
| 6 | ?> | 9 | ?> |
| 10 | +<div class="basket_form basket_result"> | ||
| 11 | + <?php $form = ActiveForm::begin([ | ||
| 12 | + 'class' => 'basket_order_01_form' | ||
| 13 | + ]); ?><!-- начало формы заказа --> | ||
| 7 | 14 | ||
| 8 | -<h1 class="basket_main_title">Оформление заказа</h1> | 15 | + <h1 class="basket_main_title">Оформление заказа</h1> |
| 16 | + <div class="order_list"> | ||
| 17 | + <h3>Номер заказа <?= $order_id?></h3> | ||
| 18 | + <ul> | ||
| 19 | + <?php foreach($items as $item){ | ||
| 9 | 20 | ||
| 10 | -<div class="order_list"> | ||
| 11 | - <h3>Номер заказа 671</h3> | ||
| 12 | - <ul> | ||
| 13 | - <li> | ||
| 14 | - <div class="order_list_li "> | ||
| 15 | - <div class="little_img"> | ||
| 16 | - <img src="/images/items/01.jpg" alt=""> | ||
| 17 | - </div> | ||
| 18 | - <div class="name_and_code"> | ||
| 19 | - <span class="name">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</span> | ||
| 20 | - <span class="code"> Код: 45885-01016049</span> | ||
| 21 | - </div> | ||
| 22 | - <div class="how_many">1 шт.</div> | ||
| 23 | - <div class="price">102.05 <span class="price_text">грн.</span></div> | ||
| 24 | - </div> | ||
| 25 | - </li> | ||
| 26 | - <li> | ||
| 27 | - <div class="order_list_li active"> | ||
| 28 | - <div class="little_img"> | ||
| 29 | - <img src="/images/items/01.jpg" alt=""> | ||
| 30 | - </div> | ||
| 31 | - <div class="name_and_code"> | ||
| 32 | - <span class="name">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</span> | ||
| 33 | - <span class="code"> Код: 45885-01016049</span> | ||
| 34 | - </div> | ||
| 35 | - <div class="how_many">1 шт.</div> | ||
| 36 | - <div class="price">102.05 <span class="price_text">грн.</span></div> | ||
| 37 | - </div> | ||
| 38 | - </li> | ||
| 39 | - <li> | ||
| 40 | - <div class="order_list_li "> | ||
| 41 | - <div class="little_img"> | ||
| 42 | - <img src="/images/items/01.jpg" alt=""> | ||
| 43 | - </div> | ||
| 44 | - <div class="name_and_code"> | ||
| 45 | - <span class="name">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</span> | ||
| 46 | - <span class="code"> Код: 45885-01016049</span> | ||
| 47 | - </div> | ||
| 48 | - <div class="how_many">1 шт.</div> | ||
| 49 | - <div class="price">102.05 <span class="price_text">грн.</span></div> | ||
| 50 | - </div> | ||
| 51 | - </li> | ||
| 52 | - </ul> | ||
| 53 | - <hr> | ||
| 54 | - <div class="all_price"> | ||
| 55 | - <p>Всего товаров: <span class="all_count">3</span></p> | ||
| 56 | - <p>Сумма: <span class="all_price">306.15</span> грн.</p> | ||
| 57 | - </div> | ||
| 58 | - <hr> | ||
| 59 | -</div> | 21 | + ?> |
| 22 | + | ||
| 23 | + <li> | ||
| 24 | + <div class="order_list_li" data-id="<?= $item['item']->product_variant_id?>"> | ||
| 25 | + <div class="delete_item_btn"><i class="fa fa-times"></i></div> | ||
| 26 | + <div class="little_img"> | ||
| 27 | + <?php if (empty($item['item']->product->image)) :?> | ||
| 28 | + <img src="/images/no_photo.png"> | ||
| 29 | + <?php else :?> | ||
| 30 | + <img src="/images/<?= $item['item']->product->image->image?>" alt="<?= $item['item']->product->image->alt ? $item['item']->product->image->alt : $item['item']->product->name?>"> | ||
| 31 | + <?php endif?> | ||
| 32 | + </div> | ||
| 33 | + <div class="name_and_code"> | ||
| 34 | + <span class="name"><?= $item['item']->name?></span> | ||
| 35 | + <span class="code"> Код: 45885-01016049</span> | ||
| 36 | + </div> | ||
| 37 | + <div class="count_block_wrap"> | ||
| 38 | + <div class="count_block"> | ||
| 39 | + <input type="text" name="" class="form-control buy_one_item" value="<?= $item['num']?>"> | ||
| 40 | + <div class="count_buttons"> | ||
| 41 | + <div class="button_plus">+</div> | ||
| 42 | + <div class="button_minus">-</div> | ||
| 43 | + </div> | ||
| 44 | + </div> | ||
| 45 | + <div class="price"><span class="price_val" data-price="<?= $item['item']->price ?>"><?= $item['item']->price * $item['num'] ?></span><span class="price_text">грн.</span></div> | ||
| 46 | + </div> | ||
| 47 | + </div> | ||
| 48 | + </li> | ||
| 49 | + <?php } ?> | ||
| 60 | 50 | ||
| 61 | -<div class="basket_step_2_delivery"> | ||
| 62 | - <h3>Детали</h3> | ||
| 63 | - <div class="detail"> | ||
| 64 | - <span class="grey">Имя</span>Артем | 51 | + </ul> |
| 52 | + <hr> | ||
| 53 | + <div class="all_price"> | ||
| 54 | + <p>Всего товаров: <span class="all_count"><?= $count ?></span></p> | ||
| 55 | + <p>Сумма: <span class="all_price all_price_span"><?= $price ?></span> грн.</p> | ||
| 56 | + </div> | ||
| 57 | + <hr> | ||
| 65 | </div> | 58 | </div> |
| 66 | - <div class="detail"> | ||
| 67 | - <span class="grey">E-mail</span>artem@mail.com | 59 | + |
| 60 | + <div class="basket_step_2_delivery"> | ||
| 61 | + <h3>Детали</h3> | ||
| 62 | + <div class="detail"> | ||
| 63 | + <span class="grey">Имя</span><?= $order_model->name ?> | ||
| 64 | + </div> | ||
| 65 | + <div class="detail"> | ||
| 66 | + <span class="grey">E-mail</span><?= $order_model->email ?> | ||
| 67 | + </div> | ||
| 68 | + <div class="detail"> | ||
| 69 | + <span class="grey">Телефон</span><?= $order_model->phone ?> | ||
| 70 | + </div> | ||
| 71 | + <h4>Способ оплаты</h4> | ||
| 72 | + <div class="detail">Оплата наличными</div> | ||
| 73 | + <h4>Доставка</h4> | ||
| 74 | + <div class="detail">Курьерска доставка по Киеву и области</div> | ||
| 68 | </div> | 75 | </div> |
| 69 | - <div class="detail"> | ||
| 70 | - <span class="grey">Телефон</span>050 340-34-34 | 76 | + |
| 77 | + <div class="for_margin_2"> | ||
| 78 | + <?= Html::submitButton(Yii::t('app', 'оформить заказ'), ['class' => 'order_01_btn', 'name' => 'signup-button']) ?> | ||
| 71 | </div> | 79 | </div> |
| 72 | - <h4>Способ оплаты</h4> | ||
| 73 | - <div class="detail">Оплата наличными</div> | ||
| 74 | - <h4>Доставка</h4> | ||
| 75 | - <div class="detail">Курьерска доставка по Киеву и области</div> | 80 | + |
| 81 | + <?php ActiveForm::end(); ?><!-- конец формы заказа --> | ||
| 76 | </div> | 82 | </div> |
| 77 | 83 | ||
| 78 | -<div class="for_margin_2"> | ||
| 79 | - <button type="submit" class="order_01_btn">оформить заказ</button> | ||
| 80 | -</div> | ||
| 81 | \ No newline at end of file | 84 | \ No newline at end of file |
frontend/web/css/concat_all.css
| @@ -2729,9 +2729,11 @@ span.red { | @@ -2729,9 +2729,11 @@ span.red { | ||
| 2729 | margin-right: 130px; | 2729 | margin-right: 130px; |
| 2730 | } | 2730 | } |
| 2731 | 2731 | ||
| 2732 | -.busket_modal_header .busket_modal_02 .order_list .busket_bottom_btn button { | 2732 | +.busket_modal_header .busket_modal_02 .order_list .busket_bottom_btn .button { |
| 2733 | display: inline-block; | 2733 | display: inline-block; |
| 2734 | padding: 10px 20px; | 2734 | padding: 10px 20px; |
| 2735 | + text-decoration: none; | ||
| 2736 | + margin: 0; | ||
| 2735 | color: white; | 2737 | color: white; |
| 2736 | background-color: #6aa034; | 2738 | background-color: #6aa034; |
| 2737 | border: none; | 2739 | border: none; |
| @@ -2743,14 +2745,14 @@ span.red { | @@ -2743,14 +2745,14 @@ span.red { | ||
| 2743 | box-shadow: 0px 2px 0px #517a27; | 2745 | box-shadow: 0px 2px 0px #517a27; |
| 2744 | } | 2746 | } |
| 2745 | 2747 | ||
| 2746 | -.busket_modal_header .busket_modal_02 .order_list .busket_bottom_btn button:active { | 2748 | +.busket_modal_header .busket_modal_02 .order_list .busket_bottom_btn .button:active { |
| 2747 | position: relative; | 2749 | position: relative; |
| 2748 | -webkit-box-shadow: none; | 2750 | -webkit-box-shadow: none; |
| 2749 | box-shadow: none; | 2751 | box-shadow: none; |
| 2750 | top: 2px; | 2752 | top: 2px; |
| 2751 | } | 2753 | } |
| 2752 | 2754 | ||
| 2753 | -.busket_modal_header .busket_modal_02 .order_list .busket_bottom_btn button:hover { | 2755 | +.busket_modal_header .busket_modal_02 .order_list .busket_bottom_btn .button:hover { |
| 2754 | background-color: #5d8d2e; | 2756 | background-color: #5d8d2e; |
| 2755 | } | 2757 | } |
| 2756 | 2758 | ||
| @@ -2768,7 +2770,174 @@ span.red { | @@ -2768,7 +2770,174 @@ span.red { | ||
| 2768 | .busket_modal_header .busket_modal_02 .order_list .delete_item_btn:hover { | 2770 | .busket_modal_header .busket_modal_02 .order_list .delete_item_btn:hover { |
| 2769 | color: red; | 2771 | color: red; |
| 2770 | } | 2772 | } |
| 2773 | +/********************BASKET *************************/ | ||
| 2774 | + | ||
| 2775 | + | ||
| 2776 | +.basket_form .order_list { | ||
| 2777 | + /*width: auto;*/ | ||
| 2778 | + padding: 25px 0px; | ||
| 2779 | +} | ||
| 2780 | + | ||
| 2781 | +.basket_form .order_list ul { | ||
| 2782 | + overflow-y: overlay; | ||
| 2783 | + overflow-x: hidden; | ||
| 2784 | +} | ||
| 2785 | + | ||
| 2786 | +.basket_form .order_list h3 { | ||
| 2787 | + text-transform: uppercase; | ||
| 2788 | + font-weight: normal; | ||
| 2789 | + font-size: 20px; | ||
| 2790 | + padding: 20px 0 15px; | ||
| 2791 | +} | ||
| 2792 | + | ||
| 2793 | +.basket_form .order_list .order_list_li { | ||
| 2794 | + display: block; | ||
| 2795 | + max-width:440px; | ||
| 2796 | + overflow: hidden; | ||
| 2797 | +} | ||
| 2798 | + | ||
| 2799 | + | ||
| 2800 | +.basket_form .order_list li:nth-child(even){ | ||
| 2801 | + background-color:#f4f4f4; | ||
| 2802 | +} | ||
| 2803 | +.busket_modal_01 .order_list li:nth-child(even){ | ||
| 2804 | + background-color:#f4f4f4; | ||
| 2805 | +} | ||
| 2806 | + | ||
| 2807 | +.basket_form .order_list .order_list_li .little_img { | ||
| 2808 | + /*float: none;*/ | ||
| 2809 | +} | ||
| 2810 | + | ||
| 2811 | +.basket_form .order_list .order_list_li .name_and_code { | ||
| 2812 | + text-align: left; | ||
| 2813 | + /*float: none;*/ | ||
| 2814 | +} | ||
| 2815 | + | ||
| 2816 | +.basket_form .order_list .order_list_li .name_and_code .name { | ||
| 2817 | + margin-bottom: 14px; | ||
| 2818 | +} | ||
| 2771 | 2819 | ||
| 2820 | +.basket_form .order_list .order_list_li .price { | ||
| 2821 | + padding: 0; | ||
| 2822 | +} | ||
| 2823 | + | ||
| 2824 | +.basket_form .order_list .order_list_li .count_block_wrap { | ||
| 2825 | + display: inline-block; | ||
| 2826 | + vertical-align: top; | ||
| 2827 | + text-align: right; | ||
| 2828 | + float: left; | ||
| 2829 | +} | ||
| 2830 | + | ||
| 2831 | +.basket_form .order_list .count_block { | ||
| 2832 | + display: block; | ||
| 2833 | + position: relative; | ||
| 2834 | + margin-bottom: 30px; | ||
| 2835 | +} | ||
| 2836 | + | ||
| 2837 | +.basket_form .order_list .count_block .count_number { | ||
| 2838 | + display: inline-block; | ||
| 2839 | + font-size: 22px; | ||
| 2840 | + padding: 6px 13px 3px; | ||
| 2841 | + -webkit-border-radius: 3px; | ||
| 2842 | + border-radius: 3px; | ||
| 2843 | + position: relative; | ||
| 2844 | + /*top: -2px;*/ | ||
| 2845 | + background-color: #fff; | ||
| 2846 | +} | ||
| 2847 | + | ||
| 2848 | +.basket_form .order_list .count_block .count_buttons { | ||
| 2849 | + position: relative; | ||
| 2850 | + /*top: 4px;*/ | ||
| 2851 | + right: 16px; | ||
| 2852 | + display: inline-block; | ||
| 2853 | + vertical-align: bottom; | ||
| 2854 | +} | ||
| 2855 | + | ||
| 2856 | +.basket_form .order_list .count_block .count_buttons .button_plus { | ||
| 2857 | + background-color: #898b8e; | ||
| 2858 | + color: white; | ||
| 2859 | + font-weight: bold; | ||
| 2860 | + border-bottom: 1px solid #707274; | ||
| 2861 | + -webkit-border-top-right-radius: 3px; | ||
| 2862 | + border-top-right-radius: 3px; | ||
| 2863 | + font-size: 15px; | ||
| 2864 | + line-height: 15px; | ||
| 2865 | + padding: 0 7px; | ||
| 2866 | + cursor: pointer; | ||
| 2867 | +} | ||
| 2868 | + | ||
| 2869 | +.basket_form .order_list .count_block .count_buttons .button_plus:hover { | ||
| 2870 | + background-color: #7c7e81; | ||
| 2871 | +} | ||
| 2872 | + | ||
| 2873 | +.basket_form .order_list .count_block .count_buttons .button_minus { | ||
| 2874 | + background-color: #898b8e; | ||
| 2875 | + color: white; | ||
| 2876 | + font-weight: bold; | ||
| 2877 | + line-height: 16px; | ||
| 2878 | + text-align: center; | ||
| 2879 | + border-top: 1px solid #A2A2A2; | ||
| 2880 | + -webkit-border-bottom-right-radius: 3px; | ||
| 2881 | + border-bottom-right-radius: 3px; | ||
| 2882 | + cursor: pointer; | ||
| 2883 | +} | ||
| 2884 | + | ||
| 2885 | +.basket_form .order_list .count_block .count_buttons .button_minus:hover { | ||
| 2886 | + background-color: #7c7e81; | ||
| 2887 | +} | ||
| 2888 | + | ||
| 2889 | +.basket_form .order_list .busket_bottom_btn { | ||
| 2890 | + margin-top: 20px; | ||
| 2891 | + text-align: center; | ||
| 2892 | +} | ||
| 2893 | + | ||
| 2894 | +.basket_form .order_list .busket_bottom_btn a { | ||
| 2895 | + display: inline-block; | ||
| 2896 | + font-size: 13px; | ||
| 2897 | + margin-right: 130px; | ||
| 2898 | +} | ||
| 2899 | + | ||
| 2900 | +.basket_form .order_list .busket_bottom_btn .button { | ||
| 2901 | + display: inline-block; | ||
| 2902 | + padding: 10px 20px; | ||
| 2903 | + text-decoration: none; | ||
| 2904 | + margin: 0; | ||
| 2905 | + color: white; | ||
| 2906 | + background-color: #6aa034; | ||
| 2907 | + border: none; | ||
| 2908 | + -webkit-border-radius: 2px; | ||
| 2909 | + border-radius: 2px; | ||
| 2910 | + font-size: 13px; | ||
| 2911 | + font-weight: normal; | ||
| 2912 | + -webkit-box-shadow: 0px 2px 0px #517a27; | ||
| 2913 | + box-shadow: 0px 2px 0px #517a27; | ||
| 2914 | +} | ||
| 2915 | + | ||
| 2916 | +.basket_form .order_list .busket_bottom_btn .button:active { | ||
| 2917 | + position: relative; | ||
| 2918 | + -webkit-box-shadow: none; | ||
| 2919 | + box-shadow: none; | ||
| 2920 | + top: 2px; | ||
| 2921 | +} | ||
| 2922 | + | ||
| 2923 | +.basket_form .order_list .busket_bottom_btn .button:hover { | ||
| 2924 | + background-color: #5d8d2e; | ||
| 2925 | +} | ||
| 2926 | + | ||
| 2927 | +.basket_form .order_list .delete_item_btn { | ||
| 2928 | + display: inline-block; | ||
| 2929 | + vertical-align: top; | ||
| 2930 | + margin-top: 30px; | ||
| 2931 | + padding: 0 10px 0 0; | ||
| 2932 | + cursor: pointer; | ||
| 2933 | + color: #C6C7C9; | ||
| 2934 | + font-size: 20px; | ||
| 2935 | + float: left; | ||
| 2936 | +} | ||
| 2937 | + | ||
| 2938 | +.basket_form .order_list .delete_item_btn:hover { | ||
| 2939 | + color: red; | ||
| 2940 | +} | ||
| 2772 | /*=============================================== CATEGORY PAGE ================================================*/ | 2941 | /*=============================================== CATEGORY PAGE ================================================*/ |
| 2773 | 2942 | ||
| 2774 | .category_page_main_title { | 2943 | .category_page_main_title { |
frontend/web/css/style.css
| @@ -866,7 +866,7 @@ padding-left:27px; | @@ -866,7 +866,7 @@ padding-left:27px; | ||
| 866 | left:20px; | 866 | left:20px; |
| 867 | } | 867 | } |
| 868 | .basket_head .bh_cell.text{ | 868 | .basket_head .bh_cell.text{ |
| 869 | - top:8px; | 869 | + top:20px; |
| 870 | left:66px; | 870 | left:66px; |
| 871 | } | 871 | } |
| 872 | .basket_head .basket_head_desc{ | 872 | .basket_head .basket_head_desc{ |
| 1 | +$(document).ready(function(){ | ||
| 2 | + | ||
| 3 | + var result_block = $('.basket_result'); | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + function changeAjaxPrice(id, num){ | ||
| 7 | + $.post( "/orders/buy-items", {id: id, num:num}, function( data ) { | ||
| 8 | + }); | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + function countPrise(block){ | ||
| 12 | + var totalBlock = block.parents('.order_list'); | ||
| 13 | + var total_price = 0; | ||
| 14 | + totalBlock.find('.price_val').each(function(){ | ||
| 15 | + total_price += +$(this).html(); | ||
| 16 | + }); | ||
| 17 | + $('.all_price_span').html(total_price); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + $('.item').on('click', '.basket_add_but', function(e){ | ||
| 22 | + var id = $(this).data('id'); | ||
| 23 | + $.post( "/orders/buy-items", {id: id, num:1}, function( data ) { | ||
| 24 | + $('.basket_result').each(function(){ | ||
| 25 | + $(this).html(data) | ||
| 26 | + }); | ||
| 27 | + }); | ||
| 28 | + | ||
| 29 | + }); | ||
| 30 | + | ||
| 31 | + $('.main_cont_wrap').on('click', '.cart_btn', function(e){ | ||
| 32 | + var id = $(this).data('id'); | ||
| 33 | + $.post( "/orders/buy-items", {id: id, num:1}, function( data ) { | ||
| 34 | + $('.basket_result').each(function(){ | ||
| 35 | + $(this).html(data) | ||
| 36 | + }); | ||
| 37 | + }); | ||
| 38 | + | ||
| 39 | + }); | ||
| 40 | + | ||
| 41 | + result_block.on('click', '.delete_item_btn', function(){ | ||
| 42 | + var block = $(this).parents('.order_list_li'); | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + var id = block.data('id'); | ||
| 46 | + | ||
| 47 | + $.post( "/orders/delete", {id: id}, function( data ) { | ||
| 48 | + }); | ||
| 49 | + | ||
| 50 | + $('.order_list_li[data-id='+id+']').each(function(){ | ||
| 51 | + var block = $(this); | ||
| 52 | + block.remove(); | ||
| 53 | + }); | ||
| 54 | + | ||
| 55 | + countPrise(block); | ||
| 56 | + | ||
| 57 | + }); | ||
| 58 | + | ||
| 59 | + result_block.on('click', '.button_minus', function(){ | ||
| 60 | + var block = $(this).parents('.order_list_li'); | ||
| 61 | + var price_block = block.find('.price_val'); | ||
| 62 | + var input = block.find('input'); | ||
| 63 | + var number = input.val(); | ||
| 64 | + var id = block.data('id'); | ||
| 65 | + | ||
| 66 | + if(number > 1){ | ||
| 67 | + number--; | ||
| 68 | + input.val(number); | ||
| 69 | + var price = price_block.data('price'); | ||
| 70 | + var new_price = number * +price; | ||
| 71 | + price_block.html(new_price); | ||
| 72 | + changeAjaxPrice(id, number); | ||
| 73 | + synchronizationPriceData(id, number); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + countPrise(block); | ||
| 77 | + }); | ||
| 78 | + | ||
| 79 | + | ||
| 80 | + result_block.on('click', '.button_plus', function(){ | ||
| 81 | + var block = $(this).parents('.order_list_li'); | ||
| 82 | + var price_block = block.find('.price_val'); | ||
| 83 | + var input = block.find('input'); | ||
| 84 | + var number = input.val(); | ||
| 85 | + var id = block.data('id'); | ||
| 86 | + | ||
| 87 | + number++; | ||
| 88 | + input.val(number); | ||
| 89 | + var price = price_block.data('price'); | ||
| 90 | + var new_price = number * +price; | ||
| 91 | + price_block.html(new_price); | ||
| 92 | + | ||
| 93 | + changeAjaxPrice(id, number); | ||
| 94 | + synchronizationPriceData(id, number); | ||
| 95 | + countPrise(block); | ||
| 96 | + }); | ||
| 97 | + | ||
| 98 | + result_block.on('change', '.buy_one_item', function(){ | ||
| 99 | + var block = $(this).parents('.order_list_li'); | ||
| 100 | + var num = $(this).val(); | ||
| 101 | + var price_block = block.find('.price_val'); | ||
| 102 | + var price = price_block.data('price'); | ||
| 103 | + var id = block.data('id'); | ||
| 104 | + | ||
| 105 | + var new_price = num * +price; | ||
| 106 | + price_block.html(new_price); | ||
| 107 | + changeAjaxPrice(id, num); | ||
| 108 | + synchronizationPriceData(id, num); | ||
| 109 | + countPrise(block); | ||
| 110 | + }); | ||
| 111 | + | ||
| 112 | + function synchronizationPriceData(id, number){ | ||
| 113 | + $('.order_list_li[data-id='+id+']').each(function(){ | ||
| 114 | + var block = $(this); | ||
| 115 | + block.find('input').val(number); | ||
| 116 | + var price_block = block.find('.price_val'); | ||
| 117 | + var price = price_block.data('price'); | ||
| 118 | + var new_price = number * +price; | ||
| 119 | + price_block.html(new_price); | ||
| 120 | + }); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + | ||
| 124 | + | ||
| 125 | +}); | ||
| 0 | \ No newline at end of file | 126 | \ No newline at end of file |
frontend/web/js/my_scripts.js
| @@ -149,11 +149,11 @@ $(document).ready(function(){ | @@ -149,11 +149,11 @@ $(document).ready(function(){ | ||
| 149 | forget_pass_again_btn = $('.forgot_pass_success_wrapper').find('.my_cust_btn'), | 149 | forget_pass_again_btn = $('.forgot_pass_success_wrapper').find('.my_cust_btn'), |
| 150 | log_open_btn = $('.login_button_lu'), // окно логина | 150 | log_open_btn = $('.login_button_lu'), // окно логина |
| 151 | reg_open_btn = $('.reg_button_lu'), // кнопка открыть | 151 | reg_open_btn = $('.reg_button_lu'), // кнопка открыть |
| 152 | - modal_busket_open = $('.basket_add_but'), // открыть модалку корзины | 152 | + modal_busket_open = $('.basket_add_but, .cart_btn'), // открыть модалку корзины |
| 153 | modal_busket_header_open = $('i.head-down.bh_cell'), // открыть корзину в хедере | 153 | modal_busket_header_open = $('i.head-down.bh_cell'), // открыть корзину в хедере |
| 154 | modal_busket_header = $('.busket_modal_header'), // модальная корзина хедер | 154 | modal_busket_header = $('.busket_modal_header'), // модальная корзина хедер |
| 155 | - modal_busket_header_cont = $('.busket_modal_header .busket_bottom_btn a'), | ||
| 156 | - modal_busket_cont = $('.busket_bottom_btn a'), // ссылка модалки корзины - продолжить покупки | 155 | + modal_busket_header_cont = $('.busket_modal_header .busket_bottom_btn .close'), |
| 156 | + modal_busket_cont = $('.busket_bottom_btn .close'), // ссылка модалки корзины - продолжить покупки | ||
| 157 | forgot_pass_open_btn = $('.forgot_pass_link'), // ссылка на окно - забыли пароль | 157 | forgot_pass_open_btn = $('.forgot_pass_link'), // ссылка на окно - забыли пароль |
| 158 | close_btn = $('.modal_close_btn'), // кнопка закрыть регистрацию | 158 | close_btn = $('.modal_close_btn'), // кнопка закрыть регистрацию |
| 159 | doc_h = $(document).height(), | 159 | doc_h = $(document).height(), |
| @@ -471,77 +471,5 @@ $(document).ready(function(){ | @@ -471,77 +471,5 @@ $(document).ready(function(){ | ||
| 471 | 471 | ||
| 472 | 472 | ||
| 473 | //=============================================== BUSKET MODAL WINDOW FUNCTIONS | 473 | //=============================================== BUSKET MODAL WINDOW FUNCTIONS |
| 474 | - function all_modal_moves(){ | ||
| 475 | - // BUSKET MODAL WINDOW ITEM DELETE | ||
| 476 | - var delete_item_btn = $('.delete_item_btn').click(function(){ | ||
| 477 | - $(this).closest('li').remove(); | ||
| 478 | - }); | ||
| 479 | - } | ||
| 480 | - all_modal_moves(); | ||
| 481 | - | ||
| 482 | - | ||
| 483 | - function countPrise(block){ | ||
| 484 | - var total_price = 0; | ||
| 485 | - block.find('.price').each(function(){ | ||
| 486 | - total_price += +$(this).html(); | ||
| 487 | - }); | ||
| 488 | - $('.total_price').html(total_price); | ||
| 489 | - $("input[name='OrderForm[total_price]']").val(total_price); | ||
| 490 | - } | ||
| 491 | - | ||
| 492 | - | ||
| 493 | - $('.item').on('click', '.basket_add_but', function(e){ | ||
| 494 | - var id = $(this).parents('.item').data('id'); | ||
| 495 | - console.log(id); | ||
| 496 | - $.post( "/orders/buy-items", {id: id}, function( data ) { | ||
| 497 | - $('.basket_result').each(function(){ | ||
| 498 | - $(this).html(data) | ||
| 499 | - }); | ||
| 500 | - }); | ||
| 501 | - | ||
| 502 | - }); | ||
| 503 | - | ||
| 504 | - $('.basket_result').on('click', '.delete_item_btn', function(){ | ||
| 505 | - var id = $(this).parents('.order_list_li').data('id'); | ||
| 506 | - $(this).parents('.order_list_li').remove(); | ||
| 507 | - $.post( "/orders/delete", {id: id}, function( data ) { | ||
| 508 | - }); | ||
| 509 | - countPrise(); | ||
| 510 | - }); | ||
| 511 | - | ||
| 512 | - $('.basket_result').on('click', '.button_minus', function(){ | ||
| 513 | - var input = $(this).parents('.order_list_li ').find('input'); | ||
| 514 | - var number = input.val(); | ||
| 515 | - if(number > 1){ | ||
| 516 | - number--; | ||
| 517 | - input.val(number); | ||
| 518 | - var price = $(this).parents('.goods_data').find('.item_prise_block').find('span').html(); | ||
| 519 | - var new_price = number * price; | ||
| 520 | - $(this).parents('.goods_data').find('.item_prise_total_block').find('span').html(new_price); | ||
| 521 | - } | ||
| 522 | - countPrise(); | ||
| 523 | - }); | ||
| 524 | - | ||
| 525 | - | ||
| 526 | - $('.basket_result').on('click', '.button_plus', function(){ | ||
| 527 | - var input = $(this).parents('.order_list_li ').find('input'); | ||
| 528 | - var number = input.val(); | ||
| 529 | - number++; | ||
| 530 | - input.val(number); | ||
| 531 | - var price = $(this).parents('.goods_data').find('.item_prise_block').find('span').html(); | ||
| 532 | - var new_price = number * price; | ||
| 533 | - $(this).parents('.goods_data').find('.item_prise_total_block').find('span').html(new_price); | ||
| 534 | - countPrise(); | ||
| 535 | - }); | ||
| 536 | - | ||
| 537 | - $('.basket_result').on('change', '.buy_one_item', function(){ | ||
| 538 | - var num = $(this).val(); | ||
| 539 | - var priceBlock = $(this).parents('.order_list_li').find('.price'); | ||
| 540 | - var price = priceBlock.html(); | ||
| 541 | - var new_price = num * price; | ||
| 542 | - priceBlock.html(new_price); | ||
| 543 | - countPrise(); | ||
| 544 | - }); | ||
| 545 | - | ||
| 546 | 474 | ||
| 547 | }); | 475 | }); |
| 548 | \ No newline at end of file | 476 | \ No newline at end of file |