/** * function processData * <pre> * Processes the data for this form. * </pre> * @return [void] */ function processData() { $activityFormInstance = new RowManager_ActivityScheduleManager(); if ($this->personal_form_id != '') { $activityFormInstance->setStaffScheduleID($this->personal_form_id); } // if this is a delete operation then if ($this->opType == 'D') { if ($this->shouldDelete) { // Delete from the activity-schedule table as well // NOTE: COULD REPLACE WITH A CASCADING FK DELETE $matchList = $activityFormInstance->getListIterator(); $matchArray = $matchList->getDataList(); reset($matchArray); foreach (array_keys($matchArray) as $key) { $row = current($matchArray); $primaryID = $row['activityschedule_id']; if ($primaryID != '') { $deleter = new RowManager_ActivityScheduleManager($primaryID); $deleter->deleteEntry(); } next($matchArray); } /** Must delete entry from matching table BEFORE deleting activity entry * so that FK constraint is not violated **/ $db_error_msg = $this->dataManager->deleteEntry(); $this->setErrorMessage($db_error_msg); } } else { // else // save the value of the Foriegn Key(s) $this->formValues['person_id'] = $this->person_id; // $this->formValues[ 'staffactivity_id' ] = $this->staffactivity_id; // $this->formValues[ 'activitytype_id' ] = $this->activitytype_id; /*[RAD_ADMINBOX_FOREIGNKEY]*/ // check to see if dates are invalid, i.e. start date < form's first valid date OR end date > form's end date if ($this->form_start_date != '' && $this->form_end_date != '') { // check to see if dates are invalid, i.e. start date > end date if (strtotime($this->formValues['staffactivity_startdate']) > strtotime($this->formValues['staffactivity_enddate'])) { $this->dateSwitchMessage = 'Start date cannot be after end date!'; } else { if (strtotime($this->formValues['staffactivity_startdate']) < strtotime($this->form_start_date) || strtotime($this->formValues['staffactivity_enddate']) > strtotime($this->form_end_date)) { $this->dateContextMessage = 'Start and end dates must fall within the following date-range (inclusive):<br>'; $this->dateContextMessage .= $this->form_date_range; } else { // Store values in dataManager object $this->dataManager->loadFromArray($this->formValues); // Interlude: create new form instance record if none exists if ($this->personal_form_id == '') { $this->scheduleFormManager->createNewEntry(); $this->personal_form_id = $this->scheduleFormManager->getID(); } // Save the values into the Table. if (!$this->dataManager->isLoaded()) { $this->dataManager->createNewEntry(); // Update the schedule-activity match table $newID = $this->dataManager->getID(); $activityFormInstance->setStaffActivityID($newID); $activityFormInstance->setStaffScheduleID($this->personal_form_id); $activityFormInstance->createNewEntry(); } else { $this->dataManager->updateDBTable(); } } } } } // end if // now Clear out dataManager & FormValues $this->dataManager->clearValues(); $this->formValues = $this->dataManager->getArrayOfValues(); // on a successful update return staffactivity_id to '' $this->staffactivity_id = ''; return $this->personal_form_id; }