mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 10:49:10 -04:00
76 lines
1.8 KiB
PHP
76 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use \App\Log;
|
|
|
|
class CalendarController extends Controller
|
|
{
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth', ['except' => ['generate']]);
|
|
}
|
|
|
|
/**
|
|
* Show the application dashboard.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
Log::saveLog("Affichage de l'horaire");
|
|
|
|
return view('admin.calendar');
|
|
}
|
|
|
|
public function generate()
|
|
{
|
|
|
|
setlocale(LC_ALL, "fr");
|
|
$month = request('month');
|
|
$year = request('year');
|
|
|
|
$calendar = array();
|
|
|
|
$dayinmonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
|
|
|
|
$firstdaymonth = date("w", strtotime("01-".$month."-".$year));
|
|
|
|
$addingday = 0;
|
|
|
|
for ($i=$firstdaymonth ; $addingday < $dayinmonth ; $i++) {
|
|
$addingday = $addingday + 1;
|
|
$calendar[$i] = $addingday;
|
|
}
|
|
|
|
echo '<table class="table calendar">';
|
|
echo '<thead class="thead-dark">';
|
|
echo '<td colspan="7">'.strftime("%B", strtotime("01-".$month."-".$year)).'</td>';
|
|
echo '</thead>';
|
|
for ($i=0; $i < 6 ; $i++)
|
|
{
|
|
echo '<tr>';
|
|
for ($a=0; $a < 7 ; $a++)
|
|
{
|
|
if (isset($calendar[(($i*7) + $a)]))
|
|
{
|
|
echo '<td class="calendar-container">';
|
|
$today = date("Y-m-d", strtotime($year."-".$month."-".$calendar[(($i*7) + $a)]));
|
|
echo date("j", strtotime($today));
|
|
echo '</td>';
|
|
}
|
|
}
|
|
echo '</tr>';
|
|
}
|
|
echo '</table>';
|
|
|
|
}
|
|
|
|
}
|