Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #435 from InfyOmLabs/develop
Browse files Browse the repository at this point in the history
Release v0.1.7-beta
  • Loading branch information
mitulgolakiya authored Mar 15, 2020
2 parents e6cc568 + 763b683 commit 19bef40
Show file tree
Hide file tree
Showing 21 changed files with 136 additions and 72 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
*/
class HomeController extends AppBaseController
{
/** @var DashboardRepository $dashboardRepo */
/** @var DashboardRepository */
private $dashboardRepo;

/** @var UserRepository $userRepository */
/** @var UserRepository */
private $userRepository;

/**
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ public function __construct(
public function index(Request $request, ClientRepository $clientRepository)
{
if ($request->ajax()) {
return Datatables::of((new ProjectDataTable())->get(
$request->only('filter_client'))
return Datatables::of(
(new ProjectDataTable())->get(
$request->only('filter_client')
)
)->make(true);
}

Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@
*/
class ReportController extends AppBaseController
{
/** @var ReportRepository $reportRepository */
/** @var ReportRepository */
private $reportRepository;

/** @var UserRepository $userRepo */
/** @var UserRepository */
private $userRepo;

/** @var TagRepository $tagRepo */
/** @var TagRepository */
private $tagRepo;

/** @var ClientRepository $clientRepo */
/** @var ClientRepository */
private $clientRepo;

/** @var ProjectRepository $projectRepository */
/** @var ProjectRepository */
private $projectRepo;

public function __construct(
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ public function index(Request $request)
})->filterColumn('title', function (Builder $query, $search) {
$query->where(function (Builder $query) use ($search) {
$query->where('title', 'like', "%$search%")
->orWhereRaw("concat(ifnull(p.prefix,''),'-',ifnull(tasks.task_number,'')) LIKE ?",
["%$search%"]);
->orWhereRaw(
"concat(ifnull(p.prefix,''),'-',ifnull(tasks.task_number,'')) LIKE ?",
["%$search%"]
);
});
})
->make(true);
Expand Down
12 changes: 8 additions & 4 deletions app/Http/Controllers/TimeEntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ public function __construct(TimeEntryRepository $timeEntryRepo)
public function index(Request $request)
{
if ($request->ajax()) {
return Datatables::of((new TimeEntryDataTable())->get(
$request->only('filter_activity', 'filter_user', 'filter_project'))
return Datatables::of(
(new TimeEntryDataTable())->get(
$request->only('filter_activity', 'filter_user', 'filter_project')
)
)->editColumn('title', function (TimeEntry $timeEntry) {
return $timeEntry->task->prefix_task_number.' '.$timeEntry->task->title;
})->filterColumn('title', function (Builder $query, $search) {
$query->where(function (Builder $query) use ($search) {
$query->where('title', 'like', "%$search%")
->orWhereRaw("concat(ifnull(p.prefix,''),'-',ifnull(t.task_number,'')) LIKE ?",
["%$search%"]);
->orWhereRaw(
"concat(ifnull(p.prefix,''),'-',ifnull(t.task_number,'')) LIKE ?",
["%$search%"]
);
});
})->make(true);
}
Expand Down
12 changes: 8 additions & 4 deletions app/Queries/ProjectDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ public function get($input)
/** @var Project $query */
$query = Project::with(['client'])->select('projects.*');

$query->when(isset($input['filter_client']) && !empty($input['filter_client']),
$query->when(
isset($input['filter_client']) && !empty($input['filter_client']),
function (Builder $q) use ($input) {
$q->where('client_id', $input['filter_client']);
});
}
);

$query->when(isset($input['filter_team']) && !empty($input['filter_team']),
$query->when(
isset($input['filter_team']) && !empty($input['filter_team']),
function (Builder $q) use ($input) {
$q->where('team', $input['filter_team']);
});
}
);

return $query;
}
Expand Down
24 changes: 16 additions & 8 deletions app/Queries/TaskDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,35 @@ public function get($input = [])
->with(['project', 'taskAssignee', 'createdUser'])
->select(['tasks.*']);

