Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Fix out of working hours settings save
  • Loading branch information
jorikfon committed Nov 5, 2024
1 parent 39e919f commit ffb7538
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions src/AdminCabinet/Controllers/OutOffWorkTimeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public function indexAction(): void
$this->view->indexTable = $timeframesTable;
}

/**
* Changes the priority of the OutWorkTimes data based on the provided priority table.
* @return void
*/
public function changePriorityAction(): void
{
$this->view->disable();
Expand Down Expand Up @@ -113,7 +117,8 @@ public function changePriorityAction(): void
*/
public function modifyAction(string $id = ''): void
{
// Find the OutWorkTimes data based on the provided ID or create a new one if the ID is not provided or not found.
// Find the OutWorkTimes data based on the provided ID
// or create a new one if the ID is not provided or not found.
$timeFrame = OutWorkTimes::findFirstById($id);
if ($timeFrame === null) {
$timeFrame = new OutWorkTimes();
Expand Down Expand Up @@ -159,7 +164,8 @@ public function modifyAction(string $id = ''): void
$weekDays[$i] = $this->translation->_(date('D', strtotime("Sunday +$i days")));
}

// Create a new TimeFrameEditForm object with the $timeFrame and arrays for the forwarding extensions, audio messages, available actions, and week days.
// Create a new TimeFrameEditForm object with the $timeFrame
// and arrays for the forwarding extensions, audio messages, available actions, and week days.
$form = new TimeFrameEditForm(
$timeFrame,
[
Expand All @@ -170,7 +176,7 @@ public function modifyAction(string $id = ''): void
]
);

// Set the form and the represent value of the $timeFrame object to the view.
// Set the form and the represented value of the $timeFrame object to the view.
$this->view->form = $form;
$this->view->represent = $timeFrame->getRepresent();

Expand All @@ -196,7 +202,8 @@ public function modifyAction(string $id = ''): void
if ($providerData['registration_type'] === Sip::REG_TYPE_INBOUND || empty($providerData['host'])) {
$providersId[$providerData['uniqid']] = $providerData['uniqid'];
} else {
$providersId[$providerData['uniqid']] = SIPConf::getContextId($providerData['host'], $providerData['port']);
$providersId[$providerData['uniqid']]
= SIPConf::getContextId($providerData['host'], $providerData['port']);
}
}
unset($data);
Expand Down Expand Up @@ -226,7 +233,7 @@ public function modifyAction(string $id = ''): void
'extension' => $rule->extension,
'callerid' => $extension ? $extension->getRepresent() : '',
'note' => $rule->note,
'status' => in_array($rule->id, $allowedRulesIds, true) ? '' : 'disabled',
'status' => in_array($rule->id, $allowedRulesIds, false) ? '' : 'disabled',
];

$routingTable[] = $values;
Expand Down Expand Up @@ -339,11 +346,11 @@ public function saveAction(): void
/**
* Saves allowed outbound rules for a given time condition
*
* @param $data
* @param array $data
*
* @return bool
*/
private function saveAllowedOutboundRules($data): bool
private function saveAllowedOutboundRules(array $data): bool
{
// Step 1: Delete old links to rules associated with the time condition.
$parameters = [
Expand Down
2 changes: 1 addition & 1 deletion src/AdminCabinet/Views/OutOffWorkTime/modify.volt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<tr class="rule-row" id="{{ rule['id'] }}">
<td class="collapsing">
<div class="ui fitted toggle checkbox" data-did="{{ rule['number'] }}" data-context-id="{{ rule['context-id'] }}">
<input type="checkbox" {% if rule['status']!=='disabled' %} checked {% endif %}
<input type="checkbox" {% if rule['status']!=='disabled' %} checked='on' value='on' {% endif %}
name="rule-{{ rule['id'] }}" data-value="{{ rule['id'] }}">
<label for="rule-{{ rule['id'] }}"></label>
</div>
Expand Down

0 comments on commit ffb7538

Please sign in to comment.