/
home
/
sjslayjy
/
public_html
/
mosaram
/
storage
/
framework
/
views
/
Upload File
HOME
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>"> <title>Voice Command Report</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <!-- SweetAlert CSS and JS --> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> <style> body { font-family: Arial, sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; margin: 0; background-color: #f0f0f0; } #instruction { font-size: 18px; font-weight: bold; color: #333; margin-bottom: 20px; } #command-output { margin-top: 20px; font-size: 18px; text-align: center; } #result-table { width: 100%; max-width: 1000px; margin-top: 20px; border-collapse: collapse; display: none; } #result-table th, #result-table td { border: 1px solid #ddd; padding: 10px; } #result-table th { background-color: #007bff; color: white; } #result-table tr:nth-child(even) { background-color: #f2f2f2; } .animation { display: flex; flex-direction: column; align-items: center; margin-bottom: 20px; } .animation div { font-size: 20px; font-weight: bold; margin-bottom: 10px; } /* Custom microphone button */ #speech { position: relative; font-size: 80px; padding: 20px; border: none; background-color: transparent; cursor: pointer; outline: none; display: flex; align-items: center; justify-content: center; } #speech .fa-microphone { color: #007bff; position: relative; z-index: 1; } #speech .pulse-ring { position: absolute; border-radius: 50%; width: 150px; height: 150px; animation: bounce 2s infinite; background: rgba(0, 191, 255, 0.3); z-index: 0; top: 50%; left: 50%; transform: translate(-50%, -50%); } @keyframes bounce { 0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.8; } 50% { transform: translate(-50%, -50%) scale(1.4); opacity: 0.5; } 100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.8; } } /* Listening and Analyzing text animation */ #listening-animation, #analyzing-animation { display: none; font-size: 20px; font-weight: bold; color: #007bff; } #listening-animation.active, #analyzing-animation.active { display: block; } .small-toast { font-size: 0.85rem; /* Smaller font size */ padding: 10px 15px; /* Adjust padding */ width: 250px; /* Limit width */ border-radius: 8px; /* Slightly rounded corners */ } .swal2-toast .swal2-icon { width: 30px; /* Smaller icon */ height: 30px; margin-right: 10px; } .swal2-title { font-weight: bold; /* Bold title */ color: #ff6f61; /* Custom color for the title */ } .swal2-timer-progress-bar { background: #007bff; /* Blue progress bar */ } </style> </head> <body> <div class="animation"> <div id="instruction">Click on the microphone to give a command!</div> <button id="speech" class="btn"> <div class="pulse-ring"></div> <i class="fa fa-microphone" aria-hidden="true"></i> </button> <div id="listening-animation">Listening...</div> <div id="analyzing-animation">Analyzing...</div> </div> <p id="command-output"></p> <table id="result-table"> <thead></thead> <tbody></tbody> </table> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> const speechButton = document.getElementById('speech'); const output = document.getElementById('command-output'); const resultTable = document.getElementById('result-table'); const listeningAnimation = document.getElementById('listening-animation'); const analyzingAnimation = document.getElementById('analyzing-animation'); const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); const recognition = window.SpeechRecognition || window.webkitSpeechRecognition; if (recognition) { const recognitionInstance = new recognition(); recognitionInstance.lang = 'en-US'; recognitionInstance.interimResults = false; recognitionInstance.maxAlternatives = 1; speechButton.addEventListener('click', () => { speechButton.classList.add('active'); // Activate microphone visual listeningAnimation.classList.add('active'); // Show Listening animation recognitionInstance.start(); }); recognitionInstance.onresult = (event) => { const command = event.results[0][0].transcript; output.textContent = `Command: ${command}`; listeningAnimation.classList.remove('active'); // Hide Listening animation analyzingAnimation.classList.add('active'); // Show Analyzing animation setTimeout(() => { analyzingAnimation.classList.remove('active'); // Hide Analyzing animation handleCommand(command); }, 2000); // Show "Analyzing..." for 2 seconds before sending the command }; recognitionInstance.onend = () => { speechButton.classList.remove('active'); // Deactivate microphone visual when recognition ends }; recognitionInstance.onerror = (event) => { console.error('Speech Recognition Error', event.error); output.textContent = 'An error occurred while processing your command.'; speechButton.classList.remove('active'); listeningAnimation.classList.remove('active'); // Hide Listening animation on error analyzingAnimation.classList.remove('active'); // Hide Analyzing animation on error }; } else { output.textContent = 'Speech Recognition API not supported.'; } function handleCommand(command) { // Convert command to lowercase for easier matching const lowerCaseCommand = command.toLowerCase(); if (lowerCaseCommand.includes('total member report') || lowerCaseCommand.includes('total member')) { fetchTotalMembers(csrfToken); } else if (lowerCaseCommand.includes('total stock') || lowerCaseCommand.includes('show me the stock')) { fetchTotalStock(csrfToken, command); } else if (lowerCaseCommand.includes('get sale data')) { fetchSaleData(csrfToken, command); } else { output.textContent = 'Command not recognized. Please try again.'; Swal.fire({ icon: 'warning', title: 'No Record Found!', text: 'Sorry, no record found as per given command! Try after some time again!', toast: true, position: 'top', // Position the toast at the top-center showConfirmButton: false, timer: 5000, // The popup will disappear after 5 seconds timerProgressBar: true, customClass: { popup: 'gradient-toast' // Optional custom class for additional styles } }); } } function fetchTotalMembers(csrfToken) { $.ajax({ url: '/get-total-members', method: 'POST', headers: { 'X-CSRF-TOKEN': csrfToken }, success: (response) => { if (response.report) { displayTable(response.report, [ { key: 'id', label: 'ID' }, { key: 'name', label: 'Name' }, { key: 'email', label: 'Email' }, { key: 'role_name', label: 'Role' }, { key: 'status', label: 'Status' } ]); // Display total members } else { output.textContent = response.message; } }, error: (error) => { console.error('AJAX Error:', error); output.textContent = 'An error occurred while processing your command.'; } }); } function fetchTotalStock(csrfToken, command) { $.ajax({ url: '/get-stock-data', method: 'POST', headers: { 'X-CSRF-TOKEN': csrfToken }, data: { command: command }, success: (response) => { if (response.stock) { displayTable(response.stock, [ { key: 'dealer', label: 'Dealer' }, { key: 'product', label: 'Product' }, { key: 'warehouse', label: 'Warehouse' }, { key: 'quantity', label: 'Quantity' } ]); // Display stock data } else { output.textContent = response.message; } }, error: (error) => { console.error('AJAX Error:', error); output.textContent = 'An error occurred while processing your command.'; } }); } function fetchSaleData(csrfToken, command) { $.ajax({ url: '/get-sale-data', method: 'POST', headers: { 'X-CSRF-TOKEN': csrfToken }, data: { command: command }, success: (response) => { if (response.data) { displayTable(response.data, [ { key: 'dealer', label: 'Dealer' }, { key: 'product', label: 'Product' }, { key: 'invoice_type', label: 'Invoice Type' }, { key: 'invoice_number', label: 'Invoice Number' }, { key: 'quantity', label: 'Quantity' }, { key: 'rate', label: 'Rate' }, { key: 'freight_discount', label: 'Freight Discount' } ]); // Display sale data output.innerHTML = `<h2 style="font-size:15px;font-weight:bold;">Sale(<span id="sale1">${response.total}</span>)</h2>`; } else { output.textContent = response.message || 'No data found.'; } }, error: (error) => { console.error('AJAX Error:', error); output.textContent = 'An error occurred while processing your command.'; } }); } function displayTable(data, columns) { resultTable.style.display = 'table'; const thead = resultTable.querySelector('thead'); const tbody = resultTable.querySelector('tbody'); thead.innerHTML = ''; tbody.innerHTML = ''; // Generate table headers const headerRow = document.createElement('tr'); columns.forEach(column => { const th = document.createElement('th'); th.textContent = column.label; headerRow.appendChild(th); }); thead.appendChild(headerRow); // Generate table rows data.forEach(item => { const row = document.createElement('tr'); columns.forEach(column => { const td = document.createElement('td'); td.textContent = item[column.key]; row.appendChild(td); }); tbody.appendChild(row); }); } </script> </body> </html> <?php /**PATH /home3/pmmsanvp/public_html/sarojMain/resources/views/dashboard/microphone/microphone.blade.php ENDPATH**/ ?>