220 lines
8.0 KiB
PHP
220 lines
8.0 KiB
PHP
|
<?php
|
||
|
header ( "Expires: Tue, 01 Jan 2000 00:00:00 GMT" );
|
||
|
header ( "Last-Modified: " . gmdate ( "D, d M Y H:i:s" ) . " GMT" );
|
||
|
header ( "Cache-Control: no-store, no-cache, must-revalidate, max-age=0" );
|
||
|
header ( "Cache-Control: post-check=0, pre-check=0", false );
|
||
|
header ( "Pragma: no-cache" );
|
||
|
include ('techsyn_header_blank.php');
|
||
|
date_default_timezone_set("Asia/Calcutta");
|
||
|
// echo $_SESSION['role_home_page'];
|
||
|
// echo "<script>alert('".$_SESSION['RoleCode']."')</script>";
|
||
|
?>
|
||
|
<link rel="stylesheet" href="css/wizard.css">
|
||
|
<!-- Main Content Container for side bar and body-->
|
||
|
<div class="main-container ace-save-state" id="main-container">
|
||
|
<script type="text/javascript">
|
||
|
try{ace.settings.loadState('main-container')}catch(e){}
|
||
|
</script>
|
||
|
<div class="main-content">
|
||
|
<div class="main-content-inner">
|
||
|
<div class="page-content">
|
||
|
<div class="row ">
|
||
|
<div class="col-sm-9 wizard-card box box-danger"
|
||
|
style="width: 90%; margin-top: 10%; margin-left: 5%; background-color: #fff">
|
||
|
<h3 style="text-align: center">Shift Management</h3>
|
||
|
<form method="post" id="shift_form"action="review_shift_selection.php">
|
||
|
<input type="hidden" name="current_shift" id="current_shift" value="1"> <input
|
||
|
type="hidden" name="shift_date" id="shift_date" value="">
|
||
|
|
||
|
<div class="box-body">
|
||
|
<div class="row">
|
||
|
<div class="col-sm-12">
|
||
|
|
||
|
<?php
|
||
|
$current_shift_id="";
|
||
|
$current_shift_date="";
|
||
|
$sql1 = "select * from shift_status_details where current_status='R' and ohc_location_id='" . $_SESSION ['current_ohcttype'] . "'";
|
||
|
//echo $sql1;
|
||
|
$result1 = mysqli_query($conn,$sql1 );
|
||
|
if ($row = mysqli_fetch_array($result1)) {
|
||
|
$current_shift_id=$row['shift_id'];
|
||
|
$current_shift_date=date('Ymd',strtotime($row['record_date']));
|
||
|
}
|
||
|
$total = mysqli_num_rows ( $result1 );
|
||
|
error_log ( "currently active shift count:" . $total );
|
||
|
?>
|
||
|
|
||
|
<select class="form-control select2" id="shift_id"
|
||
|
name="shift_id" <?php if($total!=0){echo "disabled";}?>>
|
||
|
<option disabled><?php
|
||
|
if ($total == 0) {
|
||
|
echo "Please
|
||
|
select SHIFT";
|
||
|
} else {
|
||
|
echo "Please
|
||
|
End the CURRENT Shift";
|
||
|
}
|
||
|
?></option>
|
||
|
<?php echo generateOptionWithWhereClause1('shift_status', 'status_name', 'shift_status_id',$current_shift_id , '', 'is_shift', 'Y'); ?>
|
||
|
</select>
|
||
|
|
||
|
<div class="box-footer" style="text-align: center;">
|
||
|
<?php
|
||
|
if($total>0){
|
||
|
$current_shift ="";
|
||
|
$current_shift_starthr="";
|
||
|
$current_shift_endhr="";
|
||
|
$shift_spans_nextday=0;
|
||
|
$sql_shift_list = "select * from shift_status where is_shift='Y' and ohc_location_id =".$_SESSION ['current_ohcttype']." and shift_status_id= $current_shift_id";
|
||
|
|
||
|
if (!$result_shift_list = mysqli_query($conn,$sql_shift_list)) {
|
||
|
error_log ( "Exception Retrieving :" . mysqli_error($conn)."Failing Query:".$sql_shift_list );
|
||
|
|
||
|
}
|
||
|
if($row_shift =mysqli_fetch_array($result_shift_list)){
|
||
|
$current_shift =$row_shift['status_name'];
|
||
|
$current_shift_starthr=$row_shift['start_time'];
|
||
|
$current_shift_endhr=$row_shift['end_time'];
|
||
|
$shift_spans_nextday=$row_shift['shift_spans_nextday'];
|
||
|
}
|
||
|
$current_hr_min = date('Hi');
|
||
|
$current_date= date('Ymd');
|
||
|
echo "<p>current_shift_date:".$current_shift_date."</p>";
|
||
|
echo "<p>current_date:".$current_date ."</p>";
|
||
|
echo"<p>current_hr_min:".($current_hr_min) ."</p>";
|
||
|
echo"<p>current_shift_starthr:".$current_shift_starthr."</p>";
|
||
|
echo"<p>current_shift_endhr:". $current_shift_endhr."</p>";
|
||
|
echo"<p>shift_spans_nextday:". $shift_spans_nextday."</p>";
|
||
|
|
||
|
$shift_time_over =false;
|
||
|
if($shift_spans_nextday!='1' && $current_hr_min>$current_shift_endhr){
|
||
|
echo "Beyond current Shift case1";
|
||
|
$shift_time_over =true;
|
||
|
$d1=strtotime($current_shift_endhr);
|
||
|
$d2=strtotime($current_hr_min);
|
||
|
$shift_time_remaining= round(($d1 - $d2) / 60,2);
|
||
|
|
||
|
}else if($shift_spans_nextday=='1' && $current_shift_date==$current_date && $current_hr_min<$current_shift_endhr){
|
||
|
echo "Beyond current Shift case2";
|
||
|
$shift_time_over =true;
|
||
|
$d1=strtotime($current_hr_min);
|
||
|
$d2=strtotime($current_shift_endhr);
|
||
|
$shift_time_remaining= round(($d1 - $d2) / 60,2);
|
||
|
}else if($shift_spans_nextday=='1' && $current_shift_date<$current_date && $current_hr_min>$current_shift_endhr){
|
||
|
echo "Beyond current Shift case3";
|
||
|
$shift_time_over =true;
|
||
|
$d1=strtotime($current_shift_endhr);
|
||
|
$d2=strtotime($current_hr_min);
|
||
|
$shift_time_remaining= round(($d1 - $d2) / 60,2);
|
||
|
}else{
|
||
|
$shift_time_over =false;
|
||
|
echo "Within current Shift";
|
||
|
$d1=strtotime($current_shift_endhr);
|
||
|
$d2=strtotime($current_hr_min);
|
||
|
$shift_time_remaining= round(($d1 - $d2) / 60,2);
|
||
|
}
|
||
|
if($shift_time_remaining>0){
|
||
|
echo "<p>Current Shift:".$current_shift." Shift Time Remaining:".($shift_time_remaining)."Mins</p>";
|
||
|
}else{
|
||
|
echo "<p>Current Shift:".$current_shift." Shift Running Overdue by :".abs($shift_time_remaining)."Mins</p>";
|
||
|
|
||
|
}
|
||
|
}else{
|
||
|
echo "<p> No Active Shift Selected</p>";
|
||
|
}
|
||
|
//while($row_shift = $result_shift_list){
|
||
|
|
||
|
//}
|
||
|
|
||
|
?>
|
||
|
|
||
|
|
||
|
<button class="btn btn-success new_button btn-xs" id="start_button"
|
||
|
type="reset" onclick="start_shift();"
|
||
|
<?php if($total!=0){echo "disabled";}?>>START SHIFT</button>
|
||
|
|
||
|
<button class="btn btn-danger save_button btn-xs" id="end_button"
|
||
|
type="reset" onclick="end_shift();"
|
||
|
<?php if($total==0){echo "disabled";}?>>END SHIFT <?php echo $row['status_name'] ?></button>
|
||
|
<button class="btn btn-secondary btn-xs" id="review_last_shift"
|
||
|
type="button" onclick="end_shift();">Review Last Shift Summary</button>
|
||
|
<button class="btn btn-info btn-xs" id="review_current_shift"
|
||
|
type="button" onclick="end_shift();"
|
||
|
<?php if($total==0){echo "disabled";}?>>Review Current Shift Summary</button>
|
||
|
<button class="btn btn-primary btn-xs" id="review_last_shift"
|
||
|
type="button" onclick="end_shift();"
|
||
|
<?php if($total==0){echo "disabled";}?>>Continue</button>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</form>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|
||
|
<script>
|
||
|
$(document).ready(function(){
|
||
|
$(".choice").on("click", function () {
|
||
|
var v = $(this).closest("div").find("input[name='role_id']").attr("checked","checked").val()
|
||
|
$("#Role_Id").val(v);
|
||
|
document.forms[0].submit();
|
||
|
});
|
||
|
});
|
||
|
function start_shift(){
|
||
|
var shift_id = $('#shift_id').val();
|
||
|
if(shift_id ==null){
|
||
|
BootstrapDialog.alert('Please Select the shift.!!!');
|
||
|
return false;
|
||
|
}
|
||
|
$.ajax({
|
||
|
url : 'save_shift_status.php ',
|
||
|
type : "POST",
|
||
|
data : $("#shift_form").serialize(),
|
||
|
dataType : 'json',
|
||
|
success : function(data) {
|
||
|
console.log(data);
|
||
|
// alert(data);
|
||
|
BootstrapDialog.alert('Shift started successfully.');
|
||
|
document.getElementById("shift_id").disabled = true;
|
||
|
document.getElementById("end_button").disabled = false;
|
||
|
document.getElementById("start_button").disabled = true;
|
||
|
//$("#flex1").flexReload();
|
||
|
window.reload();
|
||
|
return;
|
||
|
},
|
||
|
error : function(data) {
|
||
|
BootstrapDialog.alert('Error Starting Shift');
|
||
|
return;
|
||
|
}
|
||
|
});
|
||
|
$('.close').click();
|
||
|
}
|
||
|
function end_shift(){
|
||
|
$.ajax({
|
||
|
url : 'save_shift_status.php ',
|
||
|
type : "POST",
|
||
|
data : $("#shift_form").serialize(),
|
||
|
dataType : 'json',
|
||
|
success : function(data) {
|
||
|
console.log(data);
|
||
|
BootstrapDialog.alert('Shift ended Successfully.');
|
||
|
document.getElementById("shift_id").disabled = false;
|
||
|
document.getElementById("end_button").disabled = true;
|
||
|
document.getElementById("start_button").disabled = false;
|
||
|
window.reload();
|
||
|
return;
|
||
|
},
|
||
|
error : function(data) {
|
||
|
BootstrapDialog.alert('Error Ending Shift');
|
||
|
return;
|
||
|
}
|
||
|
});
|
||
|
$('.close').click();
|
||
|
}
|
||
|
</script>
|