mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 10:49:10 -04:00
ALPHA 3.0.1f
This commit is contained in:
@@ -5,6 +5,8 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use \App\Log;
|
||||
use \App\Schedule;
|
||||
use \App\Local;
|
||||
use \App\User;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
@@ -29,7 +31,7 @@ class CalendarController extends Controller
|
||||
{
|
||||
Log::saveLog("Affichage de l'horaire");
|
||||
|
||||
return view('admin.calendar');
|
||||
return view('admin.calendar.calendar_display');
|
||||
}
|
||||
|
||||
public function generate()
|
||||
@@ -111,68 +113,57 @@ class CalendarController extends Controller
|
||||
|
||||
public function load()
|
||||
{
|
||||
|
||||
$lang = str_replace('_', '-', app()->getLocale());
|
||||
setlocale(LC_ALL, $lang.'_'.strtoupper($lang).'.utf8','fra');
|
||||
|
||||
$date = request('date');
|
||||
$Requestdate = request('date');
|
||||
|
||||
$today = Schedule::where('date','=',$date)->get();
|
||||
$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();
|
||||
|
||||
if ($isEmpty) { ?>
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="scrollmodalLabel"><?php echo ucfirst(strftime("%A le %e %B %Y", strtotime($date))) ?></h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p><?php echo trans('calendar.nothing_today'); ?></p>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block"><?php echo trans('calendar.add_to_schedule'); ?></button>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo trans('pagination.close'); ?></button>
|
||||
</div>
|
||||
</div><?php
|
||||
} else {
|
||||
foreach ($today as $date) {
|
||||
if ($date->id) {
|
||||
switch ($date->type) {
|
||||
case 'pilotage':
|
||||
$this->loadPilotage($date);
|
||||
break;
|
||||
echo '<div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="scrollmodalLabel">'.ucfirst(strftime("%A le %e %B %Y", strtotime($Requestdate))).'</h5><button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span></button></div><div class="modal-body">';
|
||||
foreach ($today as $date) {
|
||||
if ($date->id) {
|
||||
switch ($date->type) {
|
||||
case 'pilotage':
|
||||
$this->loadPilotage($date);
|
||||
break;
|
||||
|
||||
case 'instruction':
|
||||
$this->loadInstruction($date);
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 'instruction':
|
||||
$this->loadInstruction($date);
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '<a href="/admin/calendar/add/'.$url.'" type="button" class="btn btn-primary btn-lg btn-block">'.trans('calendar.add_to_schedule').'</a></div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-dismiss="modal">'.trans('pagination.close').'</button></div></div>';
|
||||
}
|
||||
|
||||
private function loadPilotage($schedule)
|
||||
{ ?>
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="scrollmodalLabel"><?php echo ucfirst(strftime("%A le %e %B %Y", strtotime($schedule->date))) ?></h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p><?php echo trans('calendar.pilotage_title'); ?></p>
|
||||
<p><?php echo trans('calendar.begin_at').$schedule->data['begin_at'].trans('calendar.end_at').$schedule->data['end_at'];?></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo trans('pagination.close'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
{
|
||||
echo '<p>'.trans('calendar.pilotage_title').'</p><p>'.trans('calendar.begin_at').$schedule->data['begin_at'].trans('calendar.end_at').$schedule->data['end_at'].'</p>';
|
||||
}
|
||||
|
||||
public function add($date)
|
||||
{
|
||||
$lang = str_replace('_', '-', app()->getLocale());
|
||||
setlocale(LC_ALL, $lang.'_'.strtoupper($lang).'.utf8','fra');
|
||||
|
||||
$UserList = User::all();
|
||||
$LocalList = Local::all();
|
||||
|
||||
return view('admin.calendar.calendar_add' ,['RequestDate' => $date, 'Userslist' => $UserList, 'LocalsList' => $LocalList]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
10
app/Local.php
Normal file
10
app/Local.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Local extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -11,12 +11,16 @@ class Log extends Model
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public static function saveLog($action)
|
||||
public static function saveLog($action, $user = "default")
|
||||
{
|
||||
$log = new Log;
|
||||
|
||||
if ($user == "default") {
|
||||
$user = \Auth::User()->id;
|
||||
}
|
||||
|
||||
$log->action = $action;
|
||||
$log->user_id = \Auth::User()->id;
|
||||
$log->user_id = $user;
|
||||
|
||||
$log->save();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user