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.144.6.9
Current Path : /var/www/html/oums/api/ |
| Current File : /var/www/html/oums/api/workentry.php |
<?php
include("sys_connect.php");
$method = $_GET['method'];
if($method == 'getempdata'){
$emplcode = $_GET['emplcode'];
$query1 = "select e1.frepthead,e2.femplname from masempl e1
inner join masempl e2 on e2.femplcode = e1.frepthead
where e1.femplcode ='{$emplcode}'";
$result1 = mysqli_query($mycon, $query1);
$count1 = mysqli_num_rows($result1);
$query2 = "select * from maswork_type order by ftypeordr,ftypedesc";
$result2 = mysqli_query($mycon, $query2);
$query3 = "select * from mastown order by ftownname";
$result3 = mysqli_query($mycon, $query3);
$query4 = "select * from masclient order by fclntname";
$result4 = mysqli_query($mycon, $query4);
if($count1 >= 0){
$fetch1 = mysqli_fetch_assoc($result1);
$arr['head'] = $fetch1;
$worktype = [];
$i = 0;
while($fetch2 = mysqli_fetch_assoc($result2)){
$worktype[$i] = $fetch2;
$i++;
}
$arr['worktype'] = $worktype;
$place = [];
$j = 0;
while($fetch3 = mysqli_fetch_assoc($result3)){
$place[$j] = $fetch3;
$j++;
}
$arr['place'] = $place;
$client = [];
$k = 0;
while($fetch4 = mysqli_fetch_assoc($result4)){
$client[$k] = $fetch4;
$k++;
}
$arr['client'] = $client;
echo json_encode(array("status"=>true, "data"=>$arr));
}
}
if($method == 'savedata'){
$emplcode = $_POST['emplcode'];
$date = $_POST['date'];
$worktypevalue = $_POST['worktypevalue'];
$workplace = $_POST['workplace'];
$client = $_POST['client'];
$wtitle = $_POST['wtitle'];
$wdetails = $_POST['wdetails'];
$status = $_POST['status'];
$reportHead = $_POST['reportHead'];
$upduser = $_POST['upduser'];
$workcode = $_POST['workcode'];
$qry = "select fworkcode from workentry where fworkcode='{$workcode}'";
$result = mysqli_query($mycon, $qry);
$count = mysqli_num_rows($result);
if($count>0){
$query = "update workentry set fdeptcode = '{$client}',
fworktype='{$worktypevalue}', fclntcode='{$client}',
fworkplce = '{$workplace}', fworkdetl='{$wdetails}',
fworkstat='{$status}',
fupdttime = now(), fdevicetype='mob' where fworkcode='{$workcode}' and femplcode='{$emplcode}'";
}else{
$query = "insert into workentry (fworkdate, fdeptcode, femplcode, fworkname,
fworktype, fclntcode, fworkplce, fworkdetl, fworkstat, freptempl,
fupdtuser, fupdttime, fdevicetype) values ('{$date}', '{$client}', '{$emplcode}',
'{$wtitle}', '{$worktypevalue}', '{$client}', '{$workplace}', '{$wdetails}',
'{$status}', '{$reportHead}', '{$upduser}', now(), 'mob')";
}
$result = mysqli_query($mycon, $query);
if($result){
echo json_encode(array("status"=>true, "msg"=>"Data Saved Successfully"));
}else{
echo json_encode(array("status"=>false, "msg"=>"Something Went Wrong!!!"));
}
}
if($method == "empl"){
$query = "select distinct femplname,wk.femplcode from workentry wk
left join masempl em on wk.femplcode = em.femplcode
where ifnull(wk.femplcode,'')<>'' order by femplname;";
$res = mysqli_query($mycon, $query);
$count = mysqli_num_rows($res);
if($count>0){
$i=0;
$data = [];
while($fetch = mysqli_fetch_assoc($res)){
$data[$i] = $fetch;
$i++;
}
echo json_encode(array("error_code"=>0, "data"=>$data));
return;
}else{
echo json_encode(array("error_code"=>-1, "data"=>"no data found"));
return;
}
}
if($method == "viewwork"){
$emplcode = $_GET['emplcode'];
$emp = $_GET['emp'];
$worktype = $_GET['worktype'];
$workstatus = $_GET['workstatus'];
$reviewstatus = $_GET['reviewstatus'];
$fromdate = $_GET['fromdate'];
$todate = $_GET['todate'];
if($workstatus == 'All'){
$workstatuscond = '';
}else{
$workstatuscond = "and fworkstat = '{$workstatus}'";
}
if($reviewstatus == 'All'){
$reviewstatuscond = '';
}else{
$reviewstatuscond = "and fviewstat = '{$reviewstatus}'";
}
if($emplcode == "1000"){
$empcod = "and wk.femplcode = '{$emp}'";
}else{
$empcod = "and wk.femplcode = '{$emplcode}'";
}
// and wk.fworktype='{$worktype}'
$query = "select fworkcode,date_format(fworkdate,'%d/%m/%Y') as lworkdate,fworkname,ftypedesc,fworkstat,fviewstat,
concat('[',dp.fdeptcode,'] ',dp.fdeptshrt) as ldeptname,
concat('[',em.femplcode,'] ',em.femplname) as lemplname,
e2.femplname as lreptname, wk.femplcode
from workentry wk
inner join masdept dp on wk.fdeptcode = dp.fdeptcode
inner join masempl em on wk.femplcode = em.femplcode
inner join masempl e2 on em.frepthead = e2.femplcode
inner join maswork_type wt on wk.fworktype = wt.fworktype where
ifnull(wk.fdelestat,'F')='F'
{$empcod} and
fworkdate between '{$fromdate}' and '{$todate}'
{$workstatuscond} {$reviewstatuscond}
order by fworkdate desc, fworkcode desc;";
// var_dump($query);
// die();
$res = mysqli_query($mycon, $query);
$count = mysqli_num_rows($res);
if($count>0){
$i = 0;
$data = [];
while($fetch = mysqli_fetch_assoc($res)){
$data[$i] = $fetch;
$i++;
}
echo json_encode(array("error_code"=>0, "data"=>$data));
return;
}else{
echo json_encode(array("error_code"=>-1, "data"=>"No data found"));
return;
}
}
if($method == "oneweek"){
$empcode = $_GET['empcode'];
$query = "select fworkcode,date_format(fworkdate,'%d/%m/%Y') as lworkdate,fworkname,ftypedesc,fworkstat,fviewstat,
concat('[',dp.fdeptcode,'] ',dp.fdeptshrt) as ldeptname,
concat('[',em.femplcode,'] ',em.femplname) as lemplname,
e2.femplname as lreptname, wk.femplcode
from workentry wk
inner join masdept dp on wk.fdeptcode = dp.fdeptcode
inner join masempl em on wk.femplcode = em.femplcode
inner join masempl e2 on em.frepthead = e2.femplcode
inner join maswork_type wt on wk.fworktype = wt.fworktype
WHERE fworkdate >= DATE(NOW() - INTERVAL 7 DAY) and wk.femplcode = '{$empcode}'
order by fworkdate desc, fworkcode desc";
$res = mysqli_query($mycon, $query);
if($res){
$i = 0;
$data = [];
while($fetch = mysqli_fetch_assoc($res)){
$data[$i] = $fetch;
$i++;
}
echo json_encode(array("error_code"=>0, "data"=>$data));
return;
}else{
echo json_encode(array("error_code"=>-1, "data"=>"No data found from last 7 days"));
return;
}
}
if($method == "get"){
$workcode = $_GET['workcode'];
$empcode = $_GET['empcode'];
$query = "select date_format(fworkdate,'%d/%m/%Y')as fworkdate, fdeptcode, femplcode, fworkname,
w.fworktype, w.fclntcode, fworkplce, fworkdetl, fworkstat, freptempl,
fupdtuser, fupdttime, ftypedesc, fclntname from workentry w
inner join maswork_type m on m.fworktype = w.fworktype
inner join masclient mc on mc.fclntcode = w.fdeptcode
WHERE femplcode = '{$empcode}' and fworkcode = '{$workcode}'";
$res = mysqli_query($mycon, $query);
if($res){
$fetch = mysqli_fetch_assoc($res);
echo json_encode(array("error_code"=>0, "data"=>$fetch));
return;
}else{
echo json_encode(array("error_code"=>-1, "data"=>"Somethimg Went Wrong"));
return;
}
}
if($method == "delete"){
$workcode = $_GET['workcode'];
$emplcode = $_GET['emplcode'];
$query = "delete from workentry where fworkcode='{$workcode}' and femplcode='{$emplcode}'";
$res = mysqli_query($mycon, $query);
if($res){
echo json_encode(array("error_code"=>0, "data"=>"Deleted"));
return;
}else{
echo json_encode(array("error_code"=>-1, "data"=>"Somethimg Went Wrong"));
return;
}
}
?>
|