コード例 #1
0
ファイル: OutlayMapper.php プロジェクト: racporto/c3op
 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]));
 }
コード例 #2
0
ファイル: OutlayCreate.php プロジェクト: racporto/c3op
 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);
     }
 }
コード例 #3
0
ファイル: ProjectController.php プロジェクト: racporto/c3op
 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}";
 }