Commit fa61b27ce693ca02d4c178e457e2050c14b55af8

Authored by Administrator
2 parents db13b814 eeca8658

Merge remote-tracking branch 'origin/master'

src/app/backend/controllers/DiscountController.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: Alex Savenko
  5 + * Date: 20.12.2016
  6 + * Time: 13:35
  7 + */
  8 +
  9 +namespace controllers;
  10 +
  11 +use Phalcon\Mvc\Controller;
  12 +
  13 +/**
  14 + * Class DiscountController
  15 + * @package controllers
  16 + * @property \models models
  17 + */
  18 +class DiscountController extends Controller
  19 +{
  20 +
  21 + /**
  22 + * Displays all discounts with pagination
  23 + * @return \Phalcon\Http\ResponseInterface
  24 + */
  25 + public function indexAction() {
  26 +
  27 + if( !$this->session->get('isAdminAuth') ) {
  28 +
  29 + return $this->response->redirect([ 'for' => 'admin_login' ]);
  30 +
  31 + }
  32 +
  33 + $params = $this->dispatcher->getParams();
  34 + $page = !empty( $params['page'] ) ? $params['page'] : 1;
  35 + $data = $this->models->getDiscount()->getAllData();
  36 + $total = $this->models->getDiscount()->countData();
  37 +
  38 + if( $total['0']['total'] > \config::get( 'limits/items') ) {
  39 +
  40 + $paginate = $this->common->paginate(
  41 + [
  42 + 'page' => $page,
  43 + 'items_per_page' => \config::get( 'limits/admin_orders', 5),
  44 + 'total_items' => $total[0]['total'],
  45 + 'url_for' => [ 'for' => 'discount_index_paged', 'page' => $page ],
  46 + 'index_page' => 'discount_index'
  47 + ], true
  48 + );
  49 +
  50 + }
  51 + $this->view->setVars([
  52 + 'info' => $data,
  53 + 'paginate' => !empty($paginate['output']) ? $paginate['output'] : '' ,
  54 + ]);
  55 +
  56 + }
  57 +
  58 + /**
  59 + * Add discount form
  60 + * @return \Phalcon\Http\ResponseInterface
  61 + */
  62 + public function addAction() {
  63 +
  64 + $titlecmp = function ($a, $b) {
  65 +
  66 + return strcasecmp($a['title'], $b['title']);
  67 +
  68 + };
  69 +
  70 + $lang_id = 1; // ua language
  71 + if( !$this->session->get('isAdminAuth') ) {
  72 +
  73 + return $this->response->redirect([ 'for' => 'admin_login' ]);
  74 +
  75 + }
  76 +
  77 + if( $this->request->isPost() ) {
  78 +
  79 + $data['name'] = $this->request->getPost('name', 'string', NULL );
  80 + $data['description'] = $this->request->getPost('description');
  81 + $data['start_date'] = $this->request->getPost('start_date');
  82 + $data['end_date'] = $this->request->getPost('end_date');
  83 + $data['discount'] = $this->request->getPost('discount', 'string', NULL );
  84 + $data['status'] = 1;
  85 +
  86 +
  87 + //$data['catalog_ids'] = $this->request->getPost('catalog', 'string', NULL );
  88 + $data['group_ids'] = $this->request->getPost('items', 'string', NULL );
  89 + //$data['all_items'] = $this->request->getPost('all_items', 'int', NULL);
  90 +
  91 + if ($data['discount'] > 100) {
  92 +
  93 + $this->flash->error( 'Размер скидки не может привышать 100' );
  94 +
  95 + }
  96 + else {
  97 +
  98 + if(!empty($data['group_ids']) && $this->models->getDiscount()->addData( $data )) {
  99 +
  100 + $this->flash->success( 'Сохранение прошло успешно' );
  101 + return $this->response->redirect([ 'for' => 'discount_index' ]);
  102 +
  103 + }
  104 + else {
  105 +
  106 + $this->flash->error( 'Выберите товары на которые распространяется скидка' );
  107 +
  108 + }
  109 +
  110 + }
  111 +
  112 + }
  113 +
  114 + $catalog_temp = $this->common->getTypeSubtype1(NULL, $lang_id)['catalog'];
  115 + usort($catalog_temp, $titlecmp);
  116 +
  117 +
  118 + $this->view->setVar('catalog_temp', $catalog_temp);
  119 + $this->view->pick( 'discount/addEdit' );
  120 +
  121 + }
  122 +
  123 + /**
  124 + * Delete discount by $id
  125 + * @param $id
  126 + * @return \Phalcon\Http\ResponseInterface
  127 + */
  128 + public function deleteAction($id) {
  129 +
  130 + if( !$this->session->get('isAdminAuth') ) {
  131 +
  132 + return $this->response->redirect([ 'for' => 'admin_login' ]);
  133 +
  134 + }
  135 +
  136 + $this->models->getDiscount()->deleteData($id);
  137 +
  138 + return $this->response->redirect([ 'for' => 'discount_index' ]);
  139 +
  140 + }
  141 +
  142 + /**
  143 + * Update discount form
  144 + * @param $id
  145 + * @return \Phalcon\Http\ResponseInterface
  146 + */
  147 + public function updateAction($id) {
  148 +
  149 + $titlecmp = function ($a, $b) {
  150 +
  151 + return strcasecmp($a['title'], $b['title']);
  152 +
  153 + };
  154 +
  155 + $lang_id = 1; // ua language
  156 +
  157 + if( !$this->session->get('isAdminAuth') ) {
  158 +
  159 + return $this->response->redirect([ 'for' => 'admin_login' ]);
  160 +
  161 + }
  162 +
  163 + $data = $this->models->getDiscount()->getOneData($id);
  164 +
  165 + if( $this->request->isPost() ) {
  166 +
  167 + $data[0]['name'] = $this->request->getPost('name', 'string', NULL );
  168 + $data[0]['discount'] = $this->request->getPost('discount', 'int', 0 );
  169 + $data[0]['start_date'] = $this->request->getPost('start_date');
  170 + $data[0]['end_date'] = $this->request->getPost('end_date');
  171 + $data[0]['description'] = $this->request->getPost('description');
  172 + $data[0]['group_ids'] = $this->request->getPost('items', 'string', NULL );
  173 +
  174 + if ($data[0]['discount'] > 100) {
  175 +
  176 + $this->flash->error( 'Размер скидки не может привышать 100' );
  177 +
  178 + }
  179 + else {
  180 +
  181 + if($this->models->getDiscount()->updateData( $data[0], $id ) ) {
  182 +
  183 + $this->flash->success( 'Сохранение прошло успешно' );
  184 + return $this->response->redirect([ 'for' => 'discount_index' ]);
  185 +
  186 + }
  187 + else {
  188 +
  189 + $this->flash->error( 'Update error.' );
  190 +
  191 + }
  192 +
  193 + }
  194 +
  195 +
  196 + }
  197 +
  198 + $data[0]['group_ids'] = $this->common->parseArray($data[0]['group_ids']);
  199 + //$data[0]['catalog_ids'] = $this->common->parseArray($data[0]['catalog_ids']);
  200 +
  201 + $catalog_temp = $this->common->getTypeSubtype1(NULL, $lang_id)['catalog'];
  202 + usort($catalog_temp, $titlecmp);
  203 +
  204 + foreach($catalog_temp as &$group) {
  205 +
  206 + usort($group['sub'], $titlecmp);
  207 +
  208 + }
  209 +
  210 + if(!empty($data[0]['group_ids'][0])) {
  211 +
  212 + $groups = $this->models->getItems()->getItemsByIds($lang_id, $data[0]['group_ids']);
  213 + usort($groups, $titlecmp);
  214 +
  215 + }
  216 +
  217 + $this->view->pick( 'discount/addEdit' );
  218 +
  219 + $this->view->setVars([
  220 + 'page' => $data,
  221 + 'catalog_temp' => $catalog_temp,
  222 + 'groups' => !empty($groups) ? $groups : null
  223 + ]);
  224 +
  225 + }
  226 +
  227 + /**
  228 + * Switch status indicator
  229 + * @param $id
  230 + * @return \Phalcon\Http\ResponseInterface
  231 + */
  232 + public function switchAction($id) {
  233 +
  234 + if( !$this->session->get('isAdminAuth') ) {
  235 +
  236 + return $this->response->redirect([ 'for' => 'admin_login' ]);
  237 +
  238 + }
  239 +
  240 + $status = $this->models->getDiscount()->getStatus($id);
  241 +
  242 + if ($status == 1) {
  243 +
  244 + $this->models->getDiscount()->updateStatus('0', $id);
  245 +
  246 + }
  247 + elseif ($status == 0) {
  248 +
  249 + $this->models->getDiscount()->updateStatus('1', $id);
  250 +
  251 + }
  252 + else {
  253 +
  254 + $this->flash->error(var_dump($status));
  255 +
  256 + }
  257 +
  258 + return $this->response->redirect([ 'for' => 'discount_index' ]);
  259 +
  260 + }
  261 +}
0 262 \ No newline at end of file
... ...
src/app/backend/controllers/PromoCodesController.php
... ... @@ -26,8 +26,8 @@ class PromoCodesController extends Controller
26 26 'page' => $page,
27 27 'items_per_page' => \config::get( 'limits/admin_orders', 5),
28 28 'total_items' => $total[0]['total'],
29   - 'url_for' => [ 'for' => 'promo_codes_index_paged', 'page' => $page ],
30   - 'index_page' => 'promo_codes_index'
  29 + 'url_for' => [ 'for' => 'discount_index_paged', 'page' => $page ],
  30 + 'index_page' => 'discount_index'
31 31 ], true
32 32 );
33 33 }
... ... @@ -38,54 +38,54 @@ class PromoCodesController extends Controller
38 38 }
39 39  
40 40 public function addAction() {
41   - $titlecmp = function ($a, $b) {
42   - return strcasecmp($a['title'], $b['title']);
43   - };
44   - $lang_id = 1; // ua language
45   - if( !$this->session->get('isAdminAuth') )
46   - {
47   - return $this->response->redirect([ 'for' => 'admin_login' ]);
48   - }
  41 + $titlecmp = function ($a, $b) {
  42 + return strcasecmp($a['title'], $b['title']);
  43 + };
  44 + $lang_id = 1; // ua language
  45 + if( !$this->session->get('isAdminAuth') )
  46 + {
  47 + return $this->response->redirect([ 'for' => 'admin_login' ]);
  48 + }
49 49  
50   - if( $this->request->isPost() )
  50 + if( $this->request->isPost() )
  51 + {
  52 +
  53 + $data['name'] = $this->request->getPost('name', 'string', NULL );
  54 + $data['code'] = $this->request->getPost('code', 'string', NULL );
  55 + $data['start_date'] = $this->request->getPost('start_date');
  56 + $data['end_date'] = $this->request->getPost('end_date');
  57 + $data['single_use'] = $this->request->getPost('single_use');
  58 + $data['discount'] = $this->request->getPost('discount', 'string', NULL );
  59 + $data['description'] = $this->request->getPost('description');
  60 + $data['catalog_ids'] = $this->request->getPost('catalog', 'string', NULL );
  61 + $data['group_ids'] = $this->request->getPost('items', 'string', NULL );
  62 + $data['all_items'] = $this->request->getPost('all_items', 'int', NULL);
  63 + $data['image'] = $this->uploadImage();
  64 +
  65 + if( empty($this->models->getPromoCodes()->getPromoByCode( $data['code'] )[0]) )
51 66 {
52   -
53   - $data['name'] = $this->request->getPost('name', 'string', NULL );
54   - $data['code'] = $this->request->getPost('code', 'string', NULL );
55   - $data['start_date'] = $this->request->getPost('start_date');
56   - $data['end_date'] = $this->request->getPost('end_date');
57   - $data['single_use'] = $this->request->getPost('single_use');
58   - $data['discount'] = $this->request->getPost('discount', 'string', NULL );
59   - $data['description'] = $this->request->getPost('description');
60   - $data['catalog_ids'] = $this->request->getPost('catalog', 'string', NULL );
61   - $data['group_ids'] = $this->request->getPost('items', 'string', NULL );
62   - $data['all_items'] = $this->request->getPost('all_items', 'int', NULL);
63   - $data['image'] = $this->uploadImage();
64   -
65   - if( empty($this->models->getPromoCodes()->getPromoByCode( $data['code'] )[0]) )
  67 + if(!empty($data['group_ids']) && $this->models->getPromoCodes()->addData( $data ))
66 68 {
67   - if(!empty($data['group_ids']) && $this->models->getPromoCodes()->addData( $data ))
68   - {
69   - $this->flash->success( 'Сохранение прошло успешно' );
70   - return $this->response->redirect([ 'for' => 'promo_codes_index' ]);
71   - }
72   - else
73   - {
74   - $this->flash->error( 'Выберите товары для промокода' );
75   - }
  69 + $this->flash->success( 'Сохранение прошло успешно' );
  70 + return $this->response->redirect([ 'for' => 'promo_codes_index' ]);
76 71 }
77   - else {
78   - $this->flash->error('Такой промокод уже существует');
  72 + else
  73 + {
  74 + $this->flash->error( 'Выберите товары для промокода' );
79 75 }
80 76 }
  77 + else {
  78 + $this->flash->error('Такой промокод уже существует');
  79 + }
  80 + }
81 81  
82   - $catalog_temp = $this->common->getTypeSubtype1(NULL, $lang_id)['catalog'];
83   - usort($catalog_temp, $titlecmp);
  82 + $catalog_temp = $this->common->getTypeSubtype1(NULL, $lang_id)['catalog'];
  83 + usort($catalog_temp, $titlecmp);
84 84  
85 85  
86   - $this->view->setVar('catalog_temp', $catalog_temp);
87   - $this->view->pick( 'promo_codes/addEdit' );
88   - }
  86 + $this->view->setVar('catalog_temp', $catalog_temp);
  87 + $this->view->pick( 'promo_codes/addEdit' );
  88 +}
