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 / managecity / tmpl / default.php
vikappointments / admin / views / managecity / tmpl Last commit date
default.php 5 days ago default_city.php 5 days ago default_map.php 5 days ago index.html 5 days ago
default.php
197 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 $city = $this->city;
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 "onDisplayViewCity". The event method receives the
23 * view instance as argument.
24 *
25 * @since 1.7
26 */
27 $forms = $this->onDisplayView();
28
29 if ($this->isTmpl)
30 {
31 // we are in a modal box, add some padding
32 JFactory::getDocument()->addStyleDeclaration('#adminForm { padding: 10px; }');
33 JHtml::fetch('behavior.core');
34 }
35
36 ?>
37
38 <form name="adminForm" action="index.php" method="post" id="adminForm" class="managecity">
39
40 <?php
41 if ($this->isTmpl)
42 {
43 ?>
44 <div class="btn-toolbar" style="display:none;">
45 <div class="btn-group pull-left">
46 <button type="button" class="btn btn-success" name="tmplSaveButton" onclick="vapValidateFieldsAndDisableButton(this);">
47 <i class="icon-apply"></i>&nbsp;<?php echo JText::translate('VAPSAVE'); ?>
48 </button>
49 </div>
50 </div>
51 <?php
52 }
53 ?>
54
55 <?php echo $vik->openCard(); ?>
56
57 <!-- MAIN -->
58
59 <div class="span6">
60
61 <div class="row-fluid">
62 <div class="span12">
63 <?php
64 echo $vik->openFieldset(JText::translate('VAPMANAGECITYTITLE1'));
65 echo $this->loadTemplate('city');
66 ?>
67
68 <!-- Define role to detect the supported hook -->
69 <!-- {"rule":"customizer","event":"onDisplayViewCity","key":"city","type":"field"} -->
70
71 <?php
72 /**
73 * Look for any additional fields to be pushed within
74 * the "City" fieldset (left-side).
75 *
76 * @since 1.7
77 */
78 if (isset($forms['city']))
79 {
80 echo $forms['city'];
81
82 // unset details form to avoid displaying it twice
83 unset($forms['city']);
84 }
85
86 echo $vik->closeFieldset();
87 ?>
88 </div>
89 </div>
90
91 <!-- Define role to detect the supported hook -->
92 <!-- {"rule":"customizer","event":"onDisplayViewCity","type":"fieldset"} -->
93
94 <?php
95 /**
96 * Iterate remaining forms to be displayed within
97 * the sidebar (below "City" fieldset).
98 *
99 * @since 1.7
100 */
101 foreach ($forms as $formName => $formHtml)
102 {
103 $title = JText::translate($formName);
104 ?>
105 <div class="row-fluid">
106 <div class="span12">
107 <?php
108 echo $vik->openFieldset($title);
109 echo $formHtml;
110 echo $vik->closeFieldset();
111 ?>
112 </div>
113 </div>
114 <?php
115 }
116 ?>
117
118 </div>
119
120 <!-- MAP -->
121
122 <div class="span6">
123 <?php
124 echo $vik->openFieldset(JText::translate('VAPMANAGECITYTITLE2'));
125 echo $this->loadTemplate('map');
126 echo $vik->closeFieldset();
127 ?>
128 </div>
129
130 <?php echo $vik->closeCard(); ?>
131
132 <?php
133 if ($this->isTmpl)
134 {
135 ?>
136 <input type="hidden" name="tmpl" value="component" />
137 <?php
138 }
139 ?>
140
141 <?php echo JHtml::fetch('form.token'); ?>
142
143 <input type="hidden" name="id" value="<?php echo $city->id; ?>" />
144 <input type="hidden" name="task" value="" />
145 <input type="hidden" name="option" value="com_vikappointments" />
146 <input type="hidden" name="id_state" value="<?php echo $city->id_state; ?>" />
147 </form>
148
149 <script>
150
151 // validate
152
153 var validator = new VikFormValidator('#adminForm');
154
155 Joomla.submitbutton = function(task) {
156 // check if we clicked a "save" button and the form is not valid
157 if (task.indexOf('save') !== -1 && !validator.validate()) {
158 // abort request
159 return false;
160 }
161
162 // submit form
163 Joomla.submitform(task, document.adminForm);
164 return true;
165 }
166
167 <?php
168 if ($this->isTmpl)
169 {
170 ?>
171 function vapValidateFieldsAndDisableButton(button) {
172 if (jQuery(button).prop('disabled')) {
173 // button already submitted
174 return false;
175 }
176
177 // disable button
178 jQuery(button).prop('disabled', true);
179
180 // submit form
181 if (Joomla.submitbutton('city.save') === false) {
182 // invalid fields, enable button again
183 jQuery(button).prop('disabled', false);
184 }
185 }
186
187 // transfer submit button instance to parent for being clicked
188 window.parent.modalCitySaveButton = document.adminForm.tmplSaveButton;
189
190 // transfer created ID to parent
191 window.parent.modalSavedCityData = <?php echo $this->city->id > 0 ? json_encode($this->city) : 0; ?>;
192 <?php
193 }
194 ?>
195
196 </script>
197