default.php
6 days ago
default_currency.php
6 days ago
default_currency_details.php
6 days ago
default_currency_providers.php
6 days ago
default_email.php
6 days ago
default_email_attachments.php
6 days ago
default_email_mail.php
6 days ago
default_email_notifications.php
6 days ago
default_email_template.php
6 days ago
default_global.php
6 days ago
default_global_calendars.php
6 days ago
default_global_columns.php
6 days ago
default_global_gdpr.php
6 days ago
default_global_sync.php
6 days ago
default_global_system.php
6 days ago
default_global_timezone.php
6 days ago
default_global_zip.php
6 days ago
default_listings.php
6 days ago
default_listings_employees.php
6 days ago
default_listings_services.php
6 days ago
default_shop.php
6 days ago
default_shop_details.php
6 days ago
default_shop_invoice.php
6 days ago
default_shop_packages.php
6 days ago
default_shop_recurrence.php
6 days ago
default_shop_reviews.php
6 days ago
default_shop_subscriptions.php
6 days ago
default_shop_waitlist.php
6 days ago
index.html
6 days ago
default_shop_recurrence.php
285 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | $params = $this->params; |
| 15 | |
| 16 | $vik = VAPApplication::getInstance(); |
| 17 | |
| 18 | /** |
| 19 | * Trigger event to display custom HTML. |
| 20 | * In case it is needed to include any additional fields, |
| 21 | * it is possible to create a plugin and attach it to an event |
| 22 | * called "onDisplayViewConfigShopRecurrence". The event method |
| 23 | * receives the view instance as argument. |
| 24 | * |
| 25 | * @since 1.7 |
| 26 | */ |
| 27 | $forms = $this->onDisplayView('ShopRecurrence'); |
| 28 | |
| 29 | ?> |
| 30 | |
| 31 | <div class="config-fieldset"> |
| 32 | |
| 33 | <div class="config-fieldset-body"> |
| 34 | |
| 35 | <!-- ENABLE RECURRENCE - Radio Button --> |
| 36 | |
| 37 | <?php |
| 38 | $yes = $vik->initRadioElement('', '', $params['enablerecur'] == 1, 'onClick="recurrenceValueChanged(1);"'); |
| 39 | $no = $vik->initRadioElement('', '', $params['enablerecur'] == 0, 'onClick="recurrenceValueChanged(0);"'); |
| 40 | |
| 41 | $help = $vik->createPopover(array( |
| 42 | 'title' => JText::translate('VAPMANAGECONFIGREC1'), |
| 43 | 'content' => JText::translate('VAPMANAGECONFIGREC1_DESC'), |
| 44 | )); |
| 45 | |
| 46 | echo $vik->openControl(JText::translate('VAPMANAGECONFIGREC1') . $help); |
| 47 | echo $vik->radioYesNo('enablerecur', $yes, $no); |
| 48 | echo $vik->closeControl(); |
| 49 | ?> |
| 50 | |
| 51 | <!-- RECURRENCE REPEAT BY - Checkbox List --> |
| 52 | |
| 53 | <?php |
| 54 | $control = array(); |
| 55 | $control['style'] = $params['enablerecur'] == 0 ? 'display:none;' : ''; |
| 56 | |
| 57 | $repeat_by = explode(';', $params['repeatbyrecur']); |
| 58 | |
| 59 | echo $vik->openControl(JText::translate('VAPMANAGECONFIGREC2'), 'vaprecurrtr', $control); |
| 60 | |
| 61 | for ($i = 0; $i < 8; $i++) |
| 62 | { |
| 63 | ?> |
| 64 | <input type="checkbox" name="repeatby<?php echo ($i + 1); ?>" value="1" id="repeatby<?php echo ($i + 1); ?>" <?php echo (!empty($repeat_by[$i]) ? "checked=\"checked\"" : "" ); ?> class="recurrence-by-renderer" /> |
| 65 | |
| 66 | <label for="repeatby<?php echo ($i + 1); ?>" style="display: inline-block; margin-right: 6px;"> |
| 67 | <?php echo JText::translate('VAPMANAGECONFIGRECSINGOPT' . ($i + 1)); ?> |
| 68 | </label> |
| 69 | <?php |
| 70 | } |
| 71 | |
| 72 | echo $vik->closeControl(); |
| 73 | ?> |
| 74 | |
| 75 | <!-- RECURRENCE MIN VALUE - Number --> |
| 76 | |
| 77 | <?php echo $vik->openControl(JText::translate('VAPMANAGECONFIGREC3'), 'vaprecurrtr', $control); ?> |
| 78 | <input type="number" name="minamountrecur" id="minamountrecur" value="<?php echo $params['minamountrecur']; ?>" size="40" min="1" max="999" /> |
| 79 | <?php echo $vik->closeControl(); ?> |
| 80 | |
| 81 | <!-- RECURRENCE MAX VALUE - Number --> |
| 82 | |
| 83 | <?php echo $vik->openControl(JText::translate('VAPMANAGECONFIGREC4'), 'vaprecurrtr', $control); ?> |
| 84 | <input type="number" name="maxamountrecur" id="maxamountrecur" value="<?php echo $params['maxamountrecur']; ?>" size="40" min="1" max="999" /> |
| 85 | <?php echo $vik->closeControl(); ?> |
| 86 | |
| 87 | <!-- RECURRENCE FOR NEXT - Checkbox List --> |
| 88 | |
| 89 | <?php |
| 90 | $for_next = explode(';', $params['fornextrecur']); |
| 91 | |
| 92 | echo $vik->openControl(JText::translate('VAPMANAGECONFIGREC5'), 'vaprecurrtr', $control); |
| 93 | |
| 94 | for ($i = 0; $i < 4; $i++) |
| 95 | { |
| 96 | ?> |
| 97 | <input type="checkbox" name="fornext<?php echo ($i + 1); ?>" value="1" id="fornext<?php echo ($i + 1); ?>" <?php echo (!empty($for_next[$i]) ? "checked=\"checked\"" : "" ); ?> class="recurrence-for-renderer" /> |
| 98 | |
| 99 | <label for="fornext<?php echo ($i + 1); ?>" style="display: inline-block; margin-right: 6px;"> |
| 100 | <?php echo JText::translate('VAPMANAGECONFIGRECMULTOPT' . ($i + 1)); ?> |
| 101 | </label> |
| 102 | <?php |
| 103 | } |
| 104 | |
| 105 | echo $vik->closeControl(); |
| 106 | ?> |
| 107 | |
| 108 | <!-- RECURRENCE DEMO BOX --> |
| 109 | |
| 110 | <?php echo $vik->openControl(JText::translate(''), 'vaprecurrtr', $control); ?> |
| 111 | <div class="inline-fields"> |
| 112 | <span><?php echo JText::translate('VAPMANAGECONFIGREC2'); ?></span> |
| 113 | <select id="vaprecrepeatbysel" class="short"></select> |
| 114 | |
| 115 | <span><?php echo JText::translate('VAPMANAGECONFIGREC5'); ?></span> |
| 116 | <select id="vaprecamountsel" class="short"></select> |
| 117 | |
| 118 | <select id="vaprecfornextsel" class="short"></select> |
| 119 | </div> |
| 120 | |
| 121 | <div style="margin-top: 5px;"><small><em><?php echo JText::translate('VAPMANAGECONFIGREC6'); ?></em></small></div> |
| 122 | |
| 123 | <?php echo $vik->closeControl(); ?> |
| 124 | |
| 125 | <!-- Define role to detect the supported hook --> |
| 126 | <!-- {"rule":"customizer","event":"onDisplayViewConfigShopRecurrence","key":"basic","type":"field"} --> |
| 127 | |
| 128 | <?php |
| 129 | /** |
| 130 | * Look for any additional fields to be pushed within |
| 131 | * the Shop > Recurrence > Details fieldset. |
| 132 | * |
| 133 | * @since 1.7 |
| 134 | */ |
| 135 | if (isset($forms['basic'])) |
| 136 | { |
| 137 | echo $forms['basic']; |
| 138 | |
| 139 | // unset details form to avoid displaying it twice |
| 140 | unset($forms['basic']); |
| 141 | } |
| 142 | ?> |
| 143 | |
| 144 | </div> |
| 145 | |
| 146 | </div> |
| 147 | |
| 148 | <!-- Define role to detect the supported hook --> |
| 149 | <!-- {"rule":"customizer","event":"onDisplayViewConfigShopRecurrence","type":"fieldset"} --> |
| 150 | |
| 151 | <?php |
| 152 | /** |
| 153 | * Iterate remaining forms to be displayed as new fieldsets |
| 154 | * within the Shop > Recurrence tab. |
| 155 | * |
| 156 | * @since 1.7 |
| 157 | */ |
| 158 | foreach ($forms as $formTitle => $formHtml) |
| 159 | { |
| 160 | ?> |
| 161 | <div class="config-fieldset"> |
| 162 | |
| 163 | <div class="config-fieldset-head"> |
| 164 | <h3><?php echo JText::translate($formTitle); ?></h3> |
| 165 | </div> |
| 166 | |
| 167 | <div class="config-fieldset-body"> |
| 168 | <?php echo $formHtml; ?> |
| 169 | </div> |
| 170 | |
| 171 | </div> |
| 172 | <?php |
| 173 | } |
| 174 | |
| 175 | JText::script('VAPMANAGECONFIGRECSINGOPT1'); |
| 176 | JText::script('VAPMANAGECONFIGRECSINGOPT2'); |
| 177 | JText::script('VAPMANAGECONFIGRECSINGOPT3'); |
| 178 | JText::script('VAPMANAGECONFIGRECSINGOPT4'); |
| 179 | JText::script('VAPMANAGECONFIGRECSINGOPT5'); |
| 180 | JText::script('VAPMANAGECONFIGRECSINGOPT6'); |
| 181 | JText::script('VAPMANAGECONFIGRECSINGOPT7'); |
| 182 | JText::script('VAPMANAGECONFIGRECSINGOPT8'); |
| 183 | JText::script('VAPMANAGECONFIGRECMULTOPT1'); |
| 184 | JText::script('VAPMANAGECONFIGRECMULTOPT2'); |
| 185 | JText::script('VAPMANAGECONFIGRECMULTOPT3'); |
| 186 | JText::script('VAPMANAGECONFIGRECMULTOPT4'); |
| 187 | ?> |
| 188 | |
| 189 | <script> |
| 190 | |
| 191 | jQuery(function($) { |
| 192 | $('.recurrence-by-renderer').on('change', () => { |
| 193 | const dropdown = $('#vaprecrepeatbysel'); |
| 194 | |
| 195 | var selected = dropdown.select2('val'); |
| 196 | dropdown.html(''); |
| 197 | |
| 198 | const ordering = [1, 2, 4, 3, 5, 6, 7, 8]; |
| 199 | |
| 200 | for (let i = 0; i < ordering.length; i++) { |
| 201 | if ($('#repeatby' + ordering[i]).is(':checked')) { |
| 202 | let opt = $('<option></option>') |
| 203 | .val(ordering[i]) |
| 204 | .text(Joomla.JText._('VAPMANAGECONFIGRECSINGOPT' + ordering[i])); |
| 205 | |
| 206 | dropdown.append(opt); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | if (dropdown.find('option[value="' + selected + '"]').length == 0) { |
| 211 | selected = dropdown.find('option').first().val(); |
| 212 | } |
| 213 | |
| 214 | // refresh selected value |
| 215 | dropdown.select2('val', selected); |
| 216 | }); |
| 217 | |
| 218 | $('.recurrence-for-renderer').on('change', () => { |
| 219 | const dropdown = $('#vaprecfornextsel'); |
| 220 | |
| 221 | var selected = dropdown.select2('val'); |
| 222 | dropdown.html(''); |
| 223 | |
| 224 | for (var i = 0; i < 4; i++) { |
| 225 | if ($('#fornext' + (i + 1)).is(':checked')) { |
| 226 | let opt = $('<option></option>') |
| 227 | .val(i + 1) |
| 228 | .text(Joomla.JText._('VAPMANAGECONFIGRECMULTOPT' + (i + 1))); |
| 229 | |
| 230 | dropdown.append(opt); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | if (dropdown.find('option[value="' + selected + '"]').length == 0) { |
| 235 | selected = dropdown.find('option').first().val(); |
| 236 | } |
| 237 | |
| 238 | // refresh selected value |
| 239 | dropdown.select2('val', selected); |
| 240 | }); |
| 241 | |
| 242 | $('#minamountrecur, #maxamountrecur').on('change', () => { |
| 243 | const dropdown = $('#vaprecamountsel'); |
| 244 | |
| 245 | var selected = dropdown.select2('val'); |
| 246 | dropdown.html(''); |
| 247 | |
| 248 | var min = parseInt($('#minamountrecur').val()); |
| 249 | var max = parseInt($('#maxamountrecur').val()); |
| 250 | |
| 251 | if (min > max) { |
| 252 | min = max; |
| 253 | |
| 254 | $('#minamountrecur').val(min); |
| 255 | } |
| 256 | |
| 257 | for (var i = min; i <= max; i++) { |
| 258 | dropdown.append('<option value="' + i + '">' + i + '</option>'); |
| 259 | } |
| 260 | |
| 261 | if (dropdown.find('option[value="' + selected + '"]').length == 0) { |
| 262 | selected = dropdown.find('option').first().val(); |
| 263 | } |
| 264 | |
| 265 | // refresh selected value |
| 266 | dropdown.select2('val', selected); |
| 267 | }); |
| 268 | |
| 269 | // set up recurrence preview |
| 270 | $('.recurrence-by-renderer') |
| 271 | .add('.recurrence-for-renderer') |
| 272 | .add('#minamountrecur, #maxamountrecur') |
| 273 | .trigger('change'); |
| 274 | }); |
| 275 | |
| 276 | function recurrenceValueChanged(is) { |
| 277 | if (is) { |
| 278 | jQuery('.vaprecurrtr').show(); |
| 279 | } else { |
| 280 | jQuery('.vaprecurrtr').hide(); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | </script> |
| 285 |