add configuration to select helpdesk for paid support module

This commit is contained in:
Vaidas Lungis committed 2015-02-13 13:55:54 +02:00
1 parent 1a8859fe56
commit c8abd00a3c
4 files changed
+348 -11

No files matched your search

+30 -2
View File
@@ -54,8 +54,9 @@ class Service implements InjectionAwareInterface
$paidSupportService = $di['mod_service']('Paidsupport');
$paidSupportService->setDi($di);
$paidSupportService->enoughInBalanceToOpenTicket($client);
if ($paidSupportService->hasHelpdeskPaidSupport($params['support_helpdesk_id'])) {
$paidSupportService->enoughInBalanceToOpenTicket($client);
}
return true;
}
@@ -73,6 +74,10 @@ class Service implements InjectionAwareInterface
$paidSupportService = $di['mod_service']('Paidsupport');
$paidSupportService->setDi($di);
if (!$paidSupportService->hasHelpdeskPaidSupport($supportTicket->support_helpdesk_id)) {
return true;
}
$paidSupportService->enoughInBalanceToOpenTicket($client);
$clientBalanceService = $di['mod_service']('Client', 'Balance');
@@ -110,6 +115,12 @@ class Service implements InjectionAwareInterface
return isset($config['error_msg']) ? $config['error_msg'] : 'Configure paid support module!';
}
public function getPaidHelpdeskConfig()
{
$config = $this->di['mod_config']('Paidsupport');
return isset($config['helpdesk']) ? $config['helpdesk'] : array();
}
public function enoughInBalanceToOpenTicket(\Model_Client $client)
{
$clientBalanceService = $this->di['mod_service']('Client', 'Balance');
@@ -122,5 +133,22 @@ class Service implements InjectionAwareInterface
return true;
}
/**
* @param $id
* @return bool
*/
public function hasHelpdeskPaidSupport($id)
{
$helpdeskConfig = $this->getPaidHelpdeskConfig();
if (empty ($helpdeskConfig)) {
return true;
}
if (isset($helpdeskConfig[$id]) && $helpdeskConfig[$id] == 1){
return true;
}
return false;
}
}
@@ -35,6 +35,38 @@
</div>
<div class="fix"></div>
</div>
<div class="tab_content nopadding" id="tab-addons">
<div class="help">
<h5>{% trans 'Set paid supoprt for helpdesks: ' %}</h5>
<p>{% trans 'Paid support applied for all of them if nothing is selected' %}</p>
</div>
<table class="tableStatic wide">
<tbody>
{% for id, title in admin.support_helpdesk_get_pairs %}
<tr {% if loop.first %}class="noborder"{% endif %}>
<td style="width:5%">
<input type="hidden" name="helpdesk[{{id}}]" value="0">
<input type="checkbox" name="helpdesk[{{id}}]" value="1" id="helpdesk_{{ id }}" {% if params.helpdesk[id] == 1 %}checked="checked"{% endif %}/>
</td>
<td><label for="helpdesk_{{ id }}">{{title}}</label></td>
<td style="width:5%"><a class="bb-button btn14" href="{{ '/support/helpdesk'|alink }}/{{id}}"><img src="images/icons/dark/pencil.png" alt=""></a></td>
</tr>
{% else %}
<tr>
<td colspan="3">{% trans 'The list is empty' %}</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="3">
<a href="{{ 'extension/settings/support'|alink }}#tab-new-helpdesk" title="" class="btnIconLeft mr10 mt5"><img src="images/icons/dark/settings2.png" alt="" class="icon"><span>{% trans 'Create new helpdesk' %}</span></a>
</td>
</tr>
</tfoot>
</table>
<div class="fix"></div>
</div>
<input type="hidden" name="ext" value="mod_paidsupport" />