mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
no message
This commit is contained in:
1 parent
2e8dd25ab8
commit
47a31f5c3a
2 files changed
+25
-1
No files matched your search
@@ -121,6 +121,23 @@ class MasterTaskController extends Controller
|
|||||||
'message' => 'Cannot update mastertask with is_finished 1.',
|
'message' => 'Cannot update mastertask with is_finished 1.',
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ak chcem ukoncit mastertask, ktory nema ani jeden subtask, ktory ma natrackovany cas, tak to nedovolim
|
||||||
|
if (isset($request->all()['data']['is_finished']) && $request->all()['data']['is_finished'] == 1) {
|
||||||
|
$atLeastOneSubtaskHasTimesheet = false;
|
||||||
|
|
||||||
|
foreach ($mastertask->subtasks as $subtask) {
|
||||||
|
if ($subtask->timesheets()->exists()) {
|
||||||
|
$atLeastOneSubtaskHasTimesheet = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$atLeastOneSubtaskHasTimesheet)
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Finishing mastertask is only possible where at least one subtask contains timesheet',
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
$mastertask->update($request->all()['data']);
|
$mastertask->update($request->all()['data']);
|
||||||
|
|
||||||
// upload attachmentu
|
// upload attachmentu
|
||||||
|
|||||||
@@ -162,13 +162,20 @@ class SubTaskController extends Controller
|
|||||||
{
|
{
|
||||||
$subtask = SubTask::find($id);
|
$subtask = SubTask::find($id);
|
||||||
|
|
||||||
// ak je Master task v stave ukončený, nedovolime update
|
// ak je sub task v stave ukončený, nedovolime update
|
||||||
if ($subtask->is_finished == 1) {
|
if ($subtask->is_finished == 1) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'message' => 'Cannot update subtask with is_finished 1.',
|
'message' => 'Cannot update subtask with is_finished 1.',
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ak chcem ukoncit subtask, ktory nema natrackovany cas, tak to nedovolim
|
||||||
|
if (isset($request->all()['data']['is_finished']) && $request->all()['data']['is_finished'] == 1 && $subtask->timesheets->count() == 0) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Cannot finish subtask with untracked time.',
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
$validator = Validator::make($request->all(), [
|
$validator = Validator::make($request->all(), [
|
||||||
'data.employee_id' => 'required',
|
'data.employee_id' => 'required',
|
||||||
'data.duration' => 'required',
|
'data.duration' => 'required',
|
||||||
|
|||||||
Reference in new issue
Block a user