/var/www/onesolution.com.hk/support/projectcalendar.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
<?php require("checkuser.php"); ?>

<?
if ($logged_in == 1) {
} else {
    
//echo 'Not logged in. <a href="login.php">Login</a>';
    
header('Location: logon.php');
}
?>
<?php 
require("configure.php"); ?>
<?
$searchdate 
$_POST['searchdate'];

if (
$searchdate == "")
{
    
// get year, eg 2006
    
$year date('Y');
    
// get month, eg 04
    
$month date('n');
    
// get day, eg 3
    
$day date('j');
    
$searchdate date('Ymd');
}
else
{
    
$year substr($searchdate,0,4);
    
$month substr($searchdate,4,2);
    
$day substr($searchdate,6,2);

}

// get number of days in month, eg 28
$daysInMonth date("t",mktime(0,0,0,$month,1,$year));


// get first day of the month, eg 4
$firstDay date("w"mktime(0,0,0,$month,1,$year));


// calculate total spaces needed in array
$tempDays $firstDay $daysInMonth;


// calculate total rows needed
$weeksInMonth ceil($tempDays/7);

for(
$j=0;$j<$weeksInMonth;$j++) 
{
    for(
$i=0;$i<7;$i++) 
    {
        
$counter++;
        
$week[$j][$i] = $counter
    }
}
?>
<?
$counter
=0;
for(
$j=0;$j<$weeksInMonth;$j++) {
    for(
$i=0;$i<7;$i++) {
        
$counter++;
        
$week[$j][$i] = $counter
        
// offset the days
        
$week[$j][$i] -= $firstDay;
        if ((
$week[$j][$i] < 1) || ($week[$j][$i] > $daysInMonth)) {    
            
$week[$j][$i] = "";
        }
    }
}
?>
<?php
function fillArray() {
    
// create a 2-d array
//    for($j=0;$j<$this->weeksInMonth;$j++) {
//        for($i=0;$i<7;$i++) {
//            $counter++;
//            $this->week[$j][$i] = $counter; 
//            // offset the days
//            $this->week[$j][$i] -= $this->firstDay;
//            if (($this->week[$j][$i] < 1) || ($this->week[$j][$i] > $this->daysInMonth)) {    
//                $this->week[$j][$i] = "";
//            }
//        }
//    }
}
?> 
<html> 
<head> 
<title>One solution Limited - Project List</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<link rel="stylesheet" href="main.css" type="text/css">
</head>
<body>
<script type="text/javascript" src="calendarDateInput.js">
</script>


<table><tr><td valign='top'>
    <form action="" method="post">
    <script>DateInput('searchdate', true, 'YYYYMMDD', '<?=$searchdate?>')</script>
    <input type="submit" value="Submit">
    </form>
    <table width="840" border="0" cellpadding='1' cellspacing='1' bgcolor='#666666'>
    <tr>
    <th colspan='7' class='content' bgcolor='#FFFFFF'><?= date('M'mktime(0,0,0,$month,1,$year)).' '.$year?></th>    
    </tr>    
    <tr>        
    <th class='content' bgcolor='#FFFFFF' background="images/gsprite_mod_sky_051408.gif"><font color="#FF0000">Sun</font></th>
    <th class='content' bgcolor='#FFFFFF' background="images/gsprite_mod_sky_051408.gif">Mon</th>
    <th class='content' bgcolor='#FFFFFF' background="images/gsprite_mod_sky_051408.gif">Tue</th>
    <th class='content' bgcolor='#FFFFFF' background="images/gsprite_mod_sky_051408.gif">Wed</th>
    <th class='content' bgcolor='#FFFFFF' background="images/gsprite_mod_sky_051408.gif">Thur</th>
    <th class='content' bgcolor='#FFFFFF' background="images/gsprite_mod_sky_051408.gif">Fri</th>
    <th class='content' bgcolor='#FFFFFF' background="images/gsprite_mod_sky_051408.gif">Sat</th>
    </tr>

    <?php
    
//mysql_query("SET NAMES 'UTF8'");
    //mysql_query("SET CHARACTER SET UTF8"); 
    //mysql_query("SET CHARACTER_SET_RESULTS=UTF8'"); 

    
foreach ($week as $key => $val
    {     
        echo 
"<tr>";    
        for (
$i=0;$i<7;$i++) 
        {
            echo 
"<td width='120' height='100' valign='top' class='content' ";
            if ((
$year.substr('0'.$monthstrlen('0'.$month)-2).substr('0'.$week[$key][$i], strlen('0'.$week[$key][$i])-2)) == (date("Ymd")))
            {
                echo 
"bgcolor='#FFFFCC'>";
            }
            else
            {
                echo 
"bgcolor='#FFFFFF'>";
            }
            echo 
$week[$key][$i];
            if (
$week[$key][$i] <> "")
            {
                
event($year.substr('0'.$monthstrlen('0'.$month)-2).substr('0'.$week[$key][$i], strlen('0'.$week[$key][$i])-2));
            }
            echo 
"</td>";    
        }    
        echo 
"</tr>";
    }
?>
    </table>
</td><td valign='top'>
    <?
    
if ($searchdate <> "")
    {
    
?>
        <table width="300" border="0" cellpadding="1" cellspacing="1" bgcolor="#666666">
        <?
        $datefr 
$year.substr('0'.$monthstrlen('0'.$month)-2)."01";
        
$dateto date("Ymd"strtotime(date("Ymd"strtotime($datefr." +1 month"))." -1 days"));

        
$sql "select taskname, staffname, projectname ";
        
$sql .= "from PM_TASK_HDR a, SYS_STAFF b, PM_PROJECT_HDR c ";
        
$sql .= "where a.staffid = b.staffid ";
        
$sql .= "and a.projectid = c.projectid ";
        
$sql .= "and ((datefr between '$datefr' and '$dateto') ";
        
$sql .= "or (dateto between '$datefr' and '$dateto')) ";
        
$sql .= "order by staffname, taskname";

        
$result=mysql_query($sql);
        while (
$row mysql_fetch_array($result,MYSQL_ASSOC))
        {
            echo 
"<tr><td valign='top' class='content' bgcolor='#FFFFFF'>".$row{'staffname'}."</td>";
            echo 
"<td valign='top' class='content' bgcolor='#FFFFFF'>".$row{'projectname'}."</td><td class='content' bgcolor='#FFFFFF'>".$row{'taskname'}."</td>";
        }
        
?>
        </table>
    <?
    
}    
    
?>
    </td></tr>
</table>
</body>
</html>
<?
function event($d)
{
    
$sql "select a.projectid, b.staffid, taskname, staffname, projectname ";
    
$sql .= "from PM_TASK_HDR a, SYS_STAFF b, PM_PROJECT_HDR c ";
    
$sql .= "where a.staffid = b.staffid ";
    
$sql .= "and a.projectid = c.projectid ";
    
$sql .= "and '"$d ."' between datefr and dateto ";
    
$sql .= "order by b.staffid desc";

    
$result=mysql_query($sql);
    while (
$row mysql_fetch_array($result,MYSQL_ASSOC))
    {
        echo 
"<br><li><a href='tasklist.php?projectid=".$row{'projectid'}."'>""<font color='#".md5(strrev($row{'staffname'}))."'>(".$row{'staffname'}.")</font> ".$row{'projectname'}."->".$row{'taskname'}."</a>";
    }
}
?>