diff options
author | Philip Häusler <msquare@notrademark.de> | 2015-08-15 14:54:25 +0200 |
---|---|---|
committer | Philip Häusler <msquare@notrademark.de> | 2015-08-15 14:54:25 +0200 |
commit | cac86ef509de8543d473db421898b80ca3b8f8e3 (patch) | |
tree | 8c2506a25c882d93b768fcf33172ec6a637f3526 /includes | |
parent | bc84710e9dcb0f4b3f52402e9b75123ae1210bfd (diff) |
add planned date of departure
Diffstat (limited to 'includes')
-rw-r--r-- | includes/pages/admin_arrive.php | 51 | ||||
-rw-r--r-- | includes/pages/user_settings.php | 17 | ||||
-rw-r--r-- | includes/sys_menu.php | 3 |
3 files changed, 56 insertions, 15 deletions
diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php index 8fdcf12b..64cf785d 100644 --- a/includes/pages/admin_arrive.php +++ b/includes/pages/admin_arrive.php @@ -31,11 +31,12 @@ function admin_arrive() { } $users = sql_select("SELECT * FROM `User` ORDER BY `Nick`"); - $arrival_count_at_day = array(); + $arrival_count_at_day = []; + $departure_count_at_day = []; $table = ""; - $users_matched = array(); + $users_matched = []; if ($search == "") - $tokens = array(); + $tokens = []; else $tokens = explode(" ", $search); foreach ($users as $usr) { @@ -52,6 +53,10 @@ function admin_arrive() { } $usr['nick'] = User_Nick_render($usr); + if ($usr['planned_departure_date'] != null) + $usr['rendered_planned_departure_date'] = date('Y-m-d', $usr['planned_departure_date']); + else + $usr['rendered_planned_departure_date'] = '-'; $usr['rendered_planned_arrival_date'] = date('Y-m-d', $usr['planned_arrival_date']); $usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-"; $usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : ""; @@ -60,24 +65,37 @@ function admin_arrive() { $day = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : date('Y-m-d', $usr['planned_arrival_date']); if (! isset($arrival_count_at_day[$day])) $arrival_count_at_day[$day] = 0; + if (! isset($departure_count_at_day[$day])) + $departure_count_at_day[$day] = 0; $arrival_count_at_day[$day] ++; + if ($usr['planned_departure_date'] != null) { + $day = date('Y-m-d', $usr['planned_departure_date']); + if (! isset($arrival_count_at_day[$day])) + $arrival_count_at_day[$day] = 0; + if (! isset($departure_count_at_day[$day])) + $departure_count_at_day[$day] = 0; + $departure_count_at_day[$day] ++; + } + $users_matched[] = $usr; } - + ksort($arrival_count_at_day); + ksort($departure_count_at_day); - $arrival_count = array(); - $arrival_sums = array(); + $arrival_count = []; + $arrival_sums = []; $arrival_sum = 0; foreach ($arrival_count_at_day as $day => $count) { - $arrival_sum += $count; + $arrival_sum += $count - $departure_count_at_day[$day]; $arrival_sums[$day] = $arrival_sum; - $arrival_count[] = array( + $arrival_count[] = [ 'day' => $day, 'count' => $count, - 'sum' => $arrival_sum - ); + 'sum' => $arrival_sum, + 'departure' => isset($departure_count_at_day[$day]) ? $departure_count_at_day[$day] : 0 + ]; } return page_with_title(admin_arrive_title(), array( @@ -88,9 +106,10 @@ function admin_arrive() { )), table(array( 'nick' => _("Nickname"), - 'rendered_planned_arrival_date' => _("Planned date"), + 'rendered_planned_arrival_date' => _("Planned arrival"), 'arrived' => _("Arrived?"), 'rendered_arrival_date' => _("Arrival date"), + 'rendered_planned_departure_date' => _("Planned departure"), 'actions' => "" ), $users_matched), heading(_("Arrival statistics"), 2), @@ -103,13 +122,18 @@ function admin_arrive() { 'datasets' => array( array( 'label' => _("arrived"), - 'fillColor' => "#444", + 'fillColor' => "#090", 'data' => array_values($arrival_count_at_day) ), array( 'label' => _("arrived sum"), 'fillColor' => "#888", 'data' => array_values($arrival_sums) + ), + array( + 'label' => _("planned departure"), + 'fillColor' => "#900", + 'data' => array_values($departure_count_at_day) ) ) )) . '); @@ -118,7 +142,8 @@ function admin_arrive() { table(array( 'day' => _("Date"), 'count' => _("arrived"), - 'sum' => _("arrived sum") + 'sum' => _("arrived sum"), + 'departure' => _("planned departure") ), $arrival_count) )); } diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php index d210ed56..466d3c3e 100644 --- a/includes/pages/user_settings.php +++ b/includes/pages/user_settings.php @@ -25,6 +25,7 @@ function user_settings() { $selected_theme = $user['color']; $selected_language = $user['Sprache']; $planned_arrival_date = $user['planned_arrival_date']; + $planned_departure_date = $user['planned_departure_date']; if (isset($_REQUEST['submit'])) { $ok = true; @@ -63,7 +64,17 @@ function user_settings() { $msg .= error(_("Please enter your planned date of arrival."), true); } - // Trivia + if (isset($_REQUEST['planned_departure_date']) && $_REQUEST['planned_departure_date'] != '') { + if (DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_departure_date']))) { + $planned_departure_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_departure_date']))->getTimestamp(); + } else { + $ok = false; + $msg .= error(_("Please enter your planned date of departure."), true); + } + } else + $planned_departure_date = null; + + // Trivia if (isset($_REQUEST['lastname'])) $lastname = strip_request_item('lastname'); if (isset($_REQUEST['prename'])) @@ -94,7 +105,8 @@ function user_settings() { `jabber`='" . sql_escape($jabber) . "', `Size`='" . sql_escape($tshirt_size) . "', `Hometown`='" . sql_escape($hometown) . "', - `planned_arrival_date`='" . sql_escape($planned_arrival_date) . "' + `planned_arrival_date`='" . sql_escape($planned_arrival_date) . "', + `planned_departure_date`=" . sql_null($planned_departure_date) . " WHERE `UID`='" . sql_escape($user['UID']) . "'"); success(_("Settings saved.")); @@ -157,6 +169,7 @@ function user_settings() { form_text('lastname', _("Last name"), $lastname), form_text('prename', _("First name"), $prename), form_date('planned_arrival_date', _("Planned date of arrival") . ' ' . entry_required(), $planned_arrival_date, time()), + form_date('planned_departure_date', _("Planned date of departure"), $planned_departure_date, time()), form_text('age', _("Age"), $age), form_text('tel', _("Phone"), $tel), form_text('dect', _("DECT"), $dect), diff --git a/includes/sys_menu.php b/includes/sys_menu.php index 16577cbc..c7ecfb88 100644 --- a/includes/sys_menu.php +++ b/includes/sys_menu.php @@ -45,6 +45,9 @@ function header_toolbar() { if ($unconfirmed_hint != '') $hints[] = $unconfirmed_hint; + if (! isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) + $hints[] = info(_("Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities."), true); + if (User_is_freeloader($user)) { $hints[] = error(sprintf(_("You freeloaded at least %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again."), $max_freeloadable_shifts), true); $hint_class = 'danger'; |