PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / views / editconfigsmsapi / tmpl / default_templates_admin.php
vikappointments / admin / views / editconfigsmsapi / tmpl Last commit date
default.php 3 days ago default_settings.php 3 days ago default_settings_basic.php 3 days ago default_templates.php 3 days ago default_templates_admin.php 3 days ago default_templates_customer.php 3 days ago index.html 3 days ago
default_templates_admin.php
218 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 "onDisplayViewConfigsmsapiTemplatesAdmin". The event method
23 * receives the view instance as argument.
24 *
25 * @since 1.7
26 */
27 $forms = $this->onDisplayView('TemplatesAdmin');
28
29 ?>
30
31 <div class="config-fieldset">
32
33 <div class="config-fieldset-head">
34 <h3><?php echo JText::translate('VAPCONFIGSMSTITLE3'); ?></h3>
35 </div>
36
37 <div class="config-fieldset-body">
38
39 <!-- TOOLBAR -->
40
41 <div style="display: inline-block; width: 100%;">
42 <div class="btn-group pull-left">
43 <button type="button" class="btn smsadmin-put-tag">{total_cost}</button>
44 <button type="button" class="btn smsadmin-put-tag">{checkin}</button>
45 <button type="button" class="btn smsadmin-put-tag">{service}</button>
46 <button type="button" class="btn smsadmin-put-tag">{employee}</button>
47 <button type="button" class="btn smsadmin-put-tag">{company}</button>
48 <button type="button" class="btn smsadmin-put-tag">{created_on}</button>
49
50 <?php
51 /**
52 * Look for any additional fields to be pushed within
53 * the Templates > Administrator > Template > Toolbar APIs fieldset.
54 *
55 * @since 1.7
56 */
57 if (isset($forms['toolbar']))
58 {
59 echo $forms['toolbar'];
60
61 // unset details form to avoid displaying it twice
62 unset($forms['toolbar']);
63 }
64 ?>
65 </div>
66 </div>
67
68 <!-- Define role to detect the supported hook -->
69 <!-- {"rule":"customizer","event":"onDisplayViewConfigsmsapiTemplatesAdmin","key":"toolbar","type":"field"} -->
70
71 <!-- CONTENTS -->
72
73 <div>
74 <?php
75 $sms_tmpl_cust = array($params['smstmpladmin'], $params['smstmpladminmulti']);
76 $placeholders = array(JText::translate('VAPSMSMESSAGEADMIN'), JText::translate('VAPSMSMESSAGEADMINMULTI'));
77
78 for ($i = 0; $i < 2; $i++)
79 {
80 $content = '';
81
82 if (!empty($sms_tmpl_cust[$i]))
83 {
84 $content = $sms_tmpl_cust[$i];
85 }
86 ?>
87 <textarea
88 class="vap-smsadmincont"
89 id="vapsmsadmincont-<?php echo ($i + 1); ?>"
90 placeholder="<?php echo $placeholders[$i]; ?>"
91 style="width: calc(100% - 15px); height: 200px; resize: vertical;<?php echo ($i != 0 ? 'display:none;' : ''); ?>"
92 name="smstmpladmin[<?php echo $i; ?>]"
93 ><?php echo $content; ?></textarea>
94 <?php
95 }
96 ?>
97 </div>
98
99 <!-- FILTERS -->
100
101 <div style="display: inline-block; width: 100%;">
102 <div class="btn-group pull-left">
103 <button type="button" class="btn active vap-smsadmin-type" data-type="0"><?php echo JText::translate('VAPSMSCONTSWITCHSINGLE'); ?></button>
104 <button type="button" class="btn vap-smsadmin-type" data-type="1"><?php echo JText::translate('VAPSMSCONTSWITCHMULTI'); ?></button>
105 </div>
106 </div>
107
108 <!-- Define role to detect the supported hook -->
109 <!-- {"rule":"customizer","event":"onDisplayViewConfigsmsapiTemplatesAdmin","key":"basic","type":"field"} -->
110
111 <?php
112 /**
113 * Look for any additional fields to be pushed within
114 * the Settings > Settings > SMS APIs fieldset.
115 *
116 * @since 1.7
117 */
118 if (isset($forms['basic']))
119 {
120 echo $forms['basic'];
121
122 // unset details form to avoid displaying it twice
123 unset($forms['basic']);
124 }
125 ?>
126
127 </div>
128
129 </div>
130
131 <!-- Define role to detect the supported hook -->
132 <!-- {"rule":"customizer","event":"onDisplayViewConfigsmsapiTemplatesAdmin","type":"fieldset"} -->
133
134 <?php
135 /**
136 * Iterate remaining forms to be displayed as new fieldsets
137 * within the SMS Templates > Admin tab.
138 *
139 * @since 1.7
140 */
141 foreach ($forms as $formTitle => $formHtml)
142 {
143 ?>
144 <div class="config-fieldset">
145
146 <div class="config-fieldset-head">
147 <h3><?php echo JText::translate($formTitle); ?></h3>
148 </div>
149
150 <div class="config-fieldset-body">
151 <?php echo $formHtml; ?>
152 </div>
153
154 </div>
155 <?php
156 }
157 ?>
158
159 <script>
160
161 jQuery(function($) {
162 // returns the active textarea
163 const getActiveArea = () => {
164 var area = null;
165
166 // find active area
167 $('.vap-smsadmincont').each(function() {
168 if ($(this).is(':visible')) {
169 area = $(this);
170 }
171 });
172
173 return area;
174 };
175
176 // put clicked tag within the active textarea
177 $('.smsadmin-put-tag').on('click', function() {
178 const area = getActiveArea();
179
180 if (!area) {
181 return false;
182 }
183
184 let cont = $(this).text().trim();
185 let start = area.get(0).selectionStart;
186 let end = area.get(0).selectionEnd;
187
188 area.val(area.val().substring(0, start) + cont + area.val().substring(end));
189 area.get(0).selectionStart = area.get(0).selectionEnd = start + cont.length;
190 area.focus();
191 });
192
193 // switch content according to selected type
194 $('.vap-smsadmin-type').on('click', function() {
195 if ($(this).hasClass('active')) {
196 return false;
197 }
198
199 $('.vap-smsadmin-type').removeClass('active');
200 $(this).addClass('active');
201
202 const area = getActiveArea();
203
204 if (area == null) {
205 return;
206 }
207
208 var id = area.attr('id').split('-');
209 area.hide();
210
211 const section = parseInt($(this).data('type'));
212
213 $('#' + id[0] + '-' + (section + 1)).show();
214 });
215 });
216
217 </script>
218