<?php
class Buy extends Controller
{
	function Buy()
	{
		parent::Controller();
	}

	function index()
	{
		$data['lang']=$this->muser->user['lang'];
		
		$data['title'] = hun() ? 'ARCHLine.XP CAD Software - Vásárlás' : 'ARCHLine.XP CAD Software - Purchase';
		$data['tartalom']='buy/index';
		$data['csik']=array('home','buy');
		if(hun())
		{
			$this->buyegyben2013();
			return;
			//$data['cimlap']=$this->mpages->get_row(110);		2011-es
			$data['cimlap']=$this->mpages->get_row(648);
		}
		elseif(eng())
		{
			$data['cimlap']=$this->mpages->get_row(111);
		}
		elseif(be())
		{
			$data['cimlap']=$this->mpages->get_row(343);
		}
		elseif(cr())
		{
			$data['cimlap']=$this->mpages->get_row(251);
		}
		elseif(gr())
		{
			$data['cimlap']=$this->mpages->get_row(206);
		}
		elseif(jap())
		{
			$data['cimlap']=$this->mpages->get_row(150);
		}

		$this->load->view('site',$data);
	}

	function check()
	{
		$temp="";
		if($this->input->post('pr25') && is_numeric($this->input->post('pr25')))
		{
			if($this->input->post('currency25')=='eur')
	           	$temp.='&PRODUCT[300357096]='.$this->input->post('pr25');
			elseif($this->input->post('currency25')=='gbp')
	          	$temp.='&PRODUCT[300300561]='.$this->input->post('pr25');
		}
		
		if($this->input->post('pr30') && is_numeric($this->input->post('pr30')))
		{
            if($this->input->post('currency30')=='eur')
	           	$temp.='&PRODUCT[300300560]='.$this->input->post('pr30');
			elseif($this->input->post('currency30')=='gbp')
	           	$temp.='&PRODUCT[300300560]='.$this->input->post('pr30');
		}

		if($this->input->post('pr35') && is_numeric($this->input->post('pr35')))
		{
            if($this->input->post('currency35')=='eur')
	           	$temp.='&PRODUCT[300357097]='.$this->input->post('pr35');
			elseif($this->input->post('currency35')=='gbp')
	           	$temp.='&PRODUCT[300357090]='.$this->input->post('pr35');
		}
		
		// interior
		if( is_numeric($this->input->post('dbint')) && $this->input->post('dbint') > 0 )
		{
            if($this->input->post('valuta')=='eur'){
	           	//$temp.='&PRODUCT[300357097]='.$this->input->post('dbint');
				$temp.='&PRODUCT[300357096]='.$this->input->post('dbint');
			}elseif($this->input->post('valuta')=='gbp'){
	           	//$temp.='&PRODUCT[300357096]='.$this->input->post('dbint');
				$temp.='&PRODUCT[300300561]='.$this->input->post('dbint');
			}elseif($this->input->post('valuta')=='usd'){
				$temp.='&PRODUCT[300500917]='.$this->input->post('dbint');
			}
		}
		
		// render
		if( is_numeric($this->input->post('dbren')) && $this->input->post('dbren') > 0 )
		{
            if($this->input->post('valutarender')=='eur')
	           	$temp.='&PRODUCT[300505884]='.$this->input->post('dbren');
			elseif($this->input->post('valutarender')=='gbp')
	           	$temp.='&PRODUCT[300162430]='.$this->input->post('dbren');
		}
		
		// animáció
		if( is_numeric($this->input->post('dbani')) && $this->input->post('dbani') > 0 )
		{
            if($this->input->post('valutaanimacio')=='eur')
	           	$temp.='&PRODUCT[300505886]='.$this->input->post('dbani');
			elseif($this->input->post('valutaanimacio')=='gbp')
	           	$temp.='&PRODUCT[300505876]='.$this->input->post('dbani');
		}
		
		// 3DTV
		if( is_numeric($this->input->post('db3d')) && $this->input->post('db3d') > 0 )
		{
            if($this->input->post('valuta3dtv')=='eur')
	           	$temp.='&PRODUCT[300496927]='.$this->input->post('db3d');
			elseif($this->input->post('valuta3dtv')=='gbp')
	           	$temp.='&PRODUCT[300496926]='.$this->input->post('db3d');
		}
		
		// virtual staging
		if( is_numeric($this->input->post('dbvt')) && $this->input->post('dbvt') > 0 )
		{
            if($this->input->post('valutavs')=='eur')
	           	$temp.='&PRODUCT[300505888]='.$this->input->post('dbvt');
			elseif($this->input->post('valutavs')=='gbp')
	           	$temp.='&PRODUCT[300505880]='.$this->input->post('dbvt');
		}

		if($this->input->post('pr23')) $temp.='&PRODUCT[300161018]='.$this->input->post('pr23');
		if($this->input->post('pr24')) $temp.='&PRODUCT[300300560]='.$this->input->post('pr24');
		if($this->input->post('pr26')) $temp.='&PRODUCT[300308301]='.$this->input->post('pr26');
        if($this->input->post('pr29')) $temp.='&PRODUCT[300161029]='.$this->input->post('pr29');
        //if($this->input->post('pr30')) $temp.='&PRODUCT[300300560]='.$this->input->post('pr30');
		

		if($temp=="")
		{
			header("Location: ".$_SERVER['HTTP_REFERER']);
			exit;
		}
		elseif($temp!="")
		{
			eng() ? $temp .= '&language=English' : '' ;
			$head = "https://secure.shareit.com/shareit/cart.html?DELIVERY[300158265]=EML".$temp;
			header("Location: ".$head);
			exit;
		}
	}

