Removed show holidays config option.
[timetracker.git] / display_options.php
1 <?php
2 // +----------------------------------------------------------------------+
3 // | Anuko Time Tracker
4 // +----------------------------------------------------------------------+
5 // | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
6 // +----------------------------------------------------------------------+
7 // | LIBERAL FREEWARE LICENSE: This source code document may be used
8 // | by anyone for any purpose, and freely redistributed alone or in
9 // | combination with other software, provided that the license is obeyed.
10 // |
11 // | There are only two ways to violate the license:
12 // |
13 // | 1. To redistribute this code in source form, with the copyright
14 // |    notice or license removed or altered. (Distributing in compiled
15 // |    forms without embedded copyright notices is permitted).
16 // |
17 // | 2. To redistribute modified versions of this code in *any* form
18 // |    that bears insufficient indications that the modifications are
19 // |    not the work of the original author(s).
20 // |
21 // | This license applies to this document only, not any other software
22 // | that it may be combined with.
23 // |
24 // +----------------------------------------------------------------------+
25 // | Contributors:
26 // | https://www.anuko.com/time_tracker/credits.htm
27 // +----------------------------------------------------------------------+
28
29 require_once('initialize.php');
30 import('ttConfigHelper');
31 import('form.Form');
32
33 // Access checks.
34 if (!ttAccessAllowed('manage_basic_settings')) {
35   header('Location: access_denied.php');
36   exit();
37 }
38 // End of access checks.
39
40 $config = new ttConfigHelper($user->getConfig());
41
42 if ($request->isPost()) {
43   $cl_menu_week = $request->getParameter('menu_week');
44   $cl_time_note_on_separate_row = $request->getParameter('time_note_on_separate_row');
45   $cl_report_note_on_separate_row = $request->getParameter('report_note_on_separate_row');
46 } else {
47   $cl_menu_week = $config->getDefinedValue('menu_week');
48   $cl_time_note_on_separate_row = $config->getDefinedValue('time_note_on_separate_row');
49   $cl_report_note_on_separate_row = $config->getDefinedValue('report_note_on_separate_row');
50 }
51
52 $form = new Form('displayOptionsForm');
53 // Menu.
54 $form->addInput(array('type'=>'checkbox','name'=>'menu_week','value'=>$cl_menu_week));
55
56 // Time page.
57 // $form->addInput(array('type'=>'checkbox','name'=>'time_client','value'=>$cl_time_client));
58 // $form->addInput(array('type'=>'checkbox','name'=>'time_cf_1','value'=>$cl_time_cf_1));
59 // $form->addInput(array('type'=>'checkbox','name'=>'time_project','value'=>$cl_time_project));
60 // $form->addInput(array('type'=>'checkbox','name'=>'time_task','value'=>$cl_time_task));
61 // $form->addInput(array('type'=>'checkbox','name'=>'time_start','value'=>$cl_time_start));
62 // $form->addInput(array('type'=>'checkbox','name'=>'time_finish','value'=>$cl_time_finish));
63 // $form->addInput(array('type'=>'checkbox','name'=>'time_duration','value'=>$cl_time_duration));
64 // $form->addInput(array('type'=>'checkbox','name'=>'time_note','value'=>$cl_time_note));
65 $form->addInput(array('type'=>'checkbox','name'=>'time_note_on_separate_row','value'=>$cl_time_note_on_separate_row));
66 // TODO: consider adding other fields (timesheet, work_units, invoice, approved, cost, paid)?
67
68 // Reports.
69 $form->addInput(array('type'=>'checkbox','name'=>'report_note_on_separate_row','value'=>$cl_report_note_on_separate_row));
70 // TODO: add PDF break controller here.
71
72 $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save')));
73
74 if ($request->isPost()){
75   if ($err->no()) {
76     // Update config.
77     $config->setDefinedValue('menu_week', $cl_menu_week);
78     $config->setDefinedValue('time_note_on_separate_row', $cl_time_note_on_separate_row);
79     $config->setDefinedValue('report_note_on_separate_row', $cl_report_note_on_separate_row);
80     if ($user->updateGroup(array('config' => $config->getConfig()))) {
81       header('Location: success.php');
82       exit();
83     } else
84       $err->add($i18n->get('error.db'));
85   }
86 }
87
88 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
89 $smarty->assign('show_week_menu', $user->isPluginEnabled('wv'));
90 $smarty->assign('title', $i18n->get('title.display_options'));
91 $smarty->assign('content_page_name', 'display_options.tpl');
92 $smarty->display('index.tpl');