<?php

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

/**
 * Description of callme_site
 *
 * @author Igor Ratsun
 */
class callme_site extends MX_Controller {

    public function __construct() {
        $this->load->library('form_hash');
        $this->form_hash->time_point = 3;
    }
    
    public function index() {
        $this->lang->load('callme/site');
        $this->load->helper('form');

        $content = array(
            'form_open' => form_open('/ajax/callme/callme_site/add', array('id'=> 'feedbackForm')),
            'ln_info' => $this->lang->line('ln_info'),
            'ln_name' => $this->lang->line('ln_name'),
            'ln_email' => $this->lang->line('ln_email'),
            'ln_phone' => $this->lang->line('ln_phone'),
            'ln_text' => $this->lang->line('ln_text'),
            'ln_send' => $this->lang->line('ln_send'),
            'form_close' => form_close(),
            'hash' => $this->form_hash->set_form_hash(),
        );

        return $this->parser->parse('callme/template', $content, TRUE);
    }
    
    public function add() {
        $this->load->model('callme/callme_model');
        $rs = array(
            'success' => $this->form_hash->check_form_hash() ? intval($this->callme_model->add() > 0) : 0,
            'hash' => $this->form_hash->set_form_hash(),
        );
        
        die(json_encode($rs));
    }

}

