-
Notifications
You must be signed in to change notification settings - Fork 0
/
createexpense.php_bkp
executable file
·296 lines (258 loc) · 7.27 KB
/
createexpense.php_bkp
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<?php
session_name("Project");
session_start();
require_once('dbconn.php');
if(!checkUserSession($_SESSION["user"]))
{
header("Location:login.php");
}
if(checkPermission("CREATE") == false)
{
header("Location:error.php");
}
?>
<html>
<head>
<script>
function formSubmit()
{
document.forms["expenseForm"]["ExpenseDet"].style.background="white";
document.forms["expenseForm"]["ExpenseAmt"].style.background="white";
document.forms["expenseForm"]["ExpenseDate"].style.background="white";
var ua = window.navigator.userAgent;
var msie = ua.indexOf ( "MSIE " );
if(msie > 0)
{
alert("Not Supported in IE. Please use chrome");
return false;
}
var bdg = document.forms["expenseForm"]["budgettogo"];
if(!bdg)
{
alert('Project details not selected');
return false;
}
var details = document.forms["expenseForm"]["ExpenseDet"].value;
if(!details)
{
alert('Details cannot be blank');
document.forms["expenseForm"]["ExpenseDet"].style.background="pink";
document.forms["expenseForm"]["ExpenseDet"].focus();
return false;
}
var dt =document.forms["expenseForm"]["ExpenseDate"].value;
if(!dt)
{
alert("Date cannot be blank");
document.forms["expenseForm"]["ExpenseDate"].style.background="pink";
document.forms["expenseForm"]["ExpenseDate"].focus();
return false;
}
if(new Date(dt)>new Date()){
alert('Date must not be in the future!');
document.forms["expenseForm"]["ExpenseDate"].style.background="pink";
document.forms["expenseForm"]["ExpenseDate"].focus();
return false;
}
var i1 = (document.forms["expenseForm"]["budgettogo"].value);
var i2 = (document.forms["expenseForm"]["ExpenseAmt"].value);
if (i2=="" || parseInt(i2) == 0)
{
alert('Amount cannot be blank or zero');
document.forms["expenseForm"]["ExpenseAmt"].style.background="pink";
document.forms["expenseForm"]["ExpenseAmt"].focus();
return false;
}
var ix1 = (document.forms["expenseForm"]["cust"].value);
//Bypass budget for customer = Internal(9) for now
if (parseInt(i1) < parseInt(i2) && parseInt(ix1) !=9 && parseInt(ix1) !=8)
{
alert('No budget for this expense. Please get an approval for excess Budget');
// document.forms["expenseForm"]["ExpenseAmt"].style.background="pink";
// document.forms["expenseForm"]["ExpenseAmt"].focus();
return false;
}
return true;
}
function showBudget(str)
{
if(str=='Choose..')
return;
document.getElementById('txtBudget').removeChild(document.getElementById('finance'));
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById('txtBudget').removeChild(document.getElementById('ajaxloader'));
document.getElementById("txtBudget").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getohrmbudget.php?q="+str,true);
function BeginLoading(){
var eLoader = document.createElement("img");
eLoader.src = "images/loader.gif";
eLoader.alt = "";
eLoader.id = "ajaxloader";
document.getElementById('txtBudget').appendChild(eLoader);
xmlhttp.send();
}
BeginLoading();
}
function showExpense()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtExp").innerHTML=xmlhttp.responseText;
document.forms["expenseForm"]["expense"].focus();
}
}
xmlhttp.open("GET","getexpense.php",true);
xmlhttp.send();
}
function showEMP()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtEmp").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getemp1.php",true);
xmlhttp.send();
}
function showProject(str)
{
if(str=='Choose..')
return;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtProj").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getproject.php?q="+str,true);
xmlhttp.send();
}
function showCustomer()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtCust").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getcustomer.php",true);
xmlhttp.send();
}
</script>
</head>
<body id="public" onload="showExpense();">
<div id="container">
<?php include 'header.php'; ?>
<div class="section first">
<h3>Create Expense</h3>
</div>
<form name="expenseForm" action="update_expense.php" method="post" enctype="multipart/form-data" onsubmit="return formSubmit();" >
<table>
<tr>
<td><label class="desc" >Expense Type <span class="req">*</span> </td>
<td> <div id="txtExp"></div> </td>
</tr>
<tr>
<td><label class="desc">On Behalf of <span class="req">*</span> </td>
<td> <div id="txtEmp"></div> </td>
</tr>
<tr>
<td><label class="desc">Customer<span class="req">*</span></label> </td>
<td>
<div id="txtCust"></div>
</td>
<td><label class="desc">Project<span class="req">*</span></label> </td>
<td>
<div id="txtProj"></div>
</td>
</tr>
<tr>
<td><span><label class="desc">Expense Details<span class="req">*</span></label> </span></td>
<td> <textarea class="field textarea medium" name="ExpenseDet" rows="4" cols="50" required></textarea>
</td>
</tr>
<tr>
<td><label class="desc">Expense Amount (in INR)<span class="req">*</span></label> </td>
<td> <input class="field text currency" type="number" name="ExpenseAmt" required>
</td>
</tr>
<tr>
<td><label class="desc">Expense date <span class="req">*</span></label> </td>
<td> <input class="field text" type = "date" id="ExpenseDate" name="ExpenseDate" required></td>
</tr>
<tr>
<td>
<label for="userFile">Image: </label>
</td>
<td>
<input type="file" size="40" name="userFile" id="userFile"/><br />
</td>
<td>
<label for="altText">Description of Bill</label>
<td>
<input type="text" size="60" name="altText" id="altText" required/><br />
</td>
</td>
</tr>
</table>
<tr>
<td class="desc"> <div id="txtBudget"><table id="finance"></table></div> </td>
</tr>
<td>
<input type="submit" value="Submit Expense">
</td>
</form>
</div>
</body>
</html>