From f3ef9b868f9c4a25189479cc6fe21e0ebfaee39d Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 5 Oct 2015 16:19:54 +0200 Subject: [PATCH 01/14] fix entities warehouse share --- htdocs/product/class/product.class.php | 2 +- htdocs/product/stock/class/entrepot.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e6695b75bc6..9d409e73c32 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2662,7 +2662,7 @@ class Product extends CommonObject $sql = "SELECT ps.reel, ps.fk_entrepot, ps.pmp"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= ", ".MAIN_DB_PREFIX."entrepot as w"; - $sql.= " WHERE w.entity IN (".getEntity('warehouse', 1).")"; + $sql.= " WHERE w.entity IN (".getEntity('stock', 1).")"; $sql.= " AND w.rowid = ps.fk_entrepot"; $sql.= " AND ps.fk_product = ".$this->id; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 384b3712674..1056829838b 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -358,7 +358,7 @@ class Entrepot extends CommonObject $sql = "SELECT rowid, label"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot"; - $sql.= " WHERE entity IN (".getEntity('warehouse', 1).")"; + $sql.= " WHERE entity IN (".getEntity('stock', 1).")"; $sql.= " AND statut = ".$status; $result = $this->db->query($sql); From 00f0aff6f0cead68aa186b5c704b564b27d04ed2 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 8 Oct 2015 15:58:19 +0200 Subject: [PATCH 02/14] FIX: change order date on clone (as everywhere else) --- htdocs/commande/class/commande.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7a8fd63c8f1..cdb753698a4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -881,6 +881,7 @@ class Commande extends CommonOrder // Clear fields $this->user_author_id = $user->id; $this->user_valid = ''; + $this->date = dol_now(); $this->date_creation = ''; $this->date_validation = ''; $this->ref_client = ''; From 69ac75bef8570112e0ce94e03b2f70805042e35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Wed, 4 Nov 2015 22:55:14 +0100 Subject: [PATCH 03/14] Fix #3864 Fixed invalid jQuery code --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index a8c9434acec..190fad96c51 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -446,7 +446,7 @@ jQuery(document).ready(function() { rights->margins->creer) { ?> /* Code for margin */ - $("#fournprice_predef options").remove(); + $("#fournprice_predef option").each.remove(); $("#fournprice_predef").hide(); $("#buying_price").val("").show(); $.post('/fourn/ajax/getSupplierPrices.php', { 'idprod': $(this).val() }, function(data) { From 0543a3192006eed4b24f331e5aef1833ebbfc396 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 5 Nov 2015 11:11:03 +0100 Subject: [PATCH 04/14] FIX event's data lost on user assign update --- htdocs/comm/action/card.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c011717c0cc..92300a35368 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -88,7 +88,7 @@ $hookmanager->initHooks(array('actioncard','globalcard')); /* * Actions */ - +$listUserAssignedUpdated = false; // Remove user to assigned list if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') { @@ -106,6 +106,8 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') $donotclearsession=1; if ($action == 'add') $action = 'create'; if ($action == 'update') $action = 'edit'; + + $listUserAssignedUpdated = true; } // Add user to assigned list @@ -125,6 +127,8 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser')) $donotclearsession=1; if ($action == 'add') $action = 'create'; if ($action == 'update') $action = 'edit'; + + $listUserAssignedUpdated = true; } // Add event @@ -803,6 +807,28 @@ if ($id > 0) $result4=$object->fetch_userassigned(); $result5=$object->fetch_optionals($id,$extralabels); + if($listUserAssignedUpdated) { + + $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); + $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); + + $object->fk_action = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm'); + $object->label = GETPOST("label"); + $object->datep = $datep; + $object->datef = $datef; + $object->percentage = $percentage; + $object->priority = GETPOST("priority"); + $object->fulldayevent= GETPOST("fullday")?1:0; + $object->location = GETPOST('location'); + $object->socid = GETPOST("socid"); + $object->contactid = GETPOST("contactid",'int'); + //$object->societe->id = $_POST["socid"]; // deprecated + //$object->contact->id = $_POST["contactid"]; // deprecated + $object->fk_project = GETPOST("projectid",'int'); + + $object->note = GETPOST("note"); + } + if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) { dol_print_error($db,$object->error); From e1ea2215a3b1f753ea45d1415825bb7e40a62ae3 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 5 Nov 2015 11:25:04 +0100 Subject: [PATCH 05/14] FIX loss data also if update was cancel by error of ended state with no end date, try a generic patch --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 92300a35368..9d6f9590a1c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -807,7 +807,7 @@ if ($id > 0) $result4=$object->fetch_userassigned(); $result5=$object->fetch_optionals($id,$extralabels); - if($listUserAssignedUpdated) { + if($listUserAssignedUpdated || $donotclearsession) { $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); From 9b797c1831932ef0bd0c1ddacbba2535070c2a0b Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 5 Nov 2015 12:49:43 +0100 Subject: [PATCH 06/14] FIX bad calculation for stock value --- htdocs/product/stock/class/entrepot.class.php | 2 +- htdocs/product/stock/fiche.php | 8 ++++---- htdocs/product/stock/valo.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 1056829838b..a21c57e2657 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -418,7 +418,7 @@ class Entrepot extends CommonObject { $ret=array(); - $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * ps.pmp) as value"; + $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * p.pmp) as value"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE ps.fk_entrepot = ".$this->id; diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php index a60deff921e..22b70fda280 100644 --- a/htdocs/product/stock/fiche.php +++ b/htdocs/product/stock/fiche.php @@ -364,7 +364,7 @@ else print_liste_field_titre($langs->trans("Product"),"", "p.ref","&id=".$_GET['id'],"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),"", "p.label","&id=".$_GET['id'],"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Units"),"", "ps.reel","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "ps.pmp","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "p.pmp","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("EstimatedStockValueShort"),"", "","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellPriceMin"),"", "p.price","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("EstimatedStockValueSellShort"),"", "","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); @@ -426,10 +426,10 @@ else $totalunit+=$objp->value; // Price buy PMP - print ''.price(price2num($objp->pmp,'MU')).''; + print ''.price(price2num($objp->ppmp,'MU')).''; // Total PMP - print ''.price(price2num($objp->pmp*$objp->value,'MT')).''; - $totalvalue+=price2num($objp->pmp*$objp->value,'MT'); + print ''.price(price2num($objp->ppmp*$objp->value,'MT')).''; + $totalvalue+=price2num($objp->ppmp*$objp->value,'MT'); // Price sell min if (empty($conf->global->PRODUIT_MULTIPRICES)) diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index e7d782ae5e0..3c00168d82b 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -53,7 +53,7 @@ $year = strftime("%Y",time()); // Affichage valorisation par entrepot $sql = "SELECT e.rowid as ref, e.label, e.statut, e.lieu,"; -$sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; +$sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; From b0cf9bd0bebafdaebfe20cc02c4549b5cae1b357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 5 Nov 2015 14:38:11 +0100 Subject: [PATCH 07/14] Fix #3864 Really fixed invalid jQuery code --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 190fad96c51..b36f61973ee 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -446,7 +446,7 @@ jQuery(document).ready(function() { rights->margins->creer) { ?> /* Code for margin */ - $("#fournprice_predef option").each.remove(); + $("#fournprice_predef").find("option").remove(); $("#fournprice_predef").hide(); $("#buying_price").val("").show(); $.post('/fourn/ajax/getSupplierPrices.php', { 'idprod': $(this).val() }, function(data) { From fa088eb6cc23185e09bbfa18cd1c53afbebd33b9 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 5 Nov 2015 14:57:58 +0100 Subject: [PATCH 08/14] FIX bad calculation for stock value --- htdocs/product/stock/class/entrepot.class.php | 2 +- htdocs/product/stock/fiche.php | 8 ++++---- htdocs/product/stock/valo.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 2b1b368ef8c..6cb2e75fc32 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -418,7 +418,7 @@ class Entrepot extends CommonObject { $ret=array(); - $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * ps.pmp) as value"; + $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * p.pmp) as value"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE ps.fk_entrepot = ".$this->id; diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php index 8b7aa43b431..4f43b3f6c91 100644 --- a/htdocs/product/stock/fiche.php +++ b/htdocs/product/stock/fiche.php @@ -369,7 +369,7 @@ else print_liste_field_titre($langs->trans("Product"),"", "p.ref","&id=".$id,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),"", "p.label","&id=".$id,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Units"),"", "ps.reel","&id=".$id,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "ps.pmp","&id=".$id,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "p.pmp","&id=".$id,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("EstimatedStockValueShort"),"", "","&id=".$id,"",'align="right"',$sortfield,$sortorder); if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellPriceMin"),"", "p.price","&id=".$id,"",'align="right"',$sortfield,$sortorder); if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("EstimatedStockValueSellShort"),"", "","&id=".$id,"",'align="right"',$sortfield,$sortorder); @@ -431,10 +431,10 @@ else $totalunit+=$objp->value; // Price buy PMP - print ''.price(price2num($objp->pmp,'MU')).''; + print ''.price(price2num($objp->ppmp,'MU')).''; // Total PMP - print ''.price(price2num($objp->pmp*$objp->value,'MT')).''; - $totalvalue+=price2num($objp->pmp*$objp->value,'MT'); + print ''.price(price2num($objp->ppmp*$objp->value,'MT')).''; + $totalvalue+=price2num($objp->ppmp*$objp->value,'MT'); // Price sell min if (empty($conf->global->PRODUIT_MULTIPRICES)) diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 75b85af00fa..93d2f0a9152 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -53,7 +53,7 @@ $year = strftime("%Y",time()); // Affichage valorisation par entrepot $sql = "SELECT e.rowid as ref, e.label, e.statut, e.lieu,"; -$sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; +$sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; From f566b382969841bd32b0d7ba314c73d3e80ecc86 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 5 Nov 2015 15:29:51 +0100 Subject: [PATCH 09/14] FIX pmp --- htdocs/product/stock/product.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 6b08dd16ecf..a8807c5ea8e 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -578,9 +578,10 @@ if ( (! empty($conf->productbatch->enabled)) && $product->hasbatch()) { print ''; } -$sql = "SELECT e.rowid, e.label, ps.reel, ps.pmp, ps.rowid as product_stock_id"; +$sql = "SELECT e.rowid, e.label, ps.reel, p.pmp, ps.rowid as product_stock_id"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " ".MAIN_DB_PREFIX."product_stock as ps"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; $sql.= " WHERE ps.reel != 0"; $sql.= " AND ps.fk_entrepot = e.rowid"; $sql.= " AND e.entity IN (".getEntity('stock',1).")"; From 75bcb7e53f2dcb3b71cd7c4e8712b473a36ac2e8 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 5 Nov 2015 15:32:56 +0100 Subject: [PATCH 10/14] fix pmp --- htdocs/product/stock/product.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 7896476775a..a11e7f355f5 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -528,9 +528,10 @@ print ''.$langs->trans("SellPriceMin").''; print ''.$langs->trans("EstimatedStockValueSellShort").''; print ''; -$sql = "SELECT e.rowid, e.label, ps.reel, ps.pmp"; +$sql = "SELECT e.rowid, e.label, ps.reel, p.pmp"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " ".MAIN_DB_PREFIX."product_stock as ps"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; $sql.= " WHERE ps.reel != 0"; $sql.= " AND ps.fk_entrepot = e.rowid"; $sql.= " AND e.entity = ".$conf->entity; From ad821358790e17aa2619b3f2aad87be5ad74130a Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 5 Nov 2015 15:36:13 +0100 Subject: [PATCH 11/14] FIX: change order date on clone (as everywhere else) --- htdocs/commande/class/commande.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 95441e5f257..cda6a9b8d8c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -906,6 +906,7 @@ class Commande extends CommonOrder // Clear fields $this->user_author_id = $user->id; $this->user_valid = ''; + $this->date = dol_now(); $this->date_creation = ''; $this->date_validation = ''; $this->ref_client = ''; From 80d24455402b65b1519fad1c9f12093b829e5690 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 5 Nov 2015 17:00:22 +0100 Subject: [PATCH 12/14] FIX: bad stock valorisation --- htdocs/commande/class/commande.class.php | 4 ++-- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/expedition/class/expedition.class.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 95441e5f257..b2654bfcee7 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -376,7 +376,7 @@ class Commande extends CommonOrder { $mouvP = new MouvementStock($this->db); // We increment stock of product (and sub-products) - $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderBackToDraftInDolibarr",$this->ref)); + $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref)); if ($result < 0) { $error++; } } } @@ -564,7 +564,7 @@ class Commande extends CommonOrder { $mouvP = new MouvementStock($this->db); // We increment stock of product (and sub-products) - $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderCanceledInDolibarr",$this->ref)); + $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderCanceledInDolibarr",$this->ref)); if ($result < 0) { $error++; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 72103f6ac5a..8044a677d69 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1751,7 +1751,7 @@ class Facture extends CommonInvoice $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); + if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr",$num)); else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); if ($result < 0) { $error++; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 2e591bf67be..e68b063d7d2 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -959,7 +959,7 @@ class Expedition extends CommonObject $mouvS->origin = &$this; // We decrement stock of product (and sub-products) // We use warehouse selected for each line - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentDeletedInDolibarr",$this->ref)); + $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ShipmentDeletedInDolibarr",$this->ref)); if ($result < 0) { $error++; From 316b7453e47d247ca0af2ae56d8b12bafd86e7b1 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 5 Nov 2015 17:04:08 +0100 Subject: [PATCH 13/14] FIX bad stock valo --- htdocs/commande/class/commande.class.php | 4 ++-- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/expedition/class/expedition.class.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3485d50d729..d4465a43ff5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -367,7 +367,7 @@ class Commande extends CommonOrder { $mouvP = new MouvementStock($this->db); // We increment stock of product (and sub-products) - $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderBackToDraftInDolibarr",$this->ref)); + $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref)); if ($result < 0) { $error++; } } } @@ -555,7 +555,7 @@ class Commande extends CommonOrder { $mouvP = new MouvementStock($this->db); // We increment stock of product (and sub-products) - $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderCanceledInDolibarr",$this->ref)); + $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderCanceledInDolibarr",$this->ref)); if ($result < 0) { $error++; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 135280805cf..7e1ec7bacf8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1796,7 +1796,7 @@ class Facture extends CommonInvoice { $mouvP = new MouvementStock($this->db); // We decrease stock for product - if ($this->type == 2) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); + if ($this->type == 2) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr",$num)); else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); if ($result < 0) { $error++; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index fa25c48366d..92fb1f0c8a0 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -847,7 +847,7 @@ class Expedition extends CommonObject $mouvS = new MouvementStock($this->db); // We decrement stock of product (and sub-products) // We use warehouse selected for each line - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentDeletedInDolibarr",$this->ref)); + $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ShipmentDeletedInDolibarr",$this->ref)); if ($result < 0) { $error++; From e78ebf041a78f8b228392eb8bf4ec074ed4c7192 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Nov 2015 02:02:57 +0100 Subject: [PATCH 14/14] Fix deprecated code not working in jcrop. $.browser.msie and $.browser is no more available in jquery 1.9+. --- htdocs/includes/jquery/plugins/jcrop/js/jquery.Jcrop.js | 9 +++------ .../includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js | 9 ++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/htdocs/includes/jquery/plugins/jcrop/js/jquery.Jcrop.js b/htdocs/includes/jquery/plugins/jcrop/js/jquery.Jcrop.js index ad261f97aec..a31a0a10592 100755 --- a/htdocs/includes/jquery/plugins/jcrop/js/jquery.Jcrop.js +++ b/htdocs/includes/jquery/plugins/jcrop/js/jquery.Jcrop.js @@ -43,13 +43,11 @@ $.Jcrop = function(obj,opt) // Some on-the-fly fixes for MSIE...sigh if (!('trackDocument' in opt)) { - opt.trackDocument = $.browser.msie ? false : true; - if ($.browser.msie && $.browser.version.split('.')[0] == '8') - opt.trackDocument = true; + opt.trackDocument = true; } if (!('keySupport' in opt)) - opt.keySupport = $.browser.msie ? false : true; + opt.keySupport = true; // }}} // Extend the default options {{{ @@ -416,7 +414,7 @@ $.Jcrop = function(obj,opt) if (options.drawBorders) { borders = { top: insertBorder('hline') - .css('top',$.browser.msie?px(-1):px(0)), + .css('top',px(0)), bottom: insertBorder('hline'), left: insertBorder('vline'), right: insertBorder('vline') @@ -965,7 +963,6 @@ $.Jcrop = function(obj,opt) function newTracker() { var trk = $('
').addClass(cssClass('tracker')); - $.browser.msie && trk.css({ opacity: 0, backgroundColor: 'white' }); return trk; }; diff --git a/htdocs/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js b/htdocs/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js index 9002b9787f2..c3c932b8349 100755 --- a/htdocs/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js +++ b/htdocs/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js @@ -8,10 +8,9 @@ (function($){$.Jcrop=function(obj,opt) {var obj=obj,opt=opt;if(typeof(obj)!=='object')obj=$(obj)[0];if(typeof(opt)!=='object')opt={};if(!('trackDocument'in opt)) -{opt.trackDocument=$.browser.msie?false:true;if($.browser.msie&&$.browser.version.split('.')[0]=='8') -opt.trackDocument=true;} +{opt.trackDocument=true;} if(!('keySupport'in opt)) -opt.keySupport=$.browser.msie?false:true;var defaults={trackDocument:false,baseClass:'jcrop',addClass:null,bgColor:'black',bgOpacity:.6,borderOpacity:.4,handleOpacity:.5,handlePad:5,handleSize:9,handleOffset:5,edgeMargin:14,aspectRatio:0,keySupport:true,cornerHandles:true,sideHandles:true,drawBorders:true,dragEdges:true,boxWidth:0,boxHeight:0,boundary:8,animationDelay:20,swingSpeed:3,allowSelect:true,allowMove:true,allowResize:true,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){}};var options=defaults;setOptions(opt);var $origimg=$(obj);var $img=$origimg.clone().removeAttr('id').css({position:'absolute'});$img.width($origimg.width());$img.height($origimg.height());$origimg.after($img).hide();presize($img,options.boxWidth,options.boxHeight);var boundx=$img.width(),boundy=$img.height(),$div=$('
').width(boundx).height(boundy).addClass(cssClass('holder')).css({position:'relative',backgroundColor:options.bgColor}).insertAfter($origimg).append($img);;if(options.addClass)$div.addClass(options.addClass);var $img2=$('').attr('src',$img.attr('src')).css('position','absolute').width(boundx).height(boundy);var $img_holder=$('
').width(pct(100)).height(pct(100)).css({zIndex:310,position:'absolute',overflow:'hidden'}).append($img2);var $hdl_holder=$('
').width(pct(100)).height(pct(100)).css('zIndex',320);var $sel=$('
').css({position:'absolute',zIndex:300}).insertBefore($img).append($img_holder,$hdl_holder);var bound=options.boundary;var $trk=newTracker().width(boundx+(bound*2)).height(boundy+(bound*2)).css({position:'absolute',top:px(-bound),left:px(-bound),zIndex:290}).mousedown(newSelection);var xlimit,ylimit,xmin,ymin;var xscale,yscale,enabled=true;var docOffset=getPos($img),btndown,lastcurs,dimmed,animating,shift_down;var Coords=function() +opt.keySupport=true;var defaults={trackDocument:false,baseClass:'jcrop',addClass:null,bgColor:'black',bgOpacity:.6,borderOpacity:.4,handleOpacity:.5,handlePad:5,handleSize:9,handleOffset:5,edgeMargin:14,aspectRatio:0,keySupport:true,cornerHandles:true,sideHandles:true,drawBorders:true,dragEdges:true,boxWidth:0,boxHeight:0,boundary:8,animationDelay:20,swingSpeed:3,allowSelect:true,allowMove:true,allowResize:true,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){}};var options=defaults;setOptions(opt);var $origimg=$(obj);var $img=$origimg.clone().removeAttr('id').css({position:'absolute'});$img.width($origimg.width());$img.height($origimg.height());$origimg.after($img).hide();presize($img,options.boxWidth,options.boxHeight);var boundx=$img.width(),boundy=$img.height(),$div=$('
').width(boundx).height(boundy).addClass(cssClass('holder')).css({position:'relative',backgroundColor:options.bgColor}).insertAfter($origimg).append($img);;if(options.addClass)$div.addClass(options.addClass);var $img2=$('').attr('src',$img.attr('src')).css('position','absolute').width(boundx).height(boundy);var $img_holder=$('
').width(pct(100)).height(pct(100)).css({zIndex:310,position:'absolute',overflow:'hidden'}).append($img2);var $hdl_holder=$('
').width(pct(100)).height(pct(100)).css('zIndex',320);var $sel=$('
').css({position:'absolute',zIndex:300}).insertBefore($img).append($img_holder,$hdl_holder);var bound=options.boundary;var $trk=newTracker().width(boundx+(bound*2)).height(boundy+(bound*2)).css({position:'absolute',top:px(-bound),left:px(-bound),zIndex:290}).mousedown(newSelection);var xlimit,ylimit,xmin,ymin;var xscale,yscale,enabled=true;var docOffset=getPos($img),btndown,lastcurs,dimmed,animating,shift_down;var Coords=function() {var x1=0,y1=0,x2=0,y2=0,ox,oy;function setPressed(pos) {var pos=rebound(pos);x2=x1=pos[0];y2=y1=pos[1];};function setCurrent(pos) {var pos=rebound(pos);ox=pos[0]-x2;oy=pos[1]-y2;x2=pos[0];y2=pos[1];};function getOffset() @@ -57,7 +56,7 @@ if(x1>boundx){var delta=x1-boundy;y2-=delta;y1-=delta;} if(y1>boundy){var delta=y1-boundy;y2-=delta;y1-=delta;} return makeObj(flipCoords(x1,y1,x2,y2));};function makeObj(a) {return{x:a[0],y:a[1],x2:a[2],y2:a[3],w:a[2]-a[0],h:a[3]-a[1]};};return{flipCoords:flipCoords,setPressed:setPressed,setCurrent:setCurrent,getOffset:getOffset,moveOffset:moveOffset,getCorner:getCorner,getFixed:getFixed};}();var Selection=function() -{var start,end,dragmode,awake,hdep=370;var borders={};var handle={};var seehandles=false;var hhs=options.handleOffset;if(options.drawBorders){borders={top:insertBorder('hline').css('top',$.browser.msie?px(-1):px(0)),bottom:insertBorder('hline'),left:insertBorder('vline'),right:insertBorder('vline')};} +{var start,end,dragmode,awake,hdep=370;var borders={};var handle={};var seehandles=false;var hhs=options.handleOffset;if(options.drawBorders){borders={top:insertBorder('hline').css('top',px(0)),bottom:insertBorder('hline'),left:insertBorder('vline'),right:insertBorder('vline')};} if(options.dragEdges){handle.t=insertDragbar('n');handle.b=insertDragbar('s');handle.r=insertDragbar('e');handle.l=insertDragbar('w');} options.sideHandles&&createHandles(['n','s','e','w']);options.cornerHandles&&createHandles(['sw','nw','ne','se']);function insertBorder(type) {var jq=$('
').css({position:'absolute',opacity:options.borderOpacity}).addClass(cssClass(type));$img_holder.append(jq);return jq;};function dragDiv(ord,zi) @@ -134,7 +133,7 @@ else Tracker.setCursor(options.allowSelect?'crosshair':'default');};function newSelection(e) {if(options.disabled)return false;if(!options.allowSelect)return false;btndown=true;docOffset=getPos($img);Selection.disableHandles();myCursor('crosshair');var pos=mouseAbs(e);Coords.setPressed(pos);Tracker.activateHandlers(selectDrag,doneSelect);KeyManager.watchKeys();Selection.update();e.stopPropagation();e.preventDefault();return false;};function selectDrag(pos) {Coords.setCurrent(pos);Selection.update();};function newTracker() -{var trk=$('
').addClass(cssClass('tracker'));$.browser.msie&&trk.css({opacity:0,backgroundColor:'white'});return trk;};function animateTo(a) +{var trk=$('
').addClass(cssClass('tracker'));return trk;};function animateTo(a) {var x1=a[0]/xscale,y1=a[1]/yscale,x2=a[2]/xscale,y2=a[3]/yscale;if(animating)return;var animto=Coords.flipCoords(x1,y1,x2,y2);var c=Coords.getFixed();var animat=initcr=[c.x,c.y,c.x2,c.y2];var interv=options.animationDelay;var x=animat[0];var y=animat[1];var x2=animat[2];var y2=animat[3];var ix1=animto[0]-initcr[0];var iy1=animto[1]-initcr[1];var ix2=animto[2]-initcr[2];var iy2=animto[3]-initcr[3];var pcent=0;var velocity=options.swingSpeed;Selection.animMode(true);var animator=function() {return function() {pcent+=(100-pcent)/velocity;animat[0]=x+((pcent/100)*ix1);animat[1]=y+((pcent/100)*iy1);animat[2]=x2+((pcent/100)*ix2);animat[3]=y2+((pcent/100)*iy2);if(pcent<100)animateStart();else Selection.done();if(pcent>=99.8)pcent=100;setSelectRaw(animat);};}();function animateStart()