/
workorder_approval.php
309 lines (288 loc) · 11.9 KB
/
workorder_approval.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
<?php
session_start();
$ses_id = session_id();
require_once("conf/db_connection.php");
require_once("functions.php");
chkMenuAccess('workorder_approval',$_SESSION['username'],'workorder_list.php');
$estimaterefno = $_GET['estimaterefno'];
$qryestimate = new v_service_master;
$resestimate = $dbo->query($qryestimate->Query("WHERE estimate_refno = '$estimaterefno'"));
foreach($resestimate as $rowestimate){
$custid = $rowestimate['customer_id'];
$custname = $rowestimate['customername'];
$address = $rowestimate['cust_address'];
$vehicleid = $rowestimate['vehicle_id'];
$remarks = $rowestimate['remarks'];
$paymentmode = $rowestimate['payment_mode'];
$payment = $rowestimate['payment_id'];
$discount = $rowestimate['discount'];
$porefno = $rowestimate['po_refno'];
$worefno = $rowestimate['wo_refno'];
$transstatus = $rowestimate['trans_status'];
$empid = $rowestimate['emp_id'];
$empname = $rowestimate['tech_name'];
$promisetime = $rowestimate['promise_time'];
$promisedate = $rowestimate['promise_date'];
$plateno = $rowestimate['plate_no'];
$makedesc = $rowestimate['make_desc'];
$yeardesc = $rowestimate['year_desc'];
$modeldesc = $rowestimate['model_desc'];
$colordesc = $rowestimate['color_desc'];
$variant = $rowestimate['variant'];
$engineno = $rowestimate['engine_no'];
$chassisno = $rowestimate['chassis_no'];
$serialno = $rowestimate['serial_no'];
}
$qrycost_accessory = new v_service_detail_accessory;
$rescost_accessory = $dbo->query($qrycost_accessory->Query("WHERE estimate_refno = '$estimaterefno'"));
$qrycost_job = new v_service_detail_job;
$rescost_job = $dbo->query($qrycost_job->Query("WHERE estimate_refno = '$estimaterefno'"));
$qrycost_material = new v_service_detail_material;
$rescost_material = $dbo->query($qrycost_material->Query("WHERE estimate_refno = '$estimaterefno'"));
$qrycost_parts = new v_service_detail_parts;
$rescost_parts = $dbo->query($qrycost_parts->Query("WHERE estimate_refno = '$estimaterefno'"));
$subtotal = 0;
if(isset($_POST['savewo']) && !empty($_POST['savewo']) && $_POST['savewo'] == 1){
$empid = $_POST['empid'];
$promisetime = $_POST['promisetime'];
$promisedate = dateFormat($_POST['promisedate'],"Y-m-d");
$paymentmode = $_POST['paymentmode'];
$qry = null;
$qry .= "UPDATE tbl_service_master SET payment_id = '$paymentmode', technician = '$empid',promise_date = '$promisedate',promise_time = '$promisetime' WHERE estimate_refno = '$estimaterefno'; ";
$qry .= "INSERT INTO tbl_jobclock_master(wo_refno) VALUE('$worefno'); ";
$res = $dbo->query($qry);
if(!$res){
echo '<script>alert("There has been an error in updating your data! Please re-process hour transaction."); window.location="workorder_approval.php?estimaterefno='.$estimaterefno.'";</script>';
exit();
}else{
echo '<script>alert("Work order successfully selected a technician."); window.location="workorder_approval.php?estimaterefno='.$estimaterefno.'";</script>';
exit();
}
}
$qrytech = "SELECT * FROM v_employee WHERE emp_status = '1' ORDER BY employee";
$restech = $dbo->query($qrytech);
$qrytech1 = "SELECT * FROM v_employee WHERE emp_status = '1' ORDER BY employee";
$restech1 = $dbo->query($qrytech1);
$qrypayment = "SELECT * FROM v_payment";
$respayment = $dbo->query($qrypayment);
?>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style/cal.css" />
<link rel="stylesheet" type="text/css" href="style/forms.css" />
</head>
<? require_once('inc/datepicker.php'); ?>
<script type="text/javascript">
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp = false;
try{
xmlhttp = new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp = false;
}
}
}
return xmlhttp;
}
function getEmpInfo(empid){
var strURL = "divGetEmployeeInfo.php?empid="+empid;
var req = getXMLHTTP();
if (req){
req.onreadystatechange = function(){
if (req.readyState == 4){
document.getElementById('divEmpInfo').innerHTML = req.responseText;
getPlateNos(custid);
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
</script>
<style type="text/css">
div.divTableEstimateCost{ font-size: 11px; }
div.divTableEstimateCost table{ border: 1px solid #ddd; padding: 0; margin: 0; }
div.divTableEstimateCost table th{ background: #0000ff; color: #fff; font-size: 12px; }
div.divTableEstimateCost div.divCost{ border-right: 1px solid #ddd; border-bottom: 1px solid #ddd; font-size: 12px; }
</style>
<body>
<? if(!empty($empid)){ ?>
<table><tr>
<td><a href="workorder_print.php?estimaterefno=<?=$estimaterefno;?>" target="_blank">
<div style="width:100px; height:50px; text-align: center;"><img src="images/print_wo.png" width="59" height="48" style="pointer: cursor; width: 59px;" border="0" /></div></a></td>
<td><a href="workorder_cancel.php?worefno=<?=$worefno;?>"><img src="images/cancel.jpg" width="55" height="58" style="pointer: cursor; width: 59px;" border="0" /></a></td></tr>
</table>
<? } ?>
<fieldset form="form_estimate" name="form_estimate">
<legend><p id="title">REFERENCE NUMBER</p></legend>
<table>
<tr>
<td class ="label" width="100"><label name="lbl_customer_id">Estimate: </label>
<td align="left" width="200" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$estimaterefno;?></td>
</tr>
<tr>
<td class ="label"><label name="lbl_customer_id">Work Order: </label>
<td align="left" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$worefno;?></td>
</tr>
<? if($porefno != '0'){ ?>
<tr>
<td class ="label"><label name="lbl_customer_id">Purchase Order: </label>
<td align="left" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$porefno;?></td>
</tr>
<? } ?>
</table>
</fieldset>
<fieldset form="form_estimate" name="form_estimate">
<legend><p id="title">CUSTOMER INFORMATION</p></legend>
<table>
<tr>
<td class ="label" width="100"><label name="lbl_customer_id">Customer Code:</label>
<td align="left" width="200" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$custid;?></td>
<td></td>
<td class ="label" width="100"><label name="lbl_customer">Customer Name:</label></td>
<td align="left" width="200" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$custname;?></td>
</tr>
<tr>
<td class ="label"><label name="lbl_custadd">Address:</label></td>
<td align="left" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$address;?></td>
</tr>
</table>
</fieldset>
<fieldset form="form_highschool" name="form_highschool">
<legend>
<p id="title">VEHICLE INFORMATION:</p></legend>
<table>
<tr>
<td class ="label" width="100"><label name="lbl_plateno">Plate Number:</label></td>
<td align="left" width="200" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$plateno;?></td>
<td></td>
<td class ="label" width="100"><label name="lbl_year">Year:</label></td>
<td align="left" width="200" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$yeardesc;?></td>
<td></td>
<td class ="label" width="100"><label name="lbl_make">Make:</label></td>
<td align="left" width="200" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$makedesc;?></td>
</tr>
<tr>
<td class ="label"><label name="lbl_model">Model:</label></td>
<td align="left" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$modeldesc;?></td>
<td></td>
<td class ="label"><label name="lbl_color">Color:</label></td>
<td align="left" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$colordesc;?></td>
<td></td>
<td class ="label"><label name="lbl_variant">Variant:</label></td>
<td align="left" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$variant;?></td>
</tr>
<tr>
<td class ="label"><label name="lbl_vehicledescription">Engine No:</label></td>
<td align="left" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$engineno;?></td>
<td></td>
<td class ="label"><label name="lbl_color">Chassis No</label></td>
<td align="left" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$chassisno;?></td>
<td></td>
<td class ="label"><label name="lbl_serialno">Serial No:</label></td>
<td align="left" style="font-weight: normal; font-size: 12px; border:1px solid #333;"><?=$serialno;?></td>
</tr>
</table>
</fieldset>
<fieldset form="form_remarks" name="form_remarks">
<legend><p id="title">REMARKS</p></legend>
<table>
<tr>
<td align="left" style="font-weight: normal; font-size: 12px;"><?=$remarks;?></td>
</tr>
</table>
</fieldset>
<form method="Post" onSubmit="return ValidateMe();">
<fieldset form="form_remarks" name="form_remarks">
<legend><p id="title">TECHNICIAN</p></legend>
<span id="divEmpInfo">
<table>
<tr>
<td class ="label"><label name="lbl_customer_id">Technician Code:</label>
<td class ="input">
<? if(!empty($empid)){ ?>
<span class="input"><input type="text" name="empid" id="empid" value="<?=$empid;?>" readonly style="width:235px"></span>
<? }else{ ?>
<select name="empid" id="empid" onChange="getEmpInfo(this.value);">
<option value="">Select a Technician</option>
<? foreach($restech as $rowTECHNICIAN){ ?>
<option value="<?=$rowTECHNICIAN['emp_id'];?>"><?=$rowTECHNICIAN['emp_id'];?></option>
<? } ?>
</select>
<? } ?>
</td>
<td class ="label"><label name="lbl_custadd">Technician Name:</label></td>
<td class ="input">
<? if(!empty($empid)){ ?>
<span class="input"><input type="text" name="empname" id="empname" value="<?=$empname;?>" readonly style="width:235px"></span>
<? }else{ ?>
<select name="empname" id="empname" onChange="getEmpInfo(this.value);">
<option value="">Select a Technician</option>
<? foreach($restech1 as $rowTECHNICIAN1){ ?>
<option value="<?=$rowTECHNICIAN1['emp_id'];?>"><?=$rowTECHNICIAN1['employee'];?></option>
<? } ?>
</select>
<? } ?>
</td>
</tr>
</table>
</span>
<table>
<tr>
<td class ="label"><label name="lbl_custadd">Promise Date:</label></td>
<td class ="input"><input type="text" name="promisedate" id="promisedate" readonly class="date-pick" value="<?=$promisedate;?>" /></td>
<td class ="label"><label name="lbl_custadd">Promise Time:</label></td>
<td class ="input"><input type="text" name="promisetime" id="promisetime" value="<?=$promisetime;?>" /> format 00:00:00</td>
</tr>
<tr>
<td class="label">Payment Mode:</td>
<td class="input"><select name="paymentmode" id="paymentmode" style="width: 200px;">
<option value=""></option>
<? foreach($respayment as $rowpayment){ ?>
<option value="<?=$rowpayment['payment_id'];?>" <? if($payment == $rowpayment['payment_id']){ echo 'selected'; } ?>><?=$rowpayment['payment'];?></option>
<? } ?>
</select></td>
<td></td>
</tr>
</table>
</fieldset>
<? if(empty($empid)){ ?>
<input type="submit" name="btnsubmit" id="btnsubmit" value="" />
<input type="hidden" name="savewo" id="savewo" value="1" />
<? } ?>
</form>
<script type="text/javascript">
function ValidateMe(){
var empid = document.getElementById("empid").value;
var promisetime = document.getElementById("promisetime").value;
var promisedate = document.getElementById("promisedate").value;
var paymentmode = document.getElementById("paymentmode").value;
if(empid == ""){
alert("Please select a technician of this work order!");
return false;
}else if(promisedate == ""){
alert("Please enter promise date!");
return false;
}else if(promisetime == ""){
alert("Please enter promise time!");
return false;
}else if(paymentmode == ""){
alert("Please enter payment mode!");
return false;
}else{
return true;
}
}
</script>
</body>
</html>