This commit is contained in:
Mathieu Lagace
2019-09-08 16:43:34 -04:00
parent 0bd86285ca
commit 133f430445
39 changed files with 789 additions and 74 deletions

View File

@@ -20,4 +20,9 @@ class Booking extends Model
{
return $this->belongsTo('App\Item');
}
public function logs()
{
return $this->morphMany('App\Log', 'logable');
}
}

View File

@@ -19,4 +19,9 @@ class Config extends Model
{
return Config::where('name',$configName)->first()->data();
}
public function logs()
{
return $this->morphMany('App\Log', 'logable');
}
}

View File

@@ -20,4 +20,9 @@ class Course extends Model
{
return $this->belongsTo('App\Event');
}
public function logs()
{
return $this->morphMany('App\Log', 'logable');
}
}

View File

@@ -35,4 +35,9 @@ class Event extends Model
return false;
}
public function logs()
{
return $this->morphMany('App\Log', 'logable');
}
}

View File

@@ -24,7 +24,7 @@ class AdminController extends Controller
*/
public function index()
{
Log::saveLog('Affichage du tableau de bord');
clog('navigate','success','consulte le tableau de bord');
$futureEvent_to_filtered = \App\Event::all()->sortBy('date_begin');
$futureEvent_to_filtered_pass_1 = collect();
@@ -47,7 +47,7 @@ class AdminController extends Controller
public function update()
{
Log::saveLog('Affichage des notes de mise a jour');
clog('navigate','success','consulte les notes de mise à jours');
return view('admin.update');
}

View File

@@ -13,7 +13,7 @@ class ArticleController extends Controller
*/
public function index()
{
clogNav('consulte les articles');
return view('admin.article.index',['activity' => \App\ComplementaryActivity::all()]);
}
@@ -92,6 +92,7 @@ class ArticleController extends Controller
$a->public_header_picture = $request->public_header_picture;
$a->save();
clog('edit','success','a ajouté un article');
return redirect('/admin/article')->with('success','Article modifié avec succès');
}
@@ -127,7 +128,7 @@ class ArticleController extends Controller
$p->pictureable_type = "App\ComplementaryActivity";
$p->save();
clog('add','success','a ajouté une photo avec succès');
return redirect('/admin/article/activity/picture/'.$id)->with('success','Photo ajoutéé avec succès');
}
}

View File

