';
}
if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index 3e077bae802..7a9ce2733d8 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -2535,7 +2535,7 @@ elseif ($id || $ref)
// This is just to generate a delivery receipt
//var_dump($object->linkedObjectsIds['delivery']);
- if ($conf->livraison_bon->enabled && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED) && $user->rights->expedition->livraison->creer && count($object->linkedObjectsIds['delivery']) == 0)
+ if ($conf->livraison_bon->enabled && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED) && $user->rights->expedition->livraison->creer && empty($object->linkedObjectsIds['delivery']))
{
print 'id.'&action=create_delivery">'.$langs->trans("CreateDeliveryOrder").'';
}
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 905819dabc5..b623ea9c629 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -529,7 +529,7 @@ class Expedition extends CommonObject
// Check parameters
if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
- $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.fk_projet as fk_project, e.billed";
+ $sql = "SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.fk_projet as fk_project, e.billed";
$sql.= ", e.date_valid";
$sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height";
$sql.= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery";
@@ -558,6 +558,7 @@ class Expedition extends CommonObject
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
+ $this->entity = $obj->entity;
$this->ref = $obj->ref;
$this->socid = $obj->socid;
$this->ref_customer = $obj->ref_customer;
@@ -602,7 +603,7 @@ class Expedition extends CommonObject
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
-
+
$this->db->free($result);
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php
index 2dddac4dbab..bb543642733 100644
--- a/htdocs/expensereport/class/expensereport.class.php
+++ b/htdocs/expensereport/class/expensereport.class.php
@@ -970,7 +970,7 @@ class ExpenseReport extends CommonObject
{
// phpcs:enable
global $conf;
-
+
$this->lines=array();
$sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date, de.rang,';
@@ -2274,7 +2274,7 @@ class ExpenseReport extends CommonObject
public function load_state_board()
{
// phpcs:enable
- global $conf;
+ global $conf, $user;
$this->nb=array();
@@ -2282,6 +2282,12 @@ class ExpenseReport extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex";
$sql.= " WHERE ex.fk_statut > 0";
$sql.= " AND ex.entity IN (".getEntity('expensereport').")";
+ if(!$user->rights->expensereport->readall)
+ {
+ $userchildids = $user->getAllChildIds(1);
+ $sql.= " AND (ex.fk_user_author IN (".join(',', $userchildids).")";
+ $sql.= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))";
+ }
$resql=$this->db->query($sql);
if ($resql) {
@@ -2316,15 +2322,17 @@ class ExpenseReport extends CommonObject
$now=dol_now();
- $userchildids = $user->getAllChildIds(1);
-
$sql = "SELECT ex.rowid, ex.date_valid";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex";
if ($option == 'toapprove') $sql.= " WHERE ex.fk_statut = 2";
else $sql.= " WHERE ex.fk_statut = 5";
$sql.= " AND ex.entity IN (".getEntity('expensereport').")";
- $sql.= " AND (ex.fk_user_author IN (".join(',', $userchildids).")";
- $sql.= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))";
+ if(!$user->rights->expensereport->readall)
+ {
+ $userchildids = $user->getAllChildIds(1);
+ $sql.= " AND (ex.fk_user_author IN (".join(',', $userchildids).")";
+ $sql.= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))";
+ }
$resql=$this->db->query($sql);
if ($resql)
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 4b42665199f..2ad30a60b80 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -1815,7 +1815,6 @@ class CommandeFournisseur extends CommonOrder
if ($result < 0)
{
$error++;
- return -1;
}
// End call triggers
}
@@ -1923,6 +1922,7 @@ class CommandeFournisseur extends CommonOrder
{
$this->errors[]='ErrorWhenRunningTrigger';
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
+ $this->db->rollback();
return -1;
}
// End call triggers
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index b62190686b3..e20a3f9e7de 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -1967,7 +1967,7 @@ class FactureFournisseur extends CommonInvoice
$this->errors[] = $line->error;
} else {
// Update total price into invoice record
- $res = $this->update_price('', 'auto');
+ $res = $this->update_price('', 'auto', 0, $this->thirdparty);
}
return $res;
diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php
index 25f1d9675bb..1d818d33c1f 100644
--- a/htdocs/holiday/class/holiday.class.php
+++ b/htdocs/holiday/class/holiday.class.php
@@ -2182,12 +2182,20 @@ class Holiday extends CommonObject
public function load_state_board()
{
// phpcs:enable
+ global $user;
+
$this->nb=array();
$sql = "SELECT count(h.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as h";
$sql.= " WHERE h.statut > 1";
$sql.= " AND h.entity IN (".getEntity('holiday').")";
+ if(!$user->rights->expensereport->read_all)
+ {
+ $userchildids = $user->getAllChildIds(1);
+ $sql.= " AND (h.fk_user IN (".join(',', $userchildids).")";
+ $sql.= " OR h.fk_validator IN (".join(',', $userchildids)."))";
+ }
$resql=$this->db->query($sql);
if ($resql) {
@@ -2221,14 +2229,16 @@ class Holiday extends CommonObject
$now=dol_now();
- $userchildids = $user->getAllChildIds(1);
-
$sql = "SELECT h.rowid, h.date_debut";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as h";
$sql.= " WHERE h.statut = 2";
$sql.= " AND h.entity IN (".getEntity('holiday').")";
- $sql.= " AND (h.fk_user IN (".join(',', $userchildids).")";
- $sql.= " OR h.fk_validator IN (".join(',', $userchildids)."))";
+ if(!$user->rights->expensereport->read_all)
+ {
+ $userchildids = $user->getAllChildIds(1);
+ $sql.= " AND (h.fk_user IN (".join(',', $userchildids).")";
+ $sql.= " OR h.fk_validator IN (".join(',', $userchildids)."))";
+ }
$resql=$this->db->query($sql);
if ($resql)
diff --git a/htdocs/index.php b/htdocs/index.php
index 5eee02efa1e..944701fe0d1 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -324,7 +324,7 @@ if (empty($user->societe_id))
include_once $includes[$key]; // Loading a class cost around 1Mb
$board=new $classe($db);
- $board->load_state_board($user);
+ $board->load_state_board();
$boardloaded[$classe]=$board;
}
else
diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql
index 73cb1e6592d..86c37198347 100755
--- a/htdocs/install/mysql/migration/repair.sql
+++ b/htdocs/install/mysql/migration/repair.sql
@@ -337,9 +337,14 @@ UPDATE llx_c_lead_status set code = 'WON' where code = 'WIN';
-- To replace amount on all invoice and lines when forgetting to apply a 20% vat
-- update llx_facturedet set tva_tx = 20 where tva_tx = 0;
-- update llx_facturedet set total_ht = round(total_ttc / 1.2, 5) where total_ht = total_ttc;
--- update llx_facturedet set total_tva = total_ttc - total_ht where total_vat = 0;
-- update llx_facture set total = round(total_ttc / 1.2, 5) where total_ht = total_ttc;
--- update llx_facture set tva = total_ttc - total where tva = 0;
+
+-- To fix bad total of price excluding tax, vat and price tax including tax.
+-- select * from llx_facture where tva <> (total_ttc - total - localtax1 - localtax2 - revenuestamp);
+-- update llx_facture set tva = (total_ttc - total - localtax1 - localtax2 - revenuestamp) where tva <> (total_ttc - total - localtax1 - localtax2 - revenuestamp);
+-- select * from llx_facturedet where total_tva <> (total_ttc - total_ht - total_localtax1 - total_localtax2);
+-- update llx_facturedet set total_tva = (total_ttc - total_ht - total_localtax1 - total_localtax2) where total_tva <> (total_ttc - total_ht - total_localtax1 - total_localtax2);
+
-- To insert elements into a category
-- Search idcategory: select rowid from llx_categorie where type=0 and ref like '%xxx%'
@@ -470,6 +475,11 @@ UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS
-- UPDATE llx_facturedet_rec set label = NULL WHERE label IS NOT NULL;
+-- Test inconsistency of data into situation invoices: If it differs, it may be the total_ht that is wrong and situation_percent that is good.
+-- select f.rowid, f.type, fd.qty, fd.subprice, fd.situation_percent, fd.total_ht, fd.total_ttc, fd.total_tva, fd.multicurrency_total_ht, fd.multicurrency_total_tva, fd.multicurrency_total_ttc, (situation_percent / 100 * subprice * qty * (1 - (fd.remise_percent / 100)))
+-- from llx_facturedet as fd, llx_facture as f where fd.fk_facture = f.rowid AND (total_ht - situation_percent / 100 * subprice * qty * (1 - (fd.remise_percent / 100))) > 0.01 and f.type = 5;
+
+
-- Note to migrate from old counter aquarium to new one
-- drop table tmp;
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index 60064ff33c2..bc235954aca 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -3605,10 +3605,9 @@ function migrate_mode_reglement($db, $langs, $conf)
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
- * @param string $versionto Version target
* @return void
*/
-function migrate_clean_association($db, $langs, $conf, $versionto)
+function migrate_clean_association($db, $langs, $conf)
{
$result = $db->DDLDescTable(MAIN_DB_PREFIX."categorie_association");
if ($result) // result defined for version 3.2 or -
diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang
index 4b22f512826..9b80eae930c 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -218,6 +218,7 @@ ListAccounts=List of the accounting accounts
UnknownAccountForThirdparty=Unknown third-party account. We will use %s
UnknownAccountForThirdpartyBlocking=Unknown third-party account. Blocking error
ThirdpartyAccountNotDefinedOrThirdPartyUnknown=Third-party account not defined or third party unknown. We will use %s
+ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored=Third-party unknown and subledger not defined on the payment. We will keep the subledger account value empty.
ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking=Third-party account not defined or third party unknown. Blocking error.
UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Unknown third-party account and waiting account not defined. Blocking error
PaymentsNotLinkedToProduct=Payment not linked to any product / service
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 64dac1f39e5..5378ef5729d 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1792,6 +1792,7 @@ MailToThirdparty=Third parties
MailToMember=Members
MailToUser=Users
MailToProject=Projects page
+MailToTicket=Tickets
ByDefaultInList=Show by default on list view
YouUseLastStableVersion=You use the latest stable version
TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites)
@@ -1923,4 +1924,4 @@ DeleteEmailCollector=Delete email collector
ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector?
RecipientEmailsWillBeReplacedWithThisValue=Recipient emails will be always replaced with this value
AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be defined
-FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled
\ No newline at end of file
+FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index ddef01b17c1..3f6dc358d2f 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -554,4 +554,5 @@ AutoFillDateFromShort=Set start date
AutoFillDateTo=Set end date for service line with next invoice date
AutoFillDateToShort=Set end date
MaxNumberOfGenerationReached=Max number of gen. reached
-BILL_DELETEInDolibarr=Invoice deleted
\ No newline at end of file
+BILL_DELETEInDolibarr=Invoice deleted
+UnitPriceXQtyLessDiscount=Unit price x Qty - Discount
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang
index 0150ff7d017..7c0602332f3 100644
--- a/htdocs/langs/fr_FR/accountancy.lang
+++ b/htdocs/langs/fr_FR/accountancy.lang
@@ -218,6 +218,7 @@ ListAccounts=Liste des comptes comptables
UnknownAccountForThirdparty=Compte de tiers inconnu. %s sera utilisé
UnknownAccountForThirdpartyBlocking=Compte de tiers inconnu. Erreur bloquante.
ThirdpartyAccountNotDefinedOrThirdPartyUnknown=Code comptable du tiers non défini ou tiers inconnu. On utilisera %s.
+ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored=Tiers inconnu et code comptable auxiliaire non défini sur le paiement. Nous conserverons la valeur du compte auxiliaire vide.
ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking=Compte tiers non défini ou inconnu. Erreur bloquante.
UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Compte tiers inconnu et compte d'attente non défini. Erreur blocante.
PaymentsNotLinkedToProduct=Paiement non lié à un produit / service
diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang
index 58242dfaa1a..b76d78ea09d 100644
--- a/htdocs/langs/fr_FR/exports.lang
+++ b/htdocs/langs/fr_FR/exports.lang
@@ -109,7 +109,7 @@ Separator=Séparateur de champs
Enclosure=Encadrement des chaînes de textes
SpecialCode=Code spécial
ExportStringFilter=%% permet de remplacer 1 ou plusieurs caractères dans le texte
-ExportDateFilter=AAAA, AAAAMM, AAAAMMJJ: filtre pour une année/mois/jour AAAA+AAAA, AAAAMM+AAAAMM, AAAAMMJJ+AAAAMMJJ: filtre pour une plage année/mois/jour > AAAA, > AAAAMM, > AAAAMMJJ': filtre pour une date supérieure à une année/mois/jour donné < AAAA, < AAAAMM, < AAAAMMJJ: filtre pour une date inférieure à une année/mois/jour donné
+ExportDateFilter=AAAA, AAAAMM, AAAAMMJJ: filtre pour une année/mois/jour AAAA+AAAA, AAAAMM+AAAAMM, AAAAMMJJ+AAAAMMJJ: filtre pour une plage année/mois/jour > AAAA, > AAAAMM, > AAAAMMJJ: filtre pour une date supérieure à une année/mois/jour donné < AAAA, < AAAAMM, < AAAAMMJJ: filtre pour une date inférieure à une année/mois/jour donné
ExportNumericFilter=NNNNN filtre une seule valeur NNNNN+NNNNN filtre une plage de valeurs < NNNNN filtre les valeurs inférieures > NNNNN filtre les valeurs supérieures
ImportFromLine=Début d'import à la ligne numéro
EndAtLineNb=Fin à la ligne numéro
diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php
index aaafc334e9e..c636ed34ffe 100644
--- a/htdocs/societe/checkvat/checkVatPopup.php
+++ b/htdocs/societe/checkvat/checkVatPopup.php
@@ -28,9 +28,9 @@ require_once NUSOAP_PATH.'/nusoap.php';
$langs->load("companies");
//http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
-$WS_DOL_URL='http://ec.europa.eu/taxation_customs/vies/services/checkVatService';
+$WS_DOL_URL='https://ec.europa.eu/taxation_customs/vies/services/checkVatService';
//$WS_DOL_URL_WSDL=$WS_DOL_URL.'?wsdl';
-$WS_DOL_URL_WSDL='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
+$WS_DOL_URL_WSDL='https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
$WS_METHOD ='checkVat';
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index dd6765e34f5..918674ba23a 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -3402,6 +3402,7 @@ class Societe extends CommonObject
$this->twitter=$member->twitter;
$this->facebook=$member->facebook;
$this->linkedin=$member->linkedin;
+ $this->entity=$member->entity;
$this->client = 1; // A member is a customer by default
$this->code_client = ($customercode?$customercode:-1);
diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php
index f331587723b..e79faf17de0 100644
--- a/htdocs/takepos/admin/setup.php
+++ b/htdocs/takepos/admin/setup.php
@@ -74,8 +74,8 @@ if (GETPOST('action', 'alpha') == 'set')
$res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTERS", GETPOST('TAKEPOS_ORDER_PRINTERS', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_ORDER_NOTES", GETPOST('TAKEPOS_ORDER_NOTES', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity);
- $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity);
- $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'restricthtml'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'restricthtml'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity);
diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php
index 1bf31ebfd4b..bca39bde602 100755
--- a/scripts/cron/cron_run_jobs.php
+++ b/scripts/cron/cron_run_jobs.php
@@ -176,11 +176,12 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
// Force reload of setup for the current entity
if ((empty($line->entity)?1:$line->entity) != $conf->entity)
{
- dol_syslog("cron_run_jobs.php we work on another entity conf than ".$conf->entity." so we reload user and conf", LOG_DEBUG);
- echo " -> we change entity so we reload user and conf";
+ dol_syslog("cron_run_jobs.php we work on another entity conf than ".$conf->entity." so we reload mysoc, langs, user and conf", LOG_DEBUG);
+ echo " -> we change entity so we reload mysoc, langs, user and conf";
$conf->entity = (empty($line->entity)?1:$line->entity);
$conf->setValues($db); // This make also the $mc->setValues($conf); that reload $mc->sharings
+ $mysoc->setMysoc($conf);
// Force recheck that user is ok for the entity to process and reload permission for entity
if ($conf->entity != $user->entity && $user->entity != 0)
@@ -203,6 +204,11 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
}
$user->getrights();
}
+
+ // Reload langs
+ $langcode = (empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT);
+ if (! empty($user->conf->MAIN_LANG_DEFAULT)) $langcode = $user->conf->MAIN_LANG_DEFAULT;
+ if ($langs->getDefaultLang() != $langcode) $langs->setDefaultLang($langcode);
}
//If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database