diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 1f2a765ee05..93a4b9fc019 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1013,7 +1013,7 @@ class BookKeeping extends CommonObject $line->multicurrency_amount = $obj->multicurrency_amount; $line->multicurrency_code = $obj->multicurrency_code; $line->lettering_code = $obj->lettering_code; - $line->date_lettering = $obj->date_lettering; + $line->date_lettering = $this->db->jdate($obj->date_lettering); $line->fk_user_author = $obj->fk_user_author; $line->import_key = $obj->import_key; $line->code_journal = $obj->code_journal; @@ -1201,7 +1201,7 @@ class BookKeeping extends CommonObject $line->amount = $obj->amount; $line->sens = $obj->sens; $line->lettering_code = $obj->lettering_code; - $line->date_lettering = $obj->date_lettering; + $line->date_lettering = $this->db->jdate($obj->date_lettering); $line->fk_user_author = $obj->fk_user_author; $line->import_key = $obj->import_key; $line->code_journal = $obj->code_journal; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index dce6af450d3..246ca9f18a0 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -363,29 +363,31 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice } */ // New way, single query, load all unbound lines -$sql = " -SELECT - fk_facture_fourn, - COUNT(fd.rowid) as nb -FROM - " . MAIN_DB_PREFIX . "facture_fourn_det as fd -WHERE - fd.product_type <= 2 - AND fd.fk_code_ventilation <= 0 - AND fd.total_ttc <> 0 - AND fk_facture_fourn IN (".$db->sanitize(implode(",", array_keys($tabfac))).") -GROUP BY fk_facture_fourn -"; -$resql = $db->query($sql); +if (!empty($tabfac)) { + $sql = " + SELECT + fk_facture_fourn, + COUNT(fd.rowid) as nb + FROM + " . MAIN_DB_PREFIX . "facture_fourn_det as fd + WHERE + fd.product_type <= 2 + AND fd.fk_code_ventilation <= 0 + AND fd.total_ttc <> 0 + AND fk_facture_fourn IN (".$db->sanitize(join(",", array_keys($tabfac))).") + GROUP BY fk_facture_fourn + "; + $resql = $db->query($sql); -$num = $db->num_rows($resql); -$i = 0; -while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($obj->nb > 0) { - $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound'; + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj->nb > 0) { + $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound'; + } + $i++; } - $i++; } //var_dump($errorforinvoice);exit; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 1396c43328a..d46d7e8ff31 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -398,30 +398,31 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice } */ // New way, single query, load all unbound lines - -$sql = " -SELECT - fk_facture, - COUNT(fd.rowid) as nb -FROM - ".MAIN_DB_PREFIX."facturedet as fd -WHERE - fd.product_type <= 2 - AND fd.fk_code_ventilation <= 0 - AND fd.total_ttc <> 0 - AND fk_facture IN (".$db->sanitize(implode(",", array_keys($tabfac))).") -GROUP BY fk_facture -"; -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($obj->nb > 0) { - $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound'; +if (!empty($tabfac)) { + $sql = " + SELECT + fk_facture, + COUNT(fd.rowid) as nb + FROM + ".MAIN_DB_PREFIX."facturedet as fd + WHERE + fd.product_type <= 2 + AND fd.fk_code_ventilation <= 0 + AND fd.total_ttc <> 0 + AND fk_facture IN (".$db->sanitize(implode(",", array_keys($tabfac))).") + GROUP BY fk_facture + "; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj->nb > 0) { + $errorforinvoice[$obj->fk_facture] = 'somelinesarenotbound'; + } + $i++; } - $i++; } } //var_dump($errorforinvoice);exit; diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 11054c3a05c..c50bcc4bce4 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2016 Jean-François Ferry * Copyright (C) 2023 Romain Neil + * Copyright (C) 2025 William Mead * * 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 @@ -506,7 +507,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'expensereport') { require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - if (!DolibarrApiAccess::$user->hasRight('expensereport', 'read') && !DolibarrApiAccess::$user->hasRight('expensereport', 'read')) { + if (!DolibarrApiAccess::$user->hasRight('expensereport', 'read')) { throw new RestException(403); } diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 974a53f1476..67ec8ab467b 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -315,7 +315,7 @@ if ($resql) { // Date ope print ''; - print ''.dol_print_date($db->jdate($objp->do), "day").""; + print ''.dol_print_date($db->jdate($objp->do), "day").""; print "\n"; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 1586ec803b2..7da68f1734a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -99,7 +99,7 @@ $origin = GETPOST('origin', 'alpha'); $originid = (GETPOSTINT('originid') ? GETPOSTINT('originid') : GETPOSTINT('origin_id')); // For backward compatibility $fac_rec = GETPOSTINT('fac_rec'); $facid = GETPOSTINT('facid'); -$ref_client = GETPOSTINT('ref_client'); +$ref_client = GETPOST('ref_client', 'alpha'); $rank = (GETPOSTINT('rank') > 0) ? GETPOSTINT('rank') : -1; $projectid = (GETPOSTINT('projectid') ? GETPOSTINT('projectid') : 0); $selectedLines = GETPOST('toselect', 'array'); @@ -669,7 +669,7 @@ if (empty($reshook)) { $object->setValueFrom('ref', GETPOST('ref'), '', 0, '', '', $user, 'BILL_MODIFY'); } elseif ($action == 'setref_client' && $usercancreate) { $object->fetch($id); - $object->set_ref_client(GETPOST('ref_client')); + $object->set_ref_client(GETPOST('ref_client', 'alpha')); } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) { // Classify to validated $idwarehouse = GETPOSTINT('idwarehouse'); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 4a4d4cca978..0b4cb4a5fd6 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2285,7 +2285,7 @@ if ($action == 'create') { print '
'; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; - print showOnlineSignatureUrl('contract', $object->ref).'
'; + print showOnlineSignatureUrl('contract', $object->ref, $object).'
'; } print '
'; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1daa9d390ef..10041e16fc2 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2001,7 +2001,7 @@ function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0) $tmpresult .= vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); if (!getDolGlobalString('MAIN_PDF_MAIN_HIDE_SECOND_TAX')) { - if ($object->lines[$i]->total_localtax1 != 0) { + if (price2num($object->lines[$i]->localtax1_tx)) { if (preg_replace('/[\s0%]/', '', $tmpresult)) { $tmpresult .= '/'; } else { @@ -2011,7 +2011,7 @@ function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0) } } if (!getDolGlobalString('MAIN_PDF_MAIN_HIDE_THIRD_TAX')) { - if ($object->lines[$i]->total_localtax2 != 0) { + if (price2num($object->lines[$i]->localtax2_tx)) { if (preg_replace('/[\s0%]/', '', $tmpresult)) { $tmpresult .= '/'; } else { diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 6de584c4403..85adef0e1d8 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -784,8 +784,8 @@ class FactureFournisseurRec extends CommonInvoice $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; $line->product_type = $objp->product_type; - $line->date_start = $objp->date_start; - $line->date_end = $objp->date_end; + $line->date_start = $this->db->jdate($objp->date_start); + $line->date_end = $this->db->jdate($objp->date_end); $line->info_bits = $objp->info_bits ; $line->special_code = $objp->special_code; $line->rang = $objp->rang; @@ -2162,8 +2162,8 @@ class FactureFournisseurLigneRec extends CommonInvoiceLine $this->total_localtax2 = $objp->total_localtax2; $this->total_ttc = $objp->total_ttc; $this->product_type = $objp->product_type; - $this->date_start = $objp->date_start; - $this->date_end = $objp->date_end; + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); $this->info_bits = $objp->info_bits; $this->special_code = $objp->special_code; $this->rang = $objp->rang; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c2a3a0a66e9..e71200381b4 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1060,10 +1060,12 @@ class FactureFournisseur extends CommonInvoice $line->id = $obj->rowid; $line->rowid = $obj->rowid; + $line->description = $obj->line_desc; $line->desc = $obj->line_desc; - $line->date_start = $obj->date_start; - $line->date_end = $obj->date_end; + $line->date_start = $this->db->jdate($obj->date_start); + $line->date_end = $this->db->jdate($obj->date_end); + $line->product_ref = $obj->product_ref; $line->ref = $obj->product_ref; $line->ref_supplier = $obj->ref_supplier; @@ -4032,10 +4034,16 @@ class SupplierInvoiceLine extends CommonObjectLine $this->id = $obj->rowid; $this->rowid = $obj->rowid; $this->fk_facture_fourn = $obj->fk_facture_fourn; +<<<<<<< HEAD $this->description = $obj->line_desc; $this->desc = $obj->line_desc; $this->date_start = $obj->date_start; $this->date_end = $obj->date_end; +======= + $this->description = $obj->description; + $this->date_start = $this->db->jdate($obj->date_start); + $this->date_end = $this->db->jdate($obj->date_end); +>>>>>>> origin/19.0 $this->product_ref = $obj->product_ref; $this->ref_supplier = $obj->ref_supplier; $this->product_desc = $obj->product_desc; diff --git a/htdocs/takepos/send.php b/htdocs/takepos/send.php index 708dcf713cc..3597f21a839 100644 --- a/htdocs/takepos/send.php +++ b/htdocs/takepos/send.php @@ -81,7 +81,7 @@ if ($action == "send") { $msg = "".$arraydefaultmessage->content."
".$receipt.""; $sendto = $email; $from = $mysoc->email; - $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', '', '', '', '', DOL_DOCUMENT_ROOT.'/documents/takepos/temp'); + $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', '', '', '', '', DOL_DATA_ROOT.'/documents/takepos/temp'); if ($mail->error || !empty($mail->errors)) { setEventMessages($mail->error, $mail->errors, 'errors'); } else { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 856b8c03c32..89f193580cd 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -4112,10 +4112,9 @@ class User extends CommonObject if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) { $sql .= " WHERE t.entity IS NOT NULL"; // Show all users } else { - $sql .= ",".$this->db->prefix()."usergroup_user as ug"; - $sql .= " WHERE ((ug.fk_user = t.rowid"; - $sql .= " AND ug.entity IN (".getEntity('usergroup')."))"; - $sql .= " OR t.entity = 0)"; // Show always superadmin + $sql .= " WHERE t.entity = 0 OR EXISTS ("; + $sql .= " SELECT ug.rowid FROM " . $this->db->prefix() . "usergroup_user as ug"; + $sql .= " WHERE ug.fk_user = t.rowid AND ug.entity IN (" . getEntity('usergroup') . "))"; } } else { $sql .= " WHERE t.entity IN (".getEntity('user').")";