]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5736 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 24 Feb 2023 10:29:48 +0000 (11:29 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 24 Feb 2023 10:29:48 +0000 (11:29 +0100)
app/Models/TeamLeave.php

index b76ec58635a98c9648fd9bb72eee45deded7b989..4c40342da742b66a2949fc4eea7a39265a10e6f0 100644 (file)
@@ -5,11 +5,13 @@ namespace App\Models;
 use App\Http\Controllers\Admin\Operations\TeamLeave\ICSOperation;
 use App\Models\Base\ToolboxHRModel;
 use App\Widgets;
+use Carbon\Carbon;
 use Cubist\Backpack\Magic\Fields\Checkbox;
 use Cubist\Backpack\Magic\Fields\Date;
 use Cubist\Backpack\Magic\Fields\Number;
 use Cubist\Backpack\Magic\Fields\SelectFromArray;
 use Cubist\Backpack\Magic\Fields\Text;
+
 // __('!! Équipe')
 class TeamLeave extends ToolboxHRModel
 {
@@ -60,11 +62,16 @@ class TeamLeave extends ToolboxHRModel
         $this->addField('recorded_month', Date::class, __('Comptabilisé'), ['column' => true, 'column_format' => 'YYYY-MM', 'can' => self::$_permissionBase . ':admin']);
         $this->addField('comment', Text::class, __('Commentaire'), ['column' => true, 'can' => self::$_permissionBase . ':admin']);
 
-        if(can(''))
-        $this->addFilter('compta', 'simple', 'À comptabiliser', function ($value, $crud) {
-            $crud->addClause('whereNull', 'recorded_month');
-            $crud->addClause('where', 'worker', '>=', 4);
-        });
+        if (can(''))
+            $this->addFilter('compta', 'simple', 'À comptabiliser', function ($value, $crud) {
+                $startOfNextMonth = Carbon::now();
+                $startOfNextMonth->day = 1;
+                $startOfNextMonth->month++;
+
+                $crud->addClause('whereNull', 'recorded_month');
+                $crud->addClause('where', 'worker', '>=', 4);
+                $crud->addClause('where', 'start_day', '<=', $startOfNextMonth);
+            });
     }