916 lines
46 KiB
PHP
Executable File
916 lines
46 KiB
PHP
Executable File
<?php
|
|
include_once(_PS_ROOT_DIR_.'/modules/privatesales/Sale.php');
|
|
|
|
class AdminPrivateSalesSales extends AdminTab {
|
|
private $imagelist;
|
|
|
|
public function __construct() {
|
|
$this->lang = TRUE;
|
|
parent::__construct();
|
|
$this->imagelist = array(
|
|
'thumb' => array($this->l('Thumbnail'), '260x108'),
|
|
'liston' => array($this->l('Listing image (on)'), '380x178'),
|
|
'listoff' => array($this->l('Listing image (off)'), '380x178'),
|
|
'fb' => array($this->l('Facebook image'), '100x100'),
|
|
'trailerbg' => array($this->l('Trailer background'), '*x*'),
|
|
'trailercenter' => array($this->l('Trailer center background'), '560x*'),
|
|
);
|
|
}
|
|
|
|
public function displayForm($isMainTab=TRUE) {
|
|
global $currentIndex, $cookie;
|
|
parent::displayForm();
|
|
|
|
$iso = Language::getIsoById((int)($cookie->id_lang));
|
|
$images = array();
|
|
foreach(array_keys($this->imagelist) as $img) {
|
|
$images[] = 'img_'.$img;
|
|
}
|
|
$divLangName = 'description¤video¤'.implode('¤', $images);
|
|
|
|
echo '<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/privatesales/privatesale.js"></script>
|
|
<script type="text/javascript">
|
|
i18n_delete = "'.$this->l('Are you sure you want to delete this sale?').'";
|
|
current_location = "'.$currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesSales').'";
|
|
</script>
|
|
<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/privatesales/jquery.multiSelect.js"></script>
|
|
<style type="text/css">
|
|
option[disabled] {
|
|
background: #efefef;
|
|
}
|
|
.ui-sortable-handle{
|
|
cursor:move;
|
|
}
|
|
a.multiSelect {
|
|
background: #FFF url('.__PS_BASE_URI__.'modules/privatesales/dropdown.blue.png) right -1px no-repeat;
|
|
border: 1px solid #e0d0b1;
|
|
padding-right: 20px;
|
|
position: relative;
|
|
cursor: default;
|
|
text-decoration: none;
|
|
color: black;
|
|
display: -moz-inline-stack;
|
|
display: inline-block;
|
|
vertical-align: top;
|
|
margin-top: 2px;
|
|
}
|
|
a.multiSelect:link, a.multiSelect:visited, a.multiSelect:hover, a.multiSelect:active {
|
|
color: black;
|
|
text-decoration: none;
|
|
}
|
|
a.multiSelect span {
|
|
margin: 1px 0px 1px 3px;
|
|
overflow: hidden;
|
|
display: -moz-inline-stack;
|
|
display: inline-block;
|
|
white-space: nowrap;
|
|
font-size: 12px;
|
|
}
|
|
a.multiSelect.hover {
|
|
background-image: url('.__PS_BASE_URI__.'modules/privatesales/dropdown.blue.hover.png);
|
|
}
|
|
a.multiSelect.active, a.multiSelect.focus {
|
|
border: inset 1px #000000;
|
|
}
|
|
a.multiSelect.active {
|
|
background-image: url('.__PS_BASE_URI__.'modules/privatesales/dropdown.blue.active.png);
|
|
}
|
|
.multiSelectOptions {
|
|
margin-top: -1px;
|
|
overflow-y: auto;
|
|
overflow-x: hidden;
|
|
border: solid 1px #b2b2b2;
|
|
background: #ffffff;
|
|
}
|
|
.multiSelectOptions label {
|
|
padding: 0px 2px;
|
|
display: block;
|
|
white-space: nowrap;
|
|
float: none;
|
|
text-align: left;
|
|
width: auto;
|
|
}
|
|
.multiSelectOptions label.optGroup {
|
|
font-weight: bold;
|
|
}
|
|
.multiSelectOptions .optGroupContainer label {
|
|
padding-left: 10px;
|
|
font-size: 12px;
|
|
color: #333333;
|
|
padding: 2px 0px;
|
|
}
|
|
.multiSelectOptions.optGroupHasCheckboxes .optGroupContainer label {
|
|
padding-left: 18px;
|
|
}
|
|
.multiSelectOptions input {
|
|
vertical-align: middle;
|
|
margin-right: 5px;
|
|
}
|
|
.multiSelectOptions label.checked {
|
|
background-color: #dce5f8;
|
|
}
|
|
.multiSelectOptions label.optGroup {
|
|
color: #000000;
|
|
font-size: 12px;
|
|
margin-bottom: 2px;
|
|
}
|
|
.multiSelectOptions label.selectAll {
|
|
border-bottom: dotted 1px #cccccc;
|
|
font-size: 12px;
|
|
color: #333333;
|
|
padding-top: 2px;
|
|
margin: 0px 0px 6px;
|
|
}
|
|
.multiSelectOptions label.hover {
|
|
background-color: #3399ff;
|
|
color: #ffffff;
|
|
}
|
|
.green {
|
|
background : #dffad3;
|
|
}
|
|
.red {
|
|
background : #f29b9b;
|
|
}
|
|
.sale_0 {
|
|
background : #fbfbdb;
|
|
}
|
|
</style>
|
|
<form action="'.$currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesSales').'" method="post" enctype="multipart/form-data">
|
|
<fieldset>
|
|
<legend><img src="../img/admin/cms.gif" alt="" title="" /> '.$this->l('Edit a sale').'</legend>';
|
|
|
|
$categories = Db::getInstance()->ExecuteS('
|
|
SELECT c.`id_category`, l.`name`, l.`link_rewrite`
|
|
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` = '.Configuration::get('PRIVATESALES_ROOT').'
|
|
ORDER BY c.`id_category`
|
|
');
|
|
|
|
$used_categories = array();
|
|
foreach(Db::getInstance()->ExecuteS('
|
|
SELECT p.`id_category`
|
|
FROM `'._DB_PREFIX_.'privatesale_category` p
|
|
WHERE `id_category` IN (
|
|
SELECT c.`id_category`
|
|
FROM `'._DB_PREFIX_.'category` c
|
|
WHERE c.`id_parent` = '.Configuration::get('PRIVATESALES_ROOT').'
|
|
)
|
|
') as $cat) {
|
|
$used_categories[] = $cat['id_category'];
|
|
}
|
|
$categories_ordered = array();
|
|
echo '<script type="text/javascript">
|
|
var categories_ordered = {};
|
|
</script>
|
|
<label style="padding-top: 1px;">'.$this->l('Root category:').'</label>
|
|
<div class="margin-form">
|
|
<select name="id_category" onchange="$(\'#title input\').attr(\'value\', categories_ordered[$(this).attr(\'value\')].name);$(\'#alias input\').attr(\'value\', categories_ordered[$(this).attr(\'value\')].link_rewrite);">';
|
|
foreach($categories as $category) {
|
|
$categories_ordered[(string) $category['id_category']] = $category;
|
|
echo '<option value="'.$category['id_category'].'"'.($this->cursale!==NULL? ($this->cursale->id_category==$category['id_category']?' selected="selected"':(in_array($category['id_category'], $used_categories)?' disabled="disabled"': '')): (in_array($category['id_category'], $used_categories)?' disabled="disabled"': '')).'>'.$category['id_category'].' - '.$category['name'].'</option>';
|
|
}
|
|
echo '</select>
|
|
<sup> *</sup>
|
|
<p>'.$this->l('Categories already affected to other sales are greyed.').'</p>
|
|
</div>
|
|
<script type="text/javascript">
|
|
categories_ordered = '.json_encode($categories_ordered).';
|
|
</script>
|
|
';
|
|
|
|
echo '<label>'.$this->l('Title:').'</label>
|
|
<div class="margin-form">
|
|
<div id="title" style="float: left;">
|
|
<input type="text" disabled="disabled" value="'.($this->cursale!==NULL? $categories_ordered[$this->cursale->id_category]['name']: (in_array($categories[0]['id_category'], $used_categories)? '': $categories[0]['name'])).'" style="width: 500px;" /> <img src="../img/admin/access.png" alt="" />
|
|
<p>'.$this->l('This value is set by the name of the root category for this sale.').'</p>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
echo '<label>'.$this->l('Alias:').'</label>
|
|
<div class="margin-form">
|
|
<div id="alias" style="float: left;">
|
|
<input type="text" disabled="disabled" value="'.($this->cursale!==NULL? $categories_ordered[$this->cursale->id_category]['link_rewrite']: (in_array($categories[0]['id_category'], $used_categories)? '': $categories[0]['link_rewrite'])).'" style="width: 500px;" /> <img src="../img/admin/access.png" alt="" />
|
|
<p>'.$this->l('This value is set by the alias of the root category for this sale.').'</p>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
echo '<label>'.$this->l('Start date:').'</label>
|
|
<div class="margin-form">
|
|
<div id="date_start" style="float: left;">
|
|
<input name="date_start" type="text" value="'.($this->cursale!==NULL? $this->cursale->date_start: '').'" style="width: 150px;" />
|
|
<sup> *</sup>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
echo '<label>'.$this->l('End date:').'</label>
|
|
<div class="margin-form">
|
|
<div id="date_end" style="float: left;">
|
|
<input name="date_end" type="text" value="'.($this->cursale!==NULL? $this->cursale->date_end: '').'" style="width: 150px;" />
|
|
<sup> *</sup>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
echo '<label>'.$this->l('Status:').'</label>
|
|
<div class="margin-form">
|
|
<div id="enabled" style="float: left;">
|
|
<input name="enabled" type="radio" value="0"'.($this->cursale!==NULL?($this->cursale->enabled==0?' checked="checked"': ''):'').' /> '.$this->l('Disabled').' <input name="enabled" type="radio" value="1"'.($this->cursale!==NULL?($this->cursale->enabled==1?' checked="checked"': ''):'checked="checked"').' /> '.$this->l('Enabled').'
|
|
<sup> *</sup>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
echo '<label>'.$this->l('Display:').'</label>
|
|
<div class="margin-form">
|
|
<div id="logout" style="float: left;">
|
|
<input name="logout" type="radio" value="0"'.($this->cursale!==NULL? ($this->cursale->logout==0? ' checked="checked"': ''):' ').' /> '.$this->l('Only for logged in users').' <input name="logout" type="radio" value="1"'.($this->cursale!==NULL? ($this->cursale->logout==1? ' checked="checked"': ''):' checked="checked"').' /> '.$this->l('Show to guests too').'
|
|
<sup> *</sup>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
|
|
echo '<label>'.$this->l('Public sale:').'</label>
|
|
<div class="margin-form">
|
|
<div id="public" style="float: left;">
|
|
<input name="pub" type="radio" value="0"'.($this->cursale!==NULL? ($this->cursale->pub==0? ' checked="checked"': ''): ' checked="checked"').' /> '.$this->l('No').' <input name="pub" type="radio" value="1"'.($this->cursale!==NULL && $this->cursale->pub==1? ' checked="checked"': '').' /> '.$this->l('Yes').'
|
|
<sup> *</sup>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
echo '<label>'.$this->l('Braderie :').'</label>
|
|
<div class="margin-form">
|
|
<div id="public" style="float: left;">
|
|
<input name="braderie" type="radio" value="0"'.($this->cursale!==NULL? ($this->cursale->braderie==0? ' checked="checked"': ''): ' checked="checked"').' /> '.$this->l('No').' <input name="braderie" type="radio" value="1"'.($this->cursale!==NULL && $this->cursale->braderie ==1? ' checked="checked"': '').' /> '.$this->l('Yes').'
|
|
<sup> *</sup>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
echo '<label>'.$this->l('Featured sale:').'</label>
|
|
<div class="margin-form">
|
|
<div id="featured" style="float: left;">
|
|
<input name="featured" type="radio" value="0"'.($this->cursale!==NULL? ($this->cursale->featured==0? ' checked="checked"': ''):' checked="checked"').' /> '.$this->l('No').' <input name="featured" type="radio" value="1"'.($this->cursale!==NULL && $this->cursale->featured==1?' checked="checked"': '').' /> '.$this->l('Yes').'
|
|
<sup> *</sup>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
echo '<label>'.$this->l('Sale manager:').'</label>
|
|
<div class="margin-form">
|
|
<select name="id_employee">
|
|
<option value="0"></option>';
|
|
foreach(Employee::getEmployees() as $e) {
|
|
echo '<option value="'.$e['id_employee'].'"'.($this->cursale!==NULL? ($this->cursale->id_employee==$e['id_employee']?' selected="selected"': ''): '').'>'.$e['name'].'</option>';
|
|
}
|
|
echo '</select>
|
|
<sup> *</sup>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
|
|
echo '<label>'.$this->l('Nouveau :').'</label>
|
|
<div class="margin-form">
|
|
<div id="new" style="float: left;">
|
|
<input name="new" type="radio" value="0"'.($this->cursale!==NULL? ($this->cursale->new==0? ' checked="checked"': ''):' checked="checked"').' /> '.$this->l('Non').' <input name="new" type="radio" value="1"'.($this->cursale!==NULL && $this->cursale->new==1?' checked="checked"': '').' /> '.$this->l('Oui').'
|
|
<sup> *</sup>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
|
|
echo '<label>'.$this->l('Mise en avant newsletter :').'</label>
|
|
<div class="margin-form">
|
|
<div id="forward_news" style="float: left;">
|
|
<input name="forward_news" type="radio" value="0"'.($this->cursale!==NULL? ($this->cursale->forward_news==0? ' checked="checked"': ''):' checked="checked"').' /> '.$this->l('Non').' <input name="forward_news" type="radio" value="1"'.($this->cursale!==NULL && $this->cursale->forward_news==1?' checked="checked"': '').' /> '.$this->l('Oui').'
|
|
<sup> *</sup>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
|
|
echo '<label>'.$this->l('Délai de livraison :').'</label>
|
|
<div class="margin-form">
|
|
<div id="delivery_delay" style="float: left;">
|
|
<select name="delivery_delay" id="delivery_delay">
|
|
<option value="1" '.($this->cursale!==NULL? ($this->cursale->delivery_delay== 1? ' selected="selected"': ''):' selected="selected"').'>'.$this->l('Livraison classique').'</option>
|
|
<option value="2" '.($this->cursale!==NULL? ($this->cursale->delivery_delay== 2? ' selected="selected"': ''):' ').'>'.$this->l('Livraison 48h').'</option>
|
|
<option value="3" '.($this->cursale!==NULL? ($this->cursale->delivery_delay== 3? ' selected="selected"': ''):' ').'>'.$this->l('Livraison 7 Jours').'</option>
|
|
<option value="4" '.($this->cursale!==NULL? ($this->cursale->delivery_delay== 4? ' selected="selected"': ''):' ').'>'.$this->l('Livraison 10 Jours').'</option>
|
|
<option value="5" '.($this->cursale!==NULL? ($this->cursale->delivery_delay== 5? ' selected="selected"': ''):' ').'>'.$this->l('Livraison Noël').'</option>
|
|
<option value="6" '.($this->cursale!==NULL? ($this->cursale->delivery_delay== 6? ' selected="selected"': ''):' ').'>'.$this->l('Produit Star').'</option>
|
|
<option value="7" '.($this->cursale!==NULL? ($this->cursale->delivery_delay== 7? ' selected="selected"': ''):' ').'>'.$this->l('Livraison 72h').'</option>
|
|
</select>
|
|
<sup> *</sup>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
$groups = Db::getInstance()->ExecuteS('
|
|
SELECT l.`id_group`, l.`name`'.($this->cursale !== NULL? ', (
|
|
SELECT IFNULL(g.`id_sale`, NULL) FROM `'._DB_PREFIX_.'privatesale_group` g WHERE l.`id_group` = g.`id_group` AND g.`id_sale` = '.$this->cursale->id.'
|
|
) AS `id_sale`': '').'
|
|
FROM `'._DB_PREFIX_.'group_lang` l
|
|
WHERE l.`id_lang` = '.$cookie->id_lang
|
|
);
|
|
echo '<label>'.$this->l('Groups:').'</label>
|
|
<div class="margin-form">
|
|
<div id="groups" style="float: left;">
|
|
<select id="m_groups" name="m_groups[]" multiple="multiple" size="5">
|
|
<option value=""></option>
|
|
<optgroup label="'.$this->l('Select one or more groups:').'">';
|
|
foreach($groups as $group) {
|
|
echo '<option value="'.$group['id_group'].'"'.(isset($group['id_sale']) && $group['id_sale'] !== NULL?' selected="selected"':'').(!isset($this->cursale->id) && $group['id_group'] == 1? ' selected="selected"': '').'>'.$group['name'].'</option>';
|
|
}
|
|
echo '
|
|
</optgroup>
|
|
</select>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$("#m_groups").multiSelect({
|
|
selectAllText: "'.$this->l('Select all').'",
|
|
noneSelected: " ",
|
|
oneOrMoreSelected: "*"
|
|
});
|
|
});
|
|
</script>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
$site_versions = array('fr', 'es'/*, 'it'*/);
|
|
echo '<label>'.$this->l('Versions :').'</label>
|
|
<div class="margin-form">
|
|
<div id="versions" style="float: left;">
|
|
<select id="m_versions" name="m_versions[]" multiple="multiple" size="5">
|
|
<option value=""></option>
|
|
<optgroup label="'.$this->l('Select one or more versions:').'">';
|
|
foreach($site_versions as $version) {
|
|
echo '<option value="'.$version.'"'.(isset($this->cursale->id) && in_array($version, $this->cursale->versions)? ' selected="selected"': '').(!isset($this->cursale->id) ? ( ($version == 'fr') ? 'selected' : '' ) :'').'>'.$version.'</option>';
|
|
}
|
|
echo '
|
|
</optgroup>
|
|
</select>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$("#m_versions").multiSelect({
|
|
selectAllText: "'.$this->l('Select all').'",
|
|
noneSelected: " ",
|
|
oneOrMoreSelected: "*"
|
|
});
|
|
});
|
|
</script>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
$countries = Country::getCountries($cookie->id_lang, false);
|
|
echo '<label>'.$this->l('Pays de la Vente :').'</label>
|
|
<div class="margin-form">
|
|
<div id="privatesale_country" style="float: left;">
|
|
<select name="id_country" id="id_country">
|
|
<option value="0"></option>';
|
|
foreach ($countries as $key => $country) {
|
|
echo '<option value="'.$country['id_country'].'"'.($this->cursale!==NULL? ($this->cursale->id_country==$country['id_country']?' selected="selected"': ''): '').'>'.$country['name'].'</option>';
|
|
}
|
|
echo '</select>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
// if(Configuration::get('PRIVATESALES_CARRIERFENCE')) {
|
|
$carriers = Db::getInstance()->ExecuteS('
|
|
SELECT c.`id_carrier`, IF(c.`name` = "0", "'.Configuration::get('PS_SHOP_NAME').'", c.`name`) AS `name`'.($this->cursale !== NULL? ', (
|
|
SELECT IFNULL(p.`id_sale`, NULL) FROM `'._DB_PREFIX_.'privatesale_carrier` p WHERE c.`id_carrier` = p.`id_carrier` AND p.`id_sale` = '.$this->cursale->id.'
|
|
) AS `id_sale`': '').'
|
|
FROM `'._DB_PREFIX_.'carrier` c
|
|
WHERE c.`deleted` != 1
|
|
');
|
|
|
|
$carriers_default = array(22, 87, 88, 89); // prod
|
|
// $carriers_default = array(22, 46, 47, 48); // dev
|
|
|
|
echo '<label>'.$this->l('Carriers:').'</label>
|
|
<div class="margin-form">
|
|
<div id="carriers" style="float: left;">
|
|
<select id="m_carriers" name="m_groups[]" multiple="multiple" size="5">
|
|
<option value=""></option>
|
|
<optgroup label="'.$this->l('Select one or more carriers:').'">';
|
|
if( Tools::getIsset('edit')) {
|
|
foreach($carriers as $carrier) {
|
|
echo '<option value="'.$carrier['id_carrier'].'"'.(isset($carrier['id_sale']) && $carrier['id_sale'] !== NULL?' selected="selected"':'').'>'.$carrier['name'].'</option>';
|
|
}
|
|
} else{
|
|
foreach($carriers as $carrier) {
|
|
echo '<option value="'.$carrier['id_carrier'].'"'.(in_array($carrier['id_carrier'], $carriers_default) ? ' selected="selected"':'').'>'.$carrier['name'].'</option>';
|
|
}
|
|
}
|
|
echo '
|
|
</optgroup>
|
|
</select>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$("#m_carriers").multiSelect({
|
|
selectAllText: "'.$this->l('Select all').'",
|
|
noneSelected: " ",
|
|
oneOrMoreSelected: "*"
|
|
});
|
|
});
|
|
</script>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
|
|
echo '<label>'.$this->l('Livraison seulement en France :').'</label>
|
|
<div class="margin-form">
|
|
<div id="shipping_fr" style="float: left;">
|
|
<input name="shipping_fr" type="radio" value="0"'.($this->cursale!==NULL? ($this->cursale->shipping_fr==0? ' checked="checked"': ''):' checked="checked"').' /> '.$this->l('Non').' <input name="shipping_fr" type="radio" value="1"'.($this->cursale!==NULL && $this->cursale->shipping_fr==1?' checked="checked"': '').' /> '.$this->l('Oui').'
|
|
<sup> *</sup>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>';
|
|
// }
|
|
|
|
// echo '<label>'.$this->l('Sale type:').'</label>
|
|
// <div class="margin-form">
|
|
// <div id="carriers" style="float: left;">
|
|
// '.$this->l('SALETYPE1').' <input '. (isset($this->cursale->sale_type) && in_array(1,$this->cursale->sale_type) ? ' checked': '') .' type="checkbox" name="sale_type[]" value="1">
|
|
// '.$this->l('SALETYPE2').' <input '. (isset($this->cursale->sale_type) && in_array(2,$this->cursale->sale_type) ? ' checked': '') .' type="checkbox" name="sale_type[]" value="2">
|
|
// '.$this->l('SALETYPE3').' <input '. (isset($this->cursale->sale_type) && in_array(3,$this->cursale->sale_type) ? ' checked': '') .' type="checkbox" name="sale_type[]" value="3">
|
|
// </div>
|
|
// </div>';
|
|
|
|
echo '<label>'.$this->l('Description:').'</label>
|
|
<div class="margin-form">';
|
|
foreach($this->_languages as $language) {
|
|
echo '<div id="description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<textarea style="width: 500px; height: 150px;" name="description_'.$language['id_lang'].'">';
|
|
if($this->cursale !== NULL) {
|
|
echo htmlentities($this->cursale->description[$language['id_lang']]);
|
|
// echo htmlentities(utf8_decode($this->cursale->description[$language['id_lang']]));
|
|
}
|
|
echo '</textarea>
|
|
</div>';
|
|
}
|
|
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'description');
|
|
echo '<div class="clear"></div>
|
|
</div>';
|
|
|
|
echo '<label>'.$this->l('Video:').'</label>
|
|
<div class="margin-form">';
|
|
foreach($this->_languages as $language) {
|
|
echo '<div id="video_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="text" name="video_'.$language['id_lang'].'"'.($this->cursale !== NULL? ' value="'.htmlentities($this->cursale->video[$language['id_lang']]).'"': '').' />';
|
|
echo '</div>';
|
|
}
|
|
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'video');
|
|
echo '<div class="clear"></div>
|
|
<p>'.$this->l('Youtube full URL').'</p>
|
|
</div>';
|
|
|
|
foreach($this->imagelist as $k => $v) {
|
|
echo '<label>'.$v[0].'</label>
|
|
<div class="margin-form">';
|
|
foreach($this->_languages as $language) {
|
|
echo '<div id="img_'.$k.'_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="file" name="img_'.$k.'_'.$language['id_lang'].'" />
|
|
<p>'.$this->l('Size:').' '.$v[1].'</p>';
|
|
if($this->cursale !== NULL && file_exists(_PS_ROOT_DIR_.'/modules/privatesales/img/'.$this->cursale->id.'/'.$k.'_'.$language['id_lang'].'.jpg')) {
|
|
echo '<p><a href="'.__PS_BASE_URI__.'modules/privatesales/img/'.$this->cursale->id.'/'.$k.'_'.$language['id_lang'].'.jpg" onclick="window.open(this.href); return false;"> '.$this->l('Preview').'</a></p>';
|
|
}
|
|
echo '
|
|
</div>';
|
|
}
|
|
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'img_'.$k);
|
|
echo '<div class="clear"></div>
|
|
</div>';
|
|
}
|
|
|
|
Module::hookExec('privatesales_edit', array('sale' => $this->cursale));
|
|
|
|
echo '<br class="clear" />
|
|
<div class="margin-form">
|
|
<input type="hidden" name="id_sale" value="'.($this->cursale !== NULL? $this->cursale->id: '').'" />
|
|
<input type="submit" class="button" '.($this->cursale !== NULL ? 'disabled=disabled': '').' name="submitSaleAdd" value="'.$this->l('Add this sale').'" />
|
|
<input type="submit" class="button'.($this->cursale !== NULL? '': ' disable"').'" name="submitSaleUpdate" value="'.$this->l('Edit this sale').'"'.($this->cursale !== NULL? '': ' disabled="disabled"').' id="submitSaleUpdate" />
|
|
</div>';
|
|
|
|
echo '</fieldset>
|
|
</form>';
|
|
}
|
|
|
|
public function display() {
|
|
global $cookie, $currentIndex;
|
|
$this->cursale = NULL;
|
|
if($id = Tools::getValue('id')) {
|
|
$this->cursale = new Sale($id);
|
|
if($this->cursale->id === NULL) {
|
|
Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesSales'));
|
|
}
|
|
}
|
|
|
|
// // ANTADIS INSERT TYPE
|
|
// $ventes = Sale::getSales(NULL, NULL, NULL, NULL , FALSE, FALSE, 'position ASC');
|
|
// foreach ($ventes as $key => $vente) {
|
|
// global $cookie;
|
|
// if($cookie->id_employee == 1){
|
|
// Db::getInstance()->autoExecute('ps_privatesale_type', array(
|
|
// 'id_sale' => $vente->id,
|
|
// 'id_sale_type' => $vente->sale_type,
|
|
// ), 'INSERT');
|
|
// }
|
|
// }
|
|
|
|
$this->displayForm();
|
|
|
|
$export = Module::isInstalled('exports');
|
|
|
|
$employees = array();
|
|
foreach(Db::getInstance()->ExecuteS('
|
|
SELECT `id_employee`, `firstname`, `lastname`
|
|
FROM `'._DB_PREFIX_.'employee`
|
|
') as $row) {
|
|
$employees[(int) $row['id_employee']] = $row['firstname'].' '.$row['lastname'];
|
|
}
|
|
|
|
//ANTADIS
|
|
echo '<fieldset style="margin-top:15px">';
|
|
echo '<legend>Tri des ventes</legend>';
|
|
echo '<input type="submit" value="Ventes actuelles" name="not_ended" class="tri button active">';
|
|
echo '<input type="submit" value="Ventes terminées" name="finished" class="tri button">';
|
|
echo '<input type="submit" value="Toutes les ventes" name="all" class="tri button">';
|
|
echo '</fieldset>';
|
|
|
|
?>
|
|
<script>
|
|
jQuery( document ).ready(function( $ ) {
|
|
var button = $('.tri');
|
|
button.click(function(){
|
|
var type = $(this).attr('name');
|
|
|
|
if(!$(this).hasClass('active')){
|
|
button.removeClass('active');
|
|
$(this).addClass('active');
|
|
$('.list_vente').empty();
|
|
|
|
var loader = "<p class='text-align:center'><img src='../img/loader.gif' /></p>";
|
|
$('.list_vente').html(loader);
|
|
|
|
$.ajax({
|
|
url: "ajax_vp.php",
|
|
type: 'GET',
|
|
data: 'type=' + type + '&getSales',
|
|
success: function(html) {
|
|
$('.list_vente').empty();
|
|
$('.list_vente').html(html);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
$(".updatePosition").live( "click", function(e) {
|
|
e.preventDefault();
|
|
var position = $(this).attr('data-position');
|
|
var way = $(this).attr('data-way');
|
|
|
|
$.ajax({
|
|
url: "ajax_vp.php",
|
|
type: 'GET',
|
|
data: 'position=' + position + '&way='+ way +'&updatePosition',
|
|
success: function() {
|
|
var type = $('.tri.active').attr('name');
|
|
$.ajax({
|
|
url: "ajax_vp.php",
|
|
type: 'GET',
|
|
data: 'type=' + type + '&getSales',
|
|
success: function(html) {
|
|
$('.list_vente').empty();
|
|
$('.list_vente').html(html);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
});
|
|
</script>
|
|
<?php
|
|
|
|
echo '<script type="text/javascript" src="../js/jquery/jquery-ui.min.js"></script>
|
|
|
|
<script language="javascript" type="text/javascript">
|
|
<!--
|
|
$(function() {
|
|
ajax_query = function(){
|
|
$.ajax({
|
|
url: "ajax_vp.php",
|
|
type: "GET",
|
|
data: "type=not_ended&getSales",
|
|
success: function(html) {
|
|
$(".list_vente").empty();
|
|
$(".list_vente").html(html);
|
|
sortable_active();
|
|
$("html, body").animate({
|
|
scrollTop: $(".list_vente").offset().top
|
|
}, 200);
|
|
}
|
|
});
|
|
};
|
|
sortable_active = function(){
|
|
$("#saleActive").sortable({
|
|
axis : "y",
|
|
opacity : 0.6,
|
|
start: function(event, ui) {
|
|
initial_position = ui.item.index();
|
|
},
|
|
stop: function(event, ui) {
|
|
final_position = ui.item.index();
|
|
diff = initial_position - final_position;
|
|
if(diff != 0){
|
|
id_sale = ui.item.attr("id");
|
|
|
|
$.ajax({
|
|
url: "ajax_vp.php",
|
|
type: "GET",
|
|
data: "id_sale=" + id_sale + "&position=" + diff +"&updatePositionDrag",
|
|
success: function(html) {
|
|
var loader = "<p class=\"text-align:center\"><img src=\"../img/loader.gif\" /></p>";
|
|
$(".list_vente").html(loader);
|
|
ajax_query();
|
|
}
|
|
});
|
|
}
|
|
},
|
|
});
|
|
};
|
|
sortable_active();
|
|
$("#saleActive").disableSelection();
|
|
});
|
|
//-->
|
|
</script>
|
|
';
|
|
|
|
|
|
echo '<fieldset class="space">
|
|
<legend><img src="'.__PS_BASE_URI__.'modules/privatesales/prefs.gif" alt="" title="" /> '.$this->l('Sales list').'</legend>
|
|
<table class="table list_vente" style="width: 100%;">
|
|
<thead>
|
|
<tr>
|
|
<th>'.$this->l('ID').'</th>
|
|
<th>'.$this->l('Title').'</th>
|
|
<th>'.$this->l('Start').'</th>
|
|
<th>'.$this->l('End').'</th>
|
|
<th>'.$this->l('Enabled').'</th>
|
|
<th>'.$this->l('Nouveau').'</th>
|
|
<th>'.$this->l('Employee').'</th>
|
|
<th>'.$this->l('FR').'</th>
|
|
<th>'.$this->l('ES').'</th>
|
|
<th>'.$this->l('News').'</th>
|
|
<th>'.$this->l('Position').'</th>
|
|
<th style="width: '.($export? '68': '55').'px;">'.$this->l('Actions').'</th>
|
|
</tr>
|
|
</thead>
|
|
';
|
|
echo ' <tbody id="saleActive" class="sortable">';
|
|
|
|
$sales = Sale::getSales(NULL, NULL, NULL, 'not_ended', FALSE, FALSE, '`position` DESC');
|
|
$ids = array();
|
|
foreach ($sales as $key => $sale) {
|
|
$ids[] = $sale->id;
|
|
}
|
|
$extrafields = PrivateSales_ExtraFields::getFieldsForSale($ids);
|
|
|
|
foreach($sales as $key => $sale) {
|
|
echo '<tr id="item_'.$sale->id. '" class="sale_'.($key%2).'">
|
|
<td>'.$sale->id.'</td>
|
|
<td><strong>'.$sale->title[intval($cookie->id_lang)].'</strong><br/><span style="color:#666; font-style:italic">'.$extrafields[$sale->id][1].'</span></td>
|
|
<td>'.$sale->date_start.'</td>
|
|
<td>'.$sale->date_end.'</td>
|
|
<td>'.($sale->enabled?$this->l('Yes'):$this->l('No')).'</td>
|
|
';
|
|
|
|
if($sale->new == 0){
|
|
echo "<td>".$this->l('No')."</td>";
|
|
}
|
|
else if($sale->new == 1){
|
|
echo "<td>".$this->l('Yes')."</td>";
|
|
}
|
|
else if($sale->new == 3){
|
|
echo "<td>".$this->l('Non défini')."</td>";
|
|
}
|
|
|
|
echo '<td>'.((int) $sale->id_employee != 0? $employees[(int) $sale->id_employee]: '--').'</td>
|
|
<td '.(in_array('fr', $sale->versions) ? 'class="green"' : 'class="red"').'>FR</td>
|
|
<td '.(in_array('es', $sale->versions) ? 'class="green"' : 'class="red"').'>ES</td>
|
|
|
|
<td>'. $sale->forward_news .'</td>
|
|
|
|
<td class="position">';
|
|
if($key != 0){
|
|
echo '<a href="" class="updatePosition" data-way="0" data-position='. $sale->position .'><img title="Haut" alt="Haut" src="../img/admin/up.gif"></a>';
|
|
}
|
|
if($key + 1 != count($sales)){
|
|
echo '<a href="" class="updatePosition" data-way="1" data-position='. $sale->position .'><img title="Bas" alt="Bas" src="../img/admin/down.gif"></a>';
|
|
}
|
|
$category_link = Link::getCategoryLink($sale->id_category);
|
|
echo '</td>
|
|
<td>
|
|
'.($export? '<a onclick="window.open(this.href); return false;" href="'.__PS_BASE_URI__.'modules/exports/exports/privatesales.php?id_sale='.$sale->id.'&adtoken='.Tools::encrypt('PrivateSalesDirectExtract'.$sale->id).'"><img style="cursor: pointer;" title="Exporter cette vente" alt="" src="../img/admin/export.gif"></a>': '').'
|
|
<img style="cursor: pointer;" onclick="itemEdition('.$sale->id.')" title="Éditer cette vente" alt="" src="../img/admin/edit.gif">
|
|
<img style="cursor: pointer;" onclick="itemDeletion('.$sale->id.')" title="Supprimer cette vente" alt="" src="../img/admin/delete.gif">
|
|
<a href="'.$category_link.'" target="_blank">
|
|
<img style="cursor: pointer;" title="Voir cette vente" alt="" src="../img/admin/details.gif">
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
';
|
|
}
|
|
echo '
|
|
</tbody>
|
|
</table>
|
|
</fieldset>';
|
|
|
|
}
|
|
public static function getSaleType($sale_type){
|
|
$type = "";
|
|
|
|
if(in_array(1, $sale_type)){
|
|
$type.= "Bébé ";
|
|
}
|
|
if(in_array(2, $sale_type)){
|
|
$type.= "Enfant ";
|
|
}
|
|
if(in_array(3, $sale_type)){
|
|
$type.= "Maman ";
|
|
}
|
|
|
|
if(empty($type)){
|
|
return "undefined";
|
|
}
|
|
return $type;
|
|
}
|
|
|
|
public function postProcess() {
|
|
global $cookie, $currentIndex;
|
|
|
|
if(Tools::isSubmit('submitSaleAdd')) {
|
|
if (Sale::getSaleFromCategory(Tools::getValue('id_category'))) {
|
|
return false;
|
|
}
|
|
|
|
$sql_position = 'SELECT MAX(position) FROM '. _DB_PREFIX_.'privatesale';
|
|
$position = Db::getInstance()->getValue($sql_position);
|
|
|
|
$sale = new Sale();
|
|
$sale->date_start = Tools::getValue('date_start', '0000-00-00 00:00:00');
|
|
$sale->date_end = Tools::getValue('date_end', '0000-00-00 00:00:00');
|
|
$sale->id_country = (int) Tools::getValue('id_country');
|
|
$sale->enabled = Tools::getValue('enabled', 0);
|
|
$sale->featured = Tools::getValue('featured', 0);
|
|
$sale->logout = Tools::getValue('logout', 0);
|
|
$sale->new = Tools::getValue('new', 0);
|
|
$sale->braderie = Tools::getValue('braderie', 0);
|
|
$sale->forward_news = Tools::getValue('forward_news', 0);
|
|
$sale->pub = Tools::getValue('pub', 0);
|
|
$sale->id_category = Tools::getValue('id_category', Configuration::get('PRIVATESALES_ROOT'));
|
|
$sale->id_employee = (int) Tools::getValue('id_employee');
|
|
$sale->shipping_fr = (int) Tools::getValue('shipping_fr');
|
|
$sale->delivery_delay = (int) Tools::getValue('delivery_delay');
|
|
$sale->sale_type = array();
|
|
$sale->versions = array();
|
|
foreach(Tools::getValue('sale_type', array()) as $sale_type) {
|
|
$sale->sale_type[] = (int) $sale_type;
|
|
}
|
|
|
|
foreach(Language::getLanguages(FALSE) as $language) {
|
|
if($description = Tools::getValue('description_'.$language['id_lang'])) {
|
|
$sale->description[$language['id_lang']] = $description;
|
|
} else {
|
|
$sale->description[$language['id_lang']] = '';
|
|
}
|
|
if($video = Tools::getValue('video_'.$language['id_lang'])) {
|
|
$sale->video[$language['id_lang']] = $video;
|
|
} else {
|
|
$sale->video[$language['id_lang']] = '';
|
|
}
|
|
}
|
|
foreach(Tools::getValue('m_groups', array()) as $group) {
|
|
$sale->groups[] = (int) $group;
|
|
}
|
|
|
|
foreach(Tools::getValue('m_versions', array()) as $version) {
|
|
$sale->versions[] = pSql($version);
|
|
}
|
|
|
|
foreach(Tools::getValue('m_carriers', array()) as $carrier) {
|
|
$sale->carriers[] = (int) $carrier;
|
|
}
|
|
|
|
if( empty($sale->carriers)) {
|
|
echo '<div class="error alert">'.Tools::displayError($this->l('Impossible de créer une vente sans transporteur.')).'</div>';
|
|
exit;
|
|
}
|
|
|
|
$sale->save();
|
|
$sale->buildCategoryCache();
|
|
|
|
if( empty($sale->carriers)) {
|
|
mail('valentin@bebeboutik.com', 'Vente sans transporteur',
|
|
'La vente '. $sale->id.' est sans transporteur',
|
|
'Content-Type: text/plain; charset="utf-8"'."\r\n".'From: contact@bebeboutik.com'."\r\n".'Reply-To: thibault@antadis.com'."\r\n".'Return-Path: thibault@antadis.com'."\r\n");
|
|
}
|
|
|
|
if(!is_dir(_PS_ROOT_DIR_.'/modules/privatesales/img/'.$sale->id)) {
|
|
mkdir(_PS_ROOT_DIR_.'/modules/privatesales/img/'.$sale->id, 0775);
|
|
}
|
|
|
|
foreach(Language::getLanguages(FALSE) as $language) {
|
|
foreach(array_keys($this->imagelist) as $img) {
|
|
if(isset($_FILES['img_'.$img.'_'.$language['id_lang']]) && $_FILES['img_'.$img.'_'.$language['id_lang']]['name'] != '') {
|
|
if(!copy($_FILES['img_'.$img.'_'.$language['id_lang']]['tmp_name'], _PS_ROOT_DIR_.'/modules/privatesales/img/'.$sale->id.'/'.$img.'_'.$language['id_lang'].'.jpg')) {
|
|
echo $this->displayError($this->l('An error occured during the image upload.'));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} elseif(Tools::isSubmit('submitSaleUpdate') && $id_sale = (int) Tools::getValue('id_sale')) {
|
|
$sale = new Sale($id_sale);
|
|
$sale->date_start = Tools::getValue('date_start', '0000-00-00 00:00:00');
|
|
$sale->date_end = Tools::getValue('date_end', '0000-00-00 00:00:00');
|
|
$sale->id_country = (int) Tools::getValue('id_country');
|
|
$sale->enabled = Tools::getValue('enabled', 0);
|
|
$sale->featured = Tools::getValue('featured', 0);
|
|
$sale->logout = Tools::getValue('logout', 0);
|
|
$sale->pub = Tools::getValue('pub', 0);
|
|
$sale->new = Tools::getValue('new', 0);
|
|
$sale->braderie = Tools::getValue('braderie', 0);
|
|
$sale->forward_news = Tools::getValue('forward_news', 0);
|
|
$sale->id_category = Tools::getValue('id_category', Configuration::get('PRIVATESALES_ROOT'));
|
|
$sale->id_employee = (int) Tools::getValue('id_employee');
|
|
$sale->shipping_fr = (int) Tools::getValue('shipping_fr');
|
|
$sale->delivery_delay = (int) Tools::getValue('delivery_delay');
|
|
$sale->sale_type = array();
|
|
$sale->description = array();
|
|
$sale->video = array();
|
|
$sale->groups = array();
|
|
$sale->carriers = array();
|
|
$sale->versions = array();
|
|
foreach(Language::getLanguages(FALSE) as $language) {
|
|
if($description = Tools::getValue('description_'.$language['id_lang'])) {
|
|
$sale->description[$language['id_lang']] = $description;
|
|
} else {
|
|
$sale->description[$language['id_lang']] = '';
|
|
}
|
|
if($video = Tools::getValue('video_'.$language['id_lang'])) {
|
|
$sale->video[$language['id_lang']] = $video;
|
|
} else {
|
|
$sale->video[$language['id_lang']] = '';
|
|
}
|
|
}
|
|
foreach(Tools::getValue('m_groups', array()) as $group) {
|
|
$sale->groups[] = (int) $group;
|
|
}
|
|
foreach(Tools::getValue('m_carriers', array()) as $carrier) {
|
|
$sale->carriers[] = (int) $carrier;
|
|
}
|
|
foreach(Tools::getValue('m_versions', array()) as $version) {
|
|
$sale->versions[] = pSql($version);
|
|
}
|
|
foreach(Tools::getValue('sale_type', array()) as $sale_type) {
|
|
$sale->sale_type[] = (int) $sale_type;
|
|
}
|
|
|
|
if( empty($sale->carriers)) {
|
|
echo '<div class="error alert">'.Tools::displayError($this->l('Impossible d\'éditer une vente sans transporteur.')).'</div>';
|
|
exit;
|
|
}
|
|
|
|
$sale->save();
|
|
$sale->buildCategoryCache();
|
|
|
|
if(!is_dir(_PS_ROOT_DIR_.'/modules/privatesales/img/'.$sale->id)) {
|
|
mkdir(_PS_ROOT_DIR_.'/modules/privatesales/img/'.$sale->id, 0775);
|
|
}
|
|
|
|
foreach(Language::getLanguages(FALSE) as $language) {
|
|
foreach(array_keys($this->imagelist) as $img) {
|
|
if(isset($_FILES['img_'.$img.'_'.$language['id_lang']]) && $_FILES['img_'.$img.'_'.$language['id_lang']]['name'] != '') {
|
|
if(!copy($_FILES['img_'.$img.'_'.$language['id_lang']]['tmp_name'], _PS_ROOT_DIR_.'/modules/privatesales/img/'.$sale->id.'/'.$img.'_'.$language['id_lang'].'.jpg')) {
|
|
echo $this->displayError($this->l('An error occured during the image upload.'));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} elseif(isset($_GET['delete']) && $id_sale = Tools::getValue('id')) {
|
|
Sale::deleteSale($id_sale);
|
|
Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesSales'));
|
|
}
|
|
}
|
|
}
|