/
booking_type_step.php
112 lines (98 loc) · 4.39 KB
/
booking_type_step.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
* Local variables.
*
* @var array $available_services
*/
?>
<div id="wizard-frame-1" class="wizard-frame" style="visibility: hidden;">
<div class="frame-container">
<h2 class="frame-title"><?= lang('service_and_provider') ?></h2>
<div class="row frame-content">
<div class="col">
<div class="mb-3">
<label for="select-service">
<strong><?= lang('service') ?></strong>
</label>
<select id="select-service" class="form-control">
<?php
// Group services by category, only if there is at least one service with a parent category.
$has_category = FALSE;
foreach ($available_services as $service)
{
if ( ! empty($service['category_id']))
{
$has_category = TRUE;
break;
}
}
if ($has_category)
{
$grouped_services = [];
foreach ($available_services as $service)
{
if ( ! empty($service['category_id']))
{
if ( ! isset($grouped_services[$service['category_name']]))
{
$grouped_services[$service['category_name']] = [];
}
$grouped_services[$service['category_name']][] = $service;
}
}
// We need the uncategorized services at the end of the list, so we will use another
// iteration only for the uncategorized services.
$grouped_services['uncategorized'] = [];
foreach ($available_services as $service)
{
if ($service['category_id'] == NULL)
{
$grouped_services['uncategorized'][] = $service;
}
}
foreach ($grouped_services as $key => $group)
{
$group_label = $key !== 'uncategorized'
? $group[0]['category_name']
: 'Uncategorized';
if (count($group) > 0)
{
echo '<optgroup label="' . e($group_label) . '">';
foreach ($group as $service)
{
echo '<option value="' . $service['id'] . '">'
. e($service['name']) . '</option>';
}
echo '</optgroup>';
}
}
}
else
{
foreach ($available_services as $service)
{
echo '<option value="' . $service['id'] . '">' . e($service['name']) . '</option>';
}
}
?>
</select>
</div>
<div class="mb-3">
<label for="select-provider">
<strong><?= lang('provider') ?></strong>
</label>
<select id="select-provider" class="form-control"></select>
</div>
<div id="service-description"></div>
</div>
</div>
</div>
<div class="command-buttons">
<span> </span>
<button type="button" id="button-next-1" class="btn button-next btn-dark"
data-step_index="1">
<?= lang('next') ?>
<i class="fas fa-chevron-right ms-2"></i>
</button>
</div>
</div>