ESH/employee_training_schedule_list.php
2024-10-23 18:28:06 +05:30

451 lines
14 KiB
PHP

<?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'); ?>
<!--breadcrumb-->
<div class="main-content">
<div class="main-content-inner">
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
<ul class="breadcrumb">
<li class="#">WELLNESS/TRAINING Mgmt</li>
<li class="#">Employee WELLNESS/TRAINING Tracker</li>
</ul>
</div>
<!-- End of breadcrumb -->
<div class="page-content">
<div id="flexigridDiv" class="table-responsive">
<form name="f1" method="post" action="" id="">
<div id="flex1" style="width:100%">
</div>
<input type="hidden" name="flex_schedule_id" id="flex_schedule_id" />
</form>
<form name="export_form" method="post" id="export_form" action="">
<input type="hidden" name="pdf_action" id="pdf_action"
value="pdf_employee_training_schedule_list.php" />
<input type="hidden" name="excel_action" id="excel_action"
value="excel_employee_training_schedule_list.php" />
<input type="hidden" name="startDate" id="startDate" value="" />
<input type="hidden" name="endDate" id="endDate" value="" />
</form>
</div>
</div>
</div><!-- /.page-content -->
</div>
</div><!-- /.main-content -->
<script type="text/javascript">
$(function() {
var w = screen.width * .50;
var h = 0;
h = (window.innerHeight - ($("#navbar").height() + $(".breadcrumbs").height())) * .75;
$("#flex1").flexigrid({
url: 'emp_training_schedule.php',
dataType: 'json',
colModel: [{
display: 'Sr',
name: 'count',
width: w * .05,
sortable: false,
align: 'left'
},
{
display: 'Assign to',
name: '',
width: w * .2,
sortable: true,
align: 'left'
},
{
display: 'Program Name',
name: '',
width: w * .2,
sortable: true,
align: 'left'
},
{
display: 'From Date (Schedule)',
name: '',
width: w * .22,
sortable: true,
align: 'left'
},
{
display: 'To Date (Schedule)',
name: '',
width: w * .2,
sortable: true,
align: 'left'
},
{
display: 'Trainer Name',
name: '',
width: w * .2,
sortable: true,
align: 'left'
},
{
display: 'Program Location',
name: '',
width: w * .2,
sortable: true,
align: 'left'
},
{
display: 'Status',
name: '',
width: w * .15,
sortable: true,
align: 'left'
},
{
display: '',
name: '',
width: w * .1,
sortable: false,
align: 'left'
},
],
buttons: [{
name: 'PDF',
bclass: 'print',
onpress: pdf
},
{
separator: true
},
{
name: 'Excel',
bclass: 'print_excel',
onpress: excel
},
{
separator: true
}
],
searchitems: [
{
display: 'Program Name',
name: 'training_name'
},
{
display: 'From Date(DD/MM/YYYY)',
name: 'from_date'
},
{
display: 'Trainer Name',
name: 'trainer_name'
},
{
display: 'Location',
name: 'location'
},
],
sortname: "assign_training_id",
sortorder: "asc",
usepager: true, //pagination
useRp: true,
rp: 50, //records per page
showTableToggleBtn: false, //toggle button for the whole table
resizable: true,
//width: w,
height: h,
singleSelect: true
});
});
function pdf() {
window.open('ajax_pdf.php', 'Employee Training Schedule');
}
function excel() {
window.open('ajax_excel.php', 'Employee Training Schedule');
}
function open_assign_training_schedule(emp_assign_training_id) {
$("#emp_id").val("");
$("#schedule").val("");
$("#location").val("");
$("#status").val("");
$("#completion_date").val("");
$('#status').trigger('chosen:updated');
var emp = $("#emp_search").val();
$.ajax({
url: 'select_emp_assign_training.php',
type: 'POST',
data: {
emp: emp,
emp_assign_training_id: emp_assign_training_id
},
dataType: 'json',
success: function(data) {
if (data['count'] == 0) {
BootstrapDialog.alert("Training Not Assigned..!");
$('#modal-emp-assign-schedule-status').modal("show");
} else {
// console.log('====================================');
// console.log(data);
// console.log('====================================');
$("#emp_assign_training_id").val(data[0].emp_assign_training_id);
$("#assign_training_id").val(data[0].assign_training_id);
var schedule = data[0].training_name + " (" + data[0].trainer_name + ' ' + myDateFormatter(
data[0].from_date) + ' ' + myDateFormatter(data[0].to_date) + ")";
getEmployeeDetails(data[0].emp_id);
$("#schedule").val(schedule);
$("#location").val(data[0].location);
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec"
];
//alert(data[0].from_date);
const date1 = new Date(data[0].from_date);
const date2 = new Date(data[0].to_date);
let allDates = getDatesBetween(date1, date2);
var content = "";
content += `<thead style='overflow-y: scroll;'><tr><td></td><td>Date</td>`;
for (var i = 0; i < allDates.length; i++) {
content += `<td>` + allDates[i].getDate() + `-` + months[allDates[i].getMonth()] + `-` +
allDates[i].getFullYear() + `</td>`;
}
content +=
`</tr><tr><td> Sr.No. </td><td> Select All </td<td>`;
for (var i = 0; i < allDates.length; i++) {
content += `<td width='50px'><input type="checkbox" ` +
` style="margin-left:20px;max-width:50%;" id="param_status_all_` +
i +
`" name="param_status_all_` + i +
`[]" onchange="select_params(` + i + `,` + data['count'] + `)" >` +
`</td>`;
}
content += ` </td></tr> </thead><tbody>`;
for (let i = 0; i < data['count']; i++) {
content += `<tr><td>` + (i + 1) + `</td><td>` + data[i].emp_name + `</td>`;
for (var j = 0; j < allDates.length; j++) {
var month = allDates[j].getMonth() + 1;
var month = ("0" + month).slice(-2);
var day = allDates[j].getDate();
var day = ("0" + day).slice(-2);
console.log(data[i].training_dates + "----" + (allDates[j].getFullYear() +
`-` + (month) + `-` +
day));
var training_status = '';
var training_value = 0;
var training_done = '';
training_done = (data[i].training_dates.includes(allDates[j].getFullYear() +
`-` + (month) + `-` +
day));
if (training_done == "true" || training_done == true) {
training_status = "checked";
training_value = 1;
} else {
training_status = '';
training_value = 0;
}
// alert(data[0].remarks[2]);
var remarks = '';
// alert(data[i].remarks.lenght);
for (var r = 0; r < data[i].status_count; r++) {
if (data[i].remarks[r].date == (allDates[j].getFullYear() +
`-` + (month) + `-` +
day)) remarks = data[i]
.remarks[r].remarks;
// alert(remarks);
}
content += `<td><input type="checkbox" ` + training_status +
` style="margin-left:20px;max-width:50%;" id="param_status_` +
i + `_` + j +
`" name="param_status_` + i + `_` + j +
`[]" onchange="save_params(` + i + `,` + j + `)" value="` + training_value +
`">` +
`<input type="hidden" style="margin-left:20px;max-width:50%;" id="param_date_` +
i + `_` + j +
`" name="param_date_` + i + `_` + j +
`[]" onchange="save_params(` + i + `,` + j + `)" value="` + allDates[j]
.getDate() + `-` + (month) + `-` +
allDates[j].getFullYear() + `">` +
`<input type="text" style="margin-left:20px;max-width:50%;" id="param_remarks_` +
i + `_` + j +
`" name="param_remarks_` + i + `_` + j +
`[]" value="` + remarks +
`">` +
`<input type="hidden" style="margin-left:20px;max-width:50%;" id="param_emp_` +
i + `_` + j +
`" name="param_emp_` + i + `_` + j +
`[]" onchange="save_params(` + i + `,` + j + `)" value="` + data[i].emp_id +
`">` +
`</td>`;
}
content += `</tr>`;
}
content += '</tbody><tfoot><tr><td></td><td><strong>Inspected By</strong></td>';
for (var i = 0; i < allDates.length; i++) {
content += `<td>` + `` + `</td>`;
}
content += '</tr></tfoot></table>';
$('#myTable').html(content);
all_select_starus(data["count"], allDates.length);
$('#modal-emp-assign-schedule-status').modal("show");
}
},
error: function(data) {
BootstrapDialog.alert('Error Populating Training Schedule');
return;
}
});
$('.close').click();
}
function getEmployeeDetails(emp_id) {
$.ajax({
url: 'select_employee.php',
data: {
emp_id: emp_id
},
async: false,
dataType: 'json',
success: function(data) {
$("#emp_id").val(data.patient_name);
},
error: function(data) {
BootstrapDialog.alert('Error Populating Employee Details');
}
});
}
function save_emp_assign_schedule_status_form() {
$('#modal-emp-assign-schedule-status').modal("hide");
$.ajax({
url: 'save_emp_assign_status_form.php',
data: $("#emp_assign_schedule_status_form").serialize(),
type: 'POST',
success: function(data) {
BootstrapDialog.alert('Employee Assign Training Status Saved Successfully');
$("#flex1").flexReload();
},
error: function(data) {
BootstrapDialog.alert('Error In Saving Employee Assign Training Status');
}
});
}
function myDateFormatter(d) {
var date = new Date(d);
return date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear();
}
function getDatesBetween(startDate, endDate) {
const currentDate = new Date(startDate.getTime());
const dates = [];
while (currentDate <= endDate) {
dates.push(new Date(currentDate));
currentDate.setDate(currentDate.getDate() + 1);
}
return dates;
}
function select_params(i, j) {
var box = document.getElementById("param_status_all_" + i);
for (var x = 0; x < j; x++) {
if (box.checked == true) {
document.getElementById("param_status_" + x + "_" + i).value = 1;
document.getElementById("param_status_" + x + "_" + i).checked = true;
} else {
document.getElementById("param_status_" + x + "_" + i).checked = false;
document.getElementById("param_status_" + x + "_" + i).value = 0;
}
save_params(x, i);
}
}
function all_select_starus(row, clm) {
for (var i = 0; i < clm; i++) {
var all_seleced = true;
for (var j = 0; j < row; j++) {
if (document.getElementById("param_status_" + j + "_" + i).value == 0) {
all_seleced = false;
}
}
// alert(all_seleced);
document.getElementById("param_status_all_" + i).checked = all_seleced;
}
}
</script>
<?php include('techsyn_footer.php'); ?>
<?php include('form/assign_training_status_form.php');?>