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; }
display_edit_form($status_type_r, $HTTP_VARS); echo "\n</table>"; echo format_help_block(array('img' => 'compulsory.gif', 'text' => get_opendb_lang_var('compulsory_field'), id => 'compulsory')); if (get_opendb_config_var('widgets', 'enable_javascript_validation') !== FALSE) { echo "\n<input type=\"button\" class=\"button\" value=\"{$save_button}\" onclick=\"if(!checkForm(this.form)){return false;}else{this.form.submit();}\">"; } else { echo "\n<input type=\"button\" class=\"button\" value=\"{$save_button}\" onclick=\"this.form.submit();\">"; } echo "\n</form>"; } else { if (strlen($HTTP_VARS['op']) == 0) { echo "<p>[<a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=new\">New Status Type</a>]</p>"; if (is_not_empty_array($errors)) { echo format_error_block($errors); } $results = fetch_status_type_rs(); if ($results) { echo "\n<form name=\"s_status_type\" action=\"{$PHP_SELF}\" method=\"POST\">"; echo "\n<input type=\"hidden\" name=\"op\" value=\"\">"; echo "\n<input type=\"hidden\" name=\"type\" value=\"" . $ADMIN_TYPE . "\">"; echo "\n<table>"; echo "<tr class=\"navbar\">" . "<th>Type</th>" . "<th>Description</th>" . "<th>Image</th>" . "<th>Default</th>" . "<th>Closed</th>" . "<th></th>" . "</tr>"; $row = 0; while ($status_type_r = db_fetch_assoc($results)) { display_s_status_type_row($status_type_r, $row++); } db_free_result($results); echo "</form>"; echo "</table>"; } else { echo "<p class=\"error\">No Status Types Installed</p>";
$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 { //no guests or borrowers allowed! opendb_not_authorised_page(array(PERM_USER_EXPORT, PERM_ADMIN_EXPORT)); } } else { // invalid login, so login instead.
function build_item_stats() { echo "<h3>" . get_opendb_lang_var('item_stats') . "</h3>"; echo "<table class=\"itemStats\">"; echo "<tr class=\"navbar\">"; echo "<th>" . get_opendb_lang_var('owner') . "</th>"; $results = fetch_status_type_rs(); if ($results) { while ($status_type_r = db_fetch_assoc($results)) { $status_type_r['total'] = 0; $status_type_rs[] = $status_type_r; } db_free_result($results); } if (is_not_empty_array($status_type_rs)) { reset($status_type_rs); while (list(, $status_type_r) = each($status_type_rs)) { echo "<th>" . theme_image($status_type_r['img'], $status_type_r['description'], "s_status_type") . "</th>"; } } echo "<th>" . get_opendb_lang_var('total') . "</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>"; $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']); $status_type_rs[$key]['total'] += $status_total; echo "\n<td>"; if ($status_total > 0) { echo "<a href=\"listings.php?owner_id=" . $user_r['user_id'] . "&s_status_type=" . $status_type_r['s_status_type'] . "&order_by=title&sortorder=ASC\">{$status_total}</a>"; } else { echo "-"; } echo "</td>"; $num_total += $status_total; } $sum_total += $num_total; echo "\n<td>" . $num_total . "</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>"; if (is_not_empty_array($status_type_rs)) { reset($status_type_rs); while (list(, $status_type_r) = each($status_type_rs)) { echo "<td>" . $status_type_r['total'] . "</td>"; } echo "<td>" . $sum_total . "</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; }
function get_whats_new_details($update_on, $user_id = NULL) { $whats_new_conf_r = get_opendb_config_var('welcome.whats_new'); if ($whats_new_conf_r['enable'] !== FALSE) { $whats_new_rs = NULL; // Get the list of valid status_types, which we can display in this whatsnew page. $results = fetch_status_type_rs(); if ($results) { if ($whats_new_conf_r['restrict_last_login'] !== TRUE) { $update_on = NULL; } $search_vars_r['update_on'] = $update_on; if ($whats_new_conf_r['exclude_current_user'] !== FALSE) { $search_vars_r['not_owner_id'] = $user_id; } $whats_new_r['heading'] = get_opendb_lang_var('item_stats'); while ($status_type_r = db_fetch_assoc($results)) { $search_vars_r['s_status_type'] = $status_type_r['s_status_type']; $status_items_updated = fetch_item_listing_cnt($search_vars_r); $status_title = get_opendb_lang_var('cnt_item(s)_added_updated', array('count' => $status_items_updated, 's_status_type_desc' => $status_type_r['description'])); if ($status_items_updated > 0) { $item_r['class'] = 'tick'; $item_r['content'] = '<a href="listings.php?' . (strlen($search_vars_r['not_owner_id']) > 0 ? 'not_owner_id=' . $search_vars_r['not_owner_id'] . '&' : '') . 's_status_type=' . $status_type_r['s_status_type'] . '&update_on=' . urlencode($update_on) . '">' . $status_title . '</a>'; } else { $item_r['class'] = 'cross'; $item_r['content'] = $status_title; } $whats_new_r['items'][] = $item_r; } db_free_result($results); if (is_array($whats_new_r)) { $whats_new_rs[] = $whats_new_r; } } if (get_opendb_config_var('borrow', 'enable') !== FALSE && $whats_new_conf_r['borrow_stats'] !== FALSE) { $whats_new_r['heading'] = get_opendb_lang_var('borrow_stats'); $whats_new_r['items'] = NULL; $returned_cnt = fetch_borrowed_item_status_atdate_cnt('C', $update_on); if ($returned_cnt > 0) { $item_r['class'] = 'tick'; } else { $item_r['class'] = 'cross'; } $item_r['content'] = get_opendb_lang_var('cnt_item(s)_returned', 'count', $returned_cnt); $whats_new_r['items'][] = $item_r; $borrowed_cnt = fetch_borrowed_item_status_atdate_cnt('B', $update_on); if ($borrowed_cnt > 0) { $item_r['class'] = 'tick'; } else { $item_r['class'] = 'cross'; } $item_r['content'] = get_opendb_lang_var('cnt_item(s)_borrowed', 'count', $borrowed_cnt); $whats_new_r['items'][] = $item_r; $reserved_cnt = fetch_borrowed_item_status_atdate_cnt('R', $update_on); if ($reserved_cnt > 0) { $item_r['class'] = 'tick'; } else { $item_r['class'] = 'cross'; } $item_r['content'] = get_opendb_lang_var('cnt_item(s)_reserved', 'count', $reserved_cnt); $whats_new_r['items'][] = $item_r; if (is_array($whats_new_r)) { $whats_new_rs[] = $whats_new_r; } } if (get_opendb_config_var('item_review', 'enable') !== FALSE && $whats_new_conf_r['review_stats'] !== FALSE) { $whats_new_r['heading'] = get_opendb_lang_var('review(s)'); $whats_new_r['items'] = NULL; $block = ''; $review_cnt = fetch_review_atdate_cnt($update_on); if ($review_cnt > 0) { $item_r['class'] = 'tick'; } else { $item_r['class'] = 'cross'; } $item_r['content'] = get_opendb_lang_var('cnt_review(s)', 'count', $review_cnt); $whats_new_r['items'][] = $item_r; if (is_array($whats_new_r)) { $whats_new_rs[] = $whats_new_r; } } return $whats_new_rs; } else { return NULL; } }