default.php
5 days ago
default_settings.php
5 days ago
default_settings_basic.php
5 days ago
default_templates.php
5 days ago
default_templates_admin.php
5 days ago
default_templates_customer.php
5 days ago
index.html
5 days ago
default_templates_customer.php
275 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 | $languages = VikAppointments::getKnownLanguages(); |
| 19 | |
| 20 | /** |
| 21 | * Trigger event to display custom HTML. |
| 22 | * In case it is needed to include any additional fields, |
| 23 | * it is possible to create a plugin and attach it to an event |
| 24 | * called "onDisplayViewConfigsmsapiTemplatesCustomer". The event method |
| 25 | * receives the view instance as argument. |
| 26 | * |
| 27 | * @since 1.7 |
| 28 | */ |
| 29 | $forms = $this->onDisplayView('TemplatesCustomer'); |
| 30 | |
| 31 | ?> |
| 32 | |
| 33 | <div class="config-fieldset"> |
| 34 | |
| 35 | <div class="config-fieldset-head"> |
| 36 | <h3><?php echo JText::translate('VAPCONFIGSMSTITLE2'); ?></h3> |
| 37 | </div> |
| 38 | |
| 39 | <div class="config-fieldset-body"> |
| 40 | |
| 41 | <!-- TOOLBAR --> |
| 42 | |
| 43 | <div style="display: inline-block; width: 100%;"> |
| 44 | <div class="btn-group pull-left"> |
| 45 | <button type="button" class="btn sms-put-tag">{total_cost}</button> |
| 46 | <button type="button" class="btn sms-put-tag">{checkin}</button> |
| 47 | <button type="button" class="btn sms-put-tag">{service}</button> |
| 48 | <button type="button" class="btn sms-put-tag">{employee}</button> |
| 49 | <button type="button" class="btn sms-put-tag">{company}</button> |
| 50 | <button type="button" class="btn sms-put-tag">{created_on}</button> |
| 51 | |
| 52 | <?php |
| 53 | /** |
| 54 | * Look for any additional fields to be pushed within |
| 55 | * the Templates > Customer > Template > Toolbar APIs fieldset. |
| 56 | * |
| 57 | * @since 1.7 |
| 58 | */ |
| 59 | if (isset($forms['toolbar'])) |
| 60 | { |
| 61 | echo $forms['toolbar']; |
| 62 | |
| 63 | // unset details form to avoid displaying it twice |
| 64 | unset($forms['toolbar']); |
| 65 | } |
| 66 | ?> |
| 67 | </div> |
| 68 | </div> |
| 69 | |
| 70 | <!-- Define role to detect the supported hook --> |
| 71 | <!-- {"rule":"customizer","event":"onDisplayViewConfigsmsapiTemplatesCustomer","key":"toolbar","type":"field"} --> |
| 72 | |
| 73 | <!-- CONTENTS --> |
| 74 | |
| 75 | <div> |
| 76 | <?php |
| 77 | $sms_tmpl_cust = array(json_decode($params['smstmplcust'], true), json_decode($params['smstmplcustmulti'], true)); |
| 78 | $placeholders = array(array(), array()); |
| 79 | |
| 80 | // keep current language |
| 81 | $default = JFactory::getLanguage()->getTag(); |
| 82 | |
| 83 | foreach ($languages as $k => $lang) |
| 84 | { |
| 85 | $translator = JFactory::getLanguage(); |
| 86 | $translator->load('com_vikappointments', JPATH_ADMINISTRATOR, $lang, true); |
| 87 | |
| 88 | $placeholders[0][$lang] = $translator->_($appSmsTemplate = 'VAPSMSMESSAGECUSTOMER'); |
| 89 | $placeholders[1][$lang] = $translator->_($appMultiSmsTemplate = 'VAPSMSMESSAGECUSTOMERMULTI'); |
| 90 | |
| 91 | for ($i = 0; $i < 2; $i++) |
| 92 | { |
| 93 | $content = ''; |
| 94 | |
| 95 | if (!empty($sms_tmpl_cust[$i][$lang])) |
| 96 | { |
| 97 | $content = $sms_tmpl_cust[$i][$lang]; |
| 98 | } |
| 99 | |
| 100 | $_langtag = preg_replace("/[\-_]+/", '', $lang); |
| 101 | ?> |
| 102 | <textarea |
| 103 | class="vap-smscont" |
| 104 | id="vapsmscont<?php echo $_langtag; ?>-<?php echo ($i + 1); ?>" |
| 105 | placeholder="<?php echo $placeholders[$i][$lang]; ?>" |
| 106 | style="width: calc(100% - 15px); height: 200px; resize: vertical;<?php echo ($k != 0 || $i == 1 ? 'display:none;' : ''); ?>" |
| 107 | name="smstmplcust[<?php echo $i; ?>][]" |
| 108 | ><?php echo $content; ?></textarea> |
| 109 | <?php |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | // restore default language |
| 114 | if (end($languages) != $default) |
| 115 | { |
| 116 | JFactory::getLanguage()->load('com_vikappointments', JPATH_ADMINISTRATOR, $default, true); |
| 117 | } |
| 118 | ?> |
| 119 | </div> |
| 120 | |
| 121 | <!-- LANGUAGES --> |
| 122 | |
| 123 | <div style="display: inline-block; width: 100%;"> |
| 124 | <div class="btn-group pull-left"> |
| 125 | <button type="button" class="btn active vap-sms-type" data-type="0"><?php echo JText::translate('VAPSMSCONTSWITCHSINGLE'); ?></button> |
| 126 | <button type="button" class="btn vap-sms-type" data-type="1"><?php echo JText::translate('VAPSMSCONTSWITCHMULTI'); ?></button> |
| 127 | </div> |
| 128 | |
| 129 | <div class="btn-group pull-right"> |
| 130 | <?php |
| 131 | foreach ($languages as $k => $lang) |
| 132 | { |
| 133 | $_langtag = preg_replace("/[\-_]+/", '', $lang); |
| 134 | ?> |
| 135 | <button type="button" class="vap-sms-langtag btn <?php echo ($k == 0 ? 'active' : ''); ?>" data-lang="<?php echo $_langtag; ?>"> |
| 136 | <?php echo JHtml::fetch('vaphtml.site.flag', $lang); ?> |
| 137 | </button> |
| 138 | <?php |
| 139 | } |
| 140 | ?> |
| 141 | </div> |
| 142 | </div> |
| 143 | |
| 144 | <!-- Define role to detect the supported hook --> |
| 145 | <!-- {"rule":"customizer","event":"onDisplayViewConfigsmsapiTemplatesCustomer","key":"basic","type":"field"} --> |
| 146 | |
| 147 | <?php |
| 148 | /** |
| 149 | * Look for any additional fields to be pushed within |
| 150 | * the Settings > Settings > SMS APIs fieldset. |
| 151 | * |
| 152 | * @since 1.7 |
| 153 | */ |
| 154 | if (isset($forms['basic'])) |
| 155 | { |
| 156 | echo $forms['basic']; |
| 157 | |
| 158 | // unset details form to avoid displaying it twice |
| 159 | unset($forms['basic']); |
| 160 | } |
| 161 | ?> |
| 162 | |
| 163 | </div> |
| 164 | |
| 165 | </div> |
| 166 | |
| 167 | <!-- Define role to detect the supported hook --> |
| 168 | <!-- {"rule":"customizer","event":"onDisplayViewConfigsmsapiTemplatesCustomer","type":"fieldset"} --> |
| 169 | |
| 170 | <?php |
| 171 | /** |
| 172 | * Iterate remaining forms to be displayed as new fieldsets |
| 173 | * within the SMS Templates > Customer tab. |
| 174 | * |
| 175 | * @since 1.7 |
| 176 | */ |
| 177 | foreach ($forms as $formTitle => $formHtml) |
| 178 | { |
| 179 | ?> |
| 180 | <div class="config-fieldset"> |
| 181 | |
| 182 | <div class="config-fieldset-head"> |
| 183 | <h3><?php echo JText::translate($formTitle); ?></h3> |
| 184 | </div> |
| 185 | |
| 186 | <div class="config-fieldset-body"> |
| 187 | <?php echo $formHtml; ?> |
| 188 | </div> |
| 189 | |
| 190 | </div> |
| 191 | <?php |
| 192 | } |
| 193 | ?> |
| 194 | |
| 195 | <script> |
| 196 | |
| 197 | jQuery(function($) { |
| 198 | // returns the active textarea |
| 199 | const getActiveArea = () => { |
| 200 | var area = null; |
| 201 | |
| 202 | // find active area |
| 203 | $('.vap-smscont').each(function() { |
| 204 | if ($(this).is(':visible')) { |
| 205 | area = $(this); |
| 206 | } |
| 207 | }); |
| 208 | |
| 209 | return area; |
| 210 | }; |
| 211 | |
| 212 | // put clicked tag within the active textarea |
| 213 | $('.sms-put-tag').on('click', function() { |
| 214 | const area = getActiveArea(); |
| 215 | |
| 216 | if (!area) { |
| 217 | return false; |
| 218 | } |
| 219 | |
| 220 | let cont = $(this).text().trim(); |
| 221 | let start = area.get(0).selectionStart; |
| 222 | let end = area.get(0).selectionEnd; |
| 223 | |
| 224 | area.val(area.val().substring(0, start) + cont + area.val().substring(end)); |
| 225 | area.get(0).selectionStart = area.get(0).selectionEnd = start + cont.length; |
| 226 | area.focus(); |
| 227 | }); |
| 228 | |
| 229 | // switch content according to selected type |
| 230 | $('.vap-sms-type').on('click', function() { |
| 231 | if ($(this).hasClass('active')) { |
| 232 | return false; |
| 233 | } |
| 234 | |
| 235 | $('.vap-sms-type').removeClass('active'); |
| 236 | $(this).addClass('active'); |
| 237 | |
| 238 | const area = getActiveArea(); |
| 239 | |
| 240 | if (area == null) { |
| 241 | return; |
| 242 | } |
| 243 | |
| 244 | var id = area.attr('id').split('-'); |
| 245 | area.hide(); |
| 246 | |
| 247 | const section = parseInt($(this).data('type')); |
| 248 | |
| 249 | $('#' + id[0] + '-' + (section + 1)).show(); |
| 250 | }); |
| 251 | |
| 252 | // switch content according to the selected language |
| 253 | $('.vap-sms-langtag').on('click', function() { |
| 254 | if ($(this).hasClass('active')) { |
| 255 | return false; |
| 256 | } |
| 257 | |
| 258 | $('.vap-sms-langtag').removeClass('active'); |
| 259 | $(this).addClass('active'); |
| 260 | |
| 261 | const area = getActiveArea(); |
| 262 | |
| 263 | if (area == null) { |
| 264 | return; |
| 265 | } |
| 266 | |
| 267 | const langtag = $(this).data('lang'); |
| 268 | |
| 269 | $('.vap-smscont').hide(); |
| 270 | $('#vapsmscont' + langtag + '-' + area.attr('id').split('-')[1]).show(); |
| 271 | }); |
| 272 | }); |
| 273 | |
| 274 | </script> |
| 275 |