bebeboutik/modules/privatesale_mail_delay/privatesale_mail_delay.php
Srv Bebeboutik 6c0978166c add modules
2016-01-04 12:49:26 +01:00

104 lines
3.4 KiB
PHP
Executable File

<?php
class Privatesale_mail_delay extends Module {
private $_html;
const DATA_REMISE = "REMISE_PS_DELAY";
const DATA_DESC = "MAIL_PS_DESC";
const DATA_MAIL = "MAIL_PS_DELAY";
public function __construct() {
$this->name = 'privatesale_mail_delay';
$this->tab = 'administration';
$this->version = '1.0';
parent::__construct();
$this->displayName = $this->l('Mail retard vente privée');
$this->description = $this->l('Envoie un mail pour prévenir du retard de livraison d\'une VP');
}
public function install() {
if(!parent::install() ) {
return FALSE;
}
return TRUE;
}
public function getContent(){
if(Tools::isSubmit('saveConfiguration')){
$montant = Tools::getValue('remise_ps_delay');
if( !Validate::isInt($montant) ) {
$this->_html .= "<div class='error'>Le montant de la remise doit être un nombre</div>";
}else{
Configuration::updateValue(self::DATA_REMISE, $montant);
$this->_html .= "<div class='conf'>Montant mis à jour</div>";
}
Configuration::updateValue(self::DATA_DESC, Tools::getValue('remise_description'));
$this->_html .= "<div class='conf'>Description mis à jour</div>";
Configuration::updateValue(self::DATA_MAIL, Tools::getValue('mail_ps_delay'), true);
$this->_html .= "<div class='conf'>Mail mis à jour</div>";
}
$this->_html .= self::displayForm();
echo $this->_html;
}
public static function displayForm(){
$mail_delay_sql = 'SELECT value FROM ps_configuration WHERE name = "'. self::DATA_MAIL.'"';
$mail_delay = DB::getInstance()->getValue($mail_delay_sql);
$data .= '<h2>Alerte mail retard de livraison</h2>
<form method="POST" action="">
<fieldset>';
$data .= "<legend>Configuration du module</legend>";
$data .= '<label>Montant de la remise (€)</label>
<div class="margin-form">
<input type="text" name="remise_ps_delay" value="'. Configuration::get(self::DATA_REMISE) .'" />
</div>';
$data .= '<label>Description du bon</label>
<div class="margin-form">
<input type="text" name="remise_description" value="'. Configuration::get(self::DATA_DESC) .'" />
</div>';
$data .= '<br />
<label>Mail par défault</label>
<div class="margin-form">
<textarea class="rte" cols="30" rows="10" name="mail_ps_delay">'. $mail_delay .'</textarea>
<p>
Les données suivantes seront remplacés avant l\'envoi du mail :
<ol>
<li>%montant% : Montant de la remise</li>
<li>%discount% : Code de réduction</li>
<li>%marque% : Nom de la vente</li>
</ol>
</p>
</div>';
$data .= '<div class="margin-form">
<input type="submit" class="button" name="saveConfiguration" value="Mettre à jour">
</div>
</fieldset>
</form>';
// TinyMCE
global $cookie;
$iso = Language::getIsoById((int)($cookie->id_lang));
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en');
$ad = dirname($_SERVER["PHP_SELF"]);
$data .= '
<script type="text/javascript">
var iso = \''.$isoTinyMCE.'\' ;
var pathCSS = \''._THEME_CSS_DIR_.'\' ;
var ad = \''.$ad.'\' ;
</script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce.inc.js"></script>
';
return $data;
}
}