2
class iHRIS_Module_Baylor_Mentorship extends I2CE_Module {
3
public static function getMethods() {
5
'iHRIS_PageView->action_person_baylor_mentorship' => 'action_person_baylor_mentorship'
10
public static function getHooks() {
12
'validate_form_person_baylor_mentorship' => 'validate_form_person_baylor_mentorship'
15
public function action_person_baylor_mentorship($obj) {
16
if (!$obj instanceof iHRIS_PageView) {
19
return $obj->addChildForms('person_baylor_mentorship', 'end_date');
22
* Checks to make sure the end date is after the start date for the person position.
23
* @param I2CE_Form $form
25
public function validate_form_person_baylor_mentorship( $form ) {
26
if ( $form->start_date->isValid() && $form->end_date->isValid() ) {
27
if ( $form->start_date->compare( $form->end_date ) < 0 ) {
28
$form->getField('end_date')->setInvalid( "The end date must be after the start date." );
32
$personID = $form->getParent();
33
$ids = I2CE_FormStorage::search('person_baylor_mentorship', $personID );
34
//which would get the ids of the trainings for the person with id 'person|23123'.
36
//You can then loop through each of these ids....
37
$form_factory = I2CE_FormFactory::instance();
39
foreach($ids as $id) {
40
$mentorshipObj = $form_factory->createContainer('person_baylor_mentorship|' . $id);
41
if (!$mentorshipObj instanceof iHRIS_PersonBaylor_Mentorship) {
44
$mentorshipObj->populate();
46
//do the checks for the dates here.
47
if (( $form->start_date->compare( $mentorshipObj->start_date ) > 0 ) || ( $form->start_date->compare( $mentorshipObj->end_date ) < 0 )) {
50
} else if (( $form->end_date->compare( $mentorshipObj->start_date ) > 0 ) || ( $form->end_date->compare( $mentorshipObj->end_date ) < 0 )) {
53
}else if(( $form->start_date->compare( $mentorshipObj->start_date ) < 0 ) && ( $form->end_date->compare( $mentorshipObj->end_date ) > 0 )) {
61
$form->getField( "end_date" )->setInvalid( "The dates of the training overlap with another training" );