update to see consommables in BO
This commit is contained in:
parent
de06f70738
commit
df4be5618d
@ -10,11 +10,11 @@ require_once('../modules/privatesales_extrafields/privatesales_extrafields.php')
|
||||
|
||||
|
||||
if (isset($_GET['getSales'])){
|
||||
$type = $_GET['type'];
|
||||
$type = $_GET['type'];
|
||||
if($type == 'finished'){
|
||||
$sales = Sale::getSales(NULL, NULL, NULL, FALSE , FALSE, FALSE, '`position` DESC');
|
||||
}else{
|
||||
$sales = Sale::getSales(NULL, NULL, NULL, $type , FALSE, FALSE, '`position` DESC');
|
||||
$sales = Sale::getSales(NULL, NULL, NULL, FALSE , FALSE, FALSE, '`position` DESC', NULL, NULL, FALSE, TRUE);
|
||||
}else{
|
||||
$sales = Sale::getSales(NULL, NULL, NULL, $type , FALSE, FALSE, '`position` DESC', NULL, NULL, FALSE, TRUE);
|
||||
}
|
||||
|
||||
$ids = array();
|
||||
@ -45,9 +45,9 @@ if (isset($_GET['getSales'])){
|
||||
<th style='width: 68px;'>Actions</th>
|
||||
</tr></thead>
|
||||
<tbody id='saleActive' class='sortable'>";
|
||||
|
||||
|
||||
$export = true;
|
||||
foreach($sales as $key => $sale) {
|
||||
foreach($sales as $key => $sale) {
|
||||
echo '<tr id="item_'.$sale->id. '">
|
||||
<td>'.$sale->id.'</td>
|
||||
<td><strong>'.$sale->title[intval($cookie->id_lang)].'</strong><br/><span style="color:#666; font-style:italic">'.$extrafields[$sale->id][1].'</span></td>
|
||||
@ -64,7 +64,7 @@ if (isset($_GET['getSales'])){
|
||||
else if($sale->new == 3){
|
||||
echo "<td>Non défini</td>";
|
||||
}
|
||||
|
||||
|
||||
echo '<td>'.((int) $sale->id_employee != 0? $employees[(int) $sale->id_employee]: '--').'</td>
|
||||
<td '.(in_array('fr', $sale->versions) ? 'class="green"' : 'class="red"').'>FR</td>
|
||||
<td '.(in_array('es', $sale->versions) ? 'class="green"' : 'class="red"').'>ES</td>
|
||||
@ -75,14 +75,14 @@ if (isset($_GET['getSales'])){
|
||||
if($key + 1 != count($sales)){
|
||||
echo '<a href="" class="updatePosition" data-way="1" data-position='. $sale->position .'><img title="Bas" alt="Bas" src="../img/admin/down.gif"></a>';
|
||||
}
|
||||
|
||||
$category_link = Link::getCategoryLink($sale->id_category);
|
||||
|
||||
$category_link = Link::getCategoryLink($sale->id_category);
|
||||
|
||||
echo '</td>
|
||||
<td>
|
||||
'.($export? '<a onclick="window.open(this.href); return false;" href="'.__PS_BASE_URI__.'modules/exports/exports/privatesales.php?id_sale='.$sale->id.'&adtoken='.Tools::encrypt('PrivateSalesDirectExtract'.$sale->id).'"><img style="cursor: pointer;" title="Exporter cette vente" alt="" src="../img/admin/export.gif"></a>': '').'
|
||||
<img style="cursor: pointer;" onclick="itemEdition('.$sale->id.')" title="Éditer cette vente" alt="" src="../img/admin/edit.gif">
|
||||
<img style="cursor: pointer;" onclick="itemDeletion('.$sale->id.')" title="Supprimer cette vente" alt="" src="../img/admin/delete.gif">
|
||||
<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>
|
||||
@ -120,7 +120,7 @@ if (isset($_GET['updatePosition'])){
|
||||
$way = $_GET['way'];
|
||||
|
||||
if($way == 0){
|
||||
$new_position = $position + 1;
|
||||
$new_position = $position + 1;
|
||||
}elseif($way == 1){
|
||||
$new_position = $position - 1;
|
||||
}
|
||||
@ -130,19 +130,19 @@ if (isset($_GET['updatePosition'])){
|
||||
}
|
||||
|
||||
|
||||
function updateSalePosition($position, $new_position){
|
||||
function updateSalePosition($position, $new_position){
|
||||
$sale = Sale::getByPosition($position);
|
||||
$last_sale = Sale::getByPosition($new_position);
|
||||
|
||||
// // update lactuelle new position
|
||||
Db::getInstance()->autoExecute( _DB_PREFIX_.'privatesale', array(
|
||||
'position' => $position),
|
||||
'position' => $position),
|
||||
'UPDATE',
|
||||
'id_sale = ' . $last_sale->id);
|
||||
|
||||
// // update pour la nouvelle position
|
||||
// // update pour la nouvelle position
|
||||
Db::getInstance()->autoExecute( _DB_PREFIX_.'privatesale', array(
|
||||
'position' => $new_position),
|
||||
'position' => $new_position),
|
||||
'UPDATE',
|
||||
'id_sale = ' . $sale->id);
|
||||
|
||||
@ -162,20 +162,20 @@ if (isset($_GET['updatePositionDrag'])){
|
||||
|
||||
if($position > 0){
|
||||
$sales_sql = "SELECT id_sale, position FROM "._DB_PREFIX_."privatesale WHERE position BETWEEN ". ($position_initial +1) .' AND ' .$new_position;
|
||||
$sales = Db::getInstance()->ExecuteS($sales_sql);
|
||||
foreach ($sales as $key => $sale){
|
||||
$sales = Db::getInstance()->ExecuteS($sales_sql);
|
||||
foreach ($sales as $key => $sale){
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = (position -1) WHERE id_sale = '. $sale['id_sale']);
|
||||
}
|
||||
}else{
|
||||
$sales_sql = "SELECT id_sale, position FROM "._DB_PREFIX_."privatesale WHERE position BETWEEN ". $new_position . ' AND ' . ($position_initial - 1);
|
||||
$sales = Db::getInstance()->ExecuteS($sales_sql);
|
||||
foreach ($sales as $key => $sale){
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = (position + 1) WHERE id_sale = '. $sale['id_sale']);
|
||||
$sales = Db::getInstance()->ExecuteS($sales_sql);
|
||||
foreach ($sales as $key => $sale){
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = (position + 1) WHERE id_sale = '. $sale['id_sale']);
|
||||
}
|
||||
}
|
||||
|
||||
Db::getInstance()->ExecuteS( 'UPDATE '._DB_PREFIX_.'privatesale SET position = '. (int)$new_position.' WHERE id_sale = '. $id_sale);
|
||||
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
@ -185,17 +185,17 @@ if (isset($_GET['updatePositionImg'])){
|
||||
$position = $_GET['position'];
|
||||
|
||||
$sql = '
|
||||
SELECT
|
||||
SELECT
|
||||
`position`,
|
||||
`id_product`
|
||||
FROM '._DB_PREFIX_.'image
|
||||
WHERE
|
||||
FROM '._DB_PREFIX_.'image
|
||||
WHERE
|
||||
`id_image` =' . (int)$id_image;
|
||||
$position_initial = Db::getInstance()->getRow($sql);
|
||||
|
||||
$id_product = $position_initial['id_product'];
|
||||
$new_position = $position_initial['position'] + $position;
|
||||
|
||||
|
||||
// fix bug duplicate entry
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'image`
|
||||
@ -206,16 +206,16 @@ if (isset($_GET['updatePositionImg'])){
|
||||
if ($position > 0) {
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'image`
|
||||
SET `position` = (`position` -1)
|
||||
SET `position` = (`position` -1)
|
||||
WHERE `id_product` = '. (int)$id_product.'
|
||||
AND `position` BETWEEN '.(int)$position_initial['position'].' AND '.(int)$new_position
|
||||
);
|
||||
} else {
|
||||
// fix bug duplicate entry
|
||||
foreach (Db::getInstance()->ExecuteS('
|
||||
SELECT
|
||||
SELECT
|
||||
`id_image`
|
||||
FROM `'._DB_PREFIX_.'image`
|
||||
FROM `'._DB_PREFIX_.'image`
|
||||
WHERE `id_product` = '. (int)$id_product .'
|
||||
AND `position` BETWEEN '.(int)$new_position.' AND '.(int)$position_initial['position'].'
|
||||
ORDER BY position DESC') as $key => $value) {
|
||||
@ -232,7 +232,7 @@ if (isset($_GET['updatePositionImg'])){
|
||||
SET `position` = '.(int)$new_position.'
|
||||
WHERE `id_image` = '. (int)$id_image
|
||||
);
|
||||
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
@ -302,12 +302,12 @@ if (isset($_GET['getStats'])) {
|
||||
|| $percent_sale > 85) {
|
||||
$exports[] = [
|
||||
'id_product' => $row['id_product'] . '-'.(int) $row['id_product_attribute'],
|
||||
'name' => $row['name'],
|
||||
'name' => $row['name'],
|
||||
'reference' => $row['reference'],
|
||||
'quantity' => $stock_actual,
|
||||
'quantity_sale' => $stock_sales,
|
||||
'percent_sale' => round((100 - $percent_sale), 2),
|
||||
];
|
||||
];
|
||||
}
|
||||
}
|
||||
$id_attributes[] = (int) $row['id_product'];
|
||||
@ -330,7 +330,7 @@ if (isset($_GET['getStats'])) {
|
||||
|
||||
foreach($query_whitout_attributes as $row) {
|
||||
if(in_array((int) $row['id_product'].'-0', $sold_products)) {
|
||||
|
||||
|
||||
$stock_actual = $row['quantity'];
|
||||
$stock_sales = $detail_sales[(int) $row['id_product'].'-0'];
|
||||
$stock_initial = (int)$stock_actual + (int)$stock_sales;
|
||||
@ -388,6 +388,6 @@ if (isset($_GET['getStats'])) {
|
||||
}
|
||||
echo $result;
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>';
|
||||
|
||||
|
||||
|
||||
echo '<label>'.$this->l('Public sale:').'</label>
|
||||
<div class="margin-form">
|
||||
@ -241,7 +241,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>';
|
||||
|
||||
|
||||
echo '<label>'.$this->l('Braderie :').'</label>
|
||||
<div class="margin-form">
|
||||
<div id="public" style="float: left;">
|
||||
@ -272,10 +272,10 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
<div class="clear"></div>
|
||||
</div>';
|
||||
|
||||
|
||||
|
||||
echo '<label>'.$this->l('Nouveau :').'</label>
|
||||
<div class="margin-form">
|
||||
<div id="new" style="float: left;">
|
||||
<div id="new" style="float: left;">
|
||||
<input name="new" type="radio" value="0"'.($this->cursale!==NULL? ($this->cursale->new==0? ' checked="checked"': ''):' checked="checked"').' /> '.$this->l('Non').' <input name="new" type="radio" value="1"'.($this->cursale!==NULL && $this->cursale->new==1?' checked="checked"': '').' /> '.$this->l('Oui').'
|
||||
<sup> *</sup>
|
||||
</div>
|
||||
@ -285,7 +285,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
|
||||
echo '<label>'.$this->l('Mise en avant newsletter :').'</label>
|
||||
<div class="margin-form">
|
||||
<div id="forward_news" style="float: left;">
|
||||
<div id="forward_news" style="float: left;">
|
||||
<input name="forward_news" type="radio" value="0"'.($this->cursale!==NULL? ($this->cursale->forward_news==0? ' checked="checked"': ''):' checked="checked"').' /> '.$this->l('Non').' <input name="forward_news" type="radio" value="1"'.($this->cursale!==NULL && $this->cursale->forward_news==1?' checked="checked"': '').' /> '.$this->l('Oui').'
|
||||
<sup> *</sup>
|
||||
</div>
|
||||
@ -413,19 +413,19 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
|
||||
// echo '<label>'.$this->l('Sale type:').'</label>
|
||||
// <div class="margin-form">
|
||||
// <div id="carriers" style="float: left;">
|
||||
// <div id="carriers" style="float: left;">
|
||||
// '.$this->l('SALETYPE1').' <input '. (isset($this->cursale->sale_type) && in_array(1,$this->cursale->sale_type) ? ' checked': '') .' type="checkbox" name="sale_type[]" value="1">
|
||||
// '.$this->l('SALETYPE2').' <input '. (isset($this->cursale->sale_type) && in_array(2,$this->cursale->sale_type) ? ' checked': '') .' type="checkbox" name="sale_type[]" value="2">
|
||||
// '.$this->l('SALETYPE3').' <input '. (isset($this->cursale->sale_type) && in_array(3,$this->cursale->sale_type) ? ' checked': '') .' type="checkbox" name="sale_type[]" value="3">
|
||||
// </div>
|
||||
// </div>';
|
||||
|
||||
|
||||
echo '<label>'.$this->l('Description:').'</label>
|
||||
<div class="margin-form">';
|
||||
foreach($this->_languages as $language) {
|
||||
echo '<div id="description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<textarea style="width: 500px; height: 150px;" name="description_'.$language['id_lang'].'">';
|
||||
if($this->cursale !== NULL) {
|
||||
if($this->cursale !== NULL) {
|
||||
echo htmlentities($this->cursale->description[$language['id_lang']]);
|
||||
// echo htmlentities(utf8_decode($this->cursale->description[$language['id_lang']]));
|
||||
}
|
||||
@ -465,7 +465,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
echo '<div class="clear"></div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
||||
Module::hookExec('privatesales_edit', array('sale' => $this->cursale));
|
||||
|
||||
echo '<br class="clear" />
|
||||
@ -483,14 +483,14 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
global $cookie, $currentIndex;
|
||||
$this->cursale = NULL;
|
||||
if($id = Tools::getValue('id')) {
|
||||
$this->cursale = new Sale($id);
|
||||
$this->cursale = new Sale($id);
|
||||
if($this->cursale->id === NULL) {
|
||||
Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesSales'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// // ANTADIS INSERT TYPE
|
||||
// $ventes = Sale::getSales(NULL, NULL, NULL, NULL , FALSE, FALSE, 'position ASC');
|
||||
// $ventes = Sale::getSales(NULL, NULL, NULL, NULL , FALSE, FALSE, 'position ASC');
|
||||
// foreach ($ventes as $key => $vente) {
|
||||
// global $cookie;
|
||||
// if($cookie->id_employee == 1){
|
||||
@ -500,7 +500,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
// ), 'INSERT');
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$this->displayForm();
|
||||
|
||||
$export = Module::isInstalled('exports');
|
||||
@ -512,7 +512,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
') as $row) {
|
||||
$employees[(int) $row['id_employee']] = $row['firstname'].' '.$row['lastname'];
|
||||
}
|
||||
|
||||
|
||||
//ANTADIS
|
||||
echo '<fieldset style="margin-top:15px">';
|
||||
echo '<legend>Tri des ventes</legend>';
|
||||
@ -520,7 +520,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
echo '<input type="submit" value="Ventes terminées" name="finished" class="tri button">';
|
||||
echo '<input type="submit" value="Toutes les ventes" name="all" class="tri button">';
|
||||
echo '</fieldset>';
|
||||
|
||||
|
||||
?>
|
||||
<script>
|
||||
jQuery( document ).ready(function( $ ) {
|
||||
@ -532,10 +532,10 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
button.removeClass('active');
|
||||
$(this).addClass('active');
|
||||
$('.list_vente').empty();
|
||||
|
||||
|
||||
var loader = "<p class='text-align:center'><img src='../img/loader.gif' /></p>";
|
||||
$('.list_vente').html(loader);
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: "ajax_vp.php",
|
||||
type: 'GET',
|
||||
@ -549,10 +549,10 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
});
|
||||
|
||||
$(".updatePosition").live( "click", function(e) {
|
||||
e.preventDefault();
|
||||
e.preventDefault();
|
||||
var position = $(this).attr('data-position');
|
||||
var way = $(this).attr('data-way');
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: "ajax_vp.php",
|
||||
type: 'GET',
|
||||
@ -567,7 +567,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
$('.list_vente').empty();
|
||||
$('.list_vente').html(html);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -655,14 +655,14 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
';
|
||||
echo ' <tbody id="saleActive" class="sortable">';
|
||||
|
||||
$sales = Sale::getSales(NULL, NULL, NULL, 'not_ended', FALSE, FALSE, '`position` DESC');
|
||||
$sales = Sale::getSales(NULL, NULL, NULL, 'not_ended', FALSE, FALSE, '`position` DESC',NULL, NULL, FALSE, TRUE);
|
||||
$ids = array();
|
||||
foreach ($sales as $key => $sale) {
|
||||
$ids[] = $sale->id;
|
||||
}
|
||||
$extrafields = PrivateSales_ExtraFields::getFieldsForSale($ids);
|
||||
|
||||
foreach($sales as $key => $sale) {
|
||||
|
||||
foreach($sales as $key => $sale) {
|
||||
echo '<tr id="item_'.$sale->id. '" class="sale_'.($key%2).'">
|
||||
<td>'.$sale->id.'</td>
|
||||
<td><strong>'.$sale->title[intval($cookie->id_lang)].'</strong><br/><span style="color:#666; font-style:italic">'.$extrafields[$sale->id][1].'</span></td>
|
||||
@ -680,7 +680,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
else if($sale->new == 3){
|
||||
echo "<td>".$this->l('Non défini')."</td>";
|
||||
}
|
||||
|
||||
|
||||
echo '<td>'.((int) $sale->id_employee != 0? $employees[(int) $sale->id_employee]: '--').'</td>
|
||||
<td '.(in_array('fr', $sale->versions) ? 'class="green"' : 'class="red"').'>FR</td>
|
||||
<td '.(in_array('es', $sale->versions) ? 'class="green"' : 'class="red"').'>ES</td>
|
||||
@ -694,12 +694,12 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
if($key + 1 != count($sales)){
|
||||
echo '<a href="" class="updatePosition" data-way="1" data-position='. $sale->position .'><img title="Bas" alt="Bas" src="../img/admin/down.gif"></a>';
|
||||
}
|
||||
$category_link = Link::getCategoryLink($sale->id_category);
|
||||
$category_link = Link::getCategoryLink($sale->id_category);
|
||||
echo '</td>
|
||||
<td>
|
||||
'.($export? '<a onclick="window.open(this.href); return false;" href="'.__PS_BASE_URI__.'modules/exports/exports/privatesales.php?id_sale='.$sale->id.'&adtoken='.Tools::encrypt('PrivateSalesDirectExtract'.$sale->id).'"><img style="cursor: pointer;" title="Exporter cette vente" alt="" src="../img/admin/export.gif"></a>': '').'
|
||||
<img style="cursor: pointer;" onclick="itemEdition('.$sale->id.')" title="Éditer cette vente" alt="" src="../img/admin/edit.gif">
|
||||
<img style="cursor: pointer;" onclick="itemDeletion('.$sale->id.')" title="Supprimer cette vente" alt="" src="../img/admin/delete.gif">
|
||||
<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>
|
||||
@ -739,7 +739,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
if (Sale::getSaleFromCategory(Tools::getValue('id_category'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$sql_position = 'SELECT MAX(position) FROM '. _DB_PREFIX_.'privatesale';
|
||||
$position = Db::getInstance()->getValue($sql_position);
|
||||
|
||||
@ -761,7 +761,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
foreach(Tools::getValue('sale_type', array()) as $sale_type) {
|
||||
$sale->sale_type[] = (int) $sale_type;
|
||||
}
|
||||
|
||||
|
||||
foreach(Language::getLanguages(FALSE) as $language) {
|
||||
if($description = Tools::getValue('description_'.$language['id_lang'])) {
|
||||
$sale->description[$language['id_lang']] = $description;
|
||||
@ -793,7 +793,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
|
||||
$sale->save();
|
||||
$sale->buildCategoryCache();
|
||||
|
||||
|
||||
if( empty($sale->carriers)) {
|
||||
mail('valentin@bebeboutik.com', 'Vente sans transporteur',
|
||||
'La vente '. $sale->id.' est sans transporteur',
|
||||
@ -862,7 +862,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
echo '<div class="error alert">'.Tools::displayError($this->l('Impossible d\'éditer une vente sans transporteur.')).'</div>';
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sale->save();
|
||||
$sale->buildCategoryCache();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user