function getListingFiltersBlock() { global $PHP_SELF; global $HTTP_VARS; $buffer = ''; if ($HTTP_VARS['listings.filters'] != 'N' && get_opendb_config_var('listings.filters', 'enable') !== FALSE) { $excluded_vars_list = NULL; $buffer .= "<div id=\"listing-filters\" class=\"menuContainer toggleContainer\">"; $buffer .= "<span id=\"listing-filters-toggle\" class=\"menuToggle toggleHidden\" onclick=\"return toggleVisible('listing-filters');\">" . get_opendb_lang_var('listing_filters') . "</span>"; $buffer .= "<div id=\"listing-filters-content\" class=\"menuContent elementHidden\"\">"; $buffer .= "<h2 class=\"menu\">" . get_opendb_lang_var('listing_filters') . "</h2>"; $buffer .= "<form name=\"listing-filters\" action=\"{$PHP_SELF}\" method=\"GET\">"; $buffer .= "<ul>"; if (get_opendb_config_var('listings.filters', 'show_owner_lov') !== FALSE) { $excluded_vars_list[] = 'owner_id'; $buffer .= "<li><label for=\"select-owner_id\">" . get_opendb_lang_var('owner_id') . "</label>\n\t\t\t\t<select id=\"select-owner_id\" name=\"owner_id\">\n\t\t\t\t<option value=\"\"></option>" . custom_select('owner_id', fetch_user_rs(PERM_ITEM_OWNER), '%fullname% (%user_id%)', 'NA', $HTTP_VARS['owner_id'], 'user_id') . "\n</select></li>"; } if (get_opendb_config_var('listings.filters', 'show_s_status_type_lov') !== FALSE) { if (!is_array($HTTP_VARS['s_status_type']) || $HTTP_VARS['search_list'] != 'y' && $HTTP_VARS['attribute_list'] != 'y') { $results = fetch_status_type_rs(); if ($results && db_num_rows($results) > 1) { $excluded_vars_list[] = 's_status_type'; $buffer .= "<li><label for=\"select-s_status_type\">" . get_opendb_lang_var('s_status_type') . "</label>\n\t\t\t\t\t\t<select id=\"select-s_status_type\" name=\"s_status_type\">\n\t\t\t\t\t\t<option value=\"\"></option>" . custom_select('owner_id', $results, '%s_status_type% - %description%', 'NA', $HTTP_VARS['s_status_type'], 's_status_type') . "\n</select></li>"; } } } if (get_opendb_config_var('listings.filters', 'show_item_type_group_lov') !== FALSE) { $v_item_type_groups = get_list_item_type_groups(); if (is_not_empty_array($v_item_type_groups)) { $excluded_vars_list[] = 's_item_type_group'; $buffer .= "<li><label for=\"select-s_item_type_group\">" . get_opendb_lang_var('s_item_type_group') . "</label>\n\t\t\t\t\t<select id=\"select-s_item_type_group\" name=\"s_item_type_group\">\n\t\t\t\t\t<option value=\"\"></option>" . custom_select('s_item_type_group', $v_item_type_groups, '%value% - %display%', 'NA', $HTTP_VARS['s_item_type_group'], 'value') . "\n</select></li>"; } } if (get_opendb_config_var('listings.filters', 'show_item_type_lov') !== FALSE) { $v_item_types = get_list_item_types(NULL); if (is_not_empty_array($v_item_type_groups)) { $excluded_vars_list[] = 's_item_type'; $buffer .= "<li><label for=\"select-s_item_type\">" . get_opendb_lang_var('s_item_type') . "</label>\n\t\t\t\t\t<select id=\"select-s_item_type\" name=\"s_item_type\">\n\t\t\t\t\t<option value=\"\"></option>" . custom_select('s_item_type', $v_item_types, '%value% - %display%', 'NA', $HTTP_VARS['s_item_type'], 'value') . "\n</select></li>"; } } if (get_opendb_config_var('listings.filters', 'show_interest') !== FALSE) { $buffer .= "<li><label for=\"select-interest\">" . get_opendb_lang_var('interest_only_marked') . "</label>" . "<input type=\"checkbox\" class=\"checkbox\" id=\"select-interest\" name=\"interest_level\" value=\"1\"" . ($HTTP_VARS['interest_level'] >= 1 ? ' CHECKED' : '') . "></li>"; $excluded_vars_list[] = 'interest_level'; } if ($HTTP_VARS['owner_id'] != get_opendb_session_var('user_id')) { $buffer .= "<li><label for=\"exclude-current-user\">" . get_opendb_lang_var('exclude_current_user') . "</label>" . "<input type=\"checkbox\" class=\"checkbox\" id=\"exclude-current-user\" name=\"not_owner_id\" value=\"" . get_opendb_session_var('user_id') . "\"" . ($HTTP_VARS['not_owner_id'] == get_opendb_session_var('user_id') ? ' CHECKED' : '') . "></li>"; $excluded_vars_list[] = 'not_owner_id'; } $buffer .= "</ul>"; $buffer .= get_url_fields($HTTP_VARS, NULL, $excluded_vars_list); $buffer .= "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">"; $buffer .= "</form>"; $buffer .= "</div>"; $buffer .= "</div>"; } return $buffer; }
function show_changeuser_form() { echo "<h2>" . get_opendb_lang_var('change_user') . "</h2>"; echo "\n<form action=\"user_admin.php\" method=\"GET\">"; echo "\n<input type=\"hidden\" name=\"op\" value=\"change_user\">"; echo "\n<table class=\"changeUserForm\">"; $results = fetch_user_rs(PERM_ADMIN_CHANGE_USER, EXCLUDE_ROLE_PERMISSIONS, EXCLUDE_CURRENT_USER, EXCLUDE_DEACTIVATED_USER, 'fullname', 'ASC'); if ($results) { echo format_field(get_opendb_lang_var('user'), custom_select('uid', $results, '%fullname% (%user_id%)', 1, NULL, 'user_id')); } else { echo format_field(get_opendb_lang_var('user'), get_opendb_lang_var('no_records_found')); } echo "</table>"; echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">"; echo "</form>"; }
function display_borrower_form($HTTP_VARS) { echo "\n<form action=\"{$PHP_SELF}\" method=\"GET\">"; echo "\n<input type=\"hidden\" name=\"op\" value=\"checkout\">"; echo "\n<table class=\"borrowerForm\">"; if (get_opendb_config_var('borrow', 'admin_quick_checkout_borrower_lov') !== TRUE) { echo get_input_field('borrower_id', NULL, get_opendb_lang_var('borrower'), "filtered(20,20,a-zA-Z0-9_.)", "Y", NULL, TRUE); } else { $results = fetch_user_rs(PERM_USER_BORROWER, INCLUDE_ROLE_PERMISSIONS, EXCLUDE_CURRENT_USER, 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')); } } echo "</table>"; echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">"; echo "</form>"; }
function send_email_to_site_admins($user_role_permissions, $from_email_addr, $subject, $message, &$errors) { $success = TRUE; if (!is_valid_email_addr($from_email_addr)) { $errors[] = get_opendb_lang_var('invalid_from_address'); $success = FALSE; } if (strlen($subject) == 0) { $errors[] = get_opendb_lang_var('invalid_subject'); $success = FALSE; } if ($success) { $success = FALSE; $results = fetch_user_rs($user_role_permissions); while ($user_r = db_fetch_assoc($results)) { if (opendb_user_email($user_r['user_id'], $from_email_addr, $subject, $message, $errors)) { $success = TRUE; } } } return $success; }
// Set it explicitly here. $HTTP_VARS['op'] = 'my_reserve_basket'; if (is_exists_item_instance($HTTP_VARS['item_id'], $HTTP_VARS['instance_no'])) { $footer_links_r[] = array(url => "item_display.php?item_id=" . $HTTP_VARS['item_id'] . "&instance_no=" . $HTTP_VARS['instance_no'], text => get_opendb_lang_var('back_to_item')); } if (is_opendb_session_var('listing_url_vars')) { $footer_links_r[] = array(url => "listings.php?" . get_url_string(get_opendb_session_var('listing_url_vars')), text => get_opendb_lang_var('back_to_listing')); } } else { if ($HTTP_VARS['op'] == 'admin_history') { echo _theme_header(get_opendb_lang_var('borrower_history')); echo "<h2>" . get_opendb_lang_var('borrower_history') . "</h2>"; echo "\n<form action=\"{$PHP_SELF}\" method=\"GET\">"; echo "\n<input type=\"hidden\" name=\"op\" value=\"my_history\">"; echo "\n<table>"; $results = fetch_user_rs(PERM_USER_BORROWER, ROLE_PERMISSIONS_INCLUDE, INCLUDE_CURRENT_USER, EXCLUDE_DEACTIVATED_USER, "fullname", "ASC"); echo format_field(get_opendb_lang_var('borrower'), custom_select('uid', $results, '%fullname% (%user_id%)', 1, get_opendb_session_var('user_id'), 'user_id')); echo "</table>"; echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">"; echo "</form>"; echo _theme_footer(); $show_listings = FALSE; } else { opendb_operation_not_available(); $show_listings = FALSE; } } } } } }
function get_user_id_rs() { $user_id_rs = NULL; $result = fetch_user_rs(PERM_RECEIVE_EMAIL, INCLUDE_ROLE_PERMISSIONS, INCLUDE_CURRENT_USER, EXCLUDE_DEACTIVATED_USER, TRUE, 'user_id', 'ASC'); if ($result) { while ($user_r = db_fetch_assoc($result)) { $user_id_rs[] = $user_r['user_id']; } db_free_result($result); } return $user_id_rs; }
echo "<table>"; $field = "\n<select name=\"plugin\">\n"; $plugin_list_r = get_export_plugin_list_r(); if (is_array($plugin_list_r)) { while (list(, $plugin_r) = @each($plugin_list_r)) { $field .= '<option value="' . $plugin_r['name'] . '"'; if ($plugin_r['name'] == 'OpenDbExportPlugin') { $field .= ' SELECTED'; } $field .= '>' . $plugin_r['description'] . "\n"; } } $field .= "</select>"; echo format_field(get_opendb_lang_var('type'), $field); if (is_user_granted_permission(PERM_ADMIN_EXPORT)) { echo format_field(get_opendb_lang_var('owner'), "\n<select name=\"owner_id\">" . "\n<option value=\"\">-------------- " . get_opendb_lang_var('all') . " --------------" . custom_select('owner_id', fetch_user_rs(PERM_USER_EXPORT), '%fullname% (%user_id%)', 'NA', ifempty($HTTP_VARS['owner_id'], get_opendb_session_var('user_id')), 'user_id') . "\n</select>"); } else { echo "<input type=\"hidden\" name=\"owner_id\" value=\"" . $HTTP_VARS['owner_id'] . "\">"; } echo format_field(get_opendb_lang_var('item_type'), "<select name=\"s_item_type\">" . "\n<option value=\"\">-------------- " . get_opendb_lang_var('all') . " --------------" . custom_select('s_item_type', fetch_item_type_rs(), '%s_item_type% - %description%', 'NA', $HTTP_VARS['s_item_type'], 's_item_type') . "\n</select>"); $lookup_results = fetch_status_type_rs(TRUE); if ($lookup_results && db_num_rows($lookup_results) > 1) { echo format_field(get_opendb_lang_var('s_status_type'), checkbox_grid('s_status_type', $lookup_results, '%img%', 'VERTICAL', NULL)); // value } echo "</table>"; echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">"; echo "</form>"; echo _theme_footer(); } } else {
function get_upload_form($HTTP_VARS) { global $PHP_SELF; $buffer .= "\n<form name=\"main\" action=\"{$PHP_SELF}\" method=\"POST\" enctype=\"multipart/form-data\">"; $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"upload\">"; $buffer .= "\n<table>"; if (is_user_granted_permission(PERM_ADMIN_IMPORT)) { $buffer .= format_field(get_opendb_lang_var('owner'), custom_select('owner_id', fetch_user_rs(PERM_USER_IMPORT), '%fullname% (%user_id%)', 1, ifempty($HTTP_VARS['owner_id'], get_opendb_session_var('user_id')), 'user_id')); } else { $buffer .= "\n<input type=\"hidden\" name=\"owner_id\" value=\"" . $HTTP_VARS['owner_id'] . "\">"; } $buffer .= format_field(get_opendb_lang_var('item_type'), single_select('s_item_type', fetch_item_type_rs(TRUE), "%value% - %display%", NULL, $HTTP_VARS['s_item_type'])); $buffer .= format_field(get_opendb_lang_var('file'), "<input type=\"file\" class=\"file\" size=\"25\" name=\"uploadfile\">"); $buffer .= "\n</table>"; $buffer .= "\n<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">"; $buffer .= "\n</form>"; return $buffer; }
function build_borrower_stats() { if (get_opendb_config_var('borrow', 'enable') !== FALSE) { echo "<h3>" . get_opendb_lang_var('borrow_stats') . "</h3>"; echo "<table class=\"itemStats\">"; echo "<tr class=\"navbar\">"; echo "<th>" . get_opendb_lang_var('owner') . "</th>"; echo "<th>" . theme_image('reserved.gif', get_opendb_lang_var('reserved'), "borrowed_item") . "</th>"; echo "<th>" . theme_image('borrowed.gif', get_opendb_lang_var('borrowed'), "borrowed_item") . "</th>"; echo "</tr>"; $result = fetch_user_rs(PERM_ITEM_OWNER); if ($result) { $toggle = TRUE; // Totals. $sum_loaned = 0; $sum_reserved = 0; while ($user_r = db_fetch_assoc($result)) { $user_name = get_opendb_lang_var('user_name', array('fullname' => $user_r['fullname'], 'user_id' => $user_r['user_id'])); echo "<tr class=\"data\"><th>"; if (is_user_granted_permission(PERM_VIEW_USER_PROFILE)) { echo "<a href=\"user_profile.php?uid=" . $user_r['user_id'] . "\">" . $user_name . "</a>"; } else { echo $user_name; } echo "</th>"; $reserved_total = fetch_owner_reserved_item_cnt($user_r['user_id']); $sum_reserved += $reserved_total; echo "\n<td>"; if ($reserved_total > 0) { echo $reserved_total; } else { echo "-"; } echo "</td>"; $loan_total = fetch_owner_borrowed_item_cnt($user_r['user_id']); $sum_loaned += $loan_total; echo "\n<td>"; if ($loan_total > 0) { echo $loan_total; } else { echo "-"; } echo "</td>"; echo "</tr>"; } //while ($user_r = db_fetch_assoc($result)) db_free_result($result); echo "<tr class=\"data totals\"><th>" . get_opendb_lang_var('totals') . "</th>"; // sum loaned. if (get_opendb_config_var('borrow', 'enable') !== FALSE) { echo "<td>" . $sum_reserved . "</td>"; echo "<td>" . $sum_loaned . "</td>"; } echo "</tr>"; } echo "</table>"; } }
function build_item_ownership_chart_data() { $results = fetch_status_type_rs(); if ($results) { while ($status_type_r = db_fetch_assoc($results)) { $status_type_rs[] = $status_type_r; } db_free_result($results); } $results = fetch_user_rs(PERM_ITEM_OWNER); if ($results) { while ($user_r = db_fetch_assoc($results)) { $num_total = 0; if (is_not_empty_array($status_type_rs)) { reset($status_type_rs); while (list($key, $status_type_r) = each($status_type_rs)) { $status_total = fetch_owner_s_status_type_item_cnt($user_r['user_id'], $status_type_r['s_status_type']); $num_total += $status_total; } } // pie chart data if ($num_total > 0) { $data[] = array('display' => $user_r['fullname'], 'value' => $num_total); } } db_free_result($results); } return $data; }
} $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'])) { $attrTypeSelect .= "\n<option value=\"" . $item_attribute_type_r['s_attribute_type'] . "\">" . $item_attribute_type_r['s_attribute_type'] . " - " . $item_attribute_type_r['description']; } } $itemTypeBlock .= "</select>"; echo format_field(get_opendb_lang_var('s_attribute_type'), $attrTypeSelect); echo format_field(get_opendb_lang_var('s_attribute_type_lookup'), "\n<select name=\"lookup_attribute_val\" id=\"search-lookupattributeval\" onChange=\"if(this.options[this.options.selectedIndex].value.length>0){this.form['attribute_val'].disabled=true;}else{this.form['attribute_val'].disabled=false;}\">" . "\n<option value=\"\">" . get_opendb_lang_var('use_the_value_field') . " ---->" . "\n</select>"); echo format_field(get_opendb_lang_var('attribute_val'), "<input type=\"text\" class=\"text\" name=\"attribute_val\" id=\"search-attributeval\" size=\"50\" value=\"\">" . "\n<ul class=\"searchInputOptions\">" . "\n<li><input type=\"radio\" class=\"radio\" name=\"attr_match\" value=\"word\">" . get_opendb_lang_var('word_match') . "</li>" . "\n<li><input type=\"radio\" class=\"radio\" name=\"attr_match\" value=\"partial\" CHECKED>" . get_opendb_lang_var('partial_match') . "</li>" . "\n<li><input type=\"radio\" class=\"radio\" name=\"attr_match\" value=\"exact\">" . get_opendb_lang_var('exact_match') . "</li>" . "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"attr_case\" value=\"case_sensitive\">" . get_opendb_lang_var('case_sensitive') . "</li>" . "\n</ul>"); if (strlen($HTTP_VARS['not_owner_id']) > 0) { echo "\n<input type=\"hidden\" name=\"not_owner_id\" value=\"" . $HTTP_VARS['not_owner_id'] . "\">"; } echo format_field(get_opendb_lang_var('owner'), "\n<select name=\"owner_id\" id=\"search-owner\">" . "\n<option value=\"\">-------------- " . get_opendb_lang_var('all') . " --------------" . custom_select('owner_id', fetch_user_rs(PERM_ITEM_OWNER), '%fullname% (%user_id%)', 'NA', NULL, 'user_id') . "\n</select>"); $lookup_results = fetch_status_type_rs(TRUE); if ($lookup_results && db_num_rows($lookup_results) > 1) { echo format_field(get_opendb_lang_var('s_status_type'), checkbox_grid('s_status_type', $lookup_results, '%img%', 'VERTICAL', array())); // value } echo format_field(get_opendb_lang_var('status_comment'), "\n<input type=\"text\" class=\"text\" name=\"status_comment\" id=\"search-statuscomment\" size=\"50\">" . "\n<ul class=\"searchInputOptions\">" . "\n<li><input type=\"radio\" class=\"radio\" name=\"status_comment_match\" value=\"word\">" . get_opendb_lang_var('word_match') . "</li>" . "\n<li><input type=\"radio\" class=\"radio\" name=\"status_comment_match\" value=\"partial\" CHECKED>" . get_opendb_lang_var('partial_match') . "</li>" . "\n<li><input type=\"radio\" class=\"radio\" name=\"status_comment_match\" value=\"exact\">" . get_opendb_lang_var('exact_match') . "</li>" . "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"status_comment_case\" value=\"case_sensitive\">" . get_opendb_lang_var('case_sensitive') . "</li>" . "\n</ul>"); echo format_field(get_opendb_lang_var('updated'), "\n<select name=\"update_on_days\" id=\"search-updateondays\" onChange=\"if(this.options[this.options.selectedIndex].value.length>0){this.form['update_on'].disabled=true;}else{this.form['update_on'].disabled=false;}\">" . "\n<option value=\"\">" . get_opendb_lang_var('specify_datetime') . " ---->" . "\n<option value=\"1\">" . get_opendb_lang_var('one_day_ago') . "\n<option value=\"7\">" . get_opendb_lang_var('one_week_ago') . "\n<option value=\"28\">" . get_opendb_lang_var('one_month_ago') . "\n<option value=\"365\">" . get_opendb_lang_var('one_year_ago') . "\n</select>" . get_input_field("update_on", NULL, NULL, "datetime(" . get_opendb_config_var('search', 'datetime_mask') . ")", "N", NULL, FALSE)); echo format_field(get_opendb_lang_var('order_by'), "\n<select name=\"order_by\" id=\"search-orderby\">" . "\n<option value=\"title\" SELECTED>" . get_opendb_lang_var('title') . "\n<option value=\"owner_id\">" . get_opendb_lang_var('owner') . "\n<option value=\"category\">" . get_opendb_lang_var('category') . "\n<option value=\"s_item_type\">" . get_opendb_lang_var('item_type') . "\n<option value=\"s_status_type\">" . get_opendb_lang_var('s_status_type') . "\n<option value=\"update_on\">" . get_opendb_lang_var('update_date') . "\n</select>" . "\n<input type=\"radio\" class=\"radio\" name=\"sortorder\" value=\"ASC\" CHECKED>" . get_opendb_lang_var('asc') . "\n<input type=\"radio\" class=\"radio\" name=\"sortorder\" value=\"DESC\">" . get_opendb_lang_var('desc')); echo "</table>"; echo "\n<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('search') . "\">"; echo "</form>"; echo _theme_footer(); } else { opendb_not_authorised_page(PERM_VIEW_ADVANCED_SEARCH, $HTTP_VARS); }
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; }
$restrict_users_mode = INCLUDE_ACTIVATE_USER; } else { if ($HTTP_VARS['show_deactivated_users'] == 'Y') { $restrict_users_mode = INCLUDE_DEACTIVATED_USER; } else { $restrict_users_mode = EXCLUDE_DEACTIVATED_USER; } } $listingObject->startListing(); if (is_numeric($listingObject->getItemsPerPage())) { $listingObject->setTotalItems(fetch_user_cnt(NULL, INCLUDE_ROLE_PERMISSIONS, INCLUDE_CURRENT_USER, $restrict_users_mode)); if ($listingObject->getTotalItemCount() > 0) { $result = fetch_user_rs(NULL, INCLUDE_ROLE_PERMISSIONS, INCLUDE_CURRENT_USER, $restrict_users_mode, $listingObject->getCurrentOrderBy(), $listingObject->getCurrentSortOrder(), $listingObject->getStartIndex(), $listingObject->getItemsPerPage()); } } else { $result = fetch_user_rs(NULL, INCLUDE_ROLE_PERMISSIONS, INCLUDE_CURRENT_USER, $restrict_users_mode, $listingObject->getCurrentOrderBy(), $listingObject->getCurrentSortOrder()); //$include_deactivated_users } $listingObject->addHeaderColumn(NULL, 'user_id_rs', FALSE, 'checkbox'); $listingObject->addHeaderColumn(get_opendb_lang_var('user'), 'user_id'); $listingObject->addHeaderColumn(get_opendb_lang_var('action')); $listingObject->addHeaderColumn(get_opendb_lang_var('user_role'), 'role'); if ($HTTP_VARS['restrict_active_ind'] != 'X') { $listingObject->addHeaderColumn(get_opendb_lang_var('last_visit'), 'lastvisit'); } if ($result) { $v_listing_url_vars = $HTTP_VARS; $v_listing_url_vars['mode'] = NULL; unset($v_listing_url_vars['show_deactivated_users_cbox']); register_opendb_session_var('user_listing_url_vars', $v_listing_url_vars); while ($user_r = db_fetch_assoc($result)) {
/** * @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')); }