function get_uploaded_form(&$importPlugin, $header_row, $HTTP_VARS) { global $PHP_SELF; $buffer = "\n<form action=\"{$PHP_SELF}\" method=\"POST\">"; $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"import\">"; $buffer .= "\n<input type=\"hidden\" name=\"owner_id\" value=\"" . $HTTP_VARS['owner_id'] . "\">"; $buffer .= "\n<input type=\"hidden\" name=\"s_item_type\" value=\"" . $HTTP_VARS['s_item_type'] . "\">"; $buffer .= "\n<input type=\"hidden\" name=\"ic_sequence_number\" value=\"" . $HTTP_VARS['ic_sequence_number'] . "\">"; $buffer .= get_import_options_table($importPlugin, $HTTP_VARS); if ($importPlugin->get_plugin_type() == 'row') { $buffer .= get_row_column_mappings_table($HTTP_VARS['s_item_type'], $HTTP_VARS['owner_id'], $header_row, $HTTP_VARS['field_column'], $HTTP_VARS['field_default'], $HTTP_VARS['field_initcap']); if (strcasecmp(get_class($importPlugin), 'PreviewImportPlugin') !== 0) { $buffer .= "\n<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('import_items') . "\">"; } } else { if ($importPlugin->get_plugin_type() == 'xml') { // Include a Status Type LOV and a checkbox to indicate whether the s_status_type should be used for all imports // ignoring any s_status_type which may be included in the data. $buffer .= '<table>'; $results = fetch_newitem_status_type_rs(); if ($results && db_num_rows($results) > 1) { $buffer .= format_field(get_opendb_lang_var('s_status_type'), radio_grid('s_status_type', $results, '%img%', 'VERTICAL', $HTTP_VARS['s_status_type'])); // value $buffer .= format_field(get_opendb_lang_var('override_status_type'), "<input type=\"checkbox\" class=\"checkbox\" name=\"override_status_type\" value=\"Y\"" . (strcmp($HTTP_VARS['override_status_type'], 'Y') === 0 ? ' CHECKED' : '') . ">"); $buffer .= '</table>'; } else { if (db_num_rows($results) > 0) { // handle single status silently $status_type_r = db_fetch_assoc($results); $buffer .= "<input type=\"hidden\" name=\"s_status_type\" value=\"" . $status_type_r['s_status_type'] . "\">"; db_free_result($results); } } if (strcasecmp(get_class($importPlugin), 'PreviewImportPlugin') !== 0) { $buffer .= "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('import_items') . "\">"; } } } $buffer .= '</form>'; return $buffer; }
function get_item_input_field($fieldname, $item_attribute_type_r, $item_r, $value = NULL, $dowrap = TRUE, $prompt_mask = NULL, $onchange_event = NULL, $disabled = FALSE) { if (is_array($item_attribute_type_r)) { $s_attribute_type = $item_attribute_type_r['s_attribute_type']; $order_no = $item_attribute_type_r['order_no']; $prompt = $item_attribute_type_r['prompt']; $input_type = $item_attribute_type_r['input_type']; $compulsory_ind = $item_attribute_type_r['compulsory_ind']; $widget['type'] = $item_attribute_type_r['input_type']; $widget['args'][0] = $item_attribute_type_r['input_type_arg1']; $widget['args'][1] = $item_attribute_type_r['input_type_arg2']; $widget['args'][2] = $item_attribute_type_r['input_type_arg3']; $widget['args'][3] = $item_attribute_type_r['input_type_arg4']; $widget['args'][4] = $item_attribute_type_r['input_type_arg5']; } if ($item_attribute_type_r['multi_attribute_ind'] == 'Y') { $multi_value = TRUE; if (!is_array($value)) { $old_value = ifempty($value, ""); unset($value); $value[] = $old_value; } } else { $multi_value = FALSE; // an array will be a lookup value if (!is_array($value)) { // Escape all html entities so they are displayed correctly! if (strlen($value) > 0) { $value = htmlspecialchars($value); } } } $field = NULL; $field_mask = NULL; // Now we have to work out how to parse the input_type if ($item_attribute_type_r['input_type'] == 'hidden') { return hidden_field($fieldname, $value); } else { if ($item_attribute_type_r['input_type'] == 'readonly') { $field = readonly_field($fieldname, $value); } else { if ($item_attribute_type_r['input_type'] == 'textarea' || $item_attribute_type_r['input_type'] == 'htmlarea') { // arg[0] = rows, arg[1] = cols, arg[2] = length $field = textarea_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['widget']['2'], $compulsory_ind, $value, $onchange_event, $disabled); } else { if ($item_attribute_type_r['input_type'] == 'text') { // arg[0] = length of field, arg[1] = maxlength of field $field = text_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'password') { // arg[0] = length of field, arg[1] = maxlength of field $field = password_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'email') { // arg[0] = length of field, arg[1] = maxlength of field $field = email_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'filtered') { // arg[0] = length of field, arg[1] = maxlength of field, arg[2] = legalChars $field = filtered_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'datetime') { // arg[0] = datetime mask, arg[1] = auto_datetime $field = datetime_field($fieldname, $prompt, ifempty($widget['args']['0'], 'DD/MM/YYYY'), $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'number') { // arg[0] = length of field, arg[0] = maxlength of field $field = number_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['0'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'simple_checkbox') { // arg[0] = checked $field = checkbox_field($fieldname, $prompt, strcasecmp(trim($widget['args']['0']), 'CHECKED') === 0, $value, $onchange_event, $disabled); } else { if ($item_attribute_type_r['input_type'] == 'checkbox') { // arg[0] = checked, arg[1] = unchecked $field = enhanced_checkbox_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $value, $onchange_event, $disabled); } else { if ($item_attribute_type_r['input_type'] == 'checkbox_grid') { $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC'); if ($lookup_results) { //arg[0] = display_mask, arg[1] = orientation $field = checkbox_grid($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled); } } else { if ($item_attribute_type_r['input_type'] == 'radio_grid') { $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC'); if ($lookup_results) { //arg[0] = display_mask, arg[1] = orientation $field = radio_grid($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled); } } else { if ($item_attribute_type_r['input_type'] == 'value_radio_grid') { //arg[0] = "comma delimited list of values" $field = value_radio_grid($fieldname, explode(',', $widget['args']['0']), $value, $disabled); } else { if ($item_attribute_type_r['input_type'] == 'single_select') { $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC'); if ($lookup_results) { //arg[0] = display mask, arg[1] = max value length $field = single_select($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $onchange_event, $disabled); } } else { if ($item_attribute_type_r['input_type'] == 'multi_select') { $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC'); if ($lookup_results) { //arg[0] = display mask, arg[1] = max value length, arg[2] = select box number of visible rows $field = multi_select($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $value, $onchange_event, $disabled); } } else { if ($item_attribute_type_r['input_type'] == 'value_select') { //arg[0] = "comma delimited list of values"; arg[1] = number of visible rows (Defaults to single select $field = value_select($fieldname, explode(',', $widget['args']['0']), $widget['args']['1'], $value, $onchange_event, $disabled); } else { if ($item_attribute_type_r['input_type'] == 'review_options') { //arg[1] = display_mask, arg[1] = orientation $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'value DESC'); //We want the rows highest value first. if ($lookup_results) { $field = review_options($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled); } } else { if ($item_attribute_type_r['input_type'] == 'url') { //arg[0] = length of field, arg[1] = maxlength of field, arg[2] = extensions $field = url($fieldname, $item_r, $item_attribute_type_r, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $value, $onchange_event, $disabled, $multi_value); } else { $field = ">>> ERROR (input_type = {$input_type}) <<<"; } } } } } } } } } } } } } } } } } } } if ($dowrap) { return format_item_data_field($item_attribute_type_r, $field, $prompt_mask); } else { return $field; } }
function get_edit_item_instance_form($op, $item_r, $status_type_r, $HTTP_VARS) { $formContents = "<div class=\"tabContentHidden\" id=\"instance_info\">"; $formContents .= get_related_item_search_script(); $results = fetch_item_attribute_type_rs($item_r['s_item_type'], 'instance_field_types'); if ($results) { $formContents .= "<h3>" . get_opendb_lang_var('instance_info') . "</h3>"; $formContents .= "\n<table>"; if (($op == 'edit' || $op == 'refresh') && $status_type_r['change_owner_ind'] == 'Y') { $formContents .= format_field(get_opendb_lang_var('owner'), "\n<select name=\"owner_id\">" . custom_select('owner_id', fetch_user_rs(PERM_ITEM_OWNER, INCLUDE_ROLE_PERMISSIONS, INCLUDE_CURRENT_USER, EXCLUDE_DEACTIVATED_USER, 'user_id', 'ASC'), '%fullname% (%user_id%)', 'NA', ifempty($HTTP_VARS['owner_id'], $item_r['owner_id']), 'user_id') . "\n</select>"); } if ($op == 'newinstance' || $op == 'clone_item') { $item_r['s_status_type'] = NULL; $item_r['status_comment'] = NULL; $item_r['borrow_duration'] = NULL; } while ($item_attribute_type_r = db_fetch_assoc($results)) { if ($item_attribute_type_r['s_field_type'] == 'STATUSTYPE') { $status_type = ifempty(filter_item_input_field($item_attribute_type_r, $HTTP_VARS['s_status_type']), $item_r['s_status_type']); if ($op == 'new' || $op == 'site' || $op == 'newinstance' || $op == 'clone_item') { $lookup_results = fetch_newitem_status_type_rs(); } else { // If item has borrowed records, then no s_status_type with borrow_ind == 'X' should be included. $lookup_results = fetch_update_status_type_rs($status_type); } if ($lookup_results && db_num_rows($lookup_results) > 0) { $formContents .= format_field($item_attribute_type_r['prompt'], radio_grid('s_status_type', $lookup_results, '%img%', 'VERTICAL', $status_type)); // value } } else { if ($item_attribute_type_r['s_field_type'] == 'STATUSCMNT') { $status_comment = ifempty(filter_item_input_field($item_attribute_type_r, $HTTP_VARS['status_comment']), $item_r['status_comment']); $formContents .= get_item_input_field('status_comment', $item_attribute_type_r, NULL, $status_comment); } else { if ($item_attribute_type_r['s_field_type'] == 'DURATION') { $borrow_duration = ifempty(filter_item_input_field($item_attribute_type_r, $HTTP_VARS['borrow_duration']), $item_r['borrow_duration']); // The S_DURATION lookup list will most likely include an 'Undefined' option, that equates // to an empty string. So for Updates, we want to allow for a match, by forcing any NULL // value to a empty string. The reason why we do this, is because the Borrow Duration was // probably set to 'Undefined', but because this equated to an empty string, the field was // never updated. if ($op != 'new' && $op != 'site') { if ($borrow_duration === NULL) { $borrow_duration = ''; } } $formContents .= get_item_input_field('borrow_duration', $item_attribute_type_r, NULL, $borrow_duration); } } } } //while db_free_result($results); $formContents .= "\n</table>"; } if (get_opendb_config_var('item_input', 'related_item_support') !== FALSE) { $formContents .= "<h3>" . get_opendb_lang_var('add_related_parent') . "</h3>"; $formContents .= "\n<table>"; $formContents .= format_field(get_opendb_lang_var('parent_item_filter'), '<input type="text" name="parent_item_filter" id="parent_item_filter">'); $formContents .= format_field(get_opendb_lang_var('parent_item'), format_item_parents_select($HTTP_VARS, $item_r, '%parent_only%')); $formContents .= "\n</table>"; $relatedItems = get_related_items_listing($item_r, $HTTP_VARS, RELATED_PARENTS_MODE); if ($relatedItems != NULL) { $formContents .= "<h3>" . get_opendb_lang_var('related_parent_item(s)') . "</h3>"; $formContents .= $relatedItems; } } $formContents .= "</div>"; return $formContents; }