<?php
namespace WpBookingEventBlock\block_search_event;
use WpBookingEvent\Factory as FactoryAlias;
use WpBookingEvent\Mvc\Model\ModelList;
use WpBookingEvent\Utilities\Utility as UtilityAlias;
use WpBookingEventFrontend\app\helpers\DestinationHelper;

class block_search_event_helper {
    public static function getList_location(){
        $db= FactoryAlias::getDBO();
        $query=$db->getQuery(true);
        $query->select('country.countryname')
            ->from(UtilityAlias::getTableName('country').' AS country ')
            ->leftJoin(UtilityAlias::getTableName('state').' AS state ON state.country_id=country.id')
            ->select('state.id AS state_id')
            ->where('country.id=state.country_id')
        ;

        $list_country=$db->setQuery($query)->loadObjectList();
        foreach ($list_country as &$country) {
            $query->clear()
                ->select('location.name AS location_name, location.id AS location_id')
                ->from(UtilityAlias::getTableName('location').' AS location')
                ->where('location.state_id='.(int)$country->state_id)
                ;
            $list_location = $db->setQuery($query)->loadObjectList();
            $country->list_location = $list_location;
        }
       return $list_country;
    }
    public static function getList_eventtype(){
        $db= FactoryAlias::getDBO();
        $query=$db->getQuery(true);
        $query->select('eventtype.*')
            ->from(UtilityAlias::getTableName('eventtype').' AS eventtype ')
        ;

        $list_eventtypes=$db->setQuery($query)->loadObjectList();
       return $list_eventtypes;
    }

    public static function getList_employees(){
        $db=FactoryAlias::getDBO();
        $query=$db->getQuery(true);
        $query->select('employee.*')
            ->from(UtilityAlias::getTableName('employee').' AS employee')
        ;
        $list_employees=$db->setQuery($query)->loadObjectList();
        return $list_employees;
    }
}