	function check_old()
	{
		if($this->input->post('serial'))
		{
			if(strlen($this->input->post('serial'))!=16)
			{
				$_SESSION['serial_error'] = "Bad Serial Number";
				$link = "/buy/shareit_old";
				header("Location: ".$link);
				exit;
			}
		}

		$temp="";
		$temp2="";
		if ($this->input->post('pr21')) $temp.='&PRODUCT[300161033]='.$this->input->post('pr21');
		if ($this->input->post('pr22')) $temp.='&PRODUCT[300161029]='.$this->input->post('pr22');
		if ($this->input->post('pr23')) $temp.='&PRODUCT[300161018]='.$this->input->post('pr23');
		if ($this->input->post('pr24')) $temp.='&PRODUCT[300160770]='.$this->input->post('pr24');
		if ($this->input->post('pr25')) $temp.='&PRODUCT[300160765]='.$this->input->post('pr25');
		if ($this->input->post('pr71')) $temp.='&PRODUCT[300162430]='.$this->input->post('pr71');
		if ($temp=="")
		{
			if ($this->input->post('pr31')) $temp2.='&PRODUCT[300161162]=1';
			if ($this->input->post('pr32')) $temp2.='&PRODUCT[300161334]=1';
			if ($this->input->post('pr33')) $temp2.='&PRODUCT[300161090]=1';
			if ($this->input->post('pr34')) $temp2.='&PRODUCT[300161332]=1';
			if ($this->input->post('pr35')) $temp2.='&PRODUCT[300161437]=1';
			if ($this->input->post('pr36')) $temp2.='&PRODUCT[300161531]=1';
			if ($this->input->post('pr37')) $temp2.='&PRODUCT[300161339]=1';
			if ($this->input->post('pr38')) $temp2.='&PRODUCT[300161439]=1';
			if ($this->input->post('pr39')) $temp2.='&PRODUCT[300161430]=1';
		}

		if($temp=="" && $temp2=="")
		{
			$link = "/buy/shareit_old";
			header("Location: ".$link);
			exit;
		}
		elseif($temp2!="" && $this->input->post('serial')=="")
		{
			$link = "/buy/shareit_old";
			header("Location: ".$link);
			exit;
		}
		elseif($temp2=="" && $this->input->post('serial')!="")
		{
			$link = "/buy/shareit_old";
			header("Location: ".$link);
			exit;
		}
		elseif($temp!="")
		{
			$head = "https://secure.shareit.com/shareit/cart.html?DELIVERY[300158265]=EML".$temp;
			header("Location: ".$head);
			exit;
		}
		elseif($temp2!="" && $this->input->post('serial')!="")
		{
			$head = "https://secure.shareit.com/shareit/cart.html?DELIVERY[300158265]=EML".$temp2;
			header("Location: ".$head);
			exit;
		}
	}

	function shareit()
	{
		$data['lang']=$this->muser->user['lang'];
		$data['tartalom']='buy/shareit';
		$data['csik']=array('home','buy');
		$this->load->view('site',$data);

	}

	function shareit_old()
	{
		$data['lang']=$this->muser->user['lang'];
		$data['tartalom']='buy/shareit_old';
		$data['csik']=array('home','buy');
		$this->load->view('site',$data);

	}

	function buyegyben2013(){
		$data['cimlap'] = $this->mpages->get_row(761);
		$data['title'] = 'ARCHLine.XP építészeti és belsőépítészi tervezőprogram - Vásárlás';
		$data['tartalom'] = 'interior/buy2';
		$data['javascript'] = array('jquery.corner');
		$data['csik']=array('home','buy');
		
		$this->load->view('site',$data);
	}
	
	function temp(){
		$data['cimlap'] = $this->mpages->get_row(761);
		$data['title'] = 'ARCHLine.XP építészeti és belsőépítészi tervezőprogram - Vásárlás';
		$data['tartalom'] = 'interior/buy2';
		$data['javascript'] = array('jquery.corner');
		$data['csik']=array('home','buy');
		
		$this->load->view('site',$data);
	}
	
}
?>