/var/www/onesolution.com.hk/support/jobdetail.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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<?php header("Content-Type:text/html;charset=BIG5"); ?>
<?php 
require("checkuser.php"); ?>
<?php 
require("configure.php"); ?>
<?
$jobid    
$_GET['jobid'];
$id        $_GET['id'];
//$id        = "c9f0f895fb98ab9159f51fd0297e236d";

if ($id == "")
{
    if (
$logged_in <> 1) {
        
header('Location: logon.php');
        return;
    }
    
$disable "";
    
$sql "select * from SYS_JOB where jobid = $jobid";
}
else
{
    
$disable "disabled";
    
$sql "select * from SYS_JOB where md5(jobid) = '$id'";
}

$result mysql_query($sql);
if (
$row mysql_fetch_array($result,MYSQL_ASSOC))
{
    
$jobid            $row{'jobid'};
    
$staffid        $row{'staffid'};
    
$custid            $row{'custid'};
    
$email            $row{'email'};
    
$jobtimefr        substr($row{'jobtimefr'},3,2).substr($row{'jobtimefr'},6,2);
    
$jobtimeto        substr($row{'jobtimeto'},3,2).substr($row{'jobtimeto'},6,2);
    
$jobdate        $row{'jobdate'};
    
$jobtype        $row{'jobtype'};
    
$calldate        $row{'calldate'};
    
$calltime        substr($row{'calltime'},3,2).substr($row{'calltime'},6,2);
    
$jobdetail        $row{'jobdetail'};
    
$jobaction        $row{'jobaction'};
    
$jobstatus        $row{'jobstatus'};
    
$remarks        $row{'remarks'};
    
$creationby        $row{'creationby'};
    
$creationdate    $row{'creationdate'};
    
$updatedby        $row{'updatedby'};
    
$updateddate    $row{'updateddate'};
    
$acceptedby        $row{'acceptedby'};
    
$filename        $row{'filename'};
}
?>
<html>
<head>
<title>One Solution Limited - Support</title>
<link rel="stylesheet" href="main.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<script language="JavaScript" type="text/javascript" src="richtext.js"></script>
<script type="text/javascript" src="selectcustomer.js"></script>
<script type="text/javascript" src="calendarDateInput.js"></script>
<script type="text/javascript">
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}
</script>
</head>
<body onLoad="showCustomer('<?=$custid?>')">
<!--********************************************************-->
<script language="JavaScript">
<!--
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function formCheck(formobj){
    // Enter name of mandatory fields
    var fieldRequired = Array("email", "jobtimefr", "jobtimeto", "calltime", "jobdetail", "jobaction");
    // Enter field description to appear in the dialog box
    var fieldDescription = Array("Email", "Service time start", "Service time end", "Call time", "Job symptions", "Action");
    // dialog message
    var alertMsg = "Please complete the following fields:\n";
    var l_Msg = alertMsg.length;

    // check email start
    var returnval=emailfilter.test(formobj.email.value)
    if (returnval==false)
    {
        //alert("Please enter a valid email address.")
        alertMsg += " - Please enter a valid email address.\n";
        //formobj.email.select()
    }
    // check email end

    var jobtimefr = formobj.jobtimefr.value
    if (jobtimefr.length != 4 || IsNumeric(jobtimefr) == false)
    {
        alertMsg += " - Please enter expected Service Time Start using the following format (Eg. 0930).\n";
    }

    var jobtimeto = formobj.jobtimeto.value
    if (jobtimeto.length != 4 || IsNumeric(jobtimeto) == false)
    {
        alertMsg += " - Please enter expected Service Time End using the following format (Eg. 0930).\n";
    }

    var calltime = formobj.calltime.value
    if (calltime.length != 0)
    {
        if (IsNumeric(calltime) == false)
        {
            alertMsg += " - Please enter expected Call Time using the following format (Eg. 0930).\n";
        }
    }

    for (var i = 0; i < fieldRequired.length; i++){
        var obj = formobj.elements[fieldRequired[i]];
        if (obj){
            switch(obj.type){
            case "select-one":
                if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
                    alertMsg += " - " + fieldDescription[i] + "\n";
                }
                break;
            case "select-multiple":
                if (obj.selectedIndex == -1){
                    alertMsg += " - " + fieldDescription[i] + "\n";
                }
                break;
            case "text":
            case "textarea":
                if (obj.value == "" || obj.value == null){
                    alertMsg += " - " + fieldDescription[i] + "\n";
                }
                break;
            default:
            }
            if (obj.type == undefined){
                var blnchecked = false;
                for (var j = 0; j < obj.length; j++){
                    if (obj[j].checked){
                        blnchecked = true;
                    }
                }
                if (!blnchecked){
                    alertMsg += " - " + fieldDescription[i] + "\n";
                }
            }
        }
    }

    if (alertMsg.length == l_Msg){
        return submitForm();
    }else{
        alert(alertMsg);
        return false;
    }
}
function IsNumeric(sText)
{
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;


    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = false;
        }
    }
    return IsNumber;

}
function y2k(number) { return (number < 1000) ? number + 1900 : number; }

