diff --git a/app/Console/Commands/SendProductionReport.php b/app/Console/Commands/SendProductionReport.php index 78860d40..ec1b839b 100644 --- a/app/Console/Commands/SendProductionReport.php +++ b/app/Console/Commands/SendProductionReport.php @@ -6,6 +6,7 @@ use App\Mail\ProductionMail; use App\Models\Item; use App\Models\Line; use App\Models\Plant; +use App\Models\ProductionCalendar; use App\Models\ProductionPlan; use App\Models\ProductionQuantity; use Illuminate\Console\Command; @@ -260,6 +261,17 @@ class SendProductionReport extends Command // $capacityQuan = $totalHourlyQuantity * 22.5; + $leaveDates = ProductionCalendar::where('plant_id', $plant->id) + ->whereMonth('created_at', $month) + ->whereYear('created_at', $year) + ->value('leave_dates'); + + $leaveDates = $leaveDates ? array_map('trim', explode(',', $leaveDates)) : []; + + if (in_array($startDate->format('Y-m-d'), $leaveDates)) { + $totalTargetQuantity = 0; + } + if (strtolower($line->type) == 'fg line') { $productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)