default.php
342 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 | JHtml::fetch('vaphtml.assets.fancybox'); |
| 15 | JHtml::fetch('vaphtml.assets.select2'); |
| 16 | JHtml::fetch('vaphtml.assets.fontawesome'); |
| 17 | JHtml::fetch('vaphtml.assets.intltel', '#billing-phone'); |
| 18 | |
| 19 | $customer = $this->customer; |
| 20 | $itemid = $this->itemid; |
| 21 | |
| 22 | ?> |
| 23 | |
| 24 | <div class="vap-userprofile-toolbar"> |
| 25 | |
| 26 | <div class="vap-userprofile-title"> |
| 27 | <h2><?php echo JText::translate('VAPUSERPROFILETITLE'); ?></h2> |
| 28 | </div> |
| 29 | |
| 30 | <div class="vap-userprofile-controls"> |
| 31 | <button class="vap-btn blue" data-role="userprofile.save"> |
| 32 | <?php echo JText::translate('VAPSAVE'); ?> |
| 33 | </button> |
| 34 | |
| 35 | <button class="vap-btn blue" data-role="userprofile.saveclose"> |
| 36 | <?php echo JText::translate('VAPSAVEANDCLOSE'); ?> |
| 37 | </button> |
| 38 | |
| 39 | <a class="vap-btn blue" href="<?php echo JRoute::rewrite('index.php?option=com_vikappointments&view=allorders' . ($itemid ? '&Itemid=' . $itemid : '')); ?>"> |
| 40 | <?php echo JText::translate('VAPCLOSE'); ?> |
| 41 | </a> |
| 42 | </div> |
| 43 | </div> |
| 44 | |
| 45 | <form name="usersaveprofile" action="<?php echo JRoute::rewrite('index.php?option=com_vikappointments&view=userprofile' . ($itemid ? '&Itemid=' . $itemid : '')); ?>" method="post" enctype="multipart/form-data"> |
| 46 | |
| 47 | <div class="vap-userprofile-container"> |
| 48 | |
| 49 | <div class="vap-userprofile-leftwrapper"> |
| 50 | |
| 51 | <!-- Full Name --> |
| 52 | |
| 53 | <div class="vap-userprofile-field"> |
| 54 | <div class="vap-userprofile-field-label"> |
| 55 | <label for="billing-name"><?php echo JText::translate('VAPUSERPROFILEFIELD1'); ?><sup>*</sup></label> |
| 56 | </div> |
| 57 | <div class="vap-userprofile-field-control"> |
| 58 | <input type="text" name="billing_name" class="required" id="billing-name" value="<?php echo $this->escape(isset($customer->billing_name) ? $customer->billing_name : ''); ?>" /> |
| 59 | </div> |
| 60 | </div> |
| 61 | |
| 62 | <!-- E-Mail --> |
| 63 | |
| 64 | <div class="vap-userprofile-field"> |
| 65 | <div class="vap-userprofile-field-label"> |
| 66 | <label for="billing-mail"><?php echo JText::translate('VAPUSERPROFILEFIELD2'); ?><sup>*</sup></label> |
| 67 | </div> |
| 68 | <div class="vap-userprofile-field-control"> |
| 69 | <input type="text" name="billing_mail" class="required" id="billing-mail" value="<?php echo $this->escape(isset($customer->billing_mail) ? $customer->billing_mail : ''); ?>" /> |
| 70 | </div> |
| 71 | </div> |
| 72 | |
| 73 | <!-- Phone Number --> |
| 74 | |
| 75 | <div class="vap-userprofile-field"> |
| 76 | <div class="vap-userprofile-field-label"> |
| 77 | <label for="billing-phone"><?php echo JText::translate('VAPUSERPROFILEFIELD3'); ?></label> |
| 78 | </div> |
| 79 | <div class="vap-userprofile-field-control"> |
| 80 | <input type="text" name="billing_phone" id="billing-phone" value="<?php echo $this->escape(isset($customer->billing_phone) ? $customer->billing_phone : ''); ?>" /> |
| 81 | </div> |
| 82 | </div> |
| 83 | |
| 84 | <!-- Profile Image --> |
| 85 | |
| 86 | <?php |
| 87 | if ($this->shouldDisplayField('avatar')) |
| 88 | { |
| 89 | ?> |
| 90 | <div class="vap-userprofile-field"> |
| 91 | <div class="vap-userprofile-field-label"> |
| 92 | <label for="user-image"><?php echo JText::translate('VAPUSERPROFILEFIELD13'); ?></label> |
| 93 | </div> |
| 94 | <div class="vap-userprofile-field-control"> |
| 95 | <input type="file" name="image" id="user-image" /> |
| 96 | <?php |
| 97 | if (!empty($customer->image)) |
| 98 | { |
| 99 | ?> |
| 100 | <a href="javascript:void(0)" class="vapmodal" onClick="vapOpenModalImage('<?php echo VAPCUSTOMERS_AVATAR_URI . $customer->image; ?>');"> |
| 101 | <i class="fas fa-image"></i> |
| 102 | </a> |
| 103 | <?php |
| 104 | } |
| 105 | ?> |
| 106 | </div> |
| 107 | </div> |
| 108 | <?php |
| 109 | } |
| 110 | ?> |
| 111 | |
| 112 | </div> |
| 113 | |
| 114 | <div class="vap-userprofile-rightwrapper"> |
| 115 | |
| 116 | <!-- Country --> |
| 117 | |
| 118 | <?php |
| 119 | if ($this->shouldDisplayField('country')) |
| 120 | { |
| 121 | ?> |
| 122 | <div class="vap-userprofile-field"> |
| 123 | <div class="vap-userprofile-field-label"> |
| 124 | <label for="country-code"><?php echo JText::translate('VAPUSERPROFILEFIELD4'); ?></label> |
| 125 | </div> |
| 126 | <div class="vap-userprofile-field-control"> |
| 127 | <select name="country_code" id="country-code"> |
| 128 | <option></option> |
| 129 | <?php |
| 130 | foreach (VAPLocations::getCountries('country_name') as $country) |
| 131 | { |
| 132 | ?> |
| 133 | <option |
| 134 | value="<?php echo $country['country_2_code']; ?>" |
| 135 | <?php echo $country['country_2_code'] == $customer->country_code ? 'selected="selected"' : ''; ?> |
| 136 | ><?php echo $country['country_name']; ?></option> |
| 137 | <?php |
| 138 | } |
| 139 | ?> |
| 140 | </select> |
| 141 | </div> |
| 142 | </div> |
| 143 | <?php |
| 144 | } |
| 145 | ?> |
| 146 | |
| 147 | <!-- State --> |
| 148 | |
| 149 | <?php |
| 150 | if ($this->shouldDisplayField('state')) |
| 151 | { |
| 152 | ?> |
| 153 | <div class="vap-userprofile-field"> |
| 154 | <div class="vap-userprofile-field-label"> |
| 155 | <label for="billing-state"><?php echo JText::translate('VAPUSERPROFILEFIELD5'); ?></label> |
| 156 | </div> |
| 157 | <div class="vap-userprofile-field-control"> |
| 158 | <input type="text" name="billing_state" id="billing-state" value="<?php echo $this->escape(isset($customer->billing_state) ? $customer->billing_state : ''); ?>" /> |
| 159 | </div> |
| 160 | </div> |
| 161 | <?php |
| 162 | } |
| 163 | ?> |
| 164 | |
| 165 | <!-- City --> |
| 166 | |
| 167 | <?php |
| 168 | if ($this->shouldDisplayField('city')) |
| 169 | { |
| 170 | ?> |
| 171 | <div class="vap-userprofile-field"> |
| 172 | <div class="vap-userprofile-field-label"> |
| 173 | <label for="billing-city"><?php echo JText::translate('VAPUSERPROFILEFIELD6'); ?></label> |
| 174 | </div> |
| 175 | <div class="vap-userprofile-field-control"> |
| 176 | <input type="text" name="billing_city" id="billing-city" value="<?php echo $this->escape(isset($customer->billing_city) ? $customer->billing_city : ''); ?>" /> |
| 177 | </div> |
| 178 | </div> |
| 179 | <?php |
| 180 | } |
| 181 | ?> |
| 182 | |
| 183 | <!-- Address --> |
| 184 | |
| 185 | <?php |
| 186 | if ($this->shouldDisplayField('address')) |
| 187 | { |
| 188 | ?> |
| 189 | <div class="vap-userprofile-field"> |
| 190 | <div class="vap-userprofile-field-label"> |
| 191 | <label for="billing-address"><?php echo JText::translate('VAPUSERPROFILEFIELD7'); ?></label> |
| 192 | </div> |
| 193 | <div class="vap-userprofile-field-control"> |
| 194 | <input type="text" name="billing_address" id="billing-address" value="<?php echo $this->escape(isset($customer->billing_address) ? $customer->billing_address : ''); ?>" /> |
| 195 | </div> |
| 196 | </div> |
| 197 | <?php |
| 198 | } |
| 199 | ?> |
| 200 | |
| 201 | <!-- Address 2 --> |
| 202 | |
| 203 | <?php |
| 204 | if ($this->shouldDisplayField('address2')) |
| 205 | { |
| 206 | ?> |
| 207 | <div class="vap-userprofile-field"> |
| 208 | <div class="vap-userprofile-field-label"> |
| 209 | <label for="billing-address-2"><?php echo JText::translate('VAPUSERPROFILEFIELD8'); ?></label> |
| 210 | </div> |
| 211 | <div class="vap-userprofile-field-control"> |
| 212 | <input type="text" name="billing_address_2" id="billing-address-2" value="<?php echo $this->escape(isset($customer->billing_address_2) ? $customer->billing_address_2 : ''); ?>" /> |
| 213 | </div> |
| 214 | </div> |
| 215 | <?php |
| 216 | } |
| 217 | ?> |
| 218 | |
| 219 | <!-- Zip Code --> |
| 220 | |
| 221 | <?php |
| 222 | if ($this->shouldDisplayField('zip')) |
| 223 | { |
| 224 | ?> |
| 225 | <div class="vap-userprofile-field"> |
| 226 | <div class="vap-userprofile-field-label"> |
| 227 | <label for="billing-zip"><?php echo JText::translate('VAPUSERPROFILEFIELD9'); ?></label> |
| 228 | </div> |
| 229 | <div class="vap-userprofile-field-control"> |
| 230 | <input type="text" name="billing_zip" id="billing-zip" value="<?php echo $this->escape(isset($customer->billing_zip) ? $customer->billing_zip : ''); ?>" /> |
| 231 | </div> |
| 232 | </div> |
| 233 | <?php |
| 234 | } |
| 235 | ?> |
| 236 | |
| 237 | <!-- Company --> |
| 238 | |
| 239 | <?php |
| 240 | if ($this->shouldDisplayField('company')) |
| 241 | { |
| 242 | ?> |
| 243 | <div class="vap-userprofile-field"> |
| 244 | <div class="vap-userprofile-field-label"> |
| 245 | <label for="billing-company"><?php echo JText::translate('VAPUSERPROFILEFIELD10'); ?></label> |
| 246 | </div> |
| 247 | <div class="vap-userprofile-field-control"> |
| 248 | <input type="text" name="company" id="billing-company" value="<?php echo $this->escape(isset($customer->company) ? $customer->company : ''); ?>" /> |
| 249 | </div> |
| 250 | </div> |
| 251 | <?php |
| 252 | } |
| 253 | ?> |
| 254 | |
| 255 | <!-- Vat Num --> |
| 256 | |
| 257 | <?php |
| 258 | if ($this->shouldDisplayField('vatnum')) |
| 259 | { |
| 260 | ?> |
| 261 | <div class="vap-userprofile-field"> |
| 262 | <div class="vap-userprofile-field-label"> |
| 263 | <label for="billing-vatnum"><?php echo JText::translate('VAPUSERPROFILEFIELD11'); ?></label> |
| 264 | </div> |
| 265 | <div class="vap-userprofile-field-control"> |
| 266 | <input type="text" name="vatnum" id="billing-vatnum" value="<?php echo $this->escape(isset($customer->vatnum) ? $customer->vatnum : ''); ?>" /> |
| 267 | </div> |
| 268 | </div> |
| 269 | <?php |
| 270 | } |
| 271 | ?> |
| 272 | |
| 273 | <!-- SSN --> |
| 274 | |
| 275 | <?php |
| 276 | if ($this->shouldDisplayField('ssn')) |
| 277 | { |
| 278 | ?> |
| 279 | <div class="vap-userprofile-field"> |
| 280 | <div class="vap-userprofile-field-label"> |
| 281 | <label for="billing-ssn"><?php echo JText::translate('VAPUSERPROFILEFIELD12'); ?></label> |
| 282 | </div> |
| 283 | <div class="vap-userprofile-field-control"> |
| 284 | <input type="text" name="ssn" id="billing-ssn" value="<?php echo $this->escape(isset($customer->ssn) ? $customer->ssn : ''); ?>" style="text-transform: uppercase;" /> |
| 285 | </div> |
| 286 | </div> |
| 287 | <?php |
| 288 | } |
| 289 | ?> |
| 290 | |
| 291 | <!-- PEC --> |
| 292 | |
| 293 | <?php |
| 294 | if ($this->shouldDisplayField('pec')) |
| 295 | { |
| 296 | ?> |
| 297 | <div class="vap-userprofile-field"> |
| 298 | <div class="vap-userprofile-field-label"> |
| 299 | <label for="billing-pec"><?php echo JText::translate('VAPUSERPROFILEFIELD14'); ?></label> |
| 300 | </div> |
| 301 | <div class="vap-userprofile-field-control"> |
| 302 | <input type="text" name="pec" id="billing-pec" value="<?php echo $this->escape(isset($customer->pec) ? $customer->pec : ''); ?>" /> |
| 303 | </div> |
| 304 | </div> |
| 305 | <?php |
| 306 | } |
| 307 | ?> |
| 308 | |
| 309 | </div> |
| 310 | |
| 311 | </div> |
| 312 | |
| 313 | <input type="hidden" name="task" value="" /> |
| 314 | <input type="hidden" name="option" value="com_vikappointments" /> |
| 315 | |
| 316 | <input type="hidden" name="Itemid" value="<?php echo $itemid; ?>" /> |
| 317 | </form> |
| 318 | |
| 319 | <script> |
| 320 | |
| 321 | jQuery(function($) { |
| 322 | const validator = new VikFormValidator('form[name="usersaveprofile"]'); |
| 323 | validator.setLabel($('#billing-name'), $('label[for="billing-name"]')); |
| 324 | validator.setLabel($('#billing-mail'), $('label[for="billing-mail"]')); |
| 325 | |
| 326 | $('#country-code').select2({ |
| 327 | placeholder: '--', |
| 328 | allowClear: true, |
| 329 | width: 300, |
| 330 | }); |
| 331 | |
| 332 | $('button[data-role^="userprofile."]').on('click', function() { |
| 333 | if (validator.validate()) { |
| 334 | document.usersaveprofile.task.value = $(this).data('role'); |
| 335 | // submit form via jQuery in order to properly trigger the related event |
| 336 | $('form[name="usersaveprofile"]').submit(); |
| 337 | } |
| 338 | }); |
| 339 | }); |
| 340 | |
| 341 | </script> |
| 342 |