|
|
@@ -9,6 +9,8 @@ use App\Http\Requests\CreateScheduleFromReclamationRequest;
|
|
|
use App\Http\Requests\ExportScheduleRequest;
|
|
|
use App\Http\Requests\UpdateScheduleRequest;
|
|
|
use App\Jobs\ExportScheduleJob;
|
|
|
+use App\Jobs\NotifyManagerNewOrderJob;
|
|
|
+use App\Jobs\NotifyOrderInScheduleJob;
|
|
|
use App\Models\Dictionary\Area;
|
|
|
use App\Models\Dictionary\District;
|
|
|
use App\Models\Order;
|
|
|
@@ -99,10 +101,11 @@ class ScheduleController extends Controller
|
|
|
$mafsText .= $article . ' - ' . $count . "\r\n";
|
|
|
$mafsCount += $count;
|
|
|
}
|
|
|
-
|
|
|
+ $first = true;
|
|
|
for ($iDays = 1; $iDays < $order->install_days + 1; $iDays++) {
|
|
|
+
|
|
|
$instDate = date('Y-m-d', strtotime('+' . $iDays - 1 . ' days', strtotime($order->installation_date)));
|
|
|
- Schedule::query()
|
|
|
+ $schedule = Schedule::query()
|
|
|
->create([
|
|
|
'order_id' => $validated['order_id'],
|
|
|
'address_code' => $validated['order_id'],
|
|
|
@@ -118,6 +121,10 @@ class ScheduleController extends Controller
|
|
|
'brigadier_id' => $order->brigadier_id,
|
|
|
'comment' => $validated['comment'],
|
|
|
]);
|
|
|
+ if($first) {
|
|
|
+ $first = false;
|
|
|
+ NotifyOrderInScheduleJob::dispatch($schedule);
|
|
|
+ }
|
|
|
}
|
|
|
return redirect()->route('schedule.index');
|
|
|
|
|
|
@@ -160,9 +167,10 @@ class ScheduleController extends Controller
|
|
|
$mafsText .= $article . ' - ' . $count . "\r\n";
|
|
|
}
|
|
|
|
|
|
+ $first = true;
|
|
|
for ($iDays = 1; $iDays < $reclamation->work_days + 1; $iDays++) {
|
|
|
$instDate = date('Y-m-d', strtotime('+' . $iDays - 1 . ' days', strtotime($reclamation->start_work_date)));
|
|
|
- Schedule::query()
|
|
|
+ $schedule = Schedule::query()
|
|
|
->create([
|
|
|
'order_id' => $order->id,
|
|
|
'address_code' => 'РЕКЛ-' . $validated['reclamation_id'],
|
|
|
@@ -178,6 +186,10 @@ class ScheduleController extends Controller
|
|
|
'brigadier_id' => $reclamation->brigadier_id,
|
|
|
'comment' => $reclamation->guarantee,
|
|
|
]);
|
|
|
+ if($first) {
|
|
|
+ $first = false;
|
|
|
+ NotifyOrderInScheduleJob::dispatch($schedule);
|
|
|
+ }
|
|
|
}
|
|
|
return redirect()->route('schedule.index');
|
|
|
|
|
|
@@ -189,11 +201,11 @@ class ScheduleController extends Controller
|
|
|
$validated = $request->validated();
|
|
|
|
|
|
if(isset($validated['id'])) {
|
|
|
- Schedule::query()
|
|
|
+ $schedule = Schedule::query()
|
|
|
->where('id', $validated['id'])
|
|
|
->update($validated);
|
|
|
} else {
|
|
|
- Schedule::query()
|
|
|
+ $schedule = Schedule::query()
|
|
|
->create([
|
|
|
'address_code' => $validated['address_code'] ?? '-',
|
|
|
'installation_date' => $validated['installation_date'],
|
|
|
@@ -208,6 +220,7 @@ class ScheduleController extends Controller
|
|
|
'comment' => $validated['comment'],
|
|
|
]);
|
|
|
}
|
|
|
+ NotifyOrderInScheduleJob::dispatch($schedule);
|
|
|
|
|
|
return redirect()->back();
|
|
|
}
|