Ejemplo n.º 1
0
/**
 * reports_quick_graph() - Show a quick graph of data.
 *
 * @param		string	Graph title
 * @param		int		First query resource ID
 * @param		int		Second query resource ID
 * @param		string	The bar colors
 */
function reports_quick_graph($title, $sql1, $sql2, $bar_colors)
{
    $result1 = db_query($sql1);
    $result2 = db_query($sql2);
    if ($result1 && $result2 && db_numrows($result2) > 0) {
        $assoc_open = util_result_columns_to_assoc($result1);
        $assoc_all = util_result_columns_to_assoc($result2);
        while (list($key, $val) = each($assoc_all)) {
            $titles[] = $key;
            $all[] = $val;
            if ($assoc_open[$key]) {
                $open[] = $assoc_open[$key];
            } else {
                $open[] = 0;
            }
        }
        /*	       	for ($i=0; $i<db_numrows($result1); $i++) {
        			echo "$titles[$i]=>$opened[$i]/$all[$i]<br />";
        		}
        */
        $scale = graph_calculate_scale(array($opened, $all), 400);
        $props["scale"] = $scale;
        $props["cellspacing"] = 5;
        $props = hv_graph_defaults($props);
        start_graph($props, $titles);
        horizontal_multisection_graph($titles, array($open, $all), $bar_colors, $props);
        end_graph();
        print '<p /><br />';
        print '<table cellspacing="0" border="0"><tr align="center"><td width="15%">' . _('Key') . ':</td><td width="5%">(</td><td width="35%" style="background-color:' . $bar_colors[0] . '">' . _('Open') . '</td>' . '<td width="5%">/</td><td width="35%" style="background-color:' . $bar_colors[1] . '">' . _('All') . ' </td><td width="5%">)</td></tr></table>';
        print '<p />';
        //      		GraphResult($result,$title);
    } else {
        echo "<h2>" . _('No data found to report') . "</h2>";
    }
}
Ejemplo n.º 2
0
/**
 * vote_show_user_rate_box() - Show user rating box
 *
 * @param		int		The user ID
 * @param		int		The user ID of the user who is rating $user_id
 */
function vote_show_user_rate_box($user_id, $by_id = 0)
{
    if ($by_id) {
        $res = db_query("\n\t\t\tSELECT rate_field,rating FROM user_ratings\n\t\t\tWHERE rated_by='{$by_id}'\n\t\t\tAND user_id='{$user_id}'\n\t\t");
        $prev_vote = util_result_columns_to_assoc($res);
        while (list($k, $v) = each($prev_vote)) {
            if ($v == 0) {
                $prev_vote[$k] = 0.1;
            }
        }
    }
    global $USER_RATING_VALUES, $USER_RATING_QUESTIONS, $USER_RATING_POPUP1, $USER_RATING_POPUP2, $USER_RATING_POPUP3, $USER_RATING_POPUP4, $USER_RATING_POPUP5;
    echo '
	<table border="0">
		<form action="/developer/rate.php" method="post">
		<input type="hidden" name="rated_user" value="' . $user_id . '" />';
    for ($i = 1; $i <= count($USER_RATING_QUESTIONS); $i++) {
        $popup = "USER_RATING_POPUP{$i}";
        if (!isset($prev_vote[$i])) {
            $prev_vote[$i] = '';
        }
        echo '<tr>
		<td colspan="2"><strong>' . $USER_RATING_QUESTIONS[$i] . ':</strong><br /> ' . html_build_select_box_from_arrays($USER_RATING_VALUES, ${$popup}, "Q_{$i}", $prev_vote[$i], true, 'Unrated') . '</td></tr>';
    }
    echo '
		<tr><td colspan="2"><input type="submit" name="submit" value="Rate User" /></td></tr>
		</table>
	</form>';
}