-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsearch.php
More file actions
100 lines (85 loc) · 2.91 KB
/
search.php
File metadata and controls
100 lines (85 loc) · 2.91 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
93
94
95
96
97
98
99
100
<?php
/**
* Copyright 2004-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 Jason M. Felice <jason.m.felice@gmail.com>
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('hermes');
if (Hermes::showAjaxView()) {
Horde::url('', true)->setAnchor('search')->redirect();
}
$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');
}
$criteria = null;
$formname = $vars->get('formname');
switch ($formname) {
case 'hermes_form_search':
$form = new Hermes_Form_Search($vars);
$form->validate($vars);
$criteria = $form->getSearchCriteria($vars);
if (is_null($criteria)) {
$session->remove('hermes', 'search_criteria');
} else {
$session->set('hermes', 'search_criteria', $vars);
}
break;
case 'hermes_form_export':
try {
$vars->set('actionID', 'search_export');
$registry->callAppMethod('hermes', 'download', array('args' => array($vars)));
} catch (Horde_Exception $e) {
$notification->push($e->getMessage(), 'horde.error');
}
}
$title = _("Search for Time");
if (!($searchVars = $session->get('hermes', 'search_criteria'))) {
$searchVars = $vars;
}
$form = new Hermes_Form_Search($searchVars);
$page_output->header(array(
'title' => $title
));
$notification->notify(array('listeners' => 'status'));
$form->renderActive(new Horde_Form_Renderer(), $searchVars, Horde::url('search.php'), 'post');
echo '<br />';
if ($session->exists('hermes', 'search_criteria')) {
echo Hermes::tabs();
if (is_null($criteria)) {
$criteria = $form->getSearchCriteria($searchVars);
}
$table = new Hermes_Table('results', $vars,
array('title' => _("Search Results"),
'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();
echo $view->render('form');
}
echo '<br />';
$exportForm = new Hermes_Form_Export($vars);
$exportForm->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('search.php'), 'post');
$page_output->footer();