<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Apresentacao extends Comdono_Controller {

	function __construct()
	{
		parent::__construct();
		
	    Assets::add_module_css('comdono', array(
            'lp-style-apresentacao'
        ));
        
        /*Assets::add_module_css('landingpage', array(
            'lp-style'
        ));*/
        
        Assets::add_module_js('comdono', array(
            'lp-script'
            
        ));
        
        Assets::add_css(array(
            'plugins/owlcarousel2-2.3.4/css/owl.carousel.min',
            'plugins/owlcarousel2-2.3.4/css/owl.theme.default.min',
            'plugins/wow_animation/css/animate'
        ));
        
        Assets::add_js(array(
            'plugins/owlcarousel2-2.3.4/js/owl.carousel.min',
            'plugins/wow_animation/js/wow.min',
            'plugins/wow_animation/js/script'
        ));
	}
	
	public function index()
    {
        /*if(get_cookie('cookie_primeiravez') != 'primeiro'){
            set_cookie('cookie_primeiravez','primeiro',time() + (10 * 365 * 24 * 60 * 60));
            redirect('busca');
        }*/
        
        $uri = $this->uri->segment(2);
        
        if($uri == 'anunciar')
	    {
            $data['page_anunciar'] = true;
	    }
        else if($uri == 'comprar')
	    {
            $data['page_comprar'] = true;
	    }
	    else{
	        $data['page_anunciar'] = true;
	    }
	    $data['uri'] = $uri??'anunciar';
	    
	    
	    Template::set_view('apresentacao_view');
        Template::set($data);
        Template::render();
    }
    
    public function email_cadastro()
    {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('email', 'E-mail', 'required|trim|valid_email');
		
		if ($this->form_validation->run() != FALSE) 
        {
            $email = $this->input->post();
            
            var_dump($email);die();
            
            if(empty(Cad_model::getCadastro(['email'=> $email])))
            {
                $email_anunciar = $this->session->set_flashdata('email_anunciar', $email);
                redirect('cadastro',$email_anunciar);
            }else{
                $data['valid_email'] = "E-mail já cadastrado!";
            }
        }else{
            $data['valid_email'] = validation_errors();
        }
        
        Template::set($data);
        Template::set_view('apresentacao_view');
        Template::render();
    }
}