Skip to content

Commit 4b255e5

Browse files
committed
newspace2-push
1 parent 35ccd0e commit 4b255e5

9 files changed

Lines changed: 33 additions & 10 deletions

File tree

.github/workflows/php-build-and-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
id: meta
3636
uses: docker/metadata-action@v5
3737
with:
38-
images: ${{ secrets.REGISTRY_LOGIN_SERVER }}/newspace2_15
38+
images: ${{ secrets.REGISTRY_LOGIN_SERVER }}/newspace2_16
3939
flavor: |
4040
latest=false
4141
tags: |

app/Exports/CourceSheet.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class CourceSheet implements FromCollection, ShouldAutoSize, WithEvents, WithHea
2929

3030
public function __construct($month, $course)
3131
{
32-
set_time_limit(0);
3332
$this->month = $month;
3433
$this->course = $course;
3534
$this->shifts = Shift::whereNotNull('soldier_id')

app/Exports/ShiftsExport.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public function __construct($month)
2222

2323
public function sheets(): array
2424
{
25-
set_time_limit(0);
2625
$tasksTypes = Task::select('type', 'color')
2726
->get()
2827
->groupBy('type')

app/Exports/TaskTypeSheet.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected function convertColorToRBGFormat($color)
4545

4646
protected function getTasksNames()
4747
{
48-
$tasksNames = $this->shifts->groupBy(fn ($shift) => $shift->task->type)
48+
$tasksNames = $this->shifts->groupBy(fn ($shift) => $shift->task()->withTrashed()->first()->type)
4949
->map(fn ($shifts, $type) => $shifts->pluck('task.name')->unique())
5050
->flatten();
5151
$tasksNamesWithoutWeekendAndThurthday = $tasksNames->filter(fn ($name) => strpos($name, 'סופש') !== false || strpos($name, 'חמישי') !== false)->flatten();
@@ -137,7 +137,14 @@ public function collection()
137137
$row = [$date];
138138
foreach ($this->tasksNames as $name) {
139139
$shiftForDate = $shiftsByDate->get($date, collect())->first(function ($shift) use ($name) {
140-
return $shift->task && strpos($shift->task->name, $name) !== false;
140+
$taskName = $shift->task()->withTrashed()->first()->name;
141+
$baseName = str_replace([' סופש', ' חמישי'], '', $taskName);
142+
$columnBase = str_replace([' סופש', ' חמישי'], '', $name);
143+
if ($columnBase === $baseName) {
144+
return true;
145+
}
146+
147+
return false;
141148
});
142149
$row[] = ($shiftForDate && $shiftForDate->soldier) ? $shiftForDate->soldier->user->displayName : ' ';
143150
}

app/Filament/Widgets/CalendarWidget.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,11 @@ protected function getBasicActions()
344344
}),
345345
DeleteAction::make()
346346
->outlined()
347-
->label(__('Delete')),
347+
->label(__('Delete'))
348+
->action(function (Model $record) {
349+
$record->delete_cascade = true;
350+
$record->delete();
351+
}),
348352
];
349353
}
350354

app/Models/Shift.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ public function getTaskColorAttribute()
7575
return $this->task()->withTrashed()->first()->color;
7676
}
7777

78+
protected static function booted(): void
79+
{
80+
static::deleting(function (Shift $shift) {
81+
if ($shift->task->recurring['type'] == 'One time' && isset($shift->delete_cascade) && $shift->delete_cascade) {
82+
if ($shift->task) {
83+
$shift->task->delete();
84+
}
85+
}
86+
});
87+
}
88+
7889
public static function getSchema(): array
7990
{
8091
return [

app/Services/Helpers.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ protected static function getLastDayOfLastMonthShifts($soldierId, $lastDay)
146146

147147
public static function updateShiftTable($assignments)
148148
{
149-
set_time_limit(seconds: 0);
150149
if (empty($assignments)) {
151150
return;
152151
}

app/Services/PredictingProblems.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public function __construct($date)
2626

2727
public function getData()
2828
{
29-
set_time_limit(0);
3029
$this->maxNightsGreaterThanMaxShifts();
3130
$this->maxWeekendsGreaterThanCapacity();
3231
$this->weekendShiftsNotPointed();

app/Services/RecurringEvents.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct($month = null)
2121

2222
public function recurringTask(): void
2323
{
24-
Task::whereNotIn('recurring->type', ['Daily range', 'One time'])
24+
Task::whereNotIn('recurring->type', ['Daily range'])
2525
->get()
2626
->each(fn ($task) => $this->switchTasks($task));
2727
}
@@ -40,9 +40,14 @@ public function dailyRangeTask(Task $task)
4040
$this->createShifts($dates);
4141
}
4242

43-
protected function switchTasks(Task $task): void
43+
protected function switchTasks(Task $task)
4444
{
4545
$this->task = $task;
46+
if ($this->task->recurring['type'] == 'One time') {
47+
$this->oneTimeTask($task);
48+
49+
return;
50+
}
4651
$dates = match ($this->task->recurring['type']) {
4752
'Daily' => $this->dailyRecurring(),
4853
'Weekly' => $this->weeklyRecurring(),

0 commit comments

Comments
 (0)