Bonjour, j'essaie de faire un calendrier personnalisé dans mon composant Joomla 4. Pour cela j'ai écrit du code pour connecter ma database et recevoir les datas. Pour cela, j'ai 3 fichiers : default.php, ReservationController.php et AjaxReservationController.php . Quand je change les mois dans mon calendrier, j'ai une une "Internal Server Error" et quand je vais sur l'url qui est dans mon default.php j'ai "Invalid Class Controller : ReservationController" .
Voici le code dans default.php :
Voici le code dans ReservationController.php :
Et voici le code dans AjaxReservationController.php :
Je ne sais pas ce qui cause l'erreur, est-ce que l'on pourrait m'aider?
Voici le code dans default.php :
Code:
let calendarAvailabilities = {};
let days;
let periods = jQuery.get( "index.php?option=com_skydivespa&task=reservationc ontroller.getClosingDays", {"month": cal.getMonth(), "year": cal.getYear()},
function( data ) {
days = JSON.parse(data);
console.info(data);
});
Code:
public function getClosingDays()
{
try {
$input = Factory::getApplication()->input;
$month = $input->get('month');
$year = $input->get('year');
// Validate and process the month and year values as needed
$ajaxController = new AjaxReservationController();
$ajaxController->getClosingDays($month, $year);
} catch (Exception $e) {
// Handle the exception
echo 'Error occurred: ' . $e->getMessage();
}
}
Code:
public static function getClosingDays($month, $year)
{
try
{
//$month = sprintf("%02s", Factory::getApplication()->input->get('month'));
//$year = Factory::getApplication()->input->get('year');
// Get a database object.
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('p.date_start, p.date_end, p.mon, p.tue, p.wed, p.thu, p.fri, p.sat, p.sun');
$query->from($db->quoteName('#__skydive_periods') . ' AS p');
$query->where('p.type = "PERIOD_r"');
$query->where('p.published = 1');
$query->where('( (MONTH(p.date_start) = '. $month .' AND YEAR(p.date_start) = '. $year .') OR (MONTH(p.date_end) = '. $month .' AND YEAR(p.date_end) = '. $year .') )');
$db->setQuery($query);
$periods = $db->loadObjectList();
$document = Factory::getApplication()->getDocument();
$document->setMimeEncoding('application/json');
echo new JsonResponse($periods);
Factory::getApplication()->close();
}
catch(Exception $e)
{
return new JsonResponse($e);
}
}