From 86e9398b796fb988a2f5479ad7f0237cab0aa4d3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 4 Feb 2021 09:05:58 +0100 Subject: [PATCH] no inner join --- htdocs/compta/facture/list.php | 4 ++-- htdocs/compta/facture/stats/index.php | 2 +- htdocs/core/class/html.formcompany.class.php | 2 +- htdocs/fourn/facture/list.php | 6 +++--- htdocs/install/mysql/data/llx_c_typent.sql | 1 - htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 4 ++++ htdocs/install/mysql/tables/llx_societe.sql | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index da5bab5b47e..ef34979d9ff 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -494,7 +494,7 @@ if ($search_town) $sql .= natural_search('s.town', $search_town); if ($search_zip) $sql .= natural_search("s.zip", $search_zip); if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')'; -if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; +if ($search_type_thirdparty != '' && $search_type_thirdparty != '-1') $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); if ($search_company_alias) $sql .= natural_search('s.name_alias', $search_company_alias); if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); @@ -894,7 +894,7 @@ if ($resql) if (!empty($arrayfields['typent.code']['checked'])) { print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100'); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100', '', 1); print ''; } // Payment mode diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 13378979932..e50edbeee18 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -264,7 +264,7 @@ print ''; // ThirdParty Type print ''.$langs->trans("ThirdPartyType").''; $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. -print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam_typent); +print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam_typent, '' , 1); if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index d9d0442e49e..b3e383ea762 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -1031,7 +1031,7 @@ class FormCompany extends Form $out .= ''; $out .= ''; $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. - $out .= $this->selectarray($htmlname, $this->typent_array(0, $filter), $selected, 0, 0, 0, '', 0, 0, 0, $sortparam, '', 1); + $out .= $this->selectarray($htmlname, $this->typent_array(0, $filter), $selected, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1); $out .= ''; $out .= ''; } else { diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index eef93849c8b..1188db2efd8 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -532,7 +532,7 @@ if ($search_town) $sql .= natural_search('s.town', $search_town); if ($search_zip) $sql .= natural_search("s.zip", $search_zip); if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; -if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; +if ($search_type_thirdparty != '' && $search_type_thirdparty >= 0) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_montant_ht != '') $sql .= natural_search('f.total_ht', $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search('f.total_tva', $search_montant_vat, 1); if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); @@ -917,7 +917,7 @@ if ($resql) if (!empty($arrayfields['typent.code']['checked'])) { print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),'', 1); print ''; } // Condition of payment @@ -1298,7 +1298,7 @@ if ($resql) if (!empty($arrayfields['typent.code']['checked'])) { print ''; - if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); + if (empty($typenArray)) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print ''; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/install/mysql/data/llx_c_typent.sql b/htdocs/install/mysql/data/llx_c_typent.sql index ef725f43d98..d55d8fc67c2 100644 --- a/htdocs/install/mysql/data/llx_c_typent.sql +++ b/htdocs/install/mysql/data/llx_c_typent.sql @@ -32,7 +32,6 @@ delete from llx_c_typent; -- Entries for all countries -insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 0, 'TE_UNKNOWN', '-', NULL, 1); insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 1, 'TE_STARTUP', 'Start-up', NULL, 0); insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 2, 'TE_GROUP', 'Grand groupe', NULL, 1); insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 3, 'TE_MEDIUM', 'PME/PMI', NULL, 1); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 287a568c646..85d2b91e9f9 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -119,3 +119,7 @@ ALTER TABLE llx_societe CHANGE fk_entrepot fk_warehouse INTEGER DEFAULT NULL; --ALTER TABLE llx_societe ADD CONSTRAINT fk_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid); ALTER TABLE llx_societe ADD INDEX idx_societe_warehouse(fk_warehouse); +ALTER TABLE llx_societe MODIFY COLUMN fk_typent integer DEFAULT NULL; +UPDATE llx_societe SET fk_typent=NULL WHERE fk_typent=0; +DELETE FROM llx_c_typent WHERE code='TE_UNKNOWN'; + diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 4459c7a1748..201114c7863 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -63,7 +63,7 @@ create table llx_societe whatsapp varchar(255), -- deprecated fk_effectif integer DEFAULT 0, -- - fk_typent integer DEFAULT 0, -- + fk_typent integer DEFAULT NULL, -- type ent fk_forme_juridique integer DEFAULT 0, -- juridical status fk_currency varchar(3), -- default currency siren varchar(128), -- IDProf1: depends on country (example: siren or RCS for france, ...)