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; }