89 89  
90 90 public function deleteAction($id) {
91 91 if( !$this->session->get('isAdminAuth') )
... ...
src/app/backend/views/discount/addEdit.php 0 → 100644
  1 +<div id="addEdit">
  2 + <div class="inner"><?= $this->flash->output(); ?></div>
  3 + <div class="inner">
  4 + <div class="sidebar_content_wrapper clearfix">
  5 + <div class="sidebar_wrapper float">
  6 + <div class="sidebar clearfix">
  7 + <?= $this->partial('partial/sidebar') ?>
  8 + </div>
  9 + </div>
  10 + <div class="content_wrapper float">
  11 + <div class="content_wrapper_list clearfix">
  12 + <div class="table_name header_gradient"></div>
  13 +
  14 + <div class="table_pages_wrapper">
  15 + <form enctype="multipart/form-data" method="post" action="" id="discount_add_edit">
  16 +
  17 + <div class="clearfix input_wrapper">
  18 + <div class="label"><label for="name">Название</label></div>
  19 + <div class="input"><input required type="text" name="name" id="name" value='<?= (isset( $page['0']['name'] ) && !empty( $page['0']['name'] ) ? $page['0']['name'] : '') ?>'></div>
  20 + </div>
  21 +
  22 + <div class="clearfix input_wrapper">
  23 + <div class="label"><label for="discount">Скидка</label></div>
  24 + <div class="input"><input required type="text" name="discount" id="discount" value='<?= (isset( $page['0']['discount'] ) && !empty( $page['0']['discount'] ) ? $page['0']['discount'] : '') ?>'></div>
  25 + </div>
  26 +
  27 + <div class="clearfix input_wrapper">
  28 + <div class="label"><label for="start_date">Дата начала действия скидки (включительно)</label></div>
  29 + <div class="input">
  30 + <input required type="text" name="start_date" id="start_date"
  31 + value="<?= (isset( $page['0']['start_date'] ) && !empty( $page['0']['start_date'] ) ? date('d-m-Y H:i:s', strtotime($page['0']['start_date'])) : '') ?>">
  32 +
  33 + </div>
  34 + </div>
  35 +
  36 + <div class="clearfix input_wrapper">
  37 + <div class="label"><label for="end_date">Дата окончания действия скидки (включительно)</label></div>
  38 + <div class="input">
  39 + <input required type="text" name="end_date" id="end_date"
  40 + value="<?= (isset( $page['0']['end_date'] ) && !empty( $page['0']['end_date'] ) ? date('d-m-Y H:i:s' , strtotime($page['0']['end_date'])) : '') ?>">
  41 + </div>
  42 + </div>
  43 +
  44 + <div class="clearfix input_wrapper">
  45 + <div class="label"><label for="description">Описание</label></div>
  46 + <div class="input">
  47 + <textarea name="description" id="description">
  48 + <?= (isset( $page['0']['description'] ) && !empty( $page['0']['description'] ) ? $page['0']['description'] : '') ?>
  49 + </textarea>
  50 + </div>
  51 + </div>
  52 +
  53 + <div class="clearfix input_wrapper">
  54 + <div class="label"><label for="catalog">Категории товаров</label></div>
  55 + <div class="input">
  56 + <select class="catalog" id="catalog">
  57 + <option selected label=" "></option>
  58 + <?php foreach($catalog_temp as $group): ?>
  59 + <option value="<?= $group['id'] ?>"><?= $group['title'] ?></option>
  60 + <?php endforeach; ?>
  61 + </select>
  62 + </div>
  63 + <button type="button" id="apply_filter">Применить</button>
  64 + <div class="input">
  65 + <div>Цена</div>
  66 + <label for="from_price">От</label>
  67 + <input type="text" id="from_price">
  68 + <label for="to_price">До</label>
  69 + <input type="text" id="to_price">
  70 + </div>
  71 + <div class="filter">
  72 +
  73 + </div>
  74 + </div>
  75 +
  76 +
  77 + <div class="clearfix input_wrapper products">
  78 +
  79 + </div>
  80 +
  81 + <div class="clearfix input_wrapper chose_items">
  82 + <?php if(isset($groups) && !empty($groups)): ?>
  83 + <?php foreach($groups as $group): ?>
  84 + <div>
  85 + <label>
  86 + <input disabled checked style="display:inline-block" id="items" name="items[]" class="items" type="checkbox"
  87 + value="<?= $group['id'] ?>"> <?= $group['title'] ?> <?= $group['size'] ?> <?= $group['price2'] ?> грн.
  88 + </label>
  89 + <button type="button" class="delete_item">Удалить</button>
  90 + </div>
  91 + <?php endforeach; ?>
  92 + <?php endif; ?>
  93 + </div>
  94 +
  95 + <div class="clearfix submit_wrapper">
  96 + <a href="<?= $this->url->get([ 'for' => 'discount_index' ]) ?>" class="news_cancel float">Отмена</a>
  97 + <input type="submit" class="news_submit float" name="save" value="Сохранить">
  98 + </div>
  99 +
  100 + </form>
  101 + </div>
  102 + </div>
  103 + </div>
  104 + </div>
  105 + </div>
  106 +</div>
  107 +<script>
  108 +
  109 + var datepicker = {
  110 + format: "d-m-Y H:i:s"
  111 + };
  112 + var $body = $('body');
  113 + var filter = new Filter();
  114 + var catalog = new Catalog(<?= json_encode($catalog_temp) ?>);
  115 + console.log(catalog.getCatalog());
  116 +
  117 + $('#start_date').datetimepicker(datepicker);
  118 + $('#end_date').datetimepicker(datepicker);
  119 +
  120 + $("form").submit(function() {
  121 + $("input").removeAttr("disabled");
  122 + });
  123 +
  124 + $('#add_category, #add_item').click(function() {
  125 + var parent = $(this).parent();
  126 + var select = parent.find('.input');
  127 + var clone = select.clone()[0];
  128 + parent.append(clone);
  129 + });
  130 +
  131 + $('#generate').click(function() {
  132 + var length = 7;
  133 + var code = generateCode(length);
  134 + $('#code').val(code);
  135 + });
  136 +
  137 + $body.on('click', '.delete_item', function() {
  138 + var parent = $(this).parent();
  139 + parent.remove();
  140 + });
  141 +
  142 +
  143 + $body.on('change', '.catalog', function () {
  144 + var $filter = $('.filter');
  145 + var catalog_id = $(this).val();
  146 + var sub = catalog.getSub(catalog_id, catalog.getCatalog());
  147 +
  148 + if(!sub) {
  149 + $.ajax({
  150 + url: '/get_filters_by_catalog',
  151 + method: 'GET',
  152 + data: {
  153 + catalog_id : catalog_id
  154 + },
  155 + dataType: 'json'
  156 + }).done(function (data) {
  157 + filter.setFilters(data);
  158 + filter.render($filter);
  159 + });
  160 + } else {
  161 + var next = $(this).next('select');
  162 +
  163 + while(next.length) {
  164 + next.remove();
  165 + next = $(this).next('select');
  166 + }
  167 +
  168 + $(this).after(catalog.renderSub(sub));
  169 + }
  170 + });
  171 +
  172 + $('#apply_filter').click(function (e) {
  173 + e.preventDefault();
  174 + var $catalog = $('.catalog');
  175 + var l = $catalog.length;
  176 + var $input = $('.products');
  177 + var prices = [];
  178 +
  179 + prices.push(Number($('#from_price').val()) || 0);
  180 + prices.push(Number($('#to_price').val()) || Number.MAX_SAFE_INTEGER || 1000000);
  181 + $.ajax({
  182 + url: '/get_items_by_filter',
  183 + method: 'POST',
  184 + data: {
  185 + filters : filter.getFilters(),
  186 + catalog_id : $catalog[l-1].value,
  187 + prices : prices
  188 + },
  189 + dataType: 'json'
  190 + }).done(function (data) {
  191 + renderItems(data, $input);
  192 + });
  193 + });
  194 +
  195 + $body.on('click', '#add_goods', function () {
  196 + var parent_items = $('.filter_item:checked').parent().parent().clone();
  197 + parent_items.append('<button type="button" class="delete_item">Удалить</button>');
  198 + var inputs = parent_items.find('input');
  199 + inputs.prop('disabled', true);
  200 + inputs.prop('name', 'items[]');
  201 + inputs.prop('class', 'items');
  202 + inputs.prop('id', 'items');
  203 + $('.chose_items').append(parent_items);
  204 + });
  205 +
  206 + $body.on('click', '.delete_item', function () {
  207 + var parent = $(this).parent();
  208 + parent.remove();
  209 + });
  210 +
  211 + $body.on('change', '#choose_all', function () {
  212 + var checked = $(this).prop('checked');
  213 + $('.filter_item').prop( "checked", checked );
  214 + });
  215 +
  216 +
  217 + function renderItems(data, parent) {
  218 + parent.empty();
  219 +
  220 + var items = '<div><label><input style="display: inline-block" id="choose_all" type="checkbox">Выбрать все</label></div>';
  221 +
  222 + data.forEach(function(element){
  223 + items += '<div><label><input style="display:inline-block" class="filter_item" type="checkbox" value="'
  224 + + element.item_id + '">' + element.title + ' ' + element.size + ' ' + element.price2 + ' грн.'
  225 + + '</label></div>';
  226 + });
  227 + items += '<div><button type="button" id="add_goods">Добавить товары</button></div>';
  228 + parent.append(items);
  229 + }
  230 +
  231 + function Filter() {
  232 + var _filters = {};
  233 + this.render = function ($parent) {
  234 + $parent.empty();
  235 + var html = '';
  236 + forEach(_filters, function(element, key) {
  237 + html += '<div style="display: inline-block; margin: 5px;"><h4>' + key + '</h4>';
  238 + html += '<div>';
  239 + forEach(element, function (v) {
  240 + html += '<label><input type="checkbox" style="display:inline-block" id="' + v['id'] + '" value="' + v['filter_value_id'] +'">'
  241 + + v['filter_value_value'] + '</label></input><br/>';
  242 + $('body').on('change', '#' + v['id'], function() {
  243 + updateFilters(v['id']);
  244 + });
  245 + });
  246 +
  247 + html += '</div></div>';
  248 + });
  249 + $parent.append(html);
  250 +
  251 + };
  252 + this.setFilters = function (filters) {
  253 + _filters = filters;
  254 + };
  255 +
  256 + this.getFilters = function () {
  257 + var ids = [];
  258 + forEach(_filters, function(element) {
  259 + forEach(element, function (v) {
  260 + if(v.checked)
  261 + ids.push(v.id);
  262 + });
  263 + });
  264 + return ids;
  265 + };
  266 +
  267 + function updateFilters (filter_id) {
  268 + forEach(_filters, function(element) {
  269 + forEach(element, function (v) {
  270 + if(v.id == filter_id)
  271 + v.checked = !v.checked;
  272 + });
  273 + });
  274 + }
  275 + }
  276 +
  277 + function Catalog(catalog) {
  278 + var _catalog = catalog;
  279 +
  280 + this.getCatalog = function() {
  281 + return _catalog;
  282 + };
  283 +
  284 + this.getSub = function getSub(catalog_id, catalog) {
  285 + var result = null;
  286 + forEach(catalog, function (element) {
  287 + if(element.id == catalog_id) {
  288 + result = element.sub;
  289 + }
  290 + if(element.sub) {
  291 + var t = getSub(catalog_id, element.sub);
  292 + result = t || result;
  293 + }
  294 + });
  295 + return result;
  296 + };
  297 +
  298 + this.renderSub = function (sub) {
  299 + var select = '<select class="catalog" id="catalog">';
  300 + select += '<option disabled selected label=" "></option>';
  301 + forEach(sub, function (element) {
  302 + select += '<option value="' + element.id + '">' + element.title + '</option>';
  303 + });
  304 + select += '</select>';
  305 + return select;
  306 + }
  307 + }
  308 +
  309 + function generateCode(length) {
  310 + var code = '';
  311 + for(var i = 0; i < length; i++)
  312 + code += Math.floor(Math.random() * 10);
  313 + return code;
  314 + }
  315 +
  316 + function forEach(obj, callback) {
  317 + for(var key in obj) {
  318 + if(obj.hasOwnProperty(key)) {
  319 + callback(obj[key], key);
  320 + }
  321 + }
  322 + }
  323 +
  324 +
  325 +</script>
0 326 \ No newline at end of file
... ...
src/app/backend/views/discount/index.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: Alex Savenko
  5 + * Date: 20.12.2016
  6 + * Time: 15:46
  7 + */
  8 +?>
  9 +
  10 +<div id="static_page">
  11 + <div class="inner"><?= $this->flash->output(); ?></div>
  12 +<div class="inner">
  13 + <div class="sidebar_content_wrapper clearfix">
  14 + <div class="sidebar_wrapper float">
  15 + <div class="sidebar clearfix">
  16 + <?= $this->partial('partial/sidebar') ?>
  17 + </div>
  18 + </div>
  19 + <div class="content_wrapper float">
  20 + <div class="h_700">
  21 + <div class="content_wrapper_list clearfix">
  22 + <div class="table_name header_gradient">Скидки</div>
  23 + <div class="table_add_page"><a href="<?= $this->url->get([ 'for' => 'discount_add' ]) ?>" title="Добавить">Добавить</a></div>
  24 +
  25 + <div class="table_pages_wrapper">
  26 +
  27 + <?php
  28 +
  29 + if( !empty( $info ) )
  30 + {
  31 + $data_pages = '';
  32 +
  33 + foreach( $info as $p )
  34 + {
  35 + if ($p['status'] == '1') {
  36 + $status_class = 'one_page_status_on_ico';
  37 + } else {
  38 + $status_class = 'one_page_status_off_ico';
  39 + }
  40 +
  41 + $data_pages .=
  42 + '<div class="one_page_edit header_gradient clearfix">'.
  43 + '<div class="one_page_edit_check float"></div>'.
  44 + '<div class="one_page_edit_name float"><a href="/discount_update/'.$p['id'].'" title="">'.$p['name'].'</a></div>'.
  45 + '<div class="'.$status_class.' float_right"><a href="/discount_switch/'.$p['id'].'" title="Изменить статус" onclick="return confirm(\'Вы действительно хотите изменить статус?\')"></a></div>'.
  46 + '<div class="one_page_delete_ico float_right"><a href="/discount_delete/'.$p['id'].'" title="Удалить" onclick="return confirm(\'Вы действительно хотите удалить информацию?\')"></a></div>'.
  47 + '<div class="one_page_edit_ico float_right"><a href="/discount_update/'.$p['id'].'" title="Редактировать"></a></div>'.
  48 + '</div>';
  49 + }
  50 +
  51 +
  52 + echo( $data_pages );
  53 + }
  54 +
  55 + ?>
  56 +
  57 + </div>
  58 +
  59 + </div>
  60 + <div class="inner">
  61 + <div class="paginate">
  62 + <?=$paginate?>
  63 + </div>
  64 + </div>
  65 + </div>
  66 +
  67 + </div>
  68 +
  69 + </div>
  70 +</div>
  71 +</div>
... ...
src/app/backend/views/partial/sidebar.php
... ... @@ -57,6 +57,7 @@
57 57 <ul class="body">
58 58 <li class="point4"><a href="<?= $this->url->get([ 'for' => 'reviews_index' ]) ?>" title="Акции">Отзывы</a></li>
59 59 <li class="point4"><a href="<?= $this->url->get([ 'for' => 'sales_index' ]) ?>" title="Акции">Акции основного сайта</a></li>
  60 + <li class="point4"><a href="<?= $this->url->get([ 'for' => 'discount_index' ]) ?>" title="Промокоды">Скидки</a></li>
60 61 <li class="point4"><a href="<?= $this->url->get([ 'for' => 'promo_codes_index' ]) ?>" title="Промокоды">Промокоды</a></li>
61 62 <li class="point4"><a href="<?= $this->url->get([ 'for' => 'action_discount_index' ]) ?>" title="Акции">Акции для магазина</a></li>
62 63 <li class="point4"><a href="<?= $this->url->get([ 'for' => 'actions_index' ]) ?>" title="Пределы">Пределы акций для магазина</a></li>
... ...
src/app/backend/views/promo_codes/addEdit.php
... ... @@ -273,7 +273,7 @@
273 273 parent.append(items);
274 274 }
275 275  
276   - /* var data = JSON.parse('<?php //echo json_encode($catalog_temp); ?>');*/
  276 + // var data = JSON.parse("<?php //echo json_encode($catalog_temp); ?>");
