| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage mod_vikbooking_chat |
| 5 |
* @author E4J s.r.l |
| 6 |
* @copyright Copyright (C) 2026 E4J s.r.l. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
// no direct access |
| 12 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 13 |
|
| 14 |
?> |
| 15 |
|
| 16 |
<div class="vbo-chat-session-widget" id="vbo-chat-widget<?php echo (int) $moduleId; ?>"> |
| 17 |
|
| 18 |
<div class="vbo-chat-widget-container"> |
| 19 |
|
| 20 |
<div class="vbo-chat-widget-head"> |
| 21 |
<span> |
| 22 |
<?php echo $params->get('title') ?: JText::translate('MOD_VIKBOOKING_CHAT_TITLE'); ?> |
| 23 |
</span> |
| 24 |
|
| 25 |
<a href="javascript:void(0)" data-role="widget.chat.dismiss" aria-label="Hide chat"> |
| 26 |
<i class="<?php echo VikBookingIcons::i('chevron-down'); ?>" aria-hidden="true"></i> |
| 27 |
</a> |
| 28 |
</div> |
| 29 |
|
| 30 |
<div class="vbo-chat-widget-body"> |
| 31 |
|
| 32 |
<?php |
| 33 |
// display session chat through layout |
| 34 |
echo JLayoutHelper::render( |
| 35 |
'chat.session', |
| 36 |
[ |
| 37 |
'session' => $session, |
| 38 |
'suffix' => 'widget', |
| 39 |
'options' => [ |
| 40 |
'autoread' => false, |
| 41 |
], |
| 42 |
], |
| 43 |
null, |
| 44 |
[ |
| 45 |
'component' => 'com_vikbooking', |
| 46 |
'client' => 'site', |
| 47 |
] |
| 48 |
); |
| 49 |
|
| 50 |
if (!$session) { |
| 51 |
// display form to start a session |
| 52 |
?> |
| 53 |
<div class="vbo-chat-session-start-form"> |
| 54 |
|
| 55 |
<div class="vbo-chat-session-form-intro"><?php echo JText::translate('MOD_VIKBOOKING_CHAT_SESSION_INTRO'); ?></div> |
| 56 |
|
| 57 |
<div class="vbo-chat-session-form-control"> |
| 58 |
<label for="vbo-chat-session-user-name<?php echo (int) $moduleId; ?>"><?php echo JText::translate('MOD_VIKBOOKING_CHAT_SESSION_NAME_LABEL'); ?></label> |
| 59 |
<input type="text" id="vbo-chat-session-user-name<?php echo (int) $moduleId; ?>" name="name" required pattern=".{2,}" placeholder=" " /> |
| 60 |
<div class="vbo-chat-session-form-help"><?php echo JText::translate('MOD_VIKBOOKING_CHAT_SESSION_NAME_DESC'); ?></div> |
| 61 |
</div> |
| 62 |
|
| 63 |
<div class="vbo-chat-session-form-control"> |
| 64 |
<label for="vbo-chat-session-user-email<?php echo (int) $moduleId; ?>"><?php echo JText::translate('MOD_VIKBOOKING_CHAT_SESSION_MAIL_LABEL'); ?></label> |
| 65 |
<input type="email" id="vbo-chat-session-user-email<?php echo (int) $moduleId; ?>" name="email" /> |
| 66 |
<div class="vbo-chat-session-form-help"><?php echo JText::translate('MOD_VIKBOOKING_CHAT_SESSION_MAIL_DESC'); ?></div> |
| 67 |
</div> |
| 68 |
|
| 69 |
<div class="vbo-chat-session-form-control"> |
| 70 |
<button type="button" class="btn vbo-pref-color-btn start-chat-session"> |
| 71 |
<?php echo JText::translate('MOD_VIKBOOKING_CHAT_SESSION_START_BTN'); ?> |
| 72 |
</button> |
| 73 |
</div> |
| 74 |
|
| 75 |
</div> |
| 76 |
<?php |
| 77 |
} |
| 78 |
?> |
| 79 |
|
| 80 |
<div class="vbo-chat-session-placeholder" style="display: none;"> |
| 81 |
|
| 82 |
<div class="vbo-chat-session-placeholder-inner"> |
| 83 |
|
| 84 |
<div class="vbo-chat-placeholder-greetings"> |
| 85 |
<div class="greetings-title"> |
| 86 |
<?php echo $params->get('greetings_title') ?: JText::translate('MOD_VIKBOOKING_CHAT_GREETINGS_TITLE'); ?> |
| 87 |
</div> |
| 88 |
|
| 89 |
<div class="greetings-subtitle"> |
| 90 |
<?php echo $params->get('greetings_subtitle') ?: JText::translate('MOD_VIKBOOKING_CHAT_GREETINGS_SUBTITLE'); ?> |
| 91 |
</div> |
| 92 |
</div> |
| 93 |
|
| 94 |
<?php if ($faqs): ?> |
| 95 |
<div class="vbo-chat-placeholder-faqs"> |
| 96 |
<ul> |
| 97 |
<?php foreach ($faqs as $faq): ?> |
| 98 |
<li> |
| 99 |
<a href="javascript:void(0)" data-question="<?php echo htmlspecialchars($faq->question); ?>"> |
| 100 |
<i class="<?php echo VikBookingIcons::i('life-ring'); ?>" aria-hidden="true"></i> |
| 101 |
<?php echo $faq->summary; ?> |
| 102 |
</a> |
| 103 |
</li> |
| 104 |
<?php endforeach; ?> |
| 105 |
</ul> |
| 106 |
</div> |
| 107 |
<?php endif; ?> |
| 108 |
|
| 109 |
</div> |
| 110 |
|
| 111 |
</div> |
| 112 |
|
| 113 |
</div> |
| 114 |
|
| 115 |
</div> |
| 116 |
|
| 117 |
<div class="vbo-chat-widget-toggle"> |
| 118 |
<a href="javascript:void(0)" data-role="widget.chat.show" data-unread="0" aria-label="Unread messages"> |
| 119 |
<i class="<?php echo VikBookingIcons::i('comment'); ?>" aria-hidden="true"></i> |
| 120 |
</a> |
| 121 |
</div> |
| 122 |
|
| 123 |
</div> |
| 124 |
|
| 125 |
<script> |
| 126 |
(function(w) { |
| 127 |
'use strict'; |
| 128 |
|
| 129 |
if (typeof VBO_CHAT_WIDGET_CONFIG === 'undefined') { |
| 130 |
w['VBO_CHAT_WIDGET_CONFIG'] = { |
| 131 |
/** |
| 132 |
* The selector to access the chat widget element. |
| 133 |
* |
| 134 |
* @var string |
| 135 |
*/ |
| 136 |
selector: '#vbo-chat-widget<?php echo (int) $moduleId; ?>', |
| 137 |
/** |
| 138 |
* The AJAX end-point used to start a new session. |
| 139 |
* |
| 140 |
* @var string |
| 141 |
*/ |
| 142 |
startSessionUrl: '<?php echo VBOFactory::getPlatform()->getUri()->ajax('index.php?option=com_vikbooking&task=chat.start_session'); ?>', |
| 143 |
|
| 144 |
/** |
| 145 |
* The AJAX end-point used to render a chat. |
| 146 |
* |
| 147 |
* @var string |
| 148 |
*/ |
| 149 |
renderChatUrl: '<?php echo VBOFactory::getPlatform()->getUri()->ajax('index.php?option=com_vikbooking&task=chat.render_chat'); ?>', |
| 150 |
}; |
| 151 |
} |
| 152 |
})(window); |
| 153 |
</script> |