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.220.43.27
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/employees.php |
<?php
ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');
include("sys_session.php");
include("sys_mainphp.php");
include("sys_connect.php");
$inpt_errs = "F";
$resp_stat = "F";
$resp_mesg = "";
$resp_file = "";
if ($_POST['load_data'] == 'grid_data') {
$dept_code = $_POST['dept_code'];
$empl_stat = $_POST['empl_stat'];
$empl_desn = $_POST['empl_desn'];
$find_data = $_POST['find_data'];
require("sys_grid_data.php");
$i = 1;
if ($type_id == 'ADMIN') {
$myqry = " ";
} elseif ($type_id == 'CHIEF') {
$myqry = " inner join masdept_user du on em.fdeptcode = du.fdeptcode and du.fusercode = '$user_id' ";
}
$grid_sele = "select distinct dp.fdeptcode,dp.fdeptshrt,em.femplcode,em.femplname,em.fempldesn,em.fworkplce,e2.femplname as frepthead,
date_format(em.fbrthdate,'%d/%m/%Y') as fbrthdate,
date_format(em.fjoindate,'%d/%m/%Y') as fjoindate,
date_format(em.ftermdate,'%d/%m/%Y') as ftermdate,
em.femplmobl,em.femplmail,em.femplstat,em.fempltype,em.femplphot,ifnull(em.fdeviceid,'') as fdeviceid,dp.fdeptlogo
from masempl em
inner join masempl e2 on em.frepthead = e2.femplcode
inner join masdept dp on em.fdeptcode = dp.fdeptcode " . $myqry . "
where (em.femplcode like '%$find_data%' or em.femplname like '%$find_data%' or em.femplmobl like '%$find_data%')
and em.fdeptcode like '$dept_code' and em.femplstat like '$empl_stat' and em.fempldesn like '$empl_desn' and ifnull(em.fdeleted,'F')='F'
order by em.femplcode,em.fdeptcode,em.fempldesn,fempltype,femplname";
$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 class=''>";
echo "<thead>";
echo "<tr>";
echo "<th width='4%'> # </th>";
echo "<th width='5%'> Empl ID </th>";
echo "<th width='5%'> Photo </th>";
echo "<th width='15%'> Employee Name</th>";
echo "<th width='12%'> Designation </th>";
echo "<th width='12%'> Client / Location</th>";
echo "<th width='8%'> Reporting Head</th>";
echo "<th width='6%'> Mobile No.</th>";
echo "<th width='12%'> Email ID </th>";
echo "<th width='5%'> Status </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-primary btn-sm' href='#' onClick=view_data('$myrow[femplcode]')><span class='glyphicon glyphicon-list-alt'></span> View</a>";
if ($type_id == 'ADMIN') {
$page_link .= " <a class='btn btn-success btn-sm' href='#' onClick=edit_data('$myrow[femplcode]')><span class='glyphicon glyphicon-edit'></span> Edit</a>";
$page_link .= " <a class='btn btn-primary btn-sm' href='#' onClick=prnt_card('$myrow[femplcode]')><span class='glyphicon glyphicon-print'></span> ID</a>";
$page_link .= " <a class='btn btn-primary btn-sm' href='#' onClick=prnt_ndaf('$myrow[femplcode]')><span class='glyphicon glyphicon-print'></span> NDA</a></br>";
$page_link .= " <a class='btn btn-danger btn-sm' href='#' onClick=dele_data('$myrow[femplcode]')><span class='glyphicon glyphicon-trash'></span> Del.</a>";
if ($myrow['fdeviceid'] != '') {
$page_link .= " <a class='btn btn-danger btn-sm' href='#' onClick=dele_dvid('$myrow[femplcode]')><span class='glyphicon glyphicon-refresh'></span> Reset Mobile</a>";
}
}
if ($myrow['fempltype'] == 'P') $empl_type = "PERMANENT";
if ($myrow['fempltype'] == 'T') $empl_type = "TEMPORARY";
$empl_stat = $myrow['femplstat'] == 'T' ? "ACTIVE" : "INACTIVE";
if ($myrow['femplphot'] == '') {
$empl_imge = "img-empl/blank.png";
} else {
$url = dirname($_SERVER['PHP_SELF']) . "/oums/img-empl/" . $myrow['femplphot'];
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($handle);
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if ($httpCode == 404) {
$empl_imge = "img-empl/blank.png";
$dept_imge = "img-empl/blank.png";
} else {
$empl_imge = "img-empl/" . $myrow['femplphot'];
$dept_logo = "img-dept/" . $myrow['fdeptlogo'];
}
curl_close($handle);
}
echo "<tr>";
echo "<td align='center'> $i</td>";
echo "<td align='center'> $myrow[femplcode]</td>";
echo "<td align='center'><img src='$empl_imge' height='60px' width='60px' style='border:1px solid #ccc;' align='absmiddle' alt=''> </td>";
echo "<td align='left'> $myrow[femplname] </br>D.O.B.: $myrow[fbrthdate]</td>";
echo "<td align='left'> $myrow[fempldesn]</br>D.O.J.: $myrow[fjoindate]</td>";
echo "<td align='left'> $myrow[fdeptcode] - $myrow[fdeptshrt]</br>$myrow[fworkplce]</td>";
echo "<td align='center'> $myrow[frepthead]</td>";
echo "<td align='center'> $myrow[femplmobl]</td>";
echo "<td align='left'>$myrow[femplmail]</td>";
echo "<td align='center'>$empl_stat</br>D.O.R.: $myrow[ftermdate]</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 == 'actv_empl') {
$mysql = "update masempl set femplstat='T' where femplcode='$_POST[prim_code]'";
$myres = mysqli_query($mycon, $mysql);
}
if ($load_data == 'inac_empl') {
$mysql = "update masempl set femplstat='F' where femplcode='$_POST[prim_code]'";
$myres = mysqli_query($mycon, $mysql);
}
if ($_POST['load_data'] == 'view_data') {
$empl_code = $_POST['prim_code'];
// $mysql = "update masempl set femplstat='F',fdeleted='T' where femplcode='$empl_code'";
// $myres = mysqli_query($mycon, $mysql);
}
if ($_POST['load_data'] == 'dele_data') {
$empl_code = $_POST['prim_code'];
$mysql = "update masempl set femplstat='F',fdeleted='T' where femplcode='$empl_code'";
$myres = mysqli_query($mycon, $mysql);
}
if ($_POST['load_data'] == 'dele_dvid') {
$empl_code = $_POST['prim_code'];
$mysql = "update masempl set fdeviceid='' where femplcode='$empl_code'";
$myres = mysqli_query($mycon, $mysql);
}
if ($_POST['load_data'] == 'dept_data') {
if ($type_id == 'ADMIN') {
$mysql = "select * from masdept where ifnull(fdeleted,'')<>'T' order by fdeptname";
} else {
$mysql = "select * from masdept where ifnull(fdeleted,'')<>'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]</option>";
}
}
if ($_POST['load_data'] == 'desn_data') {
$mysql = "select * from masdesn where fdepttype in (select fdepttype from masdept where fdeptcode = '$_POST[dept_code]') order by fdesnordr,fempldesn";
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) > 1) {
echo "<option value=0>--SELECT--</option>";
}
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<option value='$myrow[fempldesn]'>$myrow[fempldesn]</option>";
}
}
if ($_POST['load_data'] == 'bank_data') {
$mysql = "select * from masbank order by fbankcode";
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) > 1) {
echo "<option value=0>--SELECT-</option>";
}
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<option value='$myrow[fbankcode]'>$myrow[fbankname]</option>";
}
}
if ($_POST['load_data'] == 'disp_data') {
$empl_code = $_POST['empl_code'];
$mysql = "select * from masempl where femplcode='$empl_code'";
$myres = mysqli_query($mycon, $mysql);
$myrows = array();
while ($r = mysqli_fetch_assoc($myres)) {
$myrows = $r;
}
echo json_encode($myrows);
}
if ($_POST['load_data'] == 'save_data') {
if ($type_id != 'ADMIN') {
$resp_mesg = "Edit not allowed!";
$inpt_errs = "T";
}
$page_mode = $_POST['page_mode'];
$empl_name = strtoupper($_POST['empl_name']);
$empl_phot = $_POST['empl_phot'];
$empl_phot = strtolower(str_replace(' ', '_', $empl_phot));
if ($_POST['empl_mobl'] == "") {
$inpt_errs = "T";
$resp_mesg = "Please enter mobile number!";
}
if ($_POST['empl_adhr'] == "") {
$inpt_errs = "T";
$resp_mesg = "Please enter aadhar number!";
}
$empl_stat = $_POST['empl_stat'];
if ($_POST['term_date'] == "00/00/0000" || $_POST['term_date'] == "") {
$empl_stat = 'T';
} else {
$empl_stat = 'F';
}
//photo file upload starts
if (!empty($_FILES["file"])) {
$file_name = '../img-empl/' . strtolower(str_replace(' ', '_', $_POST['empl_phot'])); //
if (file_exists("$file_name")) {
unlink("$file_name");
}
if (move_uploaded_file($_FILES['file']['tmp_name'], $file_name)) {
$inpt_errs = "F";
} else {
$resp_mesg = "Failed to upload employee photo!";
$inpt_errs = "T";
};
}
//photo file upload ends
if ($inpt_errs != "T") {
if ($page_mode == "add") {
$mysql = "select * from masempl where femplmobl='$_POST[empl_mobl]'";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt != 0) {
while ($myrowx = mysqli_fetch_assoc($myres)) {
$dupl_dept = $myrowx['fdeptcode'];
$dupl_name = $myrowx['femplname'];
}
$resp_mesg = "Mobile no. already exists with Name: " . $dupl_name . ", Dept: " . $dupl_dept . "\n";
$inpt_errs = "T";
}
$mysql = "select * from masempl where fadhrnumb='$_POST[empl_adhr]'";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt != 0) {
while ($myrowx = mysqli_fetch_assoc($myres)) {
$dupl_dept = $myrowx['fdeptcode'];
$dupl_name = $myrowx['femplname'];
}
$resp_mesg .= "Aadhaar no. already exists with Name: " . $dupl_name . ", Dept: " . $dupl_dept . "\n";
$inpt_errs = "T";
}
// $mysql = "select * from masempl where femplmail='$_POST[empl_mail]'";
// $myres = mysqli_query($mycon, $mysql);
// $mycnt = mysqli_num_rows($myres);
// if ($mycnt != 0) {
// while ($myrowx = mysqli_fetch_assoc($myres)) {
// $dupl_dept = $myrowx['fdeptcode'];
// $dupl_name = $myrowx['femplname'];
// }
// $resp_mesg .= "Email id already exists with Name: " . $dupl_name . ", Dept: " . $dupl_dept . "\n";
// $inpt_errs = 'T';
// }
$mysql = "select * from masempl where fpancnumb='$_POST[empl_panc]'";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt != 0) {
while ($myrowx = mysqli_fetch_assoc($myres)) {
$dupl_dept = $myrowx['fdeptcode'];
$dupl_name = $myrowx['femplname'];
}
$resp_mesg .= "PAN already exists with Name: " . $dupl_name . ", Dept: " . $dupl_dept . "\n";
$inpt_errs = 'T';
}
if ($inpt_errs != 'T') {
$mysql1 = "select * from sys_control";
$myres1 = mysqli_query($mycon, $mysql1);
$myrow1 = mysqli_fetch_assoc($myres1);
if (strtoupper($_POST['dept_code']) == 'DEP') {
$empl_code = $myrow1["fdeepslno"] + 1;
} elseif (strtoupper($_POST['dept_code']) == 'IHF') {
$empl_code = $myrow1["fihfsslno"] + 1;
} else {
$empl_code = $myrow1["femplslno"] + 1;
}
$mysql = "insert into masempl (
femplcode,femplname,fempldesn,fdeptcode,fempltype,fworkplce,frepthead,femplstat,femplgend,
fbrthdate,
femplmobl,femplmail,fpermadd1,fpermadd2,fpermadd3,fpermadd4,
fexpnentr,fattnentr,fworkentr,
fsalrcomp,fsalrhead,fsalrtype,fsalrappr,fsalrbase,fsalrdays,fsalrhour,
fjoindate,ftermdate,
femplremk,femplphot,ftotlleav,fadhrnumb,fpancnumb,facntname,facntnumb,fifsccode,fbankcode,fcreatime,fupdttime,fdeleted,fusercode,fusertype,fuserpswd,fupdtpswd)
values(
'$empl_code','$empl_name','$_POST[empl_desn]','$_POST[dept_code]','$_POST[empl_type]','$_POST[work_plce]','$_POST[rept_head]','$empl_stat','$_POST[empl_gend]',
str_to_date('$_POST[empl_bday]','%d/%m/%Y'),
'$_POST[empl_mobl]','$_POST[empl_mail]','$_POST[empl_add1]','$_POST[empl_add2]','$_POST[empl_add3]','$_POST[empl_add4]',
'$_POST[expn_entr]','$_POST[attn_entr]','$_POST[work_entr]',
'$_POST[salr_comp]','$_POST[salr_head]','$_POST[salr_type]','$_POST[salr_appr]','$_POST[salr_base]','$_POST[salr_days]','$_POST[salr_hour]',
str_to_date('$_POST[join_date]','%d/%m/%Y'),
str_to_date('$_POST[term_date]','%d/%m/%Y'),
'$_POST[empl_remk]','$_POST[empl_phot]','$_POST[totl_casl]','$_POST[empl_adhr]','$_POST[empl_panc]','$_POST[acnt_name]','$_POST[bank_acnt]',
'$_POST[bank_ifsc]','$_POST[bank_code]',now(),now(),'F','$_POST[empl_mobl]','USER','$_POST[empl_mobl]','T')";
$myres = mysqli_query($mycon, $mysql);
if (strtoupper($_POST['dept_code']) == 'DEP') {
$mysql = "update sys_control set fdeepslno='$empl_code'";
$myres = mysqli_query($mycon, $mysql);
} elseif (strtoupper($_POST['dept_code']) == 'IHF') {
$mysql = "update sys_control set fihfsslno='$empl_code'";
$myres = mysqli_query($mycon, $mysql);
} else {
$mysql = "update sys_control set femplslno='$empl_code'";
$myres = mysqli_query($mycon, $mysql);
}
$resp_mesg = "Employee details added!";
$resp_stat = "T";
set_user_logs($dept_id, $user_id, 'EMPL', 'EMPLOYEE DETAILS ADDED : ' . '[' . $empl_code . '] ' . $empl_name . ' CLIENT : ' . $_POST['dept_code']);
}
} else {
$mysql = "update masempl set femplname='$empl_name',fempldesn='$_POST[empl_desn]',fdeptcode='$_POST[dept_code]',
fempltype='$_POST[empl_type]',fworkplce='$_POST[work_plce]',frepthead='$_POST[rept_head]',femplgend='$_POST[empl_gend]',femplstat='$empl_stat',
femplmobl='$_POST[empl_mobl]',femplmail='$_POST[empl_mail]',fadhrnumb='$_POST[empl_adhr]',fpancnumb='$_POST[empl_panc]',
fbrthdate=str_to_date('$_POST[empl_bday]','%d/%m/%Y'),
fjoindate=str_to_date('$_POST[join_date]','%d/%m/%Y'),
ftermdate=str_to_date('$_POST[term_date]','%d/%m/%Y'),
fexpnentr='$_POST[expn_entr]',fattnentr='$_POST[attn_entr]',fworkentr='$_POST[work_entr]',
fpermadd1='$_POST[empl_add1]',fpermadd2='$_POST[empl_add2]',fpermadd3='$_POST[empl_add3]',fpermadd4='$_POST[empl_add4]',
fsalrcomp='$_POST[salr_comp]',fsalrhead='$_POST[salr_head]',fsalrtype='$_POST[salr_type]',fsalrappr='$_POST[salr_appr]',
fsalrbase='$_POST[salr_base]',fsalrdays='$_POST[salr_days]',fsalrhour='$_POST[salr_hour]',
femplremk='$_POST[empl_remk]',femplphot='$empl_phot',
facntname='$_POST[acnt_name]',facntnumb='$_POST[bank_acnt]',fifsccode='$_POST[bank_ifsc]',fbankcode='$_POST[bank_code]',
ftotlleav='$_POST[totl_casl]',
fupdttime = now(),fdeleted='F' where femplcode='$_POST[empl_code]'";
$myres = mysqli_query($mycon, $mysql);
set_user_logs($dept_id, $user_id, 'EMPL', 'EMPLOYEE DETAILS UPDATED : ' . '[' . $_POST['empl_code'] . '] ' . $empl_name . ', CLIENT : ' . $_POST['dept_code']);
$resp_mesg = "Employee details updated!";
$resp_stat = "T";
}
}
echo json_encode(array("errs" => $inpt_errs, "stat" => $resp_stat, "mesg" => $resp_mesg, "file" => $resp_file));
}
|