<?php
/**
 * @package linea21.modules
 * @subpackage newsletter
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

include_once('../config/define.php');
include_once('../class/class.newsletter.php');
include_once(SQL . '.inc.php');

@set_time_limit(0); // suppression du timeout

// sélection des newsletters à envoyer
$newsletters = $sql_object->DBSelect(SQL_GetNewsletter2Send());
if (count($newsletters) <= 1 && $newsletters[0] == false) exit;

// récupération des emails
$emails_batch = $sql_object->DBSelect(SQL_GetEmails4Sending());

if (count($emails_batch) == 1 && $emails_batch[0] == false) exit;

$newsletter_object = new newsletter;

$path = $newsletter_object->URI_TEMPLATE;

// html
$template_html = file_get_contents(override($path . '.html'));
// text
$template_txt = file_get_contents(override($path . '.txt'));
logfile(LOG_MAILING, array('[newsletter-start]', 'batch mode', 'calling ' . __FILE__ ));
require(override("../mail/template_newsletter.php"));
logfile(LOG_MAILING, array('[newsletter-stop]'));
?>