Files
bio-concept-pharma/web/override/classes/Mail.php
2019-11-17 19:14:07 +01:00

76 lines
3.4 KiB
PHP

<?php
/**
* 2014 - 2017 MDWeb - Terms of Sale Send
*
* @author MDWeb
* @version 1.3.0
* @copyright MDWeb 2014 - 2017
* @license Commerciale
*/
class Mail extends MailCore
{
public static function Send($id_lang, $template, $subject, $template_vars, $to,
$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null) #$reply_to for compatibility with PS 1.6.1
{
gettype($reply_to); #$reply_to for compatibility with PS 1.6.1
if ($template == 'order_conf')
{
if (version_compare(_PS_VERSION_, 1.4, '>=') && version_compare(_PS_VERSION_, 1.5, '<'))
{
return parent::Send($id_lang, $template, $subject, $template_vars, $to, $to_name, $from,
$from_name, $file_attachment, $mode_smtp, $template_path, $die, $id_shop, $bcc);
}
$files_attachments = array();
//Prendre le formulaire de rétractation s'il existe
if (Configuration::get('MD_CGV_INVOICE_WITHDRAWAL') == 1 && Configuration::get('MD_CGV_WITHDRAWALFORM'))
{
$form = array('content' => Tools::file_get_contents(_PS_ROOT_DIR_.'/modules/mdtossend/form/'.Configuration::get('MD_CGV_WITHDRAWALFORM')),
'name' => 'withdrawal_form.pdf',
'mime' => 'application/pdf');
$files_attachments[] = $form;
}
//Ajouter les CGV en PJ si elles sont pas ajouté à la facture ou du coup, si la version est une 1.4
if ((Configuration::get('MD_CGV_INVOICE') == 0) || (version_compare(_PS_VERSION_, 1.4, '>=') && version_compare(_PS_VERSION_, 1.5, '<')))
{
$iso = Language::getIsoById($id_lang);
$pdf = '';
if (version_compare(_PS_VERSION_, 1.5, '>'))
{
if ($id_shop == null)
$id_shop = Context::getContext()->shop->id;
$pdf = _PS_ROOT_DIR_.'/modules/mdtossend/pdf/cgv_'.$iso.'_'.$id_shop.'.pdf';
}
else
$pdf = _PS_ROOT_DIR_.'/modules/mdtossend/pdf/cgv_'.$iso.'.pdf';
$cgv = array('content' => Tools::file_get_contents($pdf),
'name' => 'cgv.pdf',
'mime' => 'application/pdf');
$files_attachments[] = $cgv;
}
//S'il n'y a qu'une seule pièce jointe
if ($file_attachment && isset($file_attachment['content']))
{
$invoice = array('content' => $file_attachment['content'],
'name' => $file_attachment['name'],
'mime' => $file_attachment['mime']);
$files_attachments[] = $invoice;
}
if (version_compare(_PS_VERSION_, 1.5, '>='))
{
return parent::Send($id_lang, $template, $subject, $template_vars, $to, $to_name, $from,
$from_name, $files_attachments, $mode_smtp, $template_path, $die, $id_shop, $bcc);
}
}
else
{
return parent::Send($id_lang, $template, $subject, $template_vars, $to, $to_name, $from,
$from_name, $file_attachment, $mode_smtp, $template_path, $die, $id_shop, $bcc);
}
}
}