/** * Save Kpi * @param sfWebRequest $request * @return None */ public function executeSaveKpi(sfWebRequest $request) { $this->form = new SaveKpiForm(array(), array(), true); $this->listJobTitle = $this->getJobTitleService()->getJobTitleList(); $kpiService = $this->getKpiService(); $this->defaultRate = $kpiService->getKpiDefaultRate(); if ($this->getUser()->hasFlash('templateMessage')) { $this->templateMessage = $this->getUser()->getFlash('templateMessage'); } if ($request->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { try { $defineKpi = new DefineKpi(); $defineKpi->setJobtitlecode($request->getParameter('txtJobTitle')); $defineKpi->setDesc(trim($request->getParameter('txtDescription'))); if (trim($request->getParameter('txtMinRate')) != "") { $defineKpi->setMin($request->getParameter('txtMinRate')); } if (trim($request->getParameter('txtMaxRate')) != "") { $defineKpi->setMax($request->getParameter('txtMaxRate')); } if ($request->getParameter('chkDefaultScale') == 1) { $defineKpi->setDefault(1); } else { $defineKpi->setDefault(0); } $defineKpi->setIsactive(1); $kpiService->saveKpi($defineKpi); $this->getUser()->setFlash('templateMessage', array('SUCCESS', __(TopLevelMessages::SAVE_SUCCESS) . ' <a href="listDefineKpi">' . __('View KPI List') . '</a>')); $this->redirect('performance/saveKpi'); } catch (Doctrine_Validator_Exception $e) { $this->setMessage('WARNING', array($e->getMessage())); $this->errorMessage = $e->getMessage(); } } } }
/** * Save all defined kpi's from selected Job Title * @param $jobTitleId * @param $copiedKpis * @return None */ public function copyKpi($toJobTitle, $fromJobTitle) { try { $this->getKpiDao()->deleteKpiForJobTitle($toJobTitle); $kpiList = $this->getKpiForJobTitle($fromJobTitle); foreach ($kpiList as $fromKpi) { $kpi = new DefineKpi(); $kpi->setJobtitlecode($toJobTitle); $kpi->setDesc($fromKpi->getDesc()); $kpi->setMin($fromKpi->getMin()); $kpi->setMax($fromKpi->getMax()); $kpi->setDefault(0); $kpi->setIsactive(1); $this->saveKpi($kpi); } return true; } catch (Exception $e) { throw new PerformanceServiceException($e->getMessage()); } }