monthNames; $years = array(); for ($i=1990; $i < 2040; $i++) { array_push($years, array('id'=>$i, 'name'=>$i)); } $year = $request->getParameter("year"); if (!$year or !ttValidInteger($year)){ $year = date("Y"); }else { $year = intval($year); } $quota = new MonthlyQuota(); if ($request->isPost()){ $postedYear = $request->getParameter("years"); $year = intval($postedYear); for ($i=0; $i < count($months); $i++){ $quota->update($postedYear, $i+1, $request->getParameter($months[$i])); } } // returns months where January is month 1, not 0 $monthsData = $quota->get($year); $form->addInput(array('type'=>'combobox', 'name'=>'years', 'data'=>$years, 'datakeys'=>array('id', 'name'), 'value'=>$year, 'onchange'=>'yearChange(this.value);')); for ($i=0; $i < count($months); $i++) { $value = ""; if (array_key_exists($i+1, $monthsData)){ $value = $monthsData[$i+1]; } $name = $months[$i]; $form->addInput(array('type'=>'text', 'name'=>$name, 'maxlength'=>3, 'value'=> $value, 'style'=>'width:50px')); } $smarty->assign('months', $months); $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('content_page_name', 'cf_monthly_quota.tpl'); $smarty->display('index.tpl');