Work in progress on configurable display options.
[timetracker.git] / display_options.php
diff --git a/display_options.php b/display_options.php
new file mode 100644 (file)
index 0000000..222cc25
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+import('ttConfigHelper');
+import('form.Form');
+
+// Access checks.
+if (!ttAccessAllowed('manage_basic_settings')) {
+  header('Location: access_denied.php');
+  exit();
+}
+// End of access checks.
+
+$config = new ttConfigHelper($user->getConfig());
+
+if ($request->isPost()) {
+  $cl_time_note_on_separate_row = trim($request->getParameter('time_note_on_separate_row'));
+  $cl_report_note_on_separate_row = trim($request->getParameter('report_note_on_separate_row'));
+} else {
+  $cl_time_note_on_separate_row = $config->getDefinedValue('time_note_on_separate_row');
+  $cl_report_note_on_separate_row = $config->getDefinedValue('report_note_on_separate_row');
+}
+
+$form = new Form('displayOptionsForm');
+// $form->addInput(array('type'=>'checkbox','name'=>'time_client','value'=>$cl_time_client));
+// $form->addInput(array('type'=>'checkbox','name'=>'time_cf_1','value'=>$cl_time_cf_1));
+// $form->addInput(array('type'=>'checkbox','name'=>'time_project','value'=>$cl_time_project));
+// $form->addInput(array('type'=>'checkbox','name'=>'time_task','value'=>$cl_time_task));
+// $form->addInput(array('type'=>'checkbox','name'=>'time_start','value'=>$cl_time_start));
+// $form->addInput(array('type'=>'checkbox','name'=>'time_finish','value'=>$cl_time_finish));
+// $form->addInput(array('type'=>'checkbox','name'=>'time_duration','value'=>$cl_time_duration));
+// $form->addInput(array('type'=>'checkbox','name'=>'time_note','value'=>$cl_time_note));
+$form->addInput(array('type'=>'checkbox','name'=>'time_note_on_separate_row','value'=>$cl_time_note_on_separate_row));
+// TODO: consider adding other fields (timesheet, work_units, invoice, approved, cost, paid)?
+
+// Reports.
+$form->addInput(array('type'=>'checkbox','name'=>'report_note_on_separate_row','value'=>$cl_report_note_on_separate_row));
+// TODO: add PDF break controller here.
+
+$form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save')));
+
+if ($request->isPost()){
+  if ($err->no()) {
+    // Update config.
+    $config->setDefinedValue('time_note_on_separate_row', $cl_time_note_on_separate_row);
+    $config->setDefinedValue('report_note_on_separate_row', $cl_report_note_on_separate_row);
+    if ($user->updateGroup(array('config' => $config->getConfig()))) {
+      header('Location: success.php');
+      exit();
+    } else
+      $err->add($i18n->get('error.db'));
+  }
+}
+
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('title', $i18n->get('title.display_options'));
+$smarty->assign('content_page_name', 'display_options.tpl');
+$smarty->display('index.tpl');