diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ce693d5bebf..c122a1c7ffc 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -380,6 +380,9 @@ class Categorie extends CommonObject $this->db = $db; + $this->ismultientitymanaged = 1; + $this->isextrafieldmanaged = 1; + if (is_object($hookmanager)) { $hookmanager->initHooks(array('category')); $parameters = array(); diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 86694d7937e..ee1a9e6d325 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -89,7 +89,10 @@ foreach ($categstatic->MAP_ID as $key => $idtype) { $arrayofcateg = dol_sort_array($arrayofcateg, 'labelwithoutaccent', 'asc', 1, 0, 1); // Get number of tags per category type -$sql = "SELECT type as idtype, COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."categorie GROUP BY type"; +$sql = "SELECT type as idtype, COUNT(rowid) as nb"; +$sql .= " FROM ".MAIN_DB_PREFIX."categorie"; +$sql .= " WHERE entity IN (".getEntity('category').")"; +$sql .= " GROUP BY type"; $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 12b18df5ddb..e6a99bf9027 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -276,13 +276,14 @@ class FactureStats extends Stats global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; - $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + $sql .= " FROM ".$this->from; + $sql .= " INNER JOIN ".$this->from_line." ON f.rowid = tl.fk_facture"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."product as product ON tl.fk_product = product.rowid"; if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE ".$this->where; - $sql .= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid"; $sql .= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; $sql .= " GROUP BY product.ref"; $sql .= $this->db->order('nb', 'DESC'); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 50f13ac254e..3113261d147 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3070,7 +3070,7 @@ class CommandeFournisseur extends CommonOrder * @param int|float $pu Unit price * @param int|float $qty Quantity * @param int|float $remise_percent Percent discount on line - * @param int|float $txtva VAT rate + * @param int|float|string $txtva VAT Rate (Can be '1.23' or '1.23 (ABC)') * @param int|float $txlocaltax1 Localtax1 tax * @param int|float $txlocaltax2 Localtax2 tax * @param string $price_base_type Type of price base diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f6e41fd9535..d385dedebb0 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -811,7 +811,7 @@ if (empty($reshook)) { $ht, (float) price2num(GETPOST('qty'), 'MS'), (float) price2num(GETPOST('remise_percent'), '', 2), - (float) $vat_rate, + $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 20d31592502..9a6dc94a51f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2740,10 +2740,11 @@ if ($action == 'create') { // Label print ''.$langs->trans('Label').''; + // Date invoice print ''.$langs->trans('DateInvoice').''; print img_picto('', 'action', 'class="pictofixedwidth"'); - print $form->selectDate((int) $dateinvoice, '', 0, 0, 0, "add", 1, 1); + print $form->selectDate($dateinvoice ? (int) $dateinvoice : '', '', 0, 0, 0, "add", 1, 1); print ''; // Payment term @@ -2909,7 +2910,11 @@ if ($action == 'create') { // We check if Origin document (id and type is known) has already at least one invoice attached to it $objectsrc->fetchObjectLinked($originid, $origin, null, 'invoice_supplier'); - $invoice_supplier = $objectsrc->linkedObjects['invoice_supplier']; + if (isset($objectsrc->linkedObjects['invoice_supplier'])) { + $invoice_supplier = $objectsrc->linkedObjects['invoice_supplier']; + } else { + $invoice_supplier = []; + } '@phan-var-force null|FactureFournisseur[] $invoice_supplier'; // count function need a array as argument (Note: the array must implement Countable too)