$query->when(isset($input['filter_project']) && !empty($input['filter_project']),
$query->when(
isset($input['filter_project']) && !empty($input['filter_project']),
function (Builder $q) use ($input) {
$q->ofProject($input['filter_project']);
});
}
);

$query->when(isset($input['filter_status']) && $input['filter_status'] != Task::STATUS_ALL,
$query->when(
isset($input['filter_status']) && $input['filter_status'] != Task::STATUS_ALL,
function (Builder $q) use ($input) {
$q->where('status', $input['filter_status']);
});
}
);

$query->when(isset($input['due_date_filter']) && !empty($input['due_date_filter']),
$query->when(
isset($input['due_date_filter']) && !empty($input['due_date_filter']),
function (Builder $q) use ($input) {
$q->where('due_date', $input['due_date_filter']);
});
}
);

$query->when(isset($input['filter_user']),
$query->when(
isset($input['filter_user']),
function (Builder $q) use ($input) {
$q->whereHas('taskAssignee', function (Builder $q) use ($input) {
$q->where('user_id', $input['filter_user']);
});
});
}
);

return $query;
}
Expand Down
18 changes: 12 additions & 6 deletions app/Queries/TimeEntryDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ public function get($input)
/** @var User $user */
$user = Auth::user();

$query->when(isset($input['filter_activity']) && !empty($input['filter_activity']),
$query->when(
isset($input['filter_activity']) && !empty($input['filter_activity']),
function (Builder $q) use ($input) {
$q->where('activity_type_id', $input['filter_activity']);
});
$query->when(isset($input['filter_project']) && !empty($input['filter_project']),
}
);
$query->when(
isset($input['filter_project']) && !empty($input['filter_project']),
function (Builder $q) use ($input,$user) {
if ($user->can('manage_time_entries')) {
$taskIds = Task::whereProjectId($input['filter_project'])->get()->pluck('id')->toArray();
Expand All @@ -47,14 +50,17 @@ function (Builder $q) use ($input,$user) {
})->get()->pluck('id')->toArray();
$q->whereIn('task_id', $taskIds);
}
});
}
);
if (!$user->can('manage_time_entries')) {
return $query->OfCurrentUser();
}
$query->when(isset($input['filter_user']) && !empty($input['filter_user']),
$query->when(
isset($input['filter_user']) && !empty($input['filter_user']),
function (Builder $q) use ($input) {
$q->where('user_id', $input['filter_user']);
});
}
);

return $query;
}
Expand Down
7 changes: 5 additions & 2 deletions app/Repositories/AccountRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ public function sendConfirmEmail($username, $email, $activateCode)
$data['username'] = $username;

