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.4.70
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/user_departments.php |
<?php
include("sys_session.php");
include("sys_connect.php");
include("sys_mainphp.php");
$load_data = $_POST['load_data'];
$resp_mesg = "";
$resp_stat = "";
$resp_file = "";
if ($load_data == 'dept_type') {
$mysql = "select * from masdept_type where ifnull(fdeleted,'F')='F' order by ftypeordr";
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) > 1) {
echo "<option value='%'>ALL [TYPES]</option>";
}
while ($row = mysqli_fetch_assoc($myres)) {
echo "<option value='$row[fdepttype]'>$row[ftypedesc] [$row[fdepttype]]</option>";
}
}
if ($load_data == 'user_data') {
$dept_code = $_POST["dept_code"];
$mysql = "select dp.fdeptcode,dp.fdeptshrt,em.femplcode,em.femplname,em.fusercode from masempl em
inner join masdept dp on em.fdeptcode = dp.fdeptcode
where ifnull(fusercode,'')<>'' and ifnull(em.fdeleted,'F')<>'T' and ifnull(em.femplstat,'F')='T'
order by em.femplname";
echo "<option value=0>--Select--</option>";
$myres = mysqli_query($mycon, $mysql);
while ($row = mysqli_fetch_assoc($myres)) {
echo "<option value='$row[fusercode]'>$row[femplname] [$row[femplcode]] [$row[fdeptcode]] [$row[fdeptshrt]]</option>";
}
}
if ($load_data == 'disp_data') {
$dept_type = $_POST['dept_type'];
$dept_stat = $_POST['dept_stat'];
echo "<table id='menu_grid' class=' table-bordered' style='max-width:1000px;margin-left:auto;margin-right:auto;'>";
echo "<tr>";
echo "<th width='5%'> # </th>";
echo "<th width='50%'> Client Name</th>";
echo "<th width='25%'> Client Type</th>";
echo "<th width='15%'> Client Status</th>";
echo "<th width='5%'> <input type='checkbox' id='selectstat' name='selectstat' onClick='select_stat();'/></th>";
echo "</tr>";
$mysql = "select dp.fdeptcode,dp.fdeptname,dp.fdeptshrt,dp.fdeptstat,dt.fdepttype,dt.ftypedesc,ifnull(du.fdeptcode,'') as fuserdept
from masdept dp
left join masdept_type dt on dp.fdepttype = dt.fdepttype
left join masdept_user du on dp.fdeptcode = du.fdeptcode and fusercode='$_POST[user_code]'
where dp.fdepttype like '$_POST[dept_type]' and dp.fdeptstat like '$_POST[dept_stat]'
order by du.fdeptcode desc,dp.fdeptcode";
$myres = mysqli_query($mycon, $mysql);
$i = 1;
while ($myrow = mysqli_fetch_assoc($myres)) {
$select_stat = "";
if ($myrow['fuserdept'] != "") {
$select_stat = 'checked="checked"';
}
$dept_stat = $myrow['fdeptstat'] == 'T' ? "ACTIVE" : "INACTIVE";
echo "<tr>";
echo "<input type=hidden name=txtuserdept[] id=txtuserdept[] value=$myrow[fdeptcode]>";
echo "<td align=center>$i</td>";
echo "<td align=left> [$myrow[fdeptcode]] $myrow[fdeptname]</td>";
echo "<td align=center>$myrow[ftypedesc]</td>";
echo "<td align=center>$dept_stat</td>";
echo "<td align=center><input type=checkbox name=chkselestat[] id=chkselestat[] $select_stat></td>";
echo "</tr>";
$i++;
}
echo "</table>";
}
if ($load_data == 'save_data') {
$dept_code = $_POST['dept_code'];
$user_code = $_POST['user_code'];
$user_dept = $_POST['user_dept'];
$sele_stat = $_POST['sele_stat'];
// $mysql = "delete from masdept_user where fusercode='$user_code'";
$myres = mysqli_query($mycon, $mysql);
for ($i = 0; $i < sizeof($user_dept); $i++) {
if ($sele_stat[$i] == 'false') {
$mysql1 = "delete from masdept_user where fusercode = '$user_code' and fdeptcode = '$user_dept[$i]'";
$myres1 = mysqli_query($mycon, $mysql1);
}
if ($sele_stat[$i] == 'true') {
$mysql1 = "insert into masdept_user (fusercode,fdeptcode,fupdttime) values('$user_code', '$user_dept[$i]',now())";
$myres1 = mysqli_query($mycon, $mysql1);
}
}
set_user_logs($dept_id, $user_id, 'UDAC', 'USER DEPT. UPDATED: ' . $user_code);
$resp_mesg = "User client updated!";
echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));
}
|