@@ -4,45 +4,91 @@ namespace App\Http\Controllers;
use App\Booking;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class BookingController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
* @return Response
*/
public function index()
public function index($type, $id)
{
//
switch ($type)
{
case 'course':
$event = \App\Course::find($id);
$event->fulltime = $event->event->date_begin.', Niveau '.$event->level.', Période '.$event->periode;
$event->fulldesc = $event->ocom;
break;
case 'event':
$event = \App\Event::find($id);
$event->fulltime = $event->date_begin;
$event->fulldesc = $event->desc;
break;
default:
abort(500);
}
clogNav('consulte les réservations');
return view('admin.booking.index',['event' => $event,'event_type' => $type,'event_id' => $id]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
* @return Response
*/
public function create()
public function create($type,$id)
{
//
return view('admin.booking.create',['items' => \App\Item::training(),'event_type' => $type,'event_id' => $id]);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
* @return Response
*/
public function store(Request $request)
public function store(Request $request,$type,$id)
{
//
$b = new Booking();
$b->item_id = $request->item_id;
$b->amount = $request->amount;
$b->bookable_id = $id;
$b->user_id = \Auth::user()->id;
if (!$request->comment == '')
{
$b->comment = $request->comment;
}
else
{
$b->comment = 'Aucun commentaire';
}
switch ($type)
{
case 'course':
$b->bookable_type = 'App\Course';
break;
case 'event':
$b->bookable_type = 'App\Event';
default:
$b->bookable_type = '';
}
$b->save();
clog('add','success','a ajouté une réservation avec succès',null,'App\Booking',$b->id);
return redirect('/admin/booking/course/'.$id)->with('success','Réservation ajouté avec succès');
}
/**
* Display the specified resource.
*
* @param \App\Booking $booking
* @return \Illuminate\Http\Response
* @return Response
*/
public function show(Booking $booking)
{
@@ -53,7 +99,7 @@ class BookingController extends Controller
* Show the form for editing the specified resource.
*
* @param \App\Booking $booking
* @return \Illuminate\Http\Response
* @return Response
*/
public function edit(Booking $booking)
{
@@ -65,21 +111,38 @@ class BookingController extends Controller
*
* @param \Illuminate\Http\Request $request
* @param \App\Booking $booking
* @return \Illuminate\Http\Response
* @return Response
*/
public function update(Request $request, Booking $booking)
{
//
$b = Booking::find($request->booking_id);
$b->amount = $request->amount;
$b->comment = $request->comment;
$b->save();
return back()->with('success','Modification sauvegardé avec succès');
}
/**
* Remove the specified resource from storage.
*
* @param \App\Booking $booking
* @return \Illuminate\Http\Response
* @return Response
*/
public function destroy(Booking $booking)
public function destroy(Request $request)
{
//
$b = Booking::find($request->id);
$b->delete();
}
public function modalItem($id)
{
return view('admin.booking.modal.create',['item' => \App\Item::find($id)]);
}
public function modalItemEdit($id)
{
return view('admin.booking.modal.edit',['booking' => \App\Booking::find($id)]);
}
}

View File

@@ -32,7 +32,6 @@ class CalendarController extends Controller
*/
public function index()
{
Log::saveLog("Affichage de l'horaire");
$this->listClass();
@@ -165,9 +164,6 @@ class CalendarController extends Controller
$url = str_replace("-","_", $Requestdate);
/** Dont work ... API stuff
* Log::saveLog("a consulté l'horaire du ".$date);
**/
$today = Schedule::where('date','=',$Requestdate)->get();
$isEmpty = $today->isEmpty();
@@ -450,8 +446,6 @@ class CalendarController extends Controller
$schedule->save();
/** Logs and Notification */
Log::saveLog("Ajout de l'activité, ".$schedule->data['event_name']." à l'horaire le ".$schedule->date);
$userToNotify = $schedule->getUserToNotify();
\Notification::send($userToNotify, new Alert(\Auth::User()->id,"Ajout de l'activité, ".$schedule->data['event_name']." à l'horaire le ".$schedule->date,"/admin/calendar"));
@@ -692,7 +686,6 @@ class CalendarController extends Controller
\Notification::send($userToNotify, new mail(\Auth::User(),"Modification d'une activité a l'horaire",\Auth::User()->fullname()." à modifié l'activité, ".$schedule->data['event_name']." à l'horaire le ".$schedule->date."<br>".$string_Change));
}
Log::saveLog("Modification de l'activité, ".$schedule->data['event_name']." à l'horaire le ".$schedule->date);
return redirect('/admin/calendar');
@@ -713,7 +706,6 @@ class CalendarController extends Controller
\Notification::send($userToNotify, new mail(\Auth::User(),"Suppression d'une activité a l'horaire",\Auth::User()->fullname()." à supprimé l'activité, ".$schedule->data['event_name']." à l'horaire le ".$schedule->date));
}
Log::saveLog("Suppression de l'activité, ".$schedule->data['event_name']." à l'horaire le ".$schedule->date);
}

View File

@@ -14,6 +14,7 @@ class ComplementaryActivityController extends Controller
*/
public function index()
{
clogNav('consulte les configurations d\'activité');
return view('admin.configs.activity',['configs' => \App\Config::all(),'activities' => \App\ComplementaryActivity::all()]);
}
@@ -67,7 +68,7 @@ class ComplementaryActivityController extends Controller
}
$activity->save();
clog('add','success','a ajouté une activité',null,'App\ComplementaryActivity',$activity->id);
return redirect('/admin/config/activity')->with('success','Activité ajouté avec succes');
}
@@ -129,7 +130,7 @@ class ComplementaryActivityController extends Controller
}
$activity->save();
clog('edit','success','a modifié une activité',null,'App\ComplementaryActivity',$activity->id);
return redirect('/admin/config/activity')->with('success','Modification sauvegarder avec succes');
}
@@ -145,6 +146,7 @@ class ComplementaryActivityController extends Controller
$activity = ComplementaryActivity::find($id);
clog('delete','success','a supprimé une activité',null,'App\ComplementaryActivity',$id);
$activity->delete();
}
}

View File

@@ -14,6 +14,7 @@ class ConfigController extends Controller
*/
public function index()
{
clogNav('consulte les configurations');
return view ('admin.configs.general',['configs' => Config::all()]);
}
@@ -34,7 +35,7 @@ class ConfigController extends Controller
$c->save();
}
\App\Log::saveLog('Modification de la configuration du site');
clog('edit','success','a modifié la configuration');
return redirect('/admin/config/customisation')->with('success','Modification sauvegarder avec succès !');
}
@@ -114,9 +115,7 @@ class ConfigController extends Controller
$c->data = [request($config)];
$c->save();
}
\App\Log::saveLog('Modification de la configuration du site');
clog('edit','success','a modifié la configuration');
return redirect('/admin/config')->with('success','Modification sauvegarder avec succès !');
}

View File

@@ -83,7 +83,7 @@ class EventController extends Controller
}
}
}
clog('add','success','a ajouté un évènement',null,'App\Event',$event->id);
return redirect('/admin/calendar')->with('success','Événement ajouter à l\'horaire');
}
@@ -174,7 +174,7 @@ class EventController extends Controller
}
}
}
clog('edit','success','a modifié un évènement',null,'App\Event',$event->id);
return redirect('/admin/calendar')->with('success','Modification à l\'événement sauvegarder à l\'horaire');
}

