/** * 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); }
protected function getFieldValuesArray($personID = '', $formID = '', $isRepeatable = false) { $FALSE = 0; $fields = new RowManager_FormFieldManager(); // $fields->setFieldGroupID(FormProcessor_EditStaffScheduleForm::NO_FIELDGROUP_ID); // HSMIT added $fvalues = new RowManager_FormFieldValueManager(); $ftypes = new RowManager_FieldTypeManager(); // echo "personID = ".$personID; // echo "eventID = ".$eventID; if ($personID != '') { //$fields->setEventID($eventID); $fvalues->setPersonID($personID); } if ($formID != '') { $fields->setFormID($formID); } // $fvalues->setSortByFieldID(); $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 ); $fieldInfo->addSearchCondition('fieldgroup_id = 0'); } else { // $fieldInfo->constructSearchCondition( 'fieldgroup_id', '!=', '0', true ); $fieldInfo->addSearchCondition('fieldgroup_id != 0'); } $fieldInfo->setSortOrder('fields_priority'); $valuesIterator = $fieldInfo->getListIterator(); $valuesArray = $valuesIterator->getDataList(); // echo "pre 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 = 0; /** Go through all event fields and map each to existing field value, otherwise create new field value record **/ $fieldsArray = array_values($this->formFieldToFieldIDmapper); // 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); $fieldvalues_list = $fieldvalues_manager->getListIterator(); $fieldvalues_array = $fieldvalues_list->getDataList(); // now update the DB with the values if (count($fieldvalues_array) < 1) { //(!$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->formFieldToValueIDmapper['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; }