diff --git a/src/bb-modules/Product/Api/Admin.php b/src/bb-modules/Product/Api/Admin.php index c2db5f6e7..c66bb3473 100644 --- a/src/bb-modules/Product/Api/Admin.php +++ b/src/bb-modules/Product/Api/Admin.php @@ -466,8 +466,13 @@ class Admin extends \Api_Abstract if(isset($data['periods']) && is_array($data['periods'])) { $periods = $data['periods']; } + + $clientGroups = array(); + if(isset($data['client_groups']) && is_array($data['client_groups'])) { + $clientGroups = $data['client_groups']; + } $service = $this->getService(); - return (int) $service->createPromo($data['code'], $data['type'], $data['value'], $products, $periods, $data); + return (int) $service->createPromo($data['code'], $data['type'], $data['value'], $products, $periods, $clientGroups, $data); } /** diff --git a/src/bb-modules/Product/Service.php b/src/bb-modules/Product/Service.php index 00ee5a0f7..b8c898778 100644 --- a/src/bb-modules/Product/Service.php +++ b/src/bb-modules/Product/Service.php @@ -564,7 +564,7 @@ class Service implements InjectionAwareInterface return array($sql, $params); } - public function createPromo($code, $type, $value, $products = array(), $periods = array(), $data) + public function createPromo($code, $type, $value, $products = array(), $periods = array(), $clientGroups = array(), $data) { $systemService = $this->di['mod_service']('system'); $systemService->checkLimits('Model_Promo', 2); @@ -583,6 +583,7 @@ class Service implements InjectionAwareInterface $model->products = json_encode($products); $model->periods = json_encode($periods); + $model->client_groups = json_encode($clientGroups); $model->updated_at = date('c'); $model->created_at = date('c'); @@ -597,10 +598,15 @@ class Service implements InjectionAwareInterface $products = json_decode($model->products, 1); $products = $this->getProductTitlesByIds($products); + $clientGroups = json_decode($model->client_groups, 1); + $clientGroups = $this->di['tools']->getPairsForTableByIds('client_group',$clientGroups); + $result = $this->di['db']->toArray($model); $result['applies_to'] = $products; + $result['cgroups'] = $clientGroups; $result['products'] = json_decode($model->products, 1); $result['periods'] = json_decode($model->periods, 1); + $result['client_groups'] = json_decode($model->client_groups, 1); return $result; } diff --git a/src/bb-themes/admin_default/html/mod_product_promos.phtml b/src/bb-themes/admin_default/html/mod_product_promos.phtml index 6d9200fd8..607f49613 100644 --- a/src/bb-themes/admin_default/html/mod_product_promos.phtml +++ b/src/bb-themes/admin_default/html/mod_product_promos.phtml @@ -30,6 +30,7 @@ {% trans 'Code' %} {% trans 'Discount' %} {% trans 'Applies to' %} + {% trans 'Client groups' %} {% trans 'Valid period' %} {% trans 'Enabled' %} {% trans 'Usage' %} @@ -49,6 +50,12 @@ All products {% endfor %} + {% for cid,client_group in promo.cgroups %} + {{ client_group|truncate(15) }}
+ {% else %} + All client groups + {% endfor %} + From {% if promo.start_at %}{{ promo.start_at|date('Y-m-d') }}{% else %}now{% endif %} untill {% if promo.end_at %}{{ promo.end_at|date('Y-m-d') }}{% else %}disabled{% endif %} @@ -183,6 +190,18 @@
+
+ +
+ {% set client_groups = admin.client_group_get_pairs %} + +
+
+
{#