X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=week.php;h=9af3564414f5d4e86efaccad1f6416f1b8cad5c3;hb=HEAD;hp=05d399214d4d8e8677121006859f1a72d3a3442a;hpb=4334f16faa68ecaec5aceb5c16bb500d62a3688f;p=timetracker.git diff --git a/week.php b/week.php index 05d39921..9af35644 100644 --- a/week.php +++ b/week.php @@ -58,6 +58,9 @@ if (!$user->behalf_id && !$user->can('track_own_time') && !$user->adjustBehalfId // End of access checks. $showClient = $user->isPluginEnabled('cl'); +$trackingMode = $user->getTrackingMode(); +$showProject = MODE_PROJECTS == $trackingMode || MODE_PROJECTS_AND_TASKS == $trackingMode; +$showTask = MODE_PROJECTS_AND_TASKS == $trackingMode; $showFiles = $user->isPluginEnabled('at'); // Initialize and store date in session. @@ -70,7 +73,7 @@ if(!$cl_date) $_SESSION['date'] = $cl_date; // Determine selected week start and end dates. -$weekStartDay = $user->week_start; +$weekStartDay = $user->getWeekStart(); $t_arr = localtime($selected_date->getTimestamp()); $t_arr[5] = $t_arr[5] + 1900; if ($t_arr[6] < $weekStartDay) @@ -140,29 +143,33 @@ else // Build day totals (total durations for each day in week). $dayTotals = ttWeekViewHelper::getDayTotals($dataArray, $dayHeaders); +$showWeekNote = $user->isOptionEnabled('week_note'); +$showWeekNotes = $user->isOptionEnabled('week_notes'); + // Define rendering class for a label field to the left of durations. class LabelCellRenderer extends DefaultCellRenderer { function render(&$table, $value, $row, $column, $selected = false) { global $user; + $showNotes = $user->isOptionEnabled('week_notes'); $this->setOptions(array('width'=>200,'valign'=>'middle')); // Special handling for a new week entry (row 0, or 0 and 1 if we show notes). if (0 == $row) { $this->setOptions(array('style'=>'text-align: center; font-weight: bold; vertical-align: top;')); - } else if ($user->isPluginEnabled('wvns') && (1 == $row)) { + } else if ($showNotes && (1 == $row)) { $this->setOptions(array('style'=>'text-align: right; vertical-align: top;')); - } else if ($user->isPluginEnabled('wvns') && (0 != $row % 2)) { + } else if ($showNotes && (0 != $row % 2)) { $this->setOptions(array('style'=>'text-align: right;')); } // Special handling for not billable entries. - $ignoreRow = $user->isPluginEnabled('wvns') ? 1 : 0; + $ignoreRow = $showNotes ? 1 : 0; if ($row > $ignoreRow) { $row_id = $table->getValueAtName($row,'row_id'); $billable = ttWeekViewHelper::parseFromWeekViewRow($row_id, 'bl'); if (!$billable) { - if (($user->isPluginEnabled('wvns') && (0 == $row % 2)) || !$user->isPluginEnabled('wvns')) { + if (($showNotes && (0 == $row % 2)) || !$showNotes) { $this->setOptions(array('style'=>'color: red;')); // TODO: style it properly in CSS. } } @@ -176,6 +183,7 @@ class LabelCellRenderer extends DefaultCellRenderer { class WeekViewCellRenderer extends DefaultCellRenderer { function render(&$table, $value, $row, $column, $selected = false) { global $user; + $showNotes = $user->isOptionEnabled('week_notes'); $field_name = $table->getValueAt($row,$column)['control_id']; // Our text field names (and ids) are like x_y (row_column). $field = new TextField($field_name); @@ -186,11 +194,11 @@ class WeekViewCellRenderer extends DefaultCellRenderer { $field->setFormName($table->getFormName()); $field->setStyle('width: 60px;'); // TODO: need to style everything properly, eventually. // Provide visual separation for new entry row. - $rowToSeparate = $user->isPluginEnabled('wvns') ? 1 : 0; + $rowToSeparate = $showNotes ? 1 : 0; if ($rowToSeparate == $row) { $field->setStyle('width: 60px; margin-bottom: 40px'); } - if ($user->isPluginEnabled('wvns')) { + if ($showNotes) { if (0 == $row % 2) { $field->setValue($table->getValueAt($row,$column)['duration']); // Duration for even rows. } else { @@ -330,7 +338,7 @@ if ($custom_fields && $custom_fields->fields[0]) { $form->addInput(array('type'=>'combobox','name'=>'cf_1', 'style'=>'width: 250px;', 'value'=>$cl_cf_1, - 'data'=>$custom_fields->options, + 'data'=>CustomFields::getOptions($custom_fields->fields[0]['id']), 'empty'=>array(''=>$i18n->get('dropdown.select')))); } } @@ -380,7 +388,7 @@ if ($request->isPost()) { $control_id = $rowNumber.'_'.$dayHeader; // Handle durations and comments in separate blocks of code. - if (!$user->isPluginEnabled('wvns') || (0 == $rowNumber % 2)) { + if (!$showWeekNotes || (0 == $rowNumber % 2)) { // Handle durations row here. // Obtain existing and posted durations. @@ -419,7 +427,7 @@ if ($request->isPost()) { // Note: no need to check for a possible conflict with an already existing row // because we are doing an insert that does not affect already existing data. - if ($user->isPluginEnabled('wvn')) { + if ($showWeekNote) { $fields['note'] = $request->getParameter('note'); } } @@ -427,7 +435,7 @@ if ($request->isPost()) { $fields['start_date'] = $startDate->toString(DB_DATEFORMAT); // To be able to determine date for the entry using $dayHeader. $fields['duration'] = $postedDuration; $fields['browser_today'] = $request->getParameter('browser_today', null); - if ($user->isPluginEnabled('wvns')) { + if ($showWeekNotes) { // Take note value from the control below duration. $noteRowNumber = $rowNumber + 1; $note_control_id = $noteRowNumber.'_'.$dayHeader; @@ -445,7 +453,7 @@ if ($request->isPost()) { } if (!$result) break; // Break out of the loop in case of first error. - } else if ($user->isPluginEnabled('wvns')) { + } else if ($showWeekNotes) { // Handle commments row here. // Obtain existing and posted comments. @@ -509,8 +517,12 @@ $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="fillDropdowns()"'); $smarty->assign('timestring', $startDate->toString($user->date_format).' - '.$endDate->toString($user->date_format)); $smarty->assign('time_records', $records); -$smarty->assign('show_navigation', !$user->getConfigOption('menu_week')); +$smarty->assign('show_navigation', !$user->isOptionEnabled('week_menu')); $smarty->assign('show_client', $showClient); +$smarty->assign('show_project', $showProject); +$smarty->assign('show_task', $showTask); +$smarty->assign('show_week_note', $showWeekNote); +$smarty->assign('show_week_list', $user->isOptionEnabled('week_list')); $smarty->assign('show_files', $showFiles); $smarty->assign('title', $i18n->get('menu.week')); $smarty->assign('content_page_name', 'week.tpl');