File: /var/www/vhosts/creativefellows.nl/figi.creativefellows.nl/classes/FigiController copy.php
<?php
class FigiController extends CassetteController{
function __construct($db_connection,$router=null,$view=null,$settings=null)
{
$this->db = $db_connection;
$this->router = $router;
$this->view = $view;
$this->settings = $settings;
$this->client_settings = $this->getClientSettings();
$this->config = new BaseController($this->settings,$this->client_settings);
//die($this->getApiKey("wwwapi_getEvenementDetails"));
}
/*
* Generate API Key for get-a-ticket
*/
private function getApiKey($gat_scriptName)
{
return sha1(date("Y-m-d") ."GETATICKET_". $gat_scriptName .".cgi".$this->getTheaterId());
}
/*
* Get Theatre ID
*/
private function getTheaterId()
{
return $this->settings["get_a_ticket_theater_id"];
}
public function redirectShow($request, $response, $args)
{
// get data
$get = $request->getQueryParams();
$event_id = $get["event_id"];
// theater
if(isset($args["show"])) $show = $this->getTheatreshowDetails($event_id);
// cinmea
else $show = $this->getShowDetails($event_id);
return $response->withRedirect( $show->getShowLink() )->withStatus(301);
}
public function getIensWidget($request, $response, $args){
$html = '<h1>Reserveer een tafel</h1><div class="iens-frame" style="padding:0;"><iframe frameborder="0" height="500" name="frame1" src="https://module.lafourchette.com/nl_NL/module/349371-829ad#/2184753/pdh" width="420"></iframe></div>';
return $response->withStatus(200)->write($html);
}
/*
* Get the client settings
*/
private function getClientSettings()
{
$sql = "SELECT * FROM `instellingen` WHERE `id`='1'";
$sth = $this->db->prepare($sql);
$settings = $sth->execute();
if($settings) return $sth->fetch();
}
/*
* Get customer reviews
*/
public function getReviews($request, $response, $args)
{
$data = $this->getPage("reviews",0,0,0,false,4);
$reviews = [];
foreach($data as $review)
{
$data = [];
$data["naam"] = $review->getProperty("naam");
$data["review"] = $review->getProperty("review");
$data["plaats"] = $review->getProperty("plaatsnaam");
array_push($reviews,$data);
}
return $response->withHeader('Content-Type', 'application/json')->withStatus(200)->write(json_encode($reviews));
}
/*
* Cinema Tickets
*/
public function getCinemaTickets($request, $response, $args)
{
// get topbar navigation
$navigation = $this->getMainNavigation();
// get request contents
$page = $this->getPage("bioscoop-filmtheater");
// get data
$post = $request->getParsedBody();
// load genre
$this->genre_id = isset($post["genre-id"]) ? $post["genre-id"] : $this->getDefaultCategoryId();
$this->genre_name = isset($post["genre-name"]) ? $post["genre-name"] : $this->getDefaultCategoryName();
// load date
$this->dag_id = isset($post["date-id"]) ? $post["date-id"] : 0;
$this->dag_name = isset($post["date-name"]) ? $post["date-name"] : null;
//search term
$this->post_term = isset($post["term"]) && $post["term"] != "" ? $post["term"] : null;
if($this->post_term) $this->dag_id = null;
//die($this->post_term);
// all tickets
$this->tickets = $this->getCinemaTicketsByCategory(null,$this->dag_id,$this->post_term);
// return the page
return $this->view->render($response, $this->getViewCanvas($page[0]->page_canvas,$page[0]->pagination_view), array(
"cassette" => $this,
"config" => $this->config,
"router" => $this->router,
"page" => $page,
"navigation" => $navigation,
"section_name" => "bioscoop-filmtheater",
"tickets" => $this->tickets,
"search_label" => "film",
"date_selector" => $this->getWeekSelectButtons($this->dag_id,$this->dag_name),
"genre_selector" => $this->getGenreSelect("cinema",$this->getCinemaCategories(),$this->genre_id,$this->genre_name)
));
}
public function getCinemaTicketsCategory($request, $response, $args)
{
// get topbar navigation
$navigation = $this->getMainNavigation();
// get request contents
$page = $this->getPage($args["category"],0,0,0,true,0,true);
// getaticket category ID
$gat_genre_id = $page[0]->getProperty("getaticket_category_id");
// getaticket group ID
$gat_group_id = $page[0]->getProperty("getaticket_groep_id");// !== null ? $page[0]->getProperty("getaticket_groep_id") : null;
// get data
$post = $request->getParsedBody();
// all tickets
$this->tickets = $this->getCinemaTicketsByCategory($gat_genre_id,null,null,$gat_group_id);
// return the page
return $this->view->render($response, $this->getViewCanvas($page[0]->page_canvas,$page[0]->pagination_view), array(
"cassette" => $this,
"config" => $this->config,
"router" => $this->router,
"page" => $page,
"navigation" => $navigation,
"section_name" => $this->section_name,
"tickets" => $this->tickets,
"search_label" => "film",
"date_selector" => $this->getWeekSelectButtons($this->dag_id,$this->dag_name),
"genre_selector" => $this->getGenreSelect("cinema",$this->getCinemaCategories(),$this->genre_id,$this->genre_name)
));
}
/*
* Get 5 latest agenda items
*/
public function getLatestAgenda($request, $response, $args)
{
$options = [
"catincl" => implode("_",$this->getTheatreDefaultCategories()),
"type" => "v3",
"count" => 3
];
$data = $this->curlDownload("wwwapi_getListEvenementen",$options);
$events = [];
foreach($data["events"]["event"] as $event)
{
$events[] = new FigiEventController($event,$this->router->pathFor('GAT.theatreTickets'));
}
$shows = [];
foreach($events as $ev)
{
$arr = [];
$arr["artist"] = $ev->getArtist();
$arr["title"] = $ev->getLead();
$arr["date"] = $ev->getEventDateTime();
// $arr["time"] = $ev->getEventTime();
$arr["image"] = $ev->getImageSrc();
$arr["url"] = $ev->getShowLink();
array_push($shows,$arr);
}
return $response->withHeader('Content-Type', 'application/json')->withStatus(200)->write(json_encode($shows));
}
/*
* Get all agenda items in a month
*/
public function getAgenda($request, $response, $args)
{
// get topbar navigation
$navigation = $this->getMainNavigation();
// get request contents
$page = $this->getPage("agenda");
// get data
$post = $request->getParsedBody();
// load date
$this->month_id = isset($post["date-id"]) ? $post["date-id"] : $this->getCurrentMonthId();
$this->month_name = isset($post["month"]) ? $post["month"] : $this->getCurrentMonthName();
// get the agenda
$this->agenda = $this->getAgendaItems(date("d-m-Y"));
// return the page
return $this->view->render($response, $this->getViewCanvas($page[0]->page_canvas,$page[0]->pagination_view), array(
"cassette" => $this,
"config" => $this->config,
"router" => $this->router,
"page" => $page,
"navigation" => $navigation,
"section_name" => $this->section_name,
"agenda" => $this->agenda,
"date_selector" => $this->getMonthSelect($this->month_id,$this->month_name,"%d-%m-%Y"),
));
}
public function getAgendaItems($date = null)
{
// set current month
if($data == null) $data = $this->getCurrentMonthId();
// get events
$events = $this->getTheatreTicketsByMonth( $date );
// new calendar
$c = new CalendarController();
$c->setDate($date);
foreach($events as $event)
{
$cal_item = new CalendarItem([
"titel" => $event->getArtist(),
"datum" => $event->getTimeStamp(),
"tekst" => $event->getDescLong(),
"image" => $event->getImageSrc(),
"link" => $event->getShowLink(),
"genre" => $event->getGenre(),
"type" => $event->color
]);
$c->addDailyHtml($cal_item->getTitle(), $cal_item->getDate(),null,$cal_item->getType(),$cal_item->getReveal(),$cal_item->getRevealId());
}
return $c;
}
public function getAgendaMonth($request, $response, $args)
{
// get data
$post = $request->getParsedBody();
// get month
$calendar = $this->getAgendaItems( $post["date"] );
// return the calendar
return $response->withStatus(200)->write( $calendar->show() );
}
private function getTheatreTicketsByMonth($post_month=null,$label=null)
{
// theater tickets
$options = [
"catincl" => implode("_",$this->getTheatreDefaultCategories()),
"periode" => $post_month,
"type" => "v3"
];
$data = $this->curlDownload("wwwapi_getListEvenementen",$options);
// fix array structure if count == 1
if($data["events"]["totalCount"] == 1)
{
$temp = array(0 => $data["events"]["event"]);
$data["events"]["event"] = $temp;
}
// theater
$events = [];
foreach($data["events"]["event"] as $event)
{
$item = new FigiEventController($event,$this->router->pathFor('GAT.theatreTickets'));
$item->color= "theater";
$events[] = $item;
}
/*
* cinema specials
*/
$options = [
"periode" => $post_month,
"label" => 4,
"type" => "v3"
];
$data2 = $this->curlDownload("wwwapi_getListEvenementen",$options);
foreach($data2["events"]["event"] as $event)
{
$item = new FigiEventController($event,$this->router->pathFor('GAT.cinemaTickets'));
$item->color= "cinema";
$events[] = $item;
}
return $events;
}
/*
* Theatre Tickets
*/
public function getTheatreTickets($request, $response, $args)
{
// pagination
$this->pagination = isset($args["pagination"]) ? $args["pagination"] : 1;
// get topbar navigation
$navigation = $this->getMainNavigation();
// get request contents
$page = $this->getPage("theater");
// get data
$post = $request->getParsedBody();
// load genre
$this->genre_id = isset($post["genre-id"]) ? $post["genre-id"] : $this->getDefaultCategoryId();
$this->genre_name = isset($post["genre-name"]) ? $post["genre-name"] : $this->getDefaultCategoryName();
// load date
$this->month_id = isset($post["date-id"]) ? $post["date-id"] : $this->getCurrentMonthId();
$this->month_name = isset($post["date-name"]) ? $post["date-name"] : $this->getCurrentMonthName();
if( isset($args["genre"] ) && $args["genre"] != 0) $this->genre_id = $args["genre"];
elseif($this->genre_id == 0) $this->genre_id = null;
if( isset($args["date"]) ) $this->month_id = $args["date"];
// all tickets
$this->tickets = $this->getTheatreTicketsByPage($this->pagination,$this->genre_id,$this->month_id);
// return the page
return $this->view->render($response, $this->getViewCanvas($page[0]->page_canvas,$page[0]->pagination_view), array(
"cassette" => $this,
"config" => $this->config,
"router" => $this->router,
"page" => $page,
"navigation" => $navigation,
"section_name" => "theater",
"tickets" => $this->tickets,
"date_selector" => $this->getMonthSelect($this->month_id,$this->month_name),
"genre_selector" => $this->getGenreSelect("theatre",$this->getTheatreCategories(),$this->genre_id,$this->genre_name),
"pagination" => $this->getPagination("theater",$this->pagination),
"active_page" => $this->pagination
));
}
/*
* Get al categories in theatre
*/
public function getTheatreCategories()
{
/*
$data = $this->curlDownload("wwwapi_getCategories",[]);
$categories = [];
// d($data);
// die();
foreach($data["categories"]["categorie"] as $cat){
//if(!in_array($cat["id"],$this->getTheatreDefaultCategories()) ) continue;
$categories[] = new FigiCategoryController($cat,$this->router->pathFor('GAT.viewtickets'));
}
return $categories;
*/
$data = $this->curlDownload("wwwapi_getGenresList",[]);
$categories = [];
//d($data);
foreach($data["genres"]["genre"] as $cat){
if(!in_array($cat["id"],$this->getTheatreDefaultGenres()) ) continue;
$categories[] = new FigiCategoryController($cat,$this->router->pathFor('GAT.viewtickets'));
}
return $categories;
}
public function getTheatreTicketsByPage($page=0,$post_category=null,$post_month=null,$search_query=null,$clicked_element=null)
{
// show all categories or specific post
$view_category = $post_category == null ? "" : $post_category;
$options = [
"vanaf" => 2,
"catincl" => implode("_",$this->getTheatreDefaultCategories()),
"genre_id" => $view_category,
"periode" => $post_month,
"type" => "v3"
];
// only show items from post month
if($clicked_element == "#date-id") unset($options["genre_id"]);
elseif($clicked_element == "#genre-id") unset($options["periode"]);
//d($options);
// search not null
if($search_query != null)
{
$options = [
"vanaf" => 2,
"catincl" => implode("_",$this->getTheatreDefaultCategories()),
//"genre_id" => $view_category,
//"periode" => $post_month,
"type" => "v3",
"term" => $search_query
];
}
$data = $this->curlDownload("wwwapi_getListEvenementen",$options);
// load next month if nu results
if($data["events"]["totalCount"] == 0 && $search_query == null){
$cur_month = intval(substr($post_month,-2));
$nextMonth = $cur_month + 1;
$yyyymm = strftime("%Y%m",mktime(0, 0, 0, $nextMonth, 1));
return $this->getTheatreTicketsByPage($page,$post_category,$yyyymm,$search_query);
}
// fix array structure if count == 1
if($data["events"]["totalCount"] == 1)
{
$temp = array(0 => $data["events"]["event"]);
$data["events"]["event"] = $temp;
}
// set total number of events from API
//$this->setEventCount($data["events"]["totalCount"]);
$events = [];
foreach($data["events"]["event"] as $event)
{
$events[] = new FigiEventController($event,$this->router->pathFor('GAT.theatreTickets'));
}
return $events;
}
public function searchTickets($request, $response, $args)
{
// get data
$post = $request->getParsedBody();
// post data
$date = $post["date"];
$category = ($post["category"] != 0) ? $post["category"] : null;
$type = $post["type"];
$cat_name = $post["name"];
//$page = $post["page"];
$genre = ($post["genre"] != 0) ? $post["genre"] : null;
$group = ($post["group"] != 0) ? $post["group"] : null;
$q = $post["q"];
$clicked = isset($post["clicked"]) ? $post["clicked"] : null;
// get tickest by date and category and type
switch($type)
{
case "cinema":
$tickets = $this->getCinemaTicketsByCategory($genre,$date,$q,$group);
break;
case "theatre":
$tickets = $this->getTheatreTicketsByPage(0,$category,$date,$q,$clicked);
break;
}
$ticket_arr = [];
foreach($tickets as $ticket)
{
$data = [];
$data["image"] = $ticket->getImageSrc();
$data["link"] = $ticket->getShowLink();
$data["artist"] = $ticket->getArtist();
$data["lead"] = $ticket->getLead();
$data["date"] = $ticket->getEventDate();
$data["icon"] = $ticket->getDateIcon();
$data["genre"] = $ticket->getGenre();
$ticket_arr["tickets"][]= $data;
}
$ticket_arr["meta"] = [
"category" => $cat_name,
"total" => $this->getEventCount(),
"pagination" => $this->getPagination($type,$page)
];
return $response->withHeader('Content-Type', 'application/json')->withStatus(200)->write(json_encode($ticket_arr));
}
/*
* View a specific Cinema show
*/
public function getShow($request, $response, $args)
{
// get topbar navigation
$navigation = $this->getMainNavigation();
// get request contents
$page = $this->getPage("theater");
// get arguments
$this->show_id = isset($args["code"]) ? $args["code"] : 0;
$this->show_name = isset($args["name"]) ? $args["name"] : 0;
// get show contents
$show = $this->getShowDetails($this->show_id);
// set meta title
$page[0]->meta_title = $show->getArtist() ." - ". $show->getLead();
// return the page
return $this->view->render($response, "view.cinema_details.php", array(
"cassette" => $this,
"config" => $this->config,
"router" => $this->router,
"page" => $page,
"section_name" => "bioscoop-filmtheater",
"navigation" => $navigation,
"show" => $show,
//"show_date_selector"=> $this->getShowSelect($show->event_shows),
//"first_show_id" => $this->getFirstShowId($show->speeldagen),
"alternative_shows" => $this->getShowAlternatives($show->alternatieven["alternatief"])
));
}
/*
* View a specific Theatre show
*/
public function getTheatre($request, $response, $args)
{
// get topbar navigation
$navigation = $this->getMainNavigation();
// get request contents
$page = $this->getPage("theater");
// get arguments
$this->show_id = isset($args["code"]) ? $args["code"] : 0;
$this->show_name = isset($args["name"]) ? $args["name"] : 0;
// get show contents
$show = $this->getTheatreshowDetails($this->show_id);
// set meta title
$page[0]->meta_title = $show->getArtist() ." - ". $show->getLead();
// return the page
return $this->view->render($response, "view.theatre_details.php", array(
"cassette" => $this,
"config" => $this->config,
"router" => $this->router,
"page" => $page,
"section_name" => "theater",
"navigation" => $navigation,
"show" => $show,
// "show_date_selector"=> $this->getShowSelect($show->event_shows),
// "first_show_id" => $this->getFirstShowId($show->speeldagen),
"alternative_shows" => $this->getShowAlternatives($show->alternatieven["alternatief"])
));
}
/*
* List movies with genre and date
*/
private function getCinemaTicketsByCategory($genre_id = null,$dag_id = null,$search=null,$group_id=null)
{
$options = [
"catincl" => $this->getCinemaDefaultCategories(),
"type" => "v3"
];
if($genre_id !== null && is_numeric($genre_id)) $options["genre_id"] = $genre_id;
if($group_id !== null) $options["label"] = $group_id;
if($dag_id !== null) $options["dag"] = $dag_id;
if($search !== null) $options["term"] = $search;
// d($options);
// die();
$data = $this->curlDownload("wwwapi_getListFilms",$options);
$events = [];
$movie_names = [];
// fix array structure if count == 1
if(!empty($data["events"]) && !is_array($data["events"]["event"][0]))
{
$temp = array(0 => $data["events"]["event"]);
$data["events"]["event"] = $temp;
}
foreach((array) $data["events"]["event"] as $event)
{
if( in_array($event["artiest"],$movie_names) ) continue;
$events[] = new FigiEventController($event,$this->router->pathFor('GAT.viewtickets'));
$movie_names[] = $event["artiest"];
}
return $events;
}
/*
* Get the details of a show
*/
private function getShowDetails($show_id)
{
// show data
$options = [
"event" => $show_id
];
$data = $this->curlDownload("wwwapi_getFilmDetails",$options);
// get all shows
$options1 = [
"type" => "v3",
"term" => trim(preg_replace("/-/","_",$this->validDbName($data["event"]["artiest"]))),
"genre_id" => $data["event"]["genreId"]
];
$event_shows = $this->curlDownload("wwwapi_getListEvenementen",$options1);
return new FigiEventController($data["event"],$this->router->pathFor('GAT.viewtickets'),$event_shows);
}
private function validDbName($name)
{
$replace_chars = array('Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y', 'ü'=>'u',
"?" => " ","!" => " ","(" => " ",")" => " ","’" => "'"
);
$valid = strtr( $name, $replace_chars );
return trim(preg_replace("/[^a-zA-Z0-9]/","_",$valid));
}
/*
* Get the details of a theatre show
*/
private function getTheatreshowDetails($show_id)
{
// show data
$options = [
"type" => "v3",
"event" => $show_id
];
$data = $this->curlDownload("wwwapi_getEvenementDetails",$options);
//d($data);
return new FigiEventController($data["event"],$this->router->pathFor('GAT.theatreTickets'));
}
/*
* Get the details of a show
*/
private function getCinemaCategories()
{
$options = [
"categorie" => $this->getCinemaDefaultCategories()
];
$data = $this->curlDownload("wwwapi_getGenresList",$options);
$genres = [];
foreach($data["genres"]["genre"] as $event){
$genres[] = new FigiEventController($event,$this->router->pathFor('GAT.viewtickets'));
}
return $genres;
}
/*
* Get details of related shows
*/
private function getShowAlternatives($alt_opions)
{
$alt_array = [];
foreach($alt_opions as $show)
{
$code = $show["@attributes"]["code"];
// show data
$options = [
"event" => $code
];
$event = $this->curlDownload("wwwapi_getFilmDetails",$options);
$alt_array[] = new FigiEventController($event["event"],$this->router->pathFor('GAT.viewtickets'));
}
return $alt_array;
}
/*
* Get the data with the GAT API
*/
private function curlDownload($gat_scriptName,$options=null)
{
// get the api key with function name
$key = $this->getApiKey($gat_scriptName);
//die($key);
//default options
$options_array = [
'theater' => $this->getTheaterId(),
'key' => $key//,
//'type' => 'v2',
];
//extended options
if($options)
{
foreach($options as $o => $value)
{
$options_array[$o] = $value;
}
}
// init curl request
$ch = curl_init();
$curlConfig = array(
CURLOPT_URL => "https://getaticket.nl/cgi-bin/". $gat_scriptName .".cgi",
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $options_array
);
curl_setopt_array($ch, $curlConfig);
$data = curl_exec($ch);
curl_close($ch);
// return data as JSON
return json_decode(json_encode(simplexml_load_string($data)), true);
}
/*
* Get ID of the first show from array
*/
private function getFirstShowId($shows_array)
{
if(isset($shows_array["speeldag"][0])) return $shows_array["speeldag"][0]["tijdstippen"]["tijdstip"]["@attributes"]["code"];
else return $shows_array["speeldag"]["tijdstippen"]["tijdstip"]["@attributes"]["code"];
//d($shows_array["speeldag"]);
}
/*
* Fake week selector
*/
public function getShowSelect($shows_array)
{
//$active_id = "";
//if(isset($shows_array["speeldag"][0])) $active_name = $shows_array["speeldag"][0]["datum"] == date("Y-m-d") ? "Vandaag" : strftime("%a %e %B",strtotime($shows_array["speeldag"][0]["datum"]));
//else $active_name = $shows_array["speeldag"]["datum"] == date("Y-m-d") ? "Vandaag" : strftime("%a %e %B",strtotime($shows_array["speeldag"]["datum"]));
$active_name = strftime("%Y-%m-%d",strtotime($shows_array[0]["start"])) == date("Y-m-d") ? strftime("Vandaag - %H:%M",strtotime($shows_array[0]["start"])) : strftime("%a %e %B om %H:%M uur",strtotime($shows_array[0]["start"])) ;
//$shows_array[0] strftime("%a %e %B",strtotime($shows_array["speeldag"][0]["datum"]));
$active_id = $shows_array[0]["id"];
$today = date('Y-m-d');
$html = '<div class="fake-input-element" data-update-element="#order-tickets" data-id="#date-id" data-name="#date-name" >';
$html .= '<input type="hidden" name="date-id" id="date-id" value="'. $active_id .'"/>';
$html .= '<input type="hidden" name="date-name" id="date-name" value="'. $active_name .'"/>';
$html .= '<div class="form-text fake-input not-selected">';
$html .= '<div class="current-element"><i class="fa fa-caret-down" aria-hidden="true"></i><span>'. $active_name .'</span></div>';
$html .= '</div>';
$html .= '<div class="fake-input-values hidden">';
$html .= '<ul class="fake-input-selector">';
foreach($shows_array as $show)
{
$show_label = strftime("%Y-%m-%d",strtotime($show["start"])) == date("Y-m-d") ? strftime("Vandaag - %H:%M",strtotime($show["start"])) : strftime("%a %e %B - %H:%M",strtotime($show["start"]));
$html .= '<li><a href="'. $this->getTicketOrderUrl() . $show["id"] .'" data-value="'. $this->getTicketOrderUrl() . $show["id"] .'" data-label="'. strftime("%H:%M uur",strtotime($show["start"])) .'" class="option">'. $show_label .'</a></li>';
}
//if( isset($shows_array["speeldag"]) ){
//d($shows_array);
/*foreach($shows_array["speeldag"] as $day){
foreach($day["tijdstippen"] as $show_on_time)
{
if(!is_array($show_on_time[0]))
{
$html .= '<li>';
$html .= '<a href="#" data-value="'. $show_on_time["@attributes"]["code"] .'" data-label="'. $day["datum"] .'" class="option">';
$html .= strftime("%a %e %B",strtotime($day["datum"]))." (". $show_on_time["aanvang"] ."-". $show_on_time["einde"] .")";
$html .= '</a>';
$html .= '</li>';
}
else{
foreach($show_on_time as $day_show)
{
$html .= '<li>';
$html .= '<a href="#" data-value="'. $day_show["@attributes"]["code"] .'" data-label="'. $day["datum"] .'" class="option">';
$html .= strftime("%a %e %B",strtotime($day["datum"]))." (". $day_show["aanvang"] ."-". $day_show["einde"] .")";
$html .= '</a>';
$html .= '</li>';
}
}
}
}*/
//}
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
$html .= '<a id="order-tickets" href="https://getaticket.nl/figi/bestellen/s'. $active_id .'" class="button primary expanded">Tickets kopen</a>';
$html .= '<br />';
return $html;
}
/*
* Fake week selector
*/
private function getWeekSelect($active_dag_id,$active_dag_name)
{
$active_id = $active_dag_id == null ? 0 : $active_dag_id;
$active_name = $active_dag_name == null ? "Vandaag" : $active_dag_name;
$today = date('Y-m-d');
$html = '<div class="fake-input-element" data-id="#date-id" data-name="#date-name">';
$html .= '<input type="hidden" name="date-id" id="date-id" value="'. $active_id .'"/>';
$html .= '<input type="hidden" name="date-name" id="date-name" value="'. $active_name .'"/>';
$html .= '<div class="form-text fake-input not-selected">';
$html .= '<div class="current-element"><i class="fa fa-caret-down" aria-hidden="true"></i><span>'. $active_name .'</span></div>';
$html .= '</div>';
$html .= '<div class="fake-input-values hidden">';
$html .= '<ul class="fake-input-selector">';
for($x=0;$x<=6;$x++)
{
$html .= '<li>';
$html .= '<a href="#" data-value="'. $x .'" data-label="'. strftime("%a %e %B",strtotime("$today + $x days")) .'" class="option">';
switch($x){
case 0:
$html .= 'Vandaag';
break;
//case 1:
// $html .= 'Morgen';
//break;
default:
$html .= strftime("%a %e %B",strtotime("$today + $x days"));
break;
}
$html .= '</a>';
$html .= '</li>';
}
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
private function getMonthSelect($active_month_id,$active_month_name,$format="%Y%m")
{
$active_id = $active_month_id == null ? 0 : $active_month_id;
$active_name = $active_month_name;
$month = substr($active_id, 4, 2);
$active_name = strftime("%B %Y",mktime(0, 0, 0, ltrim($month, '0'), 1));
$today = date('Y-m-d');
$html = '<div class="fake-input-element" data-id="#date-id" data-name="#date-name">';
$html .= '<input type="hidden" name="date-id" id="date-id" value="'. $active_id .'"/>';
$html .= '<input type="hidden" name="date-name" id="date-name" value="'. $active_name .'"/>';
$html .= '<div class="form-text fake-input not-selected">';
$html .= '<div class="current-element"><i class="fa fa-caret-down" aria-hidden="true"></i><span>'. ucfirst($active_name) .'</span></div>';
$html .= '</div>';
$html .= '<div class="fake-input-values hidden">';
$html .= '<ul class="fake-input-selector">';
$currentMonth = date('m');
for($x = $currentMonth; $x < $currentMonth + 13; $x++) {
$html .= '<li>';
$html .= '<a href="#" data-value="'. strftime($format,mktime(0, 0, 0, $x, 1)) .'" data-label="'. strftime("%a %e %B",strtotime("$today + $x days")) .'" class="option">';
$html .= ucfirst(strftime("%B %Y",mktime(0, 0, 0, $x, 1)));
$html .= '</a>';
$html .= '</li>';
}
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
private function getWeekSelectButtons($active_dag_id,$active_dag_name)
{
$active_id = $active_dag_id == null ? 0 : $active_dag_id;
$active_name = $active_dag_name == null ? "Vandaag" : $active_dag_name;
$today = date('Y-m-d');
//$today_id = 4;//date('N',strtotime($today));
$html = '<div class="fake-input-element weekdays-select" data-id="#date-id" data-name="#date-name" data-type="cinema">';
$html .= '<input type="hidden" name="date-id" id="date-id" value="'. $active_id .'"/>';
$html .= '<input type="hidden" name="date-name" id="date-name" value="'. $active_name .'"/>';
$html .= '<div class="form-text fake-input not-selected hide">';
$html .= '<div class="current-element"><i class="fa fa-caret-down" aria-hidden="true"></i><span>'. $active_name .'</span></div>';
$html .= '</div>';
$html .= '<div class="fake-input-values">';
$html .= '<ul class="fake-input-selector no-bullet">';
for($x=0;$x<=8;$x++)
{
$x_day = $x;//+4;
$data_label = strftime("%a %e %B",strtotime("$today + $x_day days"));
$day_id = date('N',strtotime("$today + $x_day days"));
// toon dat als kleiner dan woensdag of na woensdag
// if($day_id <= 3 && $today_id <= $day_id || $day_id > 3 && $today_id >= $day_id )
// {
$html .= '<li>';
$html .= '<a href="#" data-value="'. $x .'" data-filter="day" data-label="'. $data_label .'" class="option'. ($x == 0 ? " current" : "") .'">';
switch($x)
{
case 0:
$html .= 'Vandaag';
break;
default:
$html .= strftime("%a %e %b",strtotime("$today + $x_day days"));
break;
}
$html .= '</a>';
$html .= '</li>';
// }
}
$html .= '<li class="devider clear-mobile"><a href="#" data-genre="0" data-group-id="1" class="option">Kinderfilms</a></li>';
$html .= '<li><a href="#" data-genre="0" data-group-id="4" class="option secondary">Filmspecials</a></li>';
$html .= '<li class="devider"><a href="#" class="option search" data-search="1" data-toggle="panel"><i class="fal fa-search"></i></a></li>';
// $html .= '<li><inut type="text" name="term" id="term" value="" placeholder="Zoek een film" style="margin:0;width:100%"/></li>';
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
/*
* Fake Genre selector
*/
private function getGenreSelect($ticket_type,$ticket_categories,$active_genre_id = null,$active_genre_name = null)
{
$active_id = $active_genre_id == null ? $this->getDefaultCategoryId() : $active_genre_id;
$active_name = $active_genre_name == null ? $this->getDefaultCategoryName() : $active_genre_name;
//echo "v=".$active_name;
foreach($ticket_categories as $cat) {
if ($active_id == $cat->id) {
$active_name = $cat->descr;
}
}
$html = '<div class="fake-input-element" data-id="#genre-id" data-name="#genre-name">';
$html .= '<input type="hidden" name="genre-id" id="genre-id" value="'. $active_id .'"/>';
$html .= '<input type="hidden" name="genre-name" id="genre-name" value="'. $active_name .'"/>';
$html .= '<input type="hidden" name="ticket-type" id="ticket-type" value="'. $ticket_type .'"/>';
$html .= '<div class="form-text fake-input not-selected">';
$html .= '<div class="current-element"><i class="fa fa-caret-down" aria-hidden="true"></i><span>'. $active_name .'</span></div>';
$html .= '</div>';
$html .= '<div class="fake-input-values hidden">';
$html .= '<ul class="fake-input-selector">';
foreach($ticket_categories as $category)
{
$html .= '<li>';
$html .= '<a href="#" data-value="'. $category->getCategoryId() .'" data-label="'. $category->getCategoryName() .'" class="option">';
$html .= $category->getCategoryName();
$html .= '</a>';
$html .= '</li>';
}
$html .= '<li>';
$html .= '<a href="#" data-value="'. $this->getDefaultCategoryId() .'" data-label="'. $this->getDefaultCategoryName() .'" class="option">';
$html .= $this->getDefaultCategoryName();
$html .= '</a>';
$html .= '</li>';
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
/*
* Get Default theatre categories
*/
private function getTheatreDefaultCategories()
{
return $this->settings["defaults"]["theatre_categories"];
}
private function getTheatreDefaultGenres()
{
return $this->settings["defaults"]["theatre_genres"];
}
/*
* Get Default cinemacategories
*/
private function getCinemaDefaultCategories()
{
return implode("_",$this->settings["defaults"]["cinema_categories"]);
}
private function getDefaultCategoryId()
{
return $this->settings["defaults"]["category_id"];
}
private function getTicketOrderUrl()
{
return $this->settings["defaults"]["order_url"];
}
private function getDefaultCategoryName()
{
return $this->settings["defaults"]["category_name"];
}
private function getAgendaCategory()
{
return $this->settings["defaults"]["agenda_cat_id"];
}
private function getItemsPerPage()
{
return $this->settings["defaults"]["items_per_page"];
}
// set total event
private function setEventCount($count)
{
$this->showCount = $count;
}
// get total event
private function getEventCount()
{
return $this->showCount;
}
// get pagination
private function getPagination($section_name,$active_page)
{
if($this->getPageNumbers() <= 1) return "";
$html = '<ul class="pagination" role="navigation" aria-label="Pagination">';
if($active_page == 1) $html .= '<li class="pagination-previous disabled">Vorige <span class="show-for-sr">pagina</span></li>';
else $html .= '<li class="pagination-previous"><a href="'. $section_name .'/'. ($active_page-1) .'" aria-label="Vorige pagina" data-page="'. ($active_page - 1) .'">Vorige <span class="show-for-sr">pagina</span></a></li>';
for($i=1;$i <= $this->getPageNumbers();$i++)
{
if( $active_page == $i) $html .= '<li class="current" data-ids="'. $active_page ."==". $i .'"><span class="show-for-sr">Huidig: </span> '. $i .'</li>';
else $html .= '<li data-ids="'. $active_page ."==". $i .'"><a href="'. $section_name .'/'. $i .'" aria-label="Page '. $i .'" data-page="'. $i .'">'. $i .'</a></li>';
}
if($active_page >= $this->getPageNumbers()) $html .= '<li class="pagination-next disabled">Volgende <span class="show-for-sr">pagina</span></li>';
else $html .= '<li class="pagination-next"><a href="'. $section_name .'/'. ($active_page+1).'" aria-label="Next page" data-page="'. ($active_page + 1) .'">Volgende <span class="show-for-sr">pagina</span></a></li>';
$html .= '</ul>';
return $html;
}
private function getPageNumbers()
{
return round($this->getEventCount() / $this->getItemsPerPage());
}
private function getCurrentMonthId()
{
return strftime("%Y%m",mktime(0, 0, 0, date('m'), 1));
}
private function getCurrentMonthName()
{
return ucfirst(strftime("%B",mktime(0, 0, 0, date('m'), 1)));
}
}
?>