Exemplo n.º 1
0
 private function populateRequirementForReceivingField($projectId, C3op_Form_ActionCreate $form, $setedReceivableId = 0)
 {
     $validator = new C3op_Util_ValidId();
     if ($validator->isValid($projectId)) {
         $requirementForReceivingField = $form->getElement('requirementForReceiving');
         if (!isset($this->projectMapper)) {
             $this->projectMapper = new C3op_Projects_ProjectMapper($this->db);
         }
         if (!isset($this->receivableMapper)) {
             $this->receivableMapper = new C3op_Projects_ReceivableMapper($this->db);
         }
         $theProject = $this->projectMapper->findById($projectId);
         $allReceivables = $this->projectMapper->getAllReceivables($theProject);
         while (list($key, $receivableId) = each($allReceivables)) {
             $eachReceivable = $this->receivableMapper->findById($receivableId);
             $requirementForReceivingField->addMultiOption($receivableId, $eachReceivable->GetTitle());
         }
         $requirementForReceivingField->setValue($setedReceivableId);
     } else {
         throw new C3op_Projects_ActionException("Action needs a positive integer project id to find possible receivables to to be a requirement.");
     }
 }
Exemplo n.º 2
0
 private function populateContactsField($humanResourceId, C3op_Form_HumanResourceCreate $form, $contactId = 0)
 {
     $validator = new C3op_Util_ValidId();
     $parentActionId = 0;
     if ($validator->isValid($humanResourceId)) {
         $subordinatedToField = $form->getElement('subordinatedTo');
         if (!isset($this->actionMapper)) {
             $this->actionMapper = new C3op_Projects_ActionMapper($this->db);
         }
         if ($contactId > 0) {
             $thisAction = $this->actionMapper->findById($contactId);
             $parentActionId = $thisAction->GetSubordinatedTo();
             $allOtherActionsInProject = $this->actionMapper->getAllOtherActions($thisAction);
         } else {
             if (!isset($this->projectMapper)) {
                 $this->projectMapper = new C3op_Projects_ProjectMapper($this->db);
             }
             $thisProject = $this->projectMapper->findById($humanResourceId);
             $allOtherActionsInProject = $this->projectMapper->getAllActions($thisProject);
         }
         while (list($key, $contactId) = each($allOtherActionsInProject)) {
             $eachAction = $this->actionMapper->findById($contactId);
             $subordinatedToField->addMultiOption($contactId, $eachAction->GetTitle());
         }
         $subordinatedToField->setValue($parentActionId);
     } else {
         throw new C3op_Projects_ActionException("Action needs a positive integer project id to find other actions.");
     }
 }
Exemplo n.º 3
0
 public function testThatNegativeIsntValidId()
 {
     $validator = new C3op_Util_ValidId();
     $id = -12;
     $this->assertFalse($validator->isValid($id));
 }
Exemplo n.º 4
0
 private function PopulateProjectFields($projectId, C3op_Form_ReceivableCreate $form)
 {
     $validator = new C3op_Util_ValidId();
     if ($validator->isValid($projectId)) {
         $projectField = $form->getElement('project');
         $projectField->setValue($projectId);
         if (!isset($this->projectMapper)) {
             $this->projectMapper = new C3op_Projects_ProjectMapper($this->db);
         }
         $thisProject = $this->projectMapper->findById($projectId);
         $this->view->projectTitle = $thisProject->GetTitle();
         $this->view->projectId = $projectId;
         return $projectId;
     } else {
         throw new C3op_Projects_ReceivableException("Receivable needs a positive integer project id.");
     }
 }
Exemplo n.º 5
0
 private function PopulateContactFields($contactId, C3op_Form_LinkageCreate $form)
 {
     $validator = new C3op_Util_ValidId();
     if ($validator->isValid($contactId)) {
         $contactField = $form->getElement('contact');
         $contactField->setValue($contactId);
         if (!isset($this->contactMapper)) {
             $this->contactMapper = new C3op_Register_ContactMapper($this->db);
         }
         $thisContact = $this->contactMapper->findById($contactId);
         $this->view->contactName = $thisContact->GetName();
         $this->view->linkContactDetail = "/register/contact/detail/?id=" . $thisContact->GetId();
         C3op_Util_FormFieldValueSetter::SetValueToFormField($form, 'contact', $contactId);
         return $contactId;
     } else {
         throw new C3op_Register_LinkageException("Linkage needs a positive integer contact id.");
     }
 }