function daysElapsed(date1,date2) {
    var difference =
        Date.UTC(y2k(date1.getYear()),date1.getMonth(),date1.getDate(),0,0,0)
      - Date.UTC(y2k(date2.getYear()),date2.getMonth(),date2.getDate(),0,0,0);
    return difference/1000/60/60/24;
}
function submitForm() {
    return true;
}
// -->

</script>
<script type="text/javascript">

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid email address.")
e.select()
}
return returnval
}

</script>

<!--********************************************************-->
<table border="0" cellpadding="1" cellspacing="1" width="100%">
<tr><td class='pageheader' align="left" valign="middle" height="100"><img src="images/iconProducts.png">&nbsp;<b>Job Service</b></td>
    <td class='content' align="center" width="150"></td>
</tr>
</table>
<form action="jobupdate.php" name="addform" method="post" enctype="multipart/form-data" onSubmit="return formCheck(this);">
<input type="hidden" name="jobid" value="<?=$jobid?>">
<?
if ($_SESSION['roleid'] <> 2)
{
function 
getRealIpAddr()
{
    if (!empty(
$_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    
{
      return 
$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty(
$_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    
{
      return 
$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      return 
$_SERVER['REMOTE_ADDR'];
    }
    return 
0;
}
?>
<input type="hidden" name="acceptedby" value="<?=getRealIpAddr();?>">
<?
}    
?>
<table border="0" cellpadding="1" cellspacing="1" width="800">
<tr><td class='content' align="left" valign="middle" width="150"><b>Job No.:</b></td>
    <td class='content' width="650"><b><?=$jobid?></b></td></tr>
<tr><td class='content' align="left" valign="middle" width="150">Select a Staff:</td>
    <td class='content' width="650">
    <select name="staffid" class="content" <?=$disable?>>
    <?php
    
if ($_SESSION['roleid'] == 1)
    {
        
$sql "SELECT * ";
        
$sql .= "FROM SYS_STAFF where roleid = 2 and status = 1 order by staffname";
    }
    else
    {
        if (
$_SESSION['userid'] == "")
        {
            
$sql "SELECT * ";
            
$sql .= "FROM SYS_STAFF where roleid = 2 and status = 1 and staffid = '"$staffid ."' order by staffname";
        }
        else
        {
            
$sql "SELECT * ";
            
$sql .= "FROM SYS_STAFF where roleid = 2 and status = 1 and userid = '"$_SESSION['userid'] ."' order by staffname";
        }

    }

    
$result mysql_query($sql);
    while (
$row mysql_fetch_array($result,MYSQL_ASSOC))
    {
        echo 
"<option value='".$row{'staffid'}."' "getSelect($row{'staffid'}, $staffid).">"$row{'staffname'} ."</option>";
    }
    
?>
    </select>
</td></tr>

<tr><td class='content' align="left" valign="middle" width="150">Select a Customer:</td>
    <td class='content' width="650">
    <select name="custid" onChange="showCustomer(this.value)" class="content" <?=$disable?>>
    <?php
    $sql 
"SELECT * ";
    
$sql .= "FROM CM_CUSTOMER_HDR order by custname";

    
$result mysql_query($sql);
    while (
$row mysql_fetch_array($result,MYSQL_ASSOC))
    {
        echo 
"<option value='".$row{'custid'}."' "getSelect($row{'custid'}, $custid).">"$row{'custname'} ."</option>";
    }
    
mysql_close($dbh);
    
?>
    </select>
</td></tr>
</table>
<?
$showemail 
0;
?>
<div id="txtHint" class="content">Customer info will be listed here.</div>
<table border="0" cellpadding="1" cellspacing="1" width="800">
<tr><td class="content" width="150">Email:</td>
    <td class="content"><input type="text" name="email" value="<?=$email?>" size="30" maxlength="100" class="content" <?=$disable?>>
    </td></tr>
</table>
<table border="0" cellpadding="1" cellspacing="1" width="800">
<tr><td class="content" width="150">Service Time:</td>
    <td class="content">
    Start <input type="text" name="jobtimefr" value="<?=$jobtimefr?>" size="4" maxlength="4" class="content" <?=$disable?>>
    End <input type="text" name="jobtimeto" value="<?=$jobtimeto?>" size="4" maxlength="4" class="content" <?=$disable?>>
    </td></tr>
<tr><td class="content" width="150">Date:</td>
    <td class="content">
    <script>DateInput('jobdate', true, 'YYYY-MM-DD', '<?=$jobdate?>', '<?=$disable?>')</script>
    </td></tr>
<tr><td colspan="2"><hr></td></tr>
<tr><td class="content" width="150">Job Type:</td>
    <td class="content"><input type='radio' name='jobtype' value='1' class="content" <?=getCheck('1'$jobtype)?>>Schedule Visit&nbsp;&nbsp;&nbsp;<input type='radio' name='jobtype' value='2' class="content" <?=getCheck('2'$jobtype)?>>Service Call&nbsp;&nbsp;&nbsp;<input type='radio' name='jobtype' value='3' class="content" <?=getCheck('3'$jobtype)?>>Urgent Call</td></tr>
<tr><td class="content" width="150">Call Date:</td>
    <td class="content">
    <script>DateInput('calldate', true, 'YYYY-MM-DD', '<?=$calldate?>', '<?=$disable?>')</script>
    </td></tr>
<tr><td class="content" width="150">Call Time:</td>
    <td class="content">
    <input type="text" name="calltime" value="<?=$calltime?>" size="4" maxlength="4" class="content" <?=$disable?>>
    </td></tr>
<tr><td class="content" width="150" valign="top">Job Symptions:</td>
    <td class="content">
    <textarea name="jobdetail" class="content" cols="80" rows="5" maxlength="500" onKeyUp="return ismaxlength(this)" <?=$disable?>><?=$jobdetail?></textarea>
    </td></tr>
<tr><td class="content" width="150" valign="top">Action:</td>
    <td class="content">
    <textarea name="jobaction" class="content" cols="80" rows="5" maxlength="500" onKeyUp="return ismaxlength(this)" <?=$disable?>><?=$jobaction?></textarea>
    </td></tr>
<tr><td class="content" width="150" valign="top">Job Status:</td>
    <td class="content">
    <input type="radio" name="jobstatus" value="1" <?=getCheck('1'$jobstatus)?>>Done
    <input type="radio" name="jobstatus" value="2" <?=getCheck('2'$jobstatus)?>>Follow up (Please specify below)
    <input type="radio" name="jobstatus" value="3" <?=getCheck('3'$jobstatus)?>>Others (Please specify below)
    </td></tr>
<tr><td class="content" width="150" valign="top">Remarks:</td>
    <td class="content">
    <textarea name="remarks" class="content" cols="80" rows="5" maxlength="500" onKeyUp="return ismaxlength(this)"><?=$remarks?></textarea>
    </td></tr>
<tr><td class="content" width="150">File:</td>
    <td class="content">
    <?
    
if (strlen($acceptedby) == 0)
    {
    
?>
        <input name="filename" type="file" class="content" id="filename">
    <?
    
}
    
?>
    <?
    
if ($filename <> "")
    {
        echo 
"<a href='docs/".$filename."' target='_new'>".$filename."</a>";
    }
    
?>
    </td></tr>
<?
if (strlen($acceptedby) == 0)
{
    if (
$_SESSION['roleid'] <> 2)
    {
        
?>
        <tr><td class="content" width="150" valign="top"></td>
            <td class="content"><input type="submit" value="Accept" class="content"><input type="reset" value="Reset" class="content">
            </td></tr>
        <?
    
}
    elseif ((
$_SESSION['roleid'] == 2) && ($jobstatus == 1))
    {
        
?>
        <tr><td class="content" width="150" valign="top"></td>
            <td class="content"><input type="submit" value="Submit" class="content"><input type="reset" value="Reset" class="content">
            </td></tr>
        <?
    
}

}    
else
{
    
?>
    <tr><td class="content" width="150" valign="top"></td>
        <td class="content">
            <!--<input type="submit" value="Submit" class="content" disabled><input type="reset" value="Reset" class="content" disabled>-->
            <!-- <input type="submit" value="Submit" class="content" /><input type="reset" value="Reset" class="content" /> -->
        </td></tr>
    <?
}    
?>
</form>
<?
//echo date("F j, Y, g:i a");
//echo date("Ymdgi");
?>
</body>
</html>

<?
function getSelect($field1$field2)
{
    if (
$field1 == $field2)
    {
        return 
"selected";
    }
    else
    {
        return 
"";
    }
}
?>
<?
function getCheck($field1$field2)
{
    if (
$field1 == $field2)
    {
        return 
"checked";
    }
    else
    {
        return 
"";
    }
}
?>