public function process($data) { $db = Zend_Registry::get('db'); $outlayMapper = new C3op_Projects_OutlayMapper($db); if ($this->isValid($data) !== true) { throw new C3op_Form_OutlayEditException('Invalid data!'); } else { $id = $data['id']; $outlay = $outlayMapper->findById($id); $outlay->SetAction($data['action']); $outlay->SetProject($data['project']); $outlay->SetHumanResource($data['humanResource']); $outlay->SetPredictedValue($data['predictedValue']); $outlay->SetPredictedDate($this->prepareDateValueToSet($data['predictedDate'], new C3op_Util_ValidDate(), new C3op_Util_DateConverter())); $outlay->SetObservation($data['observation']); $outlayMapper->update($outlay); } }
public function process($data) { if ($this->isValid($data) !== true) { throw new C3op_Form_OutlayCreateException('Invalid data!'); } else { $db = Zend_Registry::get('db'); $outlayMapper = new C3op_Projects_OutlayMapper($db); $outlay = new C3op_Projects_Outlay($this->humanResource->GetValue()); $outlay->SetAction($this->action->GetValue()); $outlay->SetProject($this->project->GetValue()); $outlay->SetPredictedValue($this->predictedValue->GetValue()); $predictedDate = $this->predictedDate->GetValue(); $dateValidator = new C3op_Util_ValidDate(); if ($dateValidator->isValid($predictedDate)) { $converter = new C3op_Util_DateConverter(); $dateForMysql = $converter->convertDateToMySQLFormat($predictedDate); $outlay->SetPredictedDate($dateForMysql); } $outlay->SetObservation($this->observation->GetValue()); $outlayMapper->insert($outlay); } }
public function outlaysAction() { $outlayMapper = new C3op_Projects_OutlayMapper($this->db); if (!isset($this->humanResourceMapper)) { $this->humanResourceMapper = new C3op_Projects_HumanResourceMapper($this->db); } $id = $this->checkIdFromGet(); $thisHumanResource = $this->humanResourceMapper->findById($id); $outlaysIdList = $this->humanResourceMapper->getAllOutlays($thisHumanResource); $outlaysList = array(); reset($outlaysList); $outlaysTotalValue = 0; $outlaysCounter = 0; foreach ($outlaysIdList as $outlayId) { $thisOutlay = $outlayMapper->findById($outlayId); $outlaysCounter++; if ($thisOutlay->GetObservation()) { $observation = $thisOutlay->GetObservation(); } else { $observation = "(#{$outlaysCounter})"; } if ($thisOutlay->GetPredictedValue()) { $value = $thisOutlay->GetPredictedValue(); } else { $value = "???"; } $outlaysList[$outlayId] = array('observation' => $observation, 'value' => $value, 'editLink' => '/projects/outlay/edit/?id=' . $outlayId); } $humanResourceInfo = array('title' => 'provisório...', 'linkDetail' => '/projects/project/detail/?id=' . 0, 'outlaysList' => $outlaysList); $this->view->humanResourceInfo = $humanResourceInfo; }