return true;
}
+
+ // enablePlugin either enables or disables a specific plugin for team.
+ function enablePlugin($plugin, $enable = true)
+ {
+ global $user;
+ if (!$user->canManageTeam())
+ return false;
+
+ $plugin_array = explode(',', $user->plugins);
+ if ($enable && !in_array($plugin, $plugin_array))
+ $plugin_array[] = $plugin; // Add plugin to array.
+
+ if (!$enable && in_array($plugin, $plugin_array)) {
+ $key = array_search($plugin, $plugin_array);
+ if ($key !== false)
+ unset($plugin_array[$key]); // Remove plugin from array.
+ }
+
+ $plugins = implode(',', $plugin_array);
+ if ($plugins != $user->plugins) {
+ return ttTeamHelper::update($user->team_id, array(
+ 'name' => $user->team,
+ 'plugins' => $plugins));
+ }
+ return true;
+ }
}
-<table cellspacing="0" cellpadding="7" border="0" width="720">
- <tr><td valign="top">{$i18n.form.quota.hint}</td></tr>
-</table>
+{$forms.weekViewForm.open}
+<table cellspacing="1" cellpadding="2" border="0">
+ <tr>
+ <td align="right" nowrap>{$forms.weekViewForm.week_note.control}</td>
+ <td><label for="week_note">{$i18n.label.week_note}</label> <a href="https://www.anuko.com/lp/tt_11.htm" target="_blank">{$i18n.label.what_is_it}</a></td>
+ </tr>
+ <tr>
+ <td align="right" nowrap>{$forms.weekViewForm.week_list.control}</td>
+ <td><label for="week_note">{$i18n.label.week_list}</label> <a href="https://www.anuko.com/lp/tt_12.htm" target="_blank">{$i18n.label.what_is_it}</a></td>
+ </tr>
-{$forms.monthlyQuotasForm.open}
-<div style="padding: 0 0 10 0">
- <table border="0" class="divider">
- <tr>
- <td align="center">
- <table>
- <tr>
- <td>{$i18n.form.quota.workday_hours}:</td>
- <td>{$forms.monthlyQuotasForm.workdayHours.control}</td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-</div>
-<table>
<tr>
- <td>{$i18n.form.quota.year}:</td>
- <td>{$forms.monthlyQuotasForm.year.control}</td>
+ <td colspan="2"> </td>
</tr>
- <tr><td> </td></tr>
<tr>
- <td colspan="2">
- <table>
- <tr>
- <td class="tableHeaderCentered">{$i18n.form.quota.month}</td>
- <td class="tableHeaderCentered">{$i18n.form.quota.quota}</td>
- </tr>
-{foreach $months as $month}
- <tr>
- <td>{$month}:</td>
- <td>{$forms.monthlyQuotasForm.$month.control}</td>
- </tr>
-{/foreach}
- <tr><td colspan="2"> </td></tr>
- <tr><td colspan="2" style="text-align:center;"><input type="submit" name="btn_submit" value="{$i18n.button.save}"></td></tr>
- </table>
- </td>
+ <td colspan="2" height="50" align="center">{$forms.weekViewForm.btn_save.control}</td>
</tr>
</table>
-{$forms.monthlyQuotasForm.close}
+{$forms.weekViewForm.close}
exit();
}
-
-// Get selected year from url parameter.
-$selectedYear = $request->getParameter('year');
-if (!$selectedYear or !ttValidInteger($selectedYear)){
- $selectedYear = date('Y');
+if ($request->isPost()) {
+ $cl_week_note = $request->getParameter('week_note');
+ $cl_week_list = $request->getParameter('week_list');
} else {
- $selectedYear = (int) $selectedYear;
+ $plugins = explode(',', $user->plugins);
+ $cl_week_note = in_array('wn', $plugins);
+ $cl_week_list = in_array('wl', $plugins);
}
-// Months are zero indexed.
-$months = $i18n->monthNames;
-$quota = new MonthlyQuota();
+$form = new Form('weekViewForm');
+$form->addInput(array('type'=>'checkbox','name'=>'week_note','value'=>$cl_week_note));
+$form->addInput(array('type'=>'checkbox','name'=>'week_list','value'=>$cl_week_list));
+$form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
if ($request->isPost()){
- // Validate user input.
- if (!ttTimeHelper::isValidDuration($request->getParameter('workdayHours')))
- $err->add($i18n->getKey('error.field'), $i18n->getKey('form.quota.workday_hours'));
-
- for ($i = 0; $i < count($months); $i++){
- $val = $request->getParameter($months[$i]);
- if (!$quota->isValidQuota($val))
- $err->add($i18n->getKey('error.field'), $months[$i]);
- }
- // Finished validating user input.
-
- if ($err->no()) {
-
- // Handle workday hours.
- $hours = $quota->quotaToFloat($request->getParameter('workdayHours'));
- if ($hours != $user->workday_hours) {
- if (!ttTeamHelper::update($user->team_id, array('name'=>$user->team,'workday_hours'=>$hours)))
- $err->add($i18n->getKey('error.db'));
- }
-
- // Handle monthly quotas for a selected year.
- $selectedYear = (int) $request->getParameter('year');
- for ($i = 0; $i < count($months); $i++){
- if (!$quota->update($selectedYear, $i+1, $request->getParameter($months[$i])))
- $err->add($i18n->getKey('error.db'));
- }
-
- if ($err->no()) {
- // Redisplay the form.
- header('Location: quotas.php?year='.$selectedYear);
- exit();
- }
+ if (!ttTeamHelper::enablePlugin('wn', $cl_week_note) ||
+ !ttTeamHelper::enablePlugin('wl', $cl_week_list)) {
+ $err->add($i18n->getKey('error.db'));
}
}
-// Get monthly quotas for the entire year.
-$monthsData = $quota->get($selectedYear);
-$workdayHours = ttTimeHelper::toAbsDuration($user->workday_hours * 60, true);
-
-$form = new Form('weekViewForm');
-$form->addInput(array('type'=>'checkbox','name'=>'week_note','value'=>$cl_week_note));
-$form->addInput(array('type'=>'checkbox','name'=>'week_list','value'=>$cl_week_list));
-
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
-$smarty->assign('title', $i18n->getKey('label.week_view'));
+$smarty->assign('title', $i18n->getKey('title.week_view'));
$smarty->assign('content_page_name', 'week_view.tpl');
$smarty->display('index.tpl');