Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.145.40.234
<?php
include("sys_session.php");
include("sys_mainphp.php");
include("sys_connect.php");
$load_data = $_POST['load_data'];
$inpt_errs = "F";
$resp_mesg = "";
$resp_stat = "";
$resp_file = "";
if ($load_data == 'grid_data') {
require("sys_grid_data.php");
$i = 1;
if ($type_id == "ADMIN") {
$myqry = "";
} else {
$myqry = " inner join masdept_user du on hd.fdeptcode = du.fdeptcode and du.fusercode='$user_id' ";
}
if ($_POST['date_type']=='upcoming'){
$myqry2 = "and hd.fholidate >= current_date() ";
}else{
$myqry2 = "and hd.fholidate like '%$_POST[date_type]%' ";
}
$grid_sele = "select concat('[',dp.fdeptcode,'] ',fdeptname) as ldeptname, fholicode,date_format(fholidate,'%d/%m/%Y') as lholidate,fholidesc,hd.fdeptcode from masholiday hd
inner join masdept dp on hd.fdeptcode = dp.fdeptcode " . $myqry . "
where hd.fdeptcode like '%$_POST[dept_code]%' and ifnull(fholidesc,'') like '%$_POST[holi_find]%' and ifnull(hd.fdeleted,'F')<>'T'". $myqry2 ."
order by hd.fholidate desc,hd.fdeptcode";
$grid_para = grid_limit($grid_sele);
$page_numb = $grid_para[0];
$last_page = $grid_para[1];
$page_limt = $grid_para[2];
$lowr_limt = $grid_para[3];
$mysql = $grid_sele . " limit $lowr_limt, $page_limt";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt > 0) {
echo "<table>";
echo "<thead>";
echo "<tr>";
echo "<th width='5%'> # </th>";
echo "<th width='10%'> Date </th>";
echo "<th width='35%'> Client </th>";
echo "<th width='40%'> Description </th>";
echo "<th width='10%'> Action </th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while ($myrow = mysqli_fetch_assoc($myres)) {
$page_link = "<a class='btn btn-success btn-sm' href=# onClick=edit_data('$myrow[fholicode]')><span class='glyphicon glyphicon-edit'></span></a>";
$page_link .= " <a class='btn btn-danger btn-sm' href=# onClick=dele_data('$myrow[fholicode]')><span class='glyphicon glyphicon-trash'></span></a>";
echo "<tr>";
echo "<td align='center'>$i</td>";
echo "<td align='center'>$myrow[lholidate]</td>";
echo "<td align='left'>$myrow[ldeptname]</td>";
echo "<td align='left'>$myrow[fholidesc]</td>";
echo "<td align='center'> $page_link</td>";
echo "</tr>";
$i++;
}
echo "</tbody>";
echo "</table>";
include("sys_grid_navbar.php");
} else {
echo "<div class='alert alert-info'>No details found!</div>";
}
}
if ($load_data == 'dele_data') {
$mysql = "select * from attendance where concat(fattndate,fattndept) in (select concat(fholidate,fdeptcode) from masholiday where fholicode='$_POST[dele_code]');";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if($mycnt == 0){
$mysql = "delete from masholiday where fholicode='$_POST[dele_code]';";
$myres = mysqli_query($mycon, $mysql);
}
else{
$resp_mesg = "Holiday exists in attendance, cannot be deleted!";
$resp_stat = "F";
}
echo json_encode(array("errs" => $inpt_errs, "stat" => $resp_stat, "mesg" => $resp_mesg, "file" => $resp_file));
}
if ($load_data == 'disp_data') {
$mysql = "select * from masholiday where fholicode='$_POST[disp_code]'";
$myres = mysqli_query($mycon, $mysql);
$myrows = array();
while ($r = mysqli_fetch_assoc($myres)) {
$myrows = $r;
}
echo json_encode($myrows);
}
if ($load_data == 'dept_data') {
$holi_date = $_POST['holi_date'];
$load_type = $_POST['load_type'];
if($load_type=='add'){
$mysql = "select dp.fdeptcode,dp.fdeptname,dp.fdeptshrt from masdept dp
left join masholiday hl on dp.fdeptcode = hl.fdeptcode and fholidate=str_to_date('$holi_date','%d/%m/%Y')
where dp.fdeptstat='T' and dp.fholienbl='T' and ifnull(dp.fdeleted,'F')<>'T' and hl.fdeptcode is null
order by fdeptname;";
}
else{
$mysql = "select dp.fdeptcode,dp.fdeptname,dp.fdeptshrt from masdept dp where dp.fdeptstat='T' and dp.fholienbl='T' and ifnull(dp.fdeleted,'F')<>'T' order by fdeptname;";
}
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) > 1) {
echo "<option value=%>--SELECT--</option>";
}
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<option value='$myrow[fdeptcode]'>$myrow[fdeptname] [$myrow[fdeptcode]] [$myrow[fdeptshrt]]</option>";
}
}
if ($load_data == 'save_data') {
// IF(date_format($_POST['holi_date'],'Y-m-d')<date('Y-m-d')){
// $resp_mesg = "Holiday cannot be added for past dates!";
// $inpt_errs = "T";
// }
if ($inpt_errs != "T") {
$page_mode = $_POST['page_mode'];
$holi_desc = str_replace("'", "`", $_POST['holi_desc']);
$mysql = "select * from masholiday where fdeptcode='$_POST[dept_code]' and fholidate=str_to_date('$_POST[holi_date]','%d/%m/%Y')";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($page_mode == "add") {
if ($mycnt == 0) {
$mysql = "insert into masholiday (fdeptcode,fholidate,fholidesc,fupdtuser,fupdttime,fdeleted) values('$_POST[dept_code]',str_to_date('$_POST[holi_date]','%d/%m/%Y') ,ucase('$_POST[holi_desc]'),'$user_id',now(),'F')";
$myres = mysqli_query($mycon, $mysql);
$resp_mesg = "Holiday added!";
} else {
$resp_mesg = "Holiday already exists!";
$resp_stat = "F";
}
} else {
$mysql = "update masholiday set fdeptcode='$_POST[dept_code]',fholidesc=ucase('$_POST[holi_desc]'),fupdtuser='$user_id',fupdttime=now()
where fholicode='$_POST[holi_code]'";
$myres = mysqli_query($mycon, $mysql);
$resp_mesg = "Details updated!";
}
}
echo json_encode(array("errs" => $inpt_errs, "stat" => $resp_stat, "mesg" => $resp_mesg, "file" => $resp_file));
}
|