-
Notifications
You must be signed in to change notification settings - Fork 0
/
delexpense.php
executable file
·313 lines (265 loc) · 8.13 KB
/
delexpense.php
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?php
session_name("Project");
session_start();
require_once('dbconn.php');
if(!checkUserSession($_SESSION["user"]))
{
header("Location:login.php");
}
if(checkPermission("DELETE") == 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;
}
if (parseInt(i1) < parseInt(i2))
{
alert('No budget for this expense for now this will be passed.');
// document.forms["expenseForm"]["ExpenseAmt"].style.background="pink";
// document.forms["expenseForm"]["ExpenseAmt"].focus();
return true;
}
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","getbudget.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;
}
}
xmlhttp.open("GET","getexpense.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 >
<?php include 'header.php';
$expid=$_GET["exp_id"];
$coned=getConnection();
$sqled="
SELECT for_emp, status,a.expense_id,expense_type,a.project_id project_id, c.customer_id customer_id, c.name project_name,d.name customer_name,expense_details, expense_date,expense_amt FROM expense_details a
inner join expense_type b on a.expense_id = b.expense_id
inner join hr_mysql_live.ohrm_project c on a.project_id = c.project_id
inner join hr_mysql_live.ohrm_customer d on d.customer_id = c.customer_id
where expense_det_id = ".$expid;
$resulted = mysqli_query($coned,$sqled) or die($sqled." failed <br/><br/>".mysql_error());
$rowed = mysqli_fetch_array($resulted);
?>
<h3>Delete Expense</h3>
<form name="expenseForm" action="updatedel.php" method="post" onsubmit="return formSubmit();" >
<?
echo "<table>";
echo "<tr>";
echo "<td>";
echo "Please use Expense ID for future reference ";
echo "</td>";
echo "<td>";
echo "<b><input name='expensedetid' id='expensedetid' type='text' value='$expid'></b>";
echo "<script>document.getElementById('expensedetid').disabled=true;</script>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "Status ";
echo "</td>";
echo "<td>";
echo "<b><input name='expensestatus' id='expensestatus' type='text' value='$rowed[status]'></b>";
echo "<script>document.getElementById('expensestatus').disabled=true;</script>";
echo "</td>";
echo "</tr>";
?>
<tr>
<td>Expense Type : </td>
<?include 'getexpense.php';
echo "<input name='expensedetid' id='expensedetid' type='hidden' value='$expid'>";
echo "<script>document.getElementById('emp').value = '$rowed[for_emp]';</script>";
echo "<script>document.getElementById('expense').value = '$rowed[expense_id]';</script>";
echo "<script>document.getElementById('emp').disabled=true;</script>";
echo "<script>document.getElementById('expense').disabled=true;</script>";
?>
</tr>
<tr>
<td>Customer : </td>
<td>
<?php
include 'getcustomer.php';
echo "<script>document.getElementById('cust').value = '$rowed[customer_id]';</script>";
echo "<script>document.getElementById('cust').disabled=true;</script>";
?>
</td>
<td>Project : </td>
<td> <div id="txtProj">
<?php
$_GET['q'] = $rowed[customer_id];
include 'getproject.php';
echo "<script>document.getElementById('proj').value = '$rowed[project_id]';</script>";
echo "<script>document.getElementById('proj').disabled=true;</script>";
?>
</div> </td>
</tr>
<tr>
<td>Expense Details: </td>
<?php
echo "<td> <textarea name='ExpenseDet' id='ExpenseDet' rows='4' cols='50'>$rowed[expense_details]</textarea></td>";
echo "<script>document.getElementById('ExpenseDet').disabled=true;</script>";
?>
</tr>
<tr>
<td>Expense Amount (in INR): </td>
<?php echo"<td> <input type='text' name='ExpenseAmt' id='ExpenseAmt' value='$rowed[expense_amt]'></td>";
echo "<script>document.getElementById('ExpenseAmt').disabled=true;</script>";?>
</tr>
<tr>
<td>Expense date : </td>
<?php
$dt = date("Y-m-d", strtotime($rowed[expense_date]));
echo"<td> <input type = 'date' id='ExpenseDate' name='ExpenseDate' id='ExpenseDate' value='$dt' ></td>";
echo "<script>document.getElementById('ExpenseDate').disabled=true;</script>";?>
</tr>
<tr>
<td> <div id="txtBudget"><table id="finance"></table></div> </td>
<?php echo"<script>showBudget($rowed[project_id]);</script>";?>
</tr>
</table>
<td>
<input type="submit" value="Delete Expense">
</td>
</form>
</body>
</html>