public function process($data) { if ($this->isValid($data) !== true) { throw new C3op_Form_ReceivableCreateException('Invalid data!'); } else { $db = Zend_Registry::get('db'); $receivableMapper = new C3op_Projects_ReceivableMapper($db); $predictedDate = $this->predictedDate->GetValue(); $dateValidator = new C3op_Util_ValidDate(); if ($dateValidator->isValid($predictedDate)) { $converter = new C3op_Util_DateConverter(); $dateForMysql = $converter->convertDateToMySQLFormat($predictedDate); $predictedDateConvertedToMySQL = $dateForMysql; } $realDate = $this->realDate->GetValue(); $dateValidator = new C3op_Util_ValidDate(); if ($dateValidator->isValid($realDate)) { $converter = new C3op_Util_DateConverter(); $dateForMysql = $converter->convertDateToMySQLFormat($realDate); $realDateConvertedToMySQL = $dateForMysql; $receivable->SetRealDate($realDateConvertedToMySQL); } $receivable = new C3op_Projects_Receivable($this->project->GetValue(), $predictedDateConvertedToMySQL, $this->predictedValue->GetValue()); $receivable->SetTitle($this->title->GetValue()); $receivable->SetProject((double) $this->project->GetValue()); $receivable->SetRealValue((double) $this->realValue->GetValue()); $receivableMapper->insert($receivable); } }
public function getAllProducts(C3op_Projects_Receivable $r) { $result = array(); foreach ($this->db->query(sprintf('SELECT id FROM projects_actions WHERE requirement_for_receiving = %d;', $r->GetId())) as $row) { $result[] = $row['id']; } return $result; }