try {
Mail::send('auth.emails.account_verification', ['data' => $data],
Mail::send(
'auth.emails.account_verification',
['data' => $data],
function (Message $message) use ($email) {
$message->subject('Activate your account');
$message->to($email);
});
}
);
} catch (Exception $e) {
throw new Exception('Account created, but unable to send email');
}
Expand Down
4 changes: 3 additions & 1 deletion app/Repositories/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ public function profileUpdate($input)
try {
if (isset($input['photo']) && !empty($input['photo'])) {
$input['image_path'] = ImageTrait::makeImage(
$input['photo'], User::IMAGE_PATH, ['width' => 150, 'height' => 150]
$input['photo'],
User::IMAGE_PATH,
['width' => 150, 'height' => 150]
);

$imagePath = $user->image_path;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "infyomlabs/infy-tracker",
"type": "project",
"version": "0.1.6-beta",
"version": "0.1.7-beta",
"description": "Create Projects / Tasks, Track Time, Show Daily Reports",
"keywords": [
"time",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ public function up()
->references('id')
->on($tableNames['permissions']);

$table->primary(['permission_id', $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
$table->primary(
['permission_id', $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary'
);
});

Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) {
Expand All @@ -60,8 +62,10 @@ public function up()
->references('id')
->on($tableNames['roles']);

$table->primary(['role_id', $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
$table->primary(
['role_id', $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary'
);
});

Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion resources/views/tasks/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ class="flex-1">{{implode(", ",$task->taskAssignee->pluck('name')->toArray())}}</
@if(!empty($task->timeEntries->isNotEmpty()))
<div class="mb-3 d-flex task-detail__item">
<span class="task-detail__tag-heading">Time Tracking</span>
<span class="flex-1"><a class="task-detail__total-time" data-toggle="modal" data-target="#timeTrackingModal"><span data-toggle="tooltip" data-placement="bottom" title="Click for view all entry">{{roundToQuarterHour($task->timeEntries()->sum('duration'))}}</span></a></span>
<span class="flex-1">
<a class="task-detail__total-time" data-toggle="modal" data-target="#timeTrackingModal">
<span data-toggle="tooltip" data-placement="bottom"
title="Click for view all entry">
{{roundToQuarterHour($task->timeEntries()->sum('duration'))}}
</span>
</a>
</span>
</div>
@endif
</div>
Expand Down
6 changes: 5 additions & 1 deletion resources/views/tasks/time_tracking_modal.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="modal fade" id="timeTrackingModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Time Tracking</h5>
Expand All @@ -13,6 +13,8 @@
<tr>
<th scope="col">Note</th>
<th scope="col">Activity</th>
<th scope="col">Start Time</th>
<th scope="col">End Time</th>
<th scope="col" class="text-nowrap text-center">Tracked By</th>
<th scope="col" class="text-nowrap text-center">Time</th>
</tr>
Expand All @@ -22,6 +24,8 @@
<tr>
<td>{!! nl2br($entry->note) !!}</td>
<td>{{$entry->activityType->name}}</td>
<td>{{\Carbon\Carbon::parse($entry->start_time)->format('Y-m-d h:ma')}}</td>
<td>{{\Carbon\Carbon::parse($entry->end_time)->format('Y-m-d h:ma')}}</td>
<td class="text-nowrap text-center"><img src="{{$entry->user->img_avatar}}" width="40px"> </td>
<td class="text-nowrap text-center">{{roundToQuarterHour($entry->duration)}}</td>
</tr>
Expand Down
12 changes: 8 additions & 4 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@
->name('task.delete-attachment');
Route::get('tasks/{task}/get-attachments', 'TaskController@getAttachment')->name('task.attachments');
Route::post('tasks/{task}/comments', 'CommentController@addComment')->name('task.comments');
Route::post('tasks/{task}/comments/{comment}/update',
'CommentController@editComment')->name('task.update-comment');
Route::delete('tasks/{task}/comments/{comment}',
'CommentController@deleteComment')->name('task.delete-comment');
Route::post(
'tasks/{task}/comments/{comment}/update',
'CommentController@editComment'
)->name('task.update-comment');
Route::delete(
'tasks/{task}/comments/{comment}',
'CommentController@deleteComment'
)->name('task.delete-comment');
Route::get('task-details/{task}', 'TaskController@getTaskDetails')->name('task.get-details');
Route::get('tasks/{task}/comments-count', 'TaskController@getCommentsCount')->name('task.comments-count');
Route::get('tasks/{task}/users', 'TaskController@getTaskUsers')->name('task.users');
Expand Down
10 changes: 6 additions & 4 deletions tests/Controllers/ProjectControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ public function it_can_retrieve_project()

$response = $this->getJson(route('projects.edit', $project->id));

$this->assertSuccessDataResponse($response, [
'project' => $project->toArray(),
'users' => [$user->id],
],
$this->assertSuccessDataResponse(
$response,
[
'project' => $project->toArray(),
'users' => [$user->id],
],
'Project retrieved successfully.'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ public function test_add_time_entry_fails_when_start_time_is_greater_than_curren
$this->timeEntryInputs(['start_time' => $startTime, 'end_time' => $endTime])
);

$this->assertEquals('Start time must be less than or equal to current time.',
$response->exception->getMessage());
$this->assertEquals(
'Start time must be less than or equal to current time.',
$response->exception->getMessage()
);
}

/** @test */
Expand Down
Loading

0 comments on commit 19bef40

Please sign in to comment.