add arrival date feature
This commit is contained in:
parent
66c7e67a03
commit
8c518d4c34
|
@ -3,7 +3,7 @@
|
|||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Erstellungszeit: 14. Mai 2015 um 16:36
|
||||
-- Erstellungszeit: 12. Jul 2015 um 14:45
|
||||
-- Server Version: 5.6.12
|
||||
-- PHP-Version: 5.5.3
|
||||
|
||||
|
@ -418,19 +418,22 @@ CREATE TABLE IF NOT EXISTS `User` (
|
|||
`Hometown` varchar(255) NOT NULL DEFAULT '',
|
||||
`api_key` varchar(32) NOT NULL,
|
||||
`got_voucher` tinyint(1) NOT NULL,
|
||||
`arrival_date` int(11) DEFAULT NULL,
|
||||
`planned_arrival_date` int(11) NOT NULL,
|
||||
PRIMARY KEY (`UID`),
|
||||
UNIQUE KEY `Nick` (`Nick`),
|
||||
KEY `api_key` (`api_key`),
|
||||
KEY `password_recovery_token` (`password_recovery_token`),
|
||||
KEY `force_active` (`force_active`)
|
||||
KEY `force_active` (`force_active`),
|
||||
KEY `arrival_date` (`arrival_date`,`planned_arrival_date`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `User`
|
||||
--
|
||||
|
||||
INSERT INTO `User` (`UID`, `Nick`, `Name`, `Vorname`, `Alter`, `Telefon`, `DECT`, `Handy`, `email`, `email_shiftinfo`, `jabber`, `Size`, `Passwort`, `password_recovery_token`, `Gekommen`, `Aktiv`, `force_active`, `Tshirt`, `color`, `Sprache`, `Menu`, `lastLogIn`, `CreateDate`, `Art`, `kommentar`, `Hometown`, `api_key`, `got_voucher`) VALUES
|
||||
(1, 'admin', 'Gates', 'Bill', 42, '', '-', '', 'admin@example.com', 0, '', 'XL', '$6$rounds=5000$hjXbIhoRTH3vKiRa$Wl2P2iI5T9iRR.HHu/YFHswBW0WVn0yxCfCiX0Keco9OdIoDK6bIAADswP6KvMCJSwTGdV8PgA8g8Xfw5l8BD1', NULL, 1, 0, 0, 0, 2, 'de_DE.UTF-8', 'L', 1431613486, '0000-00-00 00:00:00', '', '', '', '038850abdd1feb264406be3ffa746235', 0);
|
||||
INSERT INTO `User` (`UID`, `Nick`, `Name`, `Vorname`, `Alter`, `Telefon`, `DECT`, `Handy`, `email`, `email_shiftinfo`, `jabber`, `Size`, `Passwort`, `password_recovery_token`, `Gekommen`, `Aktiv`, `force_active`, `Tshirt`, `color`, `Sprache`, `Menu`, `lastLogIn`, `CreateDate`, `Art`, `kommentar`, `Hometown`, `api_key`, `got_voucher`, `arrival_date`, `planned_arrival_date`) VALUES
|
||||
(1, 'admin', 'Gates', 'Bill', 42, '', '-', '', 'admin@example.com', 0, '', 'XL', '$6$rounds=5000$hjXbIhoRTH3vKiRa$Wl2P2iI5T9iRR.HHu/YFHswBW0WVn0yxCfCiX0Keco9OdIoDK6bIAADswP6KvMCJSwTGdV8PgA8g8Xfw5l8BD1', NULL, 1, 0, 0, 0, 2, 'de_DE.UTF-8', 'L', 1436705059, '0000-00-00 00:00:00', '', '', '', '038850abdd1feb264406be3ffa746235', 0, NULL, 0);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
|
||||
/* introduce user arrival date */
|
||||
ALTER TABLE `User` ADD `arrival_date` INT NULL ,
|
||||
ADD `planned_arrival_date` INT NOT NULL ,
|
||||
ADD INDEX ( `arrival_date` , `planned_arrival_date` ) ;
|
||||
|
||||
/* fix log */
|
||||
ALTER TABLE `LogEntries` CHANGE `nick` `nick` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ;
|
||||
|
||||
|
|
|
@ -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']) . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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)
|
||||
));
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>' : ''
|
||||
|
|
Loading…
Reference in New Issue