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.15.10.87
<?php
include("sys_session.php");
include("sys_mainphp.php");
include("sys_connect.php");
$load_data=$_POST['load_data'];
$resp_mesg="";
$resp_stat="";
$resp_file="";
if($load_data=='grid_data')
{
$dept_find=$_POST['dept_find'];
require("sys_grid_data.php");
$i=1;
if($type_id=="ADMIN")
{
$grid_sele = "select * from masdept where fdeptname like '%$dept_find%'";
}
elseif ($type_id=="CHIEF")
{
$grid_sele = "select * from masdept where fdeptname like '%$dept_find%' and fdepthead='$empl_id' ";
}
else
{
$grid_sele = "select * from masdept where fdeptname like '%$dept_find%' and fdeptcode='$dept_id' ";
}
$grid_sele.=" and ifnull(fdeleted,'F')<>'T' order by fdeptname";
$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> # </th>";
echo "<th> Code </th>";
echo "<th> Department Name </th>";
echo "<th> Department Head </th>";
echo "<th> Action </th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysqli_fetch_assoc($myres))
{
$page_link ="<a class='grid_link' href=# onClick=edit_data('$row[fdeptcode]')>Edit</a> | ";
$page_link.="<a class='grid_link' href=# onClick=dele_data('$row[fdeptcode]')>Delete</a>";
if($row['fdeptstat']=='T'){$page_link.=" | <a class='grid_link' href=# onClick=inac_dept('$row[fdeptcode]')>Deactivate</a>";}
if($row['fdeptstat']!='T'){$page_link.=" | <a class='grid_link' href=# onClick=actv_dept('$row[fdeptcode]')>Activate</a>";}
$dept_head=get_empl_name($row['fdepthead']);
echo "<tr>";
echo "<td width='5%' align='center'> $i</td>";
echo "<td width='10%' align='center'>$row[fdeptcode]</td>";
echo "<td width='40%' align='left'> $row[fdeptname]</td>";
echo "<td width='20%' align='center'> $dept_head</td>";
echo "<td width='25%' align='left'>$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=='dept_head')
{
$mysql="select * from masempl where femplstat='T' and fusertype in (select fusertype from sys_user_type where fuserordr<2) order by femplname";
$myres=mysqli_query($mycon,$mysql);
if(mysqli_num_rows($myres)>1)
{
echo "<option value=0>--Select--</option>";
}
while($row = mysqli_fetch_assoc($myres))
{
echo "<option value='$row[femplcode]'>$row[femplname]</option>";
}
}
if($load_data=='dept_time')
{
$mysql="select * from mastime order by ftimecode";
$myres=mysqli_query($mycon,$mysql);
if(mysqli_num_rows($myres)>1)
{
echo "<option value=0>--Select--</option>";
}
while($row = mysqli_fetch_assoc($myres))
{
echo "<option value='$row[ftimecode]'>$row[ftimedesc]</option>";
}
}
if($load_data=='actv_dept')
{
$mysql="update masdept set fdeptstat='T' where fdeptcode='$_POST[prim_code]'";
$myres=mysqli_query($mycon,$mysql);
}
if($load_data=='inac_dept')
{
$mysql="update masdept set fdeptstat='F' where fdeptcode='$_POST[prim_code]'";
$myres=mysqli_query($mycon,$mysql);
}
if($load_data=='dele_data')
{
$dept_code = $_POST['dele_code'];
$mysql="update masdept set fdeleted='T' where fdeptcode='$dept_code'";
$myres=mysqli_query($mycon,$mysql);
}
if($load_data=='disp_data')
{
$dept_code=$_POST['dept_code'];
$mysql="select * from masdept where fdeptcode='$dept_code'";
$myres=mysqli_query($mycon,$mysql);
$rows = array();
while($r = mysqli_fetch_assoc($myres))
{
$rows = $r;
}
echo json_encode($rows);
}
if($load_data=='save_data')
{
$page_mode=$_POST['page_mode'];
$dept_code=$_POST['dept_code'];
$dept_name=$_POST['dept_name'];
$dept_head=$_POST['dept_head'];
$dept_stat=$_POST['dept_stat'];
$attn_updt=$_POST['attn_updt'];
$salr_comp=$_POST['salr_comp'];
$logi_time=$_POST['logi_time'];
$logo_time=$_POST['logo_time'];
$expn_date=$_POST['expn_date'];
$code_rate=$_POST['code_rate'];
$dept_bank=$_POST['dept_bank'];
$mysql="select * from masdept where fdeptcode='$dept_code'";
$myres=mysqli_query($mycon,$mysql);
$mycnt=mysqli_num_rows($myres);
if($page_mode=="add")
{
if($mycnt==0)
{
$mysql="insert into masdept (fdeptcode,fdeptname,fdepthead, fdeptstat, fattnupdt, fsalrcomp, fcoderate,fdeptbank,fdeleted) values('$dept_code','$dept_name','$dept_head' ,'$dept_stat','$attn_updt','$salr_comp', '$code_rate','$dept_bank','F')";
$myres=mysqli_query($mycon,$mysql);
$resp_mesg="Details inserted!";
}
else
{
$resp_mesg="Department already exists!";
$resp_stat="F";
}
}
else
{
if($mycnt==0)
{
$resp_mesg="Department does not exists!";
$resp_stat="F";
}
else
{
$mysql="update masdept set fdeptname='$dept_name',fdepthead='$dept_head', fdeptstat='$dept_stat', fattnupdt='$attn_updt', fsalrcomp='$salr_comp', flogitime='$logi_time', flogotime='$logo_time' , fexpndate=str_to_date('$expn_date','%d-%m-%Y'), fcoderate='$code_rate' , fdeptbank='$dept_bank' where fdeptcode='$dept_code'";
$myres=mysqli_query($mycon,$mysql);
$resp_mesg="Details updated!";
}
}
echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));
}
?>
|