From f1bbe1c64da6c6f6441af4a5f3d93a9ed6cc935b Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Mon, 17 Feb 2020 19:09:58 +0100 Subject: [PATCH 01/18] Fix issue not show photo. --- htdocs/core/boxes/box_clients.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index ea2a7814f14..bb5b7023264 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -95,7 +95,7 @@ class box_clients extends ModeleBoxes $sql.= ", s.code_compta_fournisseur"; $sql.= ", s.logo"; $sql.= ", s.email"; - $sql.= ", s.datec, s.tms, s.status"; + $sql.= ", s.datec, s.tms, s.status, s.entity"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (1, 3)"; @@ -127,6 +127,7 @@ class box_clients extends ModeleBoxes $thirdpartystatic->fournisseur = $objp->fournisseur; $thirdpartystatic->logo = $objp->logo; $thirdpartystatic->email = $objp->email; + $thirdpartystatic->entity = $objp->entity; $this->info_box_contents[$line][] = array( 'td' => '', From 29cfd6d8579ef138e58bf908c0392f7a47b2704a Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Mon, 17 Feb 2020 19:18:22 +0100 Subject: [PATCH 02/18] Fix issue with Multicompany Before : can't find photo Now : ok --- htdocs/core/boxes/box_propales.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 6bf6a2c2166..3edb4d84c0c 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic France + * Copyright (C) 2020 Pierre Ardoin * * 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 @@ -84,7 +85,7 @@ class box_propales extends ModeleBoxes if ($user->rights->propale->lire) { - $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo,"; + $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity,"; $sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; @@ -121,6 +122,7 @@ class box_propales extends ModeleBoxes $societestatic->name = $objp->name; $societestatic->code_client = $objp->code_client; $societestatic->logo = $objp->logo; + $societestatic->entity = $objp->entity; $late = ''; if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { From a773b86ad18dae65b866435b4e176f9d97cbd240 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Mon, 17 Feb 2020 19:23:48 +0100 Subject: [PATCH 03/18] Fix not displayed value --- htdocs/core/boxes/box_fournisseurs.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 01f62bc38c9..4922d9556c1 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004-2006 Destailleur Laurent * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic France + * Copyright (C) 2020 Pierre Ardoin * * 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 @@ -86,7 +87,7 @@ class box_fournisseurs extends ModeleBoxes { $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; $sql.= " s.code_fournisseur,"; - $sql.= " s.logo"; + $sql.= " s.logo, s.email, s.code_compta_fournisseur, s.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; @@ -111,6 +112,9 @@ class box_fournisseurs extends ModeleBoxes $thirdpartytmp->name = $objp->name; $thirdpartytmp->code_client = $objp->code_client; $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->entity = $objp->entity; $this->info_box_contents[$line][] = array( 'td' => '', From f8e18a3826dc652531747ed8d0c8787479a5570d Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Mon, 17 Feb 2020 19:25:25 +0100 Subject: [PATCH 04/18] Fix Not displayed email --- htdocs/core/boxes/box_propales.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 3edb4d84c0c..7e73166ed90 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -85,7 +85,7 @@ class box_propales extends ModeleBoxes if ($user->rights->propale->lire) { - $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity,"; + $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,"; $sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; @@ -123,6 +123,7 @@ class box_propales extends ModeleBoxes $societestatic->code_client = $objp->code_client; $societestatic->logo = $objp->logo; $societestatic->entity = $objp->entity; + $societestatic->email = $objp->email; $late = ''; if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { From ef64e203671d9bb1618e1acb2512af4204e6fe3a Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Mon, 17 Feb 2020 19:34:09 +0100 Subject: [PATCH 05/18] Fix not display value --- htdocs/societe/index.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 2404c11861e..e5b49ee3bea 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -267,7 +267,10 @@ $max=15; $sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur"; $sql.= ", s.code_client"; $sql.= ", s.code_fournisseur"; +$sql.= ", s.code_compta_fournisseur"; +$sql.= ", s.code_compta"; $sql.= ", s.logo"; +$sql.= ", s.entity"; $sql.= ", s.canvas, s.tms as datem, s.status as status"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -314,6 +317,9 @@ if ($result) $thirdparty_static->code_fournisseur = $objp->code_fournisseur; $thirdparty_static->canvas=$objp->canvas; $thirdparty_static->email = $objp->email; + $thirdparty_static->entity = $objp->entity; + $thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdparty_static->code_compta = $objp->code_compta; print ''; // Name From 49dd8e30aae0005ce4c8cc540af612ed71db3a5c Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 18 Feb 2020 08:28:39 +0100 Subject: [PATCH 06/18] Fix not display data --- htdocs/comm/index.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 651d2c54ec7..c374120c8d2 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2020 Pierre Ardoin * * 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 @@ -141,6 +142,9 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; + $sql.= ", s.email"; + $sql.= ", s.entity"; + $sql.= ", s.code_compta"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -184,6 +188,9 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; + $companystatic->code_compta = $obj->code_compta; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 16); print ''; @@ -226,6 +233,8 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -268,6 +277,8 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'supplier', 16); print ''; @@ -308,6 +319,9 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; + $sql.= ", s.email"; + $sql.= ", s.entity"; + $sql.= ", s.code_compta"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -350,6 +364,9 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas=$obj->canvas; + $companystatic->email=$obj->email; + $companystatic->entity=$obj->entity; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 16); print ''; @@ -398,6 +415,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; $sql.= ", s.code_fournisseur"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -441,6 +460,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->entity=$obj->entity; + $companystatic->email=$obj->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'supplier', 16); print ''; @@ -492,6 +513,9 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; $sql.= ", s.code_client"; + $sql.= ", s.code_compta"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (1, 2, 3)"; @@ -527,6 +551,9 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) $companystatic->client=$objp->client; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->code_compta = $objp->code_compta; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; $companystatic->canvas=$objp->canvas; print ''; print ''.$companystatic->getNomUrl(1, 'customer', 48).''; @@ -556,6 +583,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm"; $sql.= ", s.code_fournisseur"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; @@ -586,6 +615,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) $companystatic->name=$objp->name; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; $companystatic->canvas=$objp->canvas; print ''; print ''.$companystatic->getNomUrl(1, 'supplier', 44).''; @@ -632,6 +663,8 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO $sql = "SELECT s.nom as name, s.rowid, s.canvas, "; $sql.= ", s.code_client"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; @@ -668,6 +701,8 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO $companystatic->name=$objp->name; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; $companystatic->canvas=$objp->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''."\n"; @@ -693,6 +728,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $langs->load("propal"); $sql = "SELECT s.nom as name, s.rowid, s.code_client"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; @@ -755,6 +792,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; @@ -798,6 +837,8 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; $sql.= ", s.code_client"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande as c"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -859,6 +900,8 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; From dbb7db376bc8c1b664b6360f46fea466944644ce Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 18 Feb 2020 09:16:12 +0100 Subject: [PATCH 07/18] fix error code --- htdocs/comm/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index c374120c8d2..6e14e565085 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -792,8 +792,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; @@ -900,8 +900,8 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; From d1e9f3a5050622fbca30dbcbfe3bae0427d8dace Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 18 Feb 2020 11:18:00 +0100 Subject: [PATCH 08/18] FIX keep assigned users in session when loading projects and tasks --- htdocs/comm/action/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c057dc2dee3..066d5cf8b7a 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -908,7 +908,7 @@ if ($action == 'create') $numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); print '   '.$langs->trans("AddProject").''; - $urloption='?action=create'; + $urloption = '?action=create&donotclearsession=1'; $url = dol_buildpath('comm/action/card.php', 2).$urloption; // update task list @@ -1325,7 +1325,7 @@ if ($id > 0) { print ''; - $urloption='?action=create'; // we use create not edit for more flexibility + $urloption = '?action=create&donotclearsession=1'; // we use create not edit for more flexibility $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption; // update task list From afadf9dc0e11ddf846a63a945964d2e32a91b026 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 18 Feb 2020 18:34:15 +0100 Subject: [PATCH 09/18] Fix Not Display Photo with Multicompany --- htdocs/societe/list.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index be4b0125698..3ad44f224da 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -10,6 +10,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2017 Juanjo Menent * Copyright (C) 2018 Nicolas ZABOURI + * * 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 @@ -371,6 +372,7 @@ if ($resql) else dol_print_error($db); $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,"; +$sql.= " s.entity,"; $sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; $sql.= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; $sql.= " s.tms as date_update, s.datec as date_creation,"; @@ -1003,6 +1005,7 @@ while ($i < min($num, $limit)) $companystatic->fk_prospectlevel=$obj->fk_prospectlevel; $companystatic->fk_parent = $obj->fk_parent; + $companystatic->entity = $obj->entity; print ' Date: Tue, 18 Feb 2020 17:36:00 +0000 Subject: [PATCH 10/18] Fixing style errors. --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3ad44f224da..c1fedf7cfe6 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -10,7 +10,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2017 Juanjo Menent * Copyright (C) 2018 Nicolas ZABOURI - + * * 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 From 016c7ad875c571e659e1bf9bd7719e3ae06b28f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 01:17:16 +0100 Subject: [PATCH 11/18] FIX #13135 --- htdocs/core/class/CMailFile.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index f794c76bcac..6127a7d6044 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -144,6 +144,9 @@ class CMailFile } } + // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; + $this->subject = $subject; $this->addr_to = $to; $this->addr_from = $from; @@ -268,9 +271,6 @@ class CMailFile } } - // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; - // We set all data according to choosed sending method. // We also set a value for ->msgid if ($this->sendmode == 'mail') From 43b173ef76e2873313b9becd5ec6aacb04546b24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 01:23:54 +0100 Subject: [PATCH 12/18] FIX #13131 --- htdocs/compta/facture/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 34134f49d79..2f1941ff836 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -101,6 +101,9 @@ $usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global- $object = new Facture($db); $extrafields = new ExtraFields($db); +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + // Load object if ($id > 0 || !empty($ref)) { if ($action != 'add') { @@ -138,6 +141,7 @@ $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isd + /* * Actions */ From 7c07589850526007767f8e93866b2356e7145265 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 03:07:12 +0100 Subject: [PATCH 13/18] FIX #13124 --- htdocs/core/class/html.form.class.php | 5 +- htdocs/core/lib/ajax.lib.php | 1 + htdocs/core/tpl/objectline_create.tpl.php | 68 ++++++++++++++--------- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 73e9ae0709b..83fd976f627 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2432,6 +2432,7 @@ class Form $outlabel = $objp->label; $outdesc = $objp->description; $outbarcode = $objp->barcode; + $outpbq = empty($objp->price_by_qty_rowid) ? '' : $objp->price_by_qty_rowid; $outtype = $objp->fk_product_type; $outdurationvalue = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; @@ -2479,7 +2480,7 @@ class Form $opt .= ($objp->rowid == $selected) ? ' selected' : ''; if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) { - $opt .= ' pbq="'.$objp->price_by_qty_rowid.'" data-pbq="'.$objp->price_by_qty_rowid.'" data-pbqqty="'.$objp->price_by_qty_quantity.'" data-pbqpercent="'.$objp->price_by_qty_remise_percent.'"'; + $opt .= ' pbq="'.$objp->price_by_qty_rowid.'" data-pbq="'.$objp->price_by_qty_rowid.'" data-pbqup="'.$objp->price_by_qty_unitprice.'" data-pbqbase="'.$objp->price_by_qty_price_base_type.'" data-pbqqty="'.$objp->price_by_qty_quantity.'" data-pbqpercent="'.$objp->price_by_qty_remise_percent.'"'; } if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { @@ -2665,7 +2666,7 @@ class Form } $opt .= "\n"; - $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit); + $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'pbq'=>$outpbq); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index d2626414ba6..a430a1612af 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -107,6 +107,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen } } }); + $("input#search_'.$htmlname.'").autocomplete({ source: function( request, response ) { $.get("'.$url.($urloption?'?'.$urloption:'').'", { '.$htmlname.': request.term }, function(data){ diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b60c48da09c..6fd135af821 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -541,6 +541,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) else if (npRate == "np_markRate") price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); } + $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value return true; @@ -552,26 +553,26 @@ if (!empty($usemargins) && $user->rights->margins->creer) /* JQuery for product free or predefined select */ jQuery(document).ready(function() { - jQuery("#price_ht").keyup(function(event) { - // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { - jQuery("#price_ttc").val(''); - jQuery("#multicurrency_subprice").val(''); - } + jQuery("#price_ht").keyup(function(event) { + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { + jQuery("#price_ttc").val(''); + jQuery("#multicurrency_subprice").val(''); + } }); jQuery("#price_ttc").keyup(function(event) { - // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { - jQuery("#price_ht").val(''); - jQuery("#multicurrency_subprice").val(''); - } + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { + jQuery("#price_ht").val(''); + jQuery("#multicurrency_subprice").val(''); + } }); jQuery("#multicurrency_subprice").keyup(function(event) { - // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { - jQuery("#price_ht").val(''); - jQuery("#price_ttc").val(''); - } + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { + jQuery("#price_ht").val(''); + jQuery("#price_ttc").val(''); + } }); $("#prod_entry_mode_free").on( "click", function() { @@ -630,15 +631,24 @@ if (!empty($usemargins) && $user->rights->margins->creer) if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT) && empty($senderissupplier)) { ?> - // Get the HT price for the product and display it - console.log("Load price without tax and set it into #price_ht"); - $.post('/product/ajax/products.php?action=fetch', - { 'id': $(this).val(), 'socid' : socid; ?> }, - function(data) { jQuery("#price_ht").val(data.price_ht); }, - 'json' - ); + var pbq = parseInt($('option:selected', this).attr('data-pbq')); + if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0) + { + console.log("We are in a price per qty context, we do not call ajax/product"); + } else { + // Get the HT price for the product and display it + console.log("Load price without tax and set it into #price_ht for id="+$(this).val()+" socid=socid; ?>"); + $.post('/product/ajax/products.php?action=fetch', + { 'id': $(this).val(), 'socid': socid; ?> }, + function(data) { + jQuery("#price_ht").val(data.price_ht); + }, + 'json' + ); + } rights->margins->creer) { $langs->load('stocks'); @@ -744,15 +754,20 @@ if (!empty($usemargins) && $user->rights->margins->creer) } ?> - /* To process customer price per quantity */ + /* To process customer price per quantity (CUSTOMER_PRICE_PER_QTY works only if combo product is not an ajax after x key pressed) */ var pbq = parseInt($('option:selected', this).attr('data-pbq')); + var pbqup = parseInt($('option:selected', this).attr('data-pbqup')); + var pbqbase = $('option:selected', this).attr('data-pbqbase'); var pbqqty = parseFloat($('option:selected', this).attr('data-pbqqty')); var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent')); - if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && typeof pbq !== "undefined") + if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0) { - console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent); + var pbqupht = pbqup; /* TODO support of price per qty TTC not yet available */ + + console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty upht = "+pbqupht+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent); jQuery("#pbq").val(pbq); + jQuery("#price_ht").val(pbqupht); if (jQuery("#qty").val() < pbqqty) { jQuery("#qty").val(pbqqty); @@ -809,7 +824,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) jQuery("#price_ht").val('').hide(); jQuery("#multicurrency_price_ht").val('').hide(); - jQuery("#price_ht").val(''); jQuery("#price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); jQuery("#buying_price").show(); From d0d352be1af0d6e4c76dd78c1e20e5b0800853a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 03:37:28 +0100 Subject: [PATCH 14/18] FIX #13118 --- htdocs/compta/paiement.php | 10 +++++++--- htdocs/fourn/facture/paiement.php | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 5b297eed309..b00ef1d9a0a 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -95,6 +95,8 @@ if (empty($reshook)) $totalpayment = 0; $multicurrency_totalpayment = 0; $atleastonepaymentnotnull = 0; + $formquestion = array(); + $i = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date $tmpinvoice = new Facture($db); @@ -214,7 +216,7 @@ if (empty($reshook)) { $error = 0; - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $db->begin(); @@ -260,8 +262,10 @@ if (empty($reshook)) $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); - $paiement->num_paiement = GETPOST('num_paiement', 'alpha'); - $paiement->note = GETPOST('comment', 'alpha'); + $paiement->num_payment = GETPOST('num_paiement', 'alpha'); + $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility + $paiement->note = $paiement->note_private; // For bacward compatibility if (!$error) { diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index e9198ebcc91..19fed7a3387 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -297,9 +297,13 @@ if (empty($reshook)) $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array of amounts $paiement->multicurrency_amounts = $multicurrency_amounts; - $paiement->paiementid = $_POST['paiementid']; - $paiement->num_paiement = $_POST['num_paiement']; - $paiement->note = $_POST['comment']; + $paiement->paiementid = GETPOST('paiementid', 'int'); + + $paiement->num_payment = GETPOST('num_paiement', 'alpha'); + $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility + $paiement->note = $paiement->note_private; // For bacward compatibility + if (!$error) { $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); From db1e324ba537923888d131840c540c9db3715355 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 13:58:04 +0100 Subject: [PATCH 15/18] Fix trans --- htdocs/langs/en_US/products.lang | 2 +- htdocs/langs/en_US/projects.lang | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index b9293b6187c..6f3994572c6 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -363,7 +363,7 @@ UsePercentageVariations=Use percentage variations PercentageVariation=Percentage variation ErrorDeletingGeneratedProducts=There was an error while trying to delete existing product variants NbOfDifferentValues=No. of different values -NbProducts=No. of products +NbProducts=Number of products ParentProduct=Parent product HideChildProducts=Hide variant products ShowChildProducts=Show variant products diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 55f70e68b21..9c1f5029604 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -39,8 +39,8 @@ ShowProject=Show project ShowTask=Show task SetProject=Set project NoProject=No project defined or owned -NbOfProjects=No. of projects -NbOfTasks=No. of tasks +NbOfProjects=Number of projects +NbOfTasks=Number of tasks TimeSpent=Time spent TimeSpentByYou=Time spent by you TimeSpentByUser=Time spent by user From 91899d2f56c18761a28bfe2dc11207d91d3ed2cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 14:31:32 +0100 Subject: [PATCH 16/18] Fix list of opportunity with filter on search_usage_opportunity --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 109de3a99c4..f66768b7ffb 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1683,11 +1683,11 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 1) { $newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list'); - $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode); + $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode); $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode); } elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only - $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99', $langs->trans("List"), 2, $showmode); + $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99', $langs->trans("List"), 2, $showmode); } $newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire); From 3fafbb372b39900adc7bb9a6bb9746f1f49199c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 15:51:27 +0100 Subject: [PATCH 17/18] Remove call of $mc->dao than hangs. Replaced with $mc use. --- htdocs/compta/accounting-files.php | 21 ++++++++++++++++----- htdocs/compta/bank/treso.php | 7 +++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index ac019de8088..b7d1cdd633e 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -77,7 +77,13 @@ if ($user->socid > 0) { accessforbidden(); } -$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; +$entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity)); +if (empty($entity) && ! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { + $tmparray = $mc->getEntitiesList(); + $entity = '0,'.join(',', array_keys($tmparray)); +} +if (empty($entity)) $entity = $conf->entity; + /* @@ -400,13 +406,18 @@ print ''; print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0); print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n"; -// Export is for current company only ! +// Export is for current company only if (!empty($conf->multicompany->enabled) && is_object($mc)) { + $mc->getInfo($conf->entity); print '('.$langs->trans("Entity").' : '; - $mc->dao->getEntities(); - $mc->dao->fetch($conf->entity); - print $mc->dao->label; + print ""; + if (! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { + print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true); + } else { + print $mc->label; + } + print ""; print ")\n"; } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 7ca62b67ab8..906ef09ac6b 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -286,11 +286,14 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) else print $langs->trans("NotDefined"); print ""; print "".$ref.""; - if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED ){ + if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { if($obj->family == 'invoice'){ $mc->getInfo($obj->entity); print "".$mc->label.""; - }else print ""; + } + else { + print ""; + } } print "".$refcomp.""; if ($obj->total_ttc < 0) { print ''.price(abs($total_ttc))." "; }; From 44c2909696c8197561f11d71f5cd25995e60a0c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 16:08:33 +0100 Subject: [PATCH 18/18] FIX Multicompany compatibility --- htdocs/compta/accounting-files.php | 41 ++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index b7d1cdd633e..af18b834edf 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -77,13 +77,22 @@ if ($user->socid > 0) { accessforbidden(); } +// Define $arrayofentities if multientity is set. +$arrayofentities = array(); +if (!empty($conf->multicompany->enabled) && is_object($mc)) { + $arrayofentities = $mc->getEntitiesList(); +} + $entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity)); -if (empty($entity) && ! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { - $tmparray = $mc->getEntitiesList(); - $entity = '0,'.join(',', array_keys($tmparray)); +if (!empty($conf->multicompany->enabled) && is_object($mc)) { + if (empty($entity) && ! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { + $entity = '0,'.join(',', array_keys($arrayofentities)); + } } if (empty($entity)) $entity = $conf->entity; +$error = 0; + /* @@ -114,42 +123,42 @@ if (($action == "searchfiles" || $action == "dl")) { $wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; // Customer invoices - $sql = "SELECT t.rowid as id, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql = "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; $sql .= " UNION ALL"; // Vendor invoices - $sql .= " SELECT t.rowid as id, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; $sql .= " UNION ALL"; // Expense reports - $sql .= " SELECT t.rowid as id, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE date_fin between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; $sql .= " UNION ALL"; // Donations - $sql .= " SELECT t.rowid as id, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; $sql .= " WHERE datedon between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; $sql .= " UNION ALL"; // Paiements of salaries - $sql .= " SELECT t.rowid as id, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; $sql .= " UNION ALL"; // Social contributions - $sql .= " SELECT t.rowid as id, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; $sql .= " WHERE date_creation between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -234,6 +243,7 @@ if (($action == "searchfiles" || $action == "dl")) { { $nofile = array(); $nofile['id'] = $objd->id; + $nofile['entity'] = $objd->entity; $nofile['date'] = $db->idate($objd->date); $nofile['paid'] = $objd->paid; $nofile['amount_ht'] = $objd->total_ht; @@ -254,6 +264,7 @@ if (($action == "searchfiles" || $action == "dl")) { foreach ($files as $key => $file) { $file['id'] = $objd->id; + $file['entity'] = $objd->entity; $file['date'] = $db->idate($objd->date); $file['paid'] = $objd->paid; $file['amount_ht'] = $objd->total_ht; @@ -320,6 +331,10 @@ if ($result && $action == "dl" && !$error) dol_mkdir($dirfortmpfile); $log = $langs->transnoentitiesnoconv("Type"); + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ','.$langs->transnoentitiesnoconv("Entity"); + } $log .= ','.$langs->transnoentitiesnoconv("Date"); $log .= ','.$langs->transnoentitiesnoconv("Ref"); $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); @@ -348,6 +363,10 @@ if ($result && $action == "dl" && !$error) } $log .= $file['item']; + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ','.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]); + } $log .= ','.dol_print_date($file['date'], 'dayrfc'); $log .= ','.$file['ref']; $log .= ','.$file['amount_ht']; @@ -389,11 +408,13 @@ $form = new Form($db); $userstatic = new User($db); $title = $langs->trans("ComptaFiles").' - '.$langs->trans("List"); +$help_url = ''; llxHeader('', $title, $help_url); $h = 0; -$head[$h][0] = $_SERVER["PHP_SELF"].$varlink; +$head = array(); +$head[$h][0] = $_SERVER["PHP_SELF"]; $head[$h][1] = $langs->trans("AccountantFiles"); $head[$h][2] = 'AccountancyFiles';