* @access public
*/
public $recordId = false;
-
+
/**
* Constructor
*
'type' => 'checkbox',
'use' => 'a'
),
-
+
// required field
'required' => array(
'field' => 'required',
// Get field type description from ini file.
$r['field_type_descr'] = $this->config['custom_field_type'][$r['field_type']];
-
+
// If doing the following actions
if (in_array($action, array('l','g'))) {
- // Try to get additional data for specific field types
+ // Try to get additional data for specific field types
switch ($r['field_type']) {
-
+
case 'picklist':
-
+
if (!isset($FieldOptions)) {
require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH.'/data/dataCustomFieldsOption.php';
$FieldOptions = new GlmDataFieldsCustomFieldsOption($this->wpdb, $this->config);
}
-
+
// Try to get any options for this picklist
$options = $FieldOptions->getList('T.field_id = '.$r['id']);
-
+
$r['options'] = false;
if (is_array($options) && count($options) > 0) {
$r['options'] = $options;
}
-
+
break;
-
+
default:
break;
}
-
+
// If get stored data flag is set and we have a stored data record ID
if ($this->getStoredData && $this->recordId) {
-
- // If we don't have it yet, instatiate the custom field data class
+
+ // If we don't have it yet, instatiate the custom field data class
if (!isset($CustomFieldData)) {
require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH . '/data/dataCustomFieldsData.php';
$CustomFieldData = new GlmDataFieldsCustomFieldsData($this->wpdb, $this->config);
}
-
- // Get stored data for the current field
+
+ // Get stored data for the current field
$customFieldData = $CustomFieldData->getEntry($r['id'], 'field_id', "T.record_id = ".$this->recordId);
// Place the save field data into the current result
'integer_data' => $customFieldData['integer_data'],
'float_data' => $customFieldData['float_data']
));
-
+
+ // Add a few data shortcuts
$r['stored'] = '';
-
+ $r['cost'] = '0';
+
switch ($r['field_type']) {
-
+
case 'text':
case 'textarea':
$r['stored'] = $r['text_data'];
break;
-
+
case 'checkbox':
$r['stored'] = ($r['checkbox_data'] ? 'Yes' : 'No');
break;
-
+
case 'picklist':
-
+
// set default picklist option
if (isset($r['options']) && count($options) > 0) {
foreach($r['options'] as $optKey=>$optVal) {
+
$val = false;
$name = 'No';
+
+ // If this option is the selected one
if ($optVal['option_value'] == $customFieldData['text_data']) {
+
$val = true;
$name = 'Yes';
+
+ // Add shortcuts for some useful data
$r['stored'] = $optVal['option_value'];
- $r['option_text'] = $optVal['option_text'];
+ $r['cost'] = $optVal['option_cost'];
}
+
$r['options'][$optKey]['option_default']['value'] = $val;
$r['options'][$optKey]['option_default']['name'] = $name;
+
}
}
-
+
break;
-
+
case 'integer':
$r['stored'] = $r['integer_data'];
break;
-
+
case 'float':
$r['stored'] = $r['float_data'];
break;
-
+
}
}
-
-ini_set(log_errors_max_len,4096);
-trigger_error('Form Fields: '.print_r($r, 1), E_USER_NOTICE);
-
+
+ // ini_set('log_errors_max_len',4096);
+ // trigger_error('Form Fields: '.print_r($r, 1), E_USER_NOTICE);
+
}
return $r;
}
-
+
/*
* Get form fields along with any stored data
*
- * @param
+ * @param
* @param string $a Action being performed (l, i, g, ...)
*
* @return object Class object
public function getFormWithData($fid, $recordId = false)
{
// Save current status of get stored data flag
- $savedGetStoredDataState = $this->getStoredData;
-
+ $savedGetStoredDataState = $this->getStoredData;
+
// Set stored data flag and record ID
$this->getStoredData = true;
$this->recordId = $recordId;
-
+
+ $result = array(
+ 'form' => false,
+ 'hasPriorityField' => false,
+ 'totalCost' => 0
+ );
+
// Try to get the form
- $form = $this->getList("fid = '$fid'");
-
+ $result['form'] = $this->getList("fid = '$fid'");
+
+ // Check if there's any priority display fields or fields with selected cost
+ foreach ($result['form'] as $field) {
+ if ($field['priority_display']['value'] || $field['cost'] > 0) {
+ $result['hasPriorityField'] = true;
+ }
+
+ if ($field['cost'] > 0) {
+ $result['totalCost'] += $field['cost'];
+ }
+ }
+
// Restore saved stored data flag
$this->getStoredData = $savedGetStoredDataState;
- return $form;
-
+ return $result;
+
}
}
trigger_error('Custom Fields Filter Called: glm-members-customfields-form-data-recall', E_USER_NOTICE);
}
- require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH.'/data/dataCustomField.php';
- $CustomFields = new GlmCustomFields($this->wpdb, $this->config);
-
- $form = $CustomFieldSupport->getFormWithData($fid, $recordId, $priorityDisplay);
-
-ini_set(log_errors_max_len, 5192);
-trigger_error('Form Data Recall: '.print_r($form, 1), E_USER_NOTICE);
+ require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH.'/data/dataCustomFields.php';
+ $CustomFields = new GlmDataFieldsCustomFields($this->wpdb, $this->config);
- // Consider using a shortcode to build the HTML
+ $content = $CustomFields->getFormWithData($fid, $recordId, $priorityDisplay);
return $content;
</select>
</td>
</tr>
+ <tr>
+ <th>Priority:</th>
+ <td><input type="checkbox" id="{$fid}_editPriority" name="priority_display" value="1" /></td>
+ </tr>
<tr>
<th>Required:</th>
<td><input type="checkbox" id="{$fid}_editRequired" name="required" value="1" /></td>
{$t.required.name}
</td>
<td style="width: 10%; text-align: left;" colspan="2">
-<!-- <div class="{$fid}_EditFieldButton button button-secondary glm-button-small" data-fieldId="{$t.id}" data-fieldName="{$t.field_name|escape:'html'}" data-fieldPrompt="{$t.field_prompt|escape:'html'}" data-fieldType="{$t.field_type.name|escape:'html'}" data-required="{$t.required.value}">Edit</div>
+<!-- <div class="{$fid}_EditFieldButton button button-secondary glm-button-small"
+ data-fieldId="{$t.id}"
+ data-fieldName="{$t.field_name|escape:'html'}"
+ data-fieldPrompt="{$t.field_prompt|escape:'html'}"
+ data-fieldType="{$t.field_type.name|escape:'html'}"
+ data-priority="{$t.priority_display.value}"
+ data-required="{$t.required.value}"
+ >Edit</div>
-->
<div class="{$fid}_DeleteFieldButton button button-secondary glm-button-small" data-fieldId="{$t.id}">Delete</div>
{if $t.field_type=='picklist'}
$('#{$fid}_NewFieldName').val('');
$('#{$fid}_NewFieldPrompt').val('');
$('#{$fid}_NewFieldType').prop('selectedIndex',0);
+ $('#{$fid}_NewFieldPriorityDisplay').removeAttr('checked');
$('#{$fid}_NewFieldRequired').removeAttr('checked');
});
// Submit form
// Collect the new field data
var formData = {
- 'action': 'glm_members_admin_ajax',
- 'glm_action': 'customFields',
- 'option': 'addNewField',
- 'fid': '{$fid}',
- 'field_name': $('#{$fid}_NewFieldName').val(),
- 'field_prompt': $('#{$fid}_NewFieldPrompt').val(),
- 'field_type': $('#{$fid}_NewFieldType').val(),
- 'required': $('#{$fid}_NewFieldRequired').is(':checked')
+ 'action': 'glm_members_admin_ajax',
+ 'glm_action': 'customFields',
+ 'option': 'addNewField',
+ 'fid': '{$fid}',
+ 'field_name': $('#{$fid}_NewFieldName').val(),
+ 'field_prompt': $('#{$fid}_NewFieldPrompt').val(),
+ 'field_type': $('#{$fid}_NewFieldType').val(),
+ 'priority_display': $('#{$fid}_NewFieldPriorityDisplay').is(':checked'),
+ 'required': $('#{$fid}_NewFieldRequired').is(':checked')
};
// Submit new field data - expect field new ID back
var fieldName = $(this).attr('data-fieldName');
var fieldPrompt = $(this).attr('data-fieldPrompt');
var fieldType = $(this).attr('data-fieldType');
+ var priority = $(this).attr('data-priority');
var required = $(this).attr('data-required');
$('#editFieldID').val(fieldID);