function get_edit_form($op, $review_r, $HTTP_VARS) { global $PHP_SELF; $formContents = ""; $formContents .= "<form action=\"{$PHP_SELF}\" method=\"POST\">"; $formContents .= "<table>"; $compulsory_ind = 'N'; if (get_opendb_config_var('item_review', 'comment_compulsory') === TRUE) { $compulsory_ind = 'Y'; } $formContents .= get_input_field("comment", NULL, get_opendb_lang_var('review'), "htmlarea(55,10)", $compulsory_ind, $review_r['comment'], TRUE); // We are now able to configure this in the database. $attribute_type_r = fetch_attribute_type_r('S_RATING'); $attribute_type_r['compulsory_ind'] = 'N'; if (get_opendb_config_var('item_review', 'rating_compulsory') == TRUE) { $attribute_type_r['compulsory_ind'] = 'Y'; } $formContents .= get_item_input_field("rating", $attribute_type_r, NULL, $review_r['rating']); $formContents .= "</table>"; if (get_opendb_config_var('widgets', 'enable_javascript_validation') !== FALSE) { $onclick_event = "if(!checkForm(this.form)){return false;}else{this.form.submit();}"; } else { $onclick_event = "this.form.submit();"; } $formContents .= format_help_block(array('img' => 'compulsory.gif', 'text' => get_opendb_lang_var('compulsory_field'), id => 'compulsory')); $formContents .= "<input type=\"button\" class=\"button\" onclick=\"{$onclick_event}\" value=\"" . get_opendb_lang_var('save_review') . "\">\n\t\t<input type=\"hidden\" name=\"op\" value=\"{$op}\">\n\t\t<input type=\"hidden\" name=\"sequence_number\" value=\"" . $review_r['sequence_number'] . "\">\n\t\t<input type=\"hidden\" name=\"item_id\" value=\"" . $HTTP_VARS['item_id'] . "\">\n\t\t<input type=\"hidden\" name=\"instance_no\" value=\"" . $HTTP_VARS['instance_no'] . "\">\n\t\t</form>"; return $formContents; }
/** * @param $op is 'edit' or 'new' */ function get_user_input_form($user_r, $HTTP_VARS) { global $PHP_SELF; $buffer .= "<form action=\"{$PHP_SELF}\" method=\"POST\">"; $buffer .= "<table class=\"userInputForm\">"; if (is_not_empty_array($user_r)) { $buffer .= get_input_field("user_id", NULL, get_opendb_lang_var('userid'), "readonly", "", $user_r['user_id'], TRUE); } else { $buffer .= get_input_field("user_id", NULL, get_opendb_lang_var('userid'), "filtered(20,20,a-zA-Z0-9_.)", "Y", $HTTP_VARS['user_id'], TRUE); } if (is_not_empty_array($user_r) && !is_user_granted_permission(PERM_ADMIN_USER_PROFILE)) { $role_r = fetch_role_r($user_r['user_role']); $buffer .= get_input_field("user_role", NULL, get_opendb_lang_var('user_role'), "readonly", "", $role_r['description'], TRUE); } else { $buffer .= format_field(get_opendb_lang_var('user_role'), custom_select('user_role', fetch_user_role_rs($HTTP_VARS['op'] == 'signup' ? EXCLUDE_SIGNUP_UNAVAILABLE_USER : INCLUDE_SIGNUP_UNAVAILABLE_USER), "%description%", '1', ifempty($user_r['user_role'], $HTTP_VARS['user_role']), 'role_name')); } $buffer .= get_input_field("fullname", NULL, get_opendb_lang_var('fullname'), "text(30,100)", "Y", ifempty($HTTP_VARS['fullname'], $user_r['fullname']), TRUE); $buffer .= get_input_field("email_addr", NULL, get_opendb_lang_var('email'), "email(30,100)", "Y", ifempty($HTTP_VARS['email_addr'], $user_r['email_addr']), TRUE); if (get_opendb_config_var('user_admin', 'user_themes_support') !== FALSE) { $uid_theme = ifempty($HTTP_VARS['uid_theme'], $user_r['theme']); $buffer .= format_field(get_opendb_lang_var('user_theme'), custom_select("uid_theme", get_user_theme_r(), "%value%", 1, is_exists_theme($uid_theme) ? $uid_theme : get_opendb_config_var('site', 'theme'))); // If theme no longer exists, then set to default! } if (get_opendb_config_var('user_admin', 'user_language_support') !== FALSE) { // Do not bother with language input field if only one language pack available. if (fetch_language_cnt() > 1) { $uid_language = ifempty($HTTP_VARS['uid_language'], $user_r['language']); $buffer .= format_field(get_opendb_lang_var('user_language'), custom_select('uid_language', fetch_language_rs(), "%language%", 1, is_exists_language($uid_language) ? $uid_language : get_opendb_config_var('site', 'language'), 'language', NULL, 'default_ind')); // If language no longer exists, then set to default! } } $buffer .= "</table>"; // Now do the addresses if (is_not_empty_array($user_r)) { $addr_results = fetch_user_address_type_rs($user_r['user_id'], TRUE); } else { $addr_results = fetch_address_type_rs(TRUE); } if ($addr_results) { while ($address_type_r = db_fetch_assoc($addr_results)) { $v_address_type = strtolower($address_type_r['s_address_type']); if (is_not_empty_array($user_r)) { $attr_results = fetch_address_type_attribute_type_rs($address_type_r['s_address_type'], 'update', TRUE); } else { $attr_results = fetch_address_type_attribute_type_rs($address_type_r['s_address_type'], 'update', TRUE); } if ($attr_results) { $buffer .= '<h3>' . $address_type_r['description'] . '</h3>'; $buffer .= "<ul class=\"addressIndicators\">"; $buffer .= '<li><input type="checkbox" class="checkbox" name="' . $v_address_type . '[public_address_ind]" value="Y"' . (ifempty($address_type_r['public_address_ind'], $HTTP_VARS[$v_address_type]['public_address_ind']) == 'Y' ? ' CHECKED' : '') . '">' . get_opendb_lang_var('public_address_indicator') . '</li>'; $buffer .= '<li><input type="checkbox" class="checkbox" name="' . $v_address_type . '[borrow_address_ind]" value="Y"' . (ifempty($address_type_r['borrow_address_ind'], $HTTP_VARS[$v_address_type]['borrow_address_ind']) == 'Y' ? ' CHECKED' : '') . '">' . get_opendb_lang_var('borrow_address_indicator') . '</li>'; $buffer .= "</ul>"; $buffer .= "<table class=\"addressInputForm\">"; while ($addr_attribute_type_r = db_fetch_assoc($attr_results)) { $fieldname = get_field_name($addr_attribute_type_r['s_attribute_type'], $addr_attribute_type_r['order_no']); $value = NULL; if ($address_type_r['sequence_number'] !== NULL) { if (is_lookup_attribute_type($addr_attribute_type_r['s_attribute_type'])) { $value = fetch_user_address_lookup_attribute_val($address_type_r['sequence_number'], $addr_attribute_type_r['s_attribute_type'], $addr_attribute_type_r['order_no']); } else { $value = fetch_user_address_attribute_val($address_type_r['sequence_number'], $addr_attribute_type_r['s_attribute_type'], $addr_attribute_type_r['order_no']); } $value = ifempty(filter_item_input_field($addr_attribute_type_r, $HTTP_VARS[$v_address_type][$fieldname]), $value); } else { $value = filter_item_input_field($addr_attribute_type_r, $HTTP_VARS[$v_address_type][$fieldname]); } // If this is an edit operation - the value must be NOT NULL // for some widgets to work properly. if ($address_type_r['sequence_number'] !== NULL && $value === NULL) { $value = ''; } $buffer .= get_item_input_field($v_address_type . '[' . $fieldname . ']', $addr_attribute_type_r, NULL, $value); } //while db_free_result($attr_results); $buffer .= "</table>"; } //if($attr_results) } //while db_free_result($addr_results); } //if($addr_results) $buffer .= format_help_block(array('img' => 'compulsory.gif', 'text' => get_opendb_lang_var('compulsory_field'), id => 'compulsory')); if ($HTTP_VARS['op'] == 'new_user') { $buffer .= "<h3>" . get_opendb_lang_var('password') . "</h3>"; if (get_opendb_config_var('user_admin', 'user_passwd_change_allowed') !== FALSE || is_user_granted_permission(PERM_ADMIN_CHANGE_PASSWORD)) { $buffer .= "<table class=\"changePasswordForm\">"; if (is_valid_opendb_mailer()) { $compulsory_ind = 'N'; } else { $compulsory_ind = 'Y'; } $buffer .= get_input_field("pwd", NULL, get_opendb_lang_var('new_passwd'), "password(30,40)", $compulsory_ind, "", TRUE); $buffer .= get_input_field("confirmpwd", NULL, get_opendb_lang_var('confirm_passwd'), "password(30,40)", $compulsory_ind, "", TRUE, NULL, get_opendb_config_var('widgets', 'enable_javascript_validation') !== FALSE ? "if( (this.form.pwd.value.length!=0 || this.form.confirmpwd.value.length!=0) && this.form.pwd.value!=this.form.confirmpwd.value){alert('" . get_opendb_lang_var('passwds_do_not_match') . "'); this.focus(); return false;}" : ""); $buffer .= "\n</table>"; if ($compulsory_ind == 'N') { $buffer .= format_help_block(get_opendb_lang_var('new_passwd_will_be_autogenerated_if_not_specified')); } } } if ($HTTP_VARS['op'] == 'signup' && get_opendb_config_var('login.signup', 'disable_captcha') !== TRUE) { $buffer .= render_secret_image_form_field(); } if (get_opendb_config_var('widgets', 'enable_javascript_validation') !== FALSE) { $onclick_event = "if(!checkForm(this.form)){return false;}else{this.form.submit();}"; } else { $onclick_event = "this.form.submit();"; } if (is_not_empty_array($user_r)) { $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"update\">"; if ($HTTP_VARS['user_id'] != get_opendb_session_var('user_id')) { $buffer .= "\n<input type=\"button\" class=\"button\" onclick=\"this.form.op.value='update'; {$onclick_event}\" value=\"" . get_opendb_lang_var('update_user') . "\">"; if (is_user_not_activated($HTTP_VARS['user_id'])) { $buffer .= "\n<input type=\"button\" class=\"button\" onclick=\"this.form.op.value='delete'; this.form.submit();\" value=\"" . get_opendb_lang_var('delete_user') . "\">"; } else { if (is_user_active($HTTP_VARS['user_id'])) { $buffer .= "\n<input type=\"button\" class=\"button\" onclick=\"this.form.op.value='deactivate'; this.form.submit();\" value=\"" . get_opendb_lang_var('deactivate_user') . "\">"; } } if (!is_user_active($HTTP_VARS['user_id'])) { $buffer .= "\n<input type=\"button\" class=\"button\" onclick=\"this.form.op.value='activate'; this.form.submit();\" value=\"" . get_opendb_lang_var('activate_user') . "\">"; } } else { $buffer .= "\n<input type=\"button\" class=\"button\" onclick=\"{$onclick_event}\" value=\"" . get_opendb_lang_var('update_details') . "\">"; } } else { if ($HTTP_VARS['op'] != 'signup') { if (is_valid_opendb_mailer()) { if ($HTTP_VARS['op'] == 'new_user') { if ($HTTP_VARS['email_user'] == 'Y') { $checked = "CHECKED"; } else { $checked = ""; } } else { $checked = "CHECKED"; } $buffer .= "<p><input type=\"checkbox\" class=\"checkbox\" id=\"email_user\" name=\"email_user\" value=\"Y\" {$checked}>" . get_opendb_lang_var('send_welcome_email') . "</p>"; } $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"insert\">" . "\n<input type=\"button\" class=\"button\" onclick=\"{$onclick_event}\" value=\"" . get_opendb_lang_var('add_user') . "\">"; } else { $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"signup\">" . "<input type=\"hidden\" name=\"op2\" value=\"send_info\">" . "<input type=\"button\" class=\"button\" onclick=\"{$onclick_event}\" value=\"" . get_opendb_lang_var('submit') . "\">"; } } $buffer .= "\n</form>"; return $buffer; }
echo _theme_header($page_title); echo '<h2>' . $page_title . ' ' . $page_image . '</h2>'; $attribute_type_r = fetch_alt_item_id_attribute_type_r(); $altid_item_instance_rs = update_altid_item_instance_rs($HTTP_VARS['op'], $HTTP_VARS['alt_item_id'], $attribute_type_r, get_decoded_item_instance_rs($HTTP_VARS['op'], $HTTP_VARS['checkout_item_instance_rs']), $errors); if (is_array($errors) > 0) { echo format_error_block($errors); } echo "\n<form action=\"{$PHP_SELF}\" method=\"POST\">"; echo "\n<input type=\"hidden\" name=\"op\" value=\"" . $HTTP_VARS['op'] . "\">"; echo "\n<input type=\"hidden\" name=\"page_no\" value=\"\">"; //dummy if ($HTTP_VARS['op'] == 'checkout') { echo "\n<input type=\"hidden\" name=\"borrower_id\" value=\"" . $HTTP_VARS['borrower_id'] . "\">"; } echo "\n<table class=\"borrowerForm\">"; echo get_item_input_field('alt_item_id', $attribute_type_r, NULL); echo "\n</table>"; echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('add_item') . "\">"; $HTTP_VARS['checkout_item_instance_rs'] = get_encoded_item_instance_rs($altid_item_instance_rs); echo get_url_fields(NULL, array('checkout_item_instance_rs' => $HTTP_VARS['checkout_item_instance_rs'])); if (is_not_empty_array($HTTP_VARS['checkout_item_instance_rs'])) { if ($HTTP_VARS['op'] == 'checkout') { echo "<input type=\"button\" class=\"button\" onclick=\"doFormSubmit(this.form, 'item_borrow.php', 'quick_check_out')\" value=\"" . get_opendb_lang_var('check_out_item(s)') . "\">"; } else { $HTTP_VARS['sequence_number'] = get_borrowed_item_sequence_number_r($altid_item_instance_rs); echo get_url_fields(NULL, array('sequence_number' => $HTTP_VARS['sequence_number'])); echo "<input type=\"button\" class=\"button\" onclick=\"doFormSubmit(this.form, 'item_borrow.php', 'check_in')\" value=\"" . get_opendb_lang_var('check_in_item(s)') . "\">"; } } echo "</form>"; unset($HTTP_VARS['alt_item_id']);
/** stub for non item specific functionality */ function get_input_field($fieldname, $s_attribute_type, $prompt, $input_type, $compulsory_ind = 'N', $value = NULL, $dowrap = TRUE, $prompt_mask = NULL, $onchange_event = NULL, $disabled = FALSE) { $input_type_def = prc_function_spec($input_type); return get_item_input_field($fieldname, array('s_attribute_type' => $s_attribute_type, 'order_no' => NULL, 'prompt' => $prompt, 'input_type' => $input_type_def['type'], 'input_type_arg1' => $input_type_def['args'][0], 'input_type_arg2' => $input_type_def['args'][1], 'input_type_arg3' => $input_type_def['args'][2], 'input_type_arg4' => $input_type_def['args'][3], 'input_type_arg5' => $input_type_def['args'][4], 'compulsory_ind' => $compulsory_ind), NULL, $value, $dowrap, $prompt_mask, $onchange_event, $disabled); }
/** */ function get_row_column_mappings_table($s_item_type, $owner_id, $header_row, $field_column_r, $field_default_r, $field_initcap_r) { $buffer = "\n<table>"; $buffer .= "\n<tr class=\"navbar\"><th></th>" . "<th>" . get_opendb_lang_var('field') . "</th>" . "<th>" . get_opendb_lang_var('default') . "</th>" . "<th> " . get_opendb_lang_var('initcap') . "</th></tr>"; // If the prompt for this field, matches any of the $tokens, then select that token. if (!is_numeric($field_column_r['s_item_type'])) { for ($i = 0; $i < count($header_row); $i++) { if ($header_row[$i] == 's_item_type' || $header_row[$i] == get_opendb_lang_var('s_item_type')) { $field_column_r['s_item_type'] = $i; break; } } } // If your data includes the item_type, then specify the column, so we // can ignore records that are not of the chosen item_type. $buffer .= "\n<tr>" . "<th class=\"prompt\" scope=\"row\">" . get_opendb_lang_var('s_item_type') . "</th>" . "<td class=\"data fieldColumn\">" . get_column_select_block("field_column[s_item_type]", $header_row, $field_column_r['s_item_type']) . "</td>" . "<td class=\"data defaultColumn\"> </td>" . "<td class=\"data initcapColumn\"> </td>" . "</tr>"; // --------- Now the main input fields start.... $results = fetch_item_attribute_type_rs($s_item_type); if ($results) { while ($item_attribute_type_r = db_fetch_assoc($results)) { // purely readonly if ($item_attribute_type_r['s_field_type'] !== 'ITEM_ID') { $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); if ($item_attribute_type_r['s_field_type'] == 'STATUSTYPE') { $lookup_results = fetch_newitem_status_type_rs(); $default_field = build_select("field_default[{$fieldname}]", $lookup_results, $field_default_r[$fieldname], FALSE); // do not include 'None' option $initcap_field = NULL; // No initcap for these types of fields. } else { if ($item_attribute_type_r['input_type'] !== "textarea" && $item_attribute_type_r['input_type'] !== "url") { // Check if any lookup values for this field. $lookup_results = fetch_attribute_type_lookup_rs($item_attribute_type_r['s_attribute_type'], 'order_no, value ASC'); if ($lookup_results) { $default_field = build_select("field_default[{$fieldname}]", $lookup_results, $field_default_r[$fieldname]); $initcap_field = NULL; // No initcap for these types of fields. } else { //use normal input field. if ($item_attribute_type_r['multi_attribute_ind'] == 'Y') { $item_attribute_type_r['multi_attribute_ind'] = 'N'; } $default_field = get_item_input_field("field_default[{$fieldname}]", $item_attribute_type_r, NULL, $field_default_r[$fieldname], FALSE); if ($item_attribute_type_r['input_type'] === 'text') { $initcap_field = get_input_field("field_initcap[{$fieldname}]", NULL, NULL, "checkbox(true,false,)", "N", ifempty($field_initcap_r[$fieldname], get_opendb_config_var('import', 'row_import_default_initcap_checked') ? "true" : "false"), FALSE); } else { //Only for text fields. $initcap_field = NULL; } } } else { $field = NULL; $default_field = NULL; $initcap_field = NULL; } } // If the prompt for this field, matches any of the $tokens, then select that token. if (!is_numeric($field_column_r[$fieldname])) { for ($i = 0; $i < count($header_row); $i++) { // A direct export from CSV Export, so lets match the columns for you. if ($header_row[$i] == $fieldname || $header_row[$i] == $item_attribute_type_r['prompt'] || $item_attribute_type_r['s_field_type'] == 'CATEGORY' && $header_row[$i] == 'Genre') { $field_column_r[$fieldname] = $i; break; } } } $buffer .= "\n<tr>" . "<th class=\"prompt\" scope=\"row\">" . $item_attribute_type_r['prompt'] . "</th>" . "<td class=\"data fieldColumn\">" . get_column_select_block("field_column[{$fieldname}]", $header_row, $field_column_r[$fieldname]) . "</td>" . "<td class=\"data defaultColumn\">" . $default_field . "</td>" . "<td class=\"data initcapColumn\">" . $initcap_field . "</td>" . "</tr>"; } //if($item_attribute_type_r['s_field_type'] !== 'ITEM_ID') } //while db_free_result($results); } //if($results) $buffer .= "\n</table>"; return $buffer; }
echo "\n<input type=\"hidden\" name=\"search_list\" value=\"y\">"; echo "<table class=\"searchForm\">"; echo format_field(get_opendb_lang_var('title'), "\n<input type=\"text\" class=\"text\" id=\"search-title\" size=\"50\" name=\"title\">" . "\n<ul class=\"searchInputOptions\">" . "\n<li><input type=\"radio\" class=\"radio\" name=\"title_match\" value=\"word\">" . get_opendb_lang_var('word_match') . "</li>" . "\n<li><input type=\"radio\" class=\"radio\" name=\"title_match\" value=\"partial\" CHECKED>" . get_opendb_lang_var('partial_match') . "</li>" . "\n<li><input type=\"radio\" class=\"radio\" name=\"title_match\" value=\"exact\">" . get_opendb_lang_var('exact_match') . "</li>" . "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"title_case\" value=\"case_sensitive\">" . get_opendb_lang_var('case_sensitive') . "</li>" . "\n</ul>"); if (@count($category_type_rs) > 1) { $catTypeSelect = "<select name=\"category\" id=\"search-category\">" . "\n<option value=\"\">-------------- " . get_opendb_lang_var('all') . " --------------"; reset($category_type_rs); while (list($value, $display) = each($category_type_rs)) { $catTypeSelect .= "\n<option value=\"{$value}\">{$display}"; } $itemTypeBlock .= "</select>"; echo format_field(get_opendb_lang_var('category'), $catTypeSelect); } if (get_opendb_config_var('item_review', 'enable') !== FALSE) { $attribute_type_r = fetch_attribute_type_r("S_RATING"); $attribute_type_r['compulsory_ind'] = 'N'; echo get_item_input_field("rating", $attribute_type_r, NULL, NULL); //value } if (@count($item_type_rs) > 1) { $itemTypeSelect = "<select name=\"s_item_type\" id=\"search-itemtype\" onChange=\"populateList(this.options[this.options.selectedIndex].value, this.form.attribute_type, arrayOfAttributes, true, '------------- " . get_opendb_lang_var('all') . " -------------', false);\">" . "\n<option value=\"\">-------------- " . get_opendb_lang_var('all') . " --------------"; reset($item_type_rs); while (list(, $item_type_r) = each($item_type_rs)) { $itemTypeSelect .= "\n<option value=\"" . $item_type_r['s_item_type'] . "\" >" . $item_type_r['s_item_type'] . " - " . $item_type_r['description']; } $itemTypeBlock .= "</select>"; echo format_field(get_opendb_lang_var('item_type'), $itemTypeSelect); } $attrTypeSelect = "<select name=\"attribute_type\" id=\"search-attributetype\" onChange=\"populateList(this.options[this.options.selectedIndex].value, this.form['lookup_attribute_val'], arrayOfLookupValues, false, '" . get_opendb_lang_var('use_the_value_field') . " ---->', true);\">" . "\n<option value=\"\">-------------- " . get_opendb_lang_var('all') . " --------------"; @reset($item_attribute_type_rs); while (list(, $item_attribute_type_r) = @each($item_attribute_type_rs)) { if (has_role_permission($item_attribute_type_r['view_perm'])) {
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; }
/** * @param $borrowed_item_rs Items that this action will be performed against. It may actually * be an array of 'sequence_number' values, in which case the borrow * record for the sequence_number will be fetched. * @param $HTTP_VARS * */ function more_information_form($op, $borrowed_item_rs, $HTTP_VARS, $email_notification = TRUE) { global $PHP_SELF; $duration_attr_type = NULL; $default_borrow_duration = NULL; echo "\n<form action=\"{$PHP_SELF}\" method=\"POST\">"; // In case no detail is required. echo "\n<input type=\"hidden\" name=\"more_info_requested\" value=\"true\">"; // Pass all http variables onto next instance... // Includes empty fields... echo get_url_fields($HTTP_VARS, NULL, NULL); // Display the items to be operated on. if (is_not_empty_array($borrowed_item_rs)) { echo "<div id=\"moreInfoListing\">"; // no pagination. $HTTP_VARS['items_per_page'] = ''; $listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS); $listingObject->setIncludeHrefLinks(TRUE); $listingObject->setIncludeFooter(FALSE); $listingObject->startListing(); $listingObject->addHeaderColumn(get_opendb_lang_var('type')); $listingObject->addHeaderColumn(get_opendb_lang_var('title')); if ($op == 'reserve' || $op == 'cancel_reserve' || $op == 'quick_check_out') { $listingObject->addHeaderColumn(get_opendb_lang_var('owner')); } else { if ($op == 'check_in') { $listingObject->addHeaderColumn(get_opendb_lang_var('borrower')); } } if (get_opendb_config_var('borrow', 'duration_support')) { if ($op == 'check_out' || $op == 'quick_check_out') { $listingObject->addHeaderColumn(get_opendb_lang_var('borrow_duration')); } } //initialise $max_overdue_duration = NULL; $default_borrow_duration = NULL; reset($borrowed_item_rs); while (list(, $borrowed_item_r) = each($borrowed_item_rs)) { $listingObject->startRow(); // If only a sequence_number, we need to fetch the borrow record. if (!is_array($borrowed_item_r) && is_numeric($borrowed_item_r)) { $borrowed_item_r = fetch_borrowed_item_r($borrowed_item_r); } // TODO - add borrowed item history this to be displayed as readonly. //$results = fetch_borrowed_item_hist_rs($borrowed_item_r['sequence_number']); $item_r = fetch_item_instance_r($borrowed_item_r['item_id'], $borrowed_item_r['instance_no']); $listingObject->addItemTypeImageColumn($item_r['s_item_type']); $listingObject->addTitleColumn($item_r); if ($op == 'reserve' || $op == 'cancel_reserve' || $op == 'quick_check_out') { $listingObject->addUserNameColumn($item_r['owner_id'], array('bi_sequence_number' => $borrowed_item_r['sequence_number'])); } else { if ($op == 'check_in') { $listingObject->addUserNameColumn($borrowed_item_r['borrower_id'], array('bi_sequence_number' => $borrowed_item_r['sequence_number'])); } } if (get_opendb_config_var('borrow', 'duration_support')) { if ($op == 'check_out' || $op == 'quick_check_out') { if (is_numeric($item_r['borrow_duration'])) { // todo - change $duration_attr_type_r = fetch_sfieldtype_item_attribute_type_r($item_r['s_item_type'], 'DURATION'); $listingObject->addDisplayColumn($duration_attr_type_r['s_attribute_type'], NULL, $duration_attr_type_r['display_type'], $item_r['borrow_duration']); } else { $listingObject->addColumn(get_opendb_lang_var('undefined')); } } } // While we are here, we are going to calculate the default duration value. // We want to choose the least duration value. If any of the items use a // different s_attribute_type for duration, then we should not try to get // a default value. This is indicated by the $duration_attr_type===FALSE // if we have encountered a difference. if (get_opendb_config_var('borrow', 'duration_support') && $duration_attr_type !== FALSE) { $new_duration_attr_type = fetch_sfieldtype_item_attribute_type($item_r['s_item_type'], 'DURATION'); if ($duration_attr_type == NULL) { $duration_attr_type = $new_duration_attr_type; } else { if ($duration_attr_type !== $new_duration_attr_type) { // Different s_attribute_type's for DURATION, so cannot display Duration chooser. $duration_attr_type = FALSE; } } if ($duration_attr_type !== FALSE) { if ($op == 'check_out' || $op == 'quick_check_out') { // The default borrow duration should be the least amount of days or undefined // if no records have a borrow duration. if ($default_borrow_duration === NULL) { $default_borrow_duration = $item_r['borrow_duration']; } else { if ($default_borrow_duration !== '') { // Undefined empty value. if (is_numeric($default_borrow_duration) && is_numeric($item_r['borrow_duration']) && $item_r['borrow_duration'] < $default_borrow_duration) { $default_borrow_duration = $item_r['borrow_duration']; } } } } else { if ($op == 'extension') { if ($borrowed_item_r['total_duration'] > $borrowed_item_r['borrow_duration']) { $tmp_overdue_duration = $borrowed_item_r['total_duration'] - $borrowed_item_r['borrow_duration']; } // We want to get the max overdue duration, so we can give the User granting the extension a // default, that will bring all selected items back into non-overdue status. if (!is_numeric($max_overdue_duration) || $max_overdue_duration < $tmp_overdue_duration) { $max_overdue_duration = $tmp_overdue_duration; } } } } } //if(get_opendb_config_var('borrow', 'duration_support') && $duration_attr_type!==FALSE) $listingObject->endRow(); } //while(list(,$borrowed_item_r) = each($borrowed_item_rs)) $listingObject->endListing(); echo "</div>"; } echo "<table class=\"moreInfo\">"; // Do not display this more information section unless email is enabled. if (is_valid_opendb_mailer() && $email_notification !== FALSE) { echo get_input_field("more_information", NULL, get_opendb_lang_var('more_information'), "textarea(50,10)", "N", NULL, TRUE); } // Include a Borrower ID select, minus the current user. if ($op == 'quick_check_out') { if (strlen($HTTP_VARS['borrower_id']) == 0 || !is_user_granted_permission(PERM_USER_BORROWER, $HTTP_VARS['borrower_id'])) { $current_user_mode = EXCLUDE_CURRENT_USER; if (get_opendb_config_var('borrow', 'owner_self_checkout') !== FALSE) { $current_user_mode = INCLUDE_CURRENT_USER; } $results = fetch_user_rs(PERM_USER_BORROWER, INCLUDE_ROLE_PERMISSIONS, $current_user_mode, EXCLUDE_DEACTIVATED_USER, 'fullname', 'ASC'); if ($results) { echo format_field(get_opendb_lang_var('borrower'), custom_select('borrower_id', $results, '%fullname% (%user_id%)', 1, NULL, 'user_id')); } else { echo format_field(get_opendb_lang_var('borrower'), get_opendb_lang_var('no_records_found')); } } } //Only for check_out/quick_check_out operations - makes no sense otherwise! if (get_opendb_config_var('borrow', 'duration_support') !== FALSE && ($op == 'check_out' || $op == 'quick_check_out' || $op == 'extension')) { // Display default borrow duration. if (strlen($duration_attr_type) > 0) { $duration_attr_type_r = fetch_attribute_type_r($duration_attr_type); // We have to find the matching DURATION lookup value, which is at least // as many days as the max_overdue value, or the highest possible // duration value, if none found as large as the $max_overdue_duration if ($op == 'extension') { $default_borrow_duration = NULL; $result = fetch_attribute_type_lookup_rs($duration_attr_type_r['s_attribute_type'], 'order_no, value ASC'); if ($result) { while ($lookup_r = db_fetch_assoc($result)) { if (is_numeric($lookup_r['value']) && (!is_numeric($max_overdue_duration) || is_numeric($max_overdue_duration) && $max_overdue_duration <= $lookup_r['value'])) { $default_borrow_duration = $lookup_r['value']; break; } // backup, in case we need to use outside while loop $lookup_r2 = $lookup_r; } db_free_result($result); // If still null, then set to the largest option if ($default_borrow_duration == NULL) { $default_borrow_duration = $lookup_r2['value']; } } } if ($op != 'extension' && strlen(get_opendb_lang_var('default_borrow_duration')) > 0 && is_array($borrowed_item_rs)) { $duration_attr_type_r['prompt'] = get_opendb_lang_var('default_borrow_duration'); } $duration_attr_type_r['compulsory_ind'] = 'N'; echo get_item_input_field("default_borrow_duration", $duration_attr_type_r, NULL, $op != 'quick_check_out' ? $default_borrow_duration : NULL); // Not appropriate for extension operation if ($op == 'check_out' || $op == 'quick_check_out') { echo get_input_field("override_item_duration", NULL, get_opendb_lang_var('override_item_duration'), "simple_checkbox(" . ($default_borrow_duration === NULL ? "CHECKED" : "") . ")", "N", "Y", TRUE); } } else { //otherwise tell checkout to use item_instance borrow duration instead. if ($op == 'check_out' || $op == 'quick_check_out') { echo "\n<input type=\"hidden\" name=\"override_item_duration\" value=\"N\">"; } } } echo "</table>"; echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">"; echo "</form>"; echo format_help_block(get_opendb_lang_var('more_information_help')); }