/**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $basicFormAction, $activityFormAction, $sortBy, $person_id, $staffscheduletype_id, $staffschedule_id = '', $fieldvalues_id = '', $fields_id = '', $activity_id = '', $showHidden = true)
 {
     $fieldList = FormProcessor_ApproveStaffSchedule::FORM_FIELDS;
     $fieldTypes = FormProcessor_ApproveStaffSchedule::FORM_FIELD_TYPES;
     $displayFields = FormProcessor_ApproveStaffSchedule::DISPLAY_FIELDS;
     parent::__construct($formAction, $fieldList, $displayFields);
     // initialize the object values
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->sortBy = $sortBy;
     $this->formAction = $formAction;
     $this->basic_formAction = $basicFormAction;
     $this->activity_formAction = $activityFormAction;
     //         $this->has_activity_form = $hasActivityForm;
     $this->form_id = $staffscheduletype_id;
     $this->personal_form_id = $staffschedule_id;
     $this->field_id = $fields_id;
     if ($fieldvalues_id != '') {
         $this->fieldvalues_id = $fieldvalues_id;
     }
     if ($activity_id != '') {
         $this->staffactivity_id = $activity_id;
     }
     // just let these be empty if they are passed as empty
     $this->person_id = $person_id;
     $this->has_activity_form = true;
     // set default, could be changed if form info exists
     $this->has_activity_contact_nums = false;
     // set default, could be changed if form info exists
     $this->activity_types_filter = array();
     $this->show_hidden_fields = $showHidden;
     $this->form_submitted = false;
     // Get form type context information
     $formType = new RowManager_StaffScheduleTypeManager($this->form_id);
     $formTypeList = $formType->getListIterator();
     $formTypeArray = $formTypeList->getDataList();
     if (count($formTypeArray) > 0) {
         $row = current($formTypeArray);
         // pick first record for grabbing form context data
         // Determine if form should have associated activities
         $has_activities = $row['staffscheduletype_has_activities'];
         if ($has_activities == '0') {
             $this->has_activity_form = false;
         }
         // Determine if form activities require contact phone #s
         $has_activity_phone_nums = $row['staffscheduletype_has_activity_phone'];
         if ($has_activity_phone_nums == '1') {
             $this->has_activity_contact_nums = true;
         }
         // Determine if activities form must be filtered by 1 or more activity types
         $filters_result = $row['staffscheduletype_activity_types'];
         if ($filters_result != '') {
             $this->activity_types_filter = explode(',', $filters_result);
         }
     }
     // Get person and form type IDs from form instance ID, if applicable
     if ($this->personal_form_id != '') {
         $formInstance = new RowManager_StaffScheduleManager($this->personal_form_id);
         $this->person_id = $formInstance->getPersonID();
         $this->staffscheduletype_id = $formInstance->getFormID();
         // 	        echo 'person_id = '.$this->person_id.'  and   form type id = '.$this->staffscheduletype_id;
     }
     // Setup data-manager tied to staff schedule table (i.e. for approval)
     $form_instance = new RowManager_StaffScheduleManager($staffschedule_id);
     //        $registration->setSortOrder( $sortBy );
     $form_instance->setFormID($this->form_id);
     $form_instance->setPersonID($this->person_id);
     //     $multiTableManager2->setLabelTemplate('viewer_userID', '[viewer_userID]');
     $this->listManager = $form_instance->getListIterator();
     //         $formInstanceArray = $this->listManager->getDataList();
     //         echo "<pre>".print_r($this->listManager,true)."</pre>";
     //        echo "<pre>".print_r($formInstanceArray,true)."</pre>";
     // create references to sub-page objects
     $disableHeading = true;
     $disableForm = true;
     $this->basic_form = new FormProcessor_EditBasicStaffForm($this->pathModuleRoot, $this->viewer, $this->basic_formAction, $this->person_id, $this->form_id, $this->fieldvalues_id, $this->field_id, $disableHeading, $this->show_hidden_fields, $this->personal_form_id, $disableForm);
     //  $this->sortBy,
     if ($this->has_activity_form == true) {
         $incContactNums = $this->has_activity_contact_nums;
         $this->optional_sheduled_activity_form = new FormProcessor_EditStaffActivity($this->pathModuleRoot, $this->viewer, $this->activity_formAction, $this->sortBy, $this->staffactivity_id, $this->person_id, $this->form_id, $this->personal_form_id, '', true, $incContactNums, $this->activity_types_filter, $disableForm);
         //, $activitytype_id=''
     }
     // Ensure that a form instance is created for the staff person
     $scheduleFormManager = new RowManager_StaffScheduleManager();
     $scheduleFormManager->setPersonID($this->person_id);
     $scheduleFormManager->setFormID($this->form_id);
     $formList = $scheduleFormManager->getListIterator();
     $formArray = $formList->getDataList();
     $this->is_form_approved = false;
     if (count($formArray) > 0) {
         $row = current($formArray);
         // pick first record for grabbing approval data
         $approved = $row['staffschedule_approved'];
         if ($approved == '1') {
             $this->is_form_approved = true;
         }
     }
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = FormProcessor_ApproveStaffSchedule::MULTILINGUAL_PAGE_KEY;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
 }
예제 #2
0
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $instrFormAction, $editFieldsFormAction, $sortBy, $staffscheduletype_id, $fields_id = '')
 {
     $fieldList = FormProcessor_EditHrdbForm::FORM_FIELDS;
     $fieldTypes = FormProcessor_EditHrdbForm::FORM_FIELD_TYPES;
     $displayFields = FormProcessor_EditHrdbForm::DISPLAY_FIELDS;
     parent::__construct($formAction, $fieldList, $displayFields);
     // initialize the object values
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->sortBy = $sortBy;
     $this->formAction = $formAction;
     $this->editfields_formAction = $editFieldsFormAction;
     $this->instructions_formAction = $instrFormAction;
     //         $this->has_activity_form = $hasActivityForm;
     $this->form_id = $staffscheduletype_id;
     $this->field_id = $fields_id;
     // just let these be empty if they are passed as empty
     //         $this->person_id = $person_id;
     $this->form_submitted = false;
     // figure out the important fields for the dataManager
     $fieldsOfInterest = implode(',', $this->formFields);
     $this->dataManager = new RowManager_FormFieldManager($fields_id);
     $this->dataManager->setFieldsOfInterest($fieldsOfInterest);
     $this->formValues = $this->dataManager->getArrayOfValues();
     // Get form type context information
     $formType = new RowManager_StaffScheduleTypeManager($this->form_id);
     $formTypeList = $formType->getListIterator();
     $formTypeArray = $formTypeList->getDataList();
     // Ensure that a form instance is created for the staff person
     $scheduleFormManager = new RowManager_StaffScheduleManager();
     $scheduleFormManager->setPersonID($this->person_id);
     $scheduleFormManager->setFormID($this->form_id);
     $formList = $scheduleFormManager->getListIterator();
     $formArray = $formList->getDataList();
     // create references to sub-page objects
     $disableHeading = true;
     $this->instructions_form = new FormProcessor_EditStaffFormInstructions($this->pathModuleRoot, $this->viewer, $this->instructions_formAction, $this->form_id, $disableHeading);
     $this->editfields_form = new FormProcessor_EditFormFields($this->pathModuleRoot, $this->viewer, $this->editfields_formAction, $this->sortBy, $this->field_id, $this->form_id, $disableHeading);
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = FormProcessor_EditHrdbForm::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     // load the site default form link labels
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORMERRORS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $basicFormAction, $activityFormAction, $sortBy, $person_id, $staffscheduletype_id, $staffschedule_id = '', $fieldvalues_id = '', $fields_id = '', $activity_id = '', $showHidden = true)
 {
     $fieldList = FormProcessor_EditStaffScheduleForm::FORM_FIELDS;
     $fieldTypes = FormProcessor_EditStaffScheduleForm::FORM_FIELD_TYPES;
     $displayFields = FormProcessor_EditStaffScheduleForm::DISPLAY_FIELDS;
     parent::__construct($formAction, $fieldList, $displayFields);
     // initialize the object values
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->sortBy = $sortBy;
     $this->formAction = $formAction;
     $this->basic_formAction = $basicFormAction;
     $this->activity_formAction = $activityFormAction;
     //         $this->has_activity_form = $hasActivityForm;
     $this->form_id = $staffscheduletype_id;
     $this->personal_form_id = $staffschedule_id;
     $this->field_id = $fields_id;
     if ($fieldvalues_id != '') {
         $this->fieldvalues_id = $fieldvalues_id;
     }
     if ($activity_id != '') {
         $this->staffactivity_id = $activity_id;
     }
     // just let these be empty if they are passed as empty
     $this->person_id = $person_id;
     $this->has_activity_form = true;
     // set default, could be changed if form info exists
     $this->has_activity_contact_nums = false;
     // set default, could be changed if form info exists
     $this->activity_types_filter = array();
     $this->show_hidden_fields = $showHidden;
     $this->form_submitted = false;
     //          // Get the real form name
     //         $this->hrdbFormTitle = '';
     //         if ($this->form_id != '')
     //         {
     // 	        $formContext = new RowManager_StaffScheduleTypeManager($this->form_id);
     //
     //      	  }
     // Get form type context information
     $formType = new RowManager_StaffScheduleTypeManager($this->form_id);
     $this->hrdbFormTitle = $formType->getFormName();
     $formTypeList = $formType->getListIterator();
     $formTypeArray = $formTypeList->getDataList();
     if (count($formTypeArray) > 0) {
         $row = current($formTypeArray);
         // pick first record for grabbing form context data
         // Determine if form should have associated activities
         $has_activities = $row['staffscheduletype_has_activities'];
         if ($has_activities == '0') {
             $this->has_activity_form = false;
         }
         // Determine if form activities require contact phone #s
         $has_activity_phone_nums = $row['staffscheduletype_has_activity_phone'];
         if ($has_activity_phone_nums == '1') {
             $this->has_activity_contact_nums = true;
         }
         // Determine if activities form must be filtered by 1 or more activity types
         $filters_result = $row['staffscheduletype_activity_types'];
         if ($filters_result != '') {
             $this->activity_types_filter = explode(',', $filters_result);
         }
     }
     // Ensure that a form instance is created for the staff person
     $scheduleFormManager = new RowManager_StaffScheduleManager();
     $scheduleFormManager->setPersonID($this->person_id);
     $scheduleFormManager->setFormID($this->form_id);
     $formList = $scheduleFormManager->getListIterator();
     $formArray = $formList->getDataList();
     $this->is_form_approved = false;
     if (count($formArray) > 0) {
         $row = current($formArray);
         // pick first record for grabbing approval data
         $approved = $row['staffschedule_approved'];
         if ($approved == '1') {
             $this->is_form_approved = true;
         }
         $this->approval_notes = $row['staffschedule_approvalnotes'];
     }
     // create references to sub-page objects
     $disableHeading = true;
     $this->basic_form = new FormProcessor_EditBasicStaffForm($this->pathModuleRoot, $this->viewer, $this->basic_formAction, $this->person_id, $this->form_id, $this->fieldvalues_id, $this->field_id, $disableHeading, $this->show_hidden_fields);
     //  $this->sortBy,
     if ($this->has_activity_form == true) {
         $incContactNums = $this->has_activity_contact_nums;
         // 	        $incContactNums = false;
         // 	        $onlyShowVacationType = false;
         //
         // 	        /** HACK: to be replaced with a more generic approach tied in with Edit Form Fields **/
         // 			  if ($this->form_id ==  '1')  // summer schedule form requires contact # for each activity
         // 			  {
         // 				  $incContactNums = true;
         // 			  }
         // 			  else if ($this->form_id == '2')
         // 			  {
         // 				  $onlyShowVacationType = true;
         // 			  }
         $this->optional_sheduled_activity_form = new FormProcessor_EditStaffActivity($this->pathModuleRoot, $this->viewer, $this->activity_formAction, $this->sortBy, $this->staffactivity_id, $this->person_id, $this->form_id, $this->personal_form_id, '', true, $incContactNums, $this->activity_types_filter);
         //, $activitytype_id=''
         $this->optional_sheduled_activity_form->setFormName('scheduledActivityForm');
     }
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = FormProcessor_EditStaffScheduleForm::MULTILINGUAL_PAGE_KEY;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
 }
 /**
  * function processData
  * <pre>
  * Processes the data for this form.
  * </pre>
  * @return [void]
  */
 function processData()
 {
     // save the value of the Foriegn Key(s)
     //            $this->formValues[ 'fieldvalues_id' ] = $this->fieldvalues_id;
     //            $this->formValues[ 'registration_id' ] = $this->registration_id;
     /*[RAD_ADMINBOX_FOREIGNKEY]*/
     $formValues = array();
     $fieldValues = array();
     // get field value records
     //			$fieldValues = $this->getFieldValuesArray( $this->registration_id, $this->person_id, $this->event_id, true );
     $fieldValues = $this->formValues;
     //  			echo "field values:<br><pre>".print_r($fieldValues,true)."</pre>";
     //  			echo 'field to value id mapper:<br><pre>'.print_r($this->formFieldToValueIDmapper,true).'</pre>';
     $fields = new RowManager_FormFieldManager();
     $fields->setFormID($this->staffscheduletype_id);
     $fieldsList = $fields->getListIterator();
     $fieldsArray = $fieldsList->getDataList();
     $all_field_ids = array_keys($fieldsArray);
     $field_ids_list = array();
     // use to store field ids that already have values
     $idx = 0;
     reset($fieldValues);
     $keys = array_keys($fieldValues);
     // get field value ids, since array indexed using them
     foreach ($keys as $formLabel) {
         $fieldValueID = -1;
         if (isset($this->formFieldToValueIDmapper[$formLabel])) {
             // get fieldvalues_id mapped to formlabel
             $fieldValueID = $this->formFieldToValueIDmapper[$formLabel];
             $formValues['fieldvalues_id'] = $fieldValueID;
             $formValues['fieldvalues_value'] = $fieldValues[$formLabel];
             $formValues['person_id'] = $this->person_id;
             $formValues['fieldvalues_modTime'] = strftime("%Y-%m-%d %H:%M:%S", time());
             // == CURRENT_TIME
             // 					echo "FORM values:<br><pre>".print_r($formValues,true)."</pre>";
             $this->dataManager = new RowManager_FormFieldValueManager($fieldValueID);
             //$fieldValueIDs[$idx]
             $fieldsOfInterest = FormProcessor_EditStaffScheduleForm::FORM_FIELDS;
             $this->dataManager->setFieldsOfInterest($fieldsOfInterest);
             $this->dataManager->loadFromArray($formValues);
             // load field value into appropriate row in DB
             // 				  echo 'field value id = '.$fieldValueID.' for '.$fieldValues[$formLabel].'<BR>';
             // standard code for adding/updating but nested to accomodate updating multiple fieldvalues rows
             if (!$this->dataManager->isLoaded()) {
                 $this->dataManager->createNewEntry();
                 //echo "ADDED";
             } else {
                 $this->dataManager->updateDBTable();
                 //echo "UPDATED";
             }
         } else {
             if ($this->isNewRecordCreator == true) {
                 // 				   echo "field mapper = <pre>".print_r($this->formFieldToValueIDmapper,true)."</pre>";
                 // must ensure that a fieldID exists
                 if (isset($this->formFieldToFieldIDmapper[$formLabel])) {
                     // get fields_id mapped to formlabel
                     $fieldID = $this->formFieldToFieldIDmapper[$formLabel];
                     $field_ids_list[$idx++] = $fieldID;
                     $formValues['fields_id'] = $fieldID;
                     $formValues['fieldvalues_value'] = $fieldValues[$formLabel];
                     $formValues['person_id'] = $this->person_id;
                     $formValues['fieldvalues_modTime'] = strftime("%Y-%m-%d %H:%M:%S", time());
                     // == CURRENT_TIME
                     //						echo "ADD FORM values:<br><pre>".print_r($formValues,true)."</pre>";
                     $this->dataManager = new RowManager_FormFieldValueManager();
                     //$fieldValueIDs[$idx]
                     //			        $fieldsOfInterest = FormProcessor_EditStaffScheduleForm::FORM_FIELDS;
                     //		           $this->dataManager->setFieldsOfInterest( $fieldsOfInterest );
                     $this->dataManager->loadFromArray($formValues);
                     // load field value into appropriate row in DB
                     //				  echo 'field value id = '.$fieldValueID.' for '.$fieldValues[$formLabel].'<BR>';
                     // standard code for adding/updating but nested to accomodate updating multiple fieldvalues rows
                     if (!$this->dataManager->isLoaded()) {
                         $this->dataManager->createNewEntry();
                         // 			            echo "ADDED";
                     } else {
                         $this->dataManager->updateDBTable();
                         // 			            echo "UPDATED";
                     }
                 }
             }
         }
     }
     /*** Add empty field values for event fields not shown to the user (i.e. hidden fields) **/
     /** NOTE: only required for first time registration field values are stored **/
     if ($this->isNewRecordCreator == true) {
         // Find which ids in the set of all fields do NOT appear the set of fields with values
         $missing_values = array_diff($all_field_ids, $field_ids_list);
         // 		  echo 'missing fields = <pre>'.print_r($missing_values,true).'</pre>';
         reset($missing_values);
         $newValues = array();
         foreach (array_keys($missing_values) as $key) {
             $fieldID = current($missing_values);
             $newValues['fields_id'] = $fieldID;
             $newValues['fieldvalues_value'] = '';
             $newValues['person_id'] = $this->person_id;
             $formValues['fieldvalues_modTime'] = strftime("%Y-%m-%d %H:%M:%S", time());
             // == CURRENT_TIME
             $this->dataManager = new RowManager_FormFieldValueManager();
             //$fieldValueIDs[$idx]
             $this->dataManager->loadFromArray($newValues);
             // load field value into appropriate row in DB
             //				  echo 'field value id = '.$fieldValueID.' for '.$fieldValues[$formLabel].'<BR>';
             // standard code for adding/updating but nested to accomodate updating multiple fieldvalues rows
             if (!$this->dataManager->isLoaded()) {
                 $this->dataManager->createNewEntry();
                 // 			            echo "ADDED";
             } else {
                 $this->dataManager->updateDBTable();
                 // 			            echo "UPDATED";
             }
             next($missing_values);
         }
     }
     // Ensure that a form instance is created for the staff person
     $scheduleFormManager = new RowManager_StaffScheduleManager();
     $scheduleFormManager->setPersonID($this->person_id);
     $scheduleFormManager->setFormID($this->staffscheduletype_id);
     $formList = $scheduleFormManager->getListIterator();
     $formArray = $formList->getDataList();
     $personal_form_id = '';
     if (count($formArray) > 0) {
         $row = current($formArray);
         // pick first record for grabbing form ID
         $personal_form_id = $row['staffschedule_id'];
     }
     // Create new form instance record if none exists
     if ($personal_form_id == '') {
         $scheduleFormManager->createNewEntry();
         $personal_form_id = $scheduleFormManager->getID();
     }
     return $personal_form_id;
 }