예제 #1
0
 /*
  * FormField Table
  *
  * this is a HRDB form field object
  *
  * fields_id [INTEGER]  the unique id of the field
  * fieldtype_id [INTEGER]  The field type associated with the field (i.e. "checkbox")
  * fields_desc [STRING]  the description of the form field
  * staffscheduletype_id [INTEGER]  id of the form that this field belongs to
  * fields_priority [INTEGER]  the display priority of this form field
  * fields_reqd [BOOL]  whether or not this field is a required field (for the user to fill in)
  * fields_invalid [STRING]  an value that is invalid for this field
  * fields_hidden [BOOL]  whether this field is hidden to the general user
  * datatypes_id [INTEGER]  The id of the type of data this field expects, i.e. "numeric".
  */
 $FormField = new RowManager_FormFieldManager();
 $FormField->dropTable();
 $FormField->createTable();
 /*
  * FormFieldValue Table
  *
  * A record storing a field value entered via a HRDB form.
  *
  * fieldvalues_id [INTEGER]  The unique field value id.
  * fields_id [INTEGER]  The id of the form field where this value was entered.
  * fieldvalues_value [STRING]  The value stored.
  * person_id [INTEGER]  The person who entered the value stored.
  * fieldvalues_modTime [DATE]  The time when the value record was last changed.
  */
 $FormFieldValue = new RowManager_FormFieldValueManager();
 $FormFieldValue->dropTable();
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // Uncomment the following line if you want to create a template
     // tailored for this page:
     //$path = $this->pathModuleRoot.'templates/';
     // Otherwise use the standard Templates for the site:
     $path = SITE_PATH_TEMPLATES;
     /*
      * store the link values
      */
     // example:
     // $this->linkValues[ 'view' ] = 'add/new/href/data/here';
     // store the link labels
     $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]');
     $this->linkLabels['del'] = $this->labels->getLabel('[Delete]');
     $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]');
     // $this->linkLabels[ 'view' ] = 'new link label here';
     /*
      * store any additional link Columns
      */
     // example:
     //$title = $this->labels->getLabel( '[title_groups]');
     //$columnLabel = $this->labels->getLabel( '[groups]');
     //$link = $this->linkValues[ 'groups' ];
     //$fieldName = 'accessgroup_id';
     //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName);
     /*
      * Update any label tags ...
      */
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     // NOTE:  this parent method prepares the $this->template with the
     // common AdminBox data.
     $this->prepareTemplate($path);
     // store the statevar id to edit
     $this->template->set('editEntryID', $this->fields_id);
     // store all the fields to the template
     $this->setFormFieldsToTemplate();
     /*
      * Form related Template variables:
      */
     $this->formValues['form_name'] = 'editFieldsForm';
     /*
      * Insert the date start/end values for the following date fields:
      */
     // example:
     //$this->template->set( 'startYear_[fieldName]', 2000);
     //$this->template->set( 'endYear_[fieldName]', 2010);
     /*
      * List related Template variables :
      */
     // Store the XML Node name for the Data Access Field List
     $xmlNodeName = RowManager_FormFieldManager::XML_NODE_NAME;
     $this->template->set('rowManagerXMLNodeName', $xmlNodeName);
     // store the primary key field name for the data being displayed
     $this->template->set('primaryKeyFieldName', 'fields_id');
     // store data list to the template
     // NOTE: we initialize it here to make sure we capture any new data
     // from a recent processData() call.
     $dataAccessManager = new RowManager_FormFieldManager();
     $dataAccessManager->setFormID($this->staffscheduletype_id);
     $dataAccessManager->setSortOrder($this->sortBy);
     //        $this->dataList = new FormFieldList( $this->sortBy );
     $this->dataList = $dataAccessManager->getListIterator();
     $this->template->setXML('dataList', $this->dataList->getXML());
     /*
      * Add any additional data required by the template here
      */
     // get a list of all field type IDs
     $fieldtype = new RowManager_FieldTypeManager();
     $fieldtype->setSortOrder('fieldtype_id');
     $fieldtypeList = new ListIterator($fieldtype);
     $fieldtypeArray = $fieldtypeList->getDropListArray();
     $this->template->set('list_fieldtype_id', $fieldtypeArray);
     // get a list of all data types; DB table = reg_cim_datatypes
     $type = new RowManager_DataTypeManager();
     $type->setSortOrder('datatypes_id');
     $typeList = new ListIterator($type);
     $typeArray = $typeList->getDropListArray();
     $this->template->set('list_datatypes_id', $typeArray);
     // get a list of all fieldgroups; DB table = reg_cim_fieldgroup
     $group = new RowManager_FieldGroupManager();
     $group->setSortOrder('fieldgroup_desc');
     $groupList = new ListIterator($group);
     $groupArray = $groupList->getDropListArray();
     $groupArray[0] = '';
     //'(None)';
     $this->template->set('list_fieldgroup_id', $groupArray);
     //TODO: replace this with a reference to a multi_lingual label constant array...
     $boolArray = array();
     $boolArray['0'] = 'false';
     $boolArray['1'] = 'true';
     $this->template->set('list_fields_hidden', $boolArray);
     $this->template->set('list_fields_reqd', $boolArray);
     $this->template->set('list_fields_islistfield', $boolArray);
     $this->template->set('disableHeading', $this->disableHeading);
     $templateName = 'siteFormDataList.php';
     // if you are creating a custom template for this page then
     // replace $templateName with the following:
     //$templateName = 'page_EditFormFields.php';
     return $this->template->fetch($templateName);
 }
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // Uncomment the following line if you want to create a template
     // tailored for this page:
     //$path = $this->pathModuleRoot.'templates/';
     // Otherwise use the standard Templates for the site:
     $path = SITE_PATH_TEMPLATES;
     /*
      * store the link values
      */
     // example:
     // $this->linkValues[ 'view' ] = 'add/new/href/data/here';
     // store the link labels
     $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]');
     $this->linkLabels['del'] = $this->labels->getLabel('[Delete]');
     $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]');
     // $this->linkLabels[ 'view' ] = 'new link label here';
     /*
      * store any additional link Columns
      */
     // example:
     //$title = $this->labels->getLabel( '[title_groups]');
     //$columnLabel = $this->labels->getLabel( '[groups]');
     //$link = $this->linkValues[ 'groups' ];
     //$fieldName = 'accessgroup_id';
     //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName);
     /*
      * Update any label tags ...
      */
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     // NOTE:  this parent method prepares the $this->template with the
     // common AdminBox data.
     $this->prepareTemplate($path);
     // Enable the 'Add' form for creating new reports
     $formLabel = 'New Report Name:';
     // TODO: replace with constant?
     $formFieldArray = explode(',', page_HrdbForms::DISPLAY_FIELDS);
     $formField = $formFieldArray[0];
     $formButtonText = 'Add Report';
     $this->template->set('addFormAction', $this->formAction);
     $this->template->set('addFormLabel', $formLabel);
     $this->template->set('addFormField', $formField);
     $this->template->set('addButtonText', $formButtonText);
     // store the statevar id to edit
     $this->template->set('editEntryID', $this->customfields_id);
     // store all the fields to the template
     $this->setFormFieldsToTemplate();
     /*
      * Form related Template variables:
      */
     /*
      * Insert the date start/end values for the following date fields:
      */
     // example:
     //$this->template->set( 'startYear_[fieldName]', 2000);
     //$this->template->set( 'endYear_[fieldName]', 2010);
     /*
      * List related Template variables :
      */
     // Store the XML Node name for the Data Access Field List
     $xmlNodeName = RowManager_CustomFieldsManager::XML_NODE_NAME;
     $this->template->set('rowManagerXMLNodeName', $xmlNodeName);
     // store the primary key field name for the data being displayed
     $this->template->set('primaryKeyFieldName', 'customfields_id');
     // store data list to the template
     // NOTE: we initialize it here to make sure we capture any new data
     // from a recent processData() call.
     $dataAccessManager = new RowManager_CustomFieldsManager();
     if ($this->report_id != '') {
         $dataAccessManager->setReportID($this->report_id);
     }
     $dataAccessManager->setSortOrder($this->sortBy);
     //        $this->dataList = new CustomFieldsList( $this->sortBy );
     $this->dataList = $dataAccessManager->getListIterator();
     $this->template->setXML('dataList', $this->dataList->getXML());
     /*
      * Add any additional data required by the template here
      */
     $report_manager = new RowManager_CustomReportsManager($this->report_id);
     $report_list = $report_manager->getListIterator();
     $reportArray = $report_list->getDropListArray();
     $this->template->set('list_report_id', $reportArray);
     $fields_manager = new RowManager_FormFieldManager();
     $fields_list = $fields_manager->getListIterator();
     //          $fieldsArray = $fields_list ->getDropListArray();
     $fieldsInfoArray = $fields_list->getDataList();
     $fieldsArray = array();
     foreach (array_keys($fieldsInfoArray) as $fields_id) {
         $record = current($fieldsInfoArray);
         $fields_desc = strip_tags($record['fields_desc']);
         // remove HTML tags
         $question_regex = '/[^]*[\\.\\?!:]*[A-Z]+[a-z\\s0-9%]+[?]{1}/';
         // example: ([0-9]{3})\-[0-9]{1,2}\-[0-9]{1,2} for YYYY-MM-DD
         $simple_question = '/[?]{1}/';
         if (preg_match($question_regex, $fields_desc, $matches) >= 1) {
             $fieldsArray[$fields_id] = $matches[0];
             //substr($fields_desc,$matches[0][1]);
         } else {
             if (preg_match($simple_question, $fields_desc, $matches) < 1) {
                 $fieldsArray[$fields_id] = $fields_desc;
             } else {
                 $fieldsArray[$fields_id] = 'ERROR: ' . $fields_desc;
             }
         }
         next($fieldsInfoArray);
     }
     $this->template->set('list_fields_id', $fieldsArray);
     $report_name = '';
     if ($this->report_id != '') {
         $reportContext = new RowManager_CustomReportsManager($this->report_id);
         $report_name = $reportContext->getReportName();
     }
     $this->template->set('subheading', $report_name);
     $templateName = 'siteAdminBox.php';
     // if you are creating a custom template for this page then
     // replace $templateName with the following:
     //$templateName = 'page_EditCustomReports.php';
     return $this->template->fetch($templateName);
 }
 protected function getFooterFieldValuesArray($personID = '', $formID = '', $isRepeatable = true)
 {
     $FALSE = 0;
     $fields = new RowManager_FormFieldManager();
     $fields->setFieldGroupID(FormProcessor_EditStaffScheduleForm::NO_FIELDGROUP_ID);
     // HSMIT added
     $fvalues = new RowManager_FormFieldValueManager();
     $ftypes = new RowManager_FieldTypeManager();
     if ($personID != '') {
         //$fields->setFormID($formID);
         $fvalues->setPersonID($personID);
     }
     $fieldInfo = new MultiTableManager();
     $fieldInfo->addRowManager($fields);
     $fieldInfo->addRowManager($fvalues, new JoinPair($fvalues->getJoinOnFieldID(), $fields->getJoinOnFieldID()));
     $fieldInfo->addRowManager($ftypes, new JoinPair($fields->getJoinOnFieldTypeID(), $ftypes->getJoinOnFieldTypeID()));
     if ($this->show_hidden == false) {
         $fieldInfo->constructSearchCondition('fields_hidden', '=', $FALSE, true);
     }
     // filter out repeatable fields if flag set to FALSE
     if ($isRepeatable == false) {
         $fieldInfo->constructSearchCondition('fieldgroup_id', '=', '0', true);
     } else {
         $fieldInfo->constructSearchCondition('fieldgroup_id', '!=', '0', true);
     }
     $fieldInfo->setSortOrder('fields_priority');
     $valuesIterator = $fieldInfo->getListIterator();
     $valuesArray = $valuesIterator->getDataList();
     //        echo "field values:<br><pre>".print_r($valuesArray,true)."</pre>";
     // store field ids associated with values already in database
     $initializedFieldIds = array_keys($valuesArray);
     // since each field value is located in a DB row the result array has several arrays - one per field value
     // need to extract each field value and store it as a non-array record in a result array
     $fieldValues = array();
     $idx = $this->total_nonrepeatable_fields;
     // initialize counter to first available form ID (some used already)
     /** Go through all event fields and map each to existing field value, otherwise create new field value record **/
     $fieldsArray = array_values($this->footerFieldToFieldIDmapper);
     // store field IDs (ASSUMES formFieldToFieldIDmapper is initialized)
     //         echo 'fieldsArray = <pre>'.print_r($fieldsArray,true).'</pre>';
     reset($fieldsArray);
     reset($valuesArray);
     foreach (array_keys($fieldsArray) as $k) {
         $fieldID = current($fieldsArray);
         $form_value = '';
         // default blank field value if none found
         $form_value_id = -1;
         // to be replaced with existing or newly-created field values ID
         if (in_array($fieldID, $initializedFieldIds) == true) {
             $record = $valuesArray[$fieldID];
             $form_value = $record['fieldvalues_value'];
             $form_value_id = $record['fieldvalues_id'];
         } else {
             $updateValues = array();
             $updateValues['fields_id'] = $fieldID;
             $updateValues['fieldvalues_value'] = $form_value;
             $updateValues['person_id'] = $personID;
             $fieldvalues_manager = new RowManager_FormFieldValueManager();
             // store values in table manager object.
             $fieldvalues_manager->loadFromArray($updateValues);
             // now update the DB with the values
             if (!$fieldvalues_manager->isLoaded()) {
                 // 			        echo "new entry ".$fieldID.", ".$personID;
                 $fieldvalues_manager->createNewEntry();
                 $form_value_id = $fieldvalues_manager->getID();
             }
         }
         $fieldValues['form_field' . $idx] = $form_value;
         // store mapping associating form field label with fieldvalues_id
         $this->footerFieldToValueIDmapper['form_field' . $idx] = $form_value_id;
         next($fieldsArray);
         $idx++;
     }
     // 			echo 'labels-values = <pre>'.print_r($this->formFieldToValueIDmapper,true).'</pre>';
     // 			echo 'labels-fields = <pre>'.print_r($this->formFieldToFieldIDmapper,true).'</pre>';
     return $fieldValues;
 }