277 277  
278 278 /*$('#name').autocomplete({
279 279 minLength: 2,
... ...
src/app/frontend/controllers/MenuController.php
... ... @@ -17,25 +17,22 @@ class MenuController extends \controllers\ControllerBase
17 17 return $this->response->redirect('dealer/cart');
18 18 }
19 19  
20   - $lang_url = $this->seoUrl->getChangeLangUrl();
21   - $in_cart = $this->session->get('in_cart', []);
22   - $customer_id = $this->session->get('id');
23   - $customer_email = $this->session->get('customer_email');
24   -
  20 + $lang_url = $this->seoUrl->getChangeLangUrl();
  21 + $in_cart = $this->session->get('in_cart', []);
  22 + $customer_id = $this->session->get('id');
  23 + $customer_email = $this->session->get('customer_email');
25 24 $session_promo_code = $this->session->get('promo_code');
  25 + $customer = !empty( $customer_id ) ? $this->models->getCustomers()->getCustomer( $customer_id ) : [];
26 26  
27   - $customer = !empty( $customer_id ) ? $this->models->getCustomers()->getCustomer( $customer_id ) : [];
28   - $this->session->set( 'return_url', 'basket' ); // для redirect после авторизации на соц сетях
29   -
30   - $items = [];
31   - $total_price = 0;
32   - $err = 0;
  27 + $this->session->set( 'return_url', 'basket' ); // для redirect после авторизации на соц сетях
33 28  
34   - $cities_ = $this->novaposhta->city();
  29 + $items = [];
  30 + $total_price = 0;
  31 + $err = 0;
  32 + $cities_ = $this->novaposhta->city();
35 33  
36 34 foreach( $cities_->item as $c )
37 35 {
38   -
39 36 $cities[strval($c->CityID)] = strval($c->Description);
40 37 }
41 38  
... ... @@ -43,24 +40,33 @@ class MenuController extends \controllers\ControllerBase
43 40 {
44 41 $cart = $this->common->getCartItems($in_cart, $this->lang_id);
45 42  
  43 + //promocode
46 44 if(!empty($session_promo_code)) {
47 45 if($this->common->applyPromoCode($session_promo_code, $cart['items'])) {
48 46 $this->common->countOrderSum($cart);
49 47 $cart['total_price'] = $cart['total_sum'];
50 48 }
51 49 }
52   - $total_price = $cart['total_price'];
53   - $items = $cart['items'];
54   - $items_ = $cart['items_'];
55 50  
56   - }
  51 + //discount
  52 + $discount = $this->getDi()->get('models')->getDiscount()->getActiveData();
  53 + if (!empty($discount)) {
  54 + $discount = $discount[0];
  55 + }
  56 + if ($this->common->applyPromoCode($discount, $cart['items'])) {
  57 + $this->common->countOrderSum($cart);
  58 + $cart['total_price'] = $cart['total_sum'];
  59 + }
57 60  
  61 + $total_price = $cart['total_price'];
  62 + $items = $cart['items'];
  63 + $items_ = $cart['items_'];
  64 + }
58 65  
59 66 if ( $this->request->isPost() )
60 67 {
61 68 $order['email'] = $this->request->getPost('login_email', 'string', NULL );
62 69 $order['passwd'] = $this->request->getPost('login_passwd', 'string', NULL );
63   -
64 70 $promo_code = $this->request->getPost('promo_code', 'string', NULL );
65 71  
66 72 if(empty($session_promo_code)) {
... ... @@ -73,8 +79,8 @@ class MenuController extends \controllers\ControllerBase
73 79  
74 80 $order_items = $this->request->getPost('count_items', NULL, [] );
75 81 $order_color = $this->request->getPost('color', NULL, [] );
76   - $order_size = $this->request->getPost('size', NULL, [] );
77   - $order_is = $this->request->getPost('is', NULL, [] );
  82 + $order_size = $this->request->getPost('size', NULL, [] );
  83 + $order_is = $this->request->getPost('is', NULL, [] );
78 84 $order['total_sum'] = 0;
79 85  
80 86 foreach( $order_items as $key => $val )
... ... @@ -83,15 +89,12 @@ class MenuController extends \controllers\ControllerBase
83 89 $items_[$key]['total_price'] = round($val*$items_[$key]['price2'], 1);
84 90  
85 91 if(isset($order_color[$key]))
86   - $items_[$key]['color'] = $order_color[$key];
  92 + $items_[$key]['color'] = $order_color[$key];
87 93  
88   - $items_[$key]['size'] = $order_size[$key];
89   - $items_[$key]['is'] = $order_is[$key];
90   -
  94 + $items_[$key]['size'] = $order_size[$key];
  95 + $items_[$key]['is'] = $order_is[$key];
91 96 $order['items'][] = $items_[$key];
92 97 $order['total_sum'] += $items_[$key]['total_price'];
93   -
94   -
95 98 $item_id_in_cart = $this->common->array_column( $in_cart, 'item_id' );
96 99  
97 100 if( in_array( $key, $item_id_in_cart ) )
... ... @@ -106,9 +109,10 @@ class MenuController extends \controllers\ControllerBase
106 109 }
107 110 }
108 111  
109   - $order['total_sum'] = round( $order['total_sum'], 1 );
  112 + $order['total_sum'] = round( $order['total_sum'], 1 );
110 113  
111 114 $this->session->set( 'in_cart', $in_cart );
  115 +
112 116 if ( !empty( $order['email'] ) && !empty( $order['passwd'] ) )
113 117 {
114 118  
... ... @@ -130,8 +134,6 @@ class MenuController extends \controllers\ControllerBase
130 134 $this->flash->success($this->languages->getTranslation()->_("please_change_the_password"));
131 135 $this->session->set( 'customer_email', $order['email'] );
132 136 return $this->response->redirect([ 'for' => 'finish_registration', 'language' => $this->lang_name ]);
133   -
134   -
135 137 }
136 138 }
137 139  
... ... @@ -178,7 +180,22 @@ class MenuController extends \controllers\ControllerBase
178 180 $order['passwd_'] = $passwd_;
179 181 $order['passwd'] = $this->common->hashPasswd( $passwd_ );
180 182  
181   - // save order
  183 + //promocode
  184 + if(!empty($promo_code)) {
  185 + if($this->common->applyPromoCode($promo_code[0], $order['items']))
  186 + $this->common->countOrderSum($order);
  187 + }
  188 +
  189 + //discount
  190 + $discount = $this->getDi()->get('models')->getDiscount()->getActiveData();
  191 + if (!empty($discount)) {
  192 + $discount = $discount[0];
  193 + }
  194 + if ($this->common->applyPromoCode($discount, $order['items'])) {
  195 + $this->common->countOrderSum($order);
  196 + }
  197 +
  198 + // save order
182 199 $proposal_number = $this->models->getOrders()->addOrder($order);
183 200 $order['proposal_number'] = $proposal_number['proposal_number'];
184 201 $order['confirmed'] = $proposal_number['confirmed'];
... ... @@ -187,11 +204,6 @@ class MenuController extends \controllers\ControllerBase
187 204 $sms_text = "Vash zakaz prinyat. #:".$proposal_number['proposal_number']." V blijayshee vremya menedjer svyajetsya s Vami (044) 581-67-15";
188 205 $this->sms->sendSMS($order['phone'], $sms_text);
189 206  
190   - if(!empty($promo_code)) {
191   - if($this->common->applyPromoCode($promo_code[0], $order['items']))
192   - $this->common->countOrderSum($order);
193   - }
194   -
195 207 // novaposhta
196 208 if (!empty($proposal_number['novaposhta_tnn']))
197 209 {
... ... @@ -251,7 +263,6 @@ class MenuController extends \controllers\ControllerBase
251 263 return $this->response->redirect([ 'for' => 'basket', 'language' => $this->lang_name ]);
252 264 }
253 265 }
254   -
255 266 }
256 267  
257 268 $static_page_alias = '/basket'. $this->lang_name;
... ... @@ -271,7 +282,6 @@ class MenuController extends \controllers\ControllerBase
271 282 ]);
272 283 }
273 284  
274   -
275 285 public function orderCompletedAction() {
276 286 $completed = $this->languages->getTranslation()->_("successfully_realized_order");
277 287  
... ... @@ -329,7 +339,6 @@ class MenuController extends \controllers\ControllerBase
329 339 ]);
330 340 }
331 341  
332   -
333 342 public function getCitiesAction( )
334 343 {
335 344 header('Content-Type: application/json; charset=utf8');
... ... @@ -357,7 +366,6 @@ class MenuController extends \controllers\ControllerBase
357 366 die( json_encode( $selected_cities ) );
358 367 }
359 368  
360   -
361 369 public function getOfficesAction( )
362 370 {
363 371 header('Content-Type: application/json; charset=utf8');
... ... @@ -378,7 +386,6 @@ class MenuController extends \controllers\ControllerBase
378 386 die( json_encode( $offices ) );
379 387 }
380 388  
381   -
382 389 public function addProductBasketAction(){
383 390 $item_id = $_GET['productID'];
384 391 $count_items = $_GET['productCount'];
... ... @@ -392,21 +399,31 @@ class MenuController extends \controllers\ControllerBase
392 399 }
393 400  
394 401 public function getCartItemsAction() {
  402 +
395 403 $this->view->disable();
396 404  
397 405 $in_cart = $this->session->get('in_cart', []);
398 406  
399   -
400   -
401 407 $cart_items = $this->common->getCartItems($in_cart, $this->lang_id);
402 408  
403   -
404   -
405 409 if($this->session->get('special_users_id') != null) {
406 410 $special_users_id = $this->session->get('special_users_id');
407 411 $special_user = $this->models->getSpecialUsers()->getOneData($special_users_id)[0];
408 412 }
409 413  
  414 + //discount
  415 +
  416 + $discount = $this->models->getDiscount()->getActiveData();
  417 + if (!empty($discount)) {
  418 + $discount = $discount[0];
  419 + }
  420 + if ($this->common->applyPromoCode($discount, $cart_items['items'])) {
  421 + $this->common->countOrderSum($cart_items);
  422 + $cart_items['total_price'] = $cart_items['total_sum'];
  423 + }
  424 +
  425 + /************************/
  426 +
410 427 foreach($cart_items['items'] as $k => $item) {
411 428  
412 429 $cart_items['items'][$k]['group_sizes'] = $this->models->getItems()->getSizesByGroupId( $this->lang_id, $item['group_id'] );
... ... @@ -420,7 +437,6 @@ class MenuController extends \controllers\ControllerBase
420 437 ? $cart_items['items'][$k]['prices'][$special_user['status']]
421 438 : $item['price2'], 2, '.', ''
422 439 );
423   -
424 440 $cart_items['items'][$k]['total_price'] = $cart_items['items'][$k]['price'] * $item['count'];
425 441  
426 442 $cart_items['new_total_price'] += $cart_items['items'][$k]['total_price'];
... ... @@ -429,13 +445,13 @@ class MenuController extends \controllers\ControllerBase
429 445  
430 446 } else {
431 447 $cart_items['items'][$k]['price'] = $item['price2'];
432   - }
  448 + }
  449 +
433 450 }
434 451  
435 452 echo json_encode($cart_items);
436 453 }
437 454  
438   -
439 455 public function addToBasketAction()
440 456 {
441 457 $count = 0;
... ...
src/app/frontend/controllers/PageController.php
... ... @@ -135,7 +135,16 @@
135 135 $timestamp_left = $left_date->getTimestamp();
136 136 $active_sales[$k]['seconds_left'] = $timestamp_left - $now;
137 137 }
138   - /*
  138 +
  139 + $discount = $this->models->getDiscount()->getActiveData();
  140 + if (!empty($discount)) {
  141 + $discount = $discount[0];
  142 + $discount['group_ids'] = str_replace('{', '', $discount['group_ids']);
  143 + $discount['group_ids'] = str_replace('}', '', $discount['group_ids']);
  144 + $discount['group_ids'] = explode(',', $discount['group_ids']);
  145 +
  146 + }
  147 +
139 148 $css = [
140 149 '/landing_sales/style.css',
141 150  
... ... @@ -146,7 +155,7 @@
146 155 $js = [
147 156 '/landing_sales/flipclock.min.js'
148 157 ];
149   - */
  158 +
150 159 $css = null;
151 160 $js = null;
152 161  
... ... @@ -171,7 +180,8 @@
171 180 'meta_title' => $meta_title[$this->lang_id],
172 181 'meta_description' => $meta_description[$this->lang_id],
173 182 'slider' => $slider,
174   - 'active_sales' => $active_sales
  183 + 'active_sales' => $active_sales,
  184 + 'discount' => $discount
175 185 ]);
176 186 }
177 187  
... ... @@ -424,7 +434,15 @@
424 434 '1' => (isset( $seo['description'] ) && !empty( $seo['description'] ) ? $seo['description'] : 'Замовити '.$catalog['catalog']['title'].' у Києві за найкращою ціною. Якість товара підтверджена професіоналами.').(isset( $page ) && !empty( $page ) && $page != '1' ? ' страница '.$page : ''),
425 435 '2' => (isset( $seo['description'] ) && !empty( $seo['description'] ) ? $seo['description'] : 'Заказать '.$catalog['catalog']['title'].' в Киеве по лучшей цене. Качество товара подтверждена профессионалами.').(isset( $page ) && !empty( $page ) && $page != '1' ? ' страница '.$page : '')
426 436 ];
427   -
  437 +
  438 + $discount = $this->models->getDiscount()->getActiveData();
  439 + if (!empty($discount)) {
  440 + $discount = $discount[0];
  441 + $discount['group_ids'] = str_replace('{', '', $discount['group_ids']);
  442 + $discount['group_ids'] = str_replace('}', '', $discount['group_ids']);
  443 + $discount['group_ids'] = explode(',', $discount['group_ids']);
  444 + }
  445 +
428 446 if($subtype==='semena_gazonnykh_trav_1c_21')
429 447 $this->view->setMainView('landing');
430 448 elseif($subtype==='nasinnja_gazonnikh_trav_1c1')
... ... @@ -457,7 +475,8 @@
457 475 'subtype_alias' => $subtype_alias,
458 476 'catalog_sales' => $catalog_sales,
459 477 'css' => $cssSale,
460   - 'js' => $jsSale
  478 + 'js' => $jsSale,
  479 + 'discount' => $discount
461 480 ]);
462 481 }
463 482 else
... ... @@ -685,6 +704,14 @@
685 704 $catalog_sales[] = $active_sales[$k];
686 705 }
687 706 }
  707 +
  708 + $discount = $this->models->getDiscount()->getActiveData();
  709 + if (!empty($discount)) {
  710 + $discount = $discount[0];
  711 + $discount['group_ids'] = str_replace('{', '', $discount['group_ids']);
  712 + $discount['group_ids'] = str_replace('}', '', $discount['group_ids']);
  713 + $discount['group_ids'] = explode(',', $discount['group_ids']);
  714 + }
688 715  
689 716 $cssSale = [
690 717 'https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic',
... ... @@ -726,8 +753,9 @@
726 753 'meta_link_next' => $meta_link_next[1],
727 754 'meta_link_prev' => $meta_link_prev[1],
728 755 'catalog_sales' => $catalog_sales,
729   - 'css' => $cssSale,
730   - 'js' => $jsSale
  756 + 'css' => $cssSale,
  757 + 'js' => $jsSale,
  758 + 'discount' => $discount
731 759 ]);
732 760 }
733 761  
... ... @@ -771,7 +799,6 @@
771 799 if( !empty( $type_child ) )
772 800 {
773 801 $type_alias = $type.'--'.$type_child;
774   -
775 802 }
776 803 else
777 804 {
... ... @@ -855,7 +882,7 @@
855 882 $news[$k]['link'] = $this->url->get(['for' => 'one_tips', 'tips_id' => $n['id'], 'tips_alias' => $n['alias']]);
856 883 }
857 884  
858   - // get popular items_groups
  885 + // get popular items_groups
