calendarweek.php
3 years ago
cart.php
1 month ago
confirmapp.php
2 years ago
empattachser.php
4 years ago
empeditcoupon.php
4 years ago
empeditcustfield.php
4 years ago
empeditlocation.php
4 years ago
empeditpay.php
4 years ago
empeditprofile.php
4 months ago
empeditservice.php
4 years ago
empeditwdays.php
4 years ago
emplocwdays.php
4 years ago
emplogin.php
2 years ago
employeesearch.php
2 years ago
employeeslist.php
4 years ago
empmakerecur.php
1 month ago
empmanres.php
1 month ago
empsettings.php
2 years ago
empsubscr.php
4 years ago
empsubscrorder.php
1 year ago
index.html
6 years ago
modules.php
1 year ago
order.php
4 months ago
packages.php
4 years ago
packagesconfirm.php
4 years ago
packagesorder.php
1 year ago
servicesearch.php
2 years ago
subscriptions.php
4 years ago
subscrpayment.php
1 year ago
userprofile.php
4 months ago
waitinglist.php
4 years ago
servicesearch.php
209 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 | VAPLoader::import('libraries.mvc.controllers.admin'); |
| 15 | |
| 16 | /** |
| 17 | * VikAppointments service search view controller. |
| 18 | * |
| 19 | * @since 1.7 |
| 20 | */ |
| 21 | class VikAppointmentsControllerServicesearch extends VAPControllerAdmin |
| 22 | { |
| 23 | /** |
| 24 | * Task used to send a contact message to the specified service. |
| 25 | * This method expects the following parameters to be sent |
| 26 | * via POST or GET. |
| 27 | * |
| 28 | * @param integer id_service The ID of the service. |
| 29 | * @param string sendername The sender name. |
| 30 | * @param string sendermail The sender e-mail. |
| 31 | * @param string mail_content The contents to send via mail. |
| 32 | * @param string return An optional return URL. |
| 33 | * |
| 34 | * @return boolean |
| 35 | */ |
| 36 | public function quickcontact() |
| 37 | { |
| 38 | $app = JFactory::getApplication(); |
| 39 | $input = $app->input; |
| 40 | $dbo = JFactory::getDbo(); |
| 41 | |
| 42 | $itemid = $input->getInt('Itemid'); |
| 43 | |
| 44 | $id_service = $input->getUint('id_service', 0); |
| 45 | $name = $input->getString('sendername'); |
| 46 | $email = $input->getString('sendermail'); |
| 47 | $content = $input->getString('mail_content'); |
| 48 | |
| 49 | $return_url = $input->getBase64('return'); |
| 50 | |
| 51 | if ($return_url) |
| 52 | { |
| 53 | // use given URL |
| 54 | $return_url = base64_decode($return_url); |
| 55 | } |
| 56 | else |
| 57 | { |
| 58 | // create new URL |
| 59 | $return_url = 'index.php?option=com_vikappointments&view=servicesearch&id_service=' . $id_service; |
| 60 | |
| 61 | if ($itemid) |
| 62 | { |
| 63 | $return_url .= '&Itemid=' . $itemid; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // set return URL as redirect |
| 68 | $this->setRedirect(JRoute::rewrite($return_url, false)); |
| 69 | |
| 70 | // validate session token to avoid direct requests |
| 71 | if (!JSession::checkToken()) |
| 72 | { |
| 73 | // invalid session token |
| 74 | $app->enqueueMessage(JText::translate('JINVALID_TOKEN'), 'error'); |
| 75 | return false; |
| 76 | } |
| 77 | |
| 78 | $vik = VAPApplication::getInstance(); |
| 79 | |
| 80 | // in case of reCAPTCHA, validate it |
| 81 | if ($vik->isGlobalCaptcha() && !$vik->reCaptcha('check')) |
| 82 | { |
| 83 | // invalid captcha |
| 84 | $app->enqueueMessage(JText::translate('PLG_RECAPTCHA_ERROR_EMPTY_SOLUTION'), 'error'); |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | // get view model |
| 89 | $model = $this->getModel(); |
| 90 | |
| 91 | // try to send the e-mail to the administrators |
| 92 | if (!$model->askQuestion($id_service, $name, $email, $content)) |
| 93 | { |
| 94 | // extract error from model |
| 95 | $error = $model->getError($index = null, $string = true); |
| 96 | $app->enqueueMessage($error, 'error'); |
| 97 | return false; |
| 98 | } |
| 99 | |
| 100 | // e-mail sent successfully |
| 101 | $app->enqueueMessage(JText::translate('VAPQUICKCONTACTMAILSENT')); |
| 102 | return true; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Task used to leave a review for the specified service. |
| 107 | * This method expects the following parameters to be sent |
| 108 | * via POST or GET. |
| 109 | * |
| 110 | * @param string title The review title. |
| 111 | * @param string comment The review comment. |
| 112 | * @param integer rating The review rating (1-5). |
| 113 | * @param integer id_service The ID of the service to review. |
| 114 | * |
| 115 | * @return boolean |
| 116 | */ |
| 117 | public function leavereview() |
| 118 | { |
| 119 | $app = JFactory::getApplication(); |
| 120 | $input = $app->input; |
| 121 | |
| 122 | $args = array(); |
| 123 | $args['title'] = $input->getString('title'); |
| 124 | $args['comment'] = $input->getString('comment'); |
| 125 | $args['rating'] = $input->getUint('rating', 0); |
| 126 | $args['id_service'] = $input->getUint('id_service', 0); |
| 127 | |
| 128 | $itemid = $input->getUint('Itemid'); |
| 129 | $this->setRedirect(JRoute::rewrite('index.php?option=com_vikappointments&view=servicesearch&id_service=' . $args['id_service'] . ($itemid ? '&Itemid=' . $itemid : ''), false)); |
| 130 | |
| 131 | // get review model |
| 132 | $model = $this->getModel('review'); |
| 133 | |
| 134 | if (!$model->leave($args)) |
| 135 | { |
| 136 | // get last error fetched |
| 137 | $error = $model->getError($index = null, $string = true); |
| 138 | $app->enqueueMessage($error ? $error : JText::translate('VAPPOSTREVIEWINSERTERR'), 'error'); |
| 139 | return false; |
| 140 | } |
| 141 | |
| 142 | if ($model->getData()->published) |
| 143 | { |
| 144 | // review published |
| 145 | $app->enqueueMessage(JText::translate('VAPPOSTREVIEWCREATEDCONF')); |
| 146 | } |
| 147 | else |
| 148 | { |
| 149 | // review waiting for approval |
| 150 | $app->enqueueMessage(JText::translate('VAPPOSTREVIEWCREATEDPEND')); |
| 151 | } |
| 152 | |
| 153 | return true; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * AJAX task used to load more reviews for the specified service. |
| 158 | * This method expects the following parameters to be sent |
| 159 | * via POST or GET. |
| 160 | * |
| 161 | * @param integer id_service The service ID. |
| 162 | * @param integer start The starting limit. |
| 163 | * |
| 164 | * @return void |
| 165 | */ |
| 166 | public function loadreviews() |
| 167 | { |
| 168 | $app = JFactory::getApplication(); |
| 169 | $input = $app->input; |
| 170 | |
| 171 | $id_ser = $input->getUint('id_service', 0); |
| 172 | $lim0 = $input->getUint('start', 0); |
| 173 | |
| 174 | $reviews = VikAppointments::loadReviews('service', $id_ser, $lim0); |
| 175 | |
| 176 | $result = new stdClass; |
| 177 | $result->size = $reviews->size; |
| 178 | $result->reviews = array(); |
| 179 | |
| 180 | foreach ($reviews->rows as $review) |
| 181 | { |
| 182 | $data = array( |
| 183 | 'review' => $review, |
| 184 | 'datetime_format' => JText::translate('DATE_FORMAT_LC2'), |
| 185 | ); |
| 186 | |
| 187 | /** |
| 188 | * The review block is displayed from the layout below: |
| 189 | * /components/com_vikappointments/layouts/review/default.php |
| 190 | * |
| 191 | * If you need to change something from this layout, just create |
| 192 | * an override of this layout by following the instructions below: |
| 193 | * - open the back-end of your Joomla |
| 194 | * - visit the Extensions > Templates > Templates page |
| 195 | * - edit the active template |
| 196 | * - access the "Create Overrides" tab |
| 197 | * - select Layouts > com_vikappointments > review |
| 198 | * - start editing the default.php file on your template to create your own layout |
| 199 | * |
| 200 | * @since 1.6 |
| 201 | */ |
| 202 | $result->reviews[] = JLayoutHelper::render('review.default', $data); |
| 203 | } |
| 204 | |
| 205 | // send reviews to caller |
| 206 | $this->sendJSON($result); |
| 207 | } |
| 208 | } |
| 209 |