diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php
index a62c3ecf8..80ccb6af6 100644
--- a/app/Http/Controllers/AuthController.php
+++ b/app/Http/Controllers/AuthController.php
@@ -7,7 +7,10 @@
use App\Repositories\UserRepository;
use Crypt;
use Exception;
+use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
+use Illuminate\Routing\Redirector;
+use Illuminate\View\View;
use Session;
class AuthController extends AppBaseController
@@ -27,7 +30,7 @@ public function __construct(AccountRepository $accountRepository, UserRepository
}
/**
- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
+ * @return RedirectResponse|Redirector|View
*/
public function verifyAccount()
{
@@ -84,7 +87,7 @@ public function verifyAccount()
*
* @throws Exception
*
- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ * @return RedirectResponse|Redirector
*/
public function setPassword(Request $request)
{
diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php
index 85ae27c61..4cd58a90d 100644
--- a/app/Http/Controllers/CommentController.php
+++ b/app/Http/Controllers/CommentController.php
@@ -5,6 +5,9 @@
use App\Models\Comment;
use App\Models\Task;
use App\Repositories\TaskRepository;
+use Auth;
+use Exception;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
@@ -22,7 +25,7 @@ public function __construct(TaskRepository $taskRepo)
* @param Task $task
* @param Request $request
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function addComment(Task $task, Request $request)
{
@@ -38,13 +41,13 @@ public function addComment(Task $task, Request $request)
* @param Task $task
* @param Comment $comment
*
- * @throws \Exception
+ * @throws Exception
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function deleteComment(Task $task, Comment $comment)
{
- if ($comment->task_id != $task->id || $comment->created_by != \Auth::user()->id) {
+ if ($comment->task_id != $task->id || $comment->created_by != Auth::user()->id) {
throw new UnprocessableEntityHttpException('Unable to delete comment.');
}
@@ -59,11 +62,11 @@ public function deleteComment(Task $task, Comment $comment)
* @param Comment $comment
* @param Request $request
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function editComment(Task $task, Comment $comment, Request $request)
{
- if ($comment->task_id != $task->id || $comment->created_by != \Auth::user()->id) {
+ if ($comment->task_id != $task->id || $comment->created_by != Auth::user()->id) {
throw new UnprocessableEntityHttpException('Unable to update comment.');
}
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 4077c8ae6..f26d68c4f 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -5,7 +5,9 @@
use App\Repositories\DashboardRepository;
use App\Repositories\UserRepository;
use Auth;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
+use Illuminate\Http\Response;
class HomeController extends AppBaseController
{
@@ -31,7 +33,7 @@ public function __construct(DashboardRepository $dashboardRepository, UserReposi
/**
* Show the application dashboard.
*
- * @return \Illuminate\Http\Response
+ * @return Response
*/
public function index()
{
@@ -43,7 +45,7 @@ public function index()
/**
* @param Request $request
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function workReport(Request $request)
{
@@ -58,7 +60,7 @@ public function workReport(Request $request)
/**
* @param Request $request
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function developerWorkReport(Request $request)
{
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index 58bc20877..a7223db8d 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -17,7 +17,10 @@
use DataTables;
use Exception;
use Flash;
+use Illuminate\Http\JsonResponse;
+use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
+use Illuminate\Routing\Redirector;
use Response;
class ReportController extends AppBaseController
@@ -177,7 +180,7 @@ public function update(Report $report, UpdateReportRequest $request)
*
* @throws Exception
*
- * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ * @return JsonResponse|RedirectResponse|Redirector
*/
public function destroy(Report $report)
{
diff --git a/app/Http/Controllers/RoleController.php b/app/Http/Controllers/RoleController.php
index 4cd68137f..f0934eca7 100644
--- a/app/Http/Controllers/RoleController.php
+++ b/app/Http/Controllers/RoleController.php
@@ -12,7 +12,10 @@
use DataTables;
use Exception;
use Flash;
+use Illuminate\Http\JsonResponse;
+use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
+use Illuminate\Routing\Redirector;
use Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -106,10 +109,10 @@ public function edit(Role $role)
}
/**
- * @param Role $role
- * @param Request $request
+ * @param Role $role
+ * @param UpdateRoleRequest $request
*
- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ * @return RedirectResponse|Redirector
*/
public function update(Role $role, UpdateRoleRequest $request)
{
@@ -131,7 +134,7 @@ public function update(Role $role, UpdateRoleRequest $request)
*
* @throws Exception
*
- * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ * @return JsonResponse|RedirectResponse|Redirector
*/
public function destroy(Role $role)
{
diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php
index 7c62eab5f..0a3af2a51 100644
--- a/app/Http/Controllers/TaskController.php
+++ b/app/Http/Controllers/TaskController.php
@@ -55,7 +55,7 @@ public function index(Request $request)
})->filterColumn('title', function ($query, $search) {
$query->where(function ($query) use ($search) {
$query->where('title', 'like', "%$search%")
- ->orWhereRaw("concat(ifnull(p.prefix,''),'-',ifnull(tasks.task_number,'')) LIKE ?",
+ ->orWhereRaw("concat(if null(p.prefix,''),'-',if null(tasks.task_number,'')) LIKE ?",
["%$search%"]);
});
})
@@ -88,7 +88,7 @@ public function store(CreateTaskRequest $request)
private function fill($input)
{
- $input['status'] = (isset($input['status']) && !empty($input['status'])) ? $input['status'] : 0;
+ $input['status'] = (isset($input['status']) && !empty($input['status'])) ? $input['status'] : Task::STATUS_ACTIVE;
$input['description'] = is_null($input['description']) ? '' : $input['description'];
return $input;
diff --git a/app/Http/Controllers/TimeEntryController.php b/app/Http/Controllers/TimeEntryController.php
index 8ed2c93c2..014edb755 100644
--- a/app/Http/Controllers/TimeEntryController.php
+++ b/app/Http/Controllers/TimeEntryController.php
@@ -10,9 +10,13 @@
use Auth;
use Carbon\Carbon;
use DataTables;
+use Exception;
+use Illuminate\Contracts\View\Factory;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Validation\UnauthorizedException;
+use Illuminate\View\View;
use Log;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -31,9 +35,9 @@ public function __construct(TimeEntryRepository $timeEntryRepo)
*
* @param Request $request
*
- * @throws \Exception
+ * @throws Exception
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return Factory|View
*/
public function index(Request $request)
{
@@ -53,7 +57,7 @@ public function index(Request $request)
*
* @param CreateTimeEntryRequest $request
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function store(CreateTimeEntryRequest $request)
{
@@ -70,7 +74,7 @@ public function store(CreateTimeEntryRequest $request)
*
* @param TimeEntry $timeEntry
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function edit(TimeEntry $timeEntry)
{
@@ -85,16 +89,19 @@ public function edit(TimeEntry $timeEntry)
* @param TimeEntry $timeEntry
* @param UpdateTimeEntryRequest $request
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function update(TimeEntry $timeEntry, UpdateTimeEntryRequest $request)
{
- $entry = TimeEntry::ofCurrentUser()->find($timeEntry->id);
- if (empty($entry)) {
+ $user = getLoggedInUser();
+ if (!$user->can('manage_projects')) {
+ $timeEntry = TimeEntry::ofCurrentUser()->find($timeEntry->id);
+ }
+ if (empty($timeEntry)) {
return $this->sendError('Time Entry not found.', Response::HTTP_NOT_FOUND);
}
$input = $this->validateInput($request->all(), $timeEntry->id);
- $existEntry = $entry->only([
+ $existEntry = $timeEntry->only([
'id',
'task_id',
'activity_type_id',
@@ -106,8 +113,8 @@ public function update(TimeEntry $timeEntry, UpdateTimeEntryRequest $request)
]);
$inputDiff = array_diff($existEntry, $input);
if (!empty($inputDiff)) {
- Log::info('Entry Id: '.$entry->id);
- Log::info('Task Id: '.$entry->task_id);
+ Log::info('Entry Id: '.$timeEntry->id);
+ Log::info('Task Id: '.$timeEntry->task_id);
Log::info('fields changed: ', $inputDiff);
Log::info('Entry updated by: '.Auth::user()->name);
}
@@ -119,9 +126,9 @@ public function update(TimeEntry $timeEntry, UpdateTimeEntryRequest $request)
/**
* @param TimeEntry $timeEntry
*
- * @throws \Exception
+ * @throws Exception
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function destroy(TimeEntry $timeEntry)
{
@@ -137,8 +144,9 @@ public function destroy(TimeEntry $timeEntry)
/**
* @param array $input
+ * @param null $id
*
- * @return array|\Illuminate\Http\JsonResponse
+ * @return array|JsonResponse
*/
public function validateInput($input, $id = null)
{
@@ -177,7 +185,7 @@ public function validateInput($input, $id = null)
}
/**
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function getUserLastTask()
{
@@ -190,7 +198,7 @@ public function getUserLastTask()
* @param int $projectId
* @param Request $request
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function getTasks($projectId, Request $request)
{
@@ -201,7 +209,9 @@ public function getTasks($projectId, Request $request)
}
/**
- * @return \Illuminate\Http\JsonResponse
+ * @param Request $request
+ *
+ * @return JsonResponse
*/
public function getStartTimer(Request $request)
{
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index c1395e02d..5eb110120 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -13,9 +13,12 @@
use App\Repositories\UserRepository;
use Crypt;
use DataTables;
+use Exception;
+use Illuminate\Contracts\View\Factory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
+use Illuminate\View\View;
class UserController extends AppBaseController
{
@@ -58,9 +61,9 @@ public function __construct(
*
* @param Request $request
*
- * @throws \Exception
+ * @throws Exception
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return Factory|View
*/
public function index(Request $request)
{
@@ -80,7 +83,7 @@ public function index(Request $request)
*
* @param CreateUserRequest $request
*
- * @throws \Exception
+ * @throws Exception
*
* @return JsonResponse
*/
@@ -134,7 +137,7 @@ public function edit(User $user)
* @param User $user
* @param UpdateUserRequest $request
*
- * @throws \Exception
+ * @throws Exception
*
* @return JsonResponse|RedirectResponse
*/
@@ -171,7 +174,7 @@ public function update(User $user, UpdateUserRequest $request)
*
* @param User $user
*
- * @throws \Exception
+ * @throws Exception
*
* @return JsonResponse
*/
@@ -187,7 +190,7 @@ public function destroy(User $user)
/**
* @param User $user
*
- * @throws \Exception
+ * @throws Exception
*
* @return JsonResponse
*/
diff --git a/app/Models/ActivityType.php b/app/Models/ActivityType.php
index 61eeca2c8..a2a7893a8 100644
--- a/app/Models/ActivityType.php
+++ b/app/Models/ActivityType.php
@@ -11,6 +11,7 @@
* @property int $id
* @property string $name
* @property int|null $created_by
+ * @property int $deleted_by
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\User|null $createdUser
@@ -31,7 +32,9 @@ class ActivityType extends Model
public $table = 'activity_types';
public $fillable = [
- 'name', 'created_by', 'deleted_by',
+ 'name',
+ 'created_by',
+ 'deleted_by',
];
/**
@@ -43,6 +46,7 @@ class ActivityType extends Model
'id' => 'integer',
'name' => 'string',
'created_by' => 'integer',
+ 'deleted_by' => 'integer',
];
const ACTIVITY_TYPES = [
diff --git a/app/Models/Client.php b/app/Models/Client.php
index 06b129831..4ffbb200c 100644
--- a/app/Models/Client.php
+++ b/app/Models/Client.php
@@ -12,6 +12,7 @@
* @property string $name
* @property string $email
* @property string $website
+ * @property int $deleted_by
* @property int|null $created_by
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
@@ -48,10 +49,11 @@ class Client extends Model
* @var array
*/
protected $casts = [
- 'id' => 'integer',
- 'name' => 'string',
- 'email' => 'string',
- 'website' => 'string',
+ 'id' => 'integer',
+ 'name' => 'string',
+ 'email' => 'string',
+ 'website' => 'string',
+ 'deleted_by' => 'integer',
];
/**
@@ -60,14 +62,14 @@ class Client extends Model
* @var array
*/
public static $rules = [
- 'name' => 'required|unique:clients,name',
- 'email' => 'nullable|email|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
- 'website' => 'nullable|regex:/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/',
+ 'name' => 'required|unique:clients,name',
+ 'email' => 'nullable|email|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
+ 'website' => 'nullable|regex:/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/',
];
public static $editRules = [
- 'email' => 'nullable|email|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
- 'website' => 'nullable|regex:/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/',
+ 'email' => 'nullable|email|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
+ 'website' => 'nullable|regex:/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/',
];
public static $messages = [
diff --git a/app/Models/Comment.php b/app/Models/Comment.php
index baa8ca497..f5210c0f3 100644
--- a/app/Models/Comment.php
+++ b/app/Models/Comment.php
@@ -65,6 +65,9 @@ public function task()
return $this->belongsTo(Task::class, 'task_id');
}
+ /**
+ * @return string
+ */
public function getUserAvatarAttribute()
{
return getUserImageInitial($this->created_by, $this->createdUser->name);
diff --git a/app/Models/Project.php b/app/Models/Project.php
index bf2ea001a..b6e062427 100644
--- a/app/Models/Project.php
+++ b/app/Models/Project.php
@@ -18,6 +18,7 @@
* @property-read \App\Models\Client|null $client
* @property-read \App\Models\User|null $createdUser
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\User[] $users
+ * @property int $deleted_by
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project newQuery()
@@ -64,6 +65,7 @@ class Project extends Model
'description' => 'string',
'client_id' => 'integer',
'created_by' => 'integer',
+ 'deleted_by' => 'integer',
];
/**
diff --git a/app/Models/Report.php b/app/Models/Report.php
index ab20d4ef4..a5d951c16 100644
--- a/app/Models/Report.php
+++ b/app/Models/Report.php
@@ -76,11 +76,17 @@ public function projects()
return $this->belongsToMany(Project::class, 'report_filters', 'report_id', 'param_id');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function user()
{
return $this->belongsTo(User::class, 'owner_id');
}
+ /**
+ * @return string
+ */
public function getFormattedDateAttribute()
{
$startDate = Carbon::parse($this->start_date);
diff --git a/app/Models/Tag.php b/app/Models/Tag.php
index 48421f835..8bd9d9d41 100644
--- a/app/Models/Tag.php
+++ b/app/Models/Tag.php
@@ -11,6 +11,7 @@
* @property int $id
* @property string $name
* @property int|null $created_by
+ * @property int $deleted_by
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\User|null $createdUser
diff --git a/app/Models/Task.php b/app/Models/Task.php
index 6aa469ac4..4e1567df5 100644
--- a/app/Models/Task.php
+++ b/app/Models/Task.php
@@ -54,6 +54,8 @@
*
* @property string|null $task_number
* @property string|null $priority
+ * @property int $totalDuration
+ * @property int $totalDurationMin
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Task wherePriority($value)
*
@@ -75,7 +77,9 @@ class Task extends Model
self::STATUS_ACTIVE => 'Pending',
self::STATUS_COMPLETED => 'Completed',
];
- const PRIORITY = ['highest' => 'HIGHEST', 'high' => 'HIGH', 'medium' => 'MEDIUM', 'low' => 'LOW', 'lowest' => 'LOWEST'];
+ const PRIORITY = [
+ 'highest' => 'HIGHEST', 'high' => 'HIGH', 'medium' => 'MEDIUM', 'low' => 'LOW', 'lowest' => 'LOWEST',
+ ];
const PATH = 'attachments';
public $table = 'tasks';
@@ -166,7 +170,7 @@ public static function boot()
{
parent::boot();
- static::deleting(function ($task) {
+ static::deleting(function (self $task) {
$task->timeEntries()->update(['deleted_by' => getLoggedInUserId()]);
$task->timeEntries()->delete();
});
diff --git a/app/Models/TaskAttachment.php b/app/Models/TaskAttachment.php
index bce6e05fa..27d319e4f 100644
--- a/app/Models/TaskAttachment.php
+++ b/app/Models/TaskAttachment.php
@@ -41,11 +41,17 @@ class TaskAttachment extends Model
'file',
];
+ /**
+ * @return string
+ */
public function getFilePathAttribute()
{
return Storage::path('attachments'.DIRECTORY_SEPARATOR.$this->file);
}
+ /**
+ * @return string
+ */
public function getFileUrlAttribute()
{
return $this->imageUrl(self::PATH.DIRECTORY_SEPARATOR.$this->file);
diff --git a/app/Models/User.php b/app/Models/User.php
index 24b5d7922..1ee92b9d8 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -24,6 +24,7 @@
* @property string|null $activation_code
* @property int|null $created_by
* @property string|null $remember_token
+ * @property int $deleted_by
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\User|null $createdUser
@@ -120,17 +121,17 @@ class User extends Authenticatable
* @var array
*/
public static $rules = [
- 'name' => 'required|unique:users,name',
- 'email' => 'required|email|unique:users,email|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
- 'phone' => 'nullable|numeric|digits:10',
- 'role_id' => 'required',
+ 'name' => 'required|unique:users,name',
+ 'email' => 'required|email|unique:users,email|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
+ 'phone' => 'nullable|numeric|digits:10',
+ 'role_id' => 'required',
];
public static $messages = [
- 'phone.digits' => 'The phone number must be 10 digits long.',
- 'email.regex' => 'Please enter valid email.',
- 'photo.mimes' => 'The profile image must be a file of type: jpeg, jpg, png.',
- 'role_id.required' => 'Please select user role.',
+ 'phone.digits' => 'The phone number must be 10 digits long.',
+ 'email.regex' => 'Please enter valid email.',
+ 'photo.mimes' => 'The profile image must be a file of type: jpeg, jpg, png.',
+ 'role_id.required' => 'Please select user role.',
];
public static $setPasswordRules = [
diff --git a/app/Queries/ActivityTypeDataTable.php b/app/Queries/ActivityTypeDataTable.php
index a8d0a46df..50a298d28 100644
--- a/app/Queries/ActivityTypeDataTable.php
+++ b/app/Queries/ActivityTypeDataTable.php
@@ -9,6 +9,11 @@
*/
class ActivityTypeDataTable
{
+ /**
+ * @param null $input
+ *
+ * @return ActivityType
+ */
public function get($input = null)
{
/** @var ActivityType $query */
diff --git a/app/Queries/RoleDataTable.php b/app/Queries/RoleDataTable.php
index 58a77a0e8..6e3742cdc 100644
--- a/app/Queries/RoleDataTable.php
+++ b/app/Queries/RoleDataTable.php
@@ -3,6 +3,7 @@
namespace App\Queries;
use App\Models\Role;
+use Illuminate\Database\Eloquent\Builder;
/**
* Class RoleDataTable.
@@ -10,7 +11,7 @@
class RoleDataTable
{
/**
- * @return \Illuminate\Database\Eloquent\Builder
+ * @return Builder
*/
public function get()
{
diff --git a/app/Queries/TaskDataTable.php b/app/Queries/TaskDataTable.php
index 08443b4de..068f6c7f8 100644
--- a/app/Queries/TaskDataTable.php
+++ b/app/Queries/TaskDataTable.php
@@ -14,7 +14,7 @@ class TaskDataTable
/**
* @param array $input
*
- * @return \Illuminate\Database\Eloquent\Builder
+ * @return Task
*/
public function get($input = [])
{
@@ -22,6 +22,7 @@ public function get($input = [])
$projectRepo = app(ProjectRepository::class);
$loginUserProjects = $projectRepo->getLoginUserAssignProjectsArr();
+ /** @var Task $query */
$query = Task::whereIn('project_id', array_keys($loginUserProjects))
->leftJoin('projects as p', 'p.id', '=', 'tasks.project_id')
->with(['project', 'taskAssignee', 'createdUser'])
diff --git a/app/Repositories/AccountRepository.php b/app/Repositories/AccountRepository.php
index 7b66b5e01..ac1d90c77 100644
--- a/app/Repositories/AccountRepository.php
+++ b/app/Repositories/AccountRepository.php
@@ -2,8 +2,8 @@
namespace App\Repositories;
-use App;
use Exception;
+use Illuminate\Mail\Message;
use Mail;
use URL;
@@ -23,11 +23,11 @@ public function sendConfirmEmail($username, $email, $activateCode)
try {
Mail::send('auth.emails.account_verification', ['data' => $data],
- function ($message) use ($email) {
+ function (Message $message) use ($email) {
$message->subject('Activate your account');
$message->to($email);
});
- } catch (\Exception $e) {
+ } catch (Exception $e) {
throw new Exception('Account created, but unable to send email');
}
}
diff --git a/app/Repositories/ActivityTypeRepository.php b/app/Repositories/ActivityTypeRepository.php
index 9dbae75b4..da6ed5bc2 100644
--- a/app/Repositories/ActivityTypeRepository.php
+++ b/app/Repositories/ActivityTypeRepository.php
@@ -3,6 +3,7 @@
namespace App\Repositories;
use App\Models\ActivityType;
+use Illuminate\Support\Collection;
/**
* Class ActivityTypeRepository.
@@ -39,7 +40,7 @@ public function model()
/**
* get activity types.
*
- * @return \Illuminate\Support\Collection
+ * @return Collection
*/
public function getActivityTypeList()
{
diff --git a/app/Repositories/ClientRepository.php b/app/Repositories/ClientRepository.php
index daf80dd19..1823baa93 100644
--- a/app/Repositories/ClientRepository.php
+++ b/app/Repositories/ClientRepository.php
@@ -6,6 +6,8 @@
use App\Models\Project;
use App\Models\Task;
use App\Models\TimeEntry;
+use Exception;
+use Illuminate\Support\Collection;
/**
* Class ClientRepository.
@@ -44,7 +46,7 @@ public function model()
/**
* get clients.
*
- * @return \Illuminate\Support\Collection
+ * @return Collection
*/
public function getClientList()
{
@@ -54,12 +56,13 @@ public function getClientList()
/**
* @param int $clientId
*
- * @throws \Exception
+ * @throws Exception
*
* @return bool|mixed|void|null
*/
public function delete($clientId)
{
+ /** @var Client $client */
$client = $this->find($clientId);
$projectIds = Project::where('client_id', '=', $client->id)->get()->pluck('id');
diff --git a/app/Repositories/PermissionRepository.php b/app/Repositories/PermissionRepository.php
index a71755318..67e3bebb5 100644
--- a/app/Repositories/PermissionRepository.php
+++ b/app/Repositories/PermissionRepository.php
@@ -3,6 +3,7 @@
namespace App\Repositories;
use App\Models\Permission;
+use Illuminate\Support\Collection;
/**
* Class PermissionRepository.
@@ -37,7 +38,7 @@ public function model()
}
/**
- * @return \Illuminate\Support\Collection
+ * @return Collection
*/
public function permissionList()
{
diff --git a/app/Repositories/ProjectRepository.php b/app/Repositories/ProjectRepository.php
index f55207124..ea99d3a77 100644
--- a/app/Repositories/ProjectRepository.php
+++ b/app/Repositories/ProjectRepository.php
@@ -6,6 +6,7 @@
use App\Models\Task;
use App\Models\TimeEntry;
use Auth;
+use Exception;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
@@ -94,12 +95,13 @@ public function getProjectsList($clientId = null)
/**
* @param int $id
*
- * @throws \Exception
+ * @throws Exception
*
* @return bool|mixed|void|null
*/
public function delete($id)
{
+ /** @var Project $project */
$project = $this->find($id);
$taskIds = Task::whereProjectId($project->id)->pluck('id')->toArray();
diff --git a/app/Repositories/TagRepository.php b/app/Repositories/TagRepository.php
index 7997cb1c9..7f239bfa4 100644
--- a/app/Repositories/TagRepository.php
+++ b/app/Repositories/TagRepository.php
@@ -61,6 +61,8 @@ public function store($input)
$input['created_by'] = getLoggedInUserId();
Tag::create($input);
+
+ return true;
}
/**
diff --git a/app/Repositories/TaskRepository.php b/app/Repositories/TaskRepository.php
index 821303be3..fbf34b7a2 100644
--- a/app/Repositories/TaskRepository.php
+++ b/app/Repositories/TaskRepository.php
@@ -269,16 +269,16 @@ public function attachTags($task, $tags)
*/
public function getTaskDetails($id, $input = [])
{
- if (isset($input['user_id']) && $input['user_id'] > 0) {
- $task = Task::with([
- 'timeEntries' => function (HasMany $query) use ($input) {
- $query->where('time_entries.user_id', '=', $input['user_id'])
- ->with('user');
- },
- ])->findOrFail($id);
- } else {
- $task = Task::with('timeEntries.user')->findOrFail($id);
- }
+ $task = Task::with(['timeEntries' => function (HasMany $query) use ($input) {
+ if (isset($input['user_id']) && $input['user_id'] > 0) {
+ $query->where('time_entries.user_id', '=', $input['user_id']);
+ }
+
+ if (!empty($input['start_time']) && !empty($input['end_time'])) {
+ $query->whereBetween('start_time', [$input['start_time'], $input['end_time']]);
+ }
+ $query->with('user');
+ }])->findOrFail($id);
$minutes = $task->timeEntries->pluck('duration')->sum();
$totalDuration = 0;
@@ -298,10 +298,14 @@ public function getTaskDetails($id, $input = [])
*/
public function myTasks($input = [])
{
+ $user = getLoggedInUser();
/** @var Builder|Task $query */
- $query = Task::whereHas('taskAssignee', function (Builder $query) {
- $query->where('user_id', getLoggedInUserId());
- })->whereNotIn('status', [Task::STATUS_COMPLETED]);
+ $query = Task::whereNotIn('status', [Task::STATUS_COMPLETED]);
+ if (!$user->can('manage_projects')) {
+ $query = $query->whereHas('taskAssignee', function (Builder $query) {
+ $query->where('user_id', getLoggedInUserId());
+ });
+ }
if (!empty($input['project_id'])) {
$query->ofProject($input['project_id']);
diff --git a/app/Repositories/TimeEntryRepository.php b/app/Repositories/TimeEntryRepository.php
index 33d8fdd12..c865f5136 100644
--- a/app/Repositories/TimeEntryRepository.php
+++ b/app/Repositories/TimeEntryRepository.php
@@ -98,12 +98,15 @@ public function myLastTask()
*/
public function getTasksByProject($projectId, $taskId = null)
{
+ $user = getLoggedInUser();
/** @var Builder $query */
$query = Task::ofProject($projectId)
- ->where('status', '=', Task::STATUS_ACTIVE)
- ->whereHas('taskAssignee', function (Builder $query) {
+ ->where('status', '=', Task::STATUS_ACTIVE);
+ if (!$user->can('manage_projects')) {
+ $query = $query->whereHas('taskAssignee', function (Builder $query) {
$query->where('user_id', getLoggedInUserId());
});
+ }
if (!empty($taskId)) {
$query->orWhere('id', $taskId);
@@ -139,7 +142,8 @@ public function updateTimeEntry($input, $id)
{
/** @var TimeEntry $timeEntry */
$timeEntry = $this->find($id);
- $timeEntryType = ($timeEntry->entry_type == TimeEntry::STOPWATCH) ? $this->checkTimeUpdated($timeEntry, $input) : $timeEntry->entry_type;
+ $timeEntryType = ($timeEntry->entry_type == TimeEntry::STOPWATCH) ? $this->checkTimeUpdated($timeEntry,
+ $input) : $timeEntry->entry_type;
$input['entry_type'] = $timeEntryType;
if ((isset($input['duration']) && !empty($input['duration'])) && (!isset($input['start_time']) || empty($input['start_time']) || !isset($input['end_time']) || empty($input['end_time']))) {
if ($timeEntry->duration != $input['duration']) {
diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php
index 8f9e474e9..600a19219 100644
--- a/app/Repositories/UserRepository.php
+++ b/app/Repositories/UserRepository.php
@@ -80,7 +80,7 @@ public function setUserPassword($input)
$user->set_password = true;
$user->save();
- \Auth::login($user);
+ Auth::login($user);
return true;
}
diff --git a/app/helpers.php b/app/helpers.php
index cd8a43dc0..238c6b77e 100644
--- a/app/helpers.php
+++ b/app/helpers.php
@@ -1,5 +1,7 @@
define(Task::class, function (Faker $faker) {
$project = factory(Project::class)->create();
- $dueDate = date('Y-m-d H:i:s', strtotime('+ 4hours'));
$dueDate = date('Y-m-d H:i:s', strtotime('+ 4hours'));
@@ -19,7 +18,7 @@
'description' => $faker->text,
'project_id' => $project->id,
'due_date' => $dueDate,
- 'status' => Task::STATUS_ALL,
+ 'status' => Task::STATUS_ACTIVE,
'task_number' => $faker->unique()->randomDigitNotNull,
];
});
diff --git a/database/migrations/2019_09_13_054205_update_task_status_field_value.php b/database/migrations/2019_09_13_054205_update_task_status_field_value.php
new file mode 100644
index 000000000..0cec073ad
--- /dev/null
+++ b/database/migrations/2019_09_13_054205_update_task_status_field_value.php
@@ -0,0 +1,30 @@
+integer('status')->default(0)->change();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('tasks', function ($table) {
+ $table->integer('status')->default(2)->change();
+ });
+ }
+}
diff --git a/resources/assets/js/custom.js b/resources/assets/js/custom.js
index c39c18dea..fe3103060 100644
--- a/resources/assets/js/custom.js
+++ b/resources/assets/js/custom.js
@@ -224,8 +224,42 @@ $(document).on('focus', '.select2-selection.select2-selection--single', function
$(function () {
$(".modal").on('shown.bs.modal', function () {
- setTimeout(function () {
- $(".modal").find('input:text, .select2-selection.select2-selection--single').first().focus();
- },150);
+ if($(this).find('.timeEntryAddForm').hasClass('timeEntryAddForm') || $(this).find('.editTimeEntryForm').hasClass('editTimeEntryForm')){
+ $(this).find('textarea').first().focus();
+ } else {
+ $(this).find('input:text').first().focus();
+ }
});
});
+
+window.roundToQuarterHourAll = function (minuts) {
+ var hours = Math.floor(minuts / 60);
+ var minutes = minuts % 60;
+ if (hours > 0) {
+ return pad(hours) + ":" + pad(minutes) + ' h';
+ } else {
+ return pad(hours) + ":" + pad(minutes) + ' m';
+ }
+};
+
+window.pad = function (d) {
+ return (d < 10) ? '0' + d : d;
+};
+
+window.nl2br = function (str, is_xhtml) {
+ if (typeof str === 'undefined' || str === null) {
+ return '';
+ }
+ var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
' : '
';
+ return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
+};
+
+$(document).on('click', '.collapse-icon', function () {
+ let isShow = $(this).parent().parent().hasClass('shown');
+ if (isShow) {
+ $(this).children().removeClass('fa-plus-circle').addClass("fa-minus-circle");
+ } else {
+ $(this).children().removeClass('fa-minus-circle').addClass("fa-plus-circle");
+ }
+});
+
diff --git a/resources/assets/js/dashboard/developers-daily-report.js b/resources/assets/js/dashboard/developers-daily-report.js
index a763e45cc..4380db1e6 100644
--- a/resources/assets/js/dashboard/developers-daily-report.js
+++ b/resources/assets/js/dashboard/developers-daily-report.js
@@ -84,7 +84,8 @@ window.prepareDeveloperWorkReport = function (result) {
labelString: 'Hours'
},
}]
- }
+ },
+ legend: { display: false }
}
});
};
diff --git a/resources/assets/js/profile/profile.js b/resources/assets/js/profile/profile.js
index a01fd1513..fc242ed3e 100644
--- a/resources/assets/js/profile/profile.js
+++ b/resources/assets/js/profile/profile.js
@@ -126,8 +126,12 @@ $(".changeType").click(function () {
let inputField = $(this).parent().siblings();
let oldType = inputField.attr('type');
if(oldType == 'password') {
+ $(this).children().addClass('icon-eye');
+ $(this).children().removeClass('icon-ban');
inputField.attr('type', 'text');
} else {
+ $(this).children().removeClass('icon-eye');
+ $(this).children().addClass('icon-ban');
inputField.attr('type', 'password');
}
});
diff --git a/resources/assets/js/task/task.js b/resources/assets/js/task/task.js
index 79bfafb4c..e9c9a7ac8 100644
--- a/resources/assets/js/task/task.js
+++ b/resources/assets/js/task/task.js
@@ -79,6 +79,8 @@ $(function () {
$('[data-toggle="tooltip"]').tooltip();
});
+let taskAssignees = [];
+
function getRandomColor() {
let num = Math.floor(Math.random() * 12) + 1;
let coloCodes = ['0095ff', '9594fe', 'da4342', '8e751c', 'ac1f87', 'c86069', '370e1c', 'ca4e7d', 'c02bd8', '289e05', '3aad14', '0D8ABC', '511852'];
@@ -239,11 +241,13 @@ $(document).on('click', '.edit-btn', function (event) {
var tagsIds = [];
var userIds = [];
+ taskAssignees = [];
$(task.tags).each(function (i, e) {
tagsIds.push(e.id);
});
$(task.task_assignee).each(function (i, e) {
userIds.push(e.id);
+ taskAssignees.push(e.id);
});
$("#editTagIds").val(tagsIds).trigger('change');
@@ -271,8 +275,6 @@ $(document).on('click', '.delete-btn', function (event) {
deleteItem(taskUrl + id, '#task_table', 'Task');
});
-
-
$('#addNewForm').submit(function (event) {
event.preventDefault();
let loadingButton = jQuery(this).find("#btnTaskSave");
@@ -374,15 +376,6 @@ $(function () {
}
});
-$(document).on('click', '.collapse-icon', function () {
- let isShow = $(this).parent().parent().hasClass('shown');
- if(isShow) {
- $(this).children().removeClass('fa-plus-circle').addClass("fa-minus-circle");
- } else {
- $(this).children().removeClass('fa-minus-circle').addClass("fa-plus-circle");
- }
-});
-
window.manageCollapseIcon = function (id) {
var isExpanded = $('#tdCollapse' + id).attr('aria-expanded');
if (isExpanded == 'true') {
@@ -470,6 +463,9 @@ $(document).on('change', '#projectId', function (event) {
$(document).on('change', '#editProjectId', function (event) {
let projectId = $(this).val();
loadProjectAssignees(projectId, 'editAssignee')
+ setTimeout(function () {
+ $("#editAssignee").val(taskAssignees).trigger('change');
+ }, 1500)
});
function loadProjectAssignees(projectId, selector) {
diff --git a/resources/assets/js/task/task_detail.js b/resources/assets/js/task/task_detail.js
index 967912d91..3df10706a 100644
--- a/resources/assets/js/task/task_detail.js
+++ b/resources/assets/js/task/task_detail.js
@@ -59,6 +59,8 @@ $(function () {
$('[data-toggle="tooltip"]').tooltip()
});
+let taskAssignees = [];
+
// open edit user model
$(document).on('click', '.edit-btn', function (event) {
let id = $(event.currentTarget).data('id');
@@ -80,11 +82,13 @@ $(document).on('click', '.edit-btn', function (event) {
$('#editStatus').val(task.status);
var tagsIds = [];
var userIds = [];
+ taskAssignees = [];
$(task.tags).each(function (i, e) {
tagsIds.push(e.id);
});
$(task.task_assignee).each(function (i, e) {
userIds.push(e.id);
+ taskAssignees.push(e.id);
});
$("#editTagIds").val(tagsIds).trigger('change');
@@ -110,6 +114,9 @@ $(document).on('click', '.edit-btn', function (event) {
$(document).on('change', '#editProjectId', function (event) {
let projectId = $(this).val();
loadProjectAssignees(projectId, 'editAssignee')
+ setTimeout(function () {
+ $("#editAssignee").val(taskAssignees).trigger('change');
+ }, 1500)
});
function loadProjectAssignees(projectId, selector) {
diff --git a/resources/assets/js/task/task_time_entry.js b/resources/assets/js/task/task_time_entry.js
index bfdbfafc9..280024ff0 100644
--- a/resources/assets/js/task/task_time_entry.js
+++ b/resources/assets/js/task/task_time_entry.js
@@ -1,12 +1,6 @@
$('#task_users').select2({ width: '100%', placeholder: "All", minimumResultsForSearch: -1 });
-function nl2br (str, is_xhtml) {
- if (typeof str === 'undefined' || str === null) {
- return '';
- }
- var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
' : '
';
- return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
-}
+let firstTime = true;
// open detail confirmation model
$(document).on('click', '.taskDetails', function (event) {
@@ -15,6 +9,7 @@ $(document).on('click', '.taskDetails', function (event) {
$('#no-record-info-msg').hide();
$('#taskDetailsTable').hide();
$('.time-entry-data').hide();
+ firstTime = true;
$.ajax({
url: taskUrl + id + '/' + 'users',
@@ -30,17 +25,6 @@ $(document).on('click', '.taskDetails', function (event) {
});
}
});
-
- $.ajax({
- url: taskDetailUrl + '/' + id,
- type: 'GET',
- success: function (result) {
- if (result.success) {
- let data = result.data;
- drawTaskDetailTable(data);
- }
- }
- });
});
$(document).on('change', '#task_users', function () {
@@ -52,15 +36,22 @@ $(document).on('change', '#task_users', function () {
userId = taskUserId[0];
}
let url = taskDetailUrl + '/' + taskId;
+ let startSymbol = '?';
if (userId !== 0) {
+ startSymbol = '&';
url = url + '?user_id=' + userId;
}
+ if (reportStartDate != '' && reportEndDate != '') {
+ url = url + startSymbol + 'start_time=' + reportStartDate + '&end_time=' + reportEndDate;
+ }
$.ajax({
url: url,
type: 'GET',
success: function (result) {
if (result.success) {
let data = result.data;
+ let url = taskUrl + data.project.prefix + '-' + data.task_number;
+ $("#task-heading").html("
User | Task | Activity | Start Time | End Time | -Duration (min) | +Duration | Type | -Created At | Action | +Created At |
---|