305 lines
12 KiB
PHP
305 lines
12 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>CPOne</title>
|
|
<link rel="stylesheet" href="../../../libs/vendor/css/google-fonts.css">
|
|
<link rel="stylesheet" href="../../../libs/vendor/css/icomoon-fonts.css">
|
|
<link rel="stylesheet" href="../../../libs/vendor/css/vuetify.min.css">
|
|
</head>
|
|
|
|
<body>
|
|
<div v-cloak id="app">
|
|
<v-app id="smartApp">
|
|
<!-- <one-navbar></one-navbar> -->
|
|
<!-- <v-content style="background: #2196F3 !important"> -->
|
|
<v-content style="background: rgb(33,150,243);
|
|
background: linear-gradient(180deg, rgba(33,150,243,1) 0%, rgba(255,255,255,1) 50%, rgba(33,150,243,1) 100%);">
|
|
<v-container fluid fill-height class="pl-1 pr-1 pt-2 pb-2">
|
|
<v-layout row wrap>
|
|
|
|
|
|
<v-flex xs12 class="right" fill-height>
|
|
<!-- <one-price-list></one-price-list> -->
|
|
<one-main></one-main>
|
|
</v-flex>
|
|
<!-- <v-flex xs6 class="right" fill-height pa-1> -->
|
|
<!-- komponen kanan -->
|
|
<!-- <one-fo-cashier-payment></one-fo-cashier-payment>-->
|
|
<!-- </v-flex> -->
|
|
</v-layout>
|
|
</v-container>
|
|
</v-content>
|
|
<!-- <one-footer> </one-footer> -->
|
|
</v-app>
|
|
</div>
|
|
|
|
<!-- Vendor -->
|
|
<script src="../../../libs/vendor/moment.min.js"></script>
|
|
<script src="../../../libs/vendor/numeral.min.js"></script>
|
|
<script src="../../../libs/vendor/moment-locale-id.js"></script>
|
|
<script src="../../../libs/vendor/lodash.js"></script>
|
|
<script src="../../../libs/vendor/axios.min.js"></script>
|
|
<script src="../../../libs/vendor/vue.js"></script>
|
|
<script src="../../../libs/vendor/vuex.js"></script>
|
|
<script src="../../../libs/vendor/vuetify.js"></script>
|
|
<script src="../../../libs/vendor/httpVueLoader.js"></script>
|
|
<script src="../../../libs/one_global.js"></script>
|
|
<script src="../../../libs/vendor/socket.io.js"></script>
|
|
<!-- <script src="../../../libs/one_print_barcode.js"></script>
|
|
<script src="../../../libs/one_print_robo.js"></script> -->
|
|
<!-- App Script -->
|
|
<?php
|
|
$ts = "?ts=" . Date("ymdhis");
|
|
?>
|
|
<script type="module">
|
|
var audioContext = new(window.AudioContext || window.webkitAudioContext)();
|
|
window.onload = function() {
|
|
// Inisialisasi AudioContext jika belum ada
|
|
|
|
if (audioContext.state === 'suspended') {
|
|
console.log("OnLoad");
|
|
audioContext.resume();
|
|
}
|
|
}
|
|
const events = ['load', 'mousemove', 'mousedown', 'touchstart', 'scroll'];
|
|
|
|
events.forEach(event => {
|
|
document.addEventListener(event, function() {
|
|
if (audioContext.state === 'suspended') {
|
|
audioContext.resume();
|
|
}
|
|
}, {
|
|
once: true
|
|
}); // once:true agar handler hanya dijalankan sekali
|
|
});
|
|
window.calculate_age = function(inp_dob) {
|
|
var now = moment(new Date())
|
|
var dob = moment(new Date(inp_dob))
|
|
var year = now.diff(dob, 'years')
|
|
dob.add(year, 'years')
|
|
var month = now.diff(dob, 'months')
|
|
dob.add(month, 'months')
|
|
var day = now.diff(dob, 'days')
|
|
if (isNaN(year)) return ''
|
|
return `${year} tahun ${month} bulan ${day} hari`
|
|
}
|
|
|
|
window.play_audio = function(prm) {
|
|
var url = "/audio/?prm=";
|
|
url = url + prm;
|
|
var audio = new Audio(url);
|
|
// audio.addEventListener('canplay', function() {
|
|
// if (document.readyState === 'complete') {
|
|
// audio.play().catch(function(error) {
|
|
// console.error("Error playing audio:", error);
|
|
// });
|
|
// } else {
|
|
// window.addEventListener('click', function() {
|
|
// audio.play().catch(function(error) {
|
|
// console.error("Error playing audio:", error);
|
|
// });
|
|
// }, {
|
|
// once: true
|
|
// });
|
|
// }
|
|
// });
|
|
// document.addEventListener('click', function() {
|
|
// // Sekarang audio dapat diputar
|
|
// });
|
|
audio.play()
|
|
}
|
|
window.pisahkanAngka = function(angka) {
|
|
let hasil = [];
|
|
|
|
if (angka >= 100) {
|
|
let seratusan = Math.floor(angka / 100) * 100;
|
|
hasil.push(seratusan);
|
|
angka -= seratusan;
|
|
}
|
|
|
|
if (angka >= 20) {
|
|
let puluhan = Math.floor(angka / 10) * 10;
|
|
hasil.push(puluhan);
|
|
angka -= puluhan;
|
|
}
|
|
|
|
// Add the remaining units if any, or treat as a two-digit number if less than 10
|
|
if (angka > 0) {
|
|
hasil.push(angka);
|
|
}
|
|
|
|
return hasil.join(',');
|
|
}
|
|
window.processSound = function(queueNumber, stationCode) {
|
|
// Memisahkan huruf dan angka
|
|
let huruf = queueNumber.match(/[A-Z]/)[0]; // Mengambil huruf
|
|
let angka = parseInt(queueNumber.match(/\d+/)[0]); // Mengambil angka dan konversi ke integer
|
|
|
|
let splitQueueNumber = window.pisahkanAngka(angka);
|
|
let str = "antrian," + huruf + "," + splitQueueNumber + "," + stationCode;
|
|
console.log("Huruf:", huruf);
|
|
console.log("Angka:", angka);
|
|
console.log("Hasil split:", splitQueueNumber);
|
|
console.log("prm:", str);
|
|
window.play_audio(str);
|
|
}
|
|
|
|
|
|
|
|
import {
|
|
store
|
|
} from './store.js<?php echo $ts ?>';
|
|
//for testing
|
|
window.store = store;
|
|
let g_timeout = 0;
|
|
|
|
var socketIoUrl = "https://" + window.location.host + ":9099/";
|
|
// var socketIoUrl = "wss://" + window.location.host + ":9099/";
|
|
new Vue({
|
|
store,
|
|
el: '#app',
|
|
data: {
|
|
socket: io.connect(socketIoUrl, {
|
|
forceNew: false,
|
|
// transports: ['polling', 'flashsocket']
|
|
transports: ['websocket']
|
|
}).on('connect', function() {
|
|
console.log('connection established');
|
|
})
|
|
},
|
|
mounted() {
|
|
this.socket.on("notification", function(msg) {
|
|
console.log("iosocket message", msg.type);
|
|
let type = msg.type;
|
|
let data = type.split('.')
|
|
if (data.length >= 5) {
|
|
if (data[0] === 'sm') {
|
|
let arrStation = [];
|
|
console.log(window.store.state.queue.selectedStation);
|
|
let station = window.store.state.queue.selectedStation;
|
|
let onSite = window.store.state.queue.onSite;
|
|
let branchID = window.store.state.queue.selectedBranch.M_BranchID;
|
|
let mgmMcuID = onSite ? window.store.state.queue.selectedSetup.Mgm_McuID : 0;
|
|
//yang di kantor
|
|
let onSiteMcuID = window.store.state.queue.onSiteMcuID;
|
|
let prm = {
|
|
'station': station,
|
|
'onsite': onSite,
|
|
'branchID': branchID,
|
|
'mgmMcuID': mgmMcuID,
|
|
"onSiteMcuID": onSiteMcuID
|
|
}
|
|
console.log(prm);
|
|
|
|
station.forEach(element => {
|
|
if (element.stationID == data[2] && data[1] !== 'call') {
|
|
if (onSite) {
|
|
if (mgmMcuID == data[3]) {
|
|
// 'sm.call.1.201.1.B0001'
|
|
store.dispatch("queue/getAntrian");
|
|
}
|
|
} else {
|
|
if (branchID == data[4] && onSiteMcuID.includes(data[3])) {
|
|
store.dispatch("queue/getAntrian");
|
|
// this.processSound(data[5]);
|
|
}
|
|
}
|
|
} else if (element.stationID == data[2] && data[1] === 'call') {
|
|
if (onSite) {
|
|
if (mgmMcuID == data[3]) {
|
|
// 'sm.call.1.201.1.B0001'
|
|
store.dispatch("queue/getAntrian");
|
|
window.processSound(data[5], element.stationCode);
|
|
}
|
|
} else {
|
|
if (branchID == data[4] && onSiteMcuID.includes(data[3])) {
|
|
store.dispatch("queue/getAntrian");
|
|
// store.processSound(data[5]);
|
|
window.processSound(data[5], element.stationCode); // Memanggil fungsi processSound dengan parameter data[5] menggunakan window
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
methods: {
|
|
tab_selected: function(tab) {
|
|
return this.$store.state.tab_selected == tab
|
|
},
|
|
selectedStation: function(tab) {
|
|
return window.store.state.queue.selectedStation
|
|
},
|
|
play_audio(prm) {
|
|
var url = "/audio/?prm=";
|
|
url = url + prm;
|
|
var audio = new Audio(url);
|
|
// audio.addEventListener('canplay', function() {
|
|
// audio.play();
|
|
// });
|
|
// audio.muted = true;
|
|
// audio.play().then(() => {
|
|
// audio.muted = false;
|
|
// });
|
|
// document.addEventListener('click', function() {
|
|
// Sekarang audio dapat diputar
|
|
// });
|
|
audio.play();
|
|
},
|
|
processSound(queueNumber) {
|
|
// http: //devcpone.aplikasi.web.id/audio/?prm=antrian,D,1,counter,A,1
|
|
let splitQueueNumber = this.pisahkanAngka(queueNumber);
|
|
let str = "antrian," + splitQueueNumber
|
|
console.log("Hasil split", splitQueueNumber);
|
|
console.log("prm:", str);
|
|
this.play_audio(str);
|
|
|
|
},
|
|
pisahkanAngka(angka) {
|
|
let hasil = [];
|
|
|
|
if (angka >= 100) {
|
|
let seratusan = Math.floor(angka / 100) * 100;
|
|
hasil.push(seratusan);
|
|
angka -= seratusan;
|
|
}
|
|
|
|
if (angka >= 20) {
|
|
let puluhan = Math.floor(angka / 10) * 10;
|
|
hasil.push(puluhan);
|
|
angka -= puluhan;
|
|
}
|
|
|
|
// Add the remaining units if any, or treat as a two-digit number if less than 10
|
|
if (angka > 0) {
|
|
hasil.push(angka);
|
|
}
|
|
|
|
return hasil.join(',');
|
|
}
|
|
},
|
|
components: {
|
|
'one-navbar': httpVueLoader('../../../apps/components/oneNavbarComponent.vue'),
|
|
'one-footer': httpVueLoader('../../../apps/components/oneFooter.vue'),
|
|
'one-patient-list': httpVueLoader('./components/onePatientList.vue'),
|
|
'one-main': httpVueLoader('./components/main.vue'),
|
|
}
|
|
})
|
|
</script>
|
|
<style>
|
|
[v-cloak] {
|
|
display: none
|
|
}
|
|
|
|
.left {}
|
|
|
|
.right {}
|
|
</style>
|
|
</body>
|
|
|
|
</html>
|