-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathedit_holidays.php
67 lines (54 loc) · 2.36 KB
/
edit_holidays.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
<?php
require('../include/session.inc.php');
/*
This file is part of CoDev-Timetracking.
CoDev-Timetracking 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 3 of the License, or
(at your option) any later version.
CoDev-Timetracking 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 CoDev-Timetracking. If not, see <http://www.gnu.org/licenses/>.
*/
require('../path.inc.php');
class EditHolidaysController extends Controller {
/**
* Initialize complex static variables
* @static
*/
public static function staticInit() {
// Nothing special
}
protected function display() {
// Admins only
if(Tools::isConnectedUser()) {
$session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
$this->smartyHelper->assign('defaultColor', '58CC77');
if (isset($_POST['hol_color'])) {
$formatedDate = Tools::getSecurePOSTStringValue('date');
$timestamp = Tools::date2timestamp($formatedDate);
$hol_desc = Tools::getSecurePOSTStringValue('hol_desc');
$hol_color = Tools::getSecurePOSTStringValue('hol_color');
if (!Holidays::save($timestamp, $hol_desc, $hol_color)) {
$this->smartyHelper->assign('error', T_("Couldn't add the holiday"));
}
} elseif (isset($_POST['hol_id'])) {
$hol_id = Tools::getSecurePOSTIntValue('hol_id');
if (!Holidays::delete($hol_id)) {
$this->smartyHelper->assign('error', T_("Couldn't remove the holiday"));
}
}
$this->smartyHelper->assign('holidays', Holidays::getHolidays());
}
}
}
}
// ========== MAIN ===========
EditHolidaysController::staticInit();
$controller = new EditHolidaysController('../', 'CodevTT Administration : Holidays','Admin');
$controller->execute();
?>