mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
ALPHA 3.0.1d
This commit is contained in:
75
app/Http/Controllers/CalendarController.php
Normal file
75
app/Http/Controllers/CalendarController.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?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>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user