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
$view = new ViewModel();
$result = new Result();
/* get url */
// $uri = $this->getRequest()->getUri();
// $baseurl = sprintf('//%s', $uri->getHost());
$uri = $this->getRequest()->getUri();
$baseurl = sprintf('//%s', $uri->getHost());
// $this->headScript->appendScript(' var baseURL = "' . $baseurl . '"');
// $this->headScript->appendFile('/action-js/index-js/action-listdata.js');
$this->headScript->appendScript(' var baseURL = "' . $baseurl . '"');
$this->headScript->appendFile('/action-js/antrian-js/action-panggil.js');
$this->layout("layout/layoutAdmin");
return $view;
......
......@@ -54,7 +54,7 @@ class ApiController extends \Application\Master\GlobalActionController {
}
public function savedataAction(){
if($this->isLoggedIn()){
$result = new Result();
$request = $this->getRequest();
$post = $request->getPost();
......@@ -123,9 +123,7 @@ class ApiController extends \Application\Master\GlobalActionController {
}catch (\Exception $exc) {
$result = new Result(0,1,$exc->getMessage() .'-'.$exc->getTraceAsString());
}
}else{
$result = new Result(0,401,'Silahkan masuk untuk melanjutkan');
}
}
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
......@@ -50,7 +50,7 @@
</div>
<div class="modal-body">
<form id="myForm" >
<div class="form-group">
<label>Nama Poli</label>
<select name="nama_poli" id="poli" class="form-control" >
......@@ -97,7 +97,7 @@
<div class="modal-body">
<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">
<label>Nama Poli</label>
......
......@@ -152,6 +152,8 @@ $('#dokter').on('change', function () {
tampilangka();
});
$('#no_antrian').html('-');
function tampilangka() {
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 () {
required: true,
separator: ':',
duration: true,
minimum: '00:10',
maximum: '00:20',
minimum: '00:01',
maximum: '00:59',
durationNegative: true
});
});
......@@ -36,8 +36,8 @@ $(document).ready(function () {
required: true,
separator: ':',
duration: true,
minimum: '06:00',
maximum: '18:00',
minimum: '00:00',
maximum: '23:00',
durationNegative: true
});
});
......@@ -233,142 +233,14 @@ function LoadDadta(id) {
});
}
function kondisi() {
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();
if (ruang == null || ruang == "") {
swal({
title: "",
text: "Field ruang is empty!",
icon: "error",
button: "ok",
});
return false;
} else if (antrian_all == null || antrian_all == "") {
swal({
title: "",
text: "Field antrian seluruh is empty!",
icon: "error",
button: "ok",
});
return false;
} else if (antrian_awal == null || antrian_awal == "") {
swal({
title: "",
text: "Field antrian awal is empty!",
icon: "error",
button: "ok",
});
return false;
} else if (antrian_akhir == null || antrian_akhir == "") {
swal({
title: "",
text: "Field antrian akhir is empty!",
icon: "error",
button: "ok",
});
return false;
} else if (waktu_antrian == null || waktu_antrian == "") {
swal({
title: "",
text: "Field waktu antrian is empty!",
icon: "error",
button: "ok",
});
return false;
}
else if (poli == null || poli == "") {
swal({
title: "",
text: "Field poli is empty!",
icon: "error",
button: "ok",
});
return false;
}
else if (dokter == null || dokter == "") {
swal({
title: "",
text: "Field dokter is empty!",
icon: "error",
button: "ok",
});
return false;
} else if (parseInt(antrian_akhir) < parseInt(antrian_awal)) {
if (parseInt(antrian_akhir) < parseInt(antrian_awal)) {
swal({
title: "",
text: "antrian awal tidak boleh lebih besar dari antrian akhir!",
icon: "error",
button: "ok",
});
return false;
} else if (parseInt(antrian_akhir) > parseInt(antrian_all)) {
swal({
title: "",
text: "antrian akhir tidak boleh lebih besar dari antrian seluruh!",
icon: "error",
button: "ok",
});
return false;
}
} else if (parseInt(antrian_akhir) > parseInt(antrian_all)) {
swal({
title: "",
text: "antrian akhir tidak boleh lebih besar dari antrian all!",
icon: "error",
button: "ok",
});
return false;
} else if (parseInt(antrian_awal) == parseInt(antrian_akhir)) {
swal({
title: "",
text: "antrian akhir tidak boleh sama dengan antrian awal!",
icon: "error",
button: "ok",
});
return false;
}
else if (parseInt(antrian_all) > 30) {
swal({
title: "",
text: "antrian seluruh tidak boleh lebih dari 30!",
icon: "error",
button: "ok",
});
return false;
} else if (parseInt(waktu_antrian) > 10) {
swal({
title: "",
text: "waktu antrian per orang tidak lebih dari 10 menit",
icon: "error",
button: "ok",
});
return false;
}
else if (parseInt(antrian_awal) < 5) {
swal({
title: "",
text: "antrian mobile dimulai dari 5! ",
icon: "error",
button: "ok",
});
return false;
}
}
$('#tambah').on('click', function () {
kondisi()
SaveDataRegister()
})
......@@ -404,9 +276,130 @@ function SaveDataRegister(param) {
},
success: function (result) {
// console.log(result);
if (result.code == 0) {
if (ruang == null || ruang == "") {
swal({
title: "",
text: "Field ruang is empty!",
icon: "error",
button: "ok",
});
return false;
} else if (antrian_all == null || antrian_all == "") {
swal({
title: "",
text: "Field antrian seluruh is empty!",
icon: "error",
button: "ok",
});
return false;
} else if (antrian_awal == null || antrian_awal == "") {
swal({
title: "",
text: "Field antrian awal is empty!",
icon: "error",
button: "ok",
});
return false;
} else if (antrian_akhir == null || antrian_akhir == "") {
swal({
title: "",
text: "Field antrian akhir is empty!",
icon: "error",
button: "ok",
});
return false;
} else if (waktu_antrian == null || waktu_antrian == "") {
swal({
title: "",
text: "Field waktu antrian is empty!",
icon: "error",
button: "ok",
});
return false;
}
else if (poli == null || poli == "") {
swal({
title: "",
text: "Field poli is empty!",
icon: "error",
button: "ok",
});
return false;
}
else if (dokter == null || dokter == "") {
swal({
title: "",
text: "Field dokter is empty!",
icon: "error",
button: "ok",
});
return false;
} else if (parseInt(antrian_akhir) < parseInt(antrian_awal)) {
if (parseInt(antrian_akhir) < parseInt(antrian_awal)) {
swal({
title: "",
text: "antrian awal tidak boleh lebih besar dari antrian akhir!",
icon: "error",
button: "ok",
});
return false;
} else if (parseInt(antrian_akhir) > parseInt(antrian_all)) {
swal({
title: "",
text: "antrian akhir tidak boleh lebih besar dari antrian seluruh!",
icon: "error",
button: "ok",
});
return false;
}
} else if (parseInt(antrian_akhir) > parseInt(antrian_all)) {
swal({
title: "",
text: "antrian akhir tidak boleh lebih besar dari antrian all!",
icon: "error",
button: "ok",
});
return false;
} else if (parseInt(antrian_awal) == parseInt(antrian_akhir)) {
swal({
title: "",
text: "antrian akhir tidak boleh sama dengan antrian awal!",
icon: "error",
button: "ok",
});
return false;
}
else if (parseInt(antrian_all) > 30) {
swal({
title: "",
text: "antrian seluruh tidak boleh lebih dari 30!",
icon: "error",
button: "ok",
});
return false;
} else if (parseInt(waktu_antrian) > 10) {
swal({
title: "",
text: "waktu antrian per orang tidak lebih dari 10 menit",
icon: "error",
button: "ok",
});
return false;
}
else if (parseInt(antrian_awal) < 5) {
swal({
title: "",
text: "antrian mobile dimulai dari 5! ",
icon: "error",
button: "ok",
});
return false;
}
else if (result.code == 0) {
swal({
title: "<span style='color:#222'>Good Job!</span>",
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