View File

@@ -16,7 +16,7 @@ class InventoryController extends Controller
public function index()
{
$items = Item::all();
clogNav('consulte l\'inventaire');
return view('admin.inventory.index',[ 'items' => $items]);
}
@@ -32,6 +32,7 @@ class InventoryController extends Controller
public function management()
{
clogNav('consulte la gestion de l\'inventaire');
return view('admin.inventory.management');
}

View File

@@ -15,6 +15,7 @@ class ItemCategoryController extends Controller
*/
public function index()
{
clogNav('consulte la gestion des catégories d\'inventaire');
return view('admin.itemcategory.index',['categories' => ItemCategory::all()]);
}
@@ -58,7 +59,7 @@ class ItemCategoryController extends Controller
}
$c->save();
clog('add','success','a ajouté une catégorie a l\'inventaire',null,'App\ItemCategory',$c->id);
return redirect('/admin/inventory/management/category/')->with('success','Catégorie ajouté avec succès');
}
@@ -115,7 +116,7 @@ class ItemCategoryController extends Controller
}
$c->save();
clog('edit','success','a modifié une catégorie de l\'inventaire',null,'App\ItemCategory',$c->id);
return redirect('/admin/inventory/management/category/')->with('success','Catégorie modifié avec succès');
}
@@ -130,5 +131,6 @@ class ItemCategoryController extends Controller
$c = ItemCategory::find($id);
$c->delete();
clog('delete','success','a supprimé une catégorie de l\'inventaire',null,'App\ItemCategory',$c->id);
}
}

View File

@@ -45,7 +45,7 @@ class ItemController extends Controller
$item->category_id = request('category_id');
$item->save();
clog('add','success',"a ajouté un item à l'inventaire",null,"App\Item",$item->id);
return redirect('/admin/inventory')->with('success','Item sauvegardé avec succès');
}
@@ -92,7 +92,7 @@ class ItemController extends Controller
$item->category_id = request('category_id');
$item->save();
clog('edit','success',"a modifié un item à l'inventaire",null,"App\Item",$item->id);
return redirect('/admin/inventory')->with('success','Item sauvegardé avec succès');
}
@@ -107,5 +107,6 @@ class ItemController extends Controller
$item = Item::find(request('id'));
$item->delete();
clog('delete','success',"a supprimé un item à l'inventaire",null,"App\Item",$item->id);
}
}

View File

@@ -25,6 +25,7 @@ class MessageController extends Controller
*/
public function index()
{
clogNav('consulte les messages');
return view('admin.message.index', ['messages' => \App\Message::all()]);
}
@@ -65,8 +66,7 @@ class MessageController extends Controller
$msg->save();
\App\Log::savelog("Publication du message : ".request('msg_title'));
clog('add','success','a ajouté un message',null,'App\Message',$msg->id);
return redirect('/admin/message');
}
@@ -79,6 +79,7 @@ class MessageController extends Controller
public function show($id)
{
\Auth::User()->seenMessage($id);
clog('see','success','a consulté un message',null,'App\Message',$id);
return view('admin.message.show', ['message' => Message::find($id)]);
}
@@ -118,5 +119,6 @@ class MessageController extends Controller
$msg = Message::find($id);
$msg->delete();
clog('delete','success','a supprimé un message',null,'App\Message',$id);
}
}

View File

@@ -19,6 +19,7 @@ class NewsController extends Controller
public function indexAdmin()
{
clogNav('a consulté les nouvelles');
return view('admin.news.index',['news' => \App\News::paginate(9)]);
}
@@ -55,7 +56,7 @@ class NewsController extends Controller
$n->user_id = \Auth::user()->id;
$n->save();
clog('add','success','a ajouté une nouvelle',null,'App\News',$n->id);
return redirect('/admin/news')->with('success','Nouvelle ajouté avec succès');
}
@@ -68,6 +69,7 @@ class NewsController extends Controller
*/
public function show($id)
{
clog('see','success','a consulté une nouvelle',null,'App\News',$id);
return view('public.news', ['new' => \App\News::find($id)]);
}
@@ -106,7 +108,7 @@ class NewsController extends Controller
$n->user_id = \Auth::user()->id;
$n->save();
clog('edit','success','a modifié une nouvelle',null,'App\News',$id);
return redirect('/admin/news')->with('success','Nouvelle modifié avec succès');
}
@@ -121,5 +123,6 @@ class NewsController extends Controller
$news = News::find(request('id'));
$news->delete();
clog('delete','success','a supprimé une nouvelle',null,'App\News',$id);
}
}

View File

