diff --git a/ChangeLog b/ChangeLog index 0291eeb3a21..f83979aa8e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 3.6.4 compared to 3.6.3 ***** +- Fix: [ bug #2893 ] Dolibarr error when viewing an invoice after changing invoice mask + ***** ChangeLog for 3.6.3 compared to 3.6.2 ***** - Fix: ref_ext was not saved when recording a customer order from web service - Fix: amarok is a bugged theme making dolidroid failed. We switch to eldy automatically with dolidroid. diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index dc8501c37ba..c56bb753ade 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -48,7 +48,7 @@ class PropaleStats extends Stats * Constructor * * @param DoliDB $db Database handler - * @param int $socid Id third party for filter + * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. * @param int $userid Id user for filter (creation user) */ function __construct($db, $socid=0, $userid=0) diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 312e958a38e..1ab418a9daa 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -48,7 +48,7 @@ class CommandeStats extends Stats * Constructor * * @param DoliDB $db Database handler - * @param int $socid Id third party for filter + * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. * @param string $mode Option ('customer', 'supplier') * @param int $userid Id user for filter (creation user) */ diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f5a7c27ecd1..72103f6ac5a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2558,15 +2558,16 @@ class Facture extends CommonInvoice $numref = ""; $numref = $obj->getNextValue($soc,$this,$mode); - if ($numref != "") - { - return $numref; - } - else - { + /** + * $numref can be empty in case we ask for the last value because if there is no invoice created with the + * set up mask. + */ + if ($mode != 'last' && !$numref) { dol_print_error($db,"Facture::getNextNumRef ".$obj->error); return ""; } + + return $numref; } else { diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 5d8d22cfa9d..b2fd603a394 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -45,7 +45,7 @@ class FactureStats extends Stats * Constructor * * @param DoliDB $db Database handler - * @param int $socid Id third party for filter + * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. * @param string $mode Option ('customer', 'supplier') * @param int $userid Id user for filter (creation user) */ @@ -168,7 +168,7 @@ class FactureStats extends Stats $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; @@ -188,7 +188,7 @@ class FactureStats extends Stats $sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(f.".$this->field.") as total, AVG(f.".$this->field.") as avg"; $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->where; $sql.= " GROUP BY year"; $sql.= $this->db->order('year','DESC'); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 917c88e0743..f469b48fdde 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006 Rodolphe Quiedeville * Copyright (C) 2007-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2011-2015 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -744,7 +744,6 @@ class RemiseCheque extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $this->date_bordereau = $date; return 1; } else diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 8ce0a1b3b45..b46540ad6d9 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -753,7 +753,7 @@ class ExtraFields $sqlwhere.= ' WHERE 1'; } if (in_array($InfoFieldList[0],array('tablewithentity'))) $sqlwhere.= ' AND entity = '.$conf->entity; // Some tables may have field, some other not. For the moment we disable it. - //$sql.=preg_replace('/^ AND /','',$sqlwhere); + $sql.=preg_replace('/^ AND /','',$sqlwhere); //print $sql; dol_syslog(get_class($this).'::showInputField type=sellist sql='.$sql); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index dd8c88162a5..c4989b3c087 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -448,7 +448,7 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined'); - $sql = "SELECT dbt.id"; + $sql = "SELECT dbt.".$dbt_keyfield; $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (dbt.".$dbt_keyfield." = s.rowid)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON (sc.fk_soc = dbt.".$dbt_keyfield.")"; diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 73f3ae3e77a..0e23287ac31 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -29,7 +29,7 @@ * \brief File that include conf.php file and commons lib like functions.lib.php */ -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.6.4'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.6.5'); if (! defined('EURO')) define('EURO',chr(128)); // Define syslog constants diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 02666e1c855..6a16f152425 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -262,9 +262,17 @@ if ($id > 0 || ! empty($ref)) $resql = $db->query($sql); if ($resql) { - while ( $row = $db->fetch_row($resql) ) + $num = $db->num_rows($resql); + $i = 0; + + if ($num) { - $products_dispatched[$row[0]] = $row[1]; + while ($i < $num) + { + $objd = $db->fetch_object($resql); + $products_dispatched[$objd->fk_product] = price2num($objd->qty, 5); + $i++; + } } $db->free($resql); } @@ -320,7 +328,7 @@ if ($id > 0 || ! empty($ref)) } else { - $remaintodispatch=($objp->qty - $products_dispatched[$objp->fk_product]); // Calculation of dispatched + $remaintodispatch=(price2num($objp->qty, 5) - $products_dispatched[$objp->fk_product]); // Calculation of dispatched if ($remaintodispatch < 0) $remaintodispatch=0; if ($remaintodispatch) { diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index bd302c422d9..8becd6c38ba 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -72,7 +72,7 @@ class FormProduct $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_entrepot = e.rowid"; $sql.= " AND ps.fk_product = '".$fk_product."'"; } - $sql.= " WHERE e.entity = ".$conf->entity; + $sql.= " WHERE e.entity IN (".getEntity('stock',1).")"; $sql.= " AND e.statut = 1"; $sql.= " ORDER BY e.label"; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 13fc195ff06..41c73a227a4 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2994,7 +2994,7 @@ class Product extends CommonObject $sql = "SELECT ps.reel, ps.fk_entrepot, ps.pmp, ps.rowid"; $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/index.php b/htdocs/product/index.php index a8502498e41..2803c2d06ad 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -299,7 +299,7 @@ if ($result) if (empty($conf->global->PRODUIT_MULTIPRICES)) { print ''; - if ($objp->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); + if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); else print price($objp->price).' '.$langs->trans("HT"); print ''; } diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 61c88abcaa5..b65c01f6840 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); diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index da52a5aac58..667c32346f5 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -64,7 +64,7 @@ print "
"; $sql = "SELECT e.label, e.rowid, e.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " WHERE e.statut in (0,1)"; -$sql.= " AND e.entity = ".$conf->entity; +$sql.= " AND e.entity IN (".getEntity('stock',1).")"; $sql.= $db->order('e.statut','DESC'); $sql.= $db->plimit(15, 0); @@ -119,7 +119,7 @@ $sql.= ", ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE m.fk_product = p.rowid"; $sql.= " AND m.fk_entrepot = e.rowid"; -$sql.= " AND e.entity = ".$conf->entity; +$sql.= " AND e.entity IN (".getEntity('stock',1).")"; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0"; $sql.= $db->order("datem","DESC"); $sql.= $db->plimit($max,0); diff --git a/htdocs/product/stock/liste.php b/htdocs/product/stock/liste.php index a639bd86239..a4220be092d 100644 --- a/htdocs/product/stock/liste.php +++ b/htdocs/product/stock/liste.php @@ -47,7 +47,7 @@ $offset = $limit * $page; $sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; -$sql.= " WHERE e.entity = ".$conf->entity; +$sql.= " WHERE e.entity IN (".getEntity('stock',1).")"; if ($sref) { $sql.= " AND e.label like '%".$db->escape($sref)."%'"; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 8794b00137d..e94df443702 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -129,7 +129,7 @@ $sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; $sql.= " WHERE m.fk_product = p.rowid"; $sql.= " AND m.fk_entrepot = e.rowid"; -$sql.= " AND e.entity = ".$conf->entity; +$sql.= " AND e.entity IN (".getEntity('stock',1).")"; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0"; if ($id) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 0241c0d4dcf..6b08dd16ecf 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -583,7 +583,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= " WHERE ps.reel != 0"; $sql.= " AND ps.fk_entrepot = e.rowid"; -$sql.= " AND e.entity = ".$conf->entity; +$sql.= " AND e.entity IN (".getEntity('stock',1).")"; $sql.= " AND ps.fk_product = ".$product->id; $sql.= " ORDER BY e.label"; diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 17e23fef009..75b85af00fa 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -57,7 +57,7 @@ $sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sell $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"; -$sql.= " WHERE e.entity = ".$conf->entity; +$sql.= " WHERE e.entity IN (".getEntity('stock',1).")"; if ($sref) { $sql.= " AND e.ref LIKE '%".$sref."%'";