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

306 lines
18 KiB
PHP
Executable File

<?php
class AdminPrivateSales extends AdminTab {
public function postProcess() {
if(($id_category = Tools::getValue('id_category')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_ROOT', (int) $id_category);
}
if(($pub = Tools::getValue('pub')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_SHOW_PUBLIC', (int) $pub);
}
if(($fence = Tools::getValue('fence')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_FENCE', (int) $fence);
}
if(($carrierfence = Tools::getValue('carrierfence')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_CARRIERFENCE', (int) $carrierfence);
}
if(($guest_list = Tools::getValue('guest_list')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_GUESTLIST', (int) $guest_list);
}
if(($future_display_limit = Tools::getValue('future_display_limit')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_FUTURELIMIT', (int) $future_display_limit);
}
if(($featured_ignore = Tools::getValue('featured_ignore')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_FEATURED_IGNORE', (int) $featured_ignore);
}
if(($featured_current = Tools::getValue('featured_current')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_FEATURED_CURRENT', (int) $featured_current);
}
if(($featured_order = Tools::getValue('featured_order')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_FEATURED_ORDER', (int) $featured_order);
}
if(($featured_pqty = Tools::getValue('featured_pqty')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_FEATURED_PQTY', (int) $featured_pqty);
}
if(($trailer_notification = Tools::getValue('trailer_notification')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_TRAILER_NOTIFY', (int) $trailer_notification);
}
if(($trailer_signin = Tools::getValue('trailer_signin')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_TRAILER_SIGNIN', (int) $trailer_signin);
}
if(($title_newsletter = Tools::getValue('title_newsletter')) !== FALSE) {
Configuration::updateValue('PRIVATESALES_TITLE_NEWSLETTER', $title_newsletter);
}
if(($PS_SHIPPING_HANDLING_PS_1 = Tools::getValue('PS_SHIPPING_HANDLING_PS_1')) !== FALSE) {
Configuration::updateValue('PS_SHIPPING_HANDLING_PS_1', $PS_SHIPPING_HANDLING_PS_1);
}
if(($PS_SHIPPING_HANDLING_PS_2 = Tools::getValue('PS_SHIPPING_HANDLING_PS_2')) !== FALSE) {
Configuration::updateValue('PS_SHIPPING_HANDLING_PS_2', $PS_SHIPPING_HANDLING_PS_2);
}
if(($PS_SHIPPING_HANDLING_PS_3 = Tools::getValue('PS_SHIPPING_HANDLING_PS_3')) !== FALSE) {
Configuration::updateValue('PS_SHIPPING_HANDLING_PS_3', $PS_SHIPPING_HANDLING_PS_3);
}
if(($PS_SHIPPING_HANDLING_PS_4 = Tools::getValue('PS_SHIPPING_HANDLING_PS_4')) !== FALSE) {
Configuration::updateValue('PS_SHIPPING_HANDLING_PS_4', $PS_SHIPPING_HANDLING_PS_4);
}
}
public function display() {
global $cookie;
$modules = Db::getInstance()->ExecuteS('
SELECT *
FROM `'._DB_PREFIX_.'privatesale_module`
');
echo '
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<fieldset>
<legend><img src="../img/admin/AdminShipping.gif" alt="" />'.$this->l('Frais de port par marque').'</legend>
<div style="overflow: auto;">
<label style="font-weight:normal; padding-top: 1px; width: 250px">'.$this->l('Frais commandes mixtes (2 ventes)').'</label>
<div class="margin-form">
<input size="5" value="'. Configuration::get('PS_SHIPPING_HANDLING_PS_1') .'" type="text" size="120" name="PS_SHIPPING_HANDLING_PS_1">
</div>
</div>
<div style="overflow: auto;">
<label style="font-weight:normal; padding-top: 1px; width: 250px">'.$this->l('Frais commandes mixtes (3 ventes)').'</label>
<div class="margin-form">
<input size="5" value="'. Configuration::get('PS_SHIPPING_HANDLING_PS_2') .'" type="text" size="120" name="PS_SHIPPING_HANDLING_PS_2">
</div>
</div>
<div style="overflow: auto;">
<label style="font-weight:normal; padding-top: 1px; width: 250px">'.$this->l('Frais commandes mixtes (4 ventes)').'</label>
<div class="margin-form">
<input size="5" value="'. Configuration::get('PS_SHIPPING_HANDLING_PS_3') .'" type="text" size="120" name="PS_SHIPPING_HANDLING_PS_3">
</div>
</div>
<div style="overflow: auto;">
<label style="font-weight:normal; padding-top: 1px; width: 250px">'.$this->l('Frais commandes mixtes (5 ventes)').'</label>
<div class="margin-form">
<input size="5" value="'. Configuration::get('PS_SHIPPING_HANDLING_PS_4') .'" type="text" size="120" name="PS_SHIPPING_HANDLING_PS_4">
</div>
</div>
<div class="margin-form">
<input value="'. $this->l('Sauvegarder') .'" type="submit" name="savePrivatesaleMulti" class="button">
</div>
</fieldset>
</form>
<br class="clear" />';
echo '
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<fieldset>
<legend><img src="../img/admin/comment.gif" alt="" />'.$this->l('EMARSYS - Titre newsletter').'</legend>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Title newsletter').'</label>
<div class="margin-form">
<input value="'. Configuration::get('PRIVATESALES_TITLE_NEWSLETTER') .'" type="text" size="120" name="title_newsletter">
</div>
</div>
<div class="margin-form">
<input value="'. $this->l('Sauvegarder') .'" type="submit" name="saveTitleNews" class="button">
</div>
</fieldset>
</form>
<br class="clear" />';
echo '
<fieldset>
<legend><img src="../img/admin/cog.gif" alt="" />'.$this->l('Available Modules').'</legend>
<ul style="list-style: none; margin: 0px;">';
foreach($modules as $module) {
echo '<li style="margin: 5px 0px;"><img src="../img/admin/ok.gif" alt="" />'.$module['modulename'].'</li>';
}
echo '</ul>
</fieldset>
<br class="clear" />';
echo '<form method="post" action="'.$_SERVER['REQUEST_URI'].'">
<fieldset>
<legend><img src="../img/admin/tab-tools.gif" alt="" />'.$this->l('Private Sales Configuration').'</legend>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Root category:').'</label>
<div class="margin-form">
<select name="id_category">';
$root = Configuration::get('PRIVATESALES_ROOT');
$categories = Db::getInstance()->ExecuteS('SELECT c.`id_category`, l.`name` from `'._DB_PREFIX_.'category` c, `'._DB_PREFIX_.'category_lang` l WHERE c.`id_category` = l.`id_category` and l.`id_lang` = '.intval($cookie->id_lang).' AND c.`id_parent` = 1 ORDER BY c.`id_category`');
echo '<option value="1"'.($root==1?' selected="selected"':'').'>1 - '.$this->l('Home').'</option>';
foreach($categories as $category) {
echo '<option style="padding-left: 10px;" value="'.$category['id_category'].'"'.($root==$category['id_category']?' selected="selected"':'').'>'.$category['id_category'].' - '.$category['name'].'</option>';
}
echo '</select>
<sup> *</sup>
</div>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Show public sales on listings:').'</label>
<div class="margin-form">
<br />
<input type="radio" value="0" name="pub"'.(Configuration::get('PRIVATESALES_SHOW_PUBLIC')==0?' checked="checked"':'').' /> '.$this->l('No').' <input type="radio" value="1" name="pub"'.(Configuration::get('PRIVATESALES_SHOW_PUBLIC')==1?' checked="checked"':'').' /> '.$this->l('Yes').'<sup> *</sup>
</div>
</div>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Enable the sales fencing:').'</label>
<div class="margin-form">
<br />
<input type="radio" value="0" name="fence"'.(Configuration::get('PRIVATESALES_FENCE')==0?' checked="checked"':'').' /> '.$this->l('No').' <input type="radio" value="1" name="fence"'.(Configuration::get('PRIVATESALES_FENCE')==1?' checked="checked"':'').' /> '.$this->l('Yes').'<sup> *</sup>
<p>'.$this->l('WARNING: Changing this parameter may require some modifications in your theme.').'</p>
</div>
</div>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Enable the carrier fencing:').'</label>
<div class="margin-form">
<br />
<input type="radio" value="0" name="carrierfence"'.(Configuration::get('PRIVATESALES_CARRIERFENCE')==0?' checked="checked"':'').' /> '.$this->l('No').' <input type="radio" value="1" name="carrierfence"'.(Configuration::get('PRIVATESALES_CARRIERFENCE')==1?' checked="checked"':'').' /> '.$this->l('Yes').'<sup> *</sup>
</div>
</div>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Show the sales list to guests:').'</label>
<div class="margin-form">
<br />
<input type="radio" value="0" name="guest_list"'.(Configuration::get('PRIVATESALES_GUESTLIST')==0?' checked="checked"':'').' /> '.$this->l('No').' <input type="radio" value="1" name="guest_list"'.(Configuration::get('PRIVATESALES_GUESTLIST')==1?' checked="checked"':'').' /> '.$this->l('Yes').'<sup> *</sup>
</div>
</div>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Future sales display limit:').'</label>
<div class="margin-form">
<br />
<input type="text" value="'.Configuration::get('PRIVATESALES_FUTURELIMIT').'" name="future_display_limit" style="width: 30px;" /> '.$this->l('days').'<sup> *</sup>
<p>'.$this->l('Sales starting within this limit will be displayed.').'<br />'.$this->l('Set to 0 to show all future sales.').'</p>
</div>
</div>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Show the notification form on trailers:').'</label>
<div class="margin-form">
<br />
<input type="radio" value="0" name="trailer_notification"'.(Configuration::get('PRIVATESALES_TRAILER_NOTIFY')==0?' checked="checked"':'').' /> '.$this->l('No').' <input type="radio" value="1" name="trailer_notification"'.(Configuration::get('PRIVATESALES_TRAILER_NOTIFY')==1?' checked="checked"':'').' /> '.$this->l('Yes').'<sup> *</sup>
</div>
</div>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Show a sign in button on upcoming sale trailers:').'</label>
<div class="margin-form">
<br />
<input type="radio" value="0" name="trailer_signin"'.(Configuration::get('PRIVATESALES_TRAILER_SIGNIN')==0?' checked="checked"':'').' /> '.$this->l('No').' <input type="radio" value="1" name="trailer_signin"'.(Configuration::get('PRIVATESALES_TRAILER_SIGNIN')==1?' checked="checked"':'').' /> '.$this->l('Yes').'<sup> *</sup>
</div>
</div>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Ignore sale display settings in featured brands:').'</label>
<div class="margin-form">
<br /><br /><br /><br />
<input type="radio" value="0" name="featured_ignore"'.(Configuration::get('PRIVATESALES_FEATURED_IGNORE')==0?' checked="checked"':'').' /> '.$this->l('No').' <input type="radio" value="1" name="featured_ignore"'.(Configuration::get('PRIVATESALES_FEATURED_IGNORE')==1?' checked="checked"':'').' /> '.$this->l('Yes').'<sup> *</sup>
</div>
</div>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Show brands from current sales in featured brands:').'</label>
<div class="margin-form">
<br /><br />
<input type="radio" value="0" name="featured_current"'.(Configuration::get('PRIVATESALES_FEATURED_CURRENT')==0?' checked="checked"':'').' /> '.$this->l('No').' <input type="radio" value="1" name="featured_current"'.(Configuration::get('PRIVATESALES_FEATURED_CURRENT')==1?' checked="checked"':'').' /> '.$this->l('Yes').'<sup> *</sup>
</div>
</div>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Featured brands ordering:').'</label>
<div class="margin-form">
<br />
<select name="featured_order">
<option value="0"'.(Configuration::get('PRIVATESALES_FEATURED_ORDER')==0? ' selected="selected"': '').'>'.$this->l('By brand').'</option>';
if(Module::isInstalled('privatesales_tags')) {
echo ' <option value="1"'.(Configuration::get('PRIVATESALES_FEATURED_ORDER')==1? ' selected="selected"': '').'>'.$this->l('By tag').'</option>';
}
echo ' </select><sup> *</sup>
</div>
</div>
<div style="overflow: auto;">
<label style="padding-top: 1px;">'.$this->l('Featured brands products quantity:').'</label>
<div class="margin-form">
<br /><br />
<input type="text" value="'.Configuration::get('PRIVATESALES_FEATURED_PQTY').'" name="featured_pqty" style="width: 30px;" /><sup> *</sup>
</div>
</div>
<div class="margin-form">
<input type="submit" class="button" name="submitUpdate" value="'.$this->l('Update settings').'" />
</div>
</fieldset>';
if(Configuration::get('PS_REWRITING_SETTINGS')) {
$langs = Language::getLanguages();
echo '<br /><br />
<fieldset>
<legend><img src="../img/admin/tab-tools.gif" alt="" />'.$this->l('URL Rewriting settings').'</legend>
<p>'.$this->l('Add the following text to the custom rewriting rules (Tools &gt; Generators):').'</p>
<p> </p>
<textarea style="width: 850px; height: 120px;" readonly="true">';
$urls_i18n = array(
'fr' => array(
'bande-annonce',
'flux',
'marques',
'vente',
),
'en' => array(
'trailer',
'feed',
'brands',
'sale',
),
);
if(count($langs) > 1) {
foreach($langs as $lang) {
if(isset($urls_i18n[$lang['iso_code']])) {
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n[$lang['iso_code']][0].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/trailer.php?id_sale=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n[$lang['iso_code']][1].'$ '.__PS_BASE_URI__.'modules/privatesales/feed.php?id_sale=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n[$lang['iso_code']][2].'$ '.__PS_BASE_URI__.'modules/privatesales/featured.php [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n[$lang['iso_code']][2].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/featured.php?id_tag=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n[$lang['iso_code']][2].'/([0-9]+)\-[a-zA-Z0-9-]*.html$ '.__PS_BASE_URI__.'modules/privatesales/featured.php?id_manufacturer=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n[$lang['iso_code']][3].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/showsale.php?id_sale=$1 [QSA,L]'."\n");
} else {
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n['en'][0].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/trailer.php?id_sale=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n['en'][1].'$ '.__PS_BASE_URI__.'modules/privatesales/feed.php?id_sale=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n['en'][2].'$ '.__PS_BASE_URI__.'modules/privatesales/featured.php [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n['en'][2].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/featured.php?id_tag=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n['en'][2].'/([0-9]+)\-[a-zA-Z0-9-]*.html$ '.__PS_BASE_URI__.'modules/privatesales/featured.php?id_manufacturer=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$lang['iso_code'].'/'.$urls_i18n['en'][3].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/showsale.php?id_sale=$1 [QSA,L]'."\n");
}
}
} else {
if(isset($urls_i18n[$langs[0]['iso_code']])) {
echo htmlentities('RewriteRule ^'.$urls_i18n[$langs[0]['iso_code']][0].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/trailer.php?id_sale=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$urls_i18n[$langs[0]['iso_code']][1].'$ '.__PS_BASE_URI__.'modules/privatesales/feed.php?id_sale=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$urls_i18n[$langs[0]['iso_code']][2].'$ '.__PS_BASE_URI__.'modules/privatesales/featured.php [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$urls_i18n[$langs[0]['iso_code']][2].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/featured.php?id_tag=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$urls_i18n[$langs[0]['iso_code']][2].'/([0-9]+)\-[a-zA-Z0-9-]*.html$ '.__PS_BASE_URI__.'modules/privatesales/featured.php?id_manufacturer=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$urls_i18n[$langs[0]['iso_code']][3].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/showsale.php?id_sale=$1 [QSA,L]'."\n");
} else {
echo htmlentities('RewriteRule ^'.$urls_i18n['en'][0].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/trailer.php?id_sale=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$urls_i18n['en'][1].'$ '.__PS_BASE_URI__.'modules/privatesales/feed.php?id_sale=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$urls_i18n['en'][2].'$ '.__PS_BASE_URI__.'modules/privatesales/featured.php [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$urls_i18n['en'][2].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/featured.php?id_tag=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$urls_i18n['en'][2].'/([0-9]+)\-[a-zA-Z0-9-]*.html$ '.__PS_BASE_URI__.'modules/privatesales/featured.php?id_manufacturer=$1 [QSA,L]'."\n");
echo htmlentities('RewriteRule ^'.$urls_i18n['en'][3].'/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/privatesales/showsale.php?id_sale=$1 [QSA,L]'."\n");
}
}
echo '</textarea>
</fieldset>
</form>';
}
}
}