@@ -19,6 +19,7 @@ class PictureController extends Controller
public function indexAdmin()
{
clogNav('consulte les images');
return view('admin.picture.index',['pictures' => \App\Picture::paginate(\App\Config::getData('text_public_picture_nb'))]);
}
/**
@@ -48,7 +49,7 @@ class PictureController extends Controller
$pic->pictureable_type = "";
$pic->save();
clog('add','success','a ajouté une image',null,'App\Picture',$pic->id);
return redirect('/admin/picture')->with('success','Image ajoutée avec succès');
}
@@ -61,6 +62,7 @@ class PictureController extends Controller
*/
public function show($id)
{
clog('see','success','a consulté une image',null,'App\Picture',$id);
return view('public.picture',['picture' => \App\Picture::find($id)]);
}
@@ -91,7 +93,7 @@ class PictureController extends Controller
$pic->desc = request('desc');
$pic->save();
clog('edit','success','a modifié une image',null,'App\Picture',$id);
if ($pic->pictureable_type == "App\ComplementaryActivity")
{
return redirect('admin/article/activity/picture/'.$pic->pictureable->id)->with('success','Image sauvegarder avec succès');
@@ -113,5 +115,6 @@ class PictureController extends Controller
$pic = Picture::find($id);
$pic->delete();
clog('delete','success','a supprimé une image',null,'App\Picture',$id);
}
}

View File

@@ -196,7 +196,7 @@ class ScheduleController extends Controller
public function printtopdf($id)
{
$event = \App\Event::find($id);
$pdf = PDF::loadView('admin.schedule.modal.show',['event' => $event]);
$pdf = PDF::loadView('admin.schedule.print.event',['event' => $event]);
return $pdf->download($event->date_begin.'.pdf');
}

View File

@@ -1,5 +1,10 @@
<?php
use App\Log;
/**
* @return bool
*/
function getStatus()
{
$client = new GuzzleHttp\Client();
@@ -17,3 +22,54 @@ function getStatus()
return $isBroken;
}
/**
* @param string $type
* @param string $result
* @param string $event
* @param int $user_id
* @param null $obj_type
* @param null $obj_id
*/
function clog(string $type,string $result,string $event,$user_id = null,$obj_type = null,$obj_id = null)
{
$log = new Log;
$log->result = $result;
$log->event = $event;
$log->type = $type;
if ($user_id != null)
{
$log->user_id = $user_id;
}
else
{
$log->user_id = \Auth::User()->id;
}
if ($obj_type != null)
{
$log->logable_type = $obj_type;
}
else
{
$log->logable_type = '';
}
if ($obj_id != null)
{
$log->logable_id = $obj_id;
}
else
{
$log->logable_id = 0;
}
$log->save();
}
function clogNav($event)
{
clog('navigate','success',$event);
}

View File

@@ -4,6 +4,7 @@ namespace App;
use Illuminate\Database\Eloquent\Model;
use mysql_xdevapi\Collection;
use function foo\func;
class Item extends Model
{
@@ -44,11 +45,13 @@ class Item extends Model
return \App\ItemCategory::find($this->category_id);
}
public function available()
public function available($begin = null,$end = null)
{
if ($begin == null && $end == null)
{
return $this->quantity - $this->booked();
}
}
public function booked()
{
@@ -61,4 +64,15 @@ class Item extends Model
return $nbBooked;
}
public static function training()
{
$training = collect();
$training = \App\Item::all()->filter(function($value,$key){
return $value->category()->is_training == 1 && $value->category()->is_op_appro != 1;
});
return $training;
}
}

View File

@@ -10,4 +10,9 @@ class ItemCategory extends Model
{
return $this->hasMany('App\Item','category_id');
}
public function logs()
{
return $this->morphMany('App\Log', 'logable');
}
}

View File

@@ -11,17 +11,45 @@ class Log extends Model
return $this->belongsTo(User::class);
}
public static function saveLog($action, $user = "default")
public function logable()
{
$log = new Log;
if ($user == "default") {
$user = \Auth::User()->id;
return $this->morphTo();
}
$log->action = $action;
$log->user_id = $user;
public function typeColor()
{
switch ($this->type)
{
case 'add':
return 'success';
break;
case 'edit':
return 'primary';
break;
case 'delete':
return 'warning';
break;
case 'see':
return 'info';
break;
case 'navigate':
return 'secondary';
break;
case 'error':
return 'danger';
break;
}
}
$log->save();
public function logableURL()
{
if ($this->logable != null)
{
switch ($this->logable_type)
{
case "App\News":
return "/news/".$this->logable->id;
}
}
}
}

View File

@@ -9,4 +9,9 @@ class Message extends Model
protected $casts = [
'data' => 'array',
];
public function logs()
{
return $this->morphMany('App\Log', 'logable');
}
}

View File

@@ -15,4 +15,9 @@ class News extends Model
{
return $this->morphMany('App\Picture', 'pictureable');
}
public function logs()
{
return $this->morphMany('App\Log', 'logable');
}
}

