Ejemplo n.º 1
0
 public static function ContactContract(C3op_Projects_Action $action, C3op_Projects_HumanResource $humanResource, C3op_Projects_HumanResourceMapper $humanResourceMapper)
 {
     if ($humanResource->GetContact() > 0 && $humanResource->GetStatus() == C3op_Projects_HumanResourceStatusConstants::STATUS_FORESEEN) {
         $humanResource->SetStatus(C3op_Projects_HumanResourceStatusConstants::STATUS_CONTRACTED);
         $humanResourceMapper->update($humanResource);
         self::LogContracting($action);
     }
 }
Ejemplo n.º 2
0
 public function ContactDismiss(C3op_Projects_Action $action, C3op_Projects_HumanResource $humanResource, C3op_Projects_HumanResourceMapper $humanResourceMapper)
 {
     if ($humanResource->GetContact() > 0) {
         $humanResource->SetContact(0);
         $humanResourceMapper->update($humanResource);
         $this->LogDismiss($action);
     }
 }
Ejemplo n.º 3
0
 public function process($data)
 {
     if ($this->isValid($data) !== true) {
         throw new C3op_Form_HumanResourceCreateException('Invalid data!');
     } else {
         $db = Zend_Registry::get('db');
         $humanResourceMapper = new C3op_Projects_HumanResourceMapper($db);
         $humanResource = $humanResourceMapper->findById($this->id->GetValue());
         $actionMapper = new C3op_Projects_ActionMapper($this->db);
         $itsAction = $actionMapper->findById($humanResource->GetAction());
         $weHaveThedates = true;
         $predictedBeginDate = $this->predictedBeginDate->GetValue();
         $dateValidator = new C3op_Util_ValidDate();
         if ($dateValidator->isValid($predictedBeginDate)) {
             $converter = new C3op_Util_DateConverter();
             $newBeginDate = $converter->convertDateToMySQLFormat($predictedBeginDate);
         } else {
             $weHaveThedates = false;
         }
         $predictedFinishDate = $this->predictedFinishDate->GetValue();
         $dateValidator = new C3op_Util_ValidDate();
         if ($dateValidator->isValid($predictedFinishDate)) {
             $converter = new C3op_Util_DateConverter();
             $newFinishDate = $converter->convertDateToMySQLFormat($predictedFinishDate);
         } else {
             $weHaveThedates = false;
         }
         if (!$weHaveThedates) {
             throw new C3op_Form_HumanResourceCreateException('É obrigatório informar as datas contratadas.');
         }
         $formerPredictedBeginDate = $itsAction->GetPredictedBeginDate();
         $formerPredictedFinishDate = $itsAction->GetPredictedFinishDate();
         $dateChanged = false;
         if ($dateValidator->isValid($formerPredictedBeginDate) && $formerPredictedBeginDate != $newBeginDate) {
             $dateChanged = true;
         }
         if ($dateValidator->isValid($formerPredictedFinishDate) && $formerPredictedFinishDate != $newFinishDate) {
             $dateChanged = true;
         }
         $observation = $this->observation->GetValue();
         if ($dateChanged && $observation == "") {
             throw new C3op_Form_HumanResourceCreateException('Mudanças de data devem ser justificadas.');
         } else {
             C3op_Projects_HumanResourceContracting::ContactContract($itsAction, $humanResource, $humanResourceMapper);
             if ($observation != "" && $itsAction->GetPredictedBeginDate() != $newBeginDate) {
                 C3op_Projects_ActionDateChange::ChangePredictedBeginDate($itsAction, $actionMapper, $newBeginDate, $observation);
             }
             if ($observation != "" && $itsAction->GetPredictedFinishDate() != $newFinishDate) {
                 C3op_Projects_ActionDateChange::ChangePredictedFinishDate($itsAction, $actionMapper, $newFinishDate, $observation);
             }
             $actionMapper->update($itsAction);
             $humanResourceMapper->update($humanResource);
             return $humanResource->GetId();
         }
     }
 }
Ejemplo n.º 4
0
 public function process($data)
 {
     if ($this->isValid($data) !== true) {
         throw new C3op_Form_HumanResourceCreateException('Invalid data!');
     } else {
         $db = Zend_Registry::get('db');
         $humanResourceMapper = new C3op_Projects_HumanResourceMapper($db);
         $humanResource = new C3op_Projects_HumanResource();
         $humanResource->SetDescription($this->description->GetValue());
         $humanResource->SetContact($this->contact->GetValue());
         $humanResource->SetValue($this->value->GetValue());
         $humanResource->SetAction($this->action->GetValue());
         $humanResourceMapper->insert($humanResource);
         return $humanResource->GetId();
     }
 }
Ejemplo n.º 5
0
 public function process($data)
 {
     $db = Zend_Registry::get('db');
     $humanResourceMapper = new C3op_Projects_HumanResourceMapper($db);
     if ($this->isValid($data) !== true) {
         throw new C3op_Form_InstitutionEditException('Invalid data!');
     } else {
         $id = $data['id'];
         $humanResource = $humanResourceMapper->findById($id);
         $humanResource->SetDescription($this->description->GetValue());
         $humanResource->SetContact($this->contact->GetValue());
         $humanResource->SetValue($this->value->GetValue());
         $humanResource->SetAction($this->action->GetValue());
         $humanResourceMapper->update($humanResource);
         return $humanResource->GetId();
     }
 }
Ejemplo n.º 6
0
 private function initHumanResourceWithCheckedId(C3op_Projects_HumanResourceMapper $mapper)
 {
     return $mapper->findById($this->checkIdFromGet());
 }