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.148.112.15
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/staff_move.php |
<?php
include("sys_session.php");
include("sys_mainphp.php");
include("sys_connect.php");
$resp_mesg = "";
$resp_stat = "";
$resp_file = "";
if ($_POST['load_data'] == 'grid_data') {
require("sys_grid_data.php");
$i = 1;
if ($type_id == "ADMIN") {
$grid_sele = "select fmovecode, date_format(fstrtdate, '%d/%m/%Y') as fmovedate, sm.fdeptcode, femplname, fstrttown,fdesttown,fmovetype from staffmove sm
inner join masdept dp on sm.fdeptcode = dp.fdeptcode
inner join masempl em on sm.femplcode = em.femplcode
where sm.fdeptcode like '$_POST[dept_code]' and fmovetype like '$_POST[move_type]' and sm.femplcode like '$_POST[empl_code]'
and (fstrttown like '%$_POST[move_find]%' or fdesttown like '%$_POST[move_find]%')
and sm.fdeleted='F' order by fstrtdate desc";
} elseif ($type_id == "CHIEF") {
$grid_sele = "select fmovecode, date_format(fstrtdate, '%d/%m/%Y') as fmovedate, sm.fdeptcode, femplname, fstrttown,fdesttown,fmovetype from staffmove sm
inner join masdept dp on sm.fdeptcode = dp.fdeptcode
inner join masempl em on sm.femplcode = em.femplcode
inner join masdept_user du on sm.fdeptcode = du.fdeptcode and du.fusercode = '$user_id'
where sm.fdeptcode like '$_POST[dept_code]' and fmovetype like '$_POST[move_type]' and sm.femplcode like '$_POST[empl_code]'
and (fstrttown like '%$_POST[move_find]%' or fdesttown like '%$_POST[move_find]%')
and sm.fdeleted='F' order by fstrtdate desc";
// $grid_sele = "select * from staffmove
// where fdeptcode='$dept_code' and fmovetype like '$move_type' and (fstrttown like '%$move_find%' or fdesttown like '%$move_find%') and fdeleted='F'
// order by fstrtdate desc";
} else {
$grid_sele = "select fmovecode, date_format(fstrtdate, '%d/%m/%Y') as fmovedate, sm.fdeptcode, femplname, fstrttown,fdesttown,fmovetype from staffmove sm
inner join masdept dp on sm.fdeptcode = dp.fdeptcode
inner join masempl em on sm.femplcode = em.femplcode
inner join masdept_user du on sm.fdeptcode = du.fdeptcode and du.fusercode = '$user_id'
where sm.fdeptcode like '$_POST[dept_code]' and fmovetype like '$_POST[move_type]' and sm.femplcode like '$_POST[empl_code]'
and (fstrttown like '%$_POST[move_find]%' or fdesttown like '%$_POST[move_find]%')
and sm.femplcode='$empl_id'
and sm.fdeleted='F' order by fstrtdate desc";
// $grid_sele = "select * from staffmove
// where fdeptcode='$dept_code' and fmovetype like '$move_type' and (fstrttown like '%$move_find%' or fdesttown like '%$move_find%') and femplcode='$empl_id' and fdeleted='F'
// order by fstrtdate desc";
}
$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='25%'> Name</th>";
echo "<th width='5%'> Dept</th>";
echo "<th width='15%'> From Place </th>";
echo "<th width='15%'> To Place </th>";
echo "<th width='10%'> Purpose </th>";
echo "<th width='15%'> 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[fmovecode]')>Edit</a>";
$page_link .= " <a class='btn btn-danger btn-sm' href=# onClick=dele_data('$myrow[fmovecode]')>Delete</a>";
echo "<tr>";
echo "<td align='center'>$i</td>";
echo "<td align='center'>$myrow[fmovedate]</td>";
echo "<td align='left'> $myrow[femplname]</td>";
echo "<td align='center'>$myrow[fdeptcode]</td>";
echo "<td align='left'> $myrow[fstrttown]</td>";
echo "<td align='left'> $myrow[fdesttown]</td>";
echo "<td align='center'>$myrow[fmovetype]</td>";
echo "<td 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 ($_POST['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=''>--Select--</option>";
}
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<option value='$myrow[fdeptcode]'>$myrow[fdeptname]</option>";
}
}
if ($_POST['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 femplstat='T' order by femplname";
}
$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[femplcode]'>$myrow[femplname]</option>";
}
}
if ($_POST['load_data'] == 'town_list') {
$mysql = "select * from mastown order by ftownname";
$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[ftownname]'>$myrow[ftownname]</option>";
}
}
if ($_POST['load_data'] == 'disp_data') {
$disp_code = $_POST['disp_code'];
$mysql = "select * from staffmove where fmovecode='$disp_code'";
$myres = mysqli_query($mycon, $mysql);
$myrows = array();
while ($r = mysqli_fetch_assoc($myres)) {
$myrows = $r;
}
echo json_encode($myrows);
}
if ($_POST['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 ($_POST['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!";
$empl_name = get_empl_name($_POST['empl_code']);
set_user_logs($dept_id, $user_id, 'MOVE', $empl_name . ' POSTED MOVEMENT FROM ' . $_POST['strt_town'] . ' TO ' . $_POST['dest_town'] . ' ON ' . $_POST['move_date']);
} 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));
}
|