Skip to content

Commit 1c9555f

Browse files
committed
fix accept once task
1 parent d007cc7 commit 1c9555f

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

app/Http/Controllers/ControlController.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,28 +1705,29 @@ public function accept(Request $request)
17051705
$control->plan_date = request('plan_date');
17061706
$control->action_plan = request('action_plan');
17071707

1708-
// create a new control
1709-
$new_control = $control->replicate();
1710-
$new_control->status = 0;
1711-
$new_control->observations = null;
1712-
$new_control->realisation_date = null;
1713-
$new_control->note = null;
1714-
$new_control->score = null;
1715-
$new_control->plan_date = request('next_date');
1716-
1717-
// Save new control
1718-
$new_control->save();
1719-
1720-
// Clone measures
1721-
$new_control->measures()->sync($control->measures()->pluck('id')->toArray());
1722-
1723-
// Set owners
1724-
$new_control->users()->sync($control->users()->pluck('id')->toArray());
1725-
$new_control->groups()->sync($control->groups()->pluck('id')->toArray());
1726-
1727-
// make link
1728-
$control->next_id = $new_control->id;
1729-
1708+
// Check periodicity
1709+
if ($control->periodicity !== 0) {
1710+
// create a new control
1711+
$new_control = $control->replicate();
1712+
$new_control->status = 0;
1713+
$new_control->observations = null;
1714+
$new_control->realisation_date = null;
1715+
$new_control->note = null;
1716+
$new_control->score = null;
1717+
$new_control->plan_date = request('next_date');
1718+
// Save new control
1719+
$new_control->save();
1720+
1721+
// Clone measures
1722+
$new_control->measures()->sync($control->measures()->pluck('id')->toArray());
1723+
1724+
// Set owners
1725+
$new_control->users()->sync($control->users()->pluck('id')->toArray());
1726+
$new_control->groups()->sync($control->groups()->pluck('id')->toArray());
1727+
1728+
// make link
1729+
$control->next_id = $new_control->id;
1730+
}
17301731
// set status done
17311732
$control->status = 2;
17321733

0 commit comments

Comments
 (0)