<?php defined('_JEXEC') or die;

/**
 * File       helper.php
 * Created    1/23/16 12:29 PM
 * Author     foobla | noreply@foobla.com | http://foobla.com
 * Copyright  Copyright (C) 2016 betweenbrain llc. All Rights Reserved.
 * License    GNU General Public License version 2, or later.
 */
class modObAjaxFormHelper
{
	public static function getAjax()
	{
		$app = JFactory::getApplication();
		$module = JModuleHelper::getModule('ob_ajax_form');
		$params = new JRegistry($module->params);
		$input = JFactory::getApplication()->input;

		$data  = $input->get('data',null,'raw');
		ob_start();
		require(JModuleHelper::getLayoutPath('mod_ob_ajax_form',$params->get('layout', 'default').'_html_mail'));
		$html = ob_get_clean();
		$to = $params->get('email_admin');
		$subject = $params->get('subject_mail');
		$headers = "MIME-Version: 1.0" . "\r\n";
		$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
		$headers .= 'From: <'.$params->get('email_from').'>' . "\r\n";
		$send = mail($to,$subject,$html,$headers);
		return $send?$params->get('message_send'):$params->get('message_send_error');
	}
}
