Skip to content

Commit

Permalink
Merge pull request #138 from eduayme/develop
Browse files Browse the repository at this point in the history
Update version 1.2.2
  • Loading branch information
eduayme authored Sep 27, 2020
2 parents e1c9fd6 + 3e355e4 commit 9878345
Show file tree
Hide file tree
Showing 51 changed files with 3,032 additions and 467 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ DB_HOST = 127.0.0.1
DB_PORT = 3306
DB_DATABASE = aplicatiu_bombers
DB_USERNAME = root
DB_PASSWORD =
DB_PASSWORD = root

BROADCAST_DRIVER = log
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ActionPlanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function create($id)
/* If exists previous Action Plan version */
if ($v > 0) {
$previous_ap = ActionPlan::where('search_id', $id)->where('version', $v)->first();
$previous_ap_tasks = ToDoTaskAP::where('action_plan_id', $previous_ap->id)->get();
$previous_ap_tasks = ToDoTaskAP::where('action_plan_id', $previous_ap->id)->orderBy('id', 'asc')->get();

foreach ($previous_ap_tasks as $task) {
$to_do_task = new ToDoTaskAP([
Expand Down
25 changes: 19 additions & 6 deletions app/Http/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Incident;
use App\LostPerson;
use App\Search;
use App\Task;
use Auth;
use Illuminate\Http\Request;
use Validator;
Expand Down Expand Up @@ -100,12 +101,12 @@ public function store(Request $request)
'user_finalization_id' => $request->get('user_finalization_id'),

// person alerts
'is_lost_person' => $request->get('is_lost_person'),
'is_contact_person' => $request->get('is_contact_person'),
'name_person_alerts' => $request->get('name_person_alerts'),
'affinity_person_alerts' => $request->get('affinity_person_alerts'),
'phone_number_person_alerts' => $request->get('phone_number_person_alerts'),
'address_person_alerts' => $request->get('address_person_alerts'),
'is_lost_person' => $request->get('is_lost_person'),
'is_contact_person' => $request->get('is_contact_person'),
'name_person_alerts' => $request->get('name_person_alerts'),
'affinity_person_alerts' => $request->get('affinity_person_alerts'),
'phone_number_person_alerts' => $request->get('phone_number_person_alerts'),
'address_person_alerts' => $request->get('address_person_alerts'),

// incident
'municipality_last_place_seen' => $request->get('municipality_last_place_seen'),
Expand Down Expand Up @@ -165,6 +166,18 @@ public function show($id)
$search = Search::find($id);
$action_plans = ActionPlan::where('search_id', $id)->get();
$incidents = Incident::where('search_id', $id)->get();
$tasks = Task::where('search_id', $id)->get();
$taskGroups = $tasks->pluck('group')->filter()->unique()->sort();
$taskTypes = $tasks->pluck('type')->filter()->unique();

return view('searches.view', compact(
'search',
'action_plans',
'incidents',
'tasks',
'taskGroups',
'taskTypes'
));

return view('searches.view', compact('search', 'action_plans', 'incidents'));
}
Expand Down
105 changes: 105 additions & 0 deletions app/Http/Controllers/TaskController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php

namespace App\Http\Controllers;

use App\Task;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;

class TaskController extends Controller
{
public function create($search_id)
{
if (\Auth::check()) {
$currentUser = \Auth::user()->profile;

if ($currentUser != 'guest') {
return view('searches.tasks.create', [
'search_id' => $search_id,
]);
} else {
return redirect('searches/'.$incident->search_id)
->with('error', __('messages.not_allowed'));
}
} else {
return redirect()->action('HomeController@login');
}
}

public function store(Request $request)
{
$request->validate([
'sector' => 'required',
'status' => 'required', Rule::in(['to_do', 'in_progress', 'done']),
'gpxFile' => 'file|mimes:bin,dms,lrf,mar,gpx,xml',
], [
'sector.required' => __('messages.required'),
'status.required' => __('messages.required'),
'gpxFile.mimes' => __('messages.gpx_file'),
]);

$task = new Task([
'search_id' => $request->get('search_id'),
'sector' => $request->get('sector'),
'status' => $request->get('status'),
'group' => $request->get('group'),
'start' => $request->get('start'),
'end' => $request->get('end'),
'type' => $request->get('type'),
'description' => $request->get('description'),
'trackingDevice' => $request->get('trackingDevice'),
'gpxFileName' => $request->get('gpxFileName'),
'gpxFile' => $request['gpxFile'],
]);

if ($request->hasFile('gpxFile')) {
$task->gpx = 1;
}

$task->save();

return redirect('searches/'.$task->search_id.'#nav-tasks')
->with('success', __('main.task').' '.$task->id.__('messages.added'));
}

public function update(Request $request, Task $id)
{
$request->validate([
'sector' => 'required',
'status' => 'required', Rule::in(['to_do', 'in_progress', 'done']),
'gpxFile' => 'file|mimes:bin,dms,lrf,mar,gpx,xml',
], [
'sector.required' => __('messages.required'),
'status.required' => __('messages.required'),
'gpxFile.mimes' => __('messages.gpx_file'),
]);

$id->update($request->toArray());

if ($request->hasFile('GpxFile')) {
$id->update([
'GpxFileName' => $request->get('gpxFileName'),
'Gpx' => 1,
'GpxFile' => $request['gpxFile'],
]);
}

return redirect('searches/'.$id->search_id.'#nav-tasks')
->with('success', __('main.task').' '.$id->id.__('messages.updated'));
}

public function destroy(Task $id)
{
$currentUser = \Auth::user()->profile;

if ($currentUser == 'admin') {
$id->delete();

return redirect('searches/'.$id->search_id.'#nav-tasks')
->with('success', __('main.task').' '.$id->id.__('messages.deleted'));
} else {
return redirect('searches/'.$id->search_id.'#nav-tasks')
->with('error', __('messages.not_allowed'));
}
}
}
23 changes: 23 additions & 0 deletions app/Task.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Task extends Model
{
protected $fillable = [
'search_id',
'sector',
'status',
'group',
'start',
'end',
'type',
'description',
'trackingDevice',
'gpx',
'gpxFileName',
'gpxFile',
];
}
Empty file modified artisan
100755 → 100644
Empty file.
Loading

0 comments on commit 9878345

Please sign in to comment.