-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcale.func.php
More file actions
92 lines (76 loc) · 2.36 KB
/
cale.func.php
File metadata and controls
92 lines (76 loc) · 2.36 KB
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
<?php
/**
* Generate calender table (month view)
* @param int $month Default Empty
* @param int $year Default Empty
* @return string
*/
function get_calender($month ='', $year='') {
$date = time();
$curr = array();
$curr['day'] = date('d', $date);
$curr['month']= date('n', $date);
$curr['year'] = date('Y', $date);
if(!$month && !$year){
$month = $curr['month'];
$year = $curr['year'];
}
$first_day = mktime(0, 0, 0, $month, 1, $year);
$days_in_month = cal_days_in_month(0, $month, $year);
$title = date('F', $first_day)." ".$year;
$day_of_week = date('D', $first_day);
//Week starts on Monday
switch ($day_of_week) {
case "Mon": $blank = 0;
break;
case "Tue": $blank = 1;
break;
case "Wed": $blank = 2;
break;
case "Thu": $blank = 3;
break;
case "Fri": $blank = 4;
break;
case "Sat": $blank = 5;
break;
case "Sun": $blank = 6;
break;
}
$table = "<table><tr><th>Monday</th><th>Tuesday</th><th>Wednesday</th>
<th>Thursday</th><th>Friday</th><th>Saturady</th>
<th style=color:red;>Sunday</th></tr><tr>";
$day_count = 1;
//Insert blank cell at begaining
while ($blank > 0) {
$table .= "<td class=blank></td>";
$blank--;
$day_count++;
}
$day_num = 1;
while ($day_num <= $days_in_month) {
// add today id on curr date
if ($day_num == $curr['day'] && $month == $curr['month'] && $year == $curr['year']) {
$table.= "<td id=today class=active data-value=$day_num/$month/$year><div class=date title='Click to Add event'>$day_num</div></td>";
} else {
$table.= "<td id=d$day_num class='active' data-value=$day_num/$month/$year><div class=date title='Click to Add event'>$day_num</div></td>";
}
$day_num++;
$day_count++;
if ($day_count > 7) {
$table .= "</tr><tr>";
$day_count = 1;
}
}
//Insert blank cell end
while ($day_count > 1 && $day_count <= 7) {
$table .= "<td class=blank></td>";
$day_count++;
}
$table .= "</tr></table>";
$data = array();
$data['numb'] = "$month/$year";
$data['title'] = $title;
$data['table'] = $table;
return $data;
}
?>