<?php
 class Temp_course extends Controller
 {
     function Temp_course()
	 {
	     parent::Controller();
	 }
	 
	function index(){
		
		if(!hun()){
		//	redirect('interior/workshop/reception_room');
			Header("HTTP/1.1 301 Moved Permanently");
			Header("Location: http://www.archlinexp.com/interior/workshop/reception_room");
		}
		else{
			Header("HTTP/1.1 301 Moved Permanently");
			Header("Location: http://www.archline.hu/interior/workshop/nappali");
		//	redirect('interior/workshop/nappali');
		}
		
		$this->load->model('mevents');
        //loading library for current date display
        $this->load->library('dateclass');
        
        if($this->muser->user['lang'] == "hun")
			$lang = 1;
		else
			$lang = 2;
		
		$main_events = $this->mevents->getWorkshop($lang, true);
        
        if(!$main_events){
            redirect('workshop/no_main_event');
        }
        
        $data['lang'] = $this->muser->user['lang'];
		$data['title'] = hun() ? 'Kurzusok - ARCHLine.XP CAD Software' : 'Courses - ARCHLine.XP CAD Software';
		$data['tartalom'] = 'temp_course/welcome_new4';
        $data['javascript'] = array('jquery_ui','fancybox/jquery-1.3.2.min','fancybox/jquery.easing.1.3','fancybox/jquery.fancybox-1.2.1.pack','fancybox/fancy');
        $data['style'] = array('jquery.ui','fancybox2');
		$data['csik'] = array('home', 'courses');
        $data['error'] = false;
        
        $kepek = array(
                	14 => "/public/img/workshop/ENG/workshop_kitchen.jpg",
                	15 => "/public/img/workshop/ENG/workshop_reception.jpg",
                	16 => "/public/img/workshop/ENG/workshop_bathroom.jpg",
                	19 => "/public/img/workshop/ENG/workshop_commercial_I.jpg",
                	20 => "/public/img/workshop/ENG/workshop_awning.jpg",
                	21 => "/public/img/workshop/ENG/workshop_loft.jpg",
                	22 => "/public/img/workshop/ENG/workshop_virtual.jpg",
                	23 => "/public/img/workshop/ENG/workshop_stairs.jpg",
                	30 => "/public/img/workshop/ENG/workshop_commercial_II.jpg",
                	35 => "/public/img/workshop/ENG/workshop_KBB2011.jpg",
					36 => "/public/img/workshop/ENG/workshop_2011.jpg",
                	
                	
                	
                	10 => "/public/img/workshop/HUN/workshop_kitchen.jpg",
                	11 => "/public/img/workshop/HUN/workshop_reception.jpg",
                	13 => "/public/img/workshop/HUN/workshop_bathroom.jpg",
                	24 => "/public/img/workshop/HUN/workshop_virtual.jpg",
                	25 => "/public/img/workshop/HUN/workshop_awning.jpg",
                	26 => "/public/img/workshop/HUN/workshop_commercial_I.jpg",
                	27 => "/public/img/workshop/HUN/workshop_stairs.jpg",
                	28 => "/public/img/workshop/HUN/workshop_loft.jpg",
                	29 => "/public/img/workshop/HUN/workshop_commercial_II.jpg",
                	31 => "/public/img/workshop/HUN/workshop_thea.jpg",
                	32 => "/public/img/workshop/HUN/workshop_construma2011.jpg",
                	34 => "/public/img/workshop/HUN/workshop_2011.jpg"
                );
         
         $szintek = array(
                //	10 => "HALADÓ SZINT",
                	11 => "KEZDŐ SZINT",
                	//13 => "Középhaladó szint",
                	28 => "HALADÓ SZINT",
                //	25 => "Haladó szint",
                //	26 => "Haladó szint",
                //	27 => "Haladó szint",
                //	28 => "Haladó szint"
                );
        
        foreach($main_events as $key => $main_event){
            $results = $this->mevents->getEventDatesByDay($main_event->event_main_id, true);
            $main_events[$key]->events = $results['events'];
            $main_events[$key]->times = $results['times'];
            $id = $main_event->event_main_id;
            $main_event->thumbnail_name = $kepek[$id];
            if( isset($szintek[$id]) )
            	$main_event->szint = $szintek[$id];
            else
            	$main_event->szint = "";
        }
        
        $data['main_events'] = $main_events;
        
        $this->load->view('temp_course/site',$data);
	}
 
 
	function naptar(){
		$this->load->model('mevents');
		
		if($this->muser->user['lang'] == "hun")
			$lang = 1;
		else
			$lang = 2;
		
		$main_events = $this->mevents->getWorkshop($lang, true);
		
		$urlveg = $this->uri->segment(3);
		
		$data['event'] = $this->db->query("SELECT * FROM events_new_main WHERE urlname = '".$urlveg."' AND language_id = ".$lang)->row();
		$data['dates'] = $this->db->query("SELECT * FROM events_new WHERE event_main_id = '".$data['event']->event_main_id."' AND active = 1 AND deleted = 0 ORDER BY start_ts")->result();
		
		
		
	//	if( $_SERVER['REMOTE_ADDR'] == "78.92.152.8" && strstr($_SERVER['HTTP_USER_AGENT'],"inux") )
			$data['tartalom'] = 'temp_course/nagyonujws';
	//	else
	//		$data['tartalom'] = 'temp_course/naptarral';
		
		$data['title'] = hun() ? 'Kurzusok - ARCHLine.XP CAD Software' : 'Workshop - ARCHLine.XP CAD Software';
		$data['javascript'] = array('jquery_ui','fancybox/jquery-1.3.2.min','fancybox/jquery.easing.1.3','fancybox/jquery.fancybox-1.2.1.pack','fancybox/fancy');
		$data['style'] = array('jquery.ui','fancybox2');
		$data['csik'] = array('home', 'courses');
		
		$this->load->view('site',$data);
	}
	
 	
 	function naptargen(){
 		$this->load->model('mevents');
        $this->load->library('dateclass');
		
		$main_events = $this->mevents->getWorkshop($this->muser->user['lang'], true);
        $esemenyek = array();
        
        $data['lang'] = $this->muser->user['lang'];
        $data['style'] = array('jquery.ui');
        
        $uri = explode("/", str_ireplace( "", "", $_SERVER[ 'REQUEST_URI'] ) );
		//print_r($uri);
		if( is_numeric($uri[3]) && is_numeric($uri[4]) && is_numeric($uri[5]) ){
			$honap = $uri[3];
			$ev = $uri[4];
		}else{
			$most = getdate();
			$honap = $most['mon'];
			$ev = $most['year'];
		}
        $esemenyek = $this->mevents->getEventDatesByMonth($honap,$ev,true);
        
        $data['esemenyek'] = $esemenyek;
        $this->load->view('temp_course/naptar',$data);
 	}
 
 
 }



?>