adding total quantity ticket#9598

This commit is contained in:
Marion Muszynski 2016-03-10 11:04:39 +01:00
parent 56da5a1b8f
commit f1129c1b0b

View File

@ -185,7 +185,7 @@ class AdminProducts extends AdminTab
$redirect = "/adm/index.php?tab=AdminEditFast";
$token_redirect = Tools::getAdminToken('AdminEditFast'.(int)(Tab::getIdFromClassName('AdminEditFast')).(int)($cookie->id_employee));
Tools::redirectAdmin($redirect . "&id_product=". json_encode($products)."&id_lang_fast=".(int) $id_lang_fast."&token=". $token_redirect);
Tools::redirectAdmin($redirect . "&id_product=". json_encode($products)."&id_lang_fast=".(int) $id_lang_fast."&token=". $token_redirect);
}
if (Tools::isSubmit('addCategoryProduct')) {
@ -227,15 +227,15 @@ class AdminProducts extends AdminTab
$categories_product = $product->getCategories();
foreach ($id_category_paste as $key => $id_paste) {
if(!in_array($id_paste, $categories_product)){
$max_position = Db::getInstance()->getValue("
SELECT MAX(cp.`position`) AS max FROM `"._DB_PREFIX_."category_product` cp WHERE cp.`id_category`=" . (int)$id_paste );
$add_category = Db::getInstance()->Execute("INSERT INTO `"._DB_PREFIX_."category_product` (`id_product`, `id_category`, `position`)
$add_category = Db::getInstance()->Execute("INSERT INTO `"._DB_PREFIX_."category_product` (`id_product`, `id_category`, `position`)
VALUES (
'". $product->id ."',
'". (int)$id_paste ."',
'". (int)($max_position + 1 ) ."'
'". (int)($max_position + 1 ) ."'
)");
}
}
@ -271,11 +271,11 @@ class AdminProducts extends AdminTab
{
$max_position = Db::getInstance()->getValue("SELECT MAX(cp.`position`) AS max FROM `"._DB_PREFIX_."category_product` cp WHERE cp.`id_category`=" . (int)$id_category_clonage );
$add_category = Db::getInstance()->Execute("INSERT INTO `"._DB_PREFIX_."category_product` (`id_product`, `id_category`, `position`)
$add_category = Db::getInstance()->Execute("INSERT INTO `"._DB_PREFIX_."category_product` (`id_product`, `id_category`, `position`)
VALUES (
'". $product->id ."',
'". (int)$id_category_clonage ."',
'". (int)($max_position + 1 ) ."'
'". (int)($max_position + 1 ) ."'
)");
if(!$add_category){
@ -290,7 +290,7 @@ class AdminProducts extends AdminTab
else
{
Hook::addProduct($product);
Search::indexation(false, $product->id);
Search::indexation(false, $product->id);
}
}
else
@ -305,13 +305,13 @@ class AdminProducts extends AdminTab
// ANTADIS - coup de coeur
if(Tools::getValue('id_product') && $this->tabAccess['edit'] === '1'){
$product = new Product(Tools::getValue('id_product'));
if(isset($_GET['online_onlyproduct']) || isset($_GET['online_onlyproduct1']) ){
$product->toggleCoupCoeur();
Tools::redirectAdmin($currentIndex.'&id_product='.(int)(Tools::getValue($this->identifier)).'&id_category='.(int)(Tools::getValue('id_category')).'&token='.($token ? $token : $this->token));
}
}
// Add a new product
if (Tools::isSubmit('submitAddproduct') || Tools::isSubmit('submitAddproductAndStay') || Tools::isSubmit('submitAddProductAndPreview'))
@ -1568,6 +1568,26 @@ class AdminProducts extends AdminTab
{
global $currentIndex, $cookie;
// adding Antadis
$_quantities = 0;
$this->getList((int)($cookie->id_lang), NULL, NULL,0,1000);
foreach ($this->_list AS $product) {
$result_quantities = Db::getInstance()->executeS('
SELECT od.`product_quantity`,od.`product_quantity_reinjected`
FROM '._DB_PREFIX_.'order_detail od
WHERE od.`product_id` = ' . (int)$product['id_product']
);
$quantity = 0;
foreach ($result_quantities as $od) {
$quantity += ($od['product_quantity'] - $od['product_quantity_reinjected']);
}
if ($quantity>0 && isset($product['quantity'])) {
$_quantities += ($quantity + $product['quantity']);
} elseif (isset($product['quantity'])) {
$_quantities += $product['quantity'];
}
}
if (($id_category = (int)Tools::getValue('id_category')))
$currentIndex .= '&id_category='.$id_category;
$this->getList((int)($cookie->id_lang), !$cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$cookie->__get($this->table.'Orderway') ? 'ASC' : NULL);
@ -1575,7 +1595,7 @@ class AdminProducts extends AdminTab
if (!$id_category)
$id_category = 1;
echo '<h3>'.(!$this->_listTotal ? ($this->l('No products found')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('products') : $this->l('product')))).' '.
$this->l('in category').' "'.stripslashes($this->_category->getName()).'"</h3>';
$this->l('in category').' "'.stripslashes($this->_category->getName()).'" '.(($id_category!=1 && $_quantities>0)?$this->l(' - Quantity : ').$_quantities.$this->l(' pieces'):'').'</h3>';
if ($this->tabAccess['add'] === '1')
echo '<a href="'.$currentIndex.'&id_category='.$id_category.'&add'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add a new product').'</a>';
echo '<div style="margin:10px;">';
@ -1614,7 +1634,7 @@ class AdminProducts extends AdminTab
if ($this->delete)
echo '<p><input type="submit" class="button" name="submitDel'.$this->table.'" value="'.$this->l('Delete selection').'" onclick="return confirm(\''.$this->l('Delete selected items?', __CLASS__, TRUE, FALSE).'\');" /></p>';
echo '<hr>';
$languages = Language::getLanguages(FALSE);
@ -1622,7 +1642,7 @@ class AdminProducts extends AdminTab
echo '<label>Langue à mettre à jour : </label>';
echo '<select name="id_lang_fast" id="id_lang_fast">';
foreach ($languages as $key => $language) {
echo '<option value="'.$language['id_lang'].'" '.($language['id_lang'] == 2 ? 'selected' : '').'>'.$language['name'].'</option>';
echo '<option value="'.$language['id_lang'].'" '.($language['id_lang'] == 2 ? 'selected' : '').'>'.$language['name'].'</option>';
}
echo '</select>';
echo '<p><input type="submit" class="button" name="editProduct" value="'.$this->l('Mise à jour rapide').'"/></p>';
@ -1665,11 +1685,11 @@ class AdminProducts extends AdminTab
echo '<h2>Associer des produits</h2>';
echo '<p><b>Catégorisation :</b>
<br />
<label style="text-align: left; font-weight: normal;" for="keep_category_no">Rajouter les catégories</label>
<label style="text-align: left; font-weight: normal;" for="keep_category_no">Rajouter les catégories</label>
<input style="margin:2px" type="radio" id="keep_category_no" name="keep_category" value="0" checked>
<span class="clear"></span>
<br />
<label style="text-align: left; font-weight: normal; clear:both;" for="keep_category_yes">Déplacer vers</label>
<label style="text-align: left; font-weight: normal; clear:both;" for="keep_category_yes">Déplacer vers</label>
<input style="margin:2px" type="radio" id="keep_category_yes" name="keep_category" value="1" >
</p>
<div class="clear"></div>
@ -1724,7 +1744,7 @@ class AdminProducts extends AdminTab
// }
echo '<p><input type="submit" class="button" name="addCategoryProduct" value="Ajouter à la catégorie"></p>';
echo "</div>";
echo "</div>";
}
echo ' </td>
@ -4213,7 +4233,7 @@ class AdminProducts extends AdminTab
default:
return parent::getFieldValue($obj, $data, $id_lang);
break;
}
}
}
}