/var/www/onesolution.com.hk/support/report.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
<?php header("Content-Type:text/html;charset=BIG5"); ?>
<?php 
require("checkuser.php"); ?>
<?php 
require("configure.php"); ?>
<?
$staffid    
$_POST['staffid'];
$custid        $_POST['custid'];
$jobdatefr    $_POST['jobdatefr'];
$jobdateto    $_POST['jobdateto'];
if (
$jobdatefr == "")
    
$jobdatefr date("Y-m-d");
if (
$jobdateto == "")
    
$jobdateto date("Y-m-d");
?>
<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="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>
<table border="0" cellpadding="1" cellspacing="1" width="100%">
<tr><td class='pageheader' align="left" valign="middle" height="100"><img src="images/iconNews.png">&nbsp;<b>Report</b></td>
    <td class='content' align="center" width="150"></td>
</tr>
</table>
<form action="" name="searchform" method="post">
<table border="0" cellpadding="1" cellspacing="1" width="800">
<tr><td class='content' align="left" valign="middle" width="150">Select a Staff:</td>
    <td class='content' width="450">
    <select name="staffid" class="content">
    <option></option>
    <?php
    
if ($_SESSION['roleid'] == 1)
    {
        
$sql "SELECT * ";
        
$sql .= "FROM SYS_STAFF where roleid = 2 and status = 1 order by staffname";
    }
    else
    {
        if (
$disable == "disabled")
        {
            
$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'>
    <select name="custid" class="content">
    <option></option>
    <?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>";
    }
    
?>
    </select>
</td></tr>
<tr><td class="content" width="150" valign="top">Date:</td>
    <td class="content">
    <script>DateInput('jobdatefr', true, 'YYYY-MM-DD', '<?=$jobdatefr?>', '')</script>  To  <script>DateInput('jobdateto', true, 'YYYY-MM-DD', '<?=$jobdateto?>', '')</script>
    </td></tr>

<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>
</table>
</form>

<table border="0" cellpadding="1" cellspacing="1" width="820" cellpadding='1' cellspacing='1' bgcolor='#666666'>
<tr><td class="content" width="50" align='center' bgcolor='#FFFFFF'>Job No</td>
    <td class="content" width="300" align='center' bgcolor='#FFFFFF'>Customer</td>
    <td class="content" width="70" align='center' bgcolor='#FFFFFF'>Job Date</td>
    <td class="content" width="190" align='center' bgcolor='#FFFFFF'>Job Time</td>
    <td class="content" width="70" align='center' bgcolor='#FFFFFF'>Handle by</td>
    <td class="content" width="70" align='center' bgcolor='#FFFFFF'>Status</td>
    <td class="content" width="70" align='center' bgcolor='#FFFFFF'>Completed</td></tr>

<?
$sql 
"select * from SYS_JOB a, SYS_STAFF b where a.staffid = b.staffid ";
if (
strlen($jobid) > 0)
    
$sql .= "and jobid = $jobid ";
if (
strlen($custid) > 0)
    
$sql .= "and custid = $custid ";
if (
strlen($staffid) > 0)
    
$sql .= "and a.staffid = $staffid ";


    
$sql .= "and jobdate >= '$jobdatefr' ";
    
$sql .= "and jobdate <= '$jobdateto' ";

$result mysql_query($sql);
//echo $sql;
while ($row mysql_fetch_array($result,MYSQL_ASSOC))
{
?>
    <tr><td class="content" bgcolor='#FFFFFF'><?=$row{'jobid'}?></td>
        <td class="content" bgcolor='#FFFFFF'><?=$row{'custname'}?></td>
        <td class="content" bgcolor='#FFFFFF'><?=$row{'jobdate'}?></td>
        <td class="content" bgcolor='#FFFFFF'><?=substr($row{'jobtimefr'},strlen($row{'jobtimefr'})-5)?>-<?=substr($row{'jobtimeto'},strlen($row{'jobtimeto'})-5)?>&nbsp;
        <?php
        
// a START time value
        
$start substr($row{'jobtimefr'},strlen($row{'jobtimefr'})-5);
        
// an END time value
        
$end   substr($row{'jobtimeto'},strlen($row{'jobtimeto'})-5);

        
// what is the time difference between $end and $start?
        
if($diff=@get_time_difference($start$end))
        {
          echo 
"Hours: " .
               
sprintf'%02d:%02d'$diff['hours'], $diff['minutes'] );
        }
        else
        {
          echo 
"Hours: Error";
        }
        
$totalhr += $diff['hours'];
        
$totalmin += $diff['minutes'];
        
$total += 1;
        
?>
        
        </td>
        <td class="content" bgcolor='#FFFFFF'><?=$row{'staffname'}?></td>
        <td class="content" bgcolor='#FFFFFF' align='center'>
        <?
        
switch ($row{'status'}) {
        case 
0:
            print 
"";
            break;
        case 
1:
            print 
"Done";
            break;
        case 
2:
            print 
"Follow up";
            break;
        case 
3:
            print 
"Others";
            break;
        default:
            print 
"";
            break;
        } 
        
?>        
        </td>
        <td class="content" bgcolor='#FFFFFF' align='center'>
        <?
        
if ($row{'acceptedby'} <> "")
        {
            echo 
"Yes";
        }
        
?>
        </td></tr>
<?
}
?>
<tr><td class="content" bgcolor='#FFFFFF' align='center'>Total: <?=$total?></td>
    <td class="content" bgcolor='#FFFFFF' align='center' colspan="2"></td>
    <td class="content" bgcolor='#FFFFFF' align='center'>Hours: <?=$totalhr+floor($totalmin/60)?>:<?=$totalmin 60?></td>
    <td class="content" bgcolor='#FFFFFF' align='center' colspan="3"></td></tr>
</table>

</body>
</html>
<?
function getSelect($field1$field2)
{
    if (
$field1 == $field2)
    {
        return 
"selected";
    }
    else
    {
        return 
"";
    }
}
?>
<?
function get_time_difference$start$end )
{
    
$uts['start']      =    strtotime$start );
    
$uts['end']        =    strtotime$end );
    if( 
$uts['start']!==-&& $uts['end']!==-)
    {
        if( 
$uts['end'] >= $uts['start'] )
        {
            
$diff    =    $uts['end'] - $uts['start'];
            if( 
$days=intval((floor($diff/86400))) )
                
$diff $diff 86400;
            if( 
$hours=intval((floor($diff/3600))) )
                
$diff $diff 3600;
            if( 
$minutes=intval((floor($diff/60))) )
                
$diff $diff 60;
            
$diff    =    intval$diff );            
            return( array(
'days'=>$days'hours'=>$hours'minutes'=>$minutes'seconds'=>$diff) );
        }
        else
        {
            
trigger_error"Ending date/time is earlier than the start date/time"E_USER_WARNING );
        }
    }
    else
    {
        
trigger_error"Invalid date/time data detected"E_USER_WARNING );
    }
    return( 
false );
}
?>