859 886 //
860 887 // $popular_groups = $this->models->getItems()->getPopularItems($this->lang_id);
861 888 // $popular_groups = $this->common->explodeAlias($popular_groups);
... ... @@ -893,7 +920,14 @@
893 920 '1' => isset($seo['description']) && !empty($seo['description']) ? $seo['description'] : 'Професіонали рекомендують ' . $catalog_name . ' ' . $item['0']['title'] . ' в інтернет магазині насіння Semena.in.ua.',
894 921 '2' => isset($seo['description']) && !empty($seo['description']) ? $seo['description'] : 'Профессионалы рекомендуют ' . $catalog_name . ' ' . $item['0']['title'] . ' в интернет магазине семян Semena.in.ua.'
895 922 ];
896   -
  923 +
  924 + $discount = $this->models->getDiscount()->getActiveData();
  925 + if (!empty($discount)) {
  926 + $discount = $discount[0];
  927 + $discount['group_ids'] = str_replace('{', '', $discount['group_ids']);
  928 + $discount['group_ids'] = str_replace('}', '', $discount['group_ids']);
  929 + $discount['group_ids'] = explode(',', $discount['group_ids']);
  930 + }
897 931  
898 932 $this->view->setVars([
899 933 'change_lang_url' => $lang_url,
... ... @@ -914,8 +948,9 @@
914 948 'meta_description' => $meta_description[$this->lang_id],
915 949 'breadcrumbs' => $breadcrumbs,
916 950 'catalog_id' => $catalog_id,
917   - 'type_alias' => $type_alias,
918   - 'subtype_alias' => $subtype_alias
  951 + 'type_alias' => $type_alias,
  952 + 'subtype_alias' => $subtype_alias,
  953 + 'discount' => $discount
919 954 ]);
920 955 }
921 956 else
... ... @@ -996,10 +1031,8 @@
996 1031 {
997 1032 $item_id = $this->request->getPost( 'item_id', 'int', '' );
998 1033 $group_alias = $this->request->getPost( 'group_alias', 'string', '' );
999   -
1000 1034 $item = $this->models->getItems()->getOneItem( $this->lang_id, $item_id );
1001 1035 $filters = $this->models->getFilters()->getFiltersByItemId( $this->lang_id, $item_id );
1002   -
1003 1036 $colors_info = $this->models->getItems()->getColorsInfoByColorId( $this->lang_id, $item['0']['color_id'] );
1004 1037  
1005 1038 $item['0']['color_title'] = NULL;
... ... @@ -1017,11 +1050,10 @@
1017 1050 '<div class="float properties" style="color:'.$colors_info['0']['absolute_color'].'">'.$colors_info['0']['color_title'].'</div>';
1018 1051 }
1019 1052  
1020   - $item['0']['explode'] = explode( '/', $item['0']['full_alias'] );
1021   - $item['0']['type_alias'] = $item['0']['explode']['1'];
1022   - $item['0']['subtype_alias'] = $item['0']['explode']['2'];
1023   - unset( $item['0']['explode'] );
1024   -
  1053 + $item['0']['explode'] = explode( '/', $item['0']['full_alias'] );
  1054 + $item['0']['type_alias'] = $item['0']['explode']['1'];
  1055 + $item['0']['subtype_alias'] = $item['0']['explode']['2'];
  1056 + unset( $item['0']['explode'] );
1025 1057 $item['0']['alias'] = $this->url->get([ 'for' => 'item', 'type' => $item['0']['type_alias'], 'subtype' => $item['0']['subtype_alias'], 'group_alias' => $group_alias, 'item_id' => $item_id ]);
1026 1058 $item['0']['filters'] = $filters;
1027 1059 $item['0']['images'] = $this->etc->int2arr( $item['0']['photogallery'] );
... ... @@ -1074,10 +1106,25 @@
1074 1106 'special_user' => $special_user
1075 1107 ]);
1076 1108 }
  1109 +
  1110 + $discount = $this->models->getDiscount()->getActiveData();
  1111 + if (!empty($discount)) {
  1112 + $discount = $discount[0];
  1113 + $discount['group_ids'] = str_replace('{', '', $discount['group_ids']);
  1114 + $discount['group_ids'] = str_replace('}', '', $discount['group_ids']);
  1115 + $discount['group_ids'] = explode(',', $discount['group_ids']);
  1116 + if ($discount['discount'] > 0 && $discount['discount'] <= 100 && in_array($item_id, $discount['group_ids'])) {
  1117 + $discount = $discount['discount'];
  1118 + }
  1119 + else {
  1120 + $discount = 0;
  1121 + }
  1122 + }
1077 1123  
1078 1124 $this->view->pick('page/changeWithSize');
1079 1125 $this->view->setVars([
1080   - 'item' => $item['0']
  1126 + 'item' => $item['0'],
  1127 + 'discount' => $discount
1081 1128 ]);
1082 1129 $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
1083 1130 }
... ... @@ -1419,15 +1466,19 @@
1419 1466 public function aboutuaAction(){
1420 1467 $this->view->setMainView('about_ukr');
1421 1468 }
  1469 +
1422 1470 public function aboutengAction(){
1423 1471 $this->view->setMainView('about_eng');
1424 1472 }
  1473 +
1425 1474 public function please_returnAction(){
1426 1475 $this->view->setMainView('please_return');
1427 1476 }
1428   - public function basket_uaAction(){
  1477 +
  1478 + public function basket_uaAction(){
1429 1479 $this->view->setMainView('basket_ua');
1430 1480 }
  1481 +
1431 1482 public function basket_ruAction(){
1432 1483 $this->view->setMainView('basket_ru');
1433 1484 }
... ... @@ -1544,4 +1595,4 @@
1544 1595 header(!empty($language) ? "Location:".$language : 'Location:/');
1545 1596 }
1546 1597  
1547   - }
1548 1598 \ No newline at end of file
  1599 + }
... ...
src/app/frontend/views/index.php
... ... @@ -93,7 +93,6 @@ $page_title = isset( $page_title ) &amp;&amp; !empty( $page_title ) ? $page_title : &#39;&#39;;
93 93 </div>
94 94 <div class="contact_mob_phones">
95 95 <span class="small_digits">(093)</span><span> 026-86-64</span>
96   -
97 96 <div style="float:right;font-size:12px;margin-right:65px;" class="contact_callback_phones">
98 97 <a href="<?= $this->seoUrl->setUrl('/callback') ?>" class="callback" title="<?= $t->_("Feedback")?>" id="ajax_simple" data-options="width: 940, height: 400" target="<?= $this->seoUrl->setUrl( $this->url->get([ 'for' => 'callback' ])) ?>" data-type="ajax"><?= $t->_("Feedback")?></a>
99 98 </div>
... ... @@ -245,8 +244,8 @@ $page_title = isset( $page_title ) &amp;&amp; !empty( $page_title ) ? $page_title : &#39;&#39;;
245 244 </div>
246 245 </div>
247 246  
248   -<div class="open-delivery-modal">
249   - <div></div>
  247 +<div class="open-delivery-modal hidden_modal">
  248 + <div><img src="/images/popup_full.png" class="popup_full"><img src="/images/popup_open.png" class="popup_mobile"><span class="modal_close"></span></div>
