public function update(C3op_Projects_Outlay $o) { if (!isset($this->identityMap[$o])) { throw new C3op_Projects_OutlayMapperException('Object has no ID, cannot update.'); } $this->db->exec(sprintf('UPDATE projects_outlays SET project = %d, action = %d, human_resource = %d, predicted_value = %.2f, predicted_date = \'%s\', recurrent = %d, observation = \'%s\' WHERE id = %d;', $o->GetProject(), $o->GetAction(), $o->GetHumanResource(), $o->GetPredictedValue(), $o->GetPredictedDate(), $o->GetRecurrent(), $o->GetObservation(), $this->identityMap[$o])); }
private function outlayAsAParcel(C3op_Projects_Outlay $outlay) { $humanResourceId = $outlay->GetHumanResource(); if (!isset($this->humanResourceMapper)) { $this->humanResourceMapper = new C3op_Projects_HumanResourceMapper($this->db); } $outlayHumanResource = $this->humanResourceMapper->findById($humanResourceId); $listOutlaysForHumanResource = $this->humanResourceMapper->getAllOutlays($outlayHumanResource); $totalParcels = count($listOutlaysForHumanResource); $parcelsCount = 0; foreach ($listOutlaysForHumanResource as $parcelId) { $thisParcel = $this->outlayMapper->FindById($parcelId); $parcelsCount++; if ($thisParcel->GetId() == $outlay->GetId()) { $myParcel = $parcelsCount; } } return "{$myParcel}/{$totalParcels}"; }