3 require_once('initialize.php');
4 require_once('plugins/MonthlyQuota.class.php');
8 if (!ttAccessCheck(right_manage_team)) {
9 header('Location: access_denied.php');
13 $form = new Form('monthlyQuotaForm');
14 // months are zero indexed
15 $months = $i18n->monthNames;
17 for ($i=1990; $i < 2040; $i++) {
18 array_push($years, array('id'=>$i, 'name'=>$i));
21 $year = $request->getParameter("year");
22 if (!$year or !ttValidInteger($year)){
25 $year = intval($year);
28 $quota = new MonthlyQuota();
30 if ($request->isPost()){
31 $postedYear = $request->getParameter("years");
32 $year = intval($postedYear);
34 for ($i=0; $i < count($months); $i++){
35 $res = $quota->update($postedYear, $i+1, $request->getParameter($months[$i]));
38 header('Location: profile_edit.php');
41 $err->add($i18n->getKey('error.db'));
44 // returns months where January is month 1, not 0
45 $monthsData = $quota->get($year);
47 $form->addInput(array('type'=>'combobox', 'name'=>'years', 'data'=>$years, 'datakeys'=>array('id', 'name'), 'value'=>$year, 'onchange'=>'yearChange(this.value);'));
48 for ($i=0; $i < count($months); $i++) {
50 if (array_key_exists($i+1, $monthsData)){
51 $value = $monthsData[$i+1];
54 $form->addInput(array('type'=>'text', 'name'=>$name, 'maxlength'=>3, 'value'=> $value, 'style'=>'width:50px'));
56 $smarty->assign('months', $months);
57 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
58 $smarty->assign('content_page_name', 'cf_monthly_quota.tpl');
59 $smarty->display('index.tpl');