garancia/controllers/front/DiagnosticpdfemailController.php
2016-10-10 15:24:25 +02:00

107 lines
4.0 KiB
PHP
Executable File

<?php session_start();
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class DiagnosticpdfemailControllerCore extends FrontController
{
protected $display_header = false;
protected $display_footer = false;
public function postProcess()
{
// print_r($this->context->cookie->final_14);
// die();
if($this->context->cookie->final_14!=""){
$this->Offredefidelite = new Offredefidelite(3);
$this->Offredefidelite->mktime=mktime();
// $this->Offredefidelite->template="Offredefidelite";
// $this->template="Offredefidelite";
if (!isset($this->Offredefidelite) || !Validate::isLoadedObject($this->Offredefidelite))
die(Tools::displayError('not found.'));
}
}
public function attacher(){
sleep(4);
// echo _PS_BASE_URL_.__PS_BASE_URI__.'upload/votre-diagnostic-Garancia-'.$this->Offredefidelite->mktime.'.pdf';
// die();
if(!$fileAttachment['content'] = file_get_contents(_PS_BASE_URL_.__PS_BASE_URI__.'upload/votre-diagnostic-Garancia-'.$this->Offredefidelite->mktime.'.pdf'))
$this->attacher();
else{
$fileAttachment['name'] = 'votre-diagnostic-Garancia-'.$this->Offredefidelite->mktime.'.pdf';
$fileAttachment['mime'] = "application/pdf";
$var_list['{attached_file_url}'] = _PS_BASE_URL_.__PS_BASE_URI__.'upload/votre-diagnostic-Garancia-'.$this->Offredefidelite->mktime.'.pdf';
$var_list['{attached_file}'] = "Votre diagnostic";
$subject="Votre Diagnostic Garancia";
// print_r($fileAttachment);
// die();
$from = trim(Tools::getValue('recevoir_from'));
if(!Mail::Send($this->context->language->id, 'diagnostic', $subject, $var_list, $from, null, null, null, $fileAttachment))
Tools::redirect('diagnostic?step=7&error=badmail') ;
else
Tools::redirect('diagnostic?step=7&succes=1');
}
}
public function display()
{
if($this->context->cookie->final_14!=""){
if(Tools::isSubmit('submitMail')){
if (($from = trim(Tools::getValue('recevoir_from'))) && Validate::isEmail($from)){
$pdf = new PDF($this->Offredefidelite,'Diagnostic', $this->context->smarty);
$pdf->render('F');
// echo "test";
// die();
$this->attacher();
// $fileAttachment = null;
// $fileAttachment['content'] = file_get_contents(_PS_BASE_URL_.__PS_BASE_URI__.'upload/votre-diagnostic-Garancia-'.$this->Offredefidelite->mktime.'.pdf');
// $fileAttachment['name'] = 'votre-diagnostic-Garancia-'.$this->Offredefidelite->mktime.'.pdf';
// $fileAttachment['mime'] = "application/pdf";
// $var_list['{attached_file_url}'] = _PS_BASE_URL_.__PS_BASE_URI__.'upload/votre-diagnostic-Garancia-'.$this->Offredefidelite->mktime.'.pdf';
// $var_list['{attached_file}'] = "Votre diagnostic";
// $subject="Offre de fidélité";
// print_r($fileAttachment);
// die();
// Mail::Send($this->context->language->id, 'diagnostic', $subject, $var_list, $from, null, null, null, $fileAttachment);
// Tools::redirect('diagnostic?step=7&succes=1');
}else{
// Tools::redirect('diagnostic?step=7&error=badmail') ;
}
}
// else
// $pdf = new PDF($this->Offredefidelite,'Diagnostic', $this->context->smarty);
// $pdf->render();
// }
}
}
}