-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattend_spoortoess.php
More file actions
126 lines (77 loc) · 3.88 KB
/
attend_spoortoess.php
File metadata and controls
126 lines (77 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
require_once('AdminUser/config/config.php');
/******************************* Joining Employee Open *************************************/
/******************************* Joining Employee Open *************************************/
//$jsonCont = file_get_contents('studJson.json');
//$jsonData = json_decode(file_get_contents('php://input'), true);
$jsonData = file_get_contents('php://input');
$json = json_decode($jsonData); //, true
//echo 'aa='.$_REQUEST['EmployeeID'].'-'.$_REQUEST['companyId'].'-'.$_REQUEST['ATTENDANCE'].'-'.$_REQUEST['DATE'];
//echo $json; die();
if($json!=null)
//if($_REQUEST['EmployeeID']!='' && $_REQUEST['companyId']!='' && $_REQUEST['ATTENDANCE']!='' && $_REQUEST['DATE']!='')
{
/*
$ec_s = $_REQUEST['EmployeeID'];
$com_s = $_REQUEST['companyId'];
$attv_s = $_REQUEST['ATTENDANCE'];
$attd_s = $_REQUEST['DATE'];
*/
//$ec_s = $json->NAME;
$ec_s = $json->EmployeeID;
$com_s = $json->companyId;
$attv_s = $json->ATTENDANCE;
$attd_s = $json->DATE;
/*
$ec_s = $json['NAME'];
$com_s = $json['companyId'];
$attv_s = $json['ATTENDANCE'];
$attd_s = $json['DATE'];
*/
//$ec=$ec_s;
$ec=str_replace(array( '"', '"' ), '', $ec_s);
$com=0; if($com_s==845){ $com=1; }
$attv=''; if($attv_s=='Present'){ $attv='P'; }
$attd=date("Y-m-d",strtotime($attd_s));
/*****************************************************************************/
$sY=mysql_query("select YearId from hrm_year where Company".$com."Status='A'", $con);
$rY=mysql_fetch_assoc($sY);
$sqlE=mysql_query("select EmployeeID from hrm_employee where EmpCode=".$ec." AND CompanyId=".$com, $con);
$rowE=mysql_num_rows($sqlE); $resE=mysql_fetch_assoc($sqlE);
if($rowE>0){
$sql=mysql_query("select Leave_Type,LeaveStatus from hrm_employee_applyleave WHERE EmployeeID=".$resE['EmployeeID']." AND ('".$attd."'>=Apply_FromDate AND '".$attd."'<=Apply_ToDate) AND LeaveStatus!=3 AND LeaveCancelStatus!='Y'", $con);
$row=mysql_num_rows($sql);
if($row==0){
if($attv=='P'){
/*************************/
$sql2=mysql_query("select * from hrm_employee_attendance WHERE EmployeeID=".$resE['EmployeeID']." AND AttDate='".$attd."'", $con); $row2=mysql_num_rows($sql2);
if($row2>0){
$res2=mysql_fetch_assoc($sql2);
if($res2['AttValue']!='CL' AND $res2['AttValue']!='CH' AND $res2['AttValue']!='SL' AND $res2['AttValue']!='SH' AND $res2['AttValue']!='PL' AND $res2['AttValue']!='PH' AND $res2['AttValue']!='EL' AND $res2['AttValue']!='FL' AND $res2['AttValue']!='TL'){
$sqlUp=mysql_query("update hrm_employee_attendance set AttValue='".$attv."' WHERE EmployeeID=".$resE['EmployeeID']." AND AttDate='".$attd."'", $con);
}
}elseif($row2==0 AND date("w",strtotime($attd))!=0){
$sqlUp = mysql_query("insert into hrm_employee_attendance(EmployeeID, AttValue, AttDate, Year, YearId) values(".$resE['EmployeeID'].",'".$attv."', '".$attd."', '".date("Y")."', ".$rY['YearId'].")", $con);
}else{
echo json_encode( array("Error" => "True", "ErrorDesc" => "not inserted!") );
}
if($sqlUp){
echo json_encode( array("Error" => "False", "ErrorDesc" => "") );
}
} //if($attv=='A' OR $attv=='P' OR $attv=='OD' OR $attv=='WFH')
else{
echo json_encode( array("Error" => "True", "ErrorDesc" => "not inserted!") );
}
} //if($row==0)
else{
echo json_encode( array("Error" => "True", "ErrorDesc" => "not inserted!") );
}
}
//if($rowE>0)
/*****************************************************************************/
}else{
echo json_encode( array("Error" => "True", "ErrorDesc" => "value missing!") );
}
/******************************* Joining Employee Close *************************************/
/******************************* Joining Employee Close *************************************/
?>