View File

@@ -10,4 +10,9 @@ class Picture extends Model
{
return $this->morphTo();
}
public function logs()
{
return $this->morphMany('App\Log', 'logable');
}
}

View File

@@ -15,8 +15,12 @@ class CreateLogsTable extends Migration
{
Schema::create('logs', function (Blueprint $table) {
$table->increments('id');
$table->string('type');
$table->string('result');
$table->text('event');
$table->integer('user_id');
$table->string('action');
$table->string('logable_type');
$table->integer('logable_id');
$table->timestamps();
});
}

View File

@@ -0,0 +1,120 @@
@extends('layouts.admin.main')
@section('content')
<div class="col-md-12">
<div class="card">
<div class="card-header card-header-primary">
<h4 class="card-title">Réserver un item
<a href="#"><i class="fa fa-question-circle float-right" aria-hidden="true"></i></a>
</h4>
</div>
<div class="card-body">
<table id="log-data" class="table table-striped table-bordered">
<thead>
<tr>
<th>#</th>
<th>Nom</th>
<th>Categorie</th>
<th>Description</th>
<th>Quantité Disponible</th>
<th width="15%"></th>
</tr>
</thead>
<tbody>
@foreach($items as $item)
<tr>
<td>{{$item->id}}</td>
<td>{{$item->name}}</td>
<td>{{$item->category()->name}}</td>
<td>{!! $item->desc !!}</td>
<td>{{$item->available()}}</td>
<td>
<button class="btn btn-primary btn-block" onclick='openModal("{{$item->id}}")'>Réserver</button>
</td>
</tr>
@endforeach
</tbody>
</table>
<a href="/admin/booking/{{$event_type}}/{{$event_id}}" class="btn btn-secondary">Retour</a>
</div>
</div>
</div>
@endsection
@section('custom_scripts')
<script src="https://cdn.datatables.net/rowgroup/1.1.0/js/dataTables.rowGroup.min.js"></script>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
$('#log-data').DataTable({
"order": [[ 2, "asc" ]],
"lengthMenu": [[25, 50, -1], [25, 50, "All"]],
"rowGroup": {
dataSrc: 2
}
});
} );
})(jQuery);
function openModal(id)
{
$.get("/api/booking/modal/item/" + id + "?api_token="+api_token, function (data) {
$("#modal-content").html(data);
});
$('#createModal').modal('toggle')
}
</script>
<div class="modal fade" id="createModal" tabindex="-1" role="dialog" aria-labelledby="schedulemodal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="card card-signup card-plain">
<div class="modal-header">
<div class="card-header card-header-primary text-center">
<h4 class="card-title">Confirmer la réservation</h4>
</div>
</div>
<div class="modal-body">
<form method="post" action="">
@csrf
<div class="card-body" id="modal-content">
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label>#</label>
<input class="form-control" type="text" disabled>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Nom de l'item</label>
<input class="form-control" type="text" disabled>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Description</label>
<input class="form-control" type="text" disabled>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Quantité</label>
<input class="form-control" type="number" min="1" required disabled>
<small class="form-text text-muted">Quantité d'item a réserver</small>
</div>
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-primary" disabled>Confimer</button>
</div>
<div class="col-md-6 text-right">
<button type="button" class="btn btn-secondary" data-dismiss="modal" aria-label="Close">Annuler</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@@ -0,0 +1,178 @@
@extends('layouts.admin.main')
@section('content')
<div class="col-md-12">
<div class="card">
<div class="card-header card-header-primary">
<h4 class="card-title">Réservation
<a href="#"><i class="fa fa-question-circle float-right" aria-hidden="true"></i></a>
</h4>
</div>
<div class="card-body">
<div class="alert alert-warning" role="alert">
<div class="row">
<div class="col-md-12">
<h6>Information sur l'évènement</h6>
<hr class="my-1">
</div>
<div class="col-md-6 mb-2">
{{$event->name}}
</div>
<div class="col-md-6 mb-2 text-right">
{{$event->fulltime}}
</div>
<div class="col-md-6 mb-2">
{{$event->fulldesc}}
</div>
<div class="col-md-6 text-right">
{{$event->user->fullname()}}
</div>
</div>
</div>
<table id="log-data" class="table table-striped table-bordered">
<thead>
<tr>
<th>#</th>
<th>Nom</th>
<th>Categorie</th>
<th>Description</th>
<th>Quantité</th>
<th width="15%">
<a name="add" id="add" class="btn btn-outline-primary" href="/admin/booking/{{$event_type}}/{{$event_id}}/add" role="button">Réserver un item</a>
</th>
</tr>
</thead>
<tbody>
@foreach($event->bookings as $booking)
<tr>
<td>{{$booking->item->id}}</td>
<td>{{$booking->item->name}}</td>
<td>{{$booking->item->category()->name}}</td>
<td>{!! $booking->item->desc !!}</td>
<td>{{$booking->amount}}</td>
<td>
<div class="btn-group">
<button class="btn btn-danger btn-just-icon" onclick="deleteBooking('{{$booking->id}}')"><i class="fas fa-times-circle"></i></button>
<button class="btn btn-primary" onclick="openModal('{{$booking->id}}')"><i class="fas fa-edit"></i> Modifier</button>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endsection
@section('custom_scripts')
<script src="https://cdn.datatables.net/rowgroup/1.1.0/js/dataTables.rowGroup.min.js"></script>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
$('#log-data').DataTable({
"order": [[ 2, "asc" ]],
"lengthMenu": [[25, 50, -1], [25, 50, "All"]],
"rowGroup": {
dataSrc: 2
}
});
} );
})(jQuery);
function deleteBooking(pid){
swal({
title: 'Êtes vous certain ?',
text: "Vous ne pourrez annuler cette action",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Oui',
cancelButtonText: 'Non'
}).then((result) => {
if (result.value) {
(function($) {
$.post('/api/booking/delete?api_token='+api_token, { id: pid } , function(data) {
console.log('Delete');
});
})(jQuery);
swal(
'Supprimé!',
"L'item a été supprimé",
'success'
).then((result) => {
if (result.value) {
location.reload();
}
})
}
})
}
function openModal(id)
{
$.get("/api/booking/modal/edit/item/" + id + "?api_token="+api_token, function (data) {
$("#modal-content").html(data);
});
$('#editModal').modal('toggle')
}
</script>
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="schedulemodal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="card card-signup card-plain">
<div class="modal-header">
<div class="card-header card-header-primary text-center">
<h4 class="card-title">Modifier la réservation</h4>
</div>
</div>
<div class="modal-body">
<form method="post" action="/admin/booking/edit">
@csrf
<div class="card-body" id="modal-content">
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label>#</label>
<input class="form-control" type="text" disabled>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Nom de l'item</label>
<input class="form-control" type="text" disabled>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Description</label>
<input class="form-control" type="text" disabled>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Quantité</label>
<input class="form-control" type="number" min="1" required disabled>
<small class="form-text text-muted">Quantité d'item a réserver</small>
</div>
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-primary" disabled>Confimer</button>
</div>
<div class="col-md-6 text-right">
<button type="button" class="btn btn-secondary" data-dismiss="modal" aria-label="Close">Annuler</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@@ -0,0 +1,47 @@
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label>#</label>
<input class="form-control" type="text" disabled value="{{$item->id}}">
</div>
</div>
<div class="col-md-2 d-none">
<div class="form-group">
<label>#</label>
<input class="form-control" name="item_id" readonly type="text" value="{{$item->id}}">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Nom de l'item</label>
<input class="form-control" type="text" disabled value="{{$item->name}}">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Description</label>
<textarea class="form-control" disabled>{!! $item->desc !!}</textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Quantité</label>
<input class="form-control" name="amount" type="number" min="1" required value="1" max="{{$item->available()}}">
<small class="form-text text-muted">Quantité d'item a réserver</small>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Commentaire</label>
<textarea class="form-control" name="comment"></textarea>
<small class="form-text text-muted">Commantaire pour l'officier d'appro</small>
</div>
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-primary">Confimer</button>
</div>
<div class="col-md-6 text-right">
<button type="button" class="btn btn-secondary" data-dismiss="modal" aria-label="Close">Annuler</button>
</div>
</div>

