-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin_config_calend2.php
230 lines (211 loc) · 8.82 KB
/
admin_config_calend2.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
<?php
/**
* admin_config_calend2.php
* interface permettant la la réservation en bloc de journées entières
* Ce script fait partie de l'application GRR
* Dernière modification : $Date: 2009-04-14 12:59:17 $
* @author Laurent Delineau <laurent.delineau@ac-poitiers.fr>
* @copyright Copyright 2003-2008 Laurent Delineau
* @link http://www.gnu.org/licenses/licenses.html
* @package root
* @version $Id: admin_config_calend2.php,v 1.8 2009-04-14 12:59:17 grr Exp $
* @filesource
*
* This file is part of GRR.
*
* GRR is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GRR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRR; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* $Log: admin_config_calend2.php,v $
* Revision 1.8 2009-04-14 12:59:17 grr
* *** empty log message ***
*
* Revision 1.7 2009-04-09 14:52:31 grr
* *** empty log message ***
*
* Revision 1.6 2009-02-27 13:28:19 grr
* *** empty log message ***
*
* Revision 1.5 2008-11-16 22:00:58 grr
* *** empty log message ***
*
*
*/
$grr_script_name = "admin_calend_jour_cycle.php";
$back = '';
if (isset($_SERVER['HTTP_REFERER'])) $back = my_htmlspecialcharacters($_SERVER['HTTP_REFERER']);
$day = date("d");
$month = date("m");
$year = date("Y");
function cal($month, $year)
{
global $weekstarts, $display_day;
$display_day="1111111";
if (!isset($weekstarts)) $weekstarts = 0;
$s = "";
$daysInMonth = getDaysInMonth($month, $year);
$date = mktime(12, 0, 0, $month, 1, $year);
$first = (strftime("%w",$date) + 7 - $weekstarts) % 7;
$monthName = utf8_strftime("%B",$date);
$s .= "<table class=\"calendar2\" border=\"1\" cellspacing=\"3\">\n";
$s .= "<tr>\n";
$s .= "<td class=\"calendarHeader2\" colspan=\"7\">$monthName $year</td>\n";
$s .= "</tr>\n";
$d = 1 - $first;
$is_ligne1 = 'y';
while ($d <= $daysInMonth)
{
$s .= "<tr>\n";
for ($i = 0; $i < 7; $i++)
{
$basetime = mktime(12,0,0,6,11+$weekstarts,2000);
$show = $basetime + ($i * 24 * 60 * 60);
$nameday = utf8_strftime('%A',$show);
$temp = mktime(0,0,0,$month,$d,$year);
if ($i==0) $s .= "<td class=\"calendar2\" style=\"vertical-align:bottom;\"><b>S".numero_semaine($temp)."</b></td>\n";
$s .= "<td class=\"calendar2\" align=\"center\" valign=\"top\">";
if ($is_ligne1 == 'y') $s .= '<b>'.ucfirst(substr($nameday,0,1)).'</b><br />';
if ($d > 0 && $d <= $daysInMonth)
{
$s .= $d;
$day = grr_sql_query1("SELECT day FROM ".TABLE_PREFIX."_calendrier_jours_cycle WHERE day='$temp'");
$s .= "<br /><input type=\"checkbox\" name=\"$temp\" value=\"$nameday\" ";
if (!($day < 0)) $s .= "checked=\"checked\" ";
$s .= " />";
} else {
$s .= " ";
}
$s .= "</td>\n";
$d++;
}
$s .= "</tr>\n";
$is_ligne1 = 'n';
}
$s .= "</table>\n";
return $s;
}
if(authGetUserLevel(getUserName(),-1) < 6)
{
showAccessDenied($day, $month, $year, '',$back);
exit();
}
# print the page header
print_header("","","","",$type="with_session", $page="admin");
// Affichage de la colonne de gauche
include "admin_col_gauche.php";
// Affichage du tableau de choix des sous-configuration pour les Jours/Cycles (Créer et voir calendrier Jours/Cycle)
include "include/admin_calend_jour_cycle.inc.php";
echo "<h3>".get_vocab('calendrier_jours/cycles').grr_help("aide_grr_jours_cycle")."</h3>";
if (isset($_POST['record']) and ($_POST['record'] == 'yes')) {
// On vide la table
$sql = "truncate table ".TABLE_PREFIX."_calendrier_jours_cycle";
if (grr_sql_command($sql) < 0) fatal_error(1, "<p>" . grr_sql_error());
$result = 0;
$end_bookings = getSettingValue("end_bookings");
$n = getSettingValue("begin_bookings");
$month = strftime("%m", getSettingValue("begin_bookings"));
$year = strftime("%Y", getSettingValue("begin_bookings"));
$day = 1;
// Pour aller chercher le Jour cycle qui débutera le premier cycle de jours
$m = getSettingValue("jour_debut_Jours/Cycles");
while ($n <= $end_bookings) {
$daysInMonth = getDaysInMonth($month, $year);
$day = 1;
while ($day <= $daysInMonth) {
$n = mktime(0,0,0,$month,$day,$year);
if (isset($_POST[$n])) {
// Le jour a été selectionné dans le calendrier
$starttime = mktime($morningstarts, 0, 0, $month, $day , $year);
$endtime = mktime($eveningends, 0, $resolution, $month, $day, $year);
// On efface toutes les résa en conflit
$sql = "select id from ".TABLE_PREFIX."_room";
$res = grr_sql_query($sql);
if ($res) for ($i = 0; ($row = grr_sql_row($res, $i)); $i++)
$result += grrDelEntryInConflict($row[0], $starttime, $endtime, 0, 0, 1);
// On enregistre la valeur
$m = cree_calendrier_date_valide($n,$m);
}
$day++;
}
$month++;
if ($month == 13) {
$year++;
$month = 1;
}
}
}
echo "<p>".get_vocab("les_journees_cochees_sont_valides").get_vocab("deux_points");
echo "<br />* ".get_vocab("nombre_jours_Jours/Cycles").get_vocab("deux_points").getSettingValue("nombre_jours_Jours/Cycles");
echo "<br />* ".get_vocab("debut_Jours/Cycles").get_vocab("deux_points").getSettingValue("jour_debut_Jours/Cycles");
echo "<br /><br />".get_vocab("explication_Jours_Cycles2")."</p>";
echo "<table cellpadding=\"3\">\n";
$basetime = mktime(12,0,0,6,11+$weekstarts,2000);
for ($i = 0; $i < 7; $i++)
{
$show = $basetime + ($i * 24 * 60 * 60);
$lday = utf8_strftime('%A',$show);
echo "<tr>\n";
echo "<td><span class='small'><a href='admin_calend_jour_cycle.php' onclick=\"setCheckboxesGrr(document.getElementById('formulaire'), true, '$lday' ); return false;\">".get_vocab("check_all_the").$lday."s</a></span></td>\n";
echo "<td><span class='small'><a href='admin_calend_jour_cycle.php' onclick=\"setCheckboxesGrr(document.getElementById('formulaire'), false, '$lday' ); return false;\">".get_vocab("uncheck_all_the").$lday."s</a></span></td>\n";
echo "</tr>\n";
}
echo "<tr>\n<td><span class='small'><a href='admin_calend_jour_cycle.php' onclick=\"setCheckboxesGrr(document.getElementById('formulaire'), false, 'all'); return false;\">".get_vocab("uncheck_all_")."</a></span></td>\n";
echo "<td></td></tr>\n";
echo "</table>\n";
echo "<form action=\"admin_calend_jour_cycle.php?page_calend=2\" method=\"post\" id=\"formulaire\">\n";
echo "<table cellspacing=\"20\">\n";
$n = getSettingValue("begin_bookings");
$end_bookings = getSettingValue("end_bookings");
$debligne = 1;
$month = strftime("%m", getSettingValue("begin_bookings"));
$year = strftime("%Y", getSettingValue("begin_bookings"));
while ($n <= $end_bookings) {
if ($debligne == 1) {
echo "<tr>\n";
$inc = 0;
$debligne = 0;
}
$inc++;
echo "<td>\n";
echo cal($month, $year);
echo "</td>";
if ($inc == 3) {
echo "</tr>";
$debligne = 1;
}
$month++;
if ($month == 13) {
$year++;
$month = 1;
}
$n = mktime(0,0,0,$month,1,$year);
}
if ($inc < 3) {
$k=$inc;
while($k < 3) {
echo "<td> </td>\n";
$k++;
} // while
echo "</tr>";
}
echo "</table>";
echo "<div id=\"fixe\" style=\"text-align:center;\"><input type=\"submit\" onclick=\"return confirmlink(this, '".AddSlashes(get_vocab("avertissement_effacement"))."', '".get_vocab("admin_config_calend1.php")."')\" name=\"ok\" value=\"".get_vocab("save")."\" /></div>\n";
echo "<div><input type=\"hidden\" name=\"record\" value=\"yes\" /></div>\n";
echo "</form>";
// fin de l'affichage de la colonne de droite
echo "</td></tr></table>";
?>
</body>
</html>