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 : 18.117.156.84
<?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')
{
if (!(isset($_POST['page_numb'])))
{$page_numb = 1;}
else
{$page_numb = intval($_POST['page_numb']);}
$page_limt = ($_POST["page_limt"] <> "" && is_numeric($_POST["page_limt"]) ) ? intval($_POST["page_limt"]) : 10;
if($type_id=="ADMIN")
{
$grid_query="select * from documents where ifnull(fdeleted,'F')<>'T' order by fdocsdate desc";
}
elseif($type_id=="CHIEF")
{
$grid_query="select * from documents where fdeptcode in (select fdeptcode from masdept where fdepthead='$empl_id') and ifnull(fdeleted,'F')<>'T' order by fdocsdate desc";
}
else
{
$grid_query="select * from documents where femplcode='$empl_id' and ifnull(fdeleted,'F')<>'T' order by fdocsdate desc";
}
$myres=mysqli_query($mycon,$grid_query);
$mycnt=mysqli_num_rows($myres);
$last_page=ceil($mycnt/$page_limt);
if ($page_numb < 1)
{$page_numb = 1;}
elseif ($page_numb > $last_page)
{$page_numb = $last_page;}
if($last_page==0)
{$lowr_limt = ($page_numb) * $page_limt;}
else
{$lowr_limt = ($page_numb-1) * $page_limt;}
$i=1;
$mysql=$grid_query." limit $lowr_limt, $page_limt";
if($myres=mysqli_query($mycon,$mysql))
{
echo "<table class='table_grid' border=1>";
echo "<tr>";
echo "<th> # </th>";
echo "<th> Date </th>";
echo "<th> Document Title </th>";
echo "<th> Created By </th>";
echo "<th> Action </th>";
echo "</tr>";
while($row = mysqli_fetch_assoc($myres))
{
$page_link ="<a class='grid_link' href=# onClick=edit_data('$row[fdocscode]')>Edit</a>";
$page_link.=" | <a class='grid_link' href=# onClick=dele_data('$row[fdocscode]')>Delete</a>";
$page_link.=" | <a class='grid_link' href=# onClick=view_data('$row[fdocscode]')>View</a>";
$docs_date = date('d-m-Y',strtotime($row["fdocsdate"]));
$empl_name = get_empl_name($row["femplcode"]);
echo "<tr>";
echo "<td width=4% align=center>$i</td>";
echo "<td width=10% align=center>$docs_date</td>";
echo "<td width=35% align=left>$row[fdocstitl]</td>";
echo "<td width=20% align=left>$row[fdeptcode]/$empl_name</td>";
echo "<td width=15% align=center>$page_link</td>";
echo "</tr>";
$i++;
}
//NAVIGATION
echo "<tr>";
echo "<th align='center' colspan='9'>";
echo "<div style='width:80%;float:left;text-align:left;'>Pages: ";
if (($page_numb-1) > 0)
{
echo "<a href='javascript:void(0);' onclick='load_grid_data($page_limt,1);'> First</a>";
echo "<a href='javascript:void(0);' onclick='load_grid_data($page_limt,$page_numb-1);'> Previous</a>";
}
for($i=1; $i<=$last_page; $i++)
{
if ($i == $page_numb){echo "<a href='javascript:void(0);' class='selected'> $i</a>";}
else{echo "<a href='javascript:void(0);' onclick='load_grid_data($page_limt,$i);'> $i</a>";}
}
if (($page_numb+1) <= $last_page){echo "<a href='javascript:void(0);' onclick='load_grid_data($page_limt,$page_numb+1);'> Next</a>";}
if (($page_numb) != $last_page){echo "<a href='javascript:void(0);' onclick='load_grid_data($page_limt,$last_page);'> Last</a>";}
echo "</div>";
echo "<div style='width:20%;float:right; text-align:right;'>Rows / Page - ";
echo "<select onChange='load_page_limt(this.value);' style='width:50px;'>";
?>
<option value="15" <?php if ($_POST["page_limt"] == 15) { echo ' selected="selected"'; } ?> >15</option>
<option value="20" <?php if ($_POST["page_limt"] == 20) { echo ' selected="selected"'; } ?> >20</option>
<option value="40" <?php if ($_POST["page_limt"] == 40) { echo ' selected="selected"'; } ?> >40</option>
<option value="50" <?php if ($_POST["page_limt"] == 50) { echo ' selected="selected"'; } ?> >50</option>
<option value="100" <?php if ($_POST["page_limt"] == 100) { echo ' selected="selected"'; } ?> >100</option>
<?php
echo "</select>";
echo "</div>";
echo "</th>";
echo "</tr>";
echo "</table>";
//NAVIGATION ENDS
}
}
if($load_data=='dept_data')
{
if($type_id=='ADMIN')
{
$mysql="select * from masdept where fdeleted<>'T' and ifnull(fdeleted,'F')='F' order by fdeptcode";
}
elseif($type_id=='CHIEF')
{
$mysql="select * from masdept where fdepthead='$empl_id' and ifnull(fdeleted,'F')='F' order by fdeptname";
}
else
{
$mysql="select * from masdept where fdeptcode='$dept_id' and ifnull(fdeleted,'F')='F' order by fdeptcode";
}
$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[fdeptcode]'>$row[fdeptname]</option>";
}
}
if($load_data=='empl_data')
{
$dept_code=$_POST["dept_code"];
if($type_id=='ADMIN')
{
$mysql="select * from masempl where fdeptcode='$dept_code' and femplstat='T' order by femplname";
}
elseif($type_id=='CHIEF')
{
$mysql="select * from masempl where fdeptcode='$dept_code' and femplstat='T' order by femplname";
}
else
{
$mysql="select * from masempl where femplcode='$empl_id' and fdeptcode='$dept_code' and femplstat='T' 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=='strt_town')
{
$mysql="select * from mastown order by ftownname";
$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[ftownname]'>$row[ftownname]</option>";
}
}
if($load_data=='dest_town')
{
$strt_town=$_POST["strt_town"];
$mysql="select * from mastown where ftownname<>'$strt_town' order by ftownname";
$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[ftownname]'>$row[ftownname]</option>";
}
}
if($load_data=='disp_data')
{
$disp_code=$_POST['disp_code'];
$mysql="select * from staffmove where fmovecode='$disp_code'";
$myres=mysqli_query($mycon,$mysql);
$rows = array();
while($r = mysqli_fetch_assoc($myres))
{
$rows = $r;
}
echo json_encode($rows);
}
if($load_data=='dele_data')
{
$dele_code = $_POST['dele_code'];
$mysql="update staffmove set fdeleted='T' where fmovecode='$dele_code'";
$myres=mysqli_query($mycon,$mysql);
}
if($load_data=='save_data')
{
$page_mode=$_POST['page_mode'];
if($page_mode=="add")
{
$mysql ="insert into staffmove (fstrtdate, fdeptcode, femplcode, fstrttown, fdesttown, fmovetype, fmovestat, fmoveremk, ";
$mysql.="fupdtuser, fupdttime) values(str_to_date('$_POST[move_date]','%d-%m-%Y'), ";
$mysql.="'$_POST[dept_code]', '$_POST[empl_code]', '$_POST[strt_town]', '$_POST[dest_town]', ";
$mysql.="'$_POST[move_type]', '$_POST[move_stat]', '$_POST[move_remk]' , '$user_id' ,now())";
$myres=mysqli_query($mycon,$mysql);
$resp_mesg="Details inserted!";
}
else
{
$mysql ="update staffmove set fdeptcode='$_POST[dept_code]', femplcode='$_POST[empl_code]',";
$mysql.="fstrtdate=str_to_date('$_POST[move_date]','%d-%m-%Y'), ";
$mysql.="fstrttown='$_POST[strt_town]', fdesttown='$_POST[dest_town]', fmovetype='$_POST[move_type]', fmovestat='$_POST[move_stat]', ";
$mysql.="fmoveremk='$_POST[move_remk]', fupdtuser='$user_id', fupdttime=now() where fmovecode='$_POST[move_code]'";
$myres=mysqli_query($mycon,$mysql);
$resp_mesg="Details updated!";
}
echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));
}
?>
|