View File

@@ -0,0 +1,49 @@
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label>#</label>
<input class="form-control" type="text" disabled value="{{$booking->item->id}}">
</div>
</div>
<div class="col-md-2 d-none">
<div class="form-group">
<label>#</label>
<input class="form-control" name="booking_id" readonly type="text" value="{{$booking->id}}">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Nom de l'item</label>
<input class="form-control" type="text" disabled value="{{$booking->item->name}}">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Description</label>
<textarea class="form-control" disabled>{!! $booking->item->desc !!}</textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Quantité</label>
<input class="form-control" name="amount" type="number" min="1" required value="{{$booking->amount}}" max="{{$booking->item->available()}}">
<small class="form-text text-muted">Quantité d'item a réserver</small>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Commentaire</label>
<textarea class="form-control" name="comment">
{{$booking->comment}}
</textarea>
<small class="form-text text-muted">Commantaire pour l'officier d'appro</small>
</div>
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-primary">Confimer</button>
</div>
<div class="col-md-6 text-right">
<button type="button" class="btn btn-secondary" data-dismiss="modal" aria-label="Close">Annuler</button>
</div>
</div>

View File

@@ -65,6 +65,18 @@
<div class="modal fade" id="schedulemodal" tabindex="-1" role="dialog" aria-labelledby="schedulemodal" aria-hidden="true">
<div class="modal-dialog w-100 modal-lg mx-2 mx-lg-auto" role="document">
<div class="modal-content" id="modal-content">
<div class="modal-header">
<h5 class="modal-title">Chargement</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body h-75">
<div class="spinner-border text-muted"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

