diff --git a/app/Http/Controllers/Credit/AccountController.php b/app/Http/Controllers/Credit/AccountController.php index 3f537f1..c5f8531 100644 --- a/app/Http/Controllers/Credit/AccountController.php +++ b/app/Http/Controllers/Credit/AccountController.php @@ -34,22 +34,16 @@ class AccountController extends Controller * * @param Builder $query * @return Builder + * @throws \ErrorException If account is missing in url. */ public function indexQuery(Builder $query): Builder { - /** @var \App\Models\User */ - $user = auth()->user(); - if (!$user->isAdmin()) { - // Show only users brand(s) accounts. - $brands = $user->sites()->with('brand')->get()->pluck('brand') - ->filter(function ($v) { - return !\is_null($v); - }); - return $query->whereHas('brand', function ($q) use ($brands) { - $q->whereIn('id', $brands->pluck('id')); - }); + /** @var \App\Models\Brand|null $brand */ + if (!($brand = request()->brand)) { + throw new \ErrorException('Cannot get brand'); } - return $query; + + return $query->where('brand_id', '=', $brand->id); } /** diff --git a/app/Http/Controllers/Credit/CreditLogController.php b/app/Http/Controllers/Credit/CreditLogController.php index d8bedee..a3d60e7 100644 --- a/app/Http/Controllers/Credit/CreditLogController.php +++ b/app/Http/Controllers/Credit/CreditLogController.php @@ -30,11 +30,20 @@ class CreditLogController extends Controller * * @param Builder $query * @return Builder + * @throws \ErrorException If account is missing in url. */ public function indexQuery(Builder $query): Builder { $query->orderBy('created_at', 'DESC'); - return $query; + + /** @var \App\Models\Credit\Account|null $account */ + if (!($account = request()->account)) { + throw new \ErrorException('Cannot get account'); + } + + return $query->whereHas('account', function ($q) use ($account) { + $q->whereIn('id', $account->pluck('id')); + }); } /** diff --git a/app/Http/Requests/Credit/CreateEstimateRequest.php b/app/Http/Requests/Credit/CreateEstimateRequest.php index 453c293..36e0cd3 100644 --- a/app/Http/Requests/Credit/CreateEstimateRequest.php +++ b/app/Http/Requests/Credit/CreateEstimateRequest.php @@ -34,8 +34,8 @@ class CreateEstimateRequest extends FormRequest return [ 'amount' => [ 'required', 'numeric', 'gt:0', function ($attribute, $value, $fail) { - if ((\floatval($value) * 10) % 5 !== 0) { - $fail("$attribute doit être un multiple de 5 (comptez par demi journées, soit 0.5)"); + if ((\floatval($value) * 1000) % 125 !== 0) { + $fail("$attribute doit être un multiple de 125 (soit 0.125)"); } } ], diff --git a/app/Models/Ticket.php b/app/Models/Ticket.php index d703d0f..a415e11 100644 --- a/app/Models/Ticket.php +++ b/app/Models/Ticket.php @@ -223,10 +223,9 @@ class Ticket extends Model */ public function getFullNameAttribute(): string { - return trans('Ticket n° :ticketId : :ticketSiteName - :ticketTypeLabel', [ + return trans('Ticket n° :ticketId : :ticketSiteName', [ 'ticketId' => $this->id, - 'ticketSiteName' => $this->site->name, - 'ticketTypeLabel' => $this->type->label + 'ticketSiteName' => $this->site->name ]); } diff --git a/composer.json b/composer.json index 971aab2..72b6120 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "fideloper/proxy": "^4.4", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", - "kwaadpepper/crud-policies": "^0.4.3", + "kwaadpepper/crud-policies": "^0.4.5", "kwaadpepper/enum": "^2.1", "kwaadpepper/exception-handler": "^0.0.9", "laravel-lang/lang": "~8.0", diff --git a/composer.lock b/composer.lock index 343543c..a57cf3c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b47b6f2c87a223409cd7086412a4463b", + "content-hash": "7231078f8b07ef175c85390302bb7298", "packages": [ { "name": "asm89/stack-cors", @@ -1505,16 +1505,16 @@ }, { "name": "kwaadpepper/crud-policies", - "version": "0.4.4", + "version": "0.4.5", "source": { "type": "git", "url": "https://github.com/Kwaadpepper/crud-policies.git", - "reference": "9fb72a59a3d9699a79e0c8862fd95491bd2b768a" + "reference": "c25ff96be976796a5447bd75d6ef16a0d7226f47" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Kwaadpepper/crud-policies/zipball/9fb72a59a3d9699a79e0c8862fd95491bd2b768a", - "reference": "9fb72a59a3d9699a79e0c8862fd95491bd2b768a", + "url": "https://api.github.com/repos/Kwaadpepper/crud-policies/zipball/c25ff96be976796a5447bd75d6ef16a0d7226f47", + "reference": "c25ff96be976796a5447bd75d6ef16a0d7226f47", "shasum": "" }, "require": { @@ -1565,9 +1565,9 @@ ], "support": { "issues": "https://github.com/Kwaadpepper/crud-policies/issues", - "source": "https://github.com/Kwaadpepper/crud-policies/tree/0.4.4" + "source": "https://github.com/Kwaadpepper/crud-policies/tree/0.4.5" }, - "time": "2022-06-10T08:04:44+00:00" + "time": "2022-06-15T15:42:22+00:00" }, { "name": "kwaadpepper/enum", diff --git a/database/migrations/2022_06_15_182442_change_amout_floating_point_on_credit_estimations.php b/database/migrations/2022_06_15_182442_change_amout_floating_point_on_credit_estimations.php new file mode 100644 index 0000000..e60f793 --- /dev/null +++ b/database/migrations/2022_06_15_182442_change_amout_floating_point_on_credit_estimations.php @@ -0,0 +1,33 @@ +unsignedFloat('amount', 8, 3) + ->comment('Estimation amount')->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('credit_estimations', function ($table) { + $table->unsignedFloat('amount') + ->comment('Estimation amount')->change(); + }); + } +} diff --git a/resources/sass/app.scss b/resources/sass/app.scss index 5353c52..bf3191e 100644 --- a/resources/sass/app.scss +++ b/resources/sass/app.scss @@ -18,6 +18,12 @@ body { background-color: $body-bg; } +#planning { + .sticky-top { + z-index: 1 !important; + } +} + // FOOTER body { position: relative; diff --git a/resources/views/accounts/index.blade.php b/resources/views/accounts/index.blade.php index b087455..6120874 100644 --- a/resources/views/accounts/index.blade.php +++ b/resources/views/accounts/index.blade.php @@ -30,6 +30,14 @@ +
| + {{ __('Ticket :id', ['id' => $model->estimation->first()->ticket->id]) }} + | + @endif + {{-- MODEL ACTIONS --}}
diff --git a/resources/views/estimations/create.blade.php b/resources/views/estimations/create.blade.php
index 912a009..74ed43d 100644
--- a/resources/views/estimations/create.blade.php
+++ b/resources/views/estimations/create.blade.php
@@ -9,6 +9,7 @@
{{ $ticket->full_name }}
@if ($ticket->is_internal)@endif
+ {{ $ticket->type->label }}
{{ __('Créer une estimation') }}
diff --git a/resources/views/estimations/form-inputs.blade.php b/resources/views/estimations/form-inputs.blade.php
index 3b9e639..b4c2961 100644
--- a/resources/views/estimations/form-inputs.blade.php
+++ b/resources/views/estimations/form-inputs.blade.php
@@ -1,6 +1,6 @@
-
+
@include('modules.input-error', [
'inputName' => 'amount', 'helperId' => 'amountHelper' , 'helper' => __('Le montant en homme jour estimé.')
])
diff --git a/resources/views/files/create.blade.php b/resources/views/files/create.blade.php
index 84a5594..2e33fe9 100644
--- a/resources/views/files/create.blade.php
+++ b/resources/views/files/create.blade.php
@@ -16,29 +16,27 @@
diff --git a/resources/views/markers/labelField.blade.php b/resources/views/markers/labelField.blade.php
index 58a9864..76d6804 100644
--- a/resources/views/markers/labelField.blade.php
+++ b/resources/views/markers/labelField.blade.php
@@ -1,7 +1,7 @@
- |
+
- |
-
+
+
@php
$dataVue = [
'name' => 'label',
@@ -13,4 +13,4 @@
id="marker-label-select"
class="sticky-top"
data-json='@json($dataVue)'>
- |
+
diff --git a/resources/views/ticket/edit.blade.php b/resources/views/ticket/edit.blade.php
index 189d501..64d4aed 100644
--- a/resources/views/ticket/edit.blade.php
+++ b/resources/views/ticket/edit.blade.php
@@ -7,7 +7,10 @@