| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /bpkd/includes/ |
Upload File : |
<?php
/**
* File: includes/whatsapp-float.php
* WhatsApp Floating Button dengan cek jam aktif
*/
// Ambil pengaturan WhatsApp dari database
global $conn, $settings;
$wa_active = $settings['whatsapp_active'] ?? '0';
$wa_number = $settings['whatsapp_number'] ?? '';
$wa_message = urlencode($settings['whatsapp_message'] ?? 'Halo, saya ingin bertanya tentang layanan di website ini');
$wa_text = $settings['whatsapp_text'] ?? 'Chat via WhatsApp';
$wa_start_time = $settings['whatsapp_start_time'] ?? '08:00';
$wa_end_time = $settings['whatsapp_end_time'] ?? '20:00';
// Tambahkan di whatsapp-float.php
$wa_outside_message = urlencode($settings['whatsapp_outside_message'] ?? 'Kami akan merespon di jam kerja (08:00-20:00)');
// Cek apakah tombol aktif
$show_button = false;
if ($wa_active == '1' && !empty($wa_number)) {
// Ambil waktu sekarang
$current_time = date('H:i');
// Cek apakah waktu sekarang dalam range jam aktif
if ($current_time >= $wa_start_time && $current_time <= $wa_end_time) {
$show_button = true;
}
}
?>
<?php if ($show_button): ?>
<style>
/* WhatsApp Floating Button */
.whatsapp-float {
position: fixed;
bottom: 30px;
right: 30px;
z-index: 999;
transition: all 0.3s ease;
}
.whatsapp-float .whatsapp-link {
display: flex;
align-items: center;
justify-content: center;
width: 60px;
height: 60px;
background: #25d366;
color: white;
border-radius: 50%;
text-decoration: none;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease;
position: relative;
}
.whatsapp-float .whatsapp-link:hover {
transform: scale(1.1);
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.whatsapp-float .whatsapp-link i {
font-size: 2rem;
}
/* Tooltip text */
.whatsapp-float .tooltip-text {
position: absolute;
right: 70px;
background: rgba(0, 0, 0, 0.8);
color: white;
padding: 8px 15px;
border-radius: 30px;
font-size: 0.8rem;
white-space: nowrap;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
pointer-events: none;
}
.whatsapp-float .tooltip-text::after {
content: '';
position: absolute;
right: -8px;
top: 50%;
transform: translateY(-50%);
border-width: 5px;
border-style: solid;
border-color: transparent transparent transparent rgba(0, 0, 0, 0.8);
}
.whatsapp-float .whatsapp-link:hover .tooltip-text {
opacity: 1;
visibility: visible;
transform: translateX(-5px);
}
/* Pulse animation */
.whatsapp-float .whatsapp-link {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.4);
}
70% {
box-shadow: 0 0 0 15px rgba(37, 211, 102, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
}
}
/* Responsive */
@media (max-width: 768px) {
.whatsapp-float {
bottom: 20px;
right: 20px;
}
.whatsapp-float .whatsapp-link {
width: 50px;
height: 50px;
}
.whatsapp-float .whatsapp-link i {
font-size: 1.6rem;
}
}
</style>
<div class="whatsapp-float">
<a href="https://wa.me/<?php echo $wa_number; ?>?text=<?php echo $wa_message; ?>"
class="whatsapp-link"
target="_blank"
rel="noopener noreferrer">
<i class="fab fa-whatsapp"></i>
<?php if (!empty($wa_text)): ?>
<span class="tooltip-text"><?php echo htmlspecialchars($wa_text); ?></span>
<?php endif; ?>
</a>
</div>
<?php endif; ?>