-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtime.php
More file actions
87 lines (81 loc) · 2.5 KB
/
time.php
File metadata and controls
87 lines (81 loc) · 2.5 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
<?php
/**
* Copyright 2002-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsdl.php.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Ben Klang <ben@alkaloid.net>
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('hermes');
$vars = Horde_Variables::getDefaultVariables();
$delete = $vars->get('delete');
if (!empty($delete)) {
try {
$injector->getInstance('Hermes_Driver')
->updateTime(array('id' => $delete, 'delete' => true));
} catch (Horde_Exception $e) {
$notification->push(
sprintf(
_("There was an error deleting the time: %s"),
$e->getMessage()
),
'horde.error'
);
}
$notification->push(
_("The time entry was successfully deleted."), 'horde.success'
);
$vars->remove('delete');
}
switch ($vars->get('formname')) {
case 'submittimeform':
$time = array();
$item = $vars->get('item');
if (is_null($item) || !count($item)) {
$notification->push(
_("No timeslices were selected to submit."),
'horde.error');
} else {
foreach (array_keys($item) as $id) {
$time[] = array('id' => $id);
}
try {
$injector->getInstance('Hermes_Driver')
->markAs('submitted', $time);
$notification->push(
_("Your time was successfully submitted."), 'horde.success');
$vars = new Horde_Variables();
} catch (Horde_Exception $e) {
$notification->push(sprintf(_("There was an error submitting your time: %s"), $e->getMessage()), 'horde.error');
}
}
break;
}
// We are displaying all time.
$tabs = Hermes::tabs();
$criteria = array(
'employee' => $registry->getAuth(),
'submitted' => false,
'link_page' => 'time.php');
$table = new Hermes_Table(
'week',
$vars,
array(
'title' => _("My Unsubmitted Time"),
'name' => 'hermes/hours',
'params' => $criteria)
);
$view = new Horde_View(['templatePath' => HERMES_TEMPLATES . '/time']);
$view->postUrl = Horde::url('time.php', false, -1);
$view->sessionId = Horde_Util::formInput();
$view->table = $table->render();
$page_output->header(array(
'title' => _("My Time")
));
$notification->notify(array('listeners' => 'status'));
echo $tabs;
echo $view->render('form');
$page_output->footer();