arrival statistics
This commit is contained in:
parent
18644cac7a
commit
46f0636f2f
|
@ -31,6 +31,7 @@ function admin_arrive() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
|
$users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
|
||||||
|
$arrival_count_at_day = array();
|
||||||
$table = "";
|
$table = "";
|
||||||
$users_matched = array();
|
$users_matched = array();
|
||||||
if ($search == "")
|
if ($search == "")
|
||||||
|
@ -49,20 +50,36 @@ function admin_arrive() {
|
||||||
if (! $match)
|
if (! $match)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$table .= '<tr>';
|
|
||||||
$table .= '<td>' . User_Nick_render($usr) . '</td>';
|
|
||||||
$usr['nick'] = User_Nick_render($usr);
|
$usr['nick'] = User_Nick_render($usr);
|
||||||
$usr['planned_arrival_date'] = date('Y-m-d', $usr['planned_arrival_date']);
|
$usr['rendered_planned_arrival_date'] = date('Y-m-d', $usr['planned_arrival_date']);
|
||||||
$usr['arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-";
|
$usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-";
|
||||||
$usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
|
$usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
|
||||||
$usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("arrived") . '</a>';
|
$usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("arrived") . '</a>';
|
||||||
if ($usr['Gekommen'] == 1)
|
|
||||||
$table .= '<td>yes</td><td><a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">reset</a></td>';
|
$day = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : date('Y-m-d', $usr['planned_arrival_date']);
|
||||||
else
|
if (! isset($arrival_count_at_day[$day]))
|
||||||
$table .= '<td></td><td><a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">arrived</a></td>';
|
$arrival_count_at_day[$day] = 0;
|
||||||
$table .= '</tr>';
|
$arrival_count_at_day[$day] ++;
|
||||||
|
|
||||||
$users_matched[] = $usr;
|
$users_matched[] = $usr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ksort($arrival_count_at_day);
|
||||||
|
|
||||||
|
$arrival_count = array();
|
||||||
|
$arrival_sums = array();
|
||||||
|
$arrival_sum = 0;
|
||||||
|
foreach ($arrival_count_at_day as $day => $count) {
|
||||||
|
$arrival_sum += $count;
|
||||||
|
$arrival_sums[$day] = $arrival_sum;
|
||||||
|
$arrival_count[] = array(
|
||||||
|
'day' => $day,
|
||||||
|
'count' => $count,
|
||||||
|
'sum' => $arrival_sum
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return page_with_title(admin_arrive_title(), array(
|
return page_with_title(admin_arrive_title(), array(
|
||||||
msg(),
|
msg(),
|
||||||
form(array(
|
form(array(
|
||||||
|
@ -71,11 +88,38 @@ function admin_arrive() {
|
||||||
)),
|
)),
|
||||||
table(array(
|
table(array(
|
||||||
'nick' => _("Nickname"),
|
'nick' => _("Nickname"),
|
||||||
'planned_arrival_date' => _("Planned date"),
|
'rendered_planned_arrival_date' => _("Planned date"),
|
||||||
'arrived' => _("Arrived?"),
|
'arrived' => _("Arrived?"),
|
||||||
'arrival_date' => _("Arrival date"),
|
'rendered_arrival_date' => _("Arrival date"),
|
||||||
'actions' => ""
|
'actions' => ""
|
||||||
), $users_matched)
|
), $users_matched),
|
||||||
|
heading(_("Arrival statistics"), 2),
|
||||||
|
table(array(
|
||||||
|
'day' => _("Date"),
|
||||||
|
'count' => _("arrived"),
|
||||||
|
'sum' => _("arrived sum")
|
||||||
|
), $arrival_count),
|
||||||
|
'<canvas id="daily_arrives" style="width: 100%; height: 300px;"></canvas>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function(){
|
||||||
|
var ctx = $("#daily_arrives").get(0).getContext("2d");
|
||||||
|
new Chart(ctx).Bar(' . json_encode(array(
|
||||||
|
'labels' => array_keys($arrival_count_at_day),
|
||||||
|
'datasets' => array(
|
||||||
|
array(
|
||||||
|
'label' => _("arrived"),
|
||||||
|
'fillColor' => "#444",
|
||||||
|
'data' => array_values($arrival_count_at_day)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'label' => _("arrived sum"),
|
||||||
|
'fillColor' => "#888",
|
||||||
|
'data' => array_values($arrival_sums)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)) . ');
|
||||||
|
});
|
||||||
|
</script>'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -38,6 +38,7 @@
|
||||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
|
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
|
||||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
|
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
|
||||||
|
<script type="text/javascript" src="vendor/Chart.min.js"></script>
|
||||||
<script type="text/javascript" src="js/forms.js"></script>
|
<script type="text/javascript" src="js/forms.js"></script>
|
||||||
<script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
|
<script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
Loading…
Reference in New Issue