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