2016-01-04 12:49:26 +01:00
|
|
|
<?php
|
|
|
|
include_once(_PS_ROOT_DIR_.'/modules/privatesales/Sale.php');
|
2017-04-11 13:06:48 +02:00
|
|
|
|
2017-01-10 18:06:01 +01:00
|
|
|
require_once(_PS_ROOT_DIR_.'/modules/privatesales_delay/saledelay.php');
|
2016-12-27 10:04:07 +01:00
|
|
|
require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
|
2016-01-04 12:49:26 +01:00
|
|
|
|
|
|
|
class AdminPrivateSalesSales extends AdminTab {
|
2016-04-04 11:47:52 +02:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
private $imagelist;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
$this->lang = TRUE;
|
|
|
|
parent::__construct();
|
|
|
|
$this->imagelist = array(
|
|
|
|
'liston' => array($this->l('Listing image (on)'), '380x178'),
|
|
|
|
'listoff' => array($this->l('Listing image (off)'), '380x178'),
|
2016-06-10 16:49:43 +02:00
|
|
|
'salebg' => array($this->l('Sale background'), '*x*'),
|
2017-04-13 12:55:09 +02:00
|
|
|
//'thumb' => array($this->l('Thumbnail'), '260x108'),
|
|
|
|
//'fb' => array($this->l('Facebook image'), '100x100'),
|
|
|
|
//'trailerbg' => array($this->l('Trailer background'), '*x*'),
|
|
|
|
//'trailercenter' => array($this->l('Trailer center background'), '560x*'),
|
2016-04-04 10:49:37 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2017-03-21 13:07:20 +01:00
|
|
|
$divLangName = 'description¤video¤'.implode('¤', $images).'¤m_extrafields_1_value¤m_extrafields_2_value';
|
|
|
|
$divLangImgName = 'description¤video¤'.implode('¤', $images).'¤m_extrafields_1_value¤m_extrafields_2_value';
|
2016-04-04 10:49:37 +02:00
|
|
|
|
2016-12-27 10:04:07 +01:00
|
|
|
$helperForm = new HelperFormBootstrap();
|
|
|
|
$helperForm->_select2 = true;
|
|
|
|
$helperForm->_inputMask = true;
|
2016-12-29 15:29:23 +01:00
|
|
|
$helperForm->_inputSwitch = true;
|
2016-04-04 10:49:37 +02:00
|
|
|
|
2016-12-27 10:04:07 +01:00
|
|
|
$helperForm->_js .='<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/privatesales/privatesale.js"></script>
|
2016-04-04 10:49:37 +02:00
|
|
|
<script type="text/javascript">
|
2017-03-06 12:54:14 +01:00
|
|
|
i18n_delete = "'.$this->l('Are you sure you want to delete this sale?').'";
|
|
|
|
current_location = "'.$currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesSales').'";
|
2016-04-04 10:49:37 +02:00
|
|
|
</script>
|
2016-12-27 10:04:07 +01:00
|
|
|
<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/privatesales/jquery.multiSelect.js"></script>';
|
2017-03-06 12:54:14 +01:00
|
|
|
|
2016-12-27 10:04:07 +01:00
|
|
|
$helperForm->_css .='<style type="text/css">
|
2016-04-04 10:49:37 +02:00
|
|
|
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 {
|
2017-01-02 16:44:29 +01:00
|
|
|
background : #C0E3B5;
|
|
|
|
color: #55b239!important;
|
2017-01-02 15:49:14 +01:00
|
|
|
font-weight:bold;
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
|
|
|
.red {
|
|
|
|
background : #f29b9b;
|
|
|
|
}
|
2017-01-02 15:49:14 +01:00
|
|
|
.rose {
|
2017-01-02 16:44:29 +01:00
|
|
|
background : rgba(226,110,162,0.2);
|
|
|
|
color: #e36ea2!important;
|
2016-11-21 16:29:22 +01:00
|
|
|
}
|
2017-01-02 15:49:14 +01:00
|
|
|
.table tr:nth-child(even) {
|
2016-11-21 16:29:22 +01:00
|
|
|
background: #F1F1F1;
|
|
|
|
}
|
2017-01-02 15:49:14 +01:00
|
|
|
.table>tbody>tr>td{
|
|
|
|
color:#504d8b;
|
|
|
|
vertical-align:middle;
|
|
|
|
font-size:0.9em;
|
|
|
|
padding: 0 6px 0 4px;
|
2016-11-21 16:29:22 +01:00
|
|
|
}
|
2017-01-02 15:49:14 +01:00
|
|
|
.table .input-group-btn .btn{
|
|
|
|
padding: 4px 5px;
|
|
|
|
color: #504d8b;
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
2016-12-27 10:04:07 +01:00
|
|
|
</style>';
|
|
|
|
echo $helperForm->renderStyle();
|
|
|
|
echo '<div class="panel">
|
|
|
|
<div class="panel-title">
|
|
|
|
<h2>'.$this->l('Edit a sale').'</h2>
|
|
|
|
<div class="clearfix"></div>
|
|
|
|
</div>
|
|
|
|
<div class="panel-content">
|
|
|
|
<form class="form-horizontal" id="sale_form" action="'.$currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesSales').'" method="post" enctype="multipart/form-data">';
|
2016-04-04 10:49:37 +02:00
|
|
|
|
|
|
|
$categories = Db::getInstance()->ExecuteS('
|
|
|
|
SELECT c.`id_category`, l.`name`, l.`link_rewrite`
|
|
|
|
FROM `'._DB_PREFIX_.'category` c, `'._DB_PREFIX_.'category_lang` l
|
2017-01-02 16:44:29 +01:00
|
|
|
WHERE c.`id_category` = l.`id_category`
|
|
|
|
AND l.`id_lang` = '.intval($cookie->id_lang).'
|
|
|
|
AND c.`id_parent` = '.Configuration::get('PRIVATESALES_ROOT').'
|
2016-04-04 10:49:37 +02:00
|
|
|
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();
|
2016-12-27 10:04:07 +01:00
|
|
|
foreach($categories as $category) {
|
|
|
|
$categories_ordered[(string) $category['id_category']] = $category;
|
|
|
|
$id_category_options[(int)$category['id_category']] = array(
|
|
|
|
'label' => $category['id_category'].' - '.$category['name'],
|
|
|
|
'value' => (int) $category['id_category']
|
|
|
|
);
|
|
|
|
if($this->cursale!==NULL && $this->cursale->id_category==$category['id_category']) {
|
|
|
|
$id_category_options[(int)$category['id_category']]['selected'] = true;
|
2016-12-29 15:29:23 +01:00
|
|
|
}elseif(in_array($category['id_category'], $used_categories)){
|
2016-12-27 10:04:07 +01:00
|
|
|
$id_category_options[(int)$category['id_category']]['disabled'] = true;
|
|
|
|
}
|
|
|
|
}
|
2016-04-04 10:49:37 +02:00
|
|
|
|
2016-12-27 10:04:07 +01:00
|
|
|
$helperForm->_js .= '<script type="text/javascript">
|
|
|
|
var categories_ordered = {};
|
|
|
|
categories_ordered = '.json_encode($categories_ordered).';
|
|
|
|
$(document).ready(function() {
|
2017-03-21 13:07:20 +01:00
|
|
|
if($("#id_category").val() != null && $("#id_category").val() != \'undefined\') {
|
|
|
|
$("#title").attr("value", categories_ordered[$("#id_category").val()].name);
|
|
|
|
$("#alias").attr("value", categories_ordered[$("#id_category").val()].link_rewrite);
|
|
|
|
}
|
2017-03-06 12:54:14 +01:00
|
|
|
$("#id_category").change(function(){
|
2017-03-21 15:45:45 +01:00
|
|
|
$("#title").attr("value", categories_ordered[$("#id_category").val()].name);
|
|
|
|
$("#alias").attr("value", categories_ordered[$("#id_category").val()].link_rewrite);
|
2016-12-27 10:04:07 +01:00
|
|
|
});
|
2016-04-04 10:49:37 +02:00
|
|
|
|
2016-12-27 10:04:07 +01:00
|
|
|
$("#date_start").inputmask("9999-99-99 99:99:99");
|
|
|
|
$("#date_end").inputmask("9999-99-99 99:99:99");
|
|
|
|
});
|
|
|
|
</script>';
|
|
|
|
|
2016-12-28 14:15:20 +01:00
|
|
|
echo '<div class="col-md-5">';
|
2016-12-27 10:04:07 +01:00
|
|
|
// select root category
|
|
|
|
$input = array(
|
|
|
|
'type' => 'select2',
|
2016-12-27 11:01:19 +01:00
|
|
|
'label' => $this->l('Root category'),
|
|
|
|
'label-class' => 'text-left',
|
|
|
|
'select-class' => 'text-left',
|
2016-12-27 10:04:07 +01:00
|
|
|
'name' => 'id_category',
|
|
|
|
'options' => $id_category_options,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
|
|
|
// title
|
|
|
|
$input = array(
|
|
|
|
'type' => 'text',
|
|
|
|
'label' => $this->l('Title'),
|
|
|
|
// 'label-class' => 'col-md-2',
|
|
|
|
// 'input-class' => 'col-md-8',
|
|
|
|
'disabled' => true,
|
|
|
|
'name' => 'title',
|
|
|
|
'help' => $this->l('This value is set by the name of the root category for this sale.'),
|
|
|
|
'default' => ($this->cursale!==NULL? $categories_ordered[$this->cursale->id_category]['name']: (in_array($categories[0]['id_category'], $used_categories)? '': $categories[0]['name'])),
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
|
|
|
// Alias
|
|
|
|
$input = array(
|
|
|
|
'type' => 'text',
|
|
|
|
'label' => $this->l('Alias'),
|
|
|
|
// 'label-class' => 'col-md-2',
|
|
|
|
// 'input-class' => 'col-md-8',
|
|
|
|
'disabled' => true,
|
|
|
|
'name' => 'alias',
|
|
|
|
'help' => $this->l('This value is set by the alias of the root category for this sale.'),
|
|
|
|
'default' => ($this->cursale!==NULL? $categories_ordered[$this->cursale->id_category]['link_rewrite']: (in_array($categories[0]['id_category'], $used_categories)? '': $categories[0]['link_rewrite'])),
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
|
|
|
// Date start
|
|
|
|
$input = array(
|
|
|
|
'type' => 'simpleDate',
|
|
|
|
'id' => 'date_start',
|
|
|
|
'name' => 'date_start',
|
|
|
|
'label' => $this->l('Start date'),
|
|
|
|
// 'label-class' => 'control-label col-md-2',
|
|
|
|
// 'input-class' => 'col-md-7',
|
|
|
|
'after' => '<span class="glyphicon glyphicon-calendar"></span>',
|
|
|
|
'value' => ($this->cursale!==NULL? $this->cursale->date_start: ''),
|
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
|
|
|
// Date end
|
|
|
|
$input = array(
|
|
|
|
'type' => 'simpleDate',
|
|
|
|
'id' => 'date_end',
|
|
|
|
'name' => 'date_end',
|
|
|
|
'label' => $this->l('End date'),
|
|
|
|
// 'label-class' => 'control-label col-md-2',
|
|
|
|
// 'input-class' => 'col-md-7',
|
|
|
|
'after' => '<span class="glyphicon glyphicon-calendar"></span>',
|
|
|
|
'value' => ($this->cursale!==NULL? $this->cursale->date_end: ''),
|
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
2016-12-28 14:15:20 +01:00
|
|
|
echo '</div><div class="col-md-5 col-md-offset-2" style="background:#eee;padding:10px;border-radius:7px;">';
|
2016-12-27 10:04:07 +01:00
|
|
|
|
|
|
|
// Status
|
|
|
|
$input = array(
|
2016-12-29 15:29:23 +01:00
|
|
|
'type' => 'switch',
|
2016-12-27 10:04:07 +01:00
|
|
|
'name' => 'enabled',
|
2016-12-29 15:29:23 +01:00
|
|
|
'label' => $this->l('Active :'),
|
|
|
|
// 'label_on' => '<span class="anticon anticon-checkmark text-green-light"></span>',
|
|
|
|
// 'label_off' => '<span class="anticon anticon-cross text-rose"></span>',
|
2016-12-28 14:15:20 +01:00
|
|
|
'label-class' => 'col-sm-8',
|
|
|
|
'input-class' => 'col-sm-4',
|
2017-04-13 12:55:09 +02:00
|
|
|
'default' => ($this->cursale!==NULL?($this->cursale->enabled==0?0:1):1),
|
|
|
|
'checked' => ($this->cursale!==NULL?($this->cursale->enabled==0?0:1):1),
|
2016-12-27 10:04:07 +01:00
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
2016-12-28 14:15:20 +01:00
|
|
|
// Display
|
2016-12-27 10:04:07 +01:00
|
|
|
$input = array(
|
2016-12-29 15:29:23 +01:00
|
|
|
'type' => 'switch',
|
2016-12-27 10:04:07 +01:00
|
|
|
'name' => 'logout',
|
2016-12-29 15:29:23 +01:00
|
|
|
'label' => $this->l('Affichage non inscrits :'),
|
|
|
|
// 'label_on' => '<span class="anticon anticon-user-check text-green-light"></span>',
|
|
|
|
// 'label_off' => '<span class="anticon anticon-user-minus text-rose"></span>',
|
2016-12-28 14:15:20 +01:00
|
|
|
'label-class' => 'col-sm-8',
|
|
|
|
'input-class' => 'col-sm-4',
|
2017-04-12 09:52:43 +02:00
|
|
|
'default' => ($this->cursale!==NULL?($this->cursale->logout==0?0:1):1),
|
|
|
|
'checked' => ($this->cursale!==NULL?($this->cursale->logout==0?0:1):1),
|
2016-12-27 10:04:07 +01:00
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
2016-12-28 14:15:20 +01:00
|
|
|
// Public
|
2016-12-27 10:04:07 +01:00
|
|
|
$input = array(
|
2016-12-29 15:29:23 +01:00
|
|
|
'type' => 'switch',
|
2016-12-27 10:04:07 +01:00
|
|
|
'name' => 'pub',
|
|
|
|
'label' => $this->l('Public sale:'),
|
2016-12-29 15:29:23 +01:00
|
|
|
// 'label_on' => '<span class="anticon anticon-checkmark text-green-light"></span>',
|
|
|
|
// 'label_off' => '<span class="anticon anticon-cross text-rose"></span>',
|
2016-12-28 14:15:20 +01:00
|
|
|
'label-class' => 'col-sm-8',
|
|
|
|
'input-class' => 'col-sm-4',
|
2016-12-27 10:04:07 +01:00
|
|
|
'default' => ($this->cursale!==NULL?($this->cursale->pub==0?0:1):0),
|
2016-12-29 15:29:23 +01:00
|
|
|
'checked' => ($this->cursale!==NULL?($this->cursale->pub==0?0:1):0),
|
2016-12-27 10:04:07 +01:00
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
2016-12-28 14:15:20 +01:00
|
|
|
// Braderie
|
2016-12-27 10:04:07 +01:00
|
|
|
$input = array(
|
2016-12-29 15:29:23 +01:00
|
|
|
'type' => 'switch',
|
2016-12-27 10:04:07 +01:00
|
|
|
'name' => 'braderie',
|
|
|
|
'label' => $this->l('Braderie :'),
|
2016-12-29 15:29:23 +01:00
|
|
|
// 'label_on' => '<span class="anticon anticon-checkmark text-green-light"></span>',
|
|
|
|
// 'label_off' => '<span class="anticon anticon-cross text-rose"></span>',
|
2016-12-28 14:15:20 +01:00
|
|
|
'label-class' => 'col-sm-8',
|
|
|
|
'input-class' => 'col-sm-4',
|
2016-12-27 10:04:07 +01:00
|
|
|
'default' => ($this->cursale!==NULL?($this->cursale->braderie==0?0:1):0),
|
2016-12-29 15:29:23 +01:00
|
|
|
'checked' => ($this->cursale!==NULL?($this->cursale->braderie==0?0:1):0),
|
2016-12-27 10:04:07 +01:00
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
2016-12-28 14:15:20 +01:00
|
|
|
// Featured
|
2016-12-27 10:04:07 +01:00
|
|
|
$input = array(
|
2016-12-29 15:29:23 +01:00
|
|
|
'type' => 'switch',
|
2016-12-27 10:04:07 +01:00
|
|
|
'name' => 'featured',
|
|
|
|
'label' => $this->l('Featured sale:'),
|
2016-12-29 15:29:23 +01:00
|
|
|
// 'label_on' => '<span class="anticon anticon-checkmark text-green-light"></span>',
|
|
|
|
// 'label_off' => '<span class="anticon anticon-cross text-rose"></span>',
|
2016-12-28 14:15:20 +01:00
|
|
|
'label-class' => 'col-sm-8',
|
|
|
|
'input-class' => 'col-sm-4',
|
2016-12-27 10:04:07 +01:00
|
|
|
'default' => ($this->cursale!==NULL?($this->cursale->featured==0?0:1):0),
|
2016-12-29 15:29:23 +01:00
|
|
|
'checked' => ($this->cursale!==NULL?($this->cursale->featured==0?0:1):0),
|
2016-12-27 10:04:07 +01:00
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
2016-12-28 14:15:20 +01:00
|
|
|
// New
|
2016-12-27 10:04:07 +01:00
|
|
|
$input = array(
|
2016-12-29 15:29:23 +01:00
|
|
|
'type' => 'switch',
|
2016-12-27 10:04:07 +01:00
|
|
|
'name' => 'new',
|
|
|
|
'label' => $this->l('Nouveau :'),
|
2016-12-29 15:29:23 +01:00
|
|
|
// 'label_on' => '<span class="anticon anticon-checkmark text-green-light"></span>',
|
|
|
|
// 'label_off' => '<span class="anticon anticon-cross text-rose"></span>',
|
2016-12-28 14:15:20 +01:00
|
|
|
'label-class' => 'col-sm-8',
|
|
|
|
'input-class' => 'col-sm-4',
|
2016-12-27 10:04:07 +01:00
|
|
|
'default' => ($this->cursale!==NULL?($this->cursale->new==0?0:1):0),
|
2016-12-29 15:29:23 +01:00
|
|
|
'checked' => ($this->cursale!==NULL?($this->cursale->new==0?0:1):0),
|
2016-12-27 10:04:07 +01:00
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
2016-12-28 14:15:20 +01:00
|
|
|
// Newsletter
|
2016-12-27 10:04:07 +01:00
|
|
|
$input = array(
|
2016-12-29 15:29:23 +01:00
|
|
|
'type' => 'switch',
|
2016-12-27 10:04:07 +01:00
|
|
|
'name' => 'forward_news',
|
|
|
|
'label' => $this->l('Mise en avant Newsletter :'),
|
2016-12-29 15:29:23 +01:00
|
|
|
// 'label_on' => '<span class="anticon anticon-checkmark text-green-light"></span>',
|
|
|
|
// 'label_off' => '<span class="anticon anticon-cross text-rose"></span>',
|
2016-12-28 14:15:20 +01:00
|
|
|
'label-class' => 'col-sm-8',
|
|
|
|
'input-class' => 'col-sm-4',
|
2016-12-27 10:04:07 +01:00
|
|
|
'default' => ($this->cursale!==NULL?($this->cursale->forward_news==0?0:1):0),
|
2016-12-29 15:29:23 +01:00
|
|
|
'checked' => ($this->cursale!==NULL?($this->cursale->forward_news==0?0:1):0),
|
2016-12-27 10:04:07 +01:00
|
|
|
'required' => true,
|
|
|
|
);
|
2017-04-13 12:55:09 +02:00
|
|
|
//echo $helperForm->generateInput($input);
|
|
|
|
//echo '<div class="clearfix"></div>';
|
2016-12-27 10:04:07 +01:00
|
|
|
|
2016-12-28 14:15:20 +01:00
|
|
|
// Shipping only fr
|
2016-12-27 10:04:07 +01:00
|
|
|
$input = array(
|
2016-12-29 15:29:23 +01:00
|
|
|
'type' => 'switch',
|
2016-12-27 10:04:07 +01:00
|
|
|
'name' => 'shipping_fr',
|
|
|
|
'label' => $this->l('Livraison seulement en France :'),
|
2016-12-29 15:29:23 +01:00
|
|
|
// 'label_on' => '<span class="anticon anticon-checkmark text-green-light"></span>',
|
|
|
|
// 'label_off' => '<span class="anticon anticon-cross text-rose"></span>',
|
2016-12-28 14:15:20 +01:00
|
|
|
'label-class' => 'col-sm-8',
|
|
|
|
'input-class' => 'col-sm-4',
|
2016-12-27 10:04:07 +01:00
|
|
|
'default' => ($this->cursale!==NULL?($this->cursale->shipping_fr==0?0:1):0),
|
2016-12-29 15:29:23 +01:00
|
|
|
'checked' => ($this->cursale!==NULL?($this->cursale->shipping_fr==0?0:1):0),
|
2016-12-27 10:04:07 +01:00
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
2017-01-02 15:49:14 +01:00
|
|
|
echo '<div class="clearfix"></div>
|
|
|
|
</div>
|
|
|
|
<div class="clearfix"></div>
|
2016-12-28 14:15:20 +01:00
|
|
|
<div class="col-sm-5">';
|
|
|
|
|
|
|
|
$id_employee_options = array();
|
2017-04-13 12:55:09 +02:00
|
|
|
foreach(Employee::getEmployeesByProfile(array(1,5)) as $e) {
|
2016-12-28 14:15:20 +01:00
|
|
|
$id_employee_options[(int)$e['id_employee']] = array(
|
|
|
|
'label' => $e['name'],
|
|
|
|
'value' => (int) $e['id_employee']
|
|
|
|
);
|
|
|
|
if($this->cursale!==NULL && $this->cursale->id_employee==$e['id_employee']){
|
|
|
|
$id_employee_options[(int)$e['id_employee']]['selected'] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Employee manager
|
|
|
|
$input = array(
|
|
|
|
'type' => 'select2',
|
|
|
|
'label' => $this->l('Sale manager:'),
|
|
|
|
'label-class' => 'text-left',
|
|
|
|
'select-class' => 'text-left',
|
|
|
|
'name' => 'id_employee',
|
|
|
|
'options' => $id_employee_options,
|
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
|
|
|
$id_delay_options = array(
|
|
|
|
array(
|
|
|
|
'label' => $this->l('Livraison classique'),
|
|
|
|
'value' => 1,
|
|
|
|
'selected' => ($this->cursale!==NULL && $this->cursale->delivery_delay== 1?true:false)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'label' => $this->l('Livraison 48h'),
|
|
|
|
'value' => 2,
|
|
|
|
'selected' => ($this->cursale!==NULL && $this->cursale->delivery_delay== 2?true:false)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'label' => $this->l('Livraison 7 Jours'),
|
|
|
|
'value' => 3,
|
|
|
|
'selected' => ($this->cursale!==NULL && $this->cursale->delivery_delay== 3?true:false)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'label' => $this->l('Livraison 10 Jours'),
|
|
|
|
'value' => 4,
|
|
|
|
'selected' => ($this->cursale!==NULL && $this->cursale->delivery_delay== 4?true:false)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'label' => $this->l('Livraison Noel'),
|
|
|
|
'value' => 5,
|
|
|
|
'selected' => ($this->cursale!==NULL && $this->cursale->delivery_delay== 5?true:false)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'label' => $this->l('Produit Star'),
|
|
|
|
'value' => 6,
|
|
|
|
'selected' => ($this->cursale!==NULL && $this->cursale->delivery_delay== 6?true:false)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'label' => $this->l('Livraison 72h'),
|
|
|
|
'value' => 7,
|
|
|
|
'selected' => ($this->cursale!==NULL && $this->cursale->delivery_delay== 7?true:false)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'label' => $this->l('Livraison 48h Noel'),
|
|
|
|
'value' => 8,
|
|
|
|
'selected' => ($this->cursale!==NULL && $this->cursale->delivery_delay== 8?true:false)
|
|
|
|
),
|
|
|
|
);
|
|
|
|
// Delivery delay
|
|
|
|
$input = array(
|
|
|
|
'type' => 'select2',
|
|
|
|
'label' => $this->l('Délai de livraison :'),
|
|
|
|
'label-class' => 'text-left',
|
|
|
|
'select-class' => 'text-left',
|
|
|
|
'name' => 'delivery_delay',
|
|
|
|
'options' => $id_delay_options,
|
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
2016-04-04 10:49:37 +02:00
|
|
|
|
2016-12-28 14:15:20 +01:00
|
|
|
$id_group_options = array();
|
|
|
|
foreach(Db::getInstance()->ExecuteS('
|
2016-04-04 10:49:37 +02:00
|
|
|
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
|
2016-12-28 14:15:20 +01:00
|
|
|
) as $group) {
|
|
|
|
$id_group_options[(int)$group['id_group']] = array(
|
|
|
|
'label' => $group['name'],
|
|
|
|
'value' => (int) $group['id_group']
|
|
|
|
);
|
|
|
|
if(isset($group['id_sale']) && $group['id_sale'] !== NULL){
|
|
|
|
$id_group_options[(int)$group['id_group']]['selected'] = true;
|
|
|
|
}
|
|
|
|
if(!isset($this->cursale->id) && $group['id_group'] == 1){
|
|
|
|
$id_group_options[(int)$group['id_group']]['selected'] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Group
|
|
|
|
$input = array(
|
|
|
|
'type' => 'select2',
|
|
|
|
'label' => $this->l('Groups:'),
|
|
|
|
'label-class' => 'text-left',
|
|
|
|
'select-class' => 'text-left',
|
|
|
|
'name' => 'm_groups[]',
|
|
|
|
'id' => 'm_groups',
|
|
|
|
'option_all' => true,
|
|
|
|
'option_clear' => true,
|
|
|
|
'options' => $id_group_options,
|
|
|
|
'multiple' => true,
|
|
|
|
'placeholder' => $this->l('Select one or more groups...'),
|
|
|
|
'required' => true,
|
2016-04-04 10:49:37 +02:00
|
|
|
);
|
2016-12-28 14:15:20 +01:00
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
|
|
|
$id_version_options = array(
|
|
|
|
array(
|
|
|
|
'label'=> 'fr',
|
|
|
|
'value'=>'fr',
|
|
|
|
'selected'=>false,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'label'=>'es',
|
|
|
|
'value'=>'es',
|
|
|
|
'selected'=>false,
|
|
|
|
),
|
2016-04-04 10:49:37 +02:00
|
|
|
);
|
2017-01-02 16:44:29 +01:00
|
|
|
foreach($id_version_options as &$version) {
|
|
|
|
if(isset($this->cursale->id) && in_array($version['value'], $this->cursale->versions)){
|
2016-12-28 14:15:20 +01:00
|
|
|
$version['selected'] = true;
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
2017-01-02 16:44:29 +01:00
|
|
|
if(!isset($this->cursale->id) && $version['value'] == 'fr') {
|
2016-12-28 14:15:20 +01:00
|
|
|
$version['selected'] = true;
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-28 14:15:20 +01:00
|
|
|
// Version
|
|
|
|
$input = array(
|
|
|
|
'type' => 'select2',
|
|
|
|
'label' => $this->l('Versions :'),
|
|
|
|
'label-class' => 'text-left',
|
|
|
|
'select-class' => 'text-left',
|
|
|
|
'name' => 'm_versions[]',
|
|
|
|
'id' => 'm_versions',
|
|
|
|
'option_all' => true,
|
|
|
|
'option_clear' => true,
|
|
|
|
'options' => $id_version_options,
|
|
|
|
'multiple' => true,
|
|
|
|
'placeholder' => $this->l('Select one or more versions...'),
|
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
2016-04-04 10:49:37 +02:00
|
|
|
|
2016-12-28 14:15:20 +01:00
|
|
|
$id_country_options = array();
|
|
|
|
$id_country_options[0] = array(
|
|
|
|
'label' => 'Choisir...',
|
|
|
|
'value' => (int) 0
|
|
|
|
);
|
|
|
|
foreach (Country::getCountries($cookie->id_lang, false) as $country) {
|
|
|
|
$id_country_options[(int)$country['id_country']] = array(
|
|
|
|
'label' => $country['name'],
|
|
|
|
'value' => (int) $country['id_country']
|
|
|
|
);
|
|
|
|
if($this->cursale!==NULL && $this->cursale->id_country==$country['id_country']){
|
|
|
|
$id_country_options[(int)$country['id_country']]['selected'] = true;
|
|
|
|
}
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
2016-12-28 14:15:20 +01:00
|
|
|
// country
|
|
|
|
$input = array(
|
|
|
|
'type' => 'select2',
|
|
|
|
'label' => $this->l('Pays de la Vente :'),
|
|
|
|
'label-class' => 'text-left',
|
|
|
|
'select-class' => 'text-left',
|
|
|
|
'name' => 'id_country',
|
|
|
|
'options' => $id_country_options,
|
|
|
|
'required' => true,
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
2016-04-04 10:49:37 +02:00
|
|
|
|
|
|
|
// if(Configuration::get('PRIVATESALES_CARRIERFENCE')) {
|
2016-12-28 17:16:50 +01:00
|
|
|
$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
|
2017-04-19 12:36:41 +02:00
|
|
|
WHERE c.`deleted` != 1 AND c.active =1
|
2016-12-28 17:16:50 +01:00
|
|
|
');
|
|
|
|
|
2017-03-06 12:54:14 +01:00
|
|
|
$carriers_default = Configuration::get('ANT_CARRIERS_SOCOL').','.Configuration::get('ANT_CARRIERS_MR');
|
|
|
|
$carriers_default = explode(',',Configuration::get('ANT_CARRIERS_SOCOL').','.Configuration::get('ANT_CARRIERS_MR'));
|
|
|
|
$carriers_dom = explode(',',Configuration::get('ANT_CARRIER_DOM'));
|
|
|
|
$carriers_drop = explode(',',Configuration::get('ANT_CARRIER_DROP'));
|
2017-01-02 17:13:46 +01:00
|
|
|
|
2016-12-28 17:16:50 +01:00
|
|
|
$id_carrier_options = array();
|
|
|
|
foreach ($carriers as $carrier) {
|
|
|
|
$id_carrier_options[$carrier['id_carrier']] = array(
|
|
|
|
'label' => $carrier['name'],
|
|
|
|
'value' => $carrier['id_carrier']
|
|
|
|
);
|
|
|
|
if(Tools::getIsset('edit') && (isset($carrier['id_sale']) && $carrier['id_sale'] !== NULL)) {
|
|
|
|
$id_carrier_options[$carrier['id_carrier']]['selected'] = true;
|
|
|
|
} elseif (!Tools::getIsset('edit') && in_array($carrier['id_carrier'], $carriers_default)) {
|
|
|
|
$id_carrier_options[$carrier['id_carrier']]['selected'] = true;
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-28 17:16:50 +01:00
|
|
|
// Carriers
|
|
|
|
$input = array(
|
|
|
|
'type' => 'select2',
|
|
|
|
'label' => $this->l('Carriers :'),
|
|
|
|
'label-class' => 'text-left',
|
|
|
|
'select-class' => 'text-left',
|
|
|
|
'name' => 'm_carriers[]',
|
|
|
|
'id' => 'm_carriers',
|
|
|
|
'option_all' => true,
|
|
|
|
'option_clear' => true,
|
|
|
|
'options' => $id_carrier_options,
|
|
|
|
'multiple' => true,
|
|
|
|
'placeholder' => $this->l('Select one or more carriers...'),
|
|
|
|
'required' => true,
|
|
|
|
'buttons' => array(
|
|
|
|
array(
|
2017-01-02 17:13:46 +01:00
|
|
|
'label' => 'Classic',
|
2016-12-28 17:16:50 +01:00
|
|
|
'value' => '"'.implode('","',$carriers_default).'"',
|
|
|
|
'class' => 'defaut_for_',
|
|
|
|
),
|
2017-01-02 17:13:46 +01:00
|
|
|
array(
|
|
|
|
'label' => 'Dom',
|
|
|
|
'value' => '"'.implode('","',$carriers_dom).'"',
|
|
|
|
'class' => 'dom_for_',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'label' => 'Dropshipping',
|
|
|
|
'value' => '"'.implode('","',$carriers_drop).'"',
|
|
|
|
'class' => 'drop_for_',
|
|
|
|
),
|
2016-12-28 17:16:50 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
|
|
|
|
|
|
|
// Description
|
|
|
|
$input = array(
|
|
|
|
'type' => 'textarea',
|
|
|
|
'label' => $this->l('Description:'),
|
|
|
|
'lang' => true,
|
|
|
|
'name' => 'description',
|
|
|
|
'id' => 'description',
|
|
|
|
'required' => true,
|
|
|
|
'languages' => $this->_languages,
|
|
|
|
'id_langs' => $divLangName,
|
|
|
|
'link_flag_img' => '../img/l/',
|
|
|
|
'default' => ($this->cursale !== NULL?$this->cursale->description:'')
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
2016-04-04 10:49:37 +02:00
|
|
|
|
2016-12-28 17:16:50 +01:00
|
|
|
// Video
|
|
|
|
$input = array(
|
|
|
|
'type' => 'text',
|
|
|
|
'label' => $this->l('Video:'),
|
|
|
|
'lang' => true,
|
|
|
|
'name' => 'video',
|
|
|
|
'id' => 'video',
|
|
|
|
'required' => true,
|
|
|
|
'languages' => $this->_languages,
|
|
|
|
'id_langs' => $divLangName,
|
|
|
|
'link_flag_img' => '../img/l/',
|
|
|
|
'default' => ($this->cursale !== NULL?$this->cursale->video:'')
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
Module::hookExec('privatesales_edit', array('sale' => $this->cursale));
|
|
|
|
|
2016-12-28 17:16:50 +01:00
|
|
|
echo '</div>
|
|
|
|
<div class="col-sm-5 col-sm-offset-2" style="background:#eee;padding:20px; border-radius:7px;">
|
|
|
|
<h4 class="text-center"><span class="anticon anticon-images"></span> Images</h4>';
|
2016-04-04 10:49:37 +02:00
|
|
|
foreach($this->imagelist as $k => $v) {
|
2016-12-29 15:29:23 +01:00
|
|
|
$input = array(
|
|
|
|
'type' => 'uploadImage',
|
|
|
|
'lang' => true,
|
|
|
|
'label' => $v[0],
|
|
|
|
'name' => 'img_'.$k,
|
|
|
|
'name_img' => $k,
|
2017-01-03 12:39:13 +01:00
|
|
|
'id' => $k,
|
2016-12-29 15:29:23 +01:00
|
|
|
'help' => $this->l('Size:').' '.$v[1],
|
|
|
|
'languages' => $this->_languages,
|
|
|
|
'default_language' => 2,
|
|
|
|
'input-class' => '',
|
|
|
|
'id_langs' => $divLangImgName,
|
|
|
|
'link_flag_img' => '../img/l/',
|
|
|
|
'url_imgs' => ($this->cursale !== NULL?__PS_BASE_URI__.'modules/privatesales/img/'.$this->cursale->id.'/':''),
|
|
|
|
'url_to_check' => ($this->cursale !== NULL?_PS_ROOT_DIR_.'/modules/privatesales/img/'.$this->cursale->id.'/':''),
|
|
|
|
);
|
|
|
|
echo $helperForm->generateInput($input);
|
|
|
|
echo '<div class="clearfix"></div>';
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
2016-12-28 17:16:50 +01:00
|
|
|
echo '</div>
|
|
|
|
<div class="clear"></div>
|
|
|
|
<div class="ln_solid-small"></div>
|
|
|
|
<div class="text-center">
|
2016-04-04 10:49:37 +02:00
|
|
|
<input type="hidden" name="id_sale" value="'.($this->cursale !== NULL? $this->cursale->id: '').'" />
|
2016-12-28 17:16:50 +01:00
|
|
|
<input type="submit" class="btn btn-primary" '.($this->cursale !== NULL ? 'disabled=disabled': '').' name="submitSaleAdd" value="'.$this->l('Add this sale').'" />
|
|
|
|
<input type="submit" class="btn btn-primary'.($this->cursale !== NULL? '': ' disable"').'" name="submitSaleUpdate" value="'.$this->l('Edit this sale').'"'.($this->cursale !== NULL? '': ' disabled="disabled"').' id="submitSaleUpdate" />
|
2016-04-04 10:49:37 +02:00
|
|
|
</div>';
|
|
|
|
|
2016-12-27 10:04:07 +01:00
|
|
|
echo '</form>
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
echo $helperForm->renderScript();
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function display() {
|
|
|
|
global $cookie, $currentIndex;
|
|
|
|
$this->cursale = NULL;
|
|
|
|
if($id = Tools::getValue('id')) {
|
2016-04-12 15:17:45 +02:00
|
|
|
$this->cursale = new Sale($id);
|
2016-04-04 10:49:37 +02:00
|
|
|
if($this->cursale->id === NULL) {
|
|
|
|
Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesSales'));
|
|
|
|
}
|
|
|
|
}
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
// // ANTADIS INSERT TYPE
|
2016-04-12 15:17:45 +02:00
|
|
|
// $ventes = Sale::getSales(NULL, NULL, NULL, NULL , FALSE, FALSE, 'position ASC');
|
2016-04-04 10:49:37 +02:00
|
|
|
// 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');
|
|
|
|
// }
|
|
|
|
// }
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
$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'];
|
|
|
|
}
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-11-21 16:29:22 +01:00
|
|
|
$sale_shipping = array();
|
|
|
|
foreach(Db::getInstance()->ExecuteS('
|
|
|
|
SELECT *
|
|
|
|
FROM `'._DB_PREFIX_.'privatesale_shipping_sale`
|
|
|
|
WHERE 1
|
|
|
|
') as $ss) {
|
|
|
|
$sale_shipping[$ss['id_sale']] = $ss['id_shipping'];
|
|
|
|
}
|
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
?>
|
|
|
|
<script>
|
2017-03-21 13:07:20 +01:00
|
|
|
function updatePositionVP(way,position) {
|
|
|
|
$.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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-04-04 10:49:37 +02:00
|
|
|
jQuery( document ).ready(function( $ ) {
|
2017-03-21 13:07:20 +01:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
var button = $('.tri');
|
|
|
|
button.click(function(){
|
|
|
|
var type = $(this).attr('name');
|
|
|
|
|
|
|
|
if(!$(this).hasClass('active')){
|
|
|
|
button.removeClass('active');
|
|
|
|
$(this).addClass('active');
|
|
|
|
$('.list_vente').empty();
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-10-14 13:10:56 +02:00
|
|
|
var loader = "<p style='text-align:center'><img src='../img/loader_payment.gif' /></p>";
|
2017-01-05 11:14:54 +01:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
$('.list_vente').html(loader);
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
$.ajax({
|
|
|
|
url: "ajax_vp.php",
|
|
|
|
type: 'GET',
|
|
|
|
data: 'type=' + type + '&getSales',
|
|
|
|
success: function(html) {
|
|
|
|
$('.list_vente').empty();
|
|
|
|
$('.list_vente').html(html);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-12-27 10:04:07 +01:00
|
|
|
$(".updatePosition").click(function(e) {
|
2016-04-12 15:17:45 +02:00
|
|
|
e.preventDefault();
|
2016-04-04 10:49:37 +02:00
|
|
|
var position = $(this).attr('data-position');
|
|
|
|
var way = $(this).attr('data-way');
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
$.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);
|
|
|
|
}
|
2016-04-12 15:17:45 +02:00
|
|
|
});
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<?php
|
|
|
|
|
2017-04-11 15:27:46 +02:00
|
|
|
//echo '<script type="text/javascript" src="../js/jquery/jquery-ui.min.js"></script>';
|
2016-04-04 10:49:37 +02:00
|
|
|
|
2016-12-27 10:04:07 +01:00
|
|
|
echo '<script language="javascript" type="text/javascript">
|
2016-04-04 10:49:37 +02:00
|
|
|
<!--
|
|
|
|
$(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) {
|
2016-11-21 16:29:22 +01:00
|
|
|
var loader = "<p style=\"text-align:center\"><img style=\"display:inline-block;\" src=\"../img/loader_payment.gif\" /></p>";
|
2016-04-04 10:49:37 +02:00
|
|
|
$(".list_vente").html(loader);
|
|
|
|
ajax_query();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
sortable_active();
|
|
|
|
$("#saleActive").disableSelection();
|
|
|
|
});
|
|
|
|
//-->
|
|
|
|
</script>
|
|
|
|
';
|
|
|
|
|
|
|
|
|
2016-12-27 10:04:07 +01:00
|
|
|
echo '
|
|
|
|
<div class="panel">
|
|
|
|
<div class="panel-title">
|
|
|
|
<h2>'.$this->l('Sales list').'</h2>
|
2017-01-02 17:07:35 +01:00
|
|
|
<div class="nav navbar-right panel_toolbox">
|
|
|
|
<div class="btn-group">
|
2017-03-21 13:07:20 +01:00
|
|
|
<button type="submit" name="not_ended" class="tri btn btn-default active">Ventes actuelles</button>
|
2017-01-02 17:07:35 +01:00
|
|
|
<button type="submit" name="finished" class="tri btn btn-default">Ventes terminées</button>
|
|
|
|
<button type="submit" name="all" class="tri btn btn-default">Toutes les ventes</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-12-27 10:04:07 +01:00
|
|
|
<div class="clearfix"></div>
|
|
|
|
</div>
|
|
|
|
<div class="panel-content">
|
2017-01-02 15:49:14 +01:00
|
|
|
<table class="table list_vente table-custombordered" style="width: 100%;">
|
2016-12-27 10:04:07 +01:00
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>'.$this->l('ID').'</th>
|
2017-03-21 14:54:06 +01:00
|
|
|
<th>'.$this->l('Cat.').'</th>
|
2016-12-27 10:04:07 +01:00
|
|
|
<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>
|
2017-03-21 14:39:43 +01:00
|
|
|
<th>'.$this->l('Delay').'</th>
|
2017-03-21 14:54:06 +01:00
|
|
|
<th>'.$this->l('Expe').'</th>
|
2016-12-27 10:04:07 +01:00
|
|
|
<th>'.$this->l('News').'</th>
|
|
|
|
<th>'.$this->l('Position').'</th>
|
2017-01-02 15:49:14 +01:00
|
|
|
<th>'.$this->l('Actions').'</th>
|
2016-12-27 10:04:07 +01:00
|
|
|
</tr>
|
|
|
|
</thead>';
|
2016-04-04 10:49:37 +02:00
|
|
|
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);
|
2016-04-12 15:17:45 +02:00
|
|
|
|
|
|
|
foreach($sales as $key => $sale) {
|
2017-01-24 17:32:22 +01:00
|
|
|
$delay = SaleDelay::getDelaySmallName($sale->delivery_delay,2);
|
2016-04-04 10:49:37 +02:00
|
|
|
echo '<tr id="item_'.$sale->id. '" class="sale_'.($key%2).'">
|
|
|
|
<td>'.$sale->id.'</td>
|
2016-10-05 11:25:43 +02:00
|
|
|
<td>'.$sale->id_category.'</td>
|
2017-03-21 14:54:06 +01:00
|
|
|
<td><strong>'.$sale->title[intval($cookie->id_lang)].'</strong><br/><span style="color:#666; font-style:italic; font-size:11px;">'.$extrafields[$sale->id][1].'</span></td>
|
|
|
|
<td style="font-size:11px;">'.$sale->date_start.'</td>
|
|
|
|
<td style="font-size:11px;">'.$sale->date_end.'</td>
|
2017-03-21 13:07:20 +01:00
|
|
|
<td align="center">'.($sale->enabled?'<span class="anticon anticon-checkmark text-green-light"></span>':'<span class="anticon anticon-cross text-rose"></span>').'</td>
|
2016-04-04 10:49:37 +02:00
|
|
|
';
|
|
|
|
|
|
|
|
if($sale->new == 0){
|
2017-03-21 13:07:20 +01:00
|
|
|
echo "<td align='center'>".$this->l('No')."</td>";
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
|
|
|
else if($sale->new == 1){
|
2017-03-21 13:07:20 +01:00
|
|
|
echo "<td align='center'>".$this->l('Yes')."</td>";
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
|
|
|
else if($sale->new == 3){
|
2017-03-21 13:07:20 +01:00
|
|
|
echo "<td align='center'>".$this->l('Non défini')."</td>";
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
echo '<td>'.((int) $sale->id_employee != 0? $employees[(int) $sale->id_employee]: '--').'</td>
|
2017-01-02 15:49:14 +01:00
|
|
|
<td class="text-center '.(in_array('fr', $sale->versions) ? 'green' : 'rose').'">FR</td>
|
|
|
|
<td class="text-center '.(in_array('es', $sale->versions) ? 'green' : 'rose').'">ES</td>
|
2017-03-21 14:39:43 +01:00
|
|
|
<td align="center">'.$delay.'</td>
|
2017-01-02 16:44:29 +01:00
|
|
|
<td align="center">'.(isset($sale_shipping[(int) $sale->id])? ($sale_shipping[(int) $sale->id] == 1? 'Philea': ''): '').'</td>
|
2016-11-21 16:29:22 +01:00
|
|
|
|
2017-01-02 16:44:29 +01:00
|
|
|
<td align="center">'. $sale->forward_news .'</td>
|
2017-01-10 17:49:21 +01:00
|
|
|
|
2017-01-02 15:49:14 +01:00
|
|
|
<td align="center" class="position">';
|
2016-04-04 10:49:37 +02:00
|
|
|
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)){
|
2017-01-02 15:49:14 +01:00
|
|
|
echo ' <a href="" class="updatePosition" data-way="1" data-position='. $sale->position .'><img title="Bas" alt="Bas" src="../img/admin/down.gif"></a>';
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
2016-04-12 15:17:45 +02:00
|
|
|
$category_link = Link::getCategoryLink($sale->id_category);
|
2017-01-02 15:49:14 +01:00
|
|
|
$category_link_bo = '?tab=AdminCatalog&viewcategory&id_category='.$sale->id_category.'&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee));
|
2016-04-04 10:49:37 +02:00
|
|
|
echo '</td>
|
|
|
|
<td>
|
2017-01-02 15:49:14 +01:00
|
|
|
<div class="input-group-btn" role="group">
|
|
|
|
<button class="btn btn-default" onclick="itemEdition('.$sale->id.')" title="Editer la vente">
|
2017-03-21 14:57:26 +01:00
|
|
|
<span style="font-size:12px;" class="anticon anticon-pencil2"></span>
|
2017-01-02 15:49:14 +01:00
|
|
|
</button>
|
|
|
|
<a href="'.$category_link.'" target="_blank" class="btn btn-default" title="Voir la vente sur le site">
|
2017-03-21 14:57:26 +01:00
|
|
|
<span style="font-size:12px;" class="anticon anticon-eye"></span>
|
2017-01-02 15:49:14 +01:00
|
|
|
</a>
|
2017-03-21 13:07:20 +01:00
|
|
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
2017-03-21 14:57:26 +01:00
|
|
|
<span style="font-size:12px;" class="anticon anticon-menu"></span>
|
2017-01-02 15:49:14 +01:00
|
|
|
</button>
|
|
|
|
|
|
|
|
<ul class="dropdown-menu dropdown-menu-right">
|
|
|
|
'.($export? '
|
|
|
|
<li>
|
2017-04-12 09:52:43 +02:00
|
|
|
<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).'">
|
2017-01-02 15:49:14 +01:00
|
|
|
<i class="glyphicon glyphicon-new-window"></i> Exporter
|
|
|
|
</a>
|
|
|
|
</li>':'').'
|
|
|
|
<li>
|
|
|
|
<a onclick="window.open(this.href); return false;" href="'.$category_link_bo.'">
|
|
|
|
<i class="glyphicon glyphicon-eye-open"></i> Voir Catégorie BO
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li role="separator" class="divider"></li>
|
|
|
|
<li>
|
|
|
|
<a style="cursor: pointer;" onclick="itemDeletion('.$sale->id.')">
|
|
|
|
<span class="anticon anticon-bin"></span> Supprimer
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
';
|
2017-01-02 15:49:14 +01:00
|
|
|
// '.($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>
|
2016-04-04 10:49:37 +02:00
|
|
|
}
|
|
|
|
echo '
|
2016-12-27 10:04:07 +01:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>';
|
2016-04-04 10:49:37 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
$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');
|
2016-05-30 15:42:20 +02:00
|
|
|
$sale->shipping_fr = (int) Tools::getValue('shipping_fr');
|
2016-04-04 10:49:37 +02:00
|
|
|
$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;
|
|
|
|
}
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
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();
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
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) {
|
2016-11-18 10:54:38 +01:00
|
|
|
if((int)$language['id_lang'] == 3 && ($img == 'liston' || $img == 'listoff' || $img == 'thumb')
|
2016-11-09 17:50:41 +01:00
|
|
|
&& (!isset($_FILES['img_'.$img.'_'.$language['id_lang']]) || $_FILES['img_'.$img.'_'.$language['id_lang']]['name'] == '')
|
|
|
|
&& (isset($_FILES['img_'.$img.'_2']) && $_FILES['img_'.$img.'_2']['name'] != '')
|
|
|
|
) {
|
|
|
|
if(!copy($_FILES['img_'.$img.'_2']['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($_FILES['img_'.$img.'_'.$language['id_lang']]) && $_FILES['img_'.$img.'_'.$language['id_lang']]['name'] != '') {
|
2016-04-04 10:49:37 +02:00
|
|
|
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');
|
2016-05-30 15:42:20 +02:00
|
|
|
$sale->shipping_fr = (int) Tools::getValue('shipping_fr');
|
2016-04-04 10:49:37 +02:00
|
|
|
$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;
|
|
|
|
}
|
2016-04-12 15:17:45 +02:00
|
|
|
|
2016-04-04 10:49:37 +02:00
|
|
|
$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) {
|
2016-11-18 10:54:38 +01:00
|
|
|
if((int)$language['id_lang'] == 3 && ($img == 'liston' || $img == 'listoff' || $img == 'thumb')
|
2016-11-09 17:50:41 +01:00
|
|
|
&& (!isset($_FILES['img_'.$img.'_'.$language['id_lang']]) || $_FILES['img_'.$img.'_'.$language['id_lang']]['name'] == '')
|
|
|
|
&& (isset($_FILES['img_'.$img.'_2']) && $_FILES['img_'.$img.'_2']['name'] != '')
|
|
|
|
) {
|
|
|
|
if(!copy($_FILES['img_'.$img.'_2']['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($_FILES['img_'.$img.'_'.$language['id_lang']]) && $_FILES['img_'.$img.'_'.$language['id_lang']]['name'] != '') {
|
2016-04-04 10:49:37 +02:00
|
|
|
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'));
|
|
|
|
}
|
|
|
|
}
|
2016-01-04 12:49:26 +01:00
|
|
|
}
|