|
|
@ -6,21 +6,21 @@
|
|
|
|
function user_worklog_delete_controller()
|
|
|
|
function user_worklog_delete_controller()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $user;
|
|
|
|
global $user;
|
|
|
|
|
|
|
|
|
|
|
|
$request = request();
|
|
|
|
$request = request();
|
|
|
|
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
|
|
|
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
|
|
|
if (empty($userWorkLog)) {
|
|
|
|
if (empty($userWorkLog)) {
|
|
|
|
redirect(user_link($user));
|
|
|
|
redirect(user_link($user));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$user_source = User($userWorkLog['user_id']);
|
|
|
|
$user_source = User($userWorkLog['user_id']);
|
|
|
|
|
|
|
|
|
|
|
|
if ($request->has('confirmed')) {
|
|
|
|
if ($request->has('confirmed')) {
|
|
|
|
UserWorkLog_delete($userWorkLog);
|
|
|
|
UserWorkLog_delete($userWorkLog);
|
|
|
|
|
|
|
|
|
|
|
|
success(_('Work log entry deleted.'));
|
|
|
|
success(_('Work log entry deleted.'));
|
|
|
|
redirect(user_link($user_source));
|
|
|
|
redirect(user_link($user_source));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|
UserWorkLog_delete_title(),
|
|
|
|
UserWorkLog_delete_title(),
|
|
|
|
UserWorkLog_delete_view($user_source, $userWorkLog)
|
|
|
|
UserWorkLog_delete_view($user_source, $userWorkLog)
|
|
|
@ -33,25 +33,25 @@ function user_worklog_delete_controller()
|
|
|
|
function user_worklog_edit_controller()
|
|
|
|
function user_worklog_edit_controller()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $user;
|
|
|
|
global $user;
|
|
|
|
|
|
|
|
|
|
|
|
$request = request();
|
|
|
|
$request = request();
|
|
|
|
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
|
|
|
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
|
|
|
if (empty($userWorkLog)) {
|
|
|
|
if (empty($userWorkLog)) {
|
|
|
|
redirect(user_link($user));
|
|
|
|
redirect(user_link($user));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$user_source = User($userWorkLog['user_id']);
|
|
|
|
$user_source = User($userWorkLog['user_id']);
|
|
|
|
|
|
|
|
|
|
|
|
if ($request->has('submit')) {
|
|
|
|
if ($request->has('submit')) {
|
|
|
|
list ($valid, $userWorkLog) = user_worklog_from_request($userWorkLog);
|
|
|
|
list ($valid, $userWorkLog) = user_worklog_from_request($userWorkLog);
|
|
|
|
|
|
|
|
|
|
|
|
if ($valid) {
|
|
|
|
if ($valid) {
|
|
|
|
UserWorkLog_update($userWorkLog);
|
|
|
|
UserWorkLog_update($userWorkLog);
|
|
|
|
|
|
|
|
|
|
|
|
success(_('Work log entry updated.'));
|
|
|
|
success(_('Work log entry updated.'));
|
|
|
|
redirect(user_link($user_source));
|
|
|
|
redirect(user_link($user_source));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|
UserWorkLog_edit_title(),
|
|
|
|
UserWorkLog_edit_title(),
|
|
|
|
UserWorkLog_edit_view($user_source, $userWorkLog)
|
|
|
|
UserWorkLog_edit_view($user_source, $userWorkLog)
|
|
|
@ -60,33 +60,33 @@ function user_worklog_edit_controller()
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
* @return [bool $valid, UserWorkLog $userWorkLog]
|
|
|
|
* @return [bool $valid, UserWorkLog $userWorkLog]
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function user_worklog_from_request($userWorkLog)
|
|
|
|
function user_worklog_from_request($userWorkLog)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$request = request();
|
|
|
|
$request = request();
|
|
|
|
|
|
|
|
|
|
|
|
$valid = true;
|
|
|
|
$valid = true;
|
|
|
|
|
|
|
|
|
|
|
|
$userWorkLog['work_timestamp'] = parse_date('Y-m-d H:i', $request->input('work_timestamp') . ' 00:00');
|
|
|
|
$userWorkLog['work_timestamp'] = parse_date('Y-m-d H:i', $request->input('work_timestamp') . ' 00:00');
|
|
|
|
if ($userWorkLog['work_timestamp'] == null) {
|
|
|
|
if (is_null($userWorkLog['work_timestamp'])) {
|
|
|
|
$valid = false;
|
|
|
|
$valid = false;
|
|
|
|
error(_('Please enter work date.'));
|
|
|
|
error(_('Please enter work date.'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$userWorkLog['work_hours'] = $request->input('work_hours');
|
|
|
|
$userWorkLog['work_hours'] = $request->input('work_hours');
|
|
|
|
if (! preg_match("/[0-9]+(\.[0-9]+)?/", $userWorkLog['work_hours'])) {
|
|
|
|
if (! preg_match("/[0-9]+(\.[0-9]+)?/", $userWorkLog['work_hours'])) {
|
|
|
|
$valid = false;
|
|
|
|
$valid = false;
|
|
|
|
error(_('Please enter work hours in format ##[.##].'));
|
|
|
|
error(_('Please enter work hours in format ##[.##].'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$userWorkLog['comment'] = $request->input('comment');
|
|
|
|
$userWorkLog['comment'] = $request->input('comment');
|
|
|
|
if (empty($userWorkLog['comment'])) {
|
|
|
|
if (empty($userWorkLog['comment'])) {
|
|
|
|
$valid = false;
|
|
|
|
$valid = false;
|
|
|
|
error(_('Please enter a comment.'));
|
|
|
|
error(_('Please enter a comment.'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|
$valid,
|
|
|
|
$valid,
|
|
|
|
$userWorkLog
|
|
|
|
$userWorkLog
|
|
|
@ -99,26 +99,26 @@ function user_worklog_from_request($userWorkLog)
|
|
|
|
function user_worklog_add_controller()
|
|
|
|
function user_worklog_add_controller()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $user;
|
|
|
|
global $user;
|
|
|
|
|
|
|
|
|
|
|
|
$request = request();
|
|
|
|
$request = request();
|
|
|
|
$user_source = User($request->input('user_id'));
|
|
|
|
$user_source = User($request->input('user_id'));
|
|
|
|
if (empty($user_source)) {
|
|
|
|
if (empty($user_source)) {
|
|
|
|
redirect(user_link($user));
|
|
|
|
redirect(user_link($user));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$userWorkLog = UserWorkLog_new($user_source);
|
|
|
|
$userWorkLog = UserWorkLog_new($user_source);
|
|
|
|
|
|
|
|
|
|
|
|
if ($request->has('submit')) {
|
|
|
|
if ($request->has('submit')) {
|
|
|
|
list ($valid, $userWorkLog) = user_worklog_from_request($userWorkLog);
|
|
|
|
list ($valid, $userWorkLog) = user_worklog_from_request($userWorkLog);
|
|
|
|
|
|
|
|
|
|
|
|
if ($valid) {
|
|
|
|
if ($valid) {
|
|
|
|
UserWorkLog_create($userWorkLog);
|
|
|
|
UserWorkLog_create($userWorkLog);
|
|
|
|
|
|
|
|
|
|
|
|
success(_('Work log entry created.'));
|
|
|
|
success(_('Work log entry created.'));
|
|
|
|
redirect(user_link($user_source));
|
|
|
|
redirect(user_link($user_source));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|
UserWorkLog_add_title(),
|
|
|
|
UserWorkLog_add_title(),
|
|
|
|
UserWorkLog_add_view($user_source, $userWorkLog)
|
|
|
|
UserWorkLog_add_view($user_source, $userWorkLog)
|
|
|
@ -128,7 +128,7 @@ function user_worklog_add_controller()
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Link to work log entry add for given user.
|
|
|
|
* Link to work log entry add for given user.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param User $user
|
|
|
|
* @param User $user
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function user_worklog_add_link($user)
|
|
|
|
function user_worklog_add_link($user)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -141,7 +141,7 @@ function user_worklog_add_link($user)
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Link to work log entry edit.
|
|
|
|
* Link to work log entry edit.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function user_worklog_edit_link($userWorkLog)
|
|
|
|
function user_worklog_edit_link($userWorkLog)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -154,8 +154,8 @@ function user_worklog_edit_link($userWorkLog)
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Link to work log entry delete.
|
|
|
|
* Link to work log entry delete.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
* @param array[] $parameters
|
|
|
|
* @param array[] $parameters
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function user_worklog_delete_link($userWorkLog, $parameters = [])
|
|
|
|
function user_worklog_delete_link($userWorkLog, $parameters = [])
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -171,17 +171,17 @@ function user_worklog_delete_link($userWorkLog, $parameters = [])
|
|
|
|
function user_worklogs_controller()
|
|
|
|
function user_worklogs_controller()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $user, $privileges;
|
|
|
|
global $user, $privileges;
|
|
|
|
|
|
|
|
|
|
|
|
if (! in_array('admin_user_worklog', $privileges)) {
|
|
|
|
if (! in_array('admin_user_worklog', $privileges)) {
|
|
|
|
redirect(user_link($user));
|
|
|
|
redirect(user_link($user));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$request = request();
|
|
|
|
$request = request();
|
|
|
|
$action = $request->input('action');
|
|
|
|
$action = $request->input('action');
|
|
|
|
if (! $request->has('action')) {
|
|
|
|
if (! $request->has('action')) {
|
|
|
|
redirect(user_link($user));
|
|
|
|
redirect(user_link($user));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch ($action) {
|
|
|
|
switch ($action) {
|
|
|
|
case 'add':
|
|
|
|
case 'add':
|
|
|
|
return user_worklog_add_controller();
|
|
|
|
return user_worklog_add_controller();
|
|
|
@ -191,5 +191,3 @@ function user_worklogs_controller()
|
|
|
|
return user_worklog_delete_controller();
|
|
|
|
return user_worklog_delete_controller();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|