<?php
namespace App\Controller;
use App\Controller\AppController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class CoursesController extends AppController
{
public function index($id = NULL, $idType = NULL): Response
{
$check = $this->commonCalls();
if(!$check){
return $check;
}
if($this->RedirectHandle!==NULL){
return $this->RedirectHandle;
}
$email = NULL;
if($this->getUser()){
$email = $this->getUser()->getEmail();
}
$this->Breadcrumbs->setGroupName('courses');
$this->setData('breadcrumbsData', $this->Breadcrumbs->get());
return $this->render('courses/categories.html.twig',
$this->getData()
);
}
public function courseList($id = NULL, $idType = NULL): Response
{
$check = $this->commonCalls();
if(!$check){
return $check;
}
// $this->search();
if(!$this->getData('search')){
if($id==NULL){
$courseCats = $this->ApiCalls->getCourses('courseList');
$this->setData('courseCats', $courseCats);
}
else{
switch ($idType){
case 'optionGroupID':
$courseCats = $this->ApiCalls->getCourses('courseList', $id);
$this->setData('optiongroupID', $id);
break;
case 'catID':
$courseCats = $this->ApiCalls->getCourses('courseList', NULL, $id);
$this->setData('courseCats', $courseCats);
break;
case 'locationID':
$courseCats = $this->ApiCalls->getCourses('courseList', NULL, NULL, $id);
$this->setData('courseCats', $courseCats);
break;
case 'providerID':
$courseCats = $this->ApiCalls->getCourses('courseList', NULL, NULL, NULL, $id);
$this->setData('courseCats', $courseCats);
break;
}
}
}
$this->setData('cards', NULL);
$email = NULL;
if($this->getUser()){
$email = $this->getUser()->getEmail();
}
$resTools = $this->ApiCalls->getProfileTools($email);
$check = $this->handleDbErrors($resTools);
if($check===FALSE){
$this->setData('tools', $resTools);
}
else{
return $check;
}
$this->Breadcrumbs->setGroupName('courses');
$this->setData('breadcrumbsData', $this->Breadcrumbs->get());
return $this->render('courses/index.html.twig',
$this->getData()
);
}
public function options(){
$check = $this->commonCalls();
if(!$check){
return $check;
}
$courseCats = $this->ApiCalls->getCourses('options');
if($this->handleDbErrors($courseCats)===FALSE){
$this->setData('optionGroups', $courseCats);
}
$this->Breadcrumbs->setGroupName('courses');
$this->setData('breadcrumbsData', $this->Breadcrumbs->get());
$this->search();
if(!$this->getData('search')){
if($this->handleDbErrors($courseCats)===FALSE){
$this->setData('courseCats', $courseCats);
}
}
$email = NULL;
if($this->getUser()){
$email = $this->getUser()->getEmail();
}
$resTools = $this->ApiCalls->getProfileTools($email);
$check = $this->handleDbErrors($resTools);
if($check===FALSE){
$this->setData('tools', $resTools);
}
else{
return $check;
}
return $this->render('courses/options.html.twig',
$this->getData()
);
}
}