Commit 98b4b32f authored by Indra Raja's avatar Indra Raja

menambahkan validasi dan udpate database

parent 0f6047ed
...@@ -28,12 +28,12 @@ class AdminController extends \Application\Master\GlobalActionController ...@@ -28,12 +28,12 @@ class AdminController extends \Application\Master\GlobalActionController
$view = new ViewModel(); $view = new ViewModel();
$result = new Result(); $result = new Result();
/* get url */
// $uri = $this->getRequest()->getUri();
// $baseurl = sprintf('//%s', $uri->getHost());
// $this->headScript->appendScript(' var baseURL = "' . $baseurl . '"'); $uri = $this->getRequest()->getUri();
// $this->headScript->appendFile('/action-js/index-js/action-listdata.js'); $baseurl = sprintf('//%s', $uri->getHost());
$this->headScript->appendScript(' var baseURL = "' . $baseurl . '"');
$this->headScript->appendFile('/action-js/antrian-js/action-panggil.js');
$this->layout("layout/layoutAdmin"); $this->layout("layout/layoutAdmin");
return $view; return $view;
......
...@@ -54,7 +54,7 @@ class ApiController extends \Application\Master\GlobalActionController { ...@@ -54,7 +54,7 @@ class ApiController extends \Application\Master\GlobalActionController {
} }
public function savedataAction(){ public function savedataAction(){
if($this->isLoggedIn()){
$result = new Result(); $result = new Result();
$request = $this->getRequest(); $request = $this->getRequest();
$post = $request->getPost(); $post = $request->getPost();
...@@ -123,9 +123,7 @@ class ApiController extends \Application\Master\GlobalActionController { ...@@ -123,9 +123,7 @@ class ApiController extends \Application\Master\GlobalActionController {
}catch (\Exception $exc) { }catch (\Exception $exc) {
$result = new Result(0,1,$exc->getMessage() .'-'.$exc->getTraceAsString()); $result = new Result(0,1,$exc->getMessage() .'-'.$exc->getTraceAsString());
} }
}else{
$result = new Result(0,401,'Silahkan masuk untuk melanjutkan');
}
} }
return $this->getOutput($result->toJson()); return $this->getOutput($result->toJson());
} }
......
<section class="warn"></section>
<select name="voice" id="voices" disabled>
</select><br><br>
<textarea disabled></textarea>
<button id="submit" onclick="speaker.speak();" disabled>Text to Speech</button>
\ No newline at end of file
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
<div class="modal-body"> <div class="modal-body">
<form id="myForm" > <form id="myForm" >
<input type="input" id="id_dokter" class="form-control" /></input> <input type="hidden" id="id_dokter" class="form-control" /></input>
<div class="form-group"> <div class="form-group">
<label>Nama Poli</label> <label>Nama Poli</label>
......
...@@ -152,6 +152,8 @@ $('#dokter').on('change', function () { ...@@ -152,6 +152,8 @@ $('#dokter').on('change', function () {
tampilangka(); tampilangka();
}); });
$('#no_antrian').html('-'); $('#no_antrian').html('-');
function tampilangka() { function tampilangka() {
var iddokter = $('#dokter').val(); var iddokter = $('#dokter').val();
......
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
var recognition = new SpeechRecognition();
recognition.onresult = function(event) {
if (event.results.length > 0) {
query.value = event.results[0][0].transcript;
query.form.submit();
}
}
var Speaker = function () {
var synth
var utterance
var voices
this.init = function () {
// CHECK FOR SPEECHSYNTHESIS API
if (!(window.speechSynthesis)) {
warn("Your browser is not capable of speech synthesis.")
return
}
// INITIALIZE SPEECH SYNTHESIS API ELEMENTS
synth = window.speechSynthesis
voices = synth.getVoices()
utterance = new SpeechSynthesisUtterance("Hello World!");
// CHECK FOR AVAILABLE VOICES
if (voices.length <= 0) {
warn("No voices are provided by either your browser or system.")
return
}
// ADD VOICE INDICES
voices.forEach(function (voice, a) {
voice.voice_index = a
})
// POPULATE VOICES LIST AND ENABLE INPUT ELEMENTS
populateVoicesList();
$(".warn").css("display", "none");
$("button#submit").removeAttr("disabled");
$("textarea").removeAttr("disabled");
$("select#voices").removeAttr("disabled");
// SET AN ENGLISH VOICE AS DEFAULT
var englishes = voices.filter(function (voice) { return voice.default && voice.lang.substr(0, 2) == "en" })
if (englishes.length > 0) {
$("#voices option[value=\"" + englishes[0].voice_index + "\"]").prop("selected", true)
}
clearInterval(timer)
}
function addVoices(languageName, filterBy) {
// Filter voices by filterBy function
var filteredVoices = voices.filter(filterBy)
// Add group only if there is at least one voice
if (filteredVoices.length > 0) {
// Add optgroup
$("#voices").append('<optgroup label="' + languageName + '">')
// Add option for each voice
filteredVoices.forEach(function (el, idx, arr) {
$("#voices").append('<option value="' + el.voice_index + '">' + el.name + ' (' + el.lang + ')' + '</option>')
})
// End optgroup
$("#voices").append('</optgroup>')
}
}
function warn(str) {
$(".warn").css("display", "block");
// $(".reason").append(str);
$("button#submit").attr("disabled");
$("textarea").attr("disabled");
$("select#voices").attr("disabled");
}
function getSelectedVoice() {
return voices[$("#voices option:selected").val()]
}
this.speak = function () {
// Cancel current voice if it's currently talking so new text can be read immediately
synth.cancel();
// CREATE NEW UTTERANCE AND SPEAK IF VOICE IS AVAILABLE
utterance = new SpeechSynthesisUtterance($("textarea").val());
var selectedVoice = getSelectedVoice()
if (selectedVoice) {
utterance.voice = selectedVoice
}
synth.speak(utterance);
}
}
var speaker = new Speaker()
var timer
$(document).ready(function () {
$(".warn").css("display", "none");
timer = setInterval(function () {
speaker.init();
}, 3);
});
\ No newline at end of file
...@@ -26,8 +26,8 @@ $(document).ready(function () { ...@@ -26,8 +26,8 @@ $(document).ready(function () {
required: true, required: true,
separator: ':', separator: ':',
duration: true, duration: true,
minimum: '00:10', minimum: '00:01',
maximum: '00:20', maximum: '00:59',
durationNegative: true durationNegative: true
}); });
}); });
...@@ -36,8 +36,8 @@ $(document).ready(function () { ...@@ -36,8 +36,8 @@ $(document).ready(function () {
required: true, required: true,
separator: ':', separator: ':',
duration: true, duration: true,
minimum: '06:00', minimum: '00:00',
maximum: '18:00', maximum: '23:00',
durationNegative: true durationNegative: true
}); });
}); });
...@@ -233,7 +233,20 @@ function LoadDadta(id) { ...@@ -233,7 +233,20 @@ function LoadDadta(id) {
}); });
} }
function kondisi() {
$('#tambah').on('click', function () {
SaveDataRegister()
})
function SaveDataRegister(param) {
let ruang = $("#ruang option:selected").attr("value"); let ruang = $("#ruang option:selected").attr("value");
let poli = $('#poli option:selected').attr("value"); let poli = $('#poli option:selected').attr("value");
let dokter = $('#dokter option:selected').attr("value"); let dokter = $('#dokter option:selected').attr("value");
...@@ -242,6 +255,30 @@ function kondisi() { ...@@ -242,6 +255,30 @@ function kondisi() {
let antrian_akhir = $('#antrian_akhir').val(); let antrian_akhir = $('#antrian_akhir').val();
let waktu_antrian = $('#waktu_antrian').val(); let waktu_antrian = $('#waktu_antrian').val();
let jam_mulai = $('#jam_mulai').val(); let jam_mulai = $('#jam_mulai').val();
/* save data */
$.ajax({
type: 'POST',
dataType: 'json',
url: baseURL + '/api/saveregister',
data: {
iruang: ruang,
id: param,
iantrian_all: antrian_all,//variable json diisi oleh variable yang menyimpan data inputan
iantrian_awal: antrian_awal,
iantrian_akhir: antrian_akhir,
iwaktu_antrian: waktu_antrian,
ipoli: poli,
idokter: dokter,
ijam_mulai: jam_mulai,
},
success: function (result) {
if (ruang == null || ruang == "") { if (ruang == null || ruang == "") {
swal({ swal({
title: "", title: "",
...@@ -362,51 +399,7 @@ function kondisi() { ...@@ -362,51 +399,7 @@ function kondisi() {
}); });
return false; return false;
} }
else if (result.code == 0) {
}
$('#tambah').on('click', function () {
kondisi()
SaveDataRegister()
})
function SaveDataRegister(param) {
let ruang = $("#ruang option:selected").attr("value");
let poli = $('#poli option:selected').attr("value");
let dokter = $('#dokter option:selected').attr("value");
let antrian_all = $('#antrian_all').val();
let antrian_awal = $('#antrian_awal').val();
let antrian_akhir = $('#antrian_akhir').val();
let waktu_antrian = $('#waktu_antrian').val();
let jam_mulai = $('#jam_mulai').val();
/* save data */
$.ajax({
type: 'POST',
dataType: 'json',
url: baseURL + '/api/saveregister',
data: {
iruang: ruang,
id: param,
iantrian_all: antrian_all,//variable json diisi oleh variable yang menyimpan data inputan
iantrian_awal: antrian_awal,
iantrian_akhir: antrian_akhir,
iwaktu_antrian: waktu_antrian,
ipoli: poli,
idokter: dokter,
ijam_mulai: jam_mulai,
},
success: function (result) {
// console.log(result);
if (result.code == 0) {
swal({ swal({
title: "<span style='color:#222'>Good Job!</span>", title: "<span style='color:#222'>Good Job!</span>",
confirmButtonColor: "#66BB6A", confirmButtonColor: "#66BB6A",
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment