~zalongwa/hrmis-ncaa/trunk

« back to all changes in this revision

Viewing changes to modules/ngorongoroDemographic/lib/iHRIS_Module_ncaaDemographic.php

  • Committer: Juma Lungo
  • Date: 2018-08-03 07:25:07 UTC
  • Revision ID: juma.lungo@zalongwa.com-20180803072507-d39vmm1d2kvo9u5y
limited birthdat to more than 18years

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
            );
156
156
    } */
157
157
 
 
158
    public static function getHooks() {
 
159
        return array(
 
160
                'validate_form_demographic' => 'validate_form_demographic',
 
161
                );
 
162
    }
158
163
 
159
164
    public function action_demographic($obj) {
160
165
        if (!$obj instanceof iHRIS_PageView) {
163
168
        return $obj->addChildForms('demographic', 'siteContent');
164
169
    }
165
170
 
 
171
    public function validate_form_demographic( $form ) {
 
172
        $year = $form->birth_date->year();
 
173
        $month = $form->birth_date->month();
 
174
        $day = $form->birth_date->day();
 
175
        $dob = $year.'-'.$month.'-'.$day;
 
176
        $dob = date("Y-m-d",strtotime($dob));
 
177
        $dob = new DateTime($dob);
 
178
        $today = new DateTime();
 
179
        $age = $dob->diff($today)->y;
 
180
        if ($age < 18) {
 
181
            $form->setInvalidMessage('birth_date','Age must be greater than 18');
 
182
        }
 
183
        
 
184
     }
 
185
 
166
186
 
167
187
}
168
188
# Local Variables: