Skip to content

Commit 1e0ee49

Browse files
Botteletvitorfleiterm-yakovenkojvas28dependabot[bot]
authored
Release (#182)
* Collapse Plugin update The collapse was not working properly. * Update CanUserUpdate.php The message is regarding the client, not the user. * Fix unprivileged user can edit roles. (#167) * Fix unprivileged user can change permissions. * rename test * Fix test env (#170) * updating jquery version (#172) * Bump lodash from 4.17.15 to 4.17.19 (#162) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.15...4.17.19) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump elliptic from 6.5.1 to 6.5.3 (#169) Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.1 to 6.5.3. - [Release notes](https://github.com/indutny/elliptic/releases) - [Commits](indutny/elliptic@v6.5.1...v6.5.3) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * run test on PRS * remove verify controllers from routes * Bump symfony/http-foundation from 4.3.6 to 4.4.11 (#174) Bumps [symfony/http-foundation](https://github.com/symfony/http-foundation) from 4.3.6 to 4.4.11. - [Release notes](https://github.com/symfony/http-foundation/releases) - [Changelog](https://github.com/symfony/http-foundation/blob/master/CHANGELOG.md) - [Commits](symfony/http-foundation@v4.3.6...v4.4.11) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add new compliment from jqery 3.5.x and remove webhook * Added Extended JSON languages (#176) * Added Extended JSON languages Extended the JSON english and spanish languages (The original translations where from @jvas28 credit to him for starting with this). General Some strings are still missing like "HR" or "Hi". Spanish Have corrected some misspelled word from the @jvas28 PR also (Some may be still broken) * Fixed Messed up string and strengthened cohesion Fixed Messed up string and strengthened cohesion between verb tenses, capital letters and some more fixes * Fixed Messed up string and strengthened cohesion 2 * Reverted initial spaces Reverted initial spaces per line to 2 spaces * Unable to change user role (#175) * Unable to change user role * add test - updating user role * Can you please update the user controller test, to ensure you need to be "OWNER" before you can do an update * refactort test, and correct namespace on other test in the users folder * update namespace * add option to chose spanish country and translation * remove last legacy repository pattern * remove access provider from config * upgrade to Laravel 7 * Unable to prepare route [leads/updatefollowup/{external_id}] for serialization. Another route has already been assigned name [lead.followup]. (#181) * public js should not be added its auto-generated Co-authored-by: vitorfleite <[email protected]> Co-authored-by: Roman Yakovenko <[email protected]> Co-authored-by: Julio Vasconez Yulan <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Edgar Borrás Carcelén <[email protected]>
1 parent 6f495a6 commit 1e0ee49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4422
-4190
lines changed

.env.ci

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
APP_ENV=local
1+
APP_ENV=testing
22
APP_DEBUG=true
33
APP_KEY=base64:lEEqEYFZGEYHBd3y3RPofI9FozOKwBCEiTANoaH2eUs=
44

.github/workflows/phpunit.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Run tests
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
run-tests:

app/Enums/Country.php

+17
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,23 @@ public static function values(): array
216216

217217
]
218218
]),
219+
"ES" => new Country("ES", [
220+
"displayValue" => "Spain",
221+
"currencyCode" => "EUR",
222+
"language" => "Spanish",
223+
"phoneCode" => "+34",
224+
"format" => [
225+
"frontendDate" => "dd/mm/yyyy",
226+
"frontendTime" => "HH:i",
227+
"momentjsDayAndDateWithText" => "ddd D MMMM",
228+
"momentJsTime" => "HH:mm",
229+
"carbonDate" => "d/m/Y",
230+
"carbonTime" => "H:i",
231+
"carbonFullDateWithText" => "d, F Y H:i",
232+
"carbonDateWithText" => "d, F Y"
233+
234+
]
235+
]),
219236
"IN" => new Country("IN", [
220237
"displayValue" => "India",
221238
"currencyCode" => "INR",

app/Exceptions/Handler.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
namespace App\Exceptions;
33

4-
use Exception;
4+
use Throwable;
55
use Illuminate\Auth\AuthenticationException;
66
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
77

@@ -28,7 +28,7 @@ class Handler extends ExceptionHandler
2828
* @param \Exception $exception
2929
* @return void
3030
*/
31-
public function report(Exception $exception)
31+
public function report(Throwable $exception)
3232
{
3333
if (app()->bound('sentry') && $this->shouldReport($exception)) {
3434
app('sentry')->captureException($exception);
@@ -43,7 +43,7 @@ public function report(Exception $exception)
4343
* @param \Exception $exception
4444
* @return \Illuminate\Http\Response
4545
*/
46-
public function render($request, Exception $exception)
46+
public function render($request, Throwable $exception)
4747
{
4848
return parent::render($request, $exception);
4949
}

app/Http/Controllers/DepartmentsController.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010

1111
class DepartmentsController extends Controller
1212
{
13-
/**
14-
* DepartmentsController constructor.
15-
* @param DepartmentRepositoryContract $departments
16-
*/
13+
1714
public function __construct()
1815
{
1916
$this->middleware('user.is.admin', ['only' => ['create', 'destroy']]);

app/Http/Controllers/RolesController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class RolesController extends Controller
1717
*/
1818
public function __construct()
1919
{
20-
$this->middleware('user.is.admin', ['only' => ['index', 'create', 'destroy']]);
20+
$this->middleware('user.is.admin', ['only' => ['index', 'create', 'destroy', 'show', 'update']]);
2121
}
2222

2323
/**

app/Http/Controllers/StripeWebhooksController.php

-9
This file was deleted.

app/Http/Controllers/TasksController.php

+1-24
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Illuminate\Http\Request;
1818
use App\Http\Requests\Task\StoreTaskRequest;
1919
use Ramsey\Uuid\Uuid;
20-
use App\Repositories\Invoice\InvoiceRepositoryContract;
2120
use App\Models\Invoice;
2221
use App\Models\InvoiceLine;
2322
use App\Models\Project;
@@ -32,10 +31,8 @@ class TasksController extends Controller
3231

3332
protected $invoices;
3433

35-
public function __construct(InvoiceRepositoryContract $invoices)
34+
public function __construct()
3635
{
37-
$this->invoices = $invoices;
38-
3936
$this->middleware('filesystem.is.enabled', ['only' => ['upload']]);
4037
$this->middleware('task.create', ['only' => ['create']]);
4138
$this->middleware('task.update.status', ['only' => ['updateStatus']]);
@@ -348,26 +345,6 @@ public function updateDeadline(Request $request, $external_id)
348345
return redirect()->back();
349346
}
350347

351-
/**
352-
* @param $external_id
353-
* @param Request $request
354-
* @return mixed
355-
*/
356-
public function invoice($external_id, Request $request)
357-
{
358-
$task = $this->findByExternalId($external_id);
359-
$clientId = $task->client()->first()->id;
360-
$timeTaskId = $task->time()->get();
361-
$integrationCheck = Integration::first();
362-
363-
if ($integrationCheck) {
364-
$this->invoices->invoice($external_id, $request);
365-
}
366-
$this->invoices->create($clientId, $timeTaskId, $request->all());
367-
Session()->flash('flash_message', 'Invoice created');
368-
return redirect()->back();
369-
}
370-
371348
public function getInvoiceLines($external_id)
372349
{
373350
$task = $this->findByExternalId($external_id);

app/Http/Controllers/UsersController.php

+10-14
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,14 @@
1818
use App\Http\Requests\User\UpdateUserRequest;
1919
use App\Http\Requests\User\StoreUserRequest;
2020
use Ramsey\Uuid\Uuid;
21-
use App\Repositories\Task\TaskRepositoryContract;
22-
use App\Repositories\Lead\LeadRepositoryContract;
2321

2422
class UsersController extends Controller
2523
{
2624
protected $users;
2725
protected $roles;
2826

29-
public function __construct(
30-
TaskRepositoryContract $tasks,
31-
LeadRepositoryContract $leads
32-
) {
33-
$this->tasks = $tasks;
34-
$this->leads = $leads;
27+
public function __construct()
28+
{
3529
$this->middleware('user.create', ['only' => ['create']]);
3630
}
3731

@@ -221,15 +215,18 @@ public function store(StoreUserRequest $request)
221215
*/
222216
public function show($external_id)
223217
{
218+
/** @var User $user */
219+
$user = $this->findByExternalId($external_id);
224220
return view('users.show')
225-
->withUser($this->findByExternalId($external_id))
221+
->withUser($user)
226222
->withCompanyname(Setting::first()->company)
227-
->with('task_statistics', $this->tasks->totalOpenAndClosedTasks($external_id))
228-
->with('lead_statistics', $this->leads->totalOpenAndClosedLeads($external_id))
223+
->with('task_statistics', $user->totalOpenAndClosedTasks($external_id))
224+
->with('lead_statistics', $user->totalOpenAndClosedLeads($external_id))
229225
->with('lead_statuses', Status::typeOfLead()->get())
230226
->with('task_statuses', Status::typeOfTask()->get());
231227
}
232228

229+
233230
/**
234231
* @param $external_id
235232
* @return mixed
@@ -279,11 +276,10 @@ public function update($external_id, UpdateUserRequest $request)
279276

280277
$user->fill($input)->save();
281278
$role = $user->roles->first();
282-
if ($request->roles == (int)$role->id) {
283-
} elseif ($role->first()->name == Role::OWNER_ROLE && $owners->count() <= 1 && $role) {
279+
if ($role && $role->name == Role::OWNER_ROLE && $owners->count() <= 1) {
284280
Session()->flash('flash_message_warning', __('Not able to change owner role, please choose a new owner first'));
285281
} else {
286-
$user->roles()->sync([$role]);
282+
$user->roles()->sync([$request->roles]);
287283
}
288284
$user->department()->sync([$department]);
289285

app/Http/Middleware/Translation.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function handle($request, Closure $next)
1717
{
1818
if (auth()->user()) {
1919
$language = auth()->user()->language;
20-
if (!in_array($language, ["en", "dk"])) {
20+
if (!in_array($language, ["en", "dk", "es"])) {
2121
$language = "en";
2222
}
2323
app()->setLocale($language);

app/Http/Middleware/User/CanUserUpdate.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CanUserUpdate
1616
public function handle($request, Closure $next)
1717
{
1818
if (!auth()->user()->can('user-update')) {
19-
Session()->flash('flash_message_warning', __("You don't have permission to update a user"));
19+
Session()->flash('flash_message_warning', __("You don't have permission to update a client"));
2020
return redirect()->route('users.index');
2121
}
2222
return $next($request);

app/Models/Absence.php

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Models;
44

5+
use DateTimeInterface;
56
use Illuminate\Database\Eloquent\Model;
67

78
class Absence extends Model
@@ -25,6 +26,11 @@ public function getRouteKeyName()
2526
return 'external_id';
2627
}
2728

29+
protected function serializeDate(DateTimeInterface $date)
30+
{
31+
return $date->format('Y-m-d H:i:s');
32+
}
33+
2834
public function user()
2935
{
3036
return $this->belongsTo(User::class);

app/Models/Appointment.php

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Models;
44

5+
use DateTimeInterface;
56
use Illuminate\Database\Eloquent\Model;
67

78
class Appointment extends Model
@@ -27,6 +28,11 @@ public function getRouteKeyName()
2728
return 'external_id';
2829
}
2930

31+
protected function serializeDate(DateTimeInterface $date)
32+
{
33+
return $date->format('Y-m-d H:i:s');
34+
}
35+
3036
public function user()
3137
{
3238
return $this->belongsTo(User::class);

app/Models/User.php

+30-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
use Illuminate\Database\Eloquent\SoftDeletes;
1313
use Illuminate\Support\Facades\Storage;
1414
use Laravel\Cashier\Billable;
15-
16-
1715
use Carbon\Carbon;
1816

1917
class User extends Authenticatable
@@ -152,4 +150,34 @@ public function getAvatarattribute()
152150
$image_path = $this->image_path ? Storage::url($this->image_path) : '/images/default_avatar.jpg';
153151
return $image_path;
154152
}
153+
154+
public function totalOpenAndClosedLeads()
155+
{
156+
$groups = $this->leads()->with('status')->get()->sortBy('status.title')->groupBy('status.title');
157+
$keys = collect();
158+
$counts = collect();
159+
foreach ($groups as $groupKey => $group) {
160+
$keys->push($groupKey);
161+
$counts->push(count($group));
162+
}
163+
164+
return collect(['keys' => $keys, 'counts' => $counts]);
165+
}
166+
167+
/**
168+
* @param $external_id
169+
* @return mixed
170+
*/
171+
public function totalOpenAndClosedTasks()
172+
{
173+
$groups = $this->tasks()->with('status')->get()->sortBy('status.title')->groupBy('status.title');
174+
$keys = collect();
175+
$counts = collect();
176+
foreach ($groups as $groupKey => $group) {
177+
$keys->push($groupKey);
178+
$counts->push(count($group));
179+
}
180+
181+
return collect(['keys' => $keys, 'counts' => $counts]);
182+
}
155183
}

app/Providers/AccessServiceProvider.php

-43
This file was deleted.

app/Repositories/Department/DepartmentRepository.php

-43
This file was deleted.

0 commit comments

Comments
 (0)