summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/model/User_model.php6
-rw-r--r--includes/pages/admin_arrive.php9
-rw-r--r--includes/pages/guest_login.php21
-rw-r--r--includes/sys_template.php11
-rw-r--r--includes/view/User_view.php4
5 files changed, 41 insertions, 10 deletions
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index 9df72748..ce760552 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -29,8 +29,10 @@ function User_update($user) {
`color`='" . sql_escape($user['color']) . "',
`Sprache`='" . sql_escape($user['Sprache']) . "',
`Hometown`='" . sql_escape($user['Hometown']) . "',
- `got_voucher`=" . sql_bool($user['got_voucher']) . "
- WHERE `UID`='" . sql_escape($user['UID']). "'");
+ `got_voucher`=" . sql_bool($user['got_voucher']) . ",
+ `arrival_date`='" . sql_escape($user['arrival_date']) . "'
+ `planned_arrival_date`='" . sql_escape($user['planned_arrival_date']) . "'
+ WHERE `UID`='" . sql_escape($user['UID']) . "'");
}
/**
diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php
index f51ef7ac..399cb335 100644
--- a/includes/pages/admin_arrive.php
+++ b/includes/pages/admin_arrive.php
@@ -1,4 +1,5 @@
<?php
+
function admin_arrive_title() {
return _("Arrived angels");
}
@@ -13,7 +14,7 @@ function admin_arrive() {
$id = $_REQUEST['reset'];
$user_source = User($id);
if ($user_source != null) {
- sql_query("UPDATE `User` SET `Gekommen`=0 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
+ sql_query("UPDATE `User` SET `Gekommen`=0, `arrival_date` = NULL WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User set to not arrived: " . User_Nick_render($user_source));
$msg = success(_("Reset done. Angel has not arrived."), true);
} else
@@ -22,7 +23,7 @@ function admin_arrive() {
$id = $_REQUEST['arrived'];
$user_source = User($id);
if ($user_source != null) {
- sql_query("UPDATE `User` SET `Gekommen`=1 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
+ sql_query("UPDATE `User` SET `Gekommen`=1, `arrival_date`='" . time() . "' WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("User set has arrived: " . User_Nick_render($user_source));
$msg = success(_("Angel has been marked as arrived."), true);
} else
@@ -51,6 +52,8 @@ function admin_arrive() {
$table .= '<tr>';
$table .= '<td>' . User_Nick_render($usr) . '</td>';
$usr['nick'] = User_Nick_render($usr);
+ $usr['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['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>';
if ($usr['Gekommen'] == 1)
@@ -68,7 +71,9 @@ function admin_arrive() {
)),
table(array(
'nick' => _("Nickname"),
+ 'planned_arrival_date' => _("Planned date"),
'arrived' => _("Arrived?"),
+ 'arrival_date' => _("Arrival date"),
'actions' => ""
), $users_matched)
));
diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php
index 741fd826..64a97d70 100644
--- a/includes/pages/guest_login.php
+++ b/includes/pages/guest_login.php
@@ -32,6 +32,7 @@ function guest_register() {
$tshirt_size = '';
$password_hash = "";
$selected_angel_types = array();
+ $planned_arrival_date = null;
$angel_types_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
$angel_types = array();
@@ -96,6 +97,13 @@ function guest_register() {
$msg .= error(sprintf(_("Your password is too short (please use at least %s characters)."), MIN_PASSWORD_LENGTH), true);
}
+ if (isset($_REQUEST['planned_arrival_date']) && DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))) {
+ $planned_arrival_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))->getTimestamp();
+ } else {
+ $ok = false;
+ $msg .= error(_("Please enter your planned date of arrival."), true);
+ }
+
$selected_angel_types = array();
foreach ($angel_types as $angel_type_id => $angel_type_name)
if (isset($_REQUEST['angel_types_' . $angel_type_id]))
@@ -138,7 +146,9 @@ function guest_register() {
`kommentar`='" . sql_escape($comment) . "',
`Hometown`='" . sql_escape($hometown) . "',
`CreateDate`=NOW(),
- `Sprache`='" . sql_escape($_SESSION["locale"]) . "'");
+ `Sprache`='" . sql_escape($_SESSION["locale"]) . "',
+ `arrival_date`=NULL,
+ `planned_arrival_date`='" . sql_escape($planned_arrival_date) . "'");
// Assign user-group and set password
$user_id = sql_id();
@@ -174,7 +184,14 @@ function guest_register() {
form_checkbox('email_shiftinfo', _("Please send me an email if my shifts change"), $email_shiftinfo)
))
)),
- $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size") . ' ' . entry_required(), $tshirt_sizes, $tshirt_size) : '',
+ div('row', array(
+ div('col-sm-6', array(
+ form_date('planned_arrival_date', _("Planned date of arrival") . ' ' . entry_required(), $planned_arrival_date, time())
+ )),
+ div('col-sm-6', array(
+ $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size") . ' ' . entry_required(), $tshirt_sizes, $tshirt_size) : ''
+ ))
+ )),
div('row', array(
div('col-sm-6', array(
form_password('password', _("Password") . ' ' . entry_required())
diff --git a/includes/sys_template.php b/includes/sys_template.php
index 452e3a82..1c631dbe 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -131,20 +131,25 @@ function form_spinner($name, $label, $value) {
* Label
* @param int $value
* Unix Timestamp
+ * @param int $min_date
+ * Earliest possible date
* @return HTML
*/
-function form_date($name, $label, $value) {
+function form_date($name, $label, $value, $start_date = '') {
$id = $name . '-date';
$value = is_numeric($value) ? date('Y-m-d', $value) : '';
+ $start_date = is_numeric($start_date) ? date('Y-m-d', $start_date) : '';
return form_element($label, '
<div class="input-group date" id="' . $id . '">
- <input type="text" class="form-control" value="' . $value . '"><span class="input-group-addon">' . glyph('th') . '</span>
+ <input type="text" name="' . $name . '" class="form-control" value="' . $value . '"><span class="input-group-addon">' . glyph('th') . '</span>
</div>
<script type="text/javascript">
$(function(){
$("#' . $id . '").datepicker({
language: "' . locale_short() . '",
- format: "yyyy-mm-dd"
+ todayBtn: "linked",
+ format: "yyyy-mm-dd",
+ startDate: "' . $start_date . '"
});
});
</script>
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 0add8e82..da52a913 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -171,7 +171,9 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
'<h4>' . _("User state") . '</h4>',
($admin_user_privilege && $freeloader) ? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _("Freeloader") . '</span><br />' : '',
$user_source['Gekommen'] ? User_shift_state_render($user_source) . '<br />' : '',
- ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _("Arrived") . '</span>' : '<span class="text-danger">' . _("Not arrived") . '</span>'),
+ $admin_user_privilege
+ ? ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . sprintf(_("Arrived at %s"), date('Y-m-d', $user_source['arrival_date'])) . '</span>' : '<span class="text-danger">' . sprintf(_("Not arrived (Planned: %s)"), date('Y-m-d', $user_source['planned_arrival_date'])) . '</span>')
+ : ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _("Arrived") . '</span>' : '<span class="text-danger">' . _("Not arrived") . '</span>'),
$admin_user_privilege ? ($user_source['got_voucher'] ? '<br /><span class="text-success">' . glyph('cutlery') . _("Got vouchers") . '</span>' : '<br /><span class="text-danger">' . _("Got no vouchers") . '</span>') : '',
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _("Active") . '</span>' : '',
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : ''