Fixed a comment.
[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 = $user->getConfigHelper();
41
42 if ($request->isPost()) {
43   $cl_time_note_on_separate_row = $request->getParameter('time_note_on_separate_row');
44   $cl_report_note_on_separate_row = $request->getParameter('report_note_on_separate_row');
45 } else {
46   $cl_time_note_on_separate_row = $config->getDefinedValue('time_note_on_separate_row');
47   $cl_report_note_on_separate_row = $config->getDefinedValue('report_note_on_separate_row');
48 }
49
50 $form = new Form('displayOptionsForm');
51
52 // Time page.
53 // $form->addInput(array('type'=>'checkbox','name'=>'time_client','value'=>$cl_time_client));
54 // $form->addInput(array('type'=>'checkbox','name'=>'time_cf_1','value'=>$cl_time_cf_1));
55 // $form->addInput(array('type'=>'checkbox','name'=>'time_project','value'=>$cl_time_project));
56 // $form->addInput(array('type'=>'checkbox','name'=>'time_task','value'=>$cl_time_task));
57 // $form->addInput(array('type'=>'checkbox','name'=>'time_start','value'=>$cl_time_start));
58 // $form->addInput(array('type'=>'checkbox','name'=>'time_finish','value'=>$cl_time_finish));
59 // $form->addInput(array('type'=>'checkbox','name'=>'time_duration','value'=>$cl_time_duration));
60 // $form->addInput(array('type'=>'checkbox','name'=>'time_note','value'=>$cl_time_note));
61 $form->addInput(array('type'=>'checkbox','name'=>'time_note_on_separate_row','value'=>$cl_time_note_on_separate_row));
62 // TODO: consider adding other fields (timesheet, work_units, invoice, approved, cost, paid)?
63
64 // Reports.
65 $form->addInput(array('type'=>'checkbox','name'=>'report_note_on_separate_row','value'=>$cl_report_note_on_separate_row));
66 // TODO: add PDF break controller here.
67
68 $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save')));
69
70 if ($request->isPost()){
71   if ($err->no()) {
72     // Update config.
73     $config->setDefinedValue('time_note_on_separate_row', $cl_time_note_on_separate_row);
74     $config->setDefinedValue('report_note_on_separate_row', $cl_report_note_on_separate_row);
75     if ($user->updateGroup(array('config' => $config->getConfig()))) {
76       header('Location: success.php');
77       exit();
78     } else
79       $err->add($i18n->get('error.db'));
80   }
81 }
82
83 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
84 $smarty->assign('title', $i18n->get('title.display_options'));
85 $smarty->assign('content_page_name', 'display_options.tpl');
86 $smarty->display('index.tpl');