calendar
3 days ago
login
3 days ago
payment
3 days ago
alert.php
3 days ago
carttotals.php
3 days ago
checkout.php
3 days ago
couponform.php
3 days ago
index.html
3 days ago
login.php
3 days ago
options.php
3 days ago
paymentmethods.php
3 days ago
quickcontact.php
3 days ago
reviews.php
3 days ago
timeline.php
3 days ago
waitlist.php
3 days ago
quickcontact.php
212 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 | $title = isset($displayData['title']) ? $displayData['title'] : ''; |
| 15 | $id_service = isset($displayData['id_service']) ? $displayData['id_service'] : 0; |
| 16 | $id_employee = isset($displayData['id_employee']) ? $displayData['id_employee'] : 0; |
| 17 | $returnUri = isset($displayData['return']) ? $displayData['return'] : ''; |
| 18 | $gdpr = isset($displayData['gdpr']) ? $displayData['gdpr'] : null; |
| 19 | $itemid = isset($displayData['itemid']) ? $displayData['itemid'] : null; |
| 20 | |
| 21 | if ($id_service) |
| 22 | { |
| 23 | // reviews for a service |
| 24 | $col_name = 'id_service'; |
| 25 | $col_value = $id_service; |
| 26 | $contact_task = 'servicesearch.quickcontact'; |
| 27 | } |
| 28 | else |
| 29 | { |
| 30 | // reviews for an employee |
| 31 | $col_name = 'id_employee'; |
| 32 | $col_value = $id_employee; |
| 33 | $contact_task = 'employeesearch.quickcontact'; |
| 34 | } |
| 35 | |
| 36 | if (is_null($gdpr)) |
| 37 | { |
| 38 | // gdpr setting not provided, get it from the global configuration |
| 39 | $gdpr = VAPFactory::getConfig()->getBool('gdpr', false); |
| 40 | } |
| 41 | |
| 42 | if (is_null($itemid)) |
| 43 | { |
| 44 | // item id not provided, get the current one (if set) |
| 45 | $itemid = JFactory::getApplication()->input->getInt('Itemid'); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Get current user to auto-populate the contact fields. |
| 50 | * |
| 51 | * @since 1.7 |
| 52 | */ |
| 53 | $user = JFactory::getUser(); |
| 54 | |
| 55 | $vik = VAPApplication::getInstance(); |
| 56 | |
| 57 | ?> |
| 58 | |
| 59 | <form action="<?php echo JRoute::rewrite('index.php?option=com_vikappointments&task=' . $contact_task . ($itemid ? '&Itemid=' . $itemid : '')); ?>" method="post" name="quickcontactform"> |
| 60 | |
| 61 | <div class="vapqcdiv <?php echo $vik->getThemeClass('background'); ?>" style="display: none;"> |
| 62 | |
| 63 | <h2 class="vapqcnominative"><?php echo $title; ?></h2> |
| 64 | |
| 65 | <div class="vapqcsendname"> |
| 66 | <label for="qc-send-name"><?php echo JText::translate('VAPEMPSENDERNAMELABEL'); ?></label> |
| 67 | <input id="qc-send-name" type="text" name="sendername" value="<?php echo $this->escape($user->name); ?>" class="required" size="32" /> |
| 68 | </div> |
| 69 | |
| 70 | <div class="vapqcsendmail"> |
| 71 | <span class="vapqcmailsp"> |
| 72 | <label for="qc-send-mail"><?php echo JText::translate('VAPEMPSENDERMAILLABEL'); ?></label> |
| 73 | <input id="qc-send-mail" type="email" name="sendermail" value="<?php echo $this->escape($user->email); ?>" class="required" size="32" /> |
| 74 | </span> |
| 75 | </div> |
| 76 | |
| 77 | <div class="vapqcmailcont"> |
| 78 | <label for="qc-send-text" style="vertical-align: top;"><?php echo JText::translate('VAPEMPMAILCONTENTLABEL'); ?></label> |
| 79 | <textarea name="mail_content" id="qc-send-text" class="required"></textarea> |
| 80 | </div> |
| 81 | |
| 82 | <?php |
| 83 | // check if global captcha is configured |
| 84 | if ($captcha = $vik->getGlobalCaptcha()) |
| 85 | { |
| 86 | // display Captcha plugin |
| 87 | echo $vik->captcha('display', ['captcha' => $captcha, 'name' => 'contact']); |
| 88 | } |
| 89 | ?> |
| 90 | |
| 91 | <span class="vapqcbuttonsp"> |
| 92 | <button type="submit" class="vap-btn blue" onClick="return vapValidateBeforeSendMail();"> |
| 93 | <?php echo JText::translate('VAPEMPSENDMAILOK'); ?> |
| 94 | </button> |
| 95 | |
| 96 | <button type="button" class="vap-btn" onClick="vapCancelMail();"> |
| 97 | <?php echo JText::translate('VAPEMPSENDMAILCANCEL'); ?> |
| 98 | </button> |
| 99 | </span> |
| 100 | |
| 101 | <?php |
| 102 | /** |
| 103 | * Display a footer message for GDPR that |
| 104 | * inform the users that the specified data |
| 105 | * are not stored within the database of the website. |
| 106 | * |
| 107 | * @since 1.6 |
| 108 | */ |
| 109 | |
| 110 | if ($gdpr) |
| 111 | { |
| 112 | ?> |
| 113 | <p class="gdpr-footer-disclaimer"> |
| 114 | <i class="fas fa-info-circle"><span><?php echo JText::translate('GDPR_DISCLAIMER'); ?></span></i> |
| 115 | </p> |
| 116 | <?php |
| 117 | } |
| 118 | ?> |
| 119 | |
| 120 | </div> |
| 121 | |
| 122 | <?php echo JHtml::fetch('form.token'); ?> |
| 123 | <input type="hidden" name="<?php echo $col_name; ?>" value="<?php echo $col_value; ?>" /> |
| 124 | <input type="hidden" name="option" value="com_vikappointments" /> |
| 125 | <input type="hidden" name="task" value="<?php echo $contact_task; ?>" /> |
| 126 | <input type="hidden" name="return" value="<?php echo base64_encode($returnUri); ?>" /> |
| 127 | </form> |
| 128 | |
| 129 | <script> |
| 130 | |
| 131 | var qcValidator; |
| 132 | var cancelElement = null; |
| 133 | |
| 134 | jQuery(function($) { |
| 135 | // instantiate validator on ready |
| 136 | qcValidator = new VikFormValidator('form[name="quickcontactform"]', 'vaprequiredfield'); |
| 137 | |
| 138 | <?php |
| 139 | /** |
| 140 | * Add callback to validate whether the ReCAPTCHA quiz |
| 141 | * was completed or not. |
| 142 | * |
| 143 | * @since 1.7 |
| 144 | */ |
| 145 | if ($captcha) |
| 146 | { |
| 147 | ?> |
| 148 | qcValidator.addCallback(() => { |
| 149 | // get recaptcha elements |
| 150 | let captcha = $(qcValidator.form).find('.g-recaptcha').first(); |
| 151 | let iframe = captcha.find('iframe').first(); |
| 152 | |
| 153 | // get widget ID |
| 154 | let widget_id = captcha.data('recaptcha-widget-id'); |
| 155 | |
| 156 | // check if recaptcha instance exists |
| 157 | // and whether the recaptcha was completed |
| 158 | if (typeof grecaptcha !== 'undefined' |
| 159 | && widget_id !== undefined |
| 160 | && !grecaptcha.getResponse(widget_id)) { |
| 161 | // captcha not completed |
| 162 | iframe.addClass(qcValidator.clazz); |
| 163 | return false; |
| 164 | } |
| 165 | |
| 166 | // captcha completed |
| 167 | iframe.removeClass(qcValidator.clazz); |
| 168 | return true; |
| 169 | }); |
| 170 | <?php |
| 171 | } |
| 172 | ?> |
| 173 | }); |
| 174 | |
| 175 | function vapValidateBeforeSendMail() { |
| 176 | return qcValidator.validate(); |
| 177 | } |
| 178 | |
| 179 | function vapCancelMail() { |
| 180 | jQuery('.vapqcdiv').fadeOut(); |
| 181 | |
| 182 | if (cancelElement) { |
| 183 | jQuery('html,body').animate({ |
| 184 | scrollTop: (jQuery(cancelElement).offset().top - 20), |
| 185 | }, { |
| 186 | duration: 'normal', |
| 187 | }); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | // used when clicking "QUICK CONTACT" from the list |
| 192 | function vapGoToMail(elem, id, name) { |
| 193 | cancelElement = elem; |
| 194 | |
| 195 | if (id) { |
| 196 | jQuery('input[name="<?php echo $col_name; ?>"]').val(id); |
| 197 | } |
| 198 | |
| 199 | if (name) { |
| 200 | jQuery('.vapqcnominative').text(name); |
| 201 | } |
| 202 | |
| 203 | jQuery('.vapqcdiv').fadeIn(); |
| 204 | jQuery('html,body').animate({ |
| 205 | scrollTop: (jQuery('.vapqcdiv').offset().top - 20), |
| 206 | }, { |
| 207 | duration: 'normal', |
| 208 | }); |
| 209 | } |
| 210 | |
| 211 | </script> |
| 212 |