2016-01-04 12:49:26 +01:00
< ? php
include_once ( _PS_ROOT_DIR_ . '/modules/privatesales/Sale.php' );
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 (
'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' ),
2016-06-10 16:49:43 +02:00
'salebg' => array ( $this -> l ( 'Sale background' ), '*x*' ),
2016-04-04 10:49:37 +02:00
'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?').' " ;
2016-09-06 11:07:40 +02:00
i18n_delete_img = " '. $this->l ('Are you sure you want to delete this image?').' " ;
2016-04-04 10:49:37 +02:00
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 : 1 px solid #e0d0b1;
padding - right : 20 px ;
position : relative ;
cursor : default ;
text - decoration : none ;
color : black ;
display : - moz - inline - stack ;
display : inline - block ;
vertical - align : top ;
margin - top : 2 px ;
}
a . multiSelect : link , a . multiSelect : visited , a . multiSelect : hover , a . multiSelect : active {
color : black ;
text - decoration : none ;
}
a . multiSelect span {
margin : 1 px 0 px 1 px 3 px ;
overflow : hidden ;
display : - moz - inline - stack ;
display : inline - block ;
white - space : nowrap ;
font - size : 12 px ;
}
a . multiSelect . hover {
background - image : url ( '.__PS_BASE_URI__.' modules / privatesales / dropdown . blue . hover . png );
}
a . multiSelect . active , a . multiSelect . focus {
border : inset 1 px #000000;
}
a . multiSelect . active {
background - image : url ( '.__PS_BASE_URI__.' modules / privatesales / dropdown . blue . active . png );
}
. multiSelectOptions {
margin - top : - 1 px ;
overflow - y : auto ;
overflow - x : hidden ;
border : solid 1 px #b2b2b2;
background : #ffffff;
}
. multiSelectOptions label {
padding : 0 px 2 px ;
display : block ;
white - space : nowrap ;
float : none ;
text - align : left ;
width : auto ;
}
. multiSelectOptions label . optGroup {
font - weight : bold ;
}
. multiSelectOptions . optGroupContainer label {
padding - left : 10 px ;
font - size : 12 px ;
color : #333333;
padding : 2 px 0 px ;
}
. multiSelectOptions . optGroupHasCheckboxes . optGroupContainer label {
padding - left : 18 px ;
}
. multiSelectOptions input {
vertical - align : middle ;
margin - right : 5 px ;
}
. multiSelectOptions label . checked {
background - color : #dce5f8;
}
. multiSelectOptions label . optGroup {
color : #000000;
font - size : 12 px ;
margin - bottom : 2 px ;
}
. multiSelectOptions label . selectAll {
border - bottom : dotted 1 px #cccccc;
font - size : 12 px ;
color : #333333;
padding - top : 2 px ;
margin : 0 px 0 px 6 px ;
}
. multiSelectOptions label . hover {
background - color : #3399ff;
color : #ffffff;
}
. green {
background : #dffad3;
}
. red {
background : #f29b9b;
}
2016-10-14 13:10:56 +02:00
fieldset . bg - grey {
background : #F1F1F1;
border : 1 px solid #565485;
}
fieldset . bg - grey legend {
background : rgba ( 86 , 84 , 133 , 0.9 );
border : 1 px solid #565485;
color : #fff;
font - weight : 300 ;
}
table {
background : #fff;
padding : 20 px ;
- moz - box - shadow : 2 px 2 px 5 px #cccccc;
- webkit - box - shadow : 2 px 2 px 5 px #CCC;
- ms - box - shadow : 2 px 2 px 5 px #cccccc;
- o - box - shadow : 2 px 2 px 5 px #cccccc;
box - shadow : 2 px 2 px 5 px #CCC;
border - collapse : collapse ;
border - spacing : 0 ;
}
. table {
border : 1 px solid #565485;
}
. table tr th {
background : rgba ( 86 , 84 , 133 , 0.9 );
color : #fff;
font - weight : 300 ;
}
. table tr td {
border - bottom : 1 px solid #DEDEDE;
color : #000;
padding : 0 4 px 0 6 px ;
}
. table tr td : nth - child ( 6 ),
. table tr td : nth - child ( 7 ),
. table tr td : nth - child ( 11 ),
. table tr td : nth - child ( 12 ){
text - align : center ;
}
. table tr : nth - child ( odd ){
background : #F3F3F3;
}
. button . purple {
background - color : rgba ( 86 , 84 , 133 , 0.7 );
border : 1 px solid #565485;
border - left : 1 px solid rgba ( 86 , 84 , 133 , 0.6 );
border - top : 1 px solid rgba ( 86 , 84 , 133 , 0.6 );
color : rgba ( 255 , 255 , 255 , 0.9 );
padding : 3 px ;
}
. button . purple : hover {
background - color : #565485;
border : 1 px solid rgba ( 86 , 84 , 133 , 0.6 );
border - left : 1 px solid #565485;
border - top : 1 px solid #565485;
color : #fff;
padding : 3 px ;
}
. button . purple : focus {
background - color : rgba ( 86 , 84 , 133 , 1.6 );
}
#delivery_mode{
margin - bottom : 5 px ;
}
. carriers_info {
background : #fff;
padding : 10 px ;
border : 1 px solid #ccc;
}
. carriers_hidden {
display : none ;
2016-04-04 10:49:37 +02:00
}
</ 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 ').' & nbsp ; & nbsp ; & nbsp ; < 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 ').' & nbsp ; & nbsp ; & nbsp ; < 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 > ' ;
2016-04-12 15:17:45 +02:00
2016-04-04 10:49:37 +02:00
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 ').' & nbsp ; & nbsp ; & nbsp ; < 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 > ' ;
2016-04-12 15:17:45 +02:00
2016-04-04 10:49:37 +02:00
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 ').' & nbsp ; & nbsp ; & nbsp ; < 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 ').' & nbsp ; & nbsp ; & nbsp ; < 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 > ' ;
2016-04-12 15:17:45 +02:00
2016-04-04 10:49:37 +02:00
echo '<label>' . $this -> l ( 'Nouveau :' ) . ' </ label >
< div class = " margin-form " >
2016-04-12 15:17:45 +02:00
< div id = " new " style = " float: left; " >
2016-04-04 10:49:37 +02:00
< input name = " new " type = " radio " value = " 0 " '.($this->cursale!==NULL? ($this->cursale->new==0? ' checked = " checked " ': ' '):' checked = " checked " ').' /> '.$this->l(' Non ').' & nbsp ; & nbsp ; & nbsp ; < 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 " >
2016-04-12 15:17:45 +02:00
< div id = " forward_news " style = " float: left; " >
2016-04-04 10:49:37 +02:00
< input name = " forward_news " type = " radio " value = " 0 " '.($this->cursale!==NULL? ($this->cursale->forward_news==0? ' checked = " checked " ': ' '):' checked = " checked " ').' /> '.$this->l(' Non ').' & nbsp ; & nbsp ; & nbsp ; < 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 48 h ').' </ 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 72 h ').' </ option >
2016-11-07 15:35:15 +01:00
< option value = " 8 " '.($this->cursale!==NULL? ($this->cursale->delivery_delay== 8? ' selected = " selected " ': ' '):' ').' > '.$this->l(' Livraison 48 h Noel ').' </ option >
2016-04-04 10:49:37 +02:00
</ 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
' );
2016-10-20 13:48:55 +02:00
// $carriers_default = array(87, 88, 89); // prod
$carriers_default = array ( 45 , 47 , 48 ); // dev
2016-04-04 10:49:37 +02:00
echo '<label>' . $this -> l ( 'Carriers:' ) . ' </ label >
< div class = " margin-form " >
< div id = " carriers " style = " float: left; " >
2016-10-14 13:10:56 +02:00
< select id = " delivery_mode " name = " delivery_mode " >
< option value = " 0 " > '.$this->l(' Select Expedition ').' </ option >
< option value = " 1 " > '.$this->l(' Expédition classique ').' </ option >
< option value = " 2 " > '.$this->l(' Expédition domicile uniquement ').' </ option >
2016-10-20 13:48:55 +02:00
< option value = " 3 " > '.$this->l(' Expédition dropshipping ').' </ option >
2016-10-14 13:10:56 +02:00
</ select >
2016-10-20 13:48:55 +02:00
< div class = " carriers_info " '.(($cookie->id_employee == 1)?' ':' style = " display:none; " ').' >
2016-10-14 13:10:56 +02:00
< h3 > '.$this->l(' Transporteurs selectionnés : ').' </ h3 >
< div class = " info " ></ div >
</ div >
< div class = " carriers_hidden " > ' ;
if ( Tools :: getIsset ( 'edit' )) {
foreach ( $carriers as $carrier ) {
echo '<input name="m_carriers[]" type="checkbox" value="' . $carrier [ 'id_carrier' ] . '"' . ( isset ( $carrier [ 'id_sale' ]) && $carrier [ 'id_sale' ] !== NULL ? ' checked="checked"' : '' ) . ' data-carrier-name="' . $carrier [ 'name' ] . '"/>' ;
2016-04-04 10:49:37 +02:00
}
2016-10-14 13:10:56 +02:00
} else {
foreach ( $carriers as $carrier ) {
echo '<input name="m_carriers[]" type="checkbox" value="' . $carrier [ 'id_carrier' ] . '"' . ( in_array ( $carrier [ 'id_carrier' ], $carriers_default ) ? ' checked="checked"' : '' ) . ' data-carrier-name="' . $carrier [ 'name' ] . '"/>' ;
}
}
echo ' </ div ></ div >
2016-04-04 10:49:37 +02:00
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
2016-10-20 13:48:55 +02:00
var carriers_selected = [];
2016-10-14 13:10:56 +02:00
var carriers_info = " " ;
$ ( " input[name= \ 'm_carriers[] \ ']:checked " ) . each ( function ( i , el ) {
carriers_info += " <p> " + $ ( el ) . data ( " carrier-name " ) + " </p> " ;
2016-10-20 13:48:55 +02:00
carriers_selected . push ( $ ( el ) . val ());
2016-10-14 13:10:56 +02:00
});
$ ( " .carriers_info div.info " ) . html ( carriers_info );
2016-10-20 14:03:15 +02:00
console . log ( $ . inArray ( " 45 " , carriers_selected ));
if ( $ . inArray ( " 45 " , carriers_selected ) != - 1 && $ . inArray ( " 47 " , carriers_selected ) != - 1 && $ . inArray ( " 48 " , carriers_selected ) != - 1 ) {
$ ( " #delivery_mode option[value= \ '1 \ '] " ) . attr ( " selected " , " selected " );
} else if ( $ . inArray ( " 45 " , carriers_selected ) != - 1 ) {
console . log ( " test " );
$ ( " #delivery_mode option[value= \ '2 \ '] " ) . attr ( " selected " , " selected " );
} else if ( $ . inArray ( " 22 " , carriers_selected ) != - 1 ) {
$ ( " #delivery_mode option[value= \ '3 \ '] " ) . attr ( " selected " , " selected " );
2016-10-20 13:48:55 +02:00
}
2016-10-14 13:10:56 +02:00
$ ( " #delivery_mode " ) . change ( function (){
carriers_info = " " ;
$ ( " input[name= \ 'm_carriers[] \ '] " ) . each ( function ( i , el ) {
$ ( el ) . attr ( " checked " , false );
});
var selected_carriers = [];
2016-10-20 13:48:55 +02:00
if ( $ ( this ) . val () == 1 ) {
selected_carriers = [ " 45 " , " 47 " , " 48 " ];
} else if ( $ ( this ) . val () == 2 ) {
selected_carriers = [ " 45 " ];
} else if ( $ ( this ) . val () == 3 ) {
selected_carriers = [ " 22 " ];
2016-10-14 13:10:56 +02:00
}
$ ( " input[name= \ 'm_carriers[] \ '] " ) . each ( function (){
if ( $ . inArray ( $ ( this ) . val (), selected_carriers ) != - 1 ){
$ ( this ) . attr ( " checked " , true );
carriers_info += " <p> " + $ ( this ) . data ( " carrier-name " ) + " </p> " ;
}
});
$ ( " .carriers_info div.info " ) . empty ();
$ ( " .carriers_info div.info " ) . html ( carriers_info );
2016-04-04 10:49:37 +02:00
});
});
</ script >
< div class = " clear " ></ div >
</ div > ' ;
2016-05-30 15:42:20 +02:00
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 ').' & nbsp ; & nbsp ; & nbsp ; < 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 > ' ;
2016-04-04 10:49:37 +02:00
// }
// echo '<label>'.$this->l('Sale type:').'</label>
// <div class="margin-form">
2016-04-12 15:17:45 +02:00
// <div id="carriers" style="float: left;">
2016-04-04 10:49:37 +02:00
// '.$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>';
2016-04-12 15:17:45 +02:00
2016-04-04 10:49:37 +02:00
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'] .' " > ' ;
2016-04-12 15:17:45 +02:00
if ( $this -> cursale !== NULL ) {
2016-04-04 10:49:37 +02:00
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' )) {
2016-09-06 11:07:40 +02:00
$imgName = $k . '_' . $language [ 'id_lang' ];
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 >
< img style = " cursor: pointer; " onclick = " ImgDeletion('. $this->cursale ->id.', \ ''. $imgName .' \ ') " title = " Supprimer cette image " alt = " " src = " ../img/admin/delete.gif " >
</ p > ' ;
2016-04-04 10:49:37 +02:00
}
echo '
</ div > ' ;
}
$this -> displayFlags ( $this -> _languages , $this -> _defaultFormLanguage , $divLangName , 'img_' . $k );
echo ' < div class = " clear " ></ div >
</ 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 ));
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' )) {
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
//ANTADIS
2016-10-14 13:10:56 +02:00
echo '<fieldset class="bg-grey" style="margin-top:15px">' ;
2016-04-04 10:49:37 +02:00
echo '<legend>Tri des ventes</legend>' ;
2016-10-14 13:10:56 +02:00
echo '<input type="submit" value="Ventes actuelles" name="not_ended" class="tri button purple active" style="margin-right:10px;">' ;
echo '<input type="submit" value="Ventes terminées" name="finished" class="tri button purple" style="margin-right:10px;">' ;
echo '<input type="submit" value="Toutes les ventes" name="all" class="tri button purple">' ;
2016-04-04 10:49:37 +02:00
echo '</fieldset>' ;
2016-04-12 15:17:45 +02:00
2016-04-04 10:49:37 +02:00
?>
< 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 ();
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> " ;
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 );
}
});
}
});
$ ( " .updatePosition " ) . live ( " 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
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 ) {
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-10-14 13:10:56 +02:00
echo ' < fieldset class = " space bg-grey " >
2016-04-04 10:49:37 +02:00
< 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 >
2016-10-05 11:25:43 +02:00
< th > '.$this->l(' Categorie ').' </ th >
2016-04-04 10:49:37 +02: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 >
2016-11-21 16:29:22 +01:00
< th > '.$this->l(' Shipping ').' </ th >
2016-04-04 10:49:37 +02:00
< 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 );
2016-04-12 15:17:45 +02:00
foreach ( $sales as $key => $sale ) {
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 >
2016-04-04 10:49:37 +02:00
< 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 >
2016-10-14 13:10:56 +02:00
< td > '.($sale->enabled?' < img src = " ../img/admin/module_install.png " /> ':' < img src = " ../img/admin/module_notinstall.png " /> ').' </ td >
2016-04-04 10:49:37 +02:00
' ;
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> " ;
}
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 >
< td '.(in_array(' fr ', $sale->versions) ? ' class = " green " ' : ' class = " red " ').' > FR </ td >
< td '.(in_array(' es ', $sale->versions) ? ' class = " green " ' : ' class = " red " ').' > ES </ td >
2016-11-21 16:29:22 +01:00
< td > '.(isset($sale_shipping[(int) $sale->id])? ($sale_shipping[(int) $sale->id] == 1? ' Philea ': ' '): ' ').' </ td >
2016-04-04 10:49:37 +02:00
< 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>' ;
}
2016-04-12 15:17:45 +02:00
$category_link = Link :: getCategoryLink ( $sale -> id_category );
2016-04-04 10:49:37 +02:00
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 " >
2016-04-12 15:17:45 +02:00
< img style = " cursor: pointer; " onclick = " itemDeletion('. $sale->id .') " title = " Supprimer cette vente " alt = " " src = " ../img/admin/delete.gif " >
2016-04-04 10:49:37 +02:00
< 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 ;
}
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' ] == '' )
2016-11-10 16:09:09 +01:00
&& ! file_exists ( _PS_ROOT_DIR_ . '/modules/privatesales/img/' . $sale -> id . '/' . $img . '_' . $language [ 'id_lang' ] . '.jpg' )
2016-11-09 17:50:41 +01:00
&& ( 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' ] == '' )
2016-11-10 16:09:09 +01:00
&& ! file_exists ( _PS_ROOT_DIR_ . '/modules/privatesales/img/' . $sale -> id . '/' . $img . '_' . $language [ 'id_lang' ] . '.jpg' )
2016-11-09 17:50:41 +01:00
&& ( 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.' ));
}
}
}
}
2016-09-06 11:07:40 +02:00
} elseif ( isset ( $_GET [ 'deleteImg' ]) && $id_sale = Tools :: getValue ( 'id' ) && $image = Tools :: getValue ( 'image' )) {
if ( file_exists ( _PS_ROOT_DIR_ . '/modules/privatesales/img/' . ( int ) Tools :: getValue ( 'id' ) . '/' . $image . '.jpg' )){
unlink ( _PS_ROOT_DIR_ . '/modules/privatesales/img/' . ( int ) Tools :: getValue ( 'id' ) . '/' . $image . '.jpg' );
Tools :: redirectAdmin ( $currentIndex . '&token=' . Tools :: getAdminTokenLite ( 'AdminPrivateSalesSales' ) . '&edit&id=' . ( int ) Tools :: getValue ( 'id' ));
} else {
echo $this -> displayError ( $this -> l ( 'This image doesn\'t exist.' ));
}
2016-04-04 10:49:37 +02:00
} 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
}