setup shutdown website toggle
This commit is contained in:
parent
ddd37d01cf
commit
db44e6a24c
3 changed files with 52 additions and 2 deletions
|
@ -21,4 +21,14 @@
|
||||||
|
|
||||||
echo $res;
|
echo $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['upd_shutdown'])){
|
||||||
|
$frm_data = ($_POST['upd_shutdown']==0) ? 1 : 0;
|
||||||
|
$q = "UPDATE `settings` SET `shutdown`=? WHERE `sr_no`=?";
|
||||||
|
$values = [$frm_data,1];
|
||||||
|
$res = update($q, $values, 'ii');
|
||||||
|
|
||||||
|
echo $res;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -49,7 +49,7 @@
|
||||||
}
|
}
|
||||||
.custom-alert-t{
|
.custom-alert-t{
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: -220px;
|
top: 20px;
|
||||||
right: 20px;
|
right: 20px;
|
||||||
width: 320px;
|
width: 320px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<div class="col-lg-10 ms-auto p-4 overflow-hidden">
|
<div class="col-lg-10 ms-auto p-4 overflow-hidden">
|
||||||
<h4 class="mb-4">Settings</h4>
|
<h4 class="mb-4">Settings</h4>
|
||||||
<!--General setting-->
|
<!--General setting-->
|
||||||
<div class="card">
|
<div class="card mb-2">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="d-flex mb-3 align-items-center justify-content-between">
|
<div class="d-flex mb-3 align-items-center justify-content-between">
|
||||||
<h5 class="card-title m-0">General Settings</h5>
|
<h5 class="card-title m-0">General Settings</h5>
|
||||||
|
@ -50,6 +50,20 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!--Shutdown mode-->
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="d-flex mb-3 align-items-center justify-content-between">
|
||||||
|
<h5 class="card-title m-0">Shutdown Mode</h5>
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<form>
|
||||||
|
<input onchange="upd_shutdown(this.value)" class="form-check-input" type="checkbox" id="shutdown_toggle">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="card-text">Customers will not be allowed to book rooms when the shutdown mode is on.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -66,6 +80,8 @@
|
||||||
|
|
||||||
let site_title_input = document.getElementById('site_title_input');
|
let site_title_input = document.getElementById('site_title_input');
|
||||||
|
|
||||||
|
let shutdown_toggle = document.getElementById('shutdown_toggle');
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest();
|
let xhr = new XMLHttpRequest();
|
||||||
xhr.open("POST", "ajax/settings_crud.php", true);
|
xhr.open("POST", "ajax/settings_crud.php", true);
|
||||||
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
|
@ -74,6 +90,14 @@
|
||||||
general_data = JSON.parse(this.responseText);
|
general_data = JSON.parse(this.responseText);
|
||||||
site_title.innerText = general_data.site_title;
|
site_title.innerText = general_data.site_title;
|
||||||
site_title_input.value = general_data.site_title;
|
site_title_input.value = general_data.site_title;
|
||||||
|
|
||||||
|
if(general_data.shutdown == 0){
|
||||||
|
shutdown_toggle.checked = false;
|
||||||
|
shutdown_toggle.value = 0;
|
||||||
|
} else{
|
||||||
|
shutdown_toggle.checked = true;
|
||||||
|
shutdown_toggle.value = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xhr.send('get_general');
|
xhr.send('get_general');
|
||||||
|
@ -100,6 +124,22 @@
|
||||||
xhr.send('site_title='+site_title_val+'&upd_general');
|
xhr.send('site_title='+site_title_val+'&upd_general');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function upd_shutdown(val){
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("POST", "ajax/settings_crud.php", true);
|
||||||
|
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
|
xhr.onload = function(){
|
||||||
|
if(this.responseText == 1 && general_data.shutdown == 0){
|
||||||
|
alert('success', 'Website is on a shutdown mode');
|
||||||
|
|
||||||
|
} else{
|
||||||
|
alert('success', 'Website is running');
|
||||||
|
}
|
||||||
|
get_general();
|
||||||
|
}
|
||||||
|
xhr.send('upd_shutdown='+val);
|
||||||
|
}
|
||||||
window.onload = function(){
|
window.onload = function(){
|
||||||
get_general();
|
get_general();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue