mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-21 20:34:57 +09:00
Implemented client_groups for new promo
This commit is contained in:
1 parent
65f7947795
commit
2e044c27d4
3 files changed
+32
-2
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
<td>{% trans 'Code' %}</td>
|
||||
<td>{% trans 'Discount' %}</td>
|
||||
<td>{% trans 'Applies to' %}</td>
|
||||
<td>{% trans 'Client groups' %}</td>
|
||||
<td>{% trans 'Valid period' %}</td>
|
||||
<td>{% trans 'Enabled' %}</td>
|
||||
<td>{% trans 'Usage' %}</td>
|
||||
@@ -49,6 +50,12 @@
|
||||
All products
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>{% for cid,client_group in promo.cgroups %}
|
||||
<a href="{{ 'client/group'|alink }}/{{cid}}">{{ client_group|truncate(15) }}</a><br/>
|
||||
{% else %}
|
||||
All client groups
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>
|
||||
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 @@
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
<div class="rowElem">
|
||||
<label>{% trans 'Periods (Select none to apply to all client groups)' %}</label>
|
||||
<div class="formRight">
|
||||
{% set client_groups = admin.client_group_get_pairs %}
|
||||
<select name="client_groups[]" multiple="multiple" class="multiple" size="{{groups|length}}">
|
||||
{% for id, client_group in client_groups %}
|
||||
<option value="{{id}}">{{ client_group }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
{#
|
||||
<div class="rowElem">
|
||||
<label>{% trans 'Addons (Select none to apply to all addons)' %}</label>
|
||||
|
||||
Reference in new issue
Block a user