View File

@@ -84,7 +84,7 @@
<div class="form-group">
<label for="location">Emplacement par défaut</label>
<input type="text"
class="form-control" name="location" id="location" aria-describedby="helpName" placeholder="Soirée d'instruction réguliere" required>
class="form-control" name="location" id="location" aria-describedby="helpName" placeholder="Escadron" required>
<small id="helpName" class="form-text text-muted">Emplacement par défaut de l'activité</small>
</div>
</div>

View File

@@ -10,7 +10,6 @@
<div class="card-body">
<div class="btn-group btn-block">
<a name="add" id="add" class="btn btn-primary btn-block" href="/admin/item/add" role="button">Ajouter un item</a>
<button name="add" id="add" disabled class="btn btn-outline-primary btn-block" href="/admin/booking/add" role="button">Réserver un item</button>
</div>
<hr>
<table id="log-data" class="table table-striped table-bordered">

View File

@@ -14,7 +14,9 @@
<table id="log-data" class="table table-striped table-no-bordered table-hover dataTable dtr-inline">
<thead>
<tr>
<th>Horodatage </th>
<th>Horodatage</th>
<th>Type</th>
<th>Résultat</th>
<th>Utilisateur</th>
<th>Action</th>
</tr>
@@ -23,8 +25,10 @@
@foreach ($log as $item)
<tr>
<td>{{$item->created_at}}</td>
<th><span class="badge badge-pill badge-{{$item->typeColor()}}">{{$item->type}}</span></th>
<th><span class="badge badge-pill badge-{{$item->result}}">Success</span></th>
<td>{{\App\User::find($item->user_id)->fullname()}}</td>
<td>{{$item->action}}</td>
<td><a href="">{{$item->event}}</a></td>
</tr>
@endforeach

View File

@@ -96,7 +96,7 @@
<div class="col-sm-6 my-2">
<div class="form-group">
<label for="name">Nom du cours</label>
<input type="text" name="name_n{{$i}}_p{{$p}}" id="name_n{{$i}}_p{{$p}}" class="form-control" aria-describedby="nameHelp" required value="{{$activity->course($p,$i)->name}}">
<input type="text" name="name_n{{$i}}_p{{$p}}" id="name_n{{$i}}_p{{$p}}" class="form-control" aria-describedby="nameHelp" required @if($activity->course($p,$i) != null) value="{{$activity->course($p,$i)->name}}" @endif>
<small id="nameHelp" class="text-muted">Veuillez entrer le nom du cours</small>
</div>
</div>
@@ -104,7 +104,7 @@
<div class="form-group">
<div class="form-group">
<label for="name">Instructeur</label>
<input type="text" name="instruc_n{{$i}}_p{{$p}}" id="instruc_n{{$i}}_p{{$p}}" class="form-control basicAutoComplete" aria-describedby="nameHelp" required value="{{\App\User::find($activity->course($p,$i)->user_id)->fullname()}}">
<input type="text" name="instruc_n{{$i}}_p{{$p}}" id="instruc_n{{$i}}_p{{$p}}" class="form-control basicAutoComplete" aria-describedby="nameHelp" required @if($activity->course($p,$i) != null) value="{{\App\User::find($activity->course($p,$i)->user_id)->fullname()}}" @endif>
<small id="nameHelp" class="text-muted">Veuillez entrer le nom de l'instructeur</small>
</div>
</div>
@@ -112,14 +112,14 @@
<div class="col-sm-6 my-2">
<div class="form-group">
<label for="name">OCOM</label>
<input type="text" name="ocom_n{{$i}}_p{{$p}}" id="ocom_n{{$i}}_p{{$p}}" class="form-control" aria-describedby="nameHelp" required value="{{$activity->course($p,$i)->ocom}}">
<input type="text" name="ocom_n{{$i}}_p{{$p}}" id="ocom_n{{$i}}_p{{$p}}" class="form-control" aria-describedby="nameHelp" required @if($activity->course($p,$i) != null) value="{{$activity->course($p,$i)->ocom}}" @endif>
<small id="nameHelp" class="text-muted">Veuillez entrer l'OCOM</small>
</div>
</div>
<div class="col-sm-6 my-2">
<div class="form-group">
<label for="name">Lieux</label>
<input type="text" name="loc_n{{$i}}_p{{$p}}" id="loc_n{{$i}}_p{{$p}}" class="form-control" placeholder="" aria-describedby="nameHelp" required value="{{$activity->course($p,$i)->location}}">
<input type="text" name="loc_n{{$i}}_p{{$p}}" id="loc_n{{$i}}_p{{$p}}" class="form-control" placeholder="" aria-describedby="nameHelp" required @if($activity->course($p,$i) != null) value="{{$activity->course($p,$i)->location}}" @endif>
<small id="nameHelp" class="text-muted">Veuillez entrer le lieux</small>
</div>
</div>

