ESH/inventory_checklist_details.php

1332 lines
49 KiB
PHP
Raw Normal View History

2024-10-23 18:28:06 +05:30
<?php include('techsyn_header.php'); ?>
<!-- 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>
<?php
include('techsyn_sidebar.php');
error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
$ohc_type = $_SESSION['current_ohcttype'];
$cat = $_POST["AMB"];
$issue_type = $_POST["issue_type"];
$shift = $_POST["shift"];
if($issue_type=='AMB'){
$amb_id = $_POST["ambulance_number"];
$_POST["inventory_type2"]=$_POST["ambulance_number"];
}else{
$amb_id = $_POST["ohc_number"];
$_POST["inventory_type2"]=$_POST["ohc_number"];
}
?>
<!--breadcrumb-->
<div class="main-content">
<div class="main-content-inner">
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
<ul class="breadcrumb">
<li><i class="ace-icon fa fa-home home-icon"></i> <a href="#">Home</a>
</li>
<li class="#">Inventory</li>
<li class="active">Inventory Checklist</li>
</ul>
</div>
<!-- End of breadcrumb -->
<?php
$db_new_date = "";
$last_day = "";
$m = 0;
$y = 0;
$selectedParamMonth = $_POST['param_month'];
$selectedParamYear = $_POST['param_year'];
if (isset($selectedParamYear) && $selectedParamYear != "" && isset($selectedParamMonth) && $selectedParamMonth != "") {
$last_day = date("t-m-Y", strtotime("" . $selectedParamYear . "-" . ($selectedParamMonth + 1) . "-01"));
} else {
$last_day = date('t-m-Y');
}
$m = date('m', strtotime("" . $selectedParamYear . "-" . ($selectedParamMonth + 1) . "-01"));
$y = date('Y', strtotime("" . $selectedParamYear . "-" . ($selectedParamMonth + 1) . "-01"));
?>
<script>
var jsonArrayParamData = <?php echo json_encode($param_data); ?>;
</script>
<div class="page-content">
<div class="box box-primary" style="padding: 10px; margin: 2px 0px 50px 5px; width: 99.5%;">
<form id="shift_form" method="post">
<!-- box-body-->
<div class="box-body" id="reload_amb">
<div class="row">
<div class="col-sm-1">
<tr>
<td><select name="param_month" id="param_month" class="form-control">
<option value="0" <?php if ($m == 1) { ?>selected<?php } ?>>January
</option>
<option value="1" <?php if ($m == 2) { ?>selected<?php } ?>>February
</option>
<option value="2" <?php if ($m == 3) { ?>selected<?php } ?>>March
</option>
<option value="3" <?php if ($m == 4) { ?>selected<?php } ?>>April
</option>
<option value="4" <?php if ($m == 5) { ?>selected<?php } ?>>May</option>
<option value="5" <?php if ($m == 6) { ?>selected<?php } ?>>June
</option>
<option value="6" <?php if ($m == 7) { ?>selected<?php } ?>>July
</option>
<option value="7" <?php if ($m == 8) { ?>selected<?php } ?>>August
</option>
<option value="8" <?php if ($m == 9) { ?>selected<?php } ?>>September
</option>
<option value="9" <?php if ($m == 10) { ?>selected<?php } ?>>October
</option>
<option value="10" <?php if ($m == 11) { ?>selected<?php } ?>>November
</option>
<option value="11" <?php if ($m == 12) { ?>selected<?php } ?>>December
</option>
</select></td>
</tr>
</div>
<div class="col-sm-1">
<tr>
<td><select name="param_year" id="param_year" class="form-control">
<?php $yy = date('Y');
//$yy=$yy-1;
echo $yy;
$r_year = $_POST['param_year'];
echo $r_year;
for ($i = 0; $i < 3; $i++) { ?>
<option value="<?php echo $yy ?>" <?php if ($yy == $r_year) { ?>
selected<?php } ?>><?php echo $yy ?></option>
<?php $yy++;
} ?>
</select>
<input type="hidden" value="<?php echo $_POST["status_id"] ?>"
name="status_id" id="status_id" class="form-control">
</td>
</tr>
</div>
<div class="col-sm-1">
<tr>
<td><input type="hidden" value="<?php echo $_POST["inventory_type"] ?>"
name="inventory_type" id="inventory_type" class="form-control">
</input></td>
<td><input type="hidden" value="<?php echo $amb_id ?>" name="inventory_type2"
id="inventory_type2" class="form-control">
</input></td>
<td><input type="hidden" value="<?php echo $_POST["inventory_item_type2"] ?>"
name="inventory_item_type2" id="inventory_item_type2"
class="form-control">
</input></td>
<td><input type="hidden" value="<?php echo $_POST["inventory_cat"] ?>"
name="inventory_cat" id="cat" class="form-control">
</input></td>
<td><input type="hidden" value="<?php echo $amb_id ?>" name="amb_idd"
id="amb_idd" class="form-control">
</input></td>
<td><input type="hidden" value="<?php echo $issue_type ?>" name="issue_type"
id="issue_type" class="form-control">
</input></td>
<td><input type="hidden" value="<?php echo $_POST['ambulance_number'] ?>"
name="ambulance_number" id="ambulance_number" class="form-control">
</input></td>
<td><input type="hidden" value="<?php echo $_POST['shift'] ?>" name="shift"
id="shift" class="form-control">
</input></td>
<td><input type="hidden" value="<?php echo $_POST['ohc_number'] ?>"
name="ohc_number" id="ohc_number" class="form-control">
</input></td>
</tr>
</div>
<button class="btn btn-primary " type="button" id="back"
onclick="window.location='<?php if($_SESSION['RoleCode']=='DOC') echo 'pending_checklist.php' ;else echo 'ohc_selector.php'; ?>' ">
<i class="ace-icon fa fa-back"></i> Back
</button>
<button class="btn btn-primary " type="button" id="submit_button"
onclick=" document.forms[0].target='';document.forms[0].action='' ;document.forms[0].submit()">
<i class="ace-icon fa fa-send"></i> Submit
</button>
<button class="btn btn-success" id="generate_pdf" onclick='pdf();'>
<i class="ace-icon fa fa-print"></i> Print PDF
</button>
<button class="btn btn-success" id="generate_excel" onclick='excel();'>
<i class="ace-icon fa fa-print"></i> Print Excel
</button>
<?php if($_SESSION ['RoleCode']!='DOC') { ?>
<input type="button" class="btn btn-danger" style="width: 126px;" id="approval"
onclick='checklist_approval("PENDING");app_alert("PENDING")'
value='Send For Approval'>
<?php }else{ ?>
<input type="button" class="btn btn-danger" id="approval" style="width: 126px;"
onclick='checklist_approval("REJECTED");app_alert("REJECTED")' value='REJECTED'>
<input type="button" class="btn btn-success" id="approval" style="width: 126px;"
onclick='checklist_approval("APPROVED");app_alert("APPROVED")' value='APPROVED'>
<?php }?>
</form>
<br>
<h2 align='center' style="color:green; ">
<?php
if($issue_type=='AMB'){
echo getTableFieldValue('ambulance_details_new', "CONCAT(ambulance_name , ' ( ' ,
ambulance_number ,' )' )", 'id', $amb_id);}
else{
echo getTableFieldValue('ohc_type', "CONCAT(ohc_type_name)", 'ohc_type_id', $amb_id);
}
$shift_name=getTableFieldValue('shift_status', "status_name", 'shift_status_id', $shift);
echo '('.$shift_name.' Shift)';
?>
<input type="hidden" name="ambulance_id" id="ambulance_id" value="<?php echo $amb_id ?>">
</h2>
<h2 style="text-align:center"><span style="color:crimson; ">
<?= date("F", mktime(0, 0, 0, $m, 10)); ?> ( <?= $y ?> )
</h2>
</section>
<div id="table-scroll" class="table-scroll">
<div id="shift_table" class="table-wrap">
<table id="myTable" class="table table-bordered order-list main-table">
<thead>
<tr>
<td class="fixed-side"></td>
<td style='width:500px' class="fixed-side">Date</td>
<?php
for ($j = 1; $j <= $last_day; $j++) {
$new_date = $j . "-" . $m . "-" . $y;
$day = date('D', strtotime($new_date));
?>
<td scope="col"><?php echo $j ?></td>
<?php } ?>
</tr>
<tr>
<td class="fixed-side">Sr. No.</td>
<td style='width:500px' class="fixed-side">Description</td>
<?php
// $last_day = date('t-m-Y');
// $m = date('m');
// $y = date('Y');
for ($k = 1; $k <= $last_day; $k++) {
$new_date = $k . "-" . $m . "-" . $y;
$day = date('D', strtotime($new_date));
?>
<td scope="col"><?php echo $day ?></td>
<?php } ?>
</tr>
</thead>
<tbody>
<?php $count = 1;
$items_array = array();
$item = array();
$sub_count = 1;
$cat = $_POST["inventory_cat"];
if ($_POST["inventory_cat"] != 'AMB_CHECK') {
$type = $_POST["inventory_type"];
} else {
$type = $_POST["inventory_type2"];
}
$item_cat=$_POST["inventory_item_type2"];
$item_cat_query='';
if($item_cat=="" || $item_cat=='ALL'||$item_cat==null ){$item_cat_query='';}
else if($item_cat=="comm"){$item_cat_query='and item_type="'.$item_cat.'"';}
else{
$item_cat_query='and item_type="item" and item_id in (select item_id from tbl_items where cat="'.$item_cat.'") ';
}
error_log("type " . $amb_id);
$ohc = "SELECT ohc_type_id from ohc_type where ohc_type_id = '" . $_SESSION['current_ohcttype'] . "' ";
error_log("PARAMS1111111::" . $ohc);
$results_ohc = mysqli_query($conn, $ohc);
$row_ohc = mysqli_fetch_array($results_ohc);
error_log("ohc Id" . $row_ohc['ohc_type_id']);
$i = 1;
$query = "SELECT ambulance_issue_master_id from ambulance_issue_master where ohc_type_id = '" . $row_ohc['ohc_type_id'] . "' AND ambulance_id = '$amb_id' AND issue_type='$issue_type' ";
error_log("PARAMS::" . $query);
$result = @mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($result)) {
$item_desc = "";
$stock_issue_item_id = "SELECT a.* from ambulance_checklist_item a WHERE a.status ='0' AND a.ambulance_issue_master_id ='" . $row['ambulance_issue_master_id'] . "' $item_cat_query";
error_log($stock_issue_item_id);
$results_issue_item_id = mysqli_query($conn, $stock_issue_item_id);
while ($row_issue_item_id = mysqli_fetch_assoc($results_issue_item_id)) {
$item_desc = "";
$sql_issue_items = "SELECT a.* from ambulance_checklist_item a WHERE a.status ='0' AND a.id='" .$row_issue_item_id["id"]."' and a.ambulance_issue_master_id ='" . $row['ambulance_issue_master_id'] . "' $item_cat_query";
$results_issue_items = mysqli_query($conn, $sql_issue_items);
while ($row_issue_items = mysqli_fetch_assoc($results_issue_items)) {
array_push($items_array, $row_issue_items);
array_push($item, $row_issue_items['item_id'].'$'.$row_issue_items['item_type']);
}
}
}
$item = array_unique($item);
// error_log('item_arr' . print_r($items_array, true));
sort($item);
$row_issue_qty = array();
for ($i = 0; $i < count($item); $i++) {
$qty = 0;
for ($j = 0; $j < count($items_array); $j++) {
if ($item[$i] == $items_array[$j]['item_id'].'$'.$items_array[$j]['item_type']) {
$qty += $items_array[$j]['issue_qty'];
}
}
error_log($item[$i] . '--' . $qty);
array_push($row_issue_qty, $qty);
}
$row_issue_items['item_id'] = $item;
$row_issue_items['issue_qty'] = $row_issue_qty;
for ($x = 0; $x < count($row_issue_items['item_id']); $x++) {
$item_desc = '';
$itemWithType=explode('$',$row_issue_items['item_id'][$x]);
$row_issue_items['item_id'][$x]=$itemWithType[0];
$row_issue_items['item_type'][$x]=$itemWithType[1];
if($row_issue_items['item_type'][$x]=='item'){
$item_desc = $item_desc . ' <p> ' . getItemWithFormName($row_issue_items['item_id'][$x]) . " ";
$item_unit_id = getTableFieldValue('tbl_items', 'unit_id', 'item_id', $row_issue_items['item_id'][$x]);
$item_unit = getTableFieldValue('unit_master', 'unit_name', 'unit_id', $item_unit_id);
error_log("Userid " . $row_issue_items['item_type'][$x]);
if ($row_issue_items['issue_qty'][$x] != 0) {
$item_desc = $item_desc . '<b> Qty: ' . $row_issue_items['issue_qty'][$x] . ' ' . $item_unit . '</b>';
}
$item_desc = $item_desc . "</p>";
}else{
$item_desc = $item_desc.' <p> '.getTableFieldValue('questionaire_master','question','question_id',$row_issue_items['item_id'][$x]);
$item_desc=$item_desc."</p>";
}
?>
<tr>
<td class="fixed-side"><?php echo $sub_count;
$sub_count++; ?></td>
<td style='width:500px' class="fixed-side"> <?php echo $item_desc; ?></td>
<input type="hidden" name="param_id<?php echo $i ?>"
id="param_id<?php echo $i ?>"
value="<?php echo $row_issue_items['item_id'][$x].'$'.$row_issue_items['item_type'][$x]; ?>" />
<?php $status_id = "";
$param_data = array();
$query1 = "SELECT * from inventory_parameters_status where month(param_date)='" . $m . "' and year(param_date)='" . $y . "' and shift='$shift'";
error_log("PARAMETER QUERY." . $query1);
$result1 = @mysqli_query($conn, $query1);
$remark = array();
$status_id = array();
while ($row_param = @mysqli_fetch_assoc($result1)) {
$key = $row_param['param_id'] . '_' . $row_param['param_date'];
$value = $row_param['param_status'];
$remark += array(
$key => $row_param['param_remark'],
);
$status_id += array(
$key => $row_param['status_id'],
);
// error_log(" REMARK " . print_r($remark, true));
$param_data[$key] = $value;
?>
<?php } ?>
<?php
// error_log(" REAMM " . print_r($remark, true));
$db_new_date = "";
$mm = 0;
for ($k = 1; $k <= $last_day; $k++) {
$new_date = $k . "-" . $m . "-" . $y;
$db_new_date = $y . "-" . $m . "-" . $k;
$day = date('D', strtotime($new_date));
if ($k < 10) {
$db_new_date = $y . "-" . $m . "-0" . $k;
}
?>
<?php
?>
<td>
<div style="width:80px;">
<input type="hidden" name="status_id_<?php echo $i ?>_<?php echo $k ?>"
id="status_id_<?php echo $i ?>_<?php echo $k ?>" />
<input type="checkbox"
class="<?php echo date('Y-m-d', strtotime($new_date)) ?>"
style="max-width:50%;"
<?php
$checklist_status=$_REQUEST['status'];
if($checklist_status=='APPROVED' || $checklist_status=='APPROVE') echo 'disabled'; ?>
id="param_status_<?php echo $i ?>_<?php echo $k ?>"
name="param_status_<?php echo $i ?>_<?php echo $k ?>[]"
onchange="save_params(<?php echo $i ?>,<?php echo $k ?>)" />
<br>
<input type="text" name="param_remark_<?php echo $i ?>_<?php echo $k ?>"
<?php
$checklist_status=$_REQUEST['status'];
if($checklist_status=='APPROVED' || $checklist_status=='APPROVE') echo 'disabled'; ?>
id="param_remark_<?php echo $i ?>_<?php echo $k ?>"
onchange="save_params(<?php echo $i ?>,<?php echo $k ?>)"
style="margin-left:5px;max-width:90%;" placeholder="Remarks">
<script>
$(document).ready(function() {
<?php $key = $row_issue_items['item_id'][$x].'$'.$row_issue_items['item_type'][$x] . '_' . $db_new_date; ?>
var existingParamValues<?php echo $i ?>_<?php echo $k ?> =
"<?php echo $param_data[$key] ?>"
document.getElementById(
"param_status_<?php echo $i ?>_<?php echo $k ?>"
).value =
existingParamValues<?php echo $i ?>_<?php echo $k ?>;
if (document.getElementById(
"param_status_<?php echo $i ?>_<?php echo $k ?>"
).value == "1" || document.getElementById(
"param_status_<?php echo $i ?>_<?php echo $k ?>"
).value == "on") {
document.getElementById(
"param_status_<?php echo $i ?>_<?php echo $k ?>"
).checked = true;
}
document.getElementById(
"param_remark_<?php echo $i ?>_<?php echo $k ?>"
).value = "<?php
echo $remark[$key]; ?>";
document.getElementById(
"status_id_<?php echo $i ?>_<?php echo $k ?>"
).value = "<?php
echo $status_id[$key]; ?>";
});
</script>
</div>
</td>
<input type="hidden" name="param_date_<?php echo $i ?>_<?php echo $k ?>"
id="param_date_<?php echo $i ?>_<?php echo $k ?>"
value="<?php echo $new_date ?>" />
<?php } ?>
</tr>
<?php
$count++;
$i++;
};
?>
</tbody>
<tfoot>
<!-- <tr>
<td></td>
<td><strong>Inspected By</strong></td>
<?php
$db_new_date = "";
for ($k = 1; $k <= $last_day; $k++) {
$new_date = $k . "-" . $m . "-" . $y;
$db_new_date = $y . "-" . $m . "-" . $k;
$day = date('D', strtotime($new_date));
if ($k < 10) {
$db_new_date = $y . "-" . $m . "-0" . $k;
}
?>
<td></td>
<?php } ?>
</tr> -->
</tr>
</tfoot>
</table>
<input type="hidden" name="count_items" id="count_items" value="<?php echo $count - 1 ?>" />
<input type="hidden" name="last_day" id="last_day" value="<?php echo $last_day ?>" />
</div>
</div>
</div>
<!-- End box-body-->
<!--box-footer-->
<!-- <div class="box-footer" style="text-align: center;">
<button class="btn btn-info save_button" type="button"
id="save_button" onclick="validate();">
<i class="ace-icon fa fa-floppy-o bigger-110"></i> Save
</button>
&nbsp; &nbsp; &nbsp;
<button class="btn btn-warning" type="reset">
<i class="ace-icon fa fa-undo bigger-110"></i> Reset
</button>
</div> -->
<!--End box-footer-->
</div>
<!-- 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>
<!--breadcrumb-->
<div class="main-content">
<div class="main-content-inner">
<!-- End of breadcrumb -->
<div class="page-content">
<div id="flexigridDiv" class="table-responsive">
<form>
<input type="hidden" name="f1" method="post" id="flex_notice_form">
<div id="flex1" style="width: 100%">
<input type="hidden" name="flex_notice_id" id="flex_notice_id" />
</div>
</form>
<form name="export_form" method="post" id="export_form" action="">
<input type="hidden" name="pdf_action" id="pdf_action" value="notice_pdf.php" />
<input type="hidden" name="excel_action" id="excel_action"
value="invenort_checklist_excel.php" />
</form>
</div>
</div>
</div>
<!-- /.page-content -->
</div>
</div>
<!-- /.main-content -->
</div>
<!-- End of page-content -->
</div>
</div>
</div>
<script>
var getDaysInMonth = function(year, month) {
return new Date(year, month, 0).getDate();
};
function shiftDetails() {
var shift_month = parseInt($("#shift_month").val());
var shift_year = parseInt($("#shift_year").val());
var content = "<tr><td></td><td>Date</td>";
for (var i = 1; i <= getDaysInMonth(shift_year, shift_month); i++) {
content += '<td>' + i + '</td>'
data_string = i + "/" + shift_month + "/" + shift_year
date = new Date(data_string);
}
var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
content += "<tr><td>S No.</td><td>Days/Staff Name</td>";
for (var i = 1; i <= getDaysInMonth(shift_year, shift_month); i++) {
let data_string = shift_month + "/" + i + "/" + shift_year;
let d = new Date(data_string)
content += '<td>' + days[d.getDay()] + '</td>'
}
$("#myTable").html(content);
}
function validate() {
save();
}
function myCalender() {
var month = $("#shift_month").val();
var year = $("#shift_year").val();
var open_date = '01-' + month + '-' + year;
$("#shift_calendar").val(open_date).show();
}
</script>
<style>
.table-scroll {
position: relative;
margin: auto;
overflow: hidden;
border: 1px solid #000;
}
.table-wrap {
width: 100%;
overflow: auto;
}
.table-scroll table {
width: 100%;
margin: auto;
border-collapse: separate;
border-spacing: 0;
}
.table-scroll th,
.table-scroll td {
padding: 5px 10px;
border: 1px solid #000;
background: #fff;
white-space: normal;
vertical-align: top;
}
.table-scroll thead,
.table-scroll tfoot {
background: #f9f9f9;
}
.clone {
position: absolute;
top: 0;
left: 0;
pointer-events: none;
}
.clone th,
.clone td {
visibility: hidden
}
.clone td,
.clone th {
border-color: transparent
}
.clone tbody th {
visibility: visible;
color: red;
}
.clone .fixed-side {
border: 1px solid #000;
background: #eee;
visibility: visible;
}
.clone thead,
.clone tfoot {
background: transparent;
}
</style>
<?php include('techsyn_footer.php'); ?>
<script type="text/javascript">
$('.select2').select2()
jQuery(function($) {
var myTable =
$('#dynamic-table')
.DataTable({
bAutoWidth: false,
"aoColumns": [{
"bSortable": false
},
null, null, null, null, null,
{
"bSortable": false
}
],
"aaSorting": [],
select: {
style: 'multi'
}
});
var defaultCopyAction = myTable.button(1).action();
myTable.button(1).action(function(e, dt, button, config) {
defaultCopyAction(e, dt, button, config);
$('.dt-button-info').addClass('gritter-item-wrapper gritter-info gritter-center white');
});
var defaultColvisAction = myTable.button(0).action();
myTable.button(0).action(function(e, dt, button, config) {
defaultColvisAction(e, dt, button, config);
if ($('.dt-button-collection > .dropdown-menu').length == 0) {
$('.dt-button-collection')
.wrapInner('<ul class="dropdown-menu dropdown-light dropdown-caret dropdown-caret" />')
.find('a').attr('href', '#').wrap("<li />")
}
$('.dt-button-collection').appendTo('.tableTools-container .dt-buttons')
});
setTimeout(function() {
$($('.tableTools-container')).find('a.dt-button').each(function() {
var div = $(this).find(' > div').first();
if (div.length == 1) div.tooltip({
container: 'body',
title: div.parent().text()
});
else $(this).tooltip({
container: 'body',
title: $(this).text()
});
});
}, 500);
$('#dynamic-table > thead > tr > th input[type=checkbox], #dynamic-table_wrapper input[type=checkbox]').eq(
0).on('click', function() {
var th_checked = this.checked;
$('#dynamic-table').find('tbody > tr').each(function() {
var row = this;
if (th_checked) myTable.row(row).select();
else myTable.row(row).deselect();
});
});
$('#dynamic-table').on('click', 'td input[type=checkbox]', function() {
var row = $(this).closest('tr').get(0);
if (this.checked) myTable.row(row).deselect();
else myTable.row(row).select();
});
$(document).on('click', '#dynamic-table .dropdown-toggle', function(e) {
e.stopImmediatePropagation();
e.stopPropagation();
e.preventDefault();
});
var active_class = 'active';
$('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function() {
var th_checked = this.checked;
$(this).closest('table').find('tbody > tr').each(function() {
var row = this;
if (th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0)
.prop('checked', true);
else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop(
'checked', false);
});
});
$('#simple-table').on('click', 'td input[type=checkbox]', function() {
var $row = $(this).closest('tr');
if ($row.is('.detail-row ')) return;
if (this.checked) $row.addClass(active_class);
else $row.removeClass(active_class);
});
$('[data-rel="tooltip"]').tooltip({
placement: tooltip_placement
});
function tooltip_placement(context, source) {
var $source = $(source);
var $parent = $source.closest('table')
var off1 = $parent.offset();
var w1 = $parent.width();
var off2 = $source.offset();
if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
return 'left';
}
/***************/
$('.show-details-btn').on('click', function(e) {
e.preventDefault();
$(this).closest('tr').next().toggleClass('open');
$(this).find(ace.vars['.icon']).toggleClass('fa-angle-double-down').toggleClass(
'fa-angle-double-up');
});
/***************/
})
function save_params(i, j) {
document.forms[0].target = '';
document.forms[0].action = 'javascript:void(0);';
document.forms[0].submit()
let param_year = <?=$y?>;
let param_month = <?=$m?>;
let amb_id = <?= $_POST["inventory_type2"]?>;
let shift = <?= $_POST["shift"]?>;
let item_cat = "<?=$_POST["inventory_item_type2"]?>";
let issue_type = "<?=$_POST["issue_type"]?>";
if (item_cat == '' || item_cat == null) {
item_cat = "ALL";
}
var box = document.getElementById("param_status_" + i + "_" + j);
if (box.checked == true) {
document.getElementById("param_status_" + i + "_" + j).value = 1;
} else {
document.getElementById("param_status_" + i + "_" + j).value = 0;
}
var formData = {
ambulance_id: $("#ambulance_id").val(),
shift: $("#shift").val(),
param_status: $("#param_status_" + i + "_" + j).val(),
param_remark: $("#param_remark_" + i + "_" + j).val(),
param_id: $("#param_id" + i).val(),
param_date: $("#param_date_" + i + "_" + j).val(),
status_id: $("#status_id_" + i + "_" + j).val(),
param_year: param_year,
param_month: param_month,
amb_id: amb_id,
item_cat: item_cat,
status: status,
shift: shift,
issue_type: issue_type,
};
// alert($("#param_id" + i).val());
$.ajax({
url: 'save_inventory_parameters.php',
type: "POST",
data: formData,
dataType: 'json',
success: function(data) {
if (data.is_inseted != 0) {
checklist_approval("PENDING");
}
$("#status_id_" + i + "_" + j).val(data.max_st_id);
$('.close').click();
// BootstrapDialog.alert('checklist Details Saved Successfully.');
// $("#flex1").flexReload();
// return;
},
error: function(data) {
BootstrapDialog.alert('Error Saving Ambulance Details');
return;
}
});
}
$('.date-picker').datepicker({
autoclose: true,
format: 'dd/mm/yyyy'
}).next().on(ace.click_event, function() {
$(this).prev().focus();
});
</script>
<!-- bootstrap & fontawesome -->
<link rel="stylesheet" href="assets/font-awesome/4.5.0/css/font-awesome.min.css" />
<!-- page specific plugin styles -->
<link rel="stylesheet" href="assets/css/jquery-ui.custom.min.css" />
<link rel="stylesheet" href="assets/css/chosen.min.css" />
<link rel="stylesheet" href="assets/css/bootstrap-datepicker3.min.css" />
<link rel="stylesheet" href="assets/css/bootstrap-timepicker.min.css" />
<link rel="stylesheet" href="assets/css/daterangepicker.min.css" />
<link rel="stylesheet" href="assets/css/bootstrap-datetimepicker.min.css" />
<link rel="stylesheet" href="assets/css/bootstrap-colorpicker.min.css" />
<script type="text/javascript" src="js/typeahead.bundle.js"></script>
<script src="assets/js/jquery-ui.custom.min.js"></script>
<script src="assets/js/jquery.ui.touch-punch.min.js"></script>
<script src="assets/js/chosen.jquery.min.js"></script>
<script src="assets/js/spinbox.min.js"></script>
<script src="assets/js/bootstrap-datepicker.min.js"></script>
<script src="assets/js/bootstrap-timepicker.min.js"></script>
<script src="assets/js/jquery.dataTables.min.js"></script>
<script src="assets/js/jquery.dataTables.bootstrap.min.js"></script>
<script src="assets/js/dataTables.buttons.min.js"></script>
<script src="assets/js/buttons.flash.min.js"></script>
<script src="assets/js/buttons.html5.min.js"></script>
<script src="assets/js/buttons.print.min.js"></script>
<script src="assets/js/buttons.colVis.min.js"></script>
<script src="assets/js/dataTables.select.min.js"></script>
<script src="assets/js/moment.min.js"></script>
<script src="assets/js/daterangepicker.min.js"></script>
<script src="assets/js/bootstrap-datetimepicker.min.js"></script>
<script src="assets/js/bootstrap-colorpicker.min.js"></script>
<script src="assets/js/jquery.knob.min.js"></script>
<script src="assets/js/autosize.min.js"></script>
<script src="assets/js/jquery.inputlimiter.min.js"></script>
<script src="assets/js/jquery.maskedinput.min.js"></script>
<script src="assets/js/bootstrap-tag.min.js"></script>
<script src="assets/js/ace-elements.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
const select = document.getElementById('myselect');
});
</script>
<script type="text/javascript">
jQuery(function($) {
$('#id-disable-check').on('click', function() {
var inp = $('#form-input-readonly').get(0);
if (inp.hasAttribute('disabled')) {
inp.setAttribute('readonly', 'true');
inp.removeAttribute('disabled');
inp.value = "This text field is readonly!";
} else {
inp.setAttribute('disabled', 'disabled');
inp.removeAttribute('readonly');
inp.value = "This text field is disabled!";
}
});
if (!ace.vars['touch']) {
$('.chosen-select').chosen({
allow_single_deselect: true
});
$(window)
.off('resize.chosen')
.on('resize.chosen', function() {
$('.chosen-select').each(function() {
var $this = $(this);
$this.next().css({
'width': $this.parent().width()
});
})
}).trigger('resize.chosen');
//resize chosen on sidebar collapse/expand
$(document).on('settings.ace.chosen', function(e, event_name, event_val) {
if (event_name != 'sidebar_collapsed') return;
$('.chosen-select').each(function() {
var $this = $(this);
$this.next().css({
'width': $this.parent().width()
});
})
});
$('#chosen-multiple-style .btn').on('click', function(e) {
var target = $(this).find('input[type=radio]');
var which = parseInt(target.val());
if (which == 2) $('#form-field-select-4').addClass('tag-input-style');
else $('#form-field-select-4').removeClass('tag-input-style');
});
}
$('[data-rel=tooltip]').tooltip({
container: 'body'
});
$('[data-rel=popover]').popover({
container: 'body'
});
autosize($('textarea[class*=autosize]'));
$('textarea.limited').inputlimiter({
remText: '%n character%s remaining...',
limitText: 'max allowed : %n.'
});
//"jQuery UI Slider"
//range slider tooltip example
$("#slider-range").css('height', '200px').slider({
orientation: "vertical",
range: true,
min: 0,
max: 100,
values: [17, 67],
slide: function(event, ui) {
var val = ui.values[$(ui.handle).index() - 1] + "";
if (!ui.handle.firstChild) {
$("<div class='tooltip right in' style='display:none;left:16px;top:-6px;'><div class='tooltip-arrow'></div><div class='tooltip-inner'></div></div>")
.prependTo(ui.handle);
}
$(ui.handle.firstChild).show().children().eq(1).text(val);
}
}).find('span.ui-slider-handle').on('blur', function() {
$(this.firstChild).hide();
});
$("#slider-range-max").slider({
range: "max",
min: 1,
max: 10,
value: 2
});
$("#slider-eq > span").css({
width: '90%',
'float': 'left',
margin: '15px'
}).each(function() {
// read initial values from markup and remove that
var value = parseInt($(this).text(), 10);
$(this).empty().slider({
value: value,
range: "min",
animate: true
});
});
$("#slider-eq > span.ui-slider-purple").slider('disable'); //disable third item
$('#id-input-file-1 , #id-input-file-2').ace_file_input({
no_file: 'No File ...',
btn_choose: 'Choose',
btn_change: 'Change',
droppable: false,
onchange: null,
thumbnail: false //| true | large
//whitelist:'gif|png|jpg|jpeg'
//blacklist:'exe|php'
//onchange:''
//
});
//pre-show a file name, for example a previously selected file
//$('#id-input-file-1').ace_file_input('show_file_list', ['myfile.txt'])
//datepicker plugin
//link
$('.date-picker').datepicker({
autoclose: true,
todayHighlight: true
})
//show datepicker when clicking on the icon
.next().on(ace.click_event, function() {
$(this).prev().focus();
});
//chosen plugin inside a modal will have a zero width because the select element is originally hidden
//and its width cannot be determined.
//so we set the width after modal is show
$('#modal-form').on('shown.bs.modal', function() {
if (!ace.vars['touch']) {
$(this).find('.chosen-container').each(function() {
$(this).find('a:first-child').css('width', '210px');
$(this).find('.chosen-drop').css('width', '210px');
$(this).find('.chosen-search input').css('width', '200px');
});
}
})
/**
//or you can activate the chosen plugin after modal is shown
//this way select element becomes visible with dimensions and chosen works as expected
$('#modal-form').on('shown', function () {
$(this).find('.modal-chosen').chosen();
})
*/
$(document).one('ajaxloadstart.page', function(e) {
autosize.destroy('textarea[class*=autosize]')
$('.limiterBox,.autosizejs').remove();
$('.daterangepicker.dropdown-menu,.colorpicker.dropdown-menu,.bootstrap-datetimepicker-widget.dropdown-menu')
.remove();
});
});
function pdf() {
$("#shift_form").attr('method', 'POST');
$("#shift_form").attr('action', 'invenort_checklist_pdf.php');
$("#shift_form").attr('target', "_blank");
// $("#shift_form").submit();
}
function checklist_approval(status) {
document.forms[0].target = '';
document.forms[0].action = 'javascript:void(0);';
document.forms[0].submit()
let param_year = <?=$y?>;
let param_month = <?=$m?>;
let amb_id = <?= $_POST["inventory_type2"]?>;
let shift = <?= $_POST["shift"]?>;
let item_cat = "<?=$_POST["inventory_item_type2"]?>";
let issue_type = "<?=$_POST["issue_type"]?>";
if (item_cat == '' || item_cat == null) {
item_cat = "ALL";
}
$.ajax({
url: 'save_inventory_parameters_status.php ',
type: "POST",
data: {
param_year: param_year,
param_month: param_month,
amb_id: amb_id,
item_cat: item_cat,
status: status,
shift: shift,
issue_type: issue_type,
},
success: function(data) {
// BootstrapDialog.alert('checklist Details Saved Successfully.');
// $("#flex1").flexReload();
if (status == 'APPROVE') {
window.location = 'pending_checklist.php';
}
// return;
},
error: function(data) {
BootstrapDialog.alert('Error Saving Ambulance Details');
return;
}
});
$('.close').click();
}
// requires jquery library
jQuery(document).ready(function() {
jQuery(".main-table").clone(true).appendTo('#table-scroll').addClass('clone');
});
function app_alert(status) {
BootstrapDialog.alert('checklist Approval Processed.');
window.location = 'pending_checklist.php';
}
function excel() {
$("#shift_form").attr('method', 'POST');
$("#shift_form").attr('action', 'invenort_checklist_excel.php');
$("#shift_form").attr('target', "_blank");
}
</script>