250 249 </div>
251 250 <link rel="stylesheet" type="text/css" href="css/fontlato.css">
252 251 <div class="delivery-form-par">
... ... @@ -268,7 +267,10 @@ $page_title = isset( $page_title ) &amp;&amp; !empty( $page_title ) ? $page_title : &#39;&#39;;
268 267 </div>
269 268  
270 269 <script>
271   - $(".open-delivery-modal").click(function(){
  270 + $(document).ready(function(){
  271 + setTimeout(function(){$(".open-delivery-modal").show();},1000);
  272 + });
  273 + $(".open-delivery-modal div img").click(function(){
272 274 $(".delivery-form-par").show();
273 275 $(".delivery-form-par").animate({opacity: "1"}, 500, function() {});
274 276 $(".delivery-form-par .popup-main-delivery").animate({opacity: "1",top: "15%"}, 300, function() {});
... ... @@ -278,6 +280,9 @@ $page_title = isset( $page_title ) &amp;&amp; !empty( $page_title ) ? $page_title : &#39;&#39;;
278 280 $(".delivery-form-par").animate({opacity: "0"}, 500, function() {});
279 281 setTimeout(function(){$(".delivery-form-par").hide();}, 600);
280 282 });
  283 + $(".modal_close").click(function(){
  284 + $(".open-delivery-modal").hide();
  285 + });
281 286 </script>
282 287 <?php
283 288 if( !IS_PRODUCTION )
... ...
src/app/frontend/views/page/changeWithSize.php
... ... @@ -6,9 +6,25 @@ if(isset($special_user)) {
6 6 } else {
7 7 $data['price'] = $item['price2'];
8 8 }
9   -$data['html'] = '<div class="clearfix buy_compare">
10   - <div class="one_item_price float">'. $t->_("price") .
11   - ' <span>' . $data['price'] . '</span> грн';
  9 +$old_price = $data['price'];
  10 +$data['price'] = $data['price']*(1-$discount/100);
  11 +$data['price'] = number_format($data['price'], 2, '.', ' ');
  12 +if ($discount == 0) {
  13 + $data['html'] =
  14 + '<div class="clearfix buy_compare">
  15 + <div class="one_item_price float">'. $t->_("price") .
  16 + ' <span>' . $data['price'] . '</span> грн
  17 + ';
  18 +}
  19 +else {
  20 + $data['html'] = '
  21 + <div class="clearfix buy_compare">
  22 + <div class="one_item_price float">'. $t->_("price") .
  23 + ' <span style="text-decoration: line-through;"><span>' . $old_price . '</span> грн</span>
  24 + <br/>
  25 + <span>' . $data['price'] . '</span> грн
  26 + ';
  27 +}
12 28  
13 29 $data['html'] .= '</ul></div><div data-group_id="' . $item['group_id'] .'" class="one_item_buttons float">';
14 30  
... ... @@ -52,5 +68,4 @@ if(!empty($item[&#39;prices&#39;][0])) {
52 68 }
53 69 }
54 70  
55   -
56 71 echo json_encode($data);
57 72 \ No newline at end of file
... ...
src/app/frontend/views/page/item.php
1 1 <div id="content" class="clearfix">
2   -<div class="item">
3   -<div class="breadcrumbs">
4   - <div class="inner">
5   - <div class="item_menu_shadow"></div>
6   - <?= $breadcrumbs ?>
7   - </div>
8   -</div>
9   - <?php $url = $this->router->getRewriteUri(); ?>
  2 + <div class="item">
  3 + <div class="breadcrumbs">
  4 + <div class="inner">
  5 + <div class="item_menu_shadow"></div>
  6 + <?= $breadcrumbs ?>
  7 + </div>
  8 + </div>
  9 + <?php $url = $this->router->getRewriteUri(); ?>
10 10  
11   - <div class="<?= strstr($url, '/dobriva_ta_zasobi_zakhistu_1c0/zasobi_zakhistu_1c1') || strstr($url, '/udobrenija_i_sredstva_zashchity_1c_20/sredstva_zashchity_1c_21') ? 'zasobi_zakhistu_logo' : null ?> item_wrapper" itemscope itemtype="http://schema.org/Product">
12   - <div class="inner clearfix">
13   - <div class="float item_images">
14   - <ul class="thumbnails">
15   - <?php
  11 + <div class="<?= strstr($url, '/dobriva_ta_zasobi_zakhistu_1c0/zasobi_zakhistu_1c1') || strstr($url, '/udobrenija_i_sredstva_zashchity_1c_20/sredstva_zashchity_1c_21') ? 'zasobi_zakhistu_logo' : null ?> item_wrapper" itemscope itemtype="http://schema.org/Product">
  12 + <div class="inner clearfix">
  13 + <div class="float item_images">
  14 + <ul class="thumbnails">
  15 + <?php
16 16  
17   - $data_images = '';
  17 + $data_images = '';
18 18  
19   - if( !empty( $item['images'] ) )
20   - {
21   - $data_images .=
22   - '<li class="float width_400 '.(count($item['images'])%3==0 ? 'last' : '').'">'.
23   - '<a href="'.$this->storage->getPhotoUrl( $item['images'][0], 'group', '800x' ).'" title="'.$item['title'].'" data-options="thumbnail: \''.$this->storage->getPhotoUrl( $item['cover'], 'avatar', '128x' ).'\'" class="thumbnail">'.
24   - '<img src="'.$this->storage->getPhotoUrl( $item['images'][0], 'group', '400x400' ).'" alt="'.$item['title'].'" class="image_400">'.
25   - '</a>'.
26   - '</li>';
27   -
28   - foreach( $item['images'] as $k => $i )
  19 + if( !empty( $item['images'] ) )
29 20 {
30 21 $data_images .=
31   - '<li class="float width_128 '.(($k+1)%3==0 ? 'last' : '').'">'.
32   - '<a href="'.$this->storage->getPhotoUrl( $i, 'group', '800x' ).'" title="'.$item['title'].'" data-options="thumbnail: \''.$this->storage->getPhotoUrl( $i, 'group', '128x128' ).'\'" class="thumbnail">'.
33   - '<img itemprop="image" title="'.$item['title'].'" src="'.$this->storage->getPhotoUrl( $i, 'group', '128x128' ).'" alt="Купити '.$item['title'].' в Києві та Львові" class="image_128">'.
  22 + '<li class="float width_400 '.(count($item['images'])%3==0 ? 'last' : '').'">'.
  23 + '<a href="'.$this->storage->getPhotoUrl( $item['images'][0], 'group', '800x' ).'" title="'.$item['title'].'" data-options="thumbnail: \''.$this->storage->getPhotoUrl( $item['cover'], 'avatar', '128x' ).'\'" class="thumbnail">'.
  24 + '<img src="'.$this->storage->getPhotoUrl( $item['images'][0], 'group', '400x400' ).'" alt="'.$item['title'].'" class="image_400">'.
34 25 '</a>'.
35 26 '</li>';
36   - }
37 27  
  28 + foreach( $item['images'] as $k => $i )
  29 + {
  30 + $data_images .=
  31 + '<li class="float width_128 '.(($k+1)%3==0 ? 'last' : '').'">'.
  32 + '<a href="'.$this->storage->getPhotoUrl( $i, 'group', '800x' ).'" title="'.$item['title'].'" data-options="thumbnail: \''.$this->storage->getPhotoUrl( $i, 'group', '128x128' ).'\'" class="thumbnail">'.
  33 + '<img itemprop="image" title="'.$item['title'].'" src="'.$this->storage->getPhotoUrl( $i, 'group', '128x128' ).'" alt="Купити '.$item['title'].' в Києві та Львові" class="image_128">'.
  34 + '</a>'.
  35 + '</li>';
  36 + }
38 37  
39   - }
40   - elseif( !empty( $item['cover'] ) && empty( $item['images'] ) )
41   - {
42   - $data_images .=
43   - '<li class="float width_400">'.
44   - '<a href="'.$this->storage->getPhotoUrl( $item['cover'], 'avatar', '800x' ).'" title="'.$item['title'].'" data-options="thumbnail: \''.$this->storage->getPhotoUrl( $item['cover'], 'avatar', '128x' ).'\'" class="thumbnail">'.
45   - '<img src="'.$this->storage->getPhotoUrl( $item['cover'], 'avatar', '400x' ).'" alt="'.$item['title'].'" class="image_400">'.
46   - '</a>'.
47   - '</li>';
48   - }
49   - else
50   - {
51   - $data_images .=
52   - '<li class="float width_400">
53   - <img src="/images/item_main_photo.jpg" alt="" width="400" height="400">
54   - </li>
55   -
56   - <li class="float width_128"><img src="/images/item_photo.jpg" alt="" width="128" height="128"></li>
57   - <li class="float width_128 last"><img src="/images/item_photo.jpg" alt="" width="128" height="128"></li>';
58   - }
59   - echo( $data_images );
60 38  
61   - ?>
  39 + }
  40 + elseif( !empty( $item['cover'] ) && empty( $item['images'] ) )
  41 + {
  42 + $data_images .=
  43 + '<li class="float width_400">'.
  44 + '<a href="'.$this->storage->getPhotoUrl( $item['cover'], 'avatar', '800x' ).'" title="'.$item['title'].'" data-options="thumbnail: \''.$this->storage->getPhotoUrl( $item['cover'], 'avatar', '128x' ).'\'" class="thumbnail">'.
  45 + '<img src="'.$this->storage->getPhotoUrl( $item['cover'], 'avatar', '400x' ).'" alt="'.$item['title'].'" class="image_400">'.
  46 + '</a>'.
  47 + '</li>';
  48 + }
  49 + else
  50 + {
  51 + $data_images .=
  52 + '<li class="float width_400">
  53 + <img src="/images/item_main_photo.jpg" alt="" width="400" height="400">
  54 + </li>
  55 +
  56 + <li class="float width_128"><img src="/images/item_photo.jpg" alt="" width="128" height="128"></li>
  57 + <li class="float width_128 last"><img src="/images/item_photo.jpg" alt="" width="128" height="128"></li>';
  58 + }
  59 + echo( $data_images );
62 60  
63   - </ul>
64   - <?php if(!empty($item['front_video'])):?>
65   - <br>
66   - <div class="front_video_block">
67   - <?php if(!empty($item['front_video'])){
68   - $video = explode(',',$item['front_video']);
69   - foreach($video as $v): ?>
70   - <iframe class="video_iframe" width="400" height="220" src="<?= $v ?>" frameborder="0" allowfullscreen></iframe>
71   - <?php endforeach;
72   - }?>
73   - </div>
74   - <?php endif;?>
75   - </div>
  61 + ?>
76 62  
77   - <div class="float item_content">
78   - <div class="item_title"><h1 class="item_name_h1" itemprop="name"><?= $item['title'] ?></h1></div>
79   - <div class="item_decription"><?= $item['description'] ?></div>
80   - <div style="float:right;width:270px;font-weight:bold;line-height:20px;">
81   - <img src="/images/truck.jpg" width="64" height="64" border="0" align="left" style="margin-right:10px;" />
82   - <?= $t->_("truck")?>
83   - </div>
84   - <div style="float:left">
85   - <div class="clearfix">
86   - <div class="float properties">Код:</div>
87   - <div class="float properties properties_article"><?= $item['product_id'] ?></div>
88   - </div>
89   - <div class="clearfix">
90   - <div class="float properties"><?= $t->_("availability")?>:</div>
91   - <div class="float presence_status">
92   - <?= $item['status'] == 1 ? '<div data-stock="1" id="stock" class="properties properties_presence ">'.$t->_("in_stock").'</div>' : ($item['status'] == 2 ? '<div data-stock="0" id="stock" class="properties properties_absent">'.$t->_("znyt").'</div>' : '<div data-stock="0" id="stock" class="properties properties_absent">'.$t->_("missing").'</div>'); ?>
93   - </div>
  63 + </ul>
  64 + <?php if(!empty($item['front_video'])):?>
  65 + <br>
  66 + <div class="front_video_block">
  67 + <?php if(!empty($item['front_video'])){
  68 + $video = explode(',',$item['front_video']);
  69 + foreach($video as $v): ?>
  70 + <iframe class="video_iframe" width="400" height="220" src="<?= $v ?>" frameborder="0" allowfullscreen></iframe>
  71 + <?php endforeach;
  72 + }?>
  73 + </div>
  74 + <?php endif;?>
94 75 </div>
95 76  
96   - <div class="clearfix">
97   - <div class="float properties"><?= $t->_("number_of") ?>:</div>
98   - <div class="float count minus">
  77 + <div class="float item_content">
  78 + <div class="item_title"><h1 class="item_name_h1" itemprop="name"><?= $item['title'] ?></h1></div>
  79 + <div class="item_decription"><?= $item['description'] ?></div>
  80 + <div style="float:right;width:270px;font-weight:bold;line-height:20px;">
  81 + <img src="/images/truck.jpg" width="64" height="64" border="0" align="left" style="margin-right:10px;" />
  82 + <?= $t->_("truck")?>
99 83 </div>
100   - <div class="float count count_input">
101   - <input name="count_items" class="count_items" type="text" value="1" />
  84 + <div style="float:left">
  85 + <div class="clearfix">
  86 + <div class="float properties">Код:</div>
  87 + <div class="float properties properties_article"><?= $item['product_id'] ?></div>
102 88 </div>
103   - <div class="float count plus">
  89 + <div class="clearfix">
  90 + <div class="float properties"><?= $t->_("availability")?>:</div>
  91 + <div class="float presence_status">
  92 + <?= $item['status'] == 1 ? '<div data-stock="1" id="stock" class="properties properties_presence ">'.$t->_("in_stock").'</div>' : ($item['status'] == 2 ? '<div data-stock="0" id="stock" class="properties properties_absent">'.$t->_("znyt").'</div>' : '<div data-stock="0" id="stock" class="properties properties_absent">'.$t->_("missing").'</div>'); ?>
  93 + </div>
104 94 </div>
105   - </div>
106   - </div><div style="clear:both;"></div>
107   - <div class="clearfix packing">
108   - <div class="float properties"><?= $t->_("packing")?>:</div>
109   - <div class="float packing_images clearfix">
110   - <?php
111 95  
112   - $data_sizes = '';
  96 + <div class="clearfix">
  97 + <div class="float properties"><?= $t->_("number_of") ?>:</div>
  98 + <div class="float count minus">
  99 + </div>
  100 + <div class="float count count_input">
  101 + <input name="count_items" class="count_items" type="text" value="1" />
  102 + </div>
  103 + <div class="float count plus">
  104 + </div>
  105 + </div>
  106 + </div><div style="clear:both;"></div>
  107 + <div class="clearfix packing">
  108 + <div class="float properties"><?= $t->_("packing")?>:</div>
  109 + <div class="float packing_images clearfix">
  110 + <?php
  111 +
  112 + $data_sizes = '';
113 113  
114   - if( !empty( $sizes_colors__ ) )
115   - {
116   - $i = 0;
117   - foreach( $sizes_colors['sizes'] as $k => $s )
  114 + if( !empty( $sizes_colors__ ) )
118 115 {
119   - if( isset( $sizes_colors__[$item['color_id']][$s] ) )
  116 + $i = 0;
  117 + foreach( $sizes_colors['sizes'] as $k => $s )
120 118 {
121   - $data_sizes .=
122   - '<a href="'.$sizes_colors__[$item['color_id']][$s]['link'].'" class="group_sizes'.($s == $item['size'] ? ' active' : '').' exist" style="padding-top:'.($i*3).'px; width:'.(31+($i*3)).'px" data-item_id="'.$sizes_colors__[$item['color_id']][$s]['id'].'" data-catalog_id="'.$catalog_id.'" data-group_alias="'.$group_alias.'">'.
123   - '<span class="group_sizes_header"></span>'.
124   - '<span class="group_sizes_content">'.$s.'</span>'.
125   - '</a>';
  119 + if( isset( $sizes_colors__[$item['color_id']][$s] ) )
  120 + {
  121 + $data_sizes .=
  122 + '<a href="'.$sizes_colors__[$item['color_id']][$s]['link'].'" class="group_sizes'.($s == $item['size'] ? ' active' : '').' exist" style="padding-top:'.($i*3).'px; width:'.(31+($i*3)).'px" data-item_id="'.$sizes_colors__[$item['color_id']][$s]['id'].'" data-catalog_id="'.$catalog_id.'" data-group_alias="'.$group_alias.'">'.
  123 + '<span class="group_sizes_header"></span>'.
  124 + '<span class="group_sizes_content">'.$s.'</span>'.
  125 + '</a>';
  126 + }
  127 + else
  128 + {
  129 + $data_sizes .=
  130 + '<a href="#" onClick="return false;" class="group_sizes'.($s == $item['size'] ? ' active' : '').' not_exist" style="padding-top:'.($i*3).'px; width:'.(31+($i*3)).'px" data-item_id="" data-catalog_id="'.$catalog_id.'" data-group_alias="'.$group_alias.'">'.
  131 + '<span class="group_sizes_header"></span>'.
  132 + '<span class="group_sizes_content">'.$s.'</span>'.
  133 + '</a>';
  134 + }
  135 +
  136 + $i++;
126 137 }
127   - else
  138 + }
  139 + else
  140 + {
  141 + foreach( $sizes as $k => $s )
128 142 {
129 143 $data_sizes .=
130   - '<a href="#" onClick="return false;" class="group_sizes'.($s == $item['size'] ? ' active' : '').' not_exist" style="padding-top:'.($i*3).'px; width:'.(31+($i*3)).'px" data-item_id="" data-catalog_id="'.$catalog_id.'" data-group_alias="'.$group_alias.'">'.
  144 + '<a href="'.$this->seoUrl->setUrl($s['link']).'" class="group_sizes'.($k == $active_size ? ' active' : '').'" style="padding-top:'.($k*3).'px; width:'.(31+($k*3)).'px" data-item_id="'.$s['id'].'" data-catalog_id="'.$catalog_id.'" data-group_alias="'.$group_alias.'">'.
131 145 '<span class="group_sizes_header"></span>'.
132   - '<span class="group_sizes_content">'.$s.'</span>'.
  146 + '<span class="group_sizes_content">'.$s['size'].'</span>'.
133 147 '</a>';
134 148 }
135   -
136   - $i++;
137   - }
138   - }
139   - else
140   - {
141   - foreach( $sizes as $k => $s )
142   - {
143   - $data_sizes .=
144   - '<a href="'.$this->seoUrl->setUrl($s['link']).'" class="group_sizes'.($k == $active_size ? ' active' : '').'" style="padding-top:'.($k*3).'px; width:'.(31+($k*3)).'px" data-item_id="'.$s['id'].'" data-catalog_id="'.$catalog_id.'" data-group_alias="'.$group_alias.'">'.
145   - '<span class="group_sizes_header"></span>'.
146   - '<span class="group_sizes_content">'.$s['size'].'</span>'.
147   - '</a>';
148 149 }
149   - }
150 150  
151   - echo( $data_sizes );
  151 + echo( $data_sizes );
152 152  
153   - ?>
  153 + ?>
154 154  
  155 + </div>
155 156 </div>
156   - </div>
157 157  
158   - <?php
  158 + <?php
159 159  
160   - if( !empty( $sizes_colors__ ) )
161   - {
162   - $data_colors =
163   - '<div class="clearfix colors">'.
164   - '<div class="float properties">'.$t->_("choose_color").': </div>'.
165   - '<div class="float properties" style="color:'.$item['absolute_color'].'">'.$item['color_title'].'</div>'.
166   - '</div>'.
  160 + if( !empty( $sizes_colors__ ) )
  161 + {
  162 + $data_colors =
  163 + '<div class="clearfix colors">'.
  164 + '<div class="float properties">'.$t->_("choose_color").': </div>'.
  165 + '<div class="float properties" style="color:'.$item['absolute_color'].'">'.$item['color_title'].'</div>'.
  166 + '</div>'.
167 167  
168   - '<div class="sliderkit carousel-demo1 colors_images clearfix">'.
169   - '<div class="sliderkit-nav">';
  168 + '<div class="sliderkit carousel-demo1 colors_images clearfix">'.
  169 + '<div class="sliderkit-nav">';
170 170  
171   - $data_colors .= '<div class="sliderkit-nav-clip" '.( count( $sizes_colors__ ) > 6 ? 'style="margin: 0 30px"' : '' ).'><ul>';
  171 + $data_colors .= '<div class="sliderkit-nav-clip" '.( count( $sizes_colors__ ) > 6 ? 'style="margin: 0 30px"' : '' ).'><ul>';
172 172  
173   - foreach( $sizes_colors__ as $k => $s )
174   - {
175   - sort($s);
176   - $data_colors .=
177   - '<li class="change_with_color" data-item_id="'.$s['0']['id'].'" data-catalog_id="'.$catalog_id.'" data-group_id="'.$item['group_id'].'" data-group_alias="'.$group_alias.'" data-color_id="'.$s['0']['color_id'].'">'.
178   - '<a href="'.$this->seoUrl->setUrl($s['0']['link']).'" title="'.$s['0']['color_title'].'" '.( $s['0']['color_id'] == $item['color_id'] ? 'class="active" style="border-color:'.$item['absolute_color'].'"' : '' ).' ><img src="'.$s['0']['image'].'" alt="'.$s['0']['color_title'].'" width="60" height="60" /></a>'.
179   - '</li>';
180   - }
  173 + foreach( $sizes_colors__ as $k => $s )
  174 + {
  175 + sort($s);
  176 + $data_colors .=
  177 + '<li class="change_with_color" data-item_id="'.$s['0']['id'].'" data-catalog_id="'.$catalog_id.'" data-group_id="'.$item['group_id'].'" data-group_alias="'.$group_alias.'" data-color_id="'.$s['0']['color_id'].'">'.
  178 + '<a href="'.$this->seoUrl->setUrl($s['0']['link']).'" title="'.$s['0']['color_title'].'" '.( $s['0']['color_id'] == $item['color_id'] ? 'class="active" style="border-color:'.$item['absolute_color'].'"' : '' ).' ><img src="'.$s['0']['image'].'" alt="'.$s['0']['color_title'].'" width="60" height="60" /></a>'.
  179 + '</li>';
  180 + }
181 181  
182   - $data_colors .= '</ul></div>';
  182 + $data_colors .= '</ul></div>';
183 183  
184   - if( count( $sizes_colors__ ) > 6 )
185   - {
186   - $data_colors .=
187   - '<div class="sliderkit-btn sliderkit-nav-btn sliderkit-nav-prev"><a href="#" title="Previous line"><span>Previous</span></a></div>'.
188   - '<div class="sliderkit-btn sliderkit-nav-btn sliderkit-nav-next"><a href="#" title="Next line"><span>Next</span></a></div>';
189   - }
  184 + if( count( $sizes_colors__ ) > 6 )
  185 + {
  186 + $data_colors .=
  187 + '<div class="sliderkit-btn sliderkit-nav-btn sliderkit-nav-prev"><a href="#" title="Previous line"><span>Previous</span></a></div>'.
  188 + '<div class="sliderkit-btn sliderkit-nav-btn sliderkit-nav-next"><a href="#" title="Next line"><span>Next</span></a></div>';
  189 + }
190 190  
191   - $data_colors .=
192   - '</div>'.
193   - '</div>';
  191 + $data_colors .=
  192 + '</div>'.
  193 + '</div>';
194 194  
195   - echo $data_colors;
196   - }
  195 + echo $data_colors;
  196 + }
197 197  
198   - ?>
  198 + ?>
199 199  
200   - <div class="change_with_size">
201   - <div class="clearfix buy_compare">
202   - <div class="one_item_price float" itemprop="offers" itemscope itemtype="http://schema.org/Offer" ><?= $t->_("price")?>
203   - <ul>
204   - <li>
205   - <span itemprop="price"><?= number_format($item['price2'],2,'.',' ') ?></span> грн<span style="display:none;" itemprop="priceCurrency">UAH</span>
206   - <div style="display: none" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
207   - <span itemprop="ratingValue">5</span>
208   - <span itemprop="reviewCount">31</span>
209   - </div>
210   - </li>
211   - </ul>
  200 + <div class="change_with_size">
  201 + <div class="clearfix buy_compare">
  202 + <div class="one_item_price float" itemprop="offers" itemscope itemtype="http://schema.org/Offer" ><?= $t->_("price")?>
  203 + <ul>
  204 + <li>
  205 + <?php
  206 + // скидка
  207 + if (!empty($discount)) {
  208 + if (isset($discount) && $discount['discount'] > 0 && $discount['discount'] <= 100 && in_array($item['id'], $discount['group_ids'])) {
  209 + echo '<span itemprop="price">'.number_format($item['price2']*(1-$discount['discount']/100), 2, '.', ' ').'</span> грн<span style="display:none;" itemprop="priceCurrency">UAH</span>';
  210 + }
  211 + else {
  212 + //echo '<span itemprop="price">'.number_format($item['price2'], 2, '.', ' ').'</span> грн<span style="display:none;" itemprop="priceCurrency">UAH</span>';
  213 + }
  214 + }
  215 + else {
  216 + //echo '<span itemprop="price">'.number_format($item['price2'], 2, '.', ' ').'</span> грн<span style="display:none;" itemprop="priceCurrency">UAH</span>';
  217 + }
  218 + ?>
  219 + <!--<span itemprop="price"><?//= number_format($item['price2'], 2, '.', ' '); ?></span> грн<span style="display:none;" itemprop="priceCurrency">UAH</span>-->
  220 + <div style="display: none" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
  221 + <span itemprop="ratingValue">5</span>
  222 + <span itemprop="reviewCount">31</span>
  223 + </div>
  224 + </li>
  225 + </ul>
  226 + </div>
  227 + <div class="one_item_buttons float">
  228 + <a href="<?= $this->seoUrl->setUrl($this->url->get([ 'for' => 'item', 'type' => $type_alias, 'subtype' => $subtype_alias, 'group_alias' => $group_alias, 'item_id' => $item_id ])); ?>" title="Додати <?= $item['title'] ?> у корзину" class="<?= $item['status'] == 1 ? 'btn green buy' : 'not_available grey'?>"><?= $t->_("buy")?></a>
  229 + </div>
  230 + <div class="one_item_compare float">
  231 + <?= '<input type="checkbox" id="compare_item_'.$item['id'].'" class="compare_item" value="'.$item['type'].'-'.$catalog_id.'-'.$item['id'].'" '.(!empty($item['checked']) ? 'checked="checked"' : '').' />' ?>
  232 + <label for="compare_item_<?= $item['id'] ?>"><span></span><?= $t->_("compared_to")?></label>
  233 + <input type="hidden" class="item_id_for_basket" value="<?= $item['id'] ?>">
  234 + <input type="hidden" class="current_item_size" value="<?= $item['size'] ?>">
  235 + </div>
212 236 </div>
213   - <div class="one_item_buttons float">
214   - <a href="<?= $this->seoUrl->setUrl($this->url->get([ 'for' => 'item', 'type' => $type_alias, 'subtype' => $subtype_alias, 'group_alias' => $group_alias, 'item_id' => $item_id ])); ?>" title="Додати <?= $item['title'] ?> у корзину" class="<?= $item['status'] == 1 ? 'btn green buy' : 'not_available grey'?>"><?= $t->_("buy")?></a>
215   - </div>
216   - <div class="one_item_compare float">
217   - <?= '<input type="checkbox" id="compare_item_'.$item['id'].'" class="compare_item" value="'.$item['type'].'-'.$catalog_id.'-'.$item['id'].'" '.(!empty($item['checked']) ? 'checked="checked"' : '').' />' ?>
218   - <label for="compare_item_<?= $item['id'] ?>"><span></span><?= $t->_("compared_to")?></label>
219   - <input type="hidden" class="item_id_for_basket" value="<?= $item['id'] ?>">
220   - <input type="hidden" class="current_item_size" value="<?= $item['size'] ?>">
221   - </div>
222   - </div>
223   - <div class="clearfix features">
224   - <?php
  237 + <div class="clearfix features">
  238 + <?php
225 239  
226   - $data_features = '';
  240 + $data_features = '';
227 241  
228   - foreach( $filters as $f )
229   - {
230   - $data_features .= '<a href="#" class="float">'.$f['value_value'].'</a>';
231   - }
  242 + foreach( $filters as $f )
  243 + {
  244 + $data_features .= '<a href="#" class="float">'.$f['value_value'].'</a>';
  245 + }
232 246  
233   - echo( $data_features );
  247 + echo( $data_features );
234 248  
235   - ?>
236   - </div>
237   - </div>
238   - <div class="clearfix item_menu">
239   - <div class="item_menu_header_menu clearfix">
240   - <div class="tabs clearfix">
241   - <ul class="change_item_description">
242   - <li class="float active_tab first_tab" data-change_item_description="tabs_description"><a href="#" title=""><?= $t->_("description")?></a></li>
243   - <li class="float not_active" data-change_item_description="tabs_properties"><a href="#" title=""><?= $t->_("features")?></a></li>
244   - <?php if(!empty($item['content_video'])):?><li class="float not_active" data-change_item_description="tabs_video"><a href="#" title=""><?= $t->_("video")?></a></li><?php endif;?>
245   - <li class="float last_tab not_active" data-change_item_description="tabs_comments"><a href="#" title=""><?= $t->_("reviews")?></a></li>
246   - </ul>
  249 + ?>
247 250 </div>
248 251 </div>
249   - <div class="item_menu_content">
250   - <div class="tabs_description item_menu_content_wrapper" itemprop="description"><?= $item['content_description'] ?></div>
251   - <div class="display_none tabs_properties item_menu_content_wrapper">
252   - <?php
253   -
254   - $data_properties = '';
255   -
256   - if( isset( $item['brand'] ) && !empty( $item['brand'] ) )
257   - {
258   - $data_properties .=
259   - '<div class="clearfix properties_producer">'.
260   - '<p class="float key_value">'.$t->_("producer").':</p>'.
261   - '<a class="float" href="#" title="'.$item['brand'].'">'.$item['brand'].'</a>'.
262   - '</div>';
263   - }
  252 + <div class="clearfix item_menu">
  253 + <div class="item_menu_header_menu clearfix">
  254 + <div class="tabs clearfix">
  255 + <ul class="change_item_description">
  256 + <li class="float active_tab first_tab" data-change_item_description="tabs_description"><a href="#" title=""><?= $t->_("description")?></a></li>
  257 + <li class="float not_active" data-change_item_description="tabs_properties"><a href="#" title=""><?= $t->_("features")?></a></li>
  258 + <?php if(!empty($item['content_video'])):?><li class="float not_active" data-change_item_description="tabs_video"><a href="#" title=""><?= $t->_("video")?></a></li><?php endif;?>
  259 + <li class="float last_tab not_active" data-change_item_description="tabs_comments"><a href="#" title=""><?= $t->_("reviews")?></a></li>
  260 + </ul>
  261 + </div>
  262 + </div>
  263 + <div class="item_menu_content">
  264 + <div class="tabs_description item_menu_content_wrapper" itemprop="description"><?= $item['content_description'] ?></div>
  265 + <div class="display_none tabs_properties item_menu_content_wrapper">
  266 + <?php
264 267  
265   - if( isset( $properties ) && !empty( $properties ) )
266   - {
267   - $data_properties .= '<div class="item_properties">';
  268 + $data_properties = '';
268 269  
269   - foreach( $properties as $p )
  270 + if( isset( $item['brand'] ) && !empty( $item['brand'] ) )
270 271 {
271 272 $data_properties .=
272   - '<div class="clearfix">'.
273   - '<p class="float key_value">'.$p['key_value'].':</p>'.
274   - '<a class="float" href="#">'.$p['value_value'].'</a>'.
  273 + '<div class="clearfix properties_producer">'.
  274 + '<p class="float key_value">'.$t->_("producer").':</p>'.
  275 + '<a class="float" href="#" title="'.$item['brand'].'">'.$item['brand'].'</a>'.
275 276 '</div>';
276 277 }
277 278  
278   - $data_properties .= '</div>';
279   - }
280   -
281   - echo( $data_properties );
  279 + if( isset( $properties ) && !empty( $properties ) )
  280 + {
  281 + $data_properties .= '<div class="item_properties">';
  282 +
  283 + foreach( $properties as $p )
  284 + {
  285 + $data_properties .=
  286 + '<div class="clearfix">'.
  287 + '<p class="float key_value">'.$p['key_value'].':</p>'.
  288 + '<a class="float" href="#">'.$p['value_value'].'</a>'.
  289 + '</div>';
  290 + }
  291 +
  292 + $data_properties .= '</div>';
  293 + }
282 294  
283   - ?>
  295 + echo( $data_properties );
  296 +
  297 + ?>
  298 + </div>
  299 + <div class="display_none tabs_video item_menu_content_wrapper">
  300 + <?php if(!empty($item['content_video'])){
  301 + $video = explode(',',$item['content_video']);
  302 + foreach($video as $v): ?>
  303 + <iframe class="video_iframe" width="520" height="340" src="<?= $v ?>" frameborder="0" allowfullscreen></iframe>
  304 + <?php endforeach;
  305 + }?>
  306 + </div>
  307 + <div class="display_none tabs_comments item_menu_content_wrapper">
  308 + <div id="mc-review"></div>
  309 + <script type="text/javascript">
  310 + cackle_widget = window.cackle_widget || [];
  311 + cackle_widget.push({widget: 'Review', id: 38277});
  312 + (function() {
  313 + var mc = document.createElement('script');
  314 + mc.type = 'text/javascript';
  315 + mc.async = true;
  316 + mc.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://cackle.me/widget.js';
  317 + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(mc, s.nextSibling);
  318 + })();
  319 + </script>
  320 + <a id="mc-link" href="http://cackle.ru">Социальные отзывы <b style="color:#4FA3DA">Cackl</b><b style="color:#F65077">e</b></a>
  321 + </div>
284 322 </div>
285   - <div class="display_none tabs_video item_menu_content_wrapper">
286   - <?php if(!empty($item['content_video'])){
287   - $video = explode(',',$item['content_video']);
288   - foreach($video as $v): ?>
289   - <iframe class="video_iframe" width="520" height="340" src="<?= $v ?>" frameborder="0" allowfullscreen></iframe>
290   - <?php endforeach;
291   - }?>
  323 + </div>
  324 + </div>
  325 + </div>
  326 + </div>
  327 +
  328 + <div class="other_items">
  329 + <div class="item_menu_header_menu clearfix">
  330 + <div class="inner">
  331 + <div class="tabs clearfix">
  332 + <ul class="change_similar_items">
  333 + <li class="float active_tab first_tab">
  334 + <?= '<a href="#" title="'.$t->_("related_items").'" data-change_similar_items="buy_with" data-catalog_id="'.$catalog_id.'" data-group_id="'.$item['group_id'].'">'.$t->_("related_items").'</a>' ?>
  335 + </li>
  336 + <li class="float not_active">
  337 + <?= '<a href="#" title="'.$t->_("similar_items").'" data-change_similar_items="same" data-catalog_id="'.$catalog_id.'" data-group_id="'.$item['group_id'].'">'.$t->_("similar_items").'</a>' ?>
  338 + </li>
  339 + <li class="float not_active">
  340 + <?= '<a href="#" title="'.$t->_("popular_items").'" data-change_similar_items="popular" data-catalog_id="'.$catalog_id.'" data-group_id="'.$item['group_id'].'">'.$t->_("popular_items").'</a>' ?>
  341 + </li>
  342 + <li class="float last_tab not_active">
  343 + <?= '<a href="#" title="'.$t->_("watched").'" data-change_similar_items="viewed" data-catalog_id="'.$catalog_id.'" data-group_id="'.$item['group_id'].'">'.$t->_("watched").'</a>' ?>
  344 + </li>
  345 + </ul>
292 346 </div>
293   - <div class="display_none tabs_comments item_menu_content_wrapper">
294   - <div id="mc-review"></div>
295   - <script type="text/javascript">
296   - cackle_widget = window.cackle_widget || [];
297   - cackle_widget.push({widget: 'Review', id: 38277});
298   - (function() {
299   - var mc = document.createElement('script');
300   - mc.type = 'text/javascript';
301   - mc.async = true;
302   - mc.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://cackle.me/widget.js';
303   - var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(mc, s.nextSibling);
304   - })();
305   - </script>
306   - <a id="mc-link" href="http://cackle.ru">Социальные отзывы <b style="color:#4FA3DA">Cackl</b><b style="color:#F65077">e</b></a>
307   - </div>
308 347 </div>
309 348 </div>
  349 + <div class="items inner clearfix">
  350 + <?php if( !empty( $popular_groups ) ):
  351 + foreach( $popular_groups as $k => $p ):
  352 + $this->partial('partial/item_group', ['k' => $k, 'i' => $p, 'limit' => 5]);
  353 + endforeach;
  354 + endif; ?>
  355 + </div>
310 356 </div>
311   - </div>
312   -</div>
313 357  
  358 + <?php
  359 + if( !empty( $news ) )
  360 + {
  361 + $data_news =
  362 + '<div class="news_wrapper">'.
  363 + '<div class="inner clearfix">';
314 364  
  365 + foreach( $news as $k => $n )
  366 + {
  367 + $data_news .=
  368 + '<div class="one_news float'.( ($k+1)%2==0 ? ' last' : '' ).'">'.
  369 + '<div class="one_news_img float">'.
  370 + ( !empty( $n['cover'] )
  371 + ?
  372 + '<a href="'.$this->seoUrl->setUrl($n['link']).'" title="'.$n['title'].'">'.
  373 + '<img src="'.$n['image'].'" alt="" width="180" height="120" />'.
  374 + '</a>'
  375 + :
  376 + '').
  377 + '</div>'.
  378 + '<div class="one_news_content float'.( empty( $n['cover'] ) ? ' full_width' : '').'">'.
  379 + '<a href="'.$this->seoUrl->setUrl($n['link']).'" title="'.$n['title'].'">'.
  380 + '<h2>'.$n['title'].'</h2>'.
  381 + '</a>'.
  382 + '<p>'.$this->common->shortenString( $n['abstract_info'], 230 ).'</p>'.
  383 + '<a href="'.$this->seoUrl->setUrl($n['link']).'" title="'.$n['title'].'" class="news_more">Докладніше</a>'.
  384 + '</div>'.
  385 + '</div>';
  386 + }
315 387  
316   -<div class="other_items">
317   - <div class="item_menu_header_menu clearfix">
318   - <div class="inner">
319   - <div class="tabs clearfix">
320   - <ul class="change_similar_items">
321   - <li class="float active_tab first_tab">
322   - <?= '<a href="#" title="'.$t->_("related_items").'" data-change_similar_items="buy_with" data-catalog_id="'.$catalog_id.'" data-group_id="'.$item['group_id'].'">'.$t->_("related_items").'</a>' ?>
323   - </li>
324   - <li class="float not_active">
325   - <?= '<a href="#" title="'.$t->_("similar_items").'" data-change_similar_items="same" data-catalog_id="'.$catalog_id.'" data-group_id="'.$item['group_id'].'">'.$t->_("similar_items").'</a>' ?>
326   - </li>
327   - <li class="float not_active">
328   - <?= '<a href="#" title="'.$t->_("popular_items").'" data-change_similar_items="popular" data-catalog_id="'.$catalog_id.'" data-group_id="'.$item['group_id'].'">'.$t->_("popular_items").'</a>' ?>
329   - </li>
330   - <li class="float last_tab not_active">
331   - <?= '<a href="#" title="'.$t->_("watched").'" data-change_similar_items="viewed" data-catalog_id="'.$catalog_id.'" data-group_id="'.$item['group_id'].'">'.$t->_("watched").'</a>' ?>
332   - </li>
333   - </ul>
334   - </div>
335   - </div>
336   - </div>
337   - <div class="items inner clearfix">
338   - <?php if( !empty( $popular_groups ) ):
339   - foreach( $popular_groups as $k => $p ):
340   - $this->partial('partial/item_group', ['k' => $k, 'i' => $p, 'limit' => 5]);
341   - endforeach;
342   - endif; ?>
343   - </div>
344   -</div>
  388 + $data_news .= '</div></div>';
345 389  
346   -<?php
347   -
348   -if( !empty( $news ) )
349   -{
350   - $data_news =
351   - '<div class="news_wrapper">'.
352   - '<div class="inner clearfix">';
353   -
354   - foreach( $news as $k => $n )
355   - {
356   - $data_news .=
357   - '<div class="one_news float'.( ($k+1)%2==0 ? ' last' : '' ).'">'.
358   - '<div class="one_news_img float">'.
359   - ( !empty( $n['cover'] )
360   - ?
361   - '<a href="'.$this->seoUrl->setUrl($n['link']).'" title="'.$n['title'].'">'.
362   - '<img src="'.$n['image'].'" alt="" width="180" height="120" />'.
363   - '</a>'
364   - :
365   - '').
366   - '</div>'.
367   - '<div class="one_news_content float'.( empty( $n['cover'] ) ? ' full_width' : '').'">'.
368   - '<a href="'.$this->seoUrl->setUrl($n['link']).'" title="'.$n['title'].'">'.
369   - '<h2>'.$n['title'].'</h2>'.
370   - '</a>'.
371   - '<p>'.$this->common->shortenString( $n['abstract_info'], 230 ).'</p>'.
372   - '<a href="'.$this->seoUrl->setUrl($n['link']).'" title="'.$n['title'].'" class="news_more">Докладніше</a>'.
373   - '</div>'.
374   - '</div>';
375   - }
376   -
377   - $data_news .= '</div></div>';
378   -
379   - echo( $data_news );
380   -}
381   -
382   -?>
383   -
384   -<!--<div class="content_accost">
  390 + echo( $data_news );
  391 + }
  392 + ?>
  393 +
  394 + <!--
  395 + <div class="content_accost">
  396 + <div class="shadow_to_down"></div>
  397 + <div class="inner">
  398 + <div class="content_accost_title"></div>
  399 + <div class="content_accost_content">
  400 + <p>
  401 + Інтернет - магазин ТМ "Професійне насіння"
  402 + </p>
  403 + </div>
  404 + </div>
  405 + </div> content_accost
  406 + -->
  407 + <div class="content_accost">
385 408 <div class="shadow_to_down"></div>
386 409 <div class="inner">
387 410 <div class="content_accost_title"></div>
388 411 <div class="content_accost_content">
389 412 <p>
390   - Інтернет - магазин ТМ "Професійне насіння"
  413 + <?= isset( $seo['seo_text'] ) && !empty( $seo['seo_text'] ) ? $seo['seo_text'] : ''?>
391 414 </p>
392 415 </div>
393 416 </div>
394   - </div> content_accost -->
395   - <div class="content_accost">
396   - <div class="shadow_to_down"></div>
397   - <div class="inner">
398   - <div class="content_accost_title"></div>
399   - <div class="content_accost_content">
400   - <p>
401   - <?= isset( $seo['seo_text'] ) && !empty( $seo['seo_text'] ) ? $seo['seo_text'] : ''?>
402   - </p>
403   - </div>
404 417 </div>
405   - </div>
406   -<div class="content_blog">
407   - <div class="inner">
408 418  
409   - <div class="links clearfix">
  419 + <div class="content_blog">
  420 + <div class="inner">
410 421  
411   - <div class="float fb">
412   - <div id="fb-root"></div>
  422 + <div class="links clearfix">
413 423  
414   - <div class="fb-like" data-href="#" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
415   - </div>
416   - <div class="float ok">
417   - <div id="ok_shareWidget"></div>
418   - </div>
419   - <div class="float vk">
420   - <script type="text/javascript"><!--
421   - document.write(VK.Share.button(false,{type: "round", text: "Нравится"}));
422   - -->
423   - </script>
424   - </div>
  424 + <div class="float fb">
  425 + <div id="fb-root"></div>
  426 +
  427 + <div class="fb-like" data-href="#" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
  428 + </div>
  429 + <div class="float ok">
  430 + <div id="ok_shareWidget"></div>
  431 + </div>
  432 + <div class="float vk">
  433 + <script type="text/javascript"><!--
  434 + document.write(VK.Share.button(false,{type: "round", text: "Нравится"}));
  435 + -->
  436 + </script>
  437 + </div>
425 438  
426   - <div class="float share">
427   - <p class="share_title float"><?= $t->_("share")?>:</p>
  439 + <div class="float share">
  440 + <p class="share_title float"><?= $t->_("share")?>:</p>
428 441  
429   - <div class="pluso float" data-background="#ebebeb" data-options="small,square,line,horizontal,nocounter,theme=04" data-services="facebook,google,livejournal,moimir,odnoklassniki,vkontakte,twitter"></div>
  442 + <div class="pluso float" data-background="#ebebeb" data-options="small,square,line,horizontal,nocounter,theme=04" data-services="facebook,google,livejournal,moimir,odnoklassniki,vkontakte,twitter"></div>
  443 + </div>
430 444 </div>
431 445 </div>
432   - </div>
433 446  
434   -</div><!-- content_blog -->
435   -</div><!-- catalog -->
  447 + </div><!-- content_blog -->
  448 +
  449 + </div><!-- catalog -->
436 450 </div>
  451 +
437 452 </div>
  453 +
438 454 <script>
439 455  
440 456 <?php
441   -
442 457 $customer_id = $this->session->get('id');
443   -
444   -
445 458 ?>
446 459 $( document ).ready(function() {
  460 +
447 461 $('body').on('click','.one_item_buttons a', function(){
448 462  
449 463 <?php if( !empty( $customer_id ) ) : ?>
... ... @@ -481,7 +495,6 @@ if( !empty( $news ) )
481 495  
482 496 });
483 497  
484   -
485 498 });
486 499  
487 500  
... ...
src/app/frontend/views/page/subtype.php
... ... @@ -197,7 +197,10 @@
197 197 $minPrice = 0;
198 198 ?>
199 199 <?php foreach ($groups as $k => $i): ?>
200   - <?php $this->partial('partial/item_group', ['k' => $k, 'i' => $i, 'limit' => 3]) ?>
  200 + <?php
  201 + if (empty($discount)) $discount = 0;
  202 + $this->partial('partial/item_group', ['k' => $k, 'i' => $i, 'limit' => 3, 'discount' => $discount])
  203 + ?>
201 204 <?php
202 205 if ($i['price'] > $maxPrice) {
203 206 $maxPrice = $i['price'];
... ...
src/app/frontend/views/partial/item_group.php
... ... @@ -31,7 +31,24 @@
31 31 </a>
32 32 </div>
33 33 <div class="align_bottom">
34   - <div class="one_item_price"><?= $t->_("price_from") ?> <span><?= $i['price'] ?></span> грн</div>
  34 + <div class="one_item_price">
  35 + <?= $t->_("price_from") ?>
  36 + <?php
  37 + // скидка
  38 + if (!empty($discount)) {
  39 + if ($discount['discount'] > 0 && $discount['discount'] <= 100 && in_array($i['id'], $discount['group_ids'])) {
  40 + echo '<span style="text-decoration: line-through;"><span>'.$i['price'].'</span></span> грн<br/>';
  41 + echo '<span>'.round($i['price']*(1-$discount['discount']/100), 1).'</span> грн';
  42 + }
  43 + else {
  44 + echo '<span>'.$i['price'].'</span> грн';
  45 + }
  46 + }
  47 + else {
  48 + echo '<span>'.$i['price'].'</span> грн';
  49 + }
  50 + ?>
  51 + </div>
35 52 <div class="one_item_buttons">
36 53 <a href="<?= $this->seoUrl->setUrl($i['alias']) ?>" title="" class="btn grey"><?= $t->_("details") ?></a>
37 54 <a data-group_id="<?= $i['group_id'] ?>" href="javascript:;" title="" class="<?= $i['count_available'] != 0 ? 'btn green buy' : 'not_available grey'?>"><?= $t->_("buy") ?></a>
... ...
src/config/global.php
... ... @@ -32,6 +32,7 @@ return
32 32  
33 33  
34 34 'phones' => '(044)-581-67-15, (044)-451-48-59 <br /> (050)-464-48-59, (067)-464-48-59',
  35 +
35 36 'email' => 'ludmila.v@hs.kiev.ua, alla@hs.kiev.ua, lesya@hs.kiev.ua, olga@hs.kiev.ua,kristina@hs.kiev.ua, test@hs.kiev.ua, olya.o.chyzh@gmail.com',
36 37 'name' => 'Semena',
37 38  
... ...
src/lib/common.php
... ... @@ -1229,24 +1229,23 @@ namespace
1229 1229 }
1230 1230  
1231 1231 public function getCartItems($in_cart, $lang_id, $special_user = null) {
1232   - $result = [];
1233   - $total_price = 0;
1234   - $item_ids = $this->array_column( $in_cart, 'item_id' );
1235   - $items = $this->getDi()->get('models')->getItems()->getItemsByIds( $lang_id, $item_ids );
1236   - $groups_ids = $this->array_column( $items, 'group_id' );
1237   - $groups_data = $this->getDi()->get('models')->getItems()->getItemsByColorAndGroupsId(join(',',$groups_ids));
1238   - $colors = array_unique($this->array_column( $groups_data, 'color_id' ));
1239   - $color_info = $this->getDi()->get('models')->getItems()->getColorsInfoByColorsId( $lang_id, join(',',$colors) );
  1232 + $result = [];
  1233 + $total_price = 0;
  1234 + $item_ids = $this->array_column( $in_cart, 'item_id' );
  1235 + $items = $this->getDi()->get('models')->getItems()->getItemsByIds( $lang_id, $item_ids );
  1236 + $groups_ids = $this->array_column( $items, 'group_id' );
  1237 + $groups_data = $this->getDi()->get('models')->getItems()->getItemsByColorAndGroupsId(join(',',$groups_ids));
  1238 + $colors = array_unique($this->array_column( $groups_data, 'color_id' ));
  1239 + $color_info = $this->getDi()->get('models')->getItems()->getColorsInfoByColorsId( $lang_id, join(',',$colors) );
  1240 +
1240 1241 foreach($color_info as $k =>$v){
1241 1242 $colors_info[$v['id']] = $v;
1242 1243 }
1243 1244  
1244   -
1245 1245 foreach($groups_data as $k =>$v){
1246 1246 if($groups_data[$k]['color_id'] != 0){
1247 1247 $groups_data[$k]['color'] = $colors_info[$groups_data[$k]['color_id']]['color_title'];
1248 1248 $groups_data[$k]['absolute_color'] = $colors_info[$groups_data[$k]['color_id']]['absolute_color'];
1249   -
1250 1249 } else {
1251 1250 $groups_data[$k]['color'] = 0;
1252 1251 $groups_data[$k]['absolute_color'] = 0;
... ... @@ -1257,9 +1256,7 @@ namespace
1257 1256 $groups_data[$v['id']] = $v;
1258 1257 }
1259 1258  
1260   - foreach ( $in_cart as $c )
1261   - {
1262   -
  1259 + foreach ( $in_cart as $c ) {
1263 1260 $count_item[$c['item_id']] = $c['count_items'];
1264 1261 }
1265 1262  
... ... @@ -1269,14 +1266,9 @@ namespace
1269 1266 }
1270 1267 }
1271 1268  
1272   -
1273   -
1274   - foreach ( $items as $k => $i )
1275   - {
1276   - $items[$k]['cover'] = !empty( $i['group_cover'] ) ? $this->getDi()->get('storage')->getPhotoUrl( $i['item_cover'], 'avatar', '128x' ) : '/images/packet.jpg';
1277   - $items[$k]['alias'] = $this->getDi()->get('url')->get([ 'for' => 'item', 'subtype' => $i['catalog_alias'], 'group_alias' => $i['group_alias'], 'item_id' => $i['id'] ]);
1278   -
1279   -
  1269 + foreach ( $items as $k => $i ) {
  1270 + $items[$k]['cover'] = !empty( $i['group_cover'] ) ? $this->getDi()->get('storage')->getPhotoUrl( $i['item_cover'], 'avatar', '128x' ) : '/images/packet.jpg';
  1271 + $items[$k]['alias'] = $this->getDi()->get('url')->get([ 'for' => 'item', 'subtype' => $i['catalog_alias'], 'group_alias' => $i['group_alias'], 'item_id' => $i['id'] ]);
1280 1272  
1281 1273 if(isset($i['prices'][0])) {
1282 1274 $items[$k]['total_price'] = round($count_item[$i['id']] * $i['prices'][$special_user['status']], 2);
... ... @@ -1285,24 +1277,25 @@ namespace
1285 1277 $items[$k]['total_price'] = round($count_item[$i['id']] * $i['price2'], 2);
1286 1278 }
1287 1279  
1288   - $items[$k]['count'] = $count_item[$i['id']];
1289   - $total_price += $items[$k]['total_price'];
1290   - $items[$k]['color'] = $groups_data[$i['id']]['color'];
1291   - $items[$k]['absolute_color'] = $groups_data[$i['id']]['absolute_color'];
1292   - $items_[$i['id']] = $items[$k];
  1280 + $items[$k]['count'] = $count_item[$i['id']];
  1281 + $total_price += $items[$k]['total_price'];
  1282 + $items[$k]['color'] = $groups_data[$i['id']]['color'];
  1283 + $items[$k]['absolute_color'] = $groups_data[$i['id']]['absolute_color'];
  1284 + $items_[$i['id']] = $items[$k];
1293 1285 }
1294 1286  
1295   - $total_price = round( $total_price, 2 );
  1287 + $total_price = round( $total_price, 2 );
  1288 + $result['total_price'] = $total_price;
  1289 + $result['items'] = $items;
  1290 + $result['items_'] = $items_;
1296 1291  
1297   - $result['total_price'] = $total_price;
1298   - $result['items'] = $items;
1299   - $result['items_'] = $items_;
1300 1292 return $result;
1301 1293 }
1302 1294  
1303   - public function countOrderSum(&$order) {
  1295 + public function countOrderSum(&$order)
  1296 + {
1304 1297 $sum = 0;
1305   - foreach($order['items'] as $k => $item) {
  1298 + foreach ($order['items'] as $k => $item) {
1306 1299 $sum += $item['total_price'];
1307 1300 }
1308 1301 $order['total_sum'] = $sum;
... ...
src/lib/models.php
... ... @@ -51,7 +51,8 @@ namespace
51 51 protected $_reviews = false;
52 52 protected $_modal = false;
53 53 protected $_manager_mail = false;
54   - protected $_promo_to_user = false;
  54 + protected $_promo_to_user = false;
  55 + protected $_discount = false;
55 56  
56 57  
57 58  
... ... @@ -84,7 +85,7 @@ namespace
84 85 * @author Jane Bezmaternykh
85 86 * @version 0.1.20140327
86 87 *
87   - * @return obj
  88 + * @return \models\items
88 89 */
89 90 public function getItems()
90 91 {
... ... @@ -553,6 +554,17 @@ namespace
553 554 return $this->_promo_codes;
554 555 }
555 556  
  557 + public function getDiscount()
  558 + {
  559 + if( empty($this->_discount) )
  560 + {
  561 + $this->_discount = new \models\discount();
  562 + $this->_discount->setDi( $this->getDi() );
  563 + }
  564 +
  565 + return $this->_discount;
  566 + }
  567 +
556 568 public function getPayment()
557 569 {
558 570 if( empty($this->_payment) )
... ...
src/lib/models/discount.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: Alex Savenko
  5 + * Date: 20.12.2016
  6 + * Time: 13:39
  7 + */
  8 +
  9 +namespace models;
  10 +
  11 +
  12 +class discount extends \db
  13 +{
  14 +
  15 + /**
  16 + * Get all discounts
  17 + * @return array
  18 + */
  19 + public function getAllData()
  20 + {
  21 +
  22 + return $this->get(
  23 + '
  24 + SELECT * FROM
  25 + public.discount
  26 + '
  27 + ,
  28 + [
  29 + ],
  30 + -1
  31 + );
  32 + }
  33 +
  34 +
  35 + /**
  36 + * Get discount
  37 + * @param $id
  38 + * @return array
  39 + */
  40 + public function getOneData($id)
  41 + {
  42 + return $this->get(
  43 + '
  44 + SELECT *
  45 + FROM public.discount
  46 + WHERE
  47 + id = :id
  48 + ',
  49 + [
  50 + 'id' => $id
  51 + ],
  52 + -1
  53 + );
  54 + }
  55 +
  56 + /**
  57 + * Get discount indication status
  58 + * @param $id
  59 + * @return array
  60 + */
  61 + public function getStatus($id) {
  62 +
  63 + $status = $this->get(
  64 + '
  65 + SELECT status
  66 + FROM public.discount
  67 + WHERE
  68 + id = :id
  69 + ',
  70 + [
  71 + 'id' => $id
  72 + ],
  73 + -1
  74 + );
  75 +
  76 + return $status[0]['status'];
  77 +
  78 + }
  79 +
  80 +
  81 + /**
  82 + * Get actual discount
  83 + * @return array
  84 + */
  85 + public function getActiveData()
  86 + {
  87 + return $this->get(
  88 + '
  89 + SELECT *
  90 + FROM public.discount
  91 + WHERE
  92 + status = 1
  93 + AND
  94 + current_timestamp > start_date
  95 + AND
  96 + current_timestamp < end_date
  97 + LIMIT 1
  98 +
  99 + ',
  100 + [
  101 + ],
  102 + -1
  103 + );
  104 + }
  105 +
  106 +
  107 + /**
  108 + * Delete discount
  109 + * @param $id
  110 + * @return bool
  111 + */
  112 + public function deleteData($id)
  113 + {
  114 + return $this->exec(
  115 + ' DELETE
  116 + FROM
  117 + public.discount
  118 + WHERE
  119 + id = :id
  120 + ',
  121 + [
  122 + 'id' => $id
  123 + ]
  124 + );
  125 + }
  126 +
  127 + /**
  128 + * Add new discount
  129 + * @param $data
  130 + * @return array
  131 + */
  132 + public function addData($data)
  133 + {
  134 +
  135 + return $this->get(
  136 + '
  137 + INSERT INTO
  138 + public.discount
  139 + (
  140 + name,
  141 + discount,
  142 + description,
  143 + start_date,
  144 + end_date,
  145 + status,
  146 + group_ids
  147 + )
  148 + VALUES
  149 + (
  150 + :name,
  151 + :discount,
  152 + :description,
  153 + :start_date,
  154 + :end_date,
  155 + :status,
  156 + :group_ids
  157 + )
  158 + RETURNING id
  159 + ',
  160 + [
  161 + 'name' => $data['name'],
  162 + 'discount' => $data['discount'],
  163 + 'description' => $data['description'],
  164 + 'start_date' => $data['start_date'],
  165 + 'end_date' => $data['end_date'],
  166 + 'group_ids' => !empty($data['group_ids']) ? '{'. implode(', ', $data['group_ids']) . '}' : null,
  167 + 'status' => $data['status']
  168 + ],
  169 + -1
  170 + );
  171 +
  172 +
  173 + }
  174 +
  175 + /**
  176 + * Update discount
  177 + * @param $data
  178 + * @param $id
  179 + * @return bool
  180 + */
  181 + public function updateData($data, $id)
  182 + {
  183 +
  184 + return $this->exec(
  185 + '
  186 + UPDATE
  187 + public.discount
  188 + SET
  189 + name = :name,
  190 + discount = :discount,
  191 + description = :description,
  192 + start_date = :start_date,
  193 + end_date = :end_date,
  194 + status = :status,
  195 + group_ids = :group_ids
  196 + WHERE
  197 + id = :id
  198 + ',
  199 + [
  200 + 'name' => $data['name'],
  201 + 'discount' => $data['discount'],
  202 + 'description' => $data['description'],
  203 + 'start_date' => $data['start_date'],
  204 + 'end_date' => $data['end_date'],
  205 + 'status' => $data['status'],
  206 + 'group_ids' => !empty($data['group_ids']) ? '{'. implode(', ', $data['group_ids']) . '}' : null,
  207 + 'id' => $id
  208 + ]
  209 + );
  210 +
  211 + }
  212 +
  213 + /**
  214 + * Switch status indicator
  215 + * @param bool $status
  216 + * @param $id
  217 + * @return bool
  218 + */
  219 + public function updateStatus($status, $id) {
  220 +
  221 + return $this->exec(
  222 + '
  223 + UPDATE
  224 + public.discount
  225 + SET
  226 + status = :status
  227 + WHERE
  228 + id = :id
  229 + ',
  230 + [
  231 + 'status' => $status,
  232 + 'id' => $id
  233 + ]
  234 + );
  235 +
  236 + }
  237 +
  238 + /**
  239 + * Count all discounts
  240 + * @return array
  241 + */
  242 + public function countData()
  243 + {
  244 + return $this->get(
  245 + '
  246 + SELECT
  247 + COUNT(id) AS total
  248 + FROM
  249 + public.discount
  250 + ',
  251 + [
  252 +
  253 + ],
  254 + -1
  255 + );
  256 + }
  257 +
  258 +}
0 259 \ No newline at end of file
... ...
www-backend/css/main.css
... ... @@ -917,6 +917,9 @@ label.error {
917 917 .one_page_edit:hover .one_page_delete_ico a{background: url(../images/del_hover.png) 0% 0% no-repeat; width: 16px; height: 16px}
918 918 .one_page_edit .one_page_edit_ico a{background: url(../images/pencil.png) 0% 0% no-repeat; width: 16px; height: 16px}
919 919 .one_page_edit:hover .one_page_edit_ico a{background: url(../images/pencil_hover.png) 0% 0% no-repeat; width: 16px; height: 16px}
  920 +.one_page_edit .one_page_status_on_ico a{background: url(../images/green_16.jpg) 0% 0% no-repeat; width: 16px; height: 16px}
  921 +.one_page_edit .one_page_status_off_ico a{background: url(../images/red_16.png) 0% 0% no-repeat; width: 16px; height: 16px}
  922 +
920 923  
921 924  
922 925  
... ...
www-backend/index.php
... ... @@ -1067,6 +1067,70 @@ try
1067 1067 )
1068 1068 ->setName('get_items_by_filter');
1069 1069  
  1070 + /* *************** discounts ************** */
  1071 +
  1072 + $router->add
  1073 + (
  1074 + '/discount_index',
  1075 + [
  1076 + 'controller' => 'discount',
  1077 + 'action' => 'index'
  1078 + ]
  1079 + )
  1080 + ->setName('discount_index');
  1081 +
  1082 + $router->add
  1083 + (
  1084 + '/discount_index/page/{page:[0-9]+}',
  1085 + [
  1086 + 'controller' => 'promo_codes',
  1087 + 'action' => 'index'
  1088 + ]
  1089 + )
  1090 + ->setName('discount_index_paged');
  1091 +
  1092 + $router->add
  1093 + (
  1094 + '/discount_add',
  1095 + [
  1096 + 'controller' => 'discount',
  1097 + 'action' => 'add'
  1098 + ]
  1099 + )
  1100 + ->setName('discount_add');
  1101 +
  1102 + $router->add
  1103 + (
  1104 + '/discount_update/{id:[0-9]+}',
  1105 + [
  1106 + 'controller' => 'discount',
  1107 + 'action' => 'update'
  1108 + ]
  1109 + )
  1110 + ->setName('discount_update');
  1111 +
  1112 + $router->add
  1113 + (
  1114 + '/discount_delete/{id:[0-9]+}',
  1115 + [
  1116 + 'controller' => 'discount',
  1117 + 'action' => 'delete'
  1118 + ]
  1119 + )
  1120 + ->setName('discount_delete');
  1121 +
  1122 + $router->add
  1123 + (
  1124 + '/discount_switch/{id:[0-9]+}',
  1125 + [
  1126 + 'controller' => 'discount',
  1127 + 'action' => 'switch'
  1128 + ]
  1129 + )
  1130 + ->setName('discount_switch');
  1131 +
  1132 + /* *************************************** */
  1133 +
1070 1134 $router->add
1071 1135 (
1072 1136 '/sales_index',
... ...
www/css/main.min.css
... ... @@ -926,15 +926,36 @@ input[type=number]{-moz-appearance:textfield;}
926 926 .catalog_description.logo320{background-color:#00a3de;}
927 927 h2.types_logo_320{color:#00a3de;}
928 928 h2.types_logo_543{color:#5b4a42;}
929   -.delivery-form-par{position:fixed;z-index:99991;top:0;background-color:rgba(255, 255, 255, 0.75);width:100%;height:100%;display:none;}
  929 +.delivery-form-par{position:fixed;z-index:99991;top:0;background-color:rgba(255, 255, 255, 0.75);width:100%;height:100%;display:none;transition:0.3s;}
930 930 .delivery-form-par .close-white{content:'';position:absolute;top:0;left:0;width:100%;height:100%;cursor:pointer;}
931   -.delivery-form-par .popup-main-delivery{width:843px;height:400px;background-image:url("../images/right_deliver.png");background-position:right center;background-repeat:no-repeat;background-color:#fdfaf1;position:absolute;font-family:'Lato-Medium';left:calc(50% - 421.5px);top:15%;}
932   -.delivery-form-par .content-popup .text-up{width:320px;border-bottom:1px solid #6cb33f;color:#42210b;text-align:center;font-size:18px;padding-top:19px;line-height:22px;padding-bottom:4px;}
933   -.delivery-form-par .text-down .up-text{color:#42210b;font-size:13.5px;text-align:center;width:323px;padding-top:23px;padding-bottom:8px;}
934   -.delivery-form-par .text-down .footer-text{color:#333333;font-style:italic;text-align:center;font-family:'Lato-Italic';padding-top:8px;padding-top:24px;width:319px;font-size:10.8px;}
  931 +.delivery-form-par .popup-main-delivery{width:843px;height:400px;background-image:url("../images/right_deliver.png");background-size: contain;background-position:right center;background-repeat:no-repeat;background-color:#fdfaf1;position:absolute;font-family:'Lato-Medium';left:calc(50% - 421.5px);top:15%;}
  932 +.delivery-form-par .content-popup .text-up{width:100%;max-width:332px;border-bottom:1px solid #6cb33f;color:#42210b;text-align:center;font-size:18px;padding-top:19px;line-height:22px;padding-bottom:4px;}
  933 +.delivery-form-par .content-popup .text-down{width:100%;max-width:332px;}
  934 +.delivery-form-par .text-down .up-text{color:#42210b;font-size:13.5px;text-align:center;width:100%;padding-top:23px;padding-bottom:8px;}
  935 +.delivery-form-par .text-down .footer-text{color:#333333;font-style:italic;text-align:center;font-family:'Lato-Italic';padding-top:8px;padding-top:24px;width:100%;font-size:10.8px;}
935 936 .delivery-form-par .submit-delivery-but{font-size:15px;color:#fff;border:none;background-color:#6cb33f;text-transform:lowercase;width:80px;height:25px;outline:none;cursor:pointer;}
936 937 .delivery-form-par .text-up p span{color:#f15a24;font-size:28.58px;}
937   -.delivery-form-par .content-popup{padding:38px;width:40%;}
  938 +.delivery-form-par .content-popup{transition:0.3s;padding:38px;width:100%;height:100%;min-height: 400px;max-width:480px;box-sizing:border-box;background-image:url('../images/grad_popup.png');background-position: left center;background-repeat-x: no-repeat;}
938 939 .delivery-form-par .text-down input{height:23px;width:104px;border:1px solid #6cb33f;font-size:9px;padding-left:12px;outline:none;}
939   -.delivery-form-par .deliver-form{display:flex;justify-content:space-between;width:327px;}
940   -body{font-family:Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif;}
941 940 \ No newline at end of file
  941 +.delivery-form-par .deliver-form{display:flex;justify-content:space-between;width:100%px;}
  942 +body{font-family:Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif;}
  943 +.open-delivery-modal{opacity: 1;cursor: pointer;position: fixed;top: calc(50% - 80px);left: 0%;font-size: 24px;z-index: 10000;}
  944 +.open-delivery-modal div{width: 100%;max-width: 360px;text-align: center;margin: 0 auto;position:relative;}
  945 +.open-delivery-modal div img{width:100%;max-width:360px;}
  946 +.modal_close{position: absolute;top: 23px;right: 10px;width: 15px;height: 15px;background-image:url('../images/close_popup.png');background-position:center center; background-repeat:no-repeat;border-radius: 50%;box-shadow: 0px 1px 3px -1px rgba(0, 0, 0, 0.40);cursor: default;}
  947 +.popup_full{display:block;}
  948 +.popup_mobile{display:none;}
  949 +@media( max-width: 880px ){
  950 + .delivery-form-par .popup-main-delivery{width:96%;left:2%;}
  951 + .open-delivery-modal{top: initial;bottom:0;width:100%;box-shadow: inset 0px -250px 125px -250px black;}
  952 + .popup_full{display:none;}
  953 + .popup_mobile{display:block;}
  954 +}
  955 +@media ( max-width: 480px ){
  956 + .delivery-form-par .content-popup{padding:25px;}
  957 + .delivery-form-par .popup-main-delivery{background-image:none;height:initial;top:10%;}
  958 + .delivery-form-par .deliver-form{justify-content: center;align-items: center;flex-direction: column;}
  959 + .delivery-form-par .text-down input {margin-bottom:5px;}
  960 + .delivery-form-par .submit-delivery-but{margin-top:5px;}
  961 + .delivery-form-par .content-popup .text-up, .delivery-form-par .content-popup .text-down{max-width:100%;}
  962 +}
942 963 \ No newline at end of file
... ...
www/images/close_popup.png 0 → 100644

15.2 KB

www/images/grad_popup.png 0 → 100644

32.3 KB

www/images/popup_full.png 0 → 100644

103 KB

www/images/popup_open.png 0 → 100644

41.8 KB

www/images/right_deliver.png

280 KB | W: | H:

233 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
www/php.php
1 1 <?php
2   -//test
  2 +echo 'on discount branch';
3 3 phpinfo();
... ...