/** * 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); }
/** * 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; }