View File

@@ -0,0 +1,86 @@
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
Du <strong>{{$event->date_begin}}</strong> au <strong>{{$event->date_end}}</strong><br>
<small>{{$event->location}} </small>
@if ($event->is_mandatory)
Obligatoire -
@else
Optionnel -
@endif
@if (is_int($event->type))
{{$event->type}}
@else
{{\App\ComplementaryActivity::find($event->type)->name}}
@endif
{!!$event->desc!!}
@if (!$event->courses->isEmpty())
<h4 class="title text-center">Horaire</h4>
<table>
<thead>
<th>Niveau</th>
@for ($p = 1; $p <= \App\Config::getData('admin_periode_nb'); $p++)
<th>
Période {{$p}} <small>{{\App\Config::all()->where('name','admin_periode_begin')->first()->data[$p]}} à {{\App\Config::all()->where('name','admin_periode_end')->first()->data[$p]}} </small>
</th>
@endfor
</thead>
<tbody>
@for ($l = 1; $l <= \App\Config::getData('admin_level_in_schedule_nb'); $l++)
<tr>
<td class="col-md-2 m-3">
Niveau {{$l}}
</td>
@for ($p = 1; $p <= \App\Config::getData('admin_periode_nb'); $p++)
<td>
@foreach ($event->courses as $course)
@if ($course->periode == $p && $course->level == $l)
{{$course->name}}
@if(\App\User::find($course->user_id))
{{\App\User::find($course->user_id)->fullname()}}
@else
Utilisateur Inconnu
@endif
{{$course->ocom}}
{{$course->location}}
<a>Réservation de materiel</a>
<table>
@if (!$course->bookings->isEmpty())
<thead class="row">
<th class="col-sm-8 p-2">
<strong>Item</strong>
</th>
<th class="col-sm-4 text-right p-2">
<strong>Quantité</strong>
</th>
</thead>
<tbody>
@foreach ($course->bookings as $booking)
<tr>
<td class="col-sm-8 p-2">
<a href="/admin/item/{{$booking->item->id}}">{{$booking->item->name}}</a>
</td>
<td class="col-sm-4 text-right p-2">
{{$booking->amount}}
</td>
</tr>
@endforeach
</tbody>
@else
<p class="text-center">
<strong>Aucune réservation</strong>
</p>
@endif
</table>
@endif
@endforeach
@endfor
@endfor
</table>
@endif
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

View File

@@ -8,7 +8,7 @@
<div class="card-body">
<h4 class="card-title">{{$activity->name}}</h4>
<div style="height: 4rem;overflow: hidden;">{!! $activity->public_body !!}</div>
<a name="activity" id="activity" class="btn btn-primary" href="/activity/{{$activity->id}}" role="button">Plus d'information</a>
<a name="activity" id="activity" class="btn btn-primary mt-2" href="/activity/{{$activity->id}}" role="button">Plus d'information</a>
</div>
</div>
</div>

View File

@@ -30,6 +30,10 @@ Route::middleware('auth:api')->group(function () {
Route::get('/schedule/events/add/modal/{type}/{date}','ScheduleController@loadModalDefautType');
Route::post('/schedule/event/delete/{id}','ScheduleController@delete');
/** Booking */
Route::get('/booking/modal/item/{id}','BookingController@modalItem');
Route::get('/booking/modal/edit/item/{id}','BookingController@modalItemEdit');
Route::post('/booking/delete','BookingController@destroy');
/** Picture */
Route::post('/picture/delete/{id}','PictureController@destroy');

View File

@@ -27,6 +27,10 @@ Route::get('/activity/{id}', 'ComplementaryActivityController@show');
Route::get('/picture/{id}', 'PictureController@show');
Route::get('/pictures', 'PictureController@index');
Route::get('/test',function(){
clog('add','success','Test');
});
Route::middleware(['auth','admin'])->group(function () {
/* Espace Administration Route */
@@ -122,10 +126,11 @@ Route::middleware(['auth','admin'])->group(function () {
/** Booking */
Route::get('/admin/booking','BookingController@index');
Route::get('/admin/booking/{id}','BookingController@show');
Route::get('/admin/booking/{type}/{id}',function() {
return 'A faire';
});
Route::get('/admin/booking/{type}/{id}','BookingController@index');
Route::get('/admin/booking/{type}/{id}/add','BookingController@create');
Route::post('/admin/booking/{type}/{id}/add','BookingController@store');
Route::get('/admin/inventory/booking' , 'InventoryController@booking');
Route::post('/admin/booking/edit','BookingController@update');
/** Item */
Route::get('/admin/item/add' , 'ItemController@create');