/**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to this module's root directory
  * @param $viewer [OBJECT] The viewer object.
  * @param $formAction [STRING] The action on a form submit
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $staffactivity_id [STRING] The init data for the dataManager obj
  * @param $person_id [INTEGER] The foreign key data for the data Manager
  * @param $activitytype_id [INTEGER] The foreign key data for the data Manager
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $sortBy, $staffactivity_id, $person_id = '', $form_id = '', $personal_form_id = '', $activitytype_id = '', $disableHeading = true, $showContactField = false, $activityTypesFilter = array(), $disableForm = false)
 {
     // NOTE: be sure to call the parent constructor before trying to
     //       use the ->formXXX arrays...
     if ($showContactField == true) {
         $FORM_FIELDS = 'staffactivity_startdate|T|,staffactivity_enddate|T|,staffactivity_contactPhone|T|,activitytype_id|N|,person_id|T|<skip>,form_name|T|<skip>';
         $FORM_FIELD_TYPES = 'datebox,datebox,textbox,droplist,-,hidden';
         $DISPLAY_FIELDS = 'staffactivity_startdate,staffactivity_enddate,staffactivity_contactPhone,activitytype_id';
     } else {
         $FORM_FIELDS = 'staffactivity_startdate|T|,staffactivity_enddate|T|,activitytype_id|N|,person_id|T|<skip>,form_name|T|<skip>';
         $FORM_FIELD_TYPES = 'datebox,datebox,droplist,-,hidden';
         $DISPLAY_FIELDS = 'staffactivity_startdate,staffactivity_enddate,activitytype_id';
     }
     $fieldList = $FORM_FIELDS;
     //FormProcessor_EditStaffActivity::FORM_FIELDS;
     $fieldTypes = $FORM_FIELD_TYPES;
     //FormProcessor_EditStaffActivity::FORM_FIELD_TYPES;
     $displayFields = $DISPLAY_FIELDS;
     //FormProcessor_EditStaffActivity::DISPLAY_FIELDS;
     parent::__construct($viewer, $formAction, $sortBy, $fieldList, $fieldTypes, $displayFields);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->sortBy = $sortBy;
     if ($sortBy == '') {
         $this->sortBy = 'staffactivity_startdate';
     }
     $this->disableForm = $disableForm;
     //         $this->showOnlyVacation = $showOnlyVacation;		// TODO??: replace with activitytype_id = 1
     $this->activityTypesFilter = $activityTypesFilter;
     $this->staffactivity_id = $staffactivity_id;
     $this->person_id = $person_id;
     $this->form_id = $form_id;
     $this->personal_form_id = $personal_form_id;
     // 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->form_id = $formInstance->getFormID();
         // 	        echo 'person_id = '.$this->person_id.'  and   form type id = '.$this->form_id;
     }
     // Set the form instance ID based on other IDs
     if ($this->person_id != '' && $this->form_id != '' && $this->personal_form_id == '') {
         $this->personal_form_id = $personal_form_id;
         $this->scheduleFormManager = new RowManager_StaffScheduleManager();
         $this->scheduleFormManager->setPersonID($this->person_id);
         $this->scheduleFormManager->setFormID($this->form_id);
         $formList = $this->scheduleFormManager->getListIterator();
         $formArray = $formList->getDataList();
         if (count($formArray) > 0) {
             $row = current($formArray);
             // pick first record for grabbing form ID
             $this->personal_form_id = $row['staffschedule_id'];
         }
     }
     $this->activitytype_id = $activitytype_id;
     $this->disableHeading = $disableHeading;
     // figure out the important fields for the dataManager
     $fieldsOfInterest = implode(',', $this->formFields);
     $this->dataManager = new RowManager_StaffActivityManager($this->staffactivity_id);
     //         $this->dataManager->setStaffActivityID($staffactivity_id);
     $this->dataManager->setPersonID($this->person_id);
     if (count($this->activityTypesFilter) > 0) {
         $activityTypesList = implode(',', $this->activityTypesFilter);
         if ($activityTypesList != '') {
             $this->dataManager->addSearchCondition('activitytype_id in (' . $activityTypesList . ')');
         }
     }
     if (!isset($this->form_start_date)) {
         $this->form_start_date = '';
     }
     if (!isset($this->form_start_date)) {
         $this->form_end_date = '';
     }
     if ($form_id != '') {
         $scheduleType = new RowManager_StaffScheduleTypeManager($this->form_id);
         $this->form_start_date = $scheduleType->getStartDate();
         //         		$this->dataManager->addSearchCondition( 'staffactivity_startdate >= '.$form_start_date );
         $this->dataManager->constructSearchCondition('staffactivity_startdate', '>=', $this->form_start_date, true);
         $this->form_end_date = $scheduleType->getEndDate();
         //         		$this->dataManager->addSearchCondition( 'staffactivity_enddate <= '.$form_end_date );
         $this->dataManager->constructSearchCondition('staffactivity_enddate', '<=', $this->form_end_date, true);
         $transformedStartDate = $this->getEasyDate($this->form_start_date);
         $transformedEndDate = $this->getEasyDate($this->form_end_date);
         $this->form_date_range = $transformedStartDate . ' - ' . $transformedEndDate;
     }
     $this->dataManager->setSortOrder($this->sortBy);
     // does nothing, see manager called in getHTML()...
     //      	  $this->dataManager->setFieldsOfInterest( $fieldsOfInterest );
     $this->formValues = $this->dataManager->getArrayOfValues();
     // 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_EditStaffActivity::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_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);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to this module's root directory
  * @param $viewer [OBJECT] The viewer object.
  * @param $formAction [STRING] The action on a form submit
  * @param $fieldvalues_id [INTEGER] Value used to initialize the dataManager
  * @param $fields_id [INTEGER] The foreign key data for the data Manager
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $person_id = '', $staffscheduletype_id = '', $fieldvalues_id = '', $fields_id = '', $disableHeading = false, $showHidden = true, $staffschedule_id = '', $disableForm = false)
 {
     $this->disable_heading = $disableHeading;
     $this->disable_form = $disableForm;
     $this->show_hidden = $showHidden;
     // set to FALSE when in sign-up process
     // NOTE: be sure to call the parent constructor before trying to
     //       use the ->formXXX arrays...
     // store field values in field list; NOTE: probably don't need this now that we are generating custom labels...
     $fieldList = $this->getFieldList($person_id, $staffscheduletype_id);
     //FormProcessor_EditStaffScheduleForm::FORM_FIELDS; ;
     // 		  $this->total_nonrepeatable_fields = count(explode(',', $fieldList)) - 1;   // subtract 1 because of special hidden field
     // 		  $footerFieldList = $this->getFooterFieldList($person_id, $staffscheduletype_id);
     // store field display types
     $fieldTypes = $this->getFormFieldTypes($person_id, $staffscheduletype_id);
     //FormProcessor_EditStaffScheduleForm::FORM_FIELD_TYPES;
     $footerFieldTypes = $this->getFooterFormFieldTypes($person_id, $staffscheduletype_id);
     $displayFields = $this->getDisplayFields($person_id, $staffscheduletype_id);
     //FormProcessor_EditStaffScheduleForm::DISPLAY_FIELDS;
     //parent::__construct( $formAction, $fieldList, $fieldDisplayTypes  );
     parent::__construct($formAction, $fieldList, $fieldTypes);
     //$viewer,  $sortBy, $displayFields, $footerFieldList, $footerFieldTypes
     $this->pathModuleRoot = $pathModuleRoot;
     //         $this->sortBy = $sortBy;
     $this->viewer = $viewer;
     $this->formFieldToValueIDmapper = array();
     // mapping is setup later in getFieldValuesArray()
     $this->formFieldToFieldIDmapper = array();
     // mapping is setup later in getFieldsArray()
     $this->formLabels = array();
     $this->formLabels = $this->getFieldLabels($person_id, $staffscheduletype_id);
     $this->listLabels = $this->getListLabels($person_id, $staffscheduletype_id);
     $this->fieldvalues_id = $fieldvalues_id;
     $this->fields_id = $fields_id;
     $this->person_id = $person_id;
     $this->staffscheduletype_id = $staffscheduletype_id;
     $this->staffschedule_id = $staffschedule_id;
     // Get person and form type IDs from form instance ID, if applicable
     if ($this->staffschedule_id != '') {
         $formInstance = new RowManager_StaffScheduleManager($this->staffschedule_id);
         $this->person_id = $formInstance->getPersonID();
         $this->staffscheduletype_id = $formInstance->getFormID();
         // 	        echo 'person_id = '.$this->person_id.'  and   form type id = '.$this->staffscheduletype_id;
     }
     // Get the real form name
     if ($this->staffscheduletype_id != '') {
         $formContext = new RowManager_StaffScheduleTypeManager($this->staffscheduletype_id);
         $this->form_name = $formContext->getFormName();
     } else {
         $this->form_name = '';
     }
     //        echo "PersonID = ".$person_id;
     // 		 echo "EventID = ".$event_id;
     // 			echo "Registration ID = ".$registration_id;
     // figure out the important fields for the dataManager
     //      $fieldsOfInterest = implode(',', $this->formFields);
     $this->dataManager = new RowManager_FormFieldValueManager($fieldvalues_id);
     //        $this->dataManager->setFieldsOfInterest( $fieldsOfInterest );
     $mainFormValues = $this->getFieldValuesArray($this->person_id, $this->staffscheduletype_id);
     //$this->dataManager->getArrayOfValues();
     // 		  $footerFormValues = $this->getFooterFieldValuesArray( $person_id, $staffscheduletype_id); //$this->dataManager->getArrayOfValues();
     $this->formValues = $mainFormValues;
     //array_merge($mainFormValues, $footerFormValues);
     //  		  echo 'initial db form values = <pre>'.print_r($this->formValues,true).'</pre>';
     // if the database contains no values then flag for new record creation (assumes not all values can be empty strings)
     if (count($this->formValues) == 0) {
         $this->isNewRecordCreator = true;
         // NEVER SET!!
     } else {
         $this->isNewRecordCreator = false;
     }
     // 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_EditStaffScheduleForm::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);
 }