From 282dc0177f4c811aa42e064dc0fcd232d47d3a4f Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 20 Jan 2020 09:45:07 +0100 Subject: [PATCH 01/68] NEW : Add French association chart of accounts 2018 --- .../install/mysql/data/llx_accounting_abc.sql | 2 + .../mysql/data/llx_accounting_account_fr.sql | 116 ++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/htdocs/install/mysql/data/llx_accounting_abc.sql b/htdocs/install/mysql/data/llx_accounting_abc.sql index 845b68e54a4..7fc9b066244 100644 --- a/htdocs/install/mysql/data/llx_accounting_abc.sql +++ b/htdocs/install/mysql/data/llx_accounting_abc.sql @@ -45,6 +45,8 @@ INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUE INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG99-BASE', 'The base accountancy french plan', 1); -- Description of chart of account FR PCG14-DEV INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG14-DEV', 'The developed accountancy french plan 2014', 1); +-- Description of chart of account FR PCG18-ASSOC +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG18-ASSOC', 'French association chart of accounts 2018', 1); -- Description of chart of account BE PCMN-BASE INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 2, 'PCMN-BASE', 'The base accountancy belgium plan', 1); diff --git a/htdocs/install/mysql/data/llx_accounting_account_fr.sql b/htdocs/install/mysql/data/llx_accounting_account_fr.sql index 0052cf86446..601a772901c 100644 --- a/htdocs/install/mysql/data/llx_accounting_account_fr.sql +++ b/htdocs/install/mysql/data/llx_accounting_account_fr.sql @@ -28,6 +28,7 @@ -- ID 0 - 438 -- ID 1501 - 5999 +-- ID -- ADD 100000 to rowid # Do no remove this comment -- INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 1401,'PCG99-ABREGE','CAPIT', 'XXXXXX', '1', '0', 'Fonds propres, provisions pour risques et charges et dettes à plus d''un an', 1); @@ -1466,3 +1467,118 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 5964,'PCG14-DEV','INCOME','XXXXXX','791',5963,'Transferts de charges d''exploitation','1'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 5965,'PCG14-DEV','INCOME','XXXXXX','796',5963,'Transferts de charges financières','1'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 5966,'PCG14-DEV','INCOME','XXXXXX','797',5963,'Transferts de charges exceptionnelles','1'); + +-- +-- Descriptif des plans comptables FR PCG18-ASSOC +-- + +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7201,'PCG18-ASSOC','CAPIT', 'CAPITAL', '1', '0', 'Fonds propres, emprunts et dettes assimilésFonds propres, provisions pour risques et charges et dettes à plus d''un an', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7202,'PCG18-ASSOC','IMMO', 'XXXXXX', '2', '0', 'Frais d''établissement. Actifs immobilisés et créances à plus d''un an', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7203,'PCG18-ASSOC','STOCK', 'XXXXXX', '3', '0', 'Stock et commandes en cours d''exécution', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7204,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '4', '0', 'Créances et dettes à un an au plus', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7205,'PCG18-ASSOC','FINAN', 'XXXXXX', '5', '0', 'Placement de trésorerie et de valeurs disponibles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7206,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '6', '0', 'Charges', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7207,'PCG18-ASSOC','INCOME', 'XXXXXX', '7', '0', 'Produits', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7208,'PCG18-ASSOC','SPECIAL', 'XXXXXX', '8', '0', 'Comptes spéciaux', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7000,'PCG18-ASSOC','CAPIT', 'XXXXXX', '10', '7201', 'Fonds propres et réserves', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7001,'PCG18-ASSOC','CAPIT', 'XXXXXX', '102', '7201', 'Fonds propres sans droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7002,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1021', '7201', 'Première situation nette établie', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7003,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1022', '7201', 'Fonds statutaires (à subdiviser en fonction des statuts)', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7004,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1023', '7201', 'Dotations non consomptibles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7005,'PCG18-ASSOC','CAPIT', 'XXXXXX','10231', '7201', 'Dotations non consomptibles initiales', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7006,'PCG18-ASSOC','CAPIT', 'XXXXXX','10232', '7201', 'Dotations non consomptibles complémentaires', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7007,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1024', '7201', 'Autres fonds propres sans droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7008,'PCG18-ASSOC','CAPIT', 'XXXXXX', '103', '7201', 'Fonds propres avec droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7009,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1032', '7201', 'Fonds statutaires (à subdiviser en fonction des statuts)', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7010,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1034', '7201', 'Autres fonds propres avec droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7011,'PCG18-ASSOC','CAPIT', 'XXXXXX', '105', '7201', 'Ecarts de réévaluation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7012,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1051', '7201', 'Ecarts de réévaluation sur des biens sans droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7013,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1052', '7201', 'Ecarts de réévaluation sur des biens avec droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7014,'PCG18-ASSOC','CAPIT', 'XXXXXX', '106', '7201', 'Réserves', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7015,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1068', '7201', 'Réserves pour projetde l’entité', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7016,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '206', '15', 'Droit au bail', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7017,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '207', '15', 'Fonds commercial', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7018,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '208', '15', 'Autres immobilisations incorporelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7019,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '21', '1402', 'Immobilisations corporelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7020,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '23', '1402', 'Immobilisations en cours', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7021,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '27', '1402', 'Autres immobilisations financieres', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7022,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '280', '1402', 'Amortissements des immobilisations incorporelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 24,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '281', '1402', 'Amortissements des immobilisations corporelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 25,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '290', '1402', 'Provisions pour dépréciation des immobilisations incorporelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 26,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '291', '1402', 'Provisions pour dépréciation des immobilisations corporelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 27,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '297', '1402', 'Provisions pour dépréciation des autres immobilisations financières', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 28,'PCG18-ASSOC','STOCK', 'XXXXXX', '31', '1403', 'Matieres premières', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 29,'PCG18-ASSOC','STOCK', 'XXXXXX', '32', '1403', 'Autres approvisionnements', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 30,'PCG18-ASSOC','STOCK', 'XXXXXX', '33', '1403', 'En-cours de production de biens', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 31,'PCG18-ASSOC','STOCK', 'XXXXXX', '34', '1403', 'En-cours de production de services', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 32,'PCG18-ASSOC','STOCK', 'XXXXXX', '35', '1403', 'Stocks de produits', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 33,'PCG18-ASSOC','STOCK', 'XXXXXX', '37', '1403', 'Stocks de marchandises', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 34,'PCG18-ASSOC','STOCK', 'XXXXXX', '391', '1403', 'Provisions pour dépréciation des matières premières', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 35,'PCG18-ASSOC','STOCK', 'XXXXXX', '392', '1403', 'Provisions pour dépréciation des autres approvisionnements', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 36,'PCG18-ASSOC','STOCK', 'XXXXXX', '393', '1403', 'Provisions pour dépréciation des en-cours de production de biens', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 37,'PCG18-ASSOC','STOCK', 'XXXXXX', '394', '1403', 'Provisions pour dépréciation des en-cours de production de services', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 38,'PCG18-ASSOC','STOCK', 'XXXXXX', '395', '1403', 'Provisions pour dépréciation des stocks de produits', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 39,'PCG18-ASSOC','STOCK', 'XXXXXX', '397', '1403', 'Provisions pour dépréciation des stocks de marchandises', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 40,'PCG18-ASSOC','THIRDPARTY', 'SUPPLIER', '400', '1404', 'Fournisseurs et Comptes rattachés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 41,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '409', '1404', 'Fournisseurs débiteurs', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 42,'PCG18-ASSOC','THIRDPARTY', 'CUSTOMER', '410', '1404', 'Clients et Comptes rattachés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 43,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '419', '1404', 'Clients créditeurs', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 44,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '421', '1404', 'Personnel', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 45,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '428', '1404', 'Personnel', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 46,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '43', '1404', 'Sécurité sociale et autres organismes sociaux', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 47,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '444', '1404', 'Etat - impôts sur bénéfice', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 48,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '445', '1404', 'Etat - Taxes sur chiffre affaires', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 49,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '447', '1404', 'Autres impôts, taxes et versements assimilés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 50,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '45', '1404', 'Groupe et associes', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 51,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '455', '50', 'Associés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 52,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '46', '1404', 'Débiteurs divers et créditeurs divers', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 53,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '47', '1404', 'Comptes transitoires ou d''attente', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 54,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '481', '1404', 'Charges à répartir sur plusieurs exercices', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 55,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '486', '1404', 'Charges constatées d''avance', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 56,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '487', '1404', 'Produits constatés d''avance', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 57,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '491', '1404', 'Provisions pour dépréciation des comptes de clients', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 58,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '496', '1404', 'Provisions pour dépréciation des comptes de débiteurs divers', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 59,'PCG18-ASSOC','FINAN', 'XXXXXX', '50', '1405', 'Valeurs mobilières de placement', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 60,'PCG18-ASSOC','FINAN', 'BANK', '51', '1405', 'Banques, établissements financiers et assimilés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 61,'PCG18-ASSOC','FINAN', 'CASH', '53', '1405', 'Caisse', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 62,'PCG18-ASSOC','FINAN', 'XXXXXX', '54', '1405', 'Régies d''avance et accréditifs', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 63,'PCG18-ASSOC','FINAN', 'XXXXXX', '58', '1405', 'Virements internes', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 64,'PCG18-ASSOC','FINAN', 'XXXXXX', '590', '1405', 'Provisions pour dépréciation des valeurs mobilières de placement', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 65,'PCG18-ASSOC','EXPENSE','PRODUCT', '60', '1406', 'Achats', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 66,'PCG18-ASSOC','EXPENSE','XXXXXX', '603', '65', 'Variations des stocks', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 67,'PCG18-ASSOC','EXPENSE','SERVICE', '61', '1406', 'Services extérieurs', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 68,'PCG18-ASSOC','EXPENSE','XXXXXX', '62', '1406', 'Autres services extérieurs', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 69,'PCG18-ASSOC','EXPENSE','XXXXXX', '63', '1406', 'Impôts, taxes et versements assimiles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 70,'PCG18-ASSOC','EXPENSE','SALARY', '641', '1406', 'Rémunérations du personnel', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 71,'PCG18-ASSOC','EXPENSE','SALARY', '644', '1406', 'Rémunération du travail de l''exploitant', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 72,'PCG18-ASSOC','EXPENSE','SOCIAL', '645', '1406', 'Charges de sécurité sociale et de prévoyance', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 73,'PCG18-ASSOC','EXPENSE','XXXXXX', '646', '1406', 'Cotisations sociales personnelles de l''exploitant', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 74,'PCG18-ASSOC','EXPENSE','XXXXXX', '65', '1406', 'Autres charges de gestion courante', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 75,'PCG18-ASSOC','EXPENSE','XXXXXX', '66', '1406', 'Charges financières', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 76,'PCG18-ASSOC','EXPENSE','XXXXXX', '67', '1406', 'Charges exceptionnelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 77,'PCG18-ASSOC','EXPENSE','XXXXXX', '681', '1406', 'Dotations aux amortissements et aux provisions', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 78,'PCG18-ASSOC','EXPENSE','XXXXXX', '686', '1406', 'Dotations aux amortissements et aux provisions', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 79,'PCG18-ASSOC','EXPENSE','XXXXXX', '687', '1406', 'Dotations aux amortissements et aux provisions', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 80,'PCG18-ASSOC','EXPENSE','XXXXXX', '691', '1406', 'Participation des salariés aux résultats', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 81,'PCG18-ASSOC','EXPENSE','TAX', '695', '1406', 'Impôts sur les bénéfices', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 82,'PCG18-ASSOC','EXPENSE','TAX', '697', '1406', 'Imposition forfaitaire annuelle des sociétés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 83,'PCG18-ASSOC','EXPENSE','XXXXXX', '699', '1406', 'Produits', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 84,'PCG18-ASSOC','INCOME', 'PRODUCT', '701', '1407', 'Ventes de produits finis', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 85,'PCG18-ASSOC','INCOME', 'SERVICE', '706', '1407', 'Prestations de services', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 86,'PCG18-ASSOC','INCOME', 'PRODUCT', '707', '1407', 'Ventes de marchandises', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 87,'PCG18-ASSOC','INCOME', 'SERVICE', '708', '1407', 'Produits des activités annexes', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 88,'PCG18-ASSOC','INCOME', 'XXXXXX', '709', '1407', 'Rabais, remises et ristournes accordés par l''entreprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 89,'PCG18-ASSOC','INCOME', 'XXXXXX', '713', '1407', 'Variation des stocks', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 90,'PCG18-ASSOC','INCOME', 'XXXXXX', '72', '1407', 'Production immobilisée', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 91,'PCG18-ASSOC','INCOME', 'XXXXXX', '73', '1407', 'Produits nets partiels sur opérations à long terme', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 92,'PCG18-ASSOC','INCOME', 'XXXXXX', '74', '1407', 'Subventions d''exploitation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 93,'PCG18-ASSOC','INCOME', 'XXXXXX', '75', '1407', 'Autres produits de gestion courante', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 94,'PCG18-ASSOC','INCOME', 'XXXXXX', '753', '93', 'Jetons de présence et rémunérations d''administrateurs, gérants,...', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 95,'PCG18-ASSOC','INCOME', 'XXXXXX', '754', '93', 'Ristournes perçues des coopératives', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 96,'PCG18-ASSOC','INCOME', 'XXXXXX', '755', '93', 'Quotes-parts de résultat sur opérations faites en commun', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 97,'PCG18-ASSOC','INCOME', 'FIN', '76', '1407', 'Produits financiers', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 98,'PCG18-ASSOC','INCOME', 'XXXXXX', '77', '1407', 'Produits exceptionnels', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 99,'PCG18-ASSOC','INCOME', 'XXXXXX', '781', '1407', 'Reprises sur amortissements et provisions', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 100,'PCG18-ASSOC','INCOME', 'XXXXXX', '786', '1407', 'Reprises sur provisions pour risques', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 101,'PCG18-ASSOC','INCOME', 'XXXXXX', '787', '1407', 'Reprises sur provisions', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 102,'PCG18-ASSOC','INCOME', 'XXXXXX', '79', '1407', 'Transferts de charges', 1); From e31a93929a0c26724bda4000571fbd4d2e18ee28 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 29 Jan 2020 14:01:48 +0100 Subject: [PATCH 02/68] FIX doc of dictionnary API --- htdocs/api/class/api_setup.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index a42888aad27..f5ed406a2a1 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -53,7 +53,7 @@ class Setup extends DolibarrApi * @param int $limit Number of items per page * @param int $page Page number {@min 0} * @param int $active Payment type is active or not {@min 0} {@max 1} - * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'CHQ')" + * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')" * * @url GET dictionary/ordering_methods * @@ -911,7 +911,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - public function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getPaymentTerms($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); From 314456f812b425f2b6162e6fa85784405b4f177b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jan 2020 13:03:33 +0100 Subject: [PATCH 03/68] Fix var not defined --- htdocs/resource/class/dolresource.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 4af42ea8ff2..bf9acde2d50 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -948,7 +948,7 @@ class Dolresource extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $langs; + global $conf, $langs; $result = ''; $label = ''.$langs->trans("ShowResource").''; From 8f2c87b0d4af8d557b881a13e6dc902ca624b807 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 30 Jan 2020 13:52:13 +0100 Subject: [PATCH 04/68] Update api_setup.class.php --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index f5ed406a2a1..66c4c1358cb 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -911,7 +911,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - public function getPaymentTerms($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); From 05d3c134dbf954eb23cb135120111849949cf8c8 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Thu, 30 Jan 2020 15:58:21 +0100 Subject: [PATCH 05/68] Add support of Number2Words module (v2) if the Number2Words Module is detected, this conversion is selected. --- htdocs/core/lib/functionsnumtoword.lib.php | 183 +++++++++++---------- 1 file changed, 98 insertions(+), 85 deletions(-) diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php index a20f1dcb99e..88032d1d096 100644 --- a/htdocs/core/lib/functionsnumtoword.lib.php +++ b/htdocs/core/lib/functionsnumtoword.lib.php @@ -44,94 +44,107 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false) if ($centimes && strlen($num) == 1) { $num = $num*10; } - $TNum = explode('.', $num); - $num = (int) $TNum[0]; - $words = array(); - $list1 = array( - '', - $langs->transnoentitiesnoconv('one'), - $langs->transnoentitiesnoconv('two'), - $langs->transnoentitiesnoconv('three'), - $langs->transnoentitiesnoconv('four'), - $langs->transnoentitiesnoconv('five'), - $langs->transnoentitiesnoconv('six'), - $langs->transnoentitiesnoconv('seven'), - $langs->transnoentitiesnoconv('eight'), - $langs->transnoentitiesnoconv('nine'), - $langs->transnoentitiesnoconv('ten'), - $langs->transnoentitiesnoconv('eleven'), - $langs->transnoentitiesnoconv('twelve'), - $langs->transnoentitiesnoconv('thirteen'), - $langs->transnoentitiesnoconv('fourteen'), - $langs->transnoentitiesnoconv('fifteen'), - $langs->transnoentitiesnoconv('sixteen'), - $langs->transnoentitiesnoconv('seventeen'), - $langs->transnoentitiesnoconv('eighteen'), - $langs->transnoentitiesnoconv('nineteen') - ); - $list2 = array( - '', - $langs->transnoentitiesnoconv('ten'), - $langs->transnoentitiesnoconv('twenty'), - $langs->transnoentitiesnoconv('thirty'), - $langs->transnoentitiesnoconv('forty'), - $langs->transnoentitiesnoconv('fifty'), - $langs->transnoentitiesnoconv('sixty'), - $langs->transnoentitiesnoconv('seventy'), - $langs->transnoentitiesnoconv('eighty'), - $langs->transnoentitiesnoconv('ninety'), - $langs->transnoentitiesnoconv('hundred') - ); - $list3 = array( - '', - $langs->transnoentitiesnoconv('thousand'), - $langs->transnoentitiesnoconv('million'), - $langs->transnoentitiesnoconv('billion'), - $langs->transnoentitiesnoconv('trillion'), - $langs->transnoentitiesnoconv('quadrillion') - ); + if (! empty($conf->global->MAIN_MODULE_NUMBERWORDS)) { + + if ($currency == true) { + $type = 1; + }else{ + $type = 0; + } - $num_length = strlen($num); - $levels = (int) (($num_length + 2) / 3); - $max_length = $levels * 3; - $num = substr('00' . $num, -$max_length); - $num_levels = str_split($num, 3); - $nboflevels = count($num_levels); - for ($i = 0; $i < $nboflevels; $i++) { - $levels--; - $hundreds = (int) ($num_levels[$i] / 100); - $hundreds = ($hundreds ? ' ' . $list1[$hundreds] . ' '.$langs->transnoentities('hundred') . ( $hundreds == 1 ? '' : 's' ) . ' ': ''); - $tens = (int) ($num_levels[$i] % 100); - $singles = ''; - if ( $tens < 20 ) { - $tens = ($tens ? ' ' . $list1[$tens] . ' ' : '' ); - } else { - $tens = (int) ($tens / 10); - $tens = ' ' . $list2[$tens] . ' '; - $singles = (int) ($num_levels[$i] % 10); - $singles = ' ' . $list1[$singles] . ' '; - } - $words[] = $hundreds . $tens . $singles . ( ( $levels && ( int ) ( $num_levels[$i] ) ) ? ' ' . $list3[$levels] . ' ' : '' ); - } //end for loop - $commas = count($words); - if ($commas > 1) { - $commas = $commas - 1; - } - $concatWords = implode(' ', $words); - // Delete multi whitespaces - $concatWords = trim(preg_replace('/[ ]+/', ' ', $concatWords)); + $concatWords = $langs->getLabelFromNumber($num, $type); + return $concatWords; - if(!empty($currency)) { - $concatWords .= ' '.$currency; + }else{ + $TNum = explode('.', $num); + $num = (int) $TNum[0]; + $words = array(); + $list1 = array( + '', + $langs->transnoentitiesnoconv('one'), + $langs->transnoentitiesnoconv('two'), + $langs->transnoentitiesnoconv('three'), + $langs->transnoentitiesnoconv('four'), + $langs->transnoentitiesnoconv('five'), + $langs->transnoentitiesnoconv('six'), + $langs->transnoentitiesnoconv('seven'), + $langs->transnoentitiesnoconv('eight'), + $langs->transnoentitiesnoconv('nine'), + $langs->transnoentitiesnoconv('ten'), + $langs->transnoentitiesnoconv('eleven'), + $langs->transnoentitiesnoconv('twelve'), + $langs->transnoentitiesnoconv('thirteen'), + $langs->transnoentitiesnoconv('fourteen'), + $langs->transnoentitiesnoconv('fifteen'), + $langs->transnoentitiesnoconv('sixteen'), + $langs->transnoentitiesnoconv('seventeen'), + $langs->transnoentitiesnoconv('eighteen'), + $langs->transnoentitiesnoconv('nineteen') + ); + $list2 = array( + '', + $langs->transnoentitiesnoconv('ten'), + $langs->transnoentitiesnoconv('twenty'), + $langs->transnoentitiesnoconv('thirty'), + $langs->transnoentitiesnoconv('forty'), + $langs->transnoentitiesnoconv('fifty'), + $langs->transnoentitiesnoconv('sixty'), + $langs->transnoentitiesnoconv('seventy'), + $langs->transnoentitiesnoconv('eighty'), + $langs->transnoentitiesnoconv('ninety'), + $langs->transnoentitiesnoconv('hundred') + ); + $list3 = array( + '', + $langs->transnoentitiesnoconv('thousand'), + $langs->transnoentitiesnoconv('million'), + $langs->transnoentitiesnoconv('billion'), + $langs->transnoentitiesnoconv('trillion'), + $langs->transnoentitiesnoconv('quadrillion') + ); + + $num_length = strlen($num); + $levels = (int) (($num_length + 2) / 3); + $max_length = $levels * 3; + $num = substr('00' . $num, -$max_length); + $num_levels = str_split($num, 3); + $nboflevels = count($num_levels); + for ($i = 0; $i < $nboflevels; $i++) { + $levels--; + $hundreds = (int) ($num_levels[$i] / 100); + $hundreds = ($hundreds ? ' ' . $list1[$hundreds] . ' '.$langs->transnoentities('hundred') . ( $hundreds == 1 ? '' : 's' ) . ' ': ''); + $tens = (int) ($num_levels[$i] % 100); + $singles = ''; + if ( $tens < 20 ) { + $tens = ($tens ? ' ' . $list1[$tens] . ' ' : '' ); + } else { + $tens = (int) ($tens / 10); + $tens = ' ' . $list2[$tens] . ' '; + $singles = (int) ($num_levels[$i] % 10); + $singles = ' ' . $list1[$singles] . ' '; + } + $words[] = $hundreds . $tens . $singles . ( ( $levels && ( int ) ( $num_levels[$i] ) ) ? ' ' . $list3[$levels] . ' ' : '' ); + } //end for loop + $commas = count($words); + if ($commas > 1) { + $commas = $commas - 1; + } + $concatWords = implode(' ', $words); + // Delete multi whitespaces + $concatWords = trim(preg_replace('/[ ]+/', ' ', $concatWords)); + + if(!empty($currency)) { + $concatWords .= ' '.$currency; + } + + // If we need to write cents call again this function for cents + if(!empty($TNum[1])) { + if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and'); + $concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true); + if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes'); + } + return $concatWords; } - - // If we need to write cents call again this function for cents - if(!empty($TNum[1])) { - if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and'); - $concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true); - if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes'); - } - return $concatWords; } From c58f76b15c2d42244f1399f886f521aaeadabba4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jan 2020 17:06:26 +0100 Subject: [PATCH 06/68] Fix constant name --- htdocs/core/lib/pdf.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 4be26bc4c50..e7538725bc2 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1388,7 +1388,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($libelleproduitservice) && !empty($ref_prodserv)) $ref_prodserv .= " - "; } - if (!empty($ref_prodserv) && !empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)) { $ref_prodserv = ''.$ref_prodserv.''; } + if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { $ref_prodserv = ''.$ref_prodserv.''; } $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; // Add an additional description for the category products @@ -1425,7 +1425,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; } //print '>'.$outputlangs->charset_output.','.$period; - if (!empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)) { + if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { $libelleproduitservice .= ''."__N__ ".$period.''; } else { $libelleproduitservice .= "__N__".$period; From 7b92aaa115533b7349cd1deb497f8ea479140987 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jan 2020 18:45:50 +0100 Subject: [PATCH 07/68] Fix templateResult into templateSelection --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 305a34d5036..d5a2fa1aae7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6552,7 +6552,7 @@ class Form templateResult: formatResult, /* For 4.0 */ // Specify format function for selected item formatSelection: formatSelection, - templateResult: formatSelection /* For 4.0 */ + templateSelection: formatSelection /* For 4.0 */ }); });'."\n"; } From b47e1bd8e8dff484795e27c1bc7d3a4d46cfdd7b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jan 2020 18:47:41 +0100 Subject: [PATCH 08/68] Fix protection when creating extrafield of type separator --- htdocs/core/class/extrafields.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index e4716947822..5d5540d77b8 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -208,7 +208,7 @@ class ExtraFields * * @param string $attrname Code of attribute * @param string $label label of attribute - * @param int $type Type of attribute ('boolean','int','varchar','text','html','date','datehour','price','phone','mail','password','url','select','checkbox','separate',...) + * @param string $type Type of attribute ('boolean','int','varchar','text','html','date','datehour','price','phone','mail','password','url','select','checkbox','separate',...) * @param int $pos Position of attribute * @param string $size Size/length definition of attribute ('5', '24,8', ...). For float, it contains 2 numeric separated with a comma. * @param string $elementtype Element type. Same value than object->table_element (Example 'member', 'product', 'thirdparty', ...) @@ -232,6 +232,7 @@ class ExtraFields if (empty($attrname)) return -1; if (empty($label)) return -1; + if ($type == 'separate') { $unique = 0; $required = 0; } // Force unique and not required if this is a separator field to avoid troubles. if ($elementtype == 'thirdparty') $elementtype = 'societe'; if ($elementtype == 'contact') $elementtype = 'socpeople'; From c0bf89929ff83de2f7c3c522087da31568ce64df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jan 2020 19:14:59 +0100 Subject: [PATCH 09/68] Code comment --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d5a2fa1aae7..725457b4bb5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6497,7 +6497,7 @@ class Form * @param int $translate Translate and encode value * @param int $width Force width of select box. May be used only when using jquery couch. Example: 250, 95% * @param string $moreattrib Add more options on select component. Example: 'disabled' - * @param string $elemtype Type of element we show ('category', ...) + * @param string $elemtype Type of element we show ('category', ...). Will execute a formating function on it. To use in readonly mode if js component support HTML formatting. * @param string $placeholder String to use as placeholder * @param int $addjscombo Add js combo * @return string HTML multiselect string From ea53e0b44e6a457c90496040f4d3fa4aa3c6ec90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jan 2020 20:00:41 +0100 Subject: [PATCH 10/68] Fix showoncombobox --- htdocs/contact/class/contact.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index e82ab7f1aea..f56d03ceeb3 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -72,8 +72,8 @@ class Contact extends CommonObject 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30, 'index'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>35), 'civility' =>array('type'=>'varchar(6)', 'label'=>'Civility', 'enabled'=>1, 'visible'=>-1, 'position'=>40), - 'lastname' =>array('type'=>'varchar(50)', 'label'=>'Lastname', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'firstname' =>array('type'=>'varchar(50)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'lastname' =>array('type'=>'varchar(50)', 'label'=>'Lastname', 'enabled'=>1, 'visible'=>-1, 'position'=>45, 'showoncombobox'=>1), + 'firstname' =>array('type'=>'varchar(50)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'showoncombobox'=>1), 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-1, 'position'=>55), 'zip' =>array('type'=>'varchar(25)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-1, 'position'=>60), 'town' =>array('type'=>'text', 'label'=>'Town', 'enabled'=>1, 'visible'=>-1, 'position'=>65), From d60ce8a2c3e318abb397b06da51146a6d89f5c08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jan 2020 20:00:41 +0100 Subject: [PATCH 11/68] Fix showoncombobox --- htdocs/contact/class/contact.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 038cb82845e..56ba2e24def 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -72,8 +72,8 @@ class Contact extends CommonObject 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30, 'index'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>35), 'civility' =>array('type'=>'varchar(6)', 'label'=>'Civility', 'enabled'=>1, 'visible'=>-1, 'position'=>40), - 'lastname' =>array('type'=>'varchar(50)', 'label'=>'Lastname', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'firstname' =>array('type'=>'varchar(50)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'lastname' =>array('type'=>'varchar(50)', 'label'=>'Lastname', 'enabled'=>1, 'visible'=>-1, 'position'=>45, 'showoncombobox'=>1), + 'firstname' =>array('type'=>'varchar(50)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'showoncombobox'=>1), 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-1, 'position'=>55), 'zip' =>array('type'=>'varchar(25)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-1, 'position'=>60), 'town' =>array('type'=>'text', 'label'=>'Town', 'enabled'=>1, 'visible'=>-1, 'position'=>65), From 51c6540a56baa78f3352cf672a88058551722188 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jan 2020 23:28:50 +0100 Subject: [PATCH 12/68] WIP Advanced search --- htdocs/core/class/html.form.class.php | 14 +++++++++++--- htdocs/langs/en_US/main.lang | 5 ++++- htdocs/theme/eldy/global.inc.php | 9 +++++++++ htdocs/theme/md/style.css.php | 9 +++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 725457b4bb5..38e18d24b8b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8040,11 +8040,19 @@ class Form */ public function searchComponent($arrayofcriterias, $search_component_params) { + global $conf, $langs; + $ret = ''; - - - + $ret .= '
'; + //$ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= $langs->trans("Filters"); + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= '
'; return $ret; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index de3ea66d682..c5c24372e06 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1015,4 +1015,7 @@ ContactAddedAutomatically=Contact added from contact thirdparty roles More=More ShowDetails=Show details CustomReports=Custom reports -SelectYourGraphOptionsFirst=Select your graph options to build a graph \ No newline at end of file +SelectYourGraphOptionsFirst=Select your graph options to build a graph +Measures=Measures +XAxis=X-Axis +YAxis=Y-Axis \ No newline at end of file diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 706cff9e46e..ae9c6cb6d65 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2573,6 +2573,15 @@ tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd border: 0px; } +.unsetcolor { + color: unset !important; +} +.nopaddingleft { + padding-: 0px; +} +.nopaddingright { + padding-: 0px; +} .notopnoleft { border-collapse: collapse; border: 0px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 68be6b84b0c..1baea54e815 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2749,6 +2749,15 @@ tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd border: 0px; } +.unsetcolor { + color: unset !important; +} +.nopaddingleft { + padding-: 0px; +} +.nopaddingright { + padding-: 0px; +} .notopnoleft { border-collapse: collapse; border: 0px; From a0d3370b8680ceede3ae8984fd5f9ce4898aa8b9 Mon Sep 17 00:00:00 2001 From: oscim Date: Fri, 31 Jan 2020 08:43:09 +0100 Subject: [PATCH 13/68] Update lettering.class.php add check colum date_validated IS NULL for block process lettering in fiscalyear is lasted validated --- htdocs/accountancy/class/lettering.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index ef63fc8b15f..2012efe0eb9 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -76,6 +76,7 @@ class Lettering extends BookKeeping $sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) "; $sql .= " AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) "; + $sql .= ' AND bk.date_validated IS NULL '; $sql .= $this->db->order('bk.doc_date', 'DESC'); // echo $sql; @@ -253,7 +254,7 @@ class Lettering extends BookKeeping } $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE "; - $sql .= " rowid IN (" . implode(',', $ids) . ") "; + $sql .= " rowid IN (" . implode(',', $ids) . ") AND date_validated IS NULL "; $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -275,7 +276,7 @@ class Lettering extends BookKeeping $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET"; $sql .= " lettering_code='" . $lettre . "'"; $sql .= " , date_lettering = '" . $this->db->idate($now) . "'"; // todo correct date it's false - $sql .= " WHERE rowid IN (" . implode(',', $ids) . ") "; + $sql .= " WHERE rowid IN (" . implode(',', $ids) . ") AND date_validated IS NULL "; $this->db->begin(); dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); From ed68ae0574272a8d4100993c7c380ecb7930085a Mon Sep 17 00:00:00 2001 From: oscim Date: Fri, 31 Jan 2020 08:50:41 +0100 Subject: [PATCH 14/68] Update thirdparty_lettering_supplier.php fix form in fiscalyear lasted validated --- .../accountancy/bookkeeping/thirdparty_lettering_supplier.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index 7eca182d630..867f5303ff8 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -144,7 +144,7 @@ dol_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; -$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code "; +$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; $sql .= " WHERE (bk.subledger_account = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . "' )"; if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { @@ -267,7 +267,7 @@ if ($resql) { $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); print '' . $journaltoshow . ''; - if (empty($obj->lettering_code)) { + if (empty($obj->lettering_code) && empty($obj->date_validated) ) { print ''; print ''; print img_edit(); From 1c24bcc7248fda053f60913e4e665d05c3e8d362 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 10:29:41 +0100 Subject: [PATCH 15/68] FIX CVE Need permission to be able to develop modules --- htdocs/core/modules/modModuleBuilder.class.php | 16 ++++++++++++++++ htdocs/modulebuilder/index.php | 3 +++ 2 files changed, 19 insertions(+) diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index 16ee16984d8..1c52ad866c2 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -45,6 +45,7 @@ class modModuleBuilder extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page $this->family = "technic"; + $this->module_position = '90'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "A RAD (Rapid Application Development) tool to help developers to build their own module."; @@ -82,6 +83,21 @@ class modModuleBuilder extends DolibarrModules //------ $this->boxes = array(); + // Permissions + //------------ + $this->rights = array(); // Permission array used by this module + $this->rights_class = 'modulebuilder'; + + $r=0; + + $r++; + $this->rights[$r][0] = 3301; + $this->rights[$r][1] = 'Generate new modules'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'run'; + + // Main menu entries //------------------ $this->menu = array(); diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 51e35ab050a..0afcd403406 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -90,6 +90,9 @@ if (empty($newmask)) // This should no happen $newmask = '0664'; } +$result = restrictedArea($user, 'modulebuilder', null); + + /* * Actions From ae14814f108bb85ba28cb05da23205889b8c80f3 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 22 Jan 2020 15:27:50 +0100 Subject: [PATCH 16/68] NEW visu FROM day TO day in permonth view --- htdocs/core/lib/date.lib.php | 64 +++ htdocs/projet/activity/permonth.php | 656 ++++++++++++++++++++++++++++ 2 files changed, 720 insertions(+) create mode 100644 htdocs/projet/activity/permonth.php diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 8fb32bb2f37..2694747f52d 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -961,3 +961,67 @@ function monthArray($outputlangs, $short = 0) return $montharray; } +/** + * Return array of week numbers. + + * + * @param int $month Month number + * @param int $year Year number + * @return array Week numbers + */ + +function getWeekNumbersOfMonth($month, $year) { + $nb_days = cal_days_in_month(CAL_GREGORIAN,$month, $year); + $TWeek = array(); + for($day = 1; $day < $nb_days; $day++) { + $week_number = getWeekNumber($day, $month, $year); + $TWeek[$week_number] = $week_number; + } + return $TWeek; +} +/** + * Return array of first day of weeks. + + * + * @param array $TWeek array of week numbers + * @param int $year Year number + * @return array First day of week + */ +function getFirstDayOfEachWeek($TWeek, $year) { + $TFirstDayOfWeek = array(); + foreach($TWeek as $weekNb) { + if(in_array('01',$TWeek) && in_array('52',$TWeek) && $weekNb == '01') $year++;//Si on a la 1re semaine et la semaine 52 c'est qu'on change d'année + $TFirstDayOfWeek[$weekNb] = date('d',strtotime($year.'W'.$weekNb)); + } + return $TFirstDayOfWeek; +} +/** + * Return array of last day of weeks. + + * + * @param array $TWeek array of week numbers + * @param int $year Year number + * @return array Last day of week + */ +function getLastDayOfEachWeek($TWeek, $year) { + $TLastDayOfWeek = array(); + foreach($TWeek as $weekNb) { + $TLastDayOfWeek[$weekNb] = date('d',strtotime($year.'W'.$weekNb.'+6 days')); + } + return $TLastDayOfWeek; +} +/** + * Return week number. + + * + * @param int $day Day number + * @param int $month Month number + * @param int $year Year number + * @return int Week number + */ + +function getWeekNumber($day, $month, $year) { + $date = new DateTime($year.'-'.$month.'-'.$day); + $week = $date->format("W"); + return $week; +} diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php new file mode 100644 index 00000000000..e35a47551b1 --- /dev/null +++ b/htdocs/projet/activity/permonth.php @@ -0,0 +1,656 @@ + + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2010 François Legastelois + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/projet/activity/permonth.php + * \ingroup projet + * \brief List activities of tasks (per week entry) + */ + +require "../../main.inc.php"; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('projects','users','companies')); +$hookmanager->initHooks(array('timesheetpermonthcard')); + +$action=GETPOST('action','aZ09'); +$mode=GETPOST("mode",'alpha'); +$id=GETPOST('id','int'); +$taskid=GETPOST('taskid','int'); + +$mine=0; +if ($mode == 'mine') $mine=1; + +$projectid=''; +$projectid=isset($_GET["id"])?$_GET["id"]:$_POST["projectid"]; + +// Security check +$socid=0; +// For external user, no check is done on company because readability is managed by public status of project and assignement. +// if ($user->societe_id > 0) $socid=$user->societe_id; +$result = restrictedArea($user, 'projet', $projectid); + +$now=dol_now(); +$nowtmp=dol_getdate($now); +$nowday=$nowtmp['mday']; +$nowmonth=$nowtmp['mon']; +$nowyear=$nowtmp['year']; + +$year=GETPOST('reyear')?GETPOST('reyear','int'):(GETPOST("year")?GETPOST("year","int"):date("Y")); +$month=GETPOST('remonth')?GETPOST('remonth','int'):(GETPOST("month")?GETPOST("month","int"):date("m")); +$day=GETPOST('reday')?GETPOST('reday','int'):(GETPOST("day")?GETPOST("day","int"):date("d")); +$day = (int) $day; +$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); + +$search_categ=GETPOST("search_categ",'alpha'); +$search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); +$search_task_ref=GETPOST('search_task_ref', 'alpha'); +$search_task_label=GETPOST('search_task_label', 'alpha'); +$search_project_ref=GETPOST('search_project_ref', 'alpha'); +$search_thirdparty=GETPOST('search_thirdparty', 'alpha'); +$search_declared_progress=GETPOST('search_declared_progress', 'alpha'); + +$startdayarray=dol_get_prev_month($month, $year); + +$prev = $startdayarray; +$prev_year = $prev['year']; +$prev_month = $prev['month']; +$prev_day = 1; + +$next = dol_get_next_month($month, $year); +$next_year = $next['year']; +$next_month = $next['month']; +$next_day = 1; +$TWeek = getWeekNumbersOfMonth($month, $year); +$firstdaytoshow = dol_mktime(0,0,0,$month,1,$year); +$TFirstDays = getFirstDayOfEachWeek($TWeek, $year); +$TFirstDays[reset($TWeek)] = '01'; //first day of month +$TLastDays = getLastDayOfEachWeek($TWeek, $year); +$TLastDays[end($TWeek)] = date("t", strtotime($year.'-'.$month.'-'.$day)); //last day of month +if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) +{ + $usertoprocess=$user; + $search_usertoprocessid=$usertoprocess->id; +} +elseif ($search_usertoprocessid > 0) +{ + $usertoprocess=new User($db); + $usertoprocess->fetch($search_usertoprocessid); + $search_usertoprocessid=$usertoprocess->id; +} +else +{ + $usertoprocess=new User($db); +} + +$object=new Task($db); + + +/* + * Actions + */ +$parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid, 'TWeek' => $TWeek, 'TFirstDays' => $TFirstDays, 'TLastDays' => $TLastDays); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +// Purge criteria +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers +{ + $action = ''; + $search_categ=''; + $search_usertoprocessid = $user->id; + $search_task_ref = ''; + $search_task_label = ''; + $search_project_ref = ''; + $search_thirdparty = ''; + $search_declared_progress = ''; +} +if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha')) +{ + $action = ''; +} + +if (GETPOST('submitdateselect')) +{ + $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + + $action = ''; +} +if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')) +{ + $action = 'assigntask'; + + if ($taskid > 0) + { + $result = $object->fetch($taskid, $ref); + if ($result < 0) $error++; + } + else + { + setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors'); + $error++; + } + if (! GETPOST('type')) + { + setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); + $error++; + } + + if (! $error) + { + $idfortaskuser=$usertoprocess->id; + $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); + + if ($result >= 0 || $result == -2) // Contact add ok or already contact of task + { + // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) + $sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; + $sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + if (! $obj) // User is not already linked to project, so we will create link to first type + { + $project = new Project($db); + $project->fetch($object->fk_project); + // Get type + $listofprojcontact=$project->liste_type_contact('internal'); + + if (count($listofprojcontact)) + { + $typeforprojectcontact=reset(array_keys($listofprojcontact)); + $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal'); + } + } + } + else + { + dol_print_error($db); + } + } + } + + if ($result < 0) + { + $error++; + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorTaskAlreadyAssigned"), null, 'warnings'); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if (! $error) + { + setEventMessages("TaskAssignedToEnterTime", null); + $taskid=0; + } + + $action=''; +} + +if ($action == 'addtime' && $user->rights->projet->lire) +{ + $timetoadd=$_POST['task']; + if (empty($timetoadd)) + { + setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); + } + else + { + + foreach($timetoadd as $taskid => $value) // Loop on each task + { + $updateoftaskdone=0; + foreach($value as $key => $val) // Loop on each day + { + $amountoadd=$timetoadd[$taskid][$key]; + if (! empty($amountoadd)) + { + $tmpduration=explode(':',$amountoadd); + $newduration=0; + if (! empty($tmpduration[0])) $newduration+=($tmpduration[0] * 3600); + if (! empty($tmpduration[1])) $newduration+=($tmpduration[1] * 60); + if (! empty($tmpduration[2])) $newduration+=($tmpduration[2]); + + if ($newduration > 0) + { + $object->fetch($taskid); + $object->progress = GETPOST($taskid . 'progress', 'int'); + $object->timespent_duration = $newduration; + $object->timespent_fk_user = $usertoprocess->id; + $object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd'); + $object->timespent_datehour = $object->timespent_date; + + $result=$object->addTimeSpent($user); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } + + $updateoftaskdone++; + } + } + } + + if (! $updateoftaskdone) // Check to update progress if no update were done on task. + { + $object->fetch($taskid); + //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit; + if ($object->progress != GETPOST($taskid . 'progress', 'int')) + { + $object->progress = GETPOST($taskid . 'progress', 'int'); + $result=$object->update($user); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } + } + } + } + + if (! $error) + { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + + $param=''; + $param.=($mode?'&mode='.$mode:''); + $param.=($projectid?'id='.$projectid:''); + $param.=($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:''); + $param.=($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:''); + $param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); + $param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.$search_usertoprocessid:''); + $param.=($search_thirdparty?'&search_thirdparty='.$search_thirdparty:''); + $param.=($search_declared_progress?'&search_declared_progress='.$search_declared_progress:''); + $param.=($search_task_ref?'&search_task_ref='.$search_task_ref:''); + $param.=($search_task_label?'&search_task_label='.$search_task_label:''); + + // Redirect to avoid submit twice on back + header('Location: '.$_SERVER["PHP_SELF"].'?'.$param); + exit; + } + } +} + + + +/* + * View + */ + +$form=new Form($db); +$formother=new FormOther($db); +$formcompany=new FormCompany($db); +$formproject=new FormProjets($db); +$projectstatic=new Project($db); +$project = new Project($db); +$taskstatic = new Task($db); +$thirdpartystatic = new Societe($db); +$holiday = new Holiday($db); + +$title=$langs->trans("TimeSpent"); + +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,(empty($usertoprocess->id)?2:0),1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project +//var_dump($projectsListId); +if ($id) +{ + $project->fetch($id); + $project->fetch_thirdparty(); +} + +$onlyopenedproject=1; // or -1 +$morewherefilter=''; + +if ($search_project_ref) $morewherefilter.=natural_search(array("p.ref", "p.title"), $search_project_ref); +if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); +if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label"), $search_task_label); +if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); +if ($search_declared_progress) $morewherefilter.=natural_search("t.progress", $search_declared_progress, 1); + +$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks +{ + $tasksarraywithoutfilter=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +} +$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); +$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); +//var_dump($tasksarray); +//var_dump($projectsrole); +//var_dump($taskrole); + + +llxHeader("",$title,"",'','','',array('/core/js/timesheet.js')); + +//print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); + +$param=''; +$param.=($mode?'&mode='.$mode:''); +$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); +$param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.$search_usertoprocessid:''); +$param.=($search_thirdparty?'&search_thirdparty='.$search_thirdparty:''); +$param.=($search_task_ref?'&search_task_ref='.$search_task_ref:''); +$param.=($search_task_label?'&search_task_label='.$search_task_label:''); + +// Show navigation bar +$nav =''.img_previous($langs->trans("Previous"))."\n"; +$nav.=" ".dol_print_date(dol_mktime(0,0,0,$month,1,$year),"%Y").", ".$langs->trans(date('F', mktime(0, 0, 0, $month, 10)))." \n"; +$nav.=''.img_next($langs->trans("Next"))."\n"; +$nav.="   (".$langs->trans("Today").")"; +$nav.='
'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' '; +$nav.=' '; + +$picto='calendarweek'; + +print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$head=project_timesheet_prepare_head($mode, $usertoprocess); +dol_fiche_head($head, 'inputpermonth', $langs->trans('TimeSpent'), -1, 'task'); + +// Show description of content +print '
'; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; +else +{ + if (empty($usertoprocess->id) || $usertoprocess->id < 0) + { + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + } +} +if ($mine || ($usertoprocess->id == $user->id)) +{ + print $langs->trans("OnlyYourTaskAreVisible").'
'; +} +else +{ + print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").'
'; +} +print '
'; + +dol_fiche_end(); + +print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. + +print '
'; +$titleassigntask = $langs->transnoentities("AssignTaskToMe"); +if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); +print '
'; +$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); +print '
'; +print ' '; +print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth150onsmartphone'); +print ''; +print '
'; + +print '
'; + + +$moreforfilter=''; + +// Filter on categories +/* +if (! empty($conf->categorie->enabled)) +{ + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('ProjectCategories'). ': '; + $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300'); + $moreforfilter.='
'; +}*/ + +// If the user can view user other than himself +$moreforfilter.='
'; +$moreforfilter.='
'.$langs->trans('User'). '
'; +$includeonly='hierachyme'; +if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); +$moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter.='
'; + +if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) +{ + $moreforfilter.='
'; + $moreforfilter.='
'.$langs->trans('Project'). '
'; + $moreforfilter.=''; + $moreforfilter.='
'; + + $moreforfilter.='
'; + $moreforfilter.='
'.$langs->trans('ThirdParty'). '
'; + $moreforfilter.=''; + $moreforfilter.='
'; +} + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; +} + +print '
'; + +print ''."\n"; + +print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +for ($idw=0;$idw'; +} +// Action column +print ''; +print "\n"; + +print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +print ''; +print ''; +print ''; +/*print ''; + if ($usertoprocess->id == $user->id) print ''; + else print '';*/ +print ''; +print ''; + +foreach ($TWeek as $week_number) +{ + print ''; +} +print ''; +print "\n"; + +$colspan=5; + +// By default, we can edit only tasks we are assigned to +$restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0); + +if (count($tasksarray) > 0) +{ + //var_dump($tasksarray); // contains only selected tasks + //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter) + //var_dump($tasksrole); + + $j=0; + $level=0; + $totalforvisibletasks = projectLinesPerMonth($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $TWeek); + //var_dump($totalforvisibletasks); + + // Show total for all other tasks + + // Calculate total for all tasks + $listofdistinctprojectid=array(); // List of all distinct projects + if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) + { + foreach($tasksarraywithoutfilter as $tmptask) + { + $listofdistinctprojectid[$tmptask->fk_project]=$tmptask->fk_project; + } + } + //var_dump($listofdistinctprojectid); + $totalforeachweek=array(); + foreach($listofdistinctprojectid as $tmpprojectid) + { + $projectstatic->id=$tmpprojectid; + $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week + foreach($TWeek as $weekNb) + { + $totalforeachweek[$weekNb]+=$projectstatic->monthWorkLoad[$weekNb]; + } + } + + //var_dump($totalforeachday); + //var_dump($totalforvisibletasks); + + // Is there a diff between selected/filtered tasks and all tasks ? + $isdiff = 0; + if (count($totalforeachweek)) + { + foreach($TWeek as $weekNb) + { + + $timeonothertasks=($totalforeachweek[$weekNb] - $totalforvisibletasks[$weekNb]); + if ($timeonothertasks) + { + $isdiff=1; + break; + } + } + } + + // There is a diff between total shown on screen and total spent by user, so we add a line with all other cumulated time of user + if ($isdiff) + { + print ''; + print ''; + foreach ($TWeek as $weekNb) + { + print ''; + } + print ' '; + print ''; + } + + if ($conf->use_javascript_ajax) + { + print ' + '; + + foreach ($TWeek as $weekNb) + { + print ''; + } + print ' + '; + } +} +else +{ + print ''; +} +print "
'; +$searchpicto=$form->showFilterAndCheckAddButtons(0); +print $searchpicto; +print '
'.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Task").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')
'.$langs->trans("TimeSpent").($usertoprocess->firstname?'
('.$usertoprocess->firstname.')':'').'
'.$langs->trans("Week").'
'.$week_number.'
('.$langs->trans('From').' '.$TFirstDays[$week_number].' '.$langs->trans('to').' '.$TLastDays[$week_number].')
'; + print $langs->trans("OtherFilteredTasks"); + print ''; + + $timeonothertasks=($totalforeachweek[$weekNb] - $totalforvisibletasks[$weekNb]); + if ($timeonothertasks) + { + print ''; + } + print '
'; + print $langs->trans("Total"); + print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; + print '
'. convertSecondToTime($totalforvisibletasks[$weekNb],'allhourmin').'
 
'.$langs->trans("NoAssignedTasks").'
"; +print '
'; + +print ''."\n"; + +print '
'; +print ''; +print '
'; + +print '
'."\n\n"; + +$modeinput='hours'; + +if ($conf->use_javascript_ajax) +{ + print "\n\n"; + print ''; +} + + +llxFooter(); + +$db->close(); From a001913751ac6a915412e51b2cd967f6e22ace0f Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 21 Nov 2019 17:05:06 +0100 Subject: [PATCH 17/68] Debut modification saisie par mois NEW hook and data id NEW visu FROM day TO day in permonth view FIX --- htdocs/core/lib/date.lib.php | 9 +- htdocs/core/lib/project.lib.php | 277 +++++++++++++++++++++++++- htdocs/langs/en_US/projects.lang | 2 + htdocs/langs/fr_FR/projects.lang | 2 + htdocs/projet/activity/perday.php | 4 +- htdocs/projet/activity/perweek.php | 4 +- htdocs/projet/class/project.class.php | 66 ++++++ 7 files changed, 355 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 2694747f52d..b604ea831b1 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -963,7 +963,7 @@ function monthArray($outputlangs, $short = 0) } /** * Return array of week numbers. - + * * @param int $month Month number * @param int $year Year number @@ -981,7 +981,7 @@ function getWeekNumbersOfMonth($month, $year) { } /** * Return array of first day of weeks. - + * * @param array $TWeek array of week numbers * @param int $year Year number @@ -997,7 +997,7 @@ function getFirstDayOfEachWeek($TWeek, $year) { } /** * Return array of last day of weeks. - + * * @param array $TWeek array of week numbers * @param int $year Year number @@ -1012,14 +1012,13 @@ function getLastDayOfEachWeek($TWeek, $year) { } /** * Return week number. - + * * @param int $day Day number * @param int $month Month number * @param int $year Year number * @return int Week number */ - function getWeekNumber($day, $month, $year) { $date = new DateTime($year.'-'.$month.'-'.$day); $week = $date->format("W"); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 9842f5357b4..e2f08e7c092 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -263,6 +263,14 @@ function project_timesheet_prepare_head($mode, $fuser = null) $param .= ($mode ? '&mode='.$mode : ''); if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id; + if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH)) + { + $head[$h][0] = DOL_URL_ROOT."/projet/activity/permonth.php".($param?'?'.$param:''); + $head[$h][1] = $langs->trans("InputPerMonth"); + $head[$h][2] = 'inputpermonth'; + $h++; + } + if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) { $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : ''); @@ -1141,7 +1149,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; - print ''."\n"; + print ''."\n"; // User /* @@ -1520,7 +1528,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; - print ''."\n"; + print ''."\n"; // User /* @@ -1704,6 +1712,271 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ return $totalforeachday; } +/** + * Output a task line into a perday intput mode + * + * @param string $inc Line output identificator (start to 0, then increased by recursive call) + * @param int $firstdaytoshow First day to show + * @param User|null $fuser Restrict list to user if defined + * @param string $parent Id of parent task to show (0 to show all) + * @param Task[] $lines Array of lines (list of tasks but we will show only if we have a specific role on task) + * @param int $level Level (start to 0, then increased/decrease by recursive call) + * @param string $projectsrole Array of roles user has on project + * @param string $tasksrole Array of roles user has on task + * @param string $mine Show only task lines I am assigned to + * @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to + * @param array $isavailable Array with data that say if user is available for several days for morning and afternoon + * @param int $oldprojectforbreak Old project id of last project break + * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks + */ +function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0, $TWeek=array()) +{ + global $conf, $db, $user, $bc, $langs; + global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; + + $numlines=count($lines); + + $lastprojectid=0; + $workloadforid=array(); + $totalforeachweek=array(); + $lineswithoutlevel0=array(); + + // Create a smaller array with sublevels only to be used later. This increase dramatically performances. + if ($parent == 0) // Always and only if at first level + { + for ($i = 0 ; $i < $numlines ; $i++) + { + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; + } + } + + //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); + + if (empty($oldprojectforbreak)) + { + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 = start break, -1 = never break + } + + for ($i = 0 ; $i < $numlines ; $i++) + { + if ($parent == 0) $level = 0; + + if ($lines[$i]->fk_task_parent == $parent) + { + // If we want all or we have a role on task, we show it + if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) + { + //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); + + // Break on a new project + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) + { + $lastprojectid=$lines[$i]->fk_project; + $projectstatic->id = $lines[$i]->fk_project; + } + + //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); + //var_dump($projectstatic->weekWorkLoadPerTask); + if (empty($workloadforid[$projectstatic->id])) + { + $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week + $workloadforid[$projectstatic->id]=1; + } + //var_dump($projectstatic->weekWorkLoadPerTask); + //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); + + $projectstatic->id=$lines[$i]->fk_project; + $projectstatic->ref=$lines[$i]->projectref; + $projectstatic->title=$lines[$i]->projectlabel; + $projectstatic->public=$lines[$i]->public; + $projectstatic->thirdparty_name=$lines[$i]->thirdparty_name; + + $taskstatic->id=$lines[$i]->id; + $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); + $taskstatic->label=$lines[$i]->label; + $taskstatic->date_start=$lines[$i]->date_start; + $taskstatic->date_end=$lines[$i]->date_end; + + $thirdpartystatic->id=$lines[$i]->thirdparty_id; + $thirdpartystatic->name=$lines[$i]->thirdparty_name; + $thirdpartystatic->email=$lines[$i]->thirdparty_email; + + if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) + { + print ''."\n"; + print ''; + print $projectstatic->getNomUrl(1,'',0,''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); + if ($projectstatic->title) + { + print ' - '; + print $projectstatic->title; + } + print ''; + print ''; + } + + if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; + print ''."\n"; + + // User + /* + print ''; + print $fuser->getNomUrl(1, 'withproject', 'time'); + print ''; + */ + + // Project + /*print ''; + if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + print "";*/ + + // Thirdparty + /*print ''; + if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project'); + print '';*/ + + // Ref + print ''; + print ''; + for ($k = 0 ; $k < $level ; $k++) print "   "; + print $taskstatic->getNomUrl(1, 'withproject', 'time'); + // Label task + print '
'; + for ($k = 0 ; $k < $level ; $k++) print "   "; + //print $taskstatic->getNomUrl(0, 'withproject', 'time'); + print $taskstatic->label; + //print "
"; + //for ($k = 0 ; $k < $level ; $k++) print "   "; + //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); + print "\n"; + + // Planned Workload + print ''; + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); + else print '--:--'; + print ''; + + // Progress declared % + print ''; + print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); + print ''; + + // Time spent by everybody + print ''; + // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user + if ($lines[$i]->duration) + { + print ''; + print convertSecondToTime($lines[$i]->duration,'allhourmin'); + print ''; + } + else print '--:--'; + print "\n"; + + // Time spent by user + print ''; + $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); + else print '--:--'; + print "\n"; + + $disabledproject=1;$disabledtask=1; + //print "x".$lines[$i]->fk_project; + //var_dump($lines[$i]); + //var_dump($projectsrole[$lines[$i]->fk_project]); + // If at least one role for project + if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) + { + $disabledproject=0; + $disabledtask=0; + } + // If $restricteditformytask is on and I have no role on task, i disable edit + if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) + { + $disabledtask=1; + } + + //var_dump($projectstatic->weekWorkLoadPerTask); + //TODO + // Fields to show current time + $tableCell=''; $modeinput='hours'; + $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y',$firstdaytoshow)); + $TFirstDay[reset($TWeek)] = 1; + foreach($TFirstDay as &$fday) { + $fday--; + } + foreach ($TWeek as $weekNb) + { + + $weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]; + $totalforeachweek[$weekNb]+=$weekWorkLoad; + + $alreadyspent=''; + if ($weekWorkLoad > 0) $alreadyspent=convertSecondToTime($weekWorkLoad,'allhourmin'); + $alttitle=$langs->trans("AddHereTimeSpentForWeek",$weekNb); + + + $tableCell =''; + $placeholder=''; + if ($alreadyspent) + { + $tableCell.=''; + //$placeholder=' placeholder="00:00"'; + //$tableCell.='+'; + } + + $tableCell.=''; + $tableCell.=''; + print $tableCell; + } + + // Warning + print ''; + if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); + else if ($disabledtask) + { + $titleassigntask = $langs->trans("AssignTaskToMe"); + if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); + + print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); + } + print ''; + + print "\n"; + } + + // Call to show task with a lower level (task under the current task) + $inc++; + $level++; + if ($lines[$i]->id > 0) + { + //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level); + //var_dump($totalforeachday); + $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek); + //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); + //var_dump($ret); + foreach($ret as $key => $val) + { + $totalforeachweek[$key]+=$val; + } + //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); + //var_dump($totalforeachday); + } + $level--; + } + else + { + //$level--; + } + } + + return $totalforeachweek; +} + /** * Search in task lines with a particular parent if there is a task for a particular user (in taskrole) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 0f9c1d8f1b3..14d0e9d2b19 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -69,6 +69,7 @@ NewTask=New task AddTask=Create task AddTimeSpent=Create time spent AddHereTimeSpentForDay=Add here time spent for this day/task +AddHereTimeSpentForWeek=Add here time spent for this week/task Activity=Activity Activities=Tasks/activities MyActivities=My tasks/activities @@ -187,6 +188,7 @@ ProjectMustBeValidatedFirst=Project must be validated first FirstAddRessourceToAllocateTime=Assign a user resource to task to allocate time InputPerDay=Input per day InputPerWeek=Input per week +InputPerMonth=Input per month InputDetail=Input detail TimeAlreadyRecorded=This is time spent already recorded for this task/day and user %s ProjectsWithThisUserAsContact=Projects with this user as contact diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 388de918e05..e1de5b386a1 100644 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -69,6 +69,7 @@ NewTask=Nouvelle tâche AddTask=Créer tâche AddTimeSpent=Saisir temps consommé AddHereTimeSpentForDay=Ajoutez ici le temps passé pour cette journée/tâche +AddHereTimeSpentForWeek=Ajoutez ici le temps passé pour cette semaine/tâche Activity=Activité Activities=Tâches/activités MyActivities=Mes tâches/activités @@ -187,6 +188,7 @@ ProjectMustBeValidatedFirst=Le projet doit être validé d'abord FirstAddRessourceToAllocateTime=Affecter un utilisateur pour saisir des temps InputPerDay=Saisie par jour InputPerWeek=Saisie par semaine +InputPerMonth=Saisie par mois InputDetail=Saisir le détail TimeAlreadyRecorded=C'est le temps passé déjà enregistré pour cette tâche/jour et pour l'utilisateur %s ProjectsWithThisUserAsContact=Projets avec cet utilisateur comme contact diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 8215eec4258..9e056ba5029 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -146,7 +146,9 @@ $search_array_options_task = $extrafields->getOptionalsFromPost($object->table_e /* * Actions */ - +$parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 8b69fc6aa01..085b54b9bdb 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -162,7 +162,9 @@ $search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', ' /* * Actions */ - +$parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 54d13a51549..048ea819187 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1797,6 +1797,72 @@ class Project extends CommonObject return -1; } } + /** + * Load time spent into this->weekWorkLoad and this->weekWorkLoadPerTask for all day of a week of project. + * Note: array weekWorkLoad and weekWorkLoadPerTask are reset and filled at each call. + * + * @param int $datestart First day of week (use dol_get_first_day to find this date) + * @param int $taskid Filter on a task id + * @param int $userid Time spent by a particular user + * @return int <0 if OK, >0 if KO + */ + public function loadTimeSpentMonth($datestart, $taskid=0, $userid=0) + { + $error=0; + + $this->monthWorkLoad=array(); + $this->monthWorkLoadPerTask=array(); + + if (empty($datestart)) dol_print_error('','Error datestart parameter is empty'); + + $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; + $sql.= " WHERE ptt.fk_task = pt.rowid"; + $sql.= " AND pt.fk_projet = ".$this->id; + $sql.= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; + $sql.= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'm') - 1)."')"; + if ($task_id) $sql.= " AND ptt.fk_task=".$taskid; + if (is_numeric($userid)) $sql.= " AND ptt.fk_user=".$userid; + + //print $sql; + $resql=$this->db->query($sql); + if ($resql) + { + $weekalreadyfound=array(); + + $num = $this->db->num_rows($resql); + $i = 0; + // Loop on each record found, so each couple (project id, task id) + while ($i < $num) + { + $obj=$this->db->fetch_object($resql); + if(!empty($obj->task_date)) { + $date = explode('-',$obj->task_date); + $week_number = getWeekNumber($date[2], $date[1], $date[0]); + } + if (empty($weekalreadyfound[$week_number])) + { + $this->monthWorkLoad[$week_number] = $obj->task_duration; + $this->monthWorkLoadPerTask[$week_number][$obj->fk_task] = $obj->task_duration; + } + else + { + $this->monthWorkLoad[$week_number] += $obj->task_duration; + $this->monthWorkLoadPerTask[$week_number][$obj->fk_task] += $obj->task_duration; + } + $weekalreadyfound[$week_number]=1; + $i++; + } + $this->db->free($resql); + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps From fee113bfb5bf928fa4630305490668fb28029b23 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 31 Jan 2020 10:26:33 +0000 Subject: [PATCH 18/68] Fixing style errors. --- htdocs/core/lib/date.lib.php | 20 +++++++----- htdocs/core/lib/project.lib.php | 23 +++++++------- htdocs/projet/activity/perday.php | 2 +- htdocs/projet/activity/permonth.php | 46 +++++++++++++-------------- htdocs/projet/activity/perweek.php | 2 +- htdocs/projet/class/project.class.php | 6 ++-- 6 files changed, 50 insertions(+), 49 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index b604ea831b1..43a28a4b05c 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -970,8 +970,9 @@ function monthArray($outputlangs, $short = 0) * @return array Week numbers */ -function getWeekNumbersOfMonth($month, $year) { - $nb_days = cal_days_in_month(CAL_GREGORIAN,$month, $year); +function getWeekNumbersOfMonth($month, $year) +{ + $nb_days = cal_days_in_month(CAL_GREGORIAN, $month, $year); $TWeek = array(); for($day = 1; $day < $nb_days; $day++) { $week_number = getWeekNumber($day, $month, $year); @@ -987,11 +988,12 @@ function getWeekNumbersOfMonth($month, $year) { * @param int $year Year number * @return array First day of week */ -function getFirstDayOfEachWeek($TWeek, $year) { +function getFirstDayOfEachWeek($TWeek, $year) +{ $TFirstDayOfWeek = array(); foreach($TWeek as $weekNb) { - if(in_array('01',$TWeek) && in_array('52',$TWeek) && $weekNb == '01') $year++;//Si on a la 1re semaine et la semaine 52 c'est qu'on change d'année - $TFirstDayOfWeek[$weekNb] = date('d',strtotime($year.'W'.$weekNb)); + if(in_array('01', $TWeek) && in_array('52', $TWeek) && $weekNb == '01') $year++;//Si on a la 1re semaine et la semaine 52 c'est qu'on change d'année + $TFirstDayOfWeek[$weekNb] = date('d', strtotime($year.'W'.$weekNb)); } return $TFirstDayOfWeek; } @@ -1003,10 +1005,11 @@ function getFirstDayOfEachWeek($TWeek, $year) { * @param int $year Year number * @return array Last day of week */ -function getLastDayOfEachWeek($TWeek, $year) { +function getLastDayOfEachWeek($TWeek, $year) +{ $TLastDayOfWeek = array(); foreach($TWeek as $weekNb) { - $TLastDayOfWeek[$weekNb] = date('d',strtotime($year.'W'.$weekNb.'+6 days')); + $TLastDayOfWeek[$weekNb] = date('d', strtotime($year.'W'.$weekNb.'+6 days')); } return $TLastDayOfWeek; } @@ -1019,7 +1022,8 @@ function getLastDayOfEachWeek($TWeek, $year) { * @param int $year Year number * @return int Week number */ -function getWeekNumber($day, $month, $year) { +function getWeekNumber($day, $month, $year) +{ $date = new DateTime($year.'-'.$month.'-'.$day); $week = $date->format("W"); return $week; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index e2f08e7c092..d7275d3343a 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1729,7 +1729,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ * @param int $oldprojectforbreak Old project id of last project break * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks */ -function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0, $TWeek=array()) +function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array()) { global $conf, $db, $user, $bc, $langs; global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; @@ -1805,7 +1805,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & { print ''."\n"; print ''; - print $projectstatic->getNomUrl(1,'',0,''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + print $projectstatic->getNomUrl(1, '', 0, ''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); if ($projectstatic->title) { @@ -1853,7 +1853,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Planned Workload print ''; - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); else print '--:--'; print ''; @@ -1868,7 +1868,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & if ($lines[$i]->duration) { print ''; - print convertSecondToTime($lines[$i]->duration,'allhourmin'); + print convertSecondToTime($lines[$i]->duration, 'allhourmin'); print ''; } else print '--:--'; @@ -1877,7 +1877,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Time spent by user print ''; $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); else print '--:--'; print "\n"; @@ -1901,20 +1901,19 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & //TODO // Fields to show current time $tableCell=''; $modeinput='hours'; - $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y',$firstdaytoshow)); + $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow)); $TFirstDay[reset($TWeek)] = 1; foreach($TFirstDay as &$fday) { $fday--; } foreach ($TWeek as $weekNb) { - $weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]; $totalforeachweek[$weekNb]+=$weekWorkLoad; $alreadyspent=''; - if ($weekWorkLoad > 0) $alreadyspent=convertSecondToTime($weekWorkLoad,'allhourmin'); - $alttitle=$langs->trans("AddHereTimeSpentForWeek",$weekNb); + if ($weekWorkLoad > 0) $alreadyspent=convertSecondToTime($weekWorkLoad, 'allhourmin'); + $alttitle=$langs->trans("AddHereTimeSpentForWeek", $weekNb); $tableCell =''; @@ -1936,13 +1935,13 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Warning print ''; - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); - else if ($disabledtask) + if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); + elseif ($disabledtask) { $titleassigntask = $langs->trans("AssignTaskToMe"); if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); - print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); + print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); } print ''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 9e056ba5029..2489104eb34 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -147,7 +147,7 @@ $search_array_options_task = $extrafields->getOptionalsFromPost($object->table_e * Actions */ $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index e35a47551b1..93c1edb6757 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -38,10 +38,10 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; $langs->loadLangs(array('projects','users','companies')); $hookmanager->initHooks(array('timesheetpermonthcard')); -$action=GETPOST('action','aZ09'); -$mode=GETPOST("mode",'alpha'); -$id=GETPOST('id','int'); -$taskid=GETPOST('taskid','int'); +$action=GETPOST('action', 'aZ09'); +$mode=GETPOST("mode", 'alpha'); +$id=GETPOST('id', 'int'); +$taskid=GETPOST('taskid', 'int'); $mine=0; if ($mode == 'mine') $mine=1; @@ -61,13 +61,13 @@ $nowday=$nowtmp['mday']; $nowmonth=$nowtmp['mon']; $nowyear=$nowtmp['year']; -$year=GETPOST('reyear')?GETPOST('reyear','int'):(GETPOST("year")?GETPOST("year","int"):date("Y")); -$month=GETPOST('remonth')?GETPOST('remonth','int'):(GETPOST("month")?GETPOST("month","int"):date("m")); -$day=GETPOST('reday')?GETPOST('reday','int'):(GETPOST("day")?GETPOST("day","int"):date("d")); +$year=GETPOST('reyear')?GETPOST('reyear', 'int'):(GETPOST("year")?GETPOST("year", "int"):date("Y")); +$month=GETPOST('remonth')?GETPOST('remonth', 'int'):(GETPOST("month")?GETPOST("month", "int"):date("m")); +$day=GETPOST('reday')?GETPOST('reday', 'int'):(GETPOST("day")?GETPOST("day", "int"):date("d")); $day = (int) $day; -$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); +$week=GETPOST("week", "int")?GETPOST("week", "int"):date("W"); -$search_categ=GETPOST("search_categ",'alpha'); +$search_categ=GETPOST("search_categ", 'alpha'); $search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); $search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha'); @@ -87,7 +87,7 @@ $next_year = $next['year']; $next_month = $next['month']; $next_day = 1; $TWeek = getWeekNumbersOfMonth($month, $year); -$firstdaytoshow = dol_mktime(0,0,0,$month,1,$year); +$firstdaytoshow = dol_mktime(0, 0, 0, $month, 1, $year); $TFirstDays = getFirstDayOfEachWeek($TWeek, $year); $TFirstDays[reset($TWeek)] = '01'; //first day of month $TLastDays = getLastDayOfEachWeek($TWeek, $year); @@ -115,11 +115,11 @@ $object=new Task($db); * Actions */ $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid, 'TWeek' => $TWeek, 'TFirstDays' => $TFirstDays, 'TLastDays' => $TLastDays); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge criteria -if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { $action = ''; $search_categ=''; @@ -130,7 +130,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_thirdparty = ''; $search_declared_progress = ''; } -if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha')) +if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) { $action = ''; } @@ -228,7 +228,6 @@ if ($action == 'addtime' && $user->rights->projet->lire) } else { - foreach($timetoadd as $taskid => $value) // Loop on each task { $updateoftaskdone=0; @@ -237,7 +236,7 @@ if ($action == 'addtime' && $user->rights->projet->lire) $amountoadd=$timetoadd[$taskid][$key]; if (! empty($amountoadd)) { - $tmpduration=explode(':',$amountoadd); + $tmpduration=explode(':', $amountoadd); $newduration=0; if (! empty($tmpduration[0])) $newduration+=($tmpduration[0] * 3600); if (! empty($tmpduration[1])) $newduration+=($tmpduration[1] * 60); @@ -324,7 +323,7 @@ $holiday = new Holiday($db); $title=$langs->trans("TimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,(empty($usertoprocess->id)?2:0),1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id)?2:0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project //var_dump($projectsListId); if ($id) { @@ -353,7 +352,7 @@ $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($proj //var_dump($taskrole); -llxHeader("",$title,"",'','','',array('/core/js/timesheet.js')); +llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js')); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); @@ -367,10 +366,10 @@ $param.=($search_task_label?'&search_task_label='.$search_task_label:''); // Show navigation bar $nav =''.img_previous($langs->trans("Previous"))."\n"; -$nav.=" ".dol_print_date(dol_mktime(0,0,0,$month,1,$year),"%Y").", ".$langs->trans(date('F', mktime(0, 0, 0, $month, 10)))." \n"; +$nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%Y").", ".$langs->trans(date('F', mktime(0, 0, 0, $month, 10)))." \n"; $nav.=''.img_next($langs->trans("Next"))."\n"; $nav.="   (".$langs->trans("Today").")"; -$nav.='
'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' '; +$nav.='
'.$form->select_date(-1, '', 0, 0, 2, "addtime", 1, 0, 1).' '; $nav.=' '; $picto='calendarweek'; @@ -418,7 +417,7 @@ print '
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); print '
'; print ' '; -print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth150onsmartphone'); +print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); print ''; print ''; @@ -464,7 +463,7 @@ if (! empty($moreforfilter)) print '
'; print $moreforfilter; $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } @@ -559,7 +558,6 @@ if (count($tasksarray) > 0) { foreach($TWeek as $weekNb) { - $timeonothertasks=($totalforeachweek[$weekNb] - $totalforvisibletasks[$weekNb]); if ($timeonothertasks) { @@ -584,7 +582,7 @@ if (count($tasksarray) > 0) if ($timeonothertasks) { print ''; } print ''; @@ -603,7 +601,7 @@ if (count($tasksarray) > 0) foreach ($TWeek as $weekNb) { - print '
'. convertSecondToTime($totalforvisibletasks[$weekNb],'allhourmin').'
'; + print '
'. convertSecondToTime($totalforvisibletasks[$weekNb], 'allhourmin').'
'; } print '
 
'; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 085b54b9bdb..563b7ca19c9 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -163,7 +163,7 @@ $search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', ' * Actions */ $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 048ea819187..ce1c8fdaf17 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1806,14 +1806,14 @@ class Project extends CommonObject * @param int $userid Time spent by a particular user * @return int <0 if OK, >0 if KO */ - public function loadTimeSpentMonth($datestart, $taskid=0, $userid=0) + public function loadTimeSpentMonth($datestart, $taskid = 0, $userid = 0) { $error=0; $this->monthWorkLoad=array(); $this->monthWorkLoadPerTask=array(); - if (empty($datestart)) dol_print_error('','Error datestart parameter is empty'); + if (empty($datestart)) dol_print_error('', 'Error datestart parameter is empty'); $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task"; $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; @@ -1837,7 +1837,7 @@ class Project extends CommonObject { $obj=$this->db->fetch_object($resql); if(!empty($obj->task_date)) { - $date = explode('-',$obj->task_date); + $date = explode('-', $obj->task_date); $week_number = getWeekNumber($date[2], $date[1], $date[0]); } if (empty($weekalreadyfound[$week_number])) From 398e83d1cc6869f3c7e030f5393e22ad5a5a6437 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 31 Jan 2020 11:36:53 +0100 Subject: [PATCH 19/68] FIX for stickler --- htdocs/core/lib/date.lib.php | 1 - htdocs/core/lib/project.lib.php | 1 + htdocs/projet/activity/permonth.php | 3 ++- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 43a28a4b05c..e7043a1798a 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -969,7 +969,6 @@ function monthArray($outputlangs, $short = 0) * @param int $year Year number * @return array Week numbers */ - function getWeekNumbersOfMonth($month, $year) { $nb_days = cal_days_in_month(CAL_GREGORIAN, $month, $year); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index d7275d3343a..9f55a431147 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1727,6 +1727,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ * @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to * @param array $isavailable Array with data that say if user is available for several days for morning and afternoon * @param int $oldprojectforbreak Old project id of last project break + * @param array $Tweek Array of week numbers * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks */ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array()) diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 93c1edb6757..398f4c67199 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -480,7 +480,8 @@ print ''; print ''; print ''; print ''; -for ($idw=0;$idw'; } From 78baae1480ef5a645476c45b8ed948aa66962bed Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 31 Jan 2020 11:51:40 +0100 Subject: [PATCH 20/68] Fix stickler v2 --- htdocs/core/lib/project.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 9f55a431147..f39856f1bc1 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1727,7 +1727,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ * @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to * @param array $isavailable Array with data that say if user is available for several days for morning and afternoon * @param int $oldprojectforbreak Old project id of last project break - * @param array $Tweek Array of week numbers + * @param array $TWeek Array of week numbers * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks */ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array()) From 0db77c1de623f6474a70ab86617152ae966afb3a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 14:52:43 +0100 Subject: [PATCH 21/68] CSS --- .../template/class/myobject.class.php | 2 +- htdocs/theme/eldy/global.inc.php | 90 ++++++++++++++++--- htdocs/theme/md/style.css.php | 35 +++++--- 3 files changed, 101 insertions(+), 26 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 0845d5ecaf2..afa906be06c 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -67,7 +67,7 @@ class MyObject extends CommonObject * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. - * 'enabled' is a condition when the field must be managed. + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) * 'position' is the sort order of field. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index ae9c6cb6d65..7f44fccaa19 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -38,14 +38,6 @@ select.vmenusearchselectcombo { background-color: unset; } -input.select2-input { - border-bottom: none ! important; -} -.select2-choice { - border: none; - border-bottom: solid 1px rgba(0,0,0,.2) !important; /* required to avoid to lose bottom line when focus is lost on select2. */ -} - .liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre select[name=month], .liste_titre input[name=month_lim], .liste_titre input[name=month_start], .liste_titre input[name=month_end], .liste_titre input[name=month_create], @@ -235,9 +227,6 @@ select.flat, form.flat select { .optionblue { color: rgb(); } -.select2-results .select2-highlighted.optionblue { - color: #FFF !important; -} .optiongrey, .opacitymedium { opacity: 0.4; } @@ -481,6 +470,18 @@ textarea.centpercent { .paddingright2 { padding-: 2px; } +.paddingtop { + padding-bottom: 4px; +} +.paddingtop2 { + padding-bottom: 2px; +} +.paddingbottom { + padding-bottom: 4px; +} +.paddingbottom2 { + padding-bottom: 2px; +} .marginleft2 { margin-: 2px; } @@ -534,14 +535,20 @@ body[class*="colorblind-"] .text-success{ color: rgb() !important; } +.floatnone { + float: none !important; +} + .fa-toggle-on, .fa-toggle-off { font-size: 2em; } .websiteselectionsection .fa-toggle-on, .websiteselectionsection .fa-toggle-off, .asetresetmodule .fa-toggle-on, .asetresetmodule .fa-toggle-off { font-size: 1.5em; vertical-align: text-bottom; } + /* Themes for badges */ - + + .borderrightlight { @@ -574,6 +581,31 @@ div.divsearchfield { padding-bottom: 5px; opacity: 0.6; } +.divadvancedsearchfield:first-child { + margin-top: 3px; +} +.divadvancedsearchfield { + float: left; + padding-left: 15px; + padding-bottom: 2px; + padding-top: 2px; +} +.divadvancedsearchfield span.select2.select2-container.select2-container--default { + padding-bottom: 4px; +} +.search_component_params { + /*display: flex; */ + -webkit-flex-flow: row wrap; + flex-flow: row wrap; + background: #fff; + padding: 3px; +} +.search_component_params_input, .search_component_params_input:focus { + border-bottom: none; + width: auto; + margin: 0 !important; + padding: 3px; +} browser->layout == 'phone') { @@ -4781,6 +4813,28 @@ div.dataTables_length select { /* Select2 */ /* ============================================================================== */ +span.select2.select2-container.select2-container--default { + border-left: none; + border-top: none; + border-right: none; +} +input.select2-input { + border-bottom: none ! important; +} +.select2-choice { + border: none; + border-bottom: solid 1px rgba(0,0,0,.2) !important; /* required to avoid to lose bottom line when focus is lost on select2. */ +} +.select2-results .select2-highlighted.optionblue { + color: #FFF !important; +} +.select2-container .select2-selection--multiple { + min-height: 30px !important; +} +.select2-container--default .select2-selection--multiple .select2-selection__choice { + margin-top: 5px !important; + border: none; +} .select2-container--focus span.select2-selection.select2-selection--single { border-bottom: 1px solid #666 !important; } @@ -4848,8 +4902,16 @@ div.dataTables_length select { box-shadow: none !important; border-radius: 0 !important; } +.select2-container--default.select2-container--focus .select2-selection--multiple { + border-top: none; + border-left: none; + border-right: none; +} .select2-container--default .select2-selection--multiple { - border: solid 1px rgba(0,0,0,.2); + border-bottom: solid 1px rgba(0,0,0,.2); + border-top: none; + border-left: none; + border-right: none; border-radius: 0 !important; } .select2-search__field @@ -4942,7 +5004,7 @@ a span.select2-chosen opacity: 0.4; } .select2-container-multi .select2-choices .select2-search-choice { - margin-bottom: 3px; + margin-bottom: 3px; } .select2-dropdown-open.select2-drop-above .select2-choice, .select2-dropdown-open.select2-drop-above .select2-choices, .select2-container-multi .select2-choices, .select2-container-multi.select2-container-active .select2-choices diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 1baea54e815..808e565285e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -269,13 +269,6 @@ textarea:focus, button:focus { input:focus, textarea:focus, button:focus, select:focus { border-bottom: 1px solid #666; } -input.select2-input { - border-bottom: none ! important; -} -.select2-choice { - border: none; - border-bottom: 1px solid #ccc !important; -} textarea.cke_source:focus { @@ -453,9 +446,6 @@ select.flat, form.flat select { .optionblue { color: rgb(); } -.select2-results .select2-highlighted.optionblue { - color: #FFF !important; -} .optiongrey, .opacitymedium { opacity: 0.5; } @@ -763,6 +753,10 @@ body[class*="colorblind-"] .text-success{ font-size: 1.5em; vertical-align: text-bottom; } +.floatnone { + float: none !important; +} + /* Themes for badges */ @@ -4919,6 +4913,17 @@ div.dataTables_length select { /* Select2 */ /* ============================================================================== */ +input.select2-input { + border-bottom: none ! important; +} +.select2-choice { + border: none; + border-bottom: 1px solid #ccc !important; +} +.select2-results .select2-highlighted.optionblue { + color: #FFF !important; +} + .blockvmenusearch .select2-container--default .select2-selection--single, .blockvmenubookmarks .select2-container--default .select2-selection--single { @@ -4980,8 +4985,16 @@ div.dataTables_length select { box-shadow: none !important; border-radius: 0 !important; } +.select2-container--default.select2-container--focus .select2-selection--multiple { + border-top: none; + border-left: none; + border-right: none; +} .select2-container--default .select2-selection--multiple { - border: solid 1px rgba(0,0,0,.2); + border-bottom: solid 1px rgba(0,0,0,.2); + border-top: none; + border-left: none; + border-right: none; border-radius: 0 !important; } .select2-search__field From f75255191413827a6f037a10338d585508e2bc24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 14:53:47 +0100 Subject: [PATCH 22/68] WIP Generic stats page --- htdocs/core/class/html.form.class.php | 36 +++++++++++++++++++++----- htdocs/core/lib/security.lib.php | 2 +- htdocs/langs/en_US/exports.lang | 2 +- htdocs/langs/en_US/main.lang | 1 + htdocs/societe/class/societe.class.php | 3 ++- 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 38e18d24b8b..a072688a703 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8034,11 +8034,12 @@ class Form /** * Output the component to make advanced search criteries * - * @param array $arrayofcriterias Array of available search criterias. Example: array($object->element => $object->fields, 'otherfamily' => otherarrayoffields, ...) - * @param array $search_component_params Array of selected search criterias - * @return string HTML component for advanced search + * @param array $arrayofcriterias Array of available search criterias. Example: array($object->element => $object->fields, 'otherfamily' => otherarrayoffields, ...) + * @param array $search_component_params Array of selected search criterias + * @param array $arrayofinputfieldsalreadyoutput Array of input fields already inform. The component will not generate a hidden input field if it is in this list. + * @return string HTML component for advanced search */ - public function searchComponent($arrayofcriterias, $search_component_params) + public function searchComponent($arrayofcriterias, $search_component_params, $arrayofhiddenfieldstoadd = array()) { global $conf, $langs; @@ -8046,12 +8047,33 @@ class Form $ret .= '
'; //$ret .= ''; - $ret .= ''; + $ret .= ''; $ret .= ''; $ret .= $langs->trans("Filters"); $ret .= ''; - $ret .= ''; - $ret .= ''; + //$ret .= ''; + $ret .= '
'; + $ret .= ''; + $ret .= '
'; + foreach($arrayofcriterias as $criterias) { + foreach($criterias as $criteriafamilykey => $criteriafamilyval) { + if (in_array('search_'.$criteriafamilykey, $arrayofhiddenfieldstoadd)) continue; + if (in_array($criteriafamilykey, array('rowid', 'ref_ext', 'entity', 'extraparams'))) continue; + if (in_array($criteriafamilyval['type'], array('date', 'datetime', 'timestamp'))) { + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + } + else { + $ret .= ''; + } + } + } $ret .= '
'; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 5a7b8342bd6..93f17422c47 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -171,7 +171,7 @@ function dol_verifyHash($chain, $hash, $type = '0') * @param string $features Features to check (it must be module name. Examples: 'societe', 'contact', 'produit&service', 'produit|service', ...) * @param int $objectid Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional). * @param string $tableandshare 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional). - * @param string $feature2 Feature to check, second level of permission (optional). Can be a 'or' check with 'level1|level2'. + * @param string $feature2 Feature to check, second level of permission (optional). Can be a 'or' check with 'sublevela|sublevelb'. * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) * @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional) * @param int $isdraft 1=The object with id=$objectid is a draft diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index ef5ff029c78..2dcf4317e00 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -37,7 +37,7 @@ FormatedExportDesc3=When data to export are selected, you can choose the format Sheet=Sheet NoImportableData=No importable data (no module with definitions to allow data imports) FileSuccessfullyBuilt=File generated -SQLUsedForExport=SQL Request used to build export file +SQLUsedForExport=SQL Request used to extract data LineId=Id of line LineLabel=Label of line LineDescription=Description of line diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c5c24372e06..3054b813f72 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1015,6 +1015,7 @@ ContactAddedAutomatically=Contact added from contact thirdparty roles More=More ShowDetails=Show details CustomReports=Custom reports +StatisticsOn=Statistics on SelectYourGraphOptionsFirst=Select your graph options to build a graph Measures=Measures XAxis=X-Axis diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index ec4ac4182d6..f22455cea1b 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -128,7 +128,7 @@ class Societe extends CommonObject public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'nom' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'name_alias' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'name_alias' =>array('type'=>'varchar(128)', 'label'=>'AliasNames', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), @@ -3779,6 +3779,7 @@ class Societe extends CommonObject /** * Check if we must use revenue stamps feature or not according to country (country of $mysocin most cases). + * Table c_revenuestamp contains the country and value of stamp per invoice. * * @return boolean true or false */ From 0cd8337b7e2b7e44f0fbb000077228ce85ec9aca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 14:54:42 +0100 Subject: [PATCH 23/68] NEW Can manage situation invoices --- htdocs/core/lib/invoice.lib.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index de1334c37a5..15de60eb791 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -137,13 +137,6 @@ function invoice_admin_prepare_head() $head[$h][2] = 'payment'; $h++; - if ($conf->global->INVOICE_USE_SITUATION || $conf->global->MAIN_FEATURES_LEVEL >= 1) { - $head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php'; - $head[$h][1] = $langs->trans("InvoiceSituation"); - $head[$h][2] = 'situation'; - $h++; - } - // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab @@ -170,6 +163,11 @@ function invoice_admin_prepare_head() $head[$h][2] = 'attributeslinesrec'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php'; + $head[$h][1] = $langs->trans("InvoiceSituation"); + $head[$h][2] = 'situation'; + $h++; + complete_head_from_modules($conf, $langs, null, $head, $h, 'invoice_admin', 'remove'); return $head; From d827e3289a568ae8de3b39bb15b8bef8f91f0c50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 15:12:17 +0100 Subject: [PATCH 24/68] Removed no more used field "amount" in llx_facture --- .../facture/class/facture-rec.class.php | 6 +- htdocs/compta/facture/class/facture.class.php | 78 +++++++++---------- htdocs/compta/facture/list.php | 1 - htdocs/install/mysql/tables/llx_facture.sql | 4 +- 4 files changed, 43 insertions(+), 46 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 593721a6f17..8a25ee42745 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -71,7 +71,6 @@ class FactureRec extends CommonInvoice public $number; public $date; - public $amount; public $remise; public $tva; public $total; @@ -127,7 +126,7 @@ class FactureRec extends CommonInvoice 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>30), - 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), + //'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), 'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>40), 'remise_percent' =>array('type'=>'double', 'label'=>'Remise percent', 'enabled'=>1, 'visible'=>-1, 'position'=>45), 'remise_absolue' =>array('type'=>'double', 'label'=>'Remise absolue', 'enabled'=>1, 'visible'=>-1, 'position'=>50), @@ -453,7 +452,7 @@ class FactureRec extends CommonInvoice */ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '') { - $sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc'; + $sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc'; $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; $sql .= ', f.date_lim_reglement as dlr'; $sql .= ', f.note_private, f.note_public, f.fk_user_author'; @@ -495,7 +494,6 @@ class FactureRec extends CommonInvoice $this->type = $obj->type; $this->datep = $obj->dp; $this->date = $obj->df; - $this->amount = $obj->amount; $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; $this->remise = $obj->remise; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b94e9373dda..a9a1e286d1e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -261,59 +261,59 @@ class Facture extends CommonInvoice 'increment' =>array('type'=>'varchar(10)', 'label'=>'Increment', 'enabled'=>1, 'visible'=>-1, 'position'=>45), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>50), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>55), - 'datef' =>array('type'=>'date', 'label'=>'Datef', 'enabled'=>1, 'visible'=>-1, 'position'=>60), + 'datef' =>array('type'=>'date', 'label'=>'DateInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>60), 'date_valid' =>array('type'=>'date', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65), 'date_closing' =>array('type'=>'datetime', 'label'=>'Date closing', 'enabled'=>1, 'visible'=>-1, 'position'=>70), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>75), - 'paye' =>array('type'=>'smallint(6)', 'label'=>'Paye', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>80), - 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>85), + 'paye' =>array('type'=>'smallint(6)', 'label'=>'InvoicePaidCompletely', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>80), + //'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>85), 'remise_percent' =>array('type'=>'double', 'label'=>'Remise percent', 'enabled'=>1, 'visible'=>-1, 'position'=>90), 'remise_absolue' =>array('type'=>'double', 'label'=>'Remise absolue', 'enabled'=>1, 'visible'=>-1, 'position'=>95), 'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>100), - 'close_code' =>array('type'=>'varchar(16)', 'label'=>'Close code', 'enabled'=>1, 'visible'=>-1, 'position'=>105), - 'close_note' =>array('type'=>'varchar(128)', 'label'=>'Close note', 'enabled'=>1, 'visible'=>-1, 'position'=>110), - 'tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>115, 'isameasure'=>1), + 'close_code' =>array('type'=>'varchar(16)', 'label'=>'EarlyClosingReason', 'enabled'=>1, 'visible'=>-1, 'position'=>105), + 'close_note' =>array('type'=>'varchar(128)', 'label'=>'EarlyClosingComment', 'enabled'=>1, 'visible'=>-1, 'position'=>110), + 'tva' =>array('type'=>'double(24,8)', 'label'=>'TotalVAT', 'enabled'=>1, 'visible'=>-1, 'position'=>115, 'isameasure'=>1), 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>120, 'isameasure'=>1), 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1), - 'revenuestamp' =>array('type'=>'double(24,8)', 'label'=>'Revenuestamp', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1), - 'total' =>array('type'=>'double(24,8)', 'label'=>'Total', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), - 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Total ttc', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1), - 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Fk statut', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), - 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>150), + 'revenuestamp' =>array('type'=>'double(24,8)', 'label'=>'RevenueStamp', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1), + 'total' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), + 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1), + 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'position'=>150), 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>155), 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>160), - 'fk_user_closing' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user closing', 'enabled'=>1, 'visible'=>-1, 'position'=>165), - 'fk_facture_source' =>array('type'=>'integer', 'label'=>'Fk facture source', 'enabled'=>1, 'visible'=>-1, 'position'=>170), - 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>175), + 'fk_user_closing' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserClosing', 'enabled'=>1, 'visible'=>-1, 'position'=>165), + 'fk_facture_source' =>array('type'=>'integer', 'label'=>'SourceInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>170), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>175), 'fk_account' =>array('type'=>'integer', 'label'=>'Fk account', 'enabled'=>1, 'visible'=>-1, 'position'=>180), - 'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'Fk currency', 'enabled'=>1, 'visible'=>-1, 'position'=>185), - 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Fk cond reglement', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>190), - 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'Fk mode reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>195), - 'date_lim_reglement' =>array('type'=>'date', 'label'=>'Date lim reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>200), + 'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'CurrencyCode', 'enabled'=>1, 'visible'=>-1, 'position'=>185), + 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>190), + 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>195), + 'date_lim_reglement' =>array('type'=>'date', 'label'=>'DateDue', 'enabled'=>1, 'visible'=>-1, 'position'=>200), 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>205), 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>210), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>215), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>220), 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>225), - 'situation_cycle_ref' =>array('type'=>'smallint(6)', 'label'=>'Situation cycle ref', 'enabled'=>1, 'visible'=>-1, 'position'=>230), - 'situation_counter' =>array('type'=>'smallint(6)', 'label'=>'Situation counter', 'enabled'=>1, 'visible'=>-1, 'position'=>235), - 'situation_final' =>array('type'=>'smallint(6)', 'label'=>'Situation final', 'enabled'=>1, 'visible'=>-1, 'position'=>240), - 'retained_warranty' =>array('type'=>'double', 'label'=>'Retained warranty', 'enabled'=>1, 'visible'=>-1, 'position'=>245), - 'retained_warranty_date_limit' =>array('type'=>'date', 'label'=>'Retained warranty date limit', 'enabled'=>1, 'visible'=>-1, 'position'=>250), - 'retained_warranty_fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Retained warranty fk cond reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>255), - 'fk_incoterms' =>array('type'=>'integer', 'label'=>'Fk incoterms', 'enabled'=>1, 'visible'=>-1, 'position'=>260), - 'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'Location incoterms', 'enabled'=>1, 'visible'=>-1, 'position'=>265), - 'date_pointoftax' =>array('type'=>'date', 'label'=>'Date pointoftax', 'enabled'=>1, 'visible'=>-1, 'position'=>270), - 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'Fk multicurrency', 'enabled'=>1, 'visible'=>-1, 'position'=>275), - 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'Multicurrency code', 'enabled'=>1, 'visible'=>-1, 'position'=>280), - 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency tx', 'enabled'=>1, 'visible'=>-1, 'position'=>285), - 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ht', 'enabled'=>1, 'visible'=>-1, 'position'=>290), - 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total tva', 'enabled'=>1, 'visible'=>-1, 'position'=>295), - 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ttc', 'enabled'=>1, 'visible'=>-1, 'position'=>300), - 'fk_fac_rec_source' =>array('type'=>'integer', 'label'=>'Fk fac rec source', 'enabled'=>1, 'visible'=>-1, 'position'=>305), + 'situation_cycle_ref' =>array('type'=>'smallint(6)', 'label'=>'Situation cycle ref', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION', 'visible'=>-1, 'position'=>230), + 'situation_counter' =>array('type'=>'smallint(6)', 'label'=>'Situation counter', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION', 'visible'=>-1, 'position'=>235), + 'situation_final' =>array('type'=>'smallint(6)', 'label'=>'Situation final', 'enabled'=>'empty($conf->global->INVOICE_USE_SITUATION) ? 0 : 1', 'visible'=>-1, 'position'=>240), + 'retained_warranty' =>array('type'=>'double', 'label'=>'Retained warranty', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>245), + 'retained_warranty_date_limit' =>array('type'=>'date', 'label'=>'Retained warranty date limit', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>250), + 'retained_warranty_fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Retained warranty fk cond reglement', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>255), + 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermsCode', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>260), + 'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'IncotermsLocation', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>265), + 'date_pointoftax' =>array('type'=>'date', 'label'=>'DatePointOfTax', 'enabled'=>'$conf->global->INVOICE_POINTOFTAX_DATE', 'visible'=>-1, 'position'=>270), + 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'MulticurrencyID', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>275), + 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'MulticurrencyCode', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>280), + 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyRate', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>285), + 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ht', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>290), + 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total tva', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>295), + 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ttc', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>300), + 'fk_fac_rec_source' =>array('type'=>'integer', 'label'=>'RecurringInvoiceSource', 'enabled'=>1, 'visible'=>-1, 'position'=>305), 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>310), - 'module_source' =>array('type'=>'varchar(32)', 'label'=>'Module source', 'enabled'=>1, 'visible'=>-1, 'position'=>315), - 'pos_source' =>array('type'=>'varchar(32)', 'label'=>'Pos source', 'enabled'=>1, 'visible'=>-1, 'position'=>320), + 'module_source' =>array('type'=>'varchar(32)', 'label'=>'POSModule', 'enabled'=>1, 'visible'=>-1, 'position'=>315), + 'pos_source' =>array('type'=>'varchar(32)', 'label'=>'POSTerminal', 'enabled'=>1, 'visible'=>-1, 'position'=>320), ); // END MODULEBUILDER PROPERTIES @@ -1451,7 +1451,7 @@ class Facture extends CommonInvoice if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = 'SELECT f.rowid,f.entity,f.ref,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; + $sql = 'SELECT f.rowid,f.entity,f.ref,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc'; $sql .= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; $sql .= ', f.datef as df, f.date_pointoftax'; @@ -2132,7 +2132,7 @@ class Facture extends CommonInvoice } } - // If we decrement stock on invoice validation, we increment + // If we decrease stock on invoice validation, we increase back if a warehouse id was provided if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -2743,7 +2743,7 @@ class Facture extends CommonInvoice $this->oldcopy = clone $this; } - // Si on decremente le produit principal et ses composants a la validation de facture, on réincrement + // If we decrease stock on invoice validation, we increase back if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 4cd01d56ecd..32cd30ea207 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1061,7 +1061,6 @@ if ($resql) { print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); } - print empty($obj->increment) ? '' : ' ('.$obj->increment.')'; $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index 3b49ef04010..5a2d5464cfc 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -34,7 +34,6 @@ create table llx_facture ref_client varchar(255), -- reference for customer type smallint DEFAULT 0 NOT NULL, -- type of invoice - increment varchar(10), fk_soc integer NOT NULL, datec datetime, -- date de creation de la facture datef date, -- date invoice @@ -43,7 +42,7 @@ create table llx_facture tms timestamp, -- date creation/modification date_closing datetime, -- date de cloture paye smallint DEFAULT 0 NOT NULL, - amount double(24,8) DEFAULT 0 NOT NULL, + --amount double(24,8) DEFAULT 0 NOT NULL, remise_percent real DEFAULT 0, -- remise relative remise_absolue real DEFAULT 0, -- remise absolue remise real DEFAULT 0, -- remise totale calculee @@ -70,6 +69,7 @@ create table llx_facture fk_fac_rec_source integer, -- facture rec source fk_facture_source integer, -- facture origin if credit notes or replacement invoice fk_projet integer DEFAULT NULL, -- project invoice is linked to + increment varchar(10), -- Numero of generation if generated from recurring template invoice fk_account integer, -- bank account fk_currency varchar(3), -- currency code From aaf83e418d53bf5b2c10ebfbce6082506aca9944 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 15:27:17 +0100 Subject: [PATCH 25/68] Code comment --- htdocs/stripe/class/stripe.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index cb57ba2a53f..12e552b164e 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -139,7 +139,8 @@ class Stripe extends CommonObject /** - * Get the Stripe customer of a thirdparty (with option to create it if not linked yet) + * Get the Stripe customer of a thirdparty (with option to create it if not linked yet). + * Search on site_account = 0 or = $stripearrayofkeysbyenv[$status]['publishable_key'] * * @param Societe $object Object thirdparty to check, or create on stripe (create on stripe also update the stripe_account table for current entity) * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect From 8e18a08377d550d1a177c0403c71055ef5b1ed9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 16:59:10 +0100 Subject: [PATCH 26/68] Fix log of proxy forward only if it differs from remote_addr --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e4a200fceff..17fa72e43b0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1059,7 +1059,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = ); // This is when server run behind a reverse proxy - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].(empty($_SERVER["REMOTE_ADDR"]) ? '' : '->'.$_SERVER['REMOTE_ADDR']); + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].((empty($_SERVER["REMOTE_ADDR"]) || ($_SERVER['HTTP_X_FORWARDED_FOR'] == $_SERVER['REMOTE_ADDR'])) ? '' : '->'.$_SERVER['REMOTE_ADDR']); // This is when server run normally on a server elseif (!empty($_SERVER["REMOTE_ADDR"])) $data['ip'] = $_SERVER['REMOTE_ADDR']; // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) From b81d223ab3eb4f05a698bbe07a44181378e45f72 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 17:27:48 +0100 Subject: [PATCH 27/68] Do no retry ping after error the same month --- htdocs/core/ajax/pingresult.php | 4 +- htdocs/main.inc.php | 121 +++++++++++++++++--------------- 2 files changed, 67 insertions(+), 58 deletions(-) diff --git a/htdocs/core/ajax/pingresult.php b/htdocs/core/ajax/pingresult.php index 0dbb5167f9e..7e9fad309d4 100644 --- a/htdocs/core/ajax/pingresult.php +++ b/htdocs/core/ajax/pingresult.php @@ -53,8 +53,8 @@ print ''; $hash_unique_id = md5('dolibarr'.$conf->file->instance_unique_id); if (empty($conf->global->MAIN_FIRST_PING_OK_DATE) || (!empty($conf->file->instance_unique_id) && ($hash_unique_id != $conf->global->MAIN_FIRST_PING_OK_ID) && ($conf->global->MAIN_FIRST_PING_OK_ID != 'disabled')) - || GETPOST('forceping', 'alpha')) + || $forceping) { - if (strpos('alpha', DOL_VERSION) > 0) { + // No ping done if we are into an alpha version + if (strpos('alpha', DOL_VERSION) > 0 && ! $forceping) { print "\n\n"; } - elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id])) // Cookie is set when we uncheck the checkbox in the installation wizard. + elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id]) || $forceping) // Cookie is set when we uncheck the checkbox in the installation wizard. { - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + // MAIN_LAST_PING_KO_DATE + // TODO Disable ping if MAIN_LAST_PING_KO_DATE is set and is recent + if (! empty($conf->global->MAIN_LAST_PING_KO_DATE) && substr($conf->global->MAIN_LAST_PING_KO_DATE, 0, 6) == dol_print_date(dol_now(), '%Y%m') && ! $forceping) { + print "\n\n"; + } else { - print "\n".''."\n"; - print "\n\n"; - $url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ? "https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING); - // Try to guess the distrib used - $distrib = 'standard'; - if ($_SERVER["SERVER_ADMIN"] == 'doliwamp@localhost') $distrib = 'doliwamp'; - if (! empty($dolibarr_distrib)) $distrib = $dolibarr_distrib; - ?> - - global->MAIN_FIRST_PING_OK_DATE.' MAIN_FIRST_PING_OK_ID='.$conf->global->MAIN_FIRST_PING_OK_ID.' MAIN_LAST_PING_KO_DATE='.$conf->global->MAIN_LAST_PING_KO_DATE.' -->'."\n"; + print "\n\n"; + $url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ? "https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING); + // Try to guess the distrib used + $distrib = 'standard'; + if ($_SERVER["SERVER_ADMIN"] == 'doliwamp@localhost') $distrib = 'doliwamp'; + if (! empty($dolibarr_distrib)) $distrib = $dolibarr_distrib; + ?> + + Date: Fri, 31 Jan 2020 17:51:30 +0100 Subject: [PATCH 28/68] Fix log through proxy --- htdocs/core/lib/functions.lib.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 17fa72e43b0..5bc3ad0056c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1058,10 +1058,13 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = 'ip' => false ); - // This is when server run behind a reverse proxy - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].((empty($_SERVER["REMOTE_ADDR"]) || ($_SERVER['HTTP_X_FORWARDED_FOR'] == $_SERVER['REMOTE_ADDR'])) ? '' : '->'.$_SERVER['REMOTE_ADDR']); - // This is when server run normally on a server - elseif (!empty($_SERVER["REMOTE_ADDR"])) $data['ip'] = $_SERVER['REMOTE_ADDR']; + $remoteip = getUserRemoteIP(); // Get ip when page run on a web server + if (! empty($remoteip)) { + $data['ip'] = $remoteip; + // This is when server run behind a reverse proxy + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != $remoteip) $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].' -> '.$data['ip']; + elseif (!empty($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != $remoteip) $data['ip'] = $_SERVER['HTTP_CLIENT_IP'].' -> '.$data['ip']; + } // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) elseif (!empty($_SERVER['SERVER_ADDR'])) $data['ip'] = $_SERVER['SERVER_ADDR']; // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it). From b83c90e348676c2d6bc6da9649b1021bc694acee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 18:02:18 +0100 Subject: [PATCH 29/68] Fix phpcs --- htdocs/main.inc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 267d65fd8e1..d396ad4cadc 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2569,11 +2569,10 @@ if (!function_exists("llxFooter")) elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id]) || $forceping) // Cookie is set when we uncheck the checkbox in the installation wizard. { // MAIN_LAST_PING_KO_DATE - // TODO Disable ping if MAIN_LAST_PING_KO_DATE is set and is recent + // Disable ping if MAIN_LAST_PING_KO_DATE is set and is recent if (! empty($conf->global->MAIN_LAST_PING_KO_DATE) && substr($conf->global->MAIN_LAST_PING_KO_DATE, 0, 6) == dol_print_date(dol_now(), '%Y%m') && ! $forceping) { print "\n\n"; } else { - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print "\n".''."\n"; From ad6758c4da10535e2b8d6b16c7800cef900a0350 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 18:03:45 +0100 Subject: [PATCH 30/68] Fix bad var --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a072688a703..43cad658efd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8039,7 +8039,7 @@ class Form * @param array $arrayofinputfieldsalreadyoutput Array of input fields already inform. The component will not generate a hidden input field if it is in this list. * @return string HTML component for advanced search */ - public function searchComponent($arrayofcriterias, $search_component_params, $arrayofhiddenfieldstoadd = array()) + public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array()) { global $conf, $langs; @@ -8057,7 +8057,7 @@ class Form $ret .= ''; foreach($arrayofcriterias as $criterias) { foreach($criterias as $criteriafamilykey => $criteriafamilyval) { - if (in_array('search_'.$criteriafamilykey, $arrayofhiddenfieldstoadd)) continue; + if (in_array('search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) continue; if (in_array($criteriafamilykey, array('rowid', 'ref_ext', 'entity', 'extraparams'))) continue; if (in_array($criteriafamilyval['type'], array('date', 'datetime', 'timestamp'))) { $ret .= ''; From d530c7f7089a7344a6ea4d80c7ce3d2f9453831c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 18:16:16 +0100 Subject: [PATCH 31/68] Try fix for #12984 --- htdocs/product/index.php | 332 ++++++++++++++++++++------------------- 1 file changed, 169 insertions(+), 163 deletions(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index d885b36a877..49df2b36cc9 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -40,7 +40,7 @@ if ($type == '' && !$user->rights->service->lire) $type = '0'; // Force global p // Security check if ($type == '0') $result = restrictedArea($user, 'produit'); elseif ($type == '1') $result = restrictedArea($user, 'service'); -else $result = restrictedArea($user, 'produit|service'); +else $result = restrictedArea($user, 'produit|service|expedition'); // Load translation files required by the page $langs->loadLangs(array('products', 'stocks')); @@ -117,77 +117,80 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles /* * Number of products and/or services */ -$prodser = array(); -$prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0; -$prodser[1][0] = $prodser[1][1] = $prodser[1][2] = $prodser[1][3] = 0; - -$sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy"; -$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; -$sql .= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')'; -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -$sql .= " GROUP BY p.fk_product_type, p.tosell, p.tobuy"; -$result = $db->query($sql); -while ($objp = $db->fetch_object($result)) +if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) { - $status = 3; // On sale + On purchase - if (!$objp->tosell && !$objp->tobuy) $status = 0; // Not on sale, not on purchase - if ($objp->tosell && !$objp->tobuy) $status = 1; // On sale only - if (!$objp->tosell && $objp->tobuy) $status = 2; // On purchase only - $prodser[$objp->fk_product_type][$status] = $objp->total; - if ($objp->tosell) $prodser[$objp->fk_product_type]['sell'] += $objp->total; - if ($objp->tobuy) $prodser[$objp->fk_product_type]['buy'] += $objp->total; - if (!$objp->tosell && !$objp->tobuy) $prodser[$objp->fk_product_type]['none'] += $objp->total; -} + $prodser = array(); + $prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0; + $prodser[1][0] = $prodser[1][1] = $prodser[1][2] = $prodser[1][3] = 0; -if ($conf->use_javascript_ajax) -{ - print '
'; - print ''; - print ''; - print ''; + print '
'.$langs->trans("Statistics").'
'; - - $SommeA = $prodser[0]['sell']; - $SommeB = $prodser[0]['buy']; - $SommeC = $prodser[0]['none']; - $SommeD = $prodser[1]['sell']; - $SommeE = $prodser[1]['buy']; - $SommeF = $prodser[1]['none']; - $total = 0; - $dataval = array(); - $datalabels = array(); - $i = 0; - - $total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF; - $dataseries = array(); - if (!empty($conf->product->enabled)) + $sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')'; + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $sql .= " GROUP BY p.fk_product_type, p.tosell, p.tobuy"; + $result = $db->query($sql); + while ($objp = $db->fetch_object($result)) { - $dataseries[] = array($langs->trans("ProductsOnSale"), round($SommeA)); - $dataseries[] = array($langs->trans("ProductsOnPurchase"), round($SommeB)); - $dataseries[] = array($langs->trans("ProductsNotOnSell"), round($SommeC)); - } - if (!empty($conf->service->enabled)) - { - $dataseries[] = array($langs->trans("ServicesOnSale"), round($SommeD)); - $dataseries[] = array($langs->trans("ServicesOnPurchase"), round($SommeE)); - $dataseries[] = array($langs->trans("ServicesNotOnSell"), round($SommeF)); + $status = 3; // On sale + On purchase + if (!$objp->tosell && !$objp->tobuy) $status = 0; // Not on sale, not on purchase + if ($objp->tosell && !$objp->tobuy) $status = 1; // On sale only + if (!$objp->tosell && $objp->tobuy) $status = 2; // On purchase only + $prodser[$objp->fk_product_type][$status] = $objp->total; + if ($objp->tosell) $prodser[$objp->fk_product_type]['sell'] += $objp->total; + if ($objp->tobuy) $prodser[$objp->fk_product_type]['buy'] += $objp->total; + if (!$objp->tosell && !$objp->tobuy) $prodser[$objp->fk_product_type]['none'] += $objp->total; } - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); - $dolgraph->setShowPercent(0); - $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + if ($conf->use_javascript_ajax) + { + print '
'; + print ''; + print ''; + print ''; - print '
'.$langs->trans("Statistics").'
'; - print '
'; - print '
'; + $SommeA = $prodser[0]['sell']; + $SommeB = $prodser[0]['buy']; + $SommeC = $prodser[0]['none']; + $SommeD = $prodser[1]['sell']; + $SommeE = $prodser[1]['buy']; + $SommeF = $prodser[1]['none']; + $total = 0; + $dataval = array(); + $datalabels = array(); + $i = 0; + + $total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF; + $dataseries = array(); + if (!empty($conf->product->enabled)) + { + $dataseries[] = array($langs->trans("ProductsOnSale"), round($SommeA)); + $dataseries[] = array($langs->trans("ProductsOnPurchase"), round($SommeB)); + $dataseries[] = array($langs->trans("ProductsNotOnSell"), round($SommeC)); + } + if (!empty($conf->service->enabled)) + { + $dataseries[] = array($langs->trans("ServicesOnSale"), round($SommeD)); + $dataseries[] = array($langs->trans("ServicesOnPurchase"), round($SommeE)); + $dataseries[] = array($langs->trans("ServicesNotOnSell"), round($SommeF)); + } + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(0); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); + + print '
'; + print '
'; + } } @@ -270,120 +273,123 @@ print '
'; /* * Latest modified products */ -$max = 15; -$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,"; -$sql .= " p.entity,"; -$sql .= " p.tms as datem"; -$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; -$sql .= " WHERE p.entity IN (".getEntity($product_static->element, 1).")"; -if ($type != '') $sql .= " AND p.fk_product_type = ".$type; -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -$sql .= $db->order("p.tms", "DESC"); -$sql .= $db->plimit($max, 0); - -//print $sql; -$result = $db->query($sql); -if ($result) +if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) { - $num = $db->num_rows($result); + $max = 15; + $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,"; + $sql .= " p.entity,"; + $sql .= " p.tms as datem"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= " WHERE p.entity IN (".getEntity($product_static->element, 1).")"; + if ($type != '') $sql .= " AND p.fk_product_type = ".$type; + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $sql .= $db->order("p.tms", "DESC"); + $sql .= $db->plimit($max, 0); - $i = 0; - - if ($num > 0) + //print $sql; + $result = $db->query($sql); + if ($result) { - $transRecordedType = $langs->trans("LastModifiedProductsAndServices", $max); - if (isset($_GET["type"]) && $_GET["type"] == 0) $transRecordedType = $langs->trans("LastRecordedProducts", $max); - if (isset($_GET["type"]) && $_GET["type"] == 1) $transRecordedType = $langs->trans("LastRecordedServices", $max); + $num = $db->num_rows($result); - print '
'; - print ''; + $i = 0; - $colnb = 2; - if (empty($conf->global->PRODUIT_MULTIPRICES)) $colnb++; - - print ''; - print ''; - - while ($i < $num) + if ($num > 0) { - $objp = $db->fetch_object($result); + $transRecordedType = $langs->trans("LastModifiedProductsAndServices", $max); + if (isset($_GET["type"]) && $_GET["type"] == 0) $transRecordedType = $langs->trans("LastRecordedProducts", $max); + if (isset($_GET["type"]) && $_GET["type"] == 1) $transRecordedType = $langs->trans("LastRecordedServices", $max); - $product_static->id = $objp->rowid; - $product_static->ref = $objp->ref; - $product_static->label = $objp->label; - $product_static->type = $objp->fk_product_type; - $product_static->entity = $objp->entity; - $product_static->status = $objp->tosell; - $product_static->status_buy = $objp->tobuy; - $product_static->status_batch = $objp->tobatch; + print '
'; + print '
'.$transRecordedType.''.$langs->trans("FullList").''; - print '
'; - //Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) + $colnb = 2; + if (empty($conf->global->PRODUIT_MULTIPRICES)) $colnb++; + + print ''; + print ''; + + while ($i < $num) { - $sql = "SELECT label"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql .= " WHERE fk_product=".$objp->rowid; - $sql .= " AND lang='".$langs->getDefaultLang()."'"; + $objp = $db->fetch_object($result); - $resultd = $db->query($sql); - if ($resultd) + $product_static->id = $objp->rowid; + $product_static->ref = $objp->ref; + $product_static->label = $objp->label; + $product_static->type = $objp->fk_product_type; + $product_static->entity = $objp->entity; + $product_static->status = $objp->tosell; + $product_static->status_buy = $objp->tobuy; + $product_static->status_batch = $objp->tobatch; + + //Multilangs + if (!empty($conf->global->MAIN_MULTILANGS)) { - $objtp = $db->fetch_object($resultd); - if ($objtp && $objtp->label != '') $objp->label = $objtp->label; + $sql = "SELECT label"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$objp->rowid; + $sql .= " AND lang='".$langs->getDefaultLang()."'"; + + $resultd = $db->query($sql); + if ($resultd) + { + $objtp = $db->fetch_object($resultd); + if ($objtp && $objtp->label != '') $objp->label = $objtp->label; + } } - } - print ''; - print '\n"; - print ''; - print ""; - // Sell price - if (empty($conf->global->PRODUIT_MULTIPRICES)) - { - if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) - { - $product = new Product($db); - $product->fetch($objp->rowid); - $priceparser = new PriceParser($db); - $price_result = $priceparser->parseProduct($product); - if ($price_result >= 0) { - $objp->price = $price_result; - } - } - print ''; + print ''; + print '\n"; + print ''; + print ""; + // Sell price + if (empty($conf->global->PRODUIT_MULTIPRICES)) + { + if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) + { + $product = new Product($db); + $product->fetch($objp->rowid); + $priceparser = new PriceParser($db); + $price_result = $priceparser->parseProduct($product); + if ($price_result >= 0) { + $objp->price = $price_result; + } + } + print ''; + } + print '"; + print '"; + print "\n"; + $i++; } - print '"; - print '"; - print "\n"; - $i++; + + $db->free($result); + + print "
'.$transRecordedType.''.$langs->trans("FullList").''; + print '
'; - print $product_static->getNomUrl(1, '', 16); - print "'.dol_trunc($objp->label, 32).'"; - print dol_print_date($db->jdate($objp->datem), 'day'); - print "'; - if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); - else print price($objp->price).' '.$langs->trans("HT"); - print '
'; + print $product_static->getNomUrl(1, '', 16); + print "'.dol_trunc($objp->label, 32).'"; + print dol_print_date($db->jdate($objp->datem), 'day'); + print "'; + if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); + else print price($objp->price).' '.$langs->trans("HT"); + print ''; + print $product_static->LibStatut($objp->tosell, 3, 0); + print "'; + print $product_static->LibStatut($objp->tobuy, 3, 1); + print "
'; - print $product_static->LibStatut($objp->tosell, 3, 0); - print "'; - print $product_static->LibStatut($objp->tobuy, 3, 1); - print "
"; + print '
'; + print '
'; } - - $db->free($result); - - print ""; - print '
'; - print '
'; } -} -else -{ - dol_print_error($db); + else + { + dol_print_error($db); + } } From 2dd1e34c2d95a6805d9c328f5e2c2042e44f64ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 19:01:31 +0100 Subject: [PATCH 32/68] Fix phpcs --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 43cad658efd..e7cd695dc0b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8070,7 +8070,7 @@ class Form $ret .= ''; } else { - $ret .= ''; + $ret .= ''; } } } From aa54aaeb01274dcabc972d2e4456533ad4c73827 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Jan 2020 19:46:03 +0100 Subject: [PATCH 33/68] FIX search filter on extrafields were not restored avec "Back to list" --- htdocs/core/lib/functions.lib.php | 49 ++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5bc3ad0056c..a0db5c8333d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -224,7 +224,54 @@ function dol_shutdown() */ function GETPOSTISSET($paramname) { - return (isset($_POST[$paramname]) || isset($_GET[$paramname])); + $isset = 0; + + $relativepathstring = $_SERVER["PHP_SELF"]; + // Clean $relativepathstring + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'), '/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + //var_dump($relativepathstring); + //var_dump($user->default_values); + + // Code for search criteria persistence. + // Retrieve values if restore_lastsearch_values + if (!empty($_GET['restore_lastsearch_values'])) // Use $_GET here and not GETPOST + { + if (!empty($_SESSION['lastsearch_values_'.$relativepathstring])) // If there is saved values + { + $tmp = json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true); + if (is_array($tmp)) + { + foreach ($tmp as $key => $val) + { + if ($key == $paramname) // We are on the requested parameter + { + $isset = 1; + break; + } + } + } + } + // If there is saved contextpage, page or limit + if ($paramname == 'contextpage' && !empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) + { + $isset = 1; + } + elseif ($paramname == 'page' && !empty($_SESSION['lastsearch_page_'.$relativepathstring])) + { + $isset = 1; + } + elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_'.$relativepathstring])) + { + $isset = 1; + } + } + else { + $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname])); + } + + return $isset; } /** From 0229cd3c6587720f210faa5ecacc07c597170cd6 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 1 Feb 2020 08:18:48 +0100 Subject: [PATCH 34/68] FIX: FEC export have specific name --- htdocs/accountancy/tpl/export_journal.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index 97f0da548ca..d2961670923 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -35,7 +35,7 @@ $endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d'); header('Content-Type: text/csv'); -if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == "11" && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger +if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == "1000" && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger { // FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle if (empty($search_date_end)) From e8b9ca3276bfb3f2fc72fa01ba4ff5fa09c60c45 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 1 Feb 2020 08:23:19 +0100 Subject: [PATCH 35/68] FIX: FEC export have specific name --- htdocs/accountancy/tpl/export_journal.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index 5c9f7ad48ed..0dec55630d3 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -35,7 +35,7 @@ $endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d'); header('Content-Type: text/csv'); -if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == "11" && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger +if ($this->getFormatCode($formatexportset) == "fec" && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger { // FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle if (empty($search_date_end)) From ec649bc0a3554ad7fcb4e4cc413be3397f260432 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 1 Feb 2020 10:09:31 +0100 Subject: [PATCH 36/68] Fix CSS --- htdocs/support/default.css | 20 ++++++++++++++++++-- htdocs/support/inc.php | 13 +++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/htdocs/support/default.css b/htdocs/support/default.css index c0d99f56657..735224254d3 100644 --- a/htdocs/support/default.css +++ b/htdocs/support/default.css @@ -23,6 +23,22 @@ background: #f9f9f9; margin: 5px 5px; } +.center { + text-align: center; +} + +.centpercent { + width: 100%; +} + +.valignmiddle { + vertical-align: middle; +} + +inline-block { + display: inline-block; +} + div.titre { padding: 5px 5px 5px 5px; margin: 0 0 0 0; @@ -147,10 +163,10 @@ padding: 4px 4px 4px 4px; tr.title { -background: #DDDFDD; +background: #EEEEEE; } -table.login { border: 1px solid #C0C0C0; background: #FFF; } +table.login { border: 1px solid #E0E0E0; background: #FFF; } .tablesupport { padding: 6px; diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php index dd369e233b9..941bf6bb0d3 100644 --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -223,15 +223,12 @@ function pHeader($soutitre, $next, $action = 'none') print ''.$langs->trans("DolibarrHelpCenter").''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; - print ''; - print ''; - print '
'; - print 'logohelpcenter'; - print ''; - print ''.$soutitre.''."\n"; - print '
'; + print '
'; + print 'logohelpcenter

'; + print ''.$soutitre.''."\n"; + print '

'; } /** From e59d118b8cfb3d7b9f6a83634c5f0189370d3d80 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 2 Feb 2020 06:36:06 +0100 Subject: [PATCH 37/68] Fix project loan data --- htdocs/loan/class/loan.class.php | 2 +- htdocs/projet/element.php | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 586b6b59036..f655b3adcb2 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -556,7 +556,7 @@ class Loan extends CommonObject $table = 'payment_loan'; $field = 'fk_loan'; - $sql = 'SELECT sum(amount) as amount'; + $sql = 'SELECT sum(amount_capital) as amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.$table; $sql .= ' WHERE '.$field.' = '.$this->id; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 9be63cad242..9b49f2814a9 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -829,11 +829,13 @@ foreach ($listofreferent as $key => $value) // Amount HT //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("AmountHT").''; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''.$langs->trans("Amount").''; - if (empty($value['disableamount'])) print ''.$langs->trans("AmountHT").''; + if ($key == 'loan') print ''.$langs->trans("LoanCapital").''; + elseif (empty($value['disableamount'])) print ''.$langs->trans("AmountHT").''; else print ''; // Amount TTC //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("AmountTTC").''; - if (empty($value['disableamount'])) print ''.$langs->trans("AmountTTC").''; + if ($key == 'loan') print ''.$langs->trans("RemainderToPay").''; + elseif (empty($value['disableamount'])) print ''.$langs->trans("AmountTTC").''; else print ''; // Status if (in_array($tablename, array('projet_task'))) print ''.$langs->trans("ProgressDeclared").''; @@ -928,6 +930,10 @@ foreach ($listofreferent as $key => $value) print $element->getNomUrl(1, 'withproject', 'time'); print ' - '.dol_trunc($element->label, 48); } + elseif ($key == 'loan'){ + print $element->getNomUrl(1); + print ' - '.dol_trunc($element->label, 48); + } else print $element->getNomUrl(1); $element_doc = $element->element; @@ -977,6 +983,10 @@ foreach ($listofreferent as $key => $value) if (empty($date)) $date = $element->datev; } } + elseif ($key == 'loan'){ + $date = $element->datestart; + } + print ''; if ($tablename == 'actioncomm') { @@ -1050,6 +1060,7 @@ foreach ($listofreferent as $key => $value) $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } + elseif ($key == 'loan') $total_ht_by_line = $element->capital; else { $total_ht_by_line = $element->total_ht; @@ -1097,6 +1108,7 @@ foreach ($listofreferent as $key => $value) $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } + elseif ($key == 'loan') $total_ttc_by_line = $element->capital - $element->getSumPayment(); else { $total_ttc_by_line = $element->total_ttc; @@ -1204,7 +1216,8 @@ foreach ($listofreferent as $key => $value) print ''; if (empty($value['disableamount'])) { - if ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); + if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("LoanCapital").' : '.price($total_ttc); + elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); } print ''; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("TotalTTC").' : '.price($total_ttc).''; @@ -1212,7 +1225,8 @@ foreach ($listofreferent as $key => $value) print ''; if (empty($value['disableamount'])) { - if ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); + if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("RemainderToPay").' : '.price($total_ttc); + elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); } print ''; print ' '; From fe009c384251396429c75adebf35beda0339df95 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 2 Feb 2020 09:06:02 +0100 Subject: [PATCH 38/68] Fix project profit for loan part --- htdocs/projet/class/project.class.php | 15 ++++++++++++-- htdocs/projet/element.php | 30 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 54d13a51549..746fdacd381 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -607,18 +607,29 @@ class Project extends CommonObject { $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$ids.") AND ms.type_mouvement = 1"; } + elseif ($type == 'loan') + { + $sql = 'SELECT l.rowid, l.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').")"; + } else { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$ids.") AND entity IN (".getEntity($type).")"; } - if ($dates > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table + if($dates > 0 && $type == 'loan'){ + $sql .= " AND (dateend > '".$this->db->idate($dates)."' OR dateend IS NULL)"; + } + elseif ($dates > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table { if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date; if (empty($datefieldname)) return 'Error this object has no date field defined'; $sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; } - if ($datee > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table + + if($datee > 0 && $type == 'loan'){ + $sql .= " AND (datestart < '".$this->db->idate($datee)."' OR datestart IS NULL)"; + } + elseif ($datee > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table { if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date; if (empty($datefieldname)) return 'Error this object has no date field defined'; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 9b49f2814a9..2aa112bd722 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -49,6 +49,7 @@ if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/exp if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; if (! empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; @@ -650,6 +651,32 @@ foreach ($listofreferent as $key => $value) $total_ht_by_line = price2num($tmp['amount'], 'MT'); } } + elseif ($key == 'loan'){ + if((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)){ + // Get total loan + $total_ht_by_line = -$element->capital; + } + else{ + // Get loan schedule according to date filter + $total_ht_by_line = 0; + $loanScheduleStatic = new LoanSchedule($element->db); + $loanScheduleStatic->fetchAll($element->id); + if(!empty($loanScheduleStatic->lines)){ + foreach($loanScheduleStatic->lines as $loanSchedule){ + /** + * @var $loanSchedule LoanSchedule + */ + if( ($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee) // dates filter is defined + || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <= dol_now() + || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee + ){ + $total_ht_by_line = -$loanSchedule->amount_capital; + } + } + } + } + + } else $total_ht_by_line = $element->total_ht; // Define $total_ttc_by_line @@ -661,6 +688,9 @@ foreach ($listofreferent as $key => $value) $defaultvat = get_default_tva($mysoc, $mysoc); $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); } + elseif ($key == 'loan'){ + $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr + } else $total_ttc_by_line = $element->total_ttc; // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases From 01b1667eedc9683a7fa36a9a6a4d585cd4d13823 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 2 Feb 2020 08:13:09 +0000 Subject: [PATCH 39/68] Fixing style errors. --- htdocs/projet/element.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 2aa112bd722..dd89b3ca9c4 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -675,7 +675,6 @@ foreach ($listofreferent as $key => $value) } } } - } else $total_ht_by_line = $element->total_ht; From bd322dc12e43d955d74d28f6e8957cd4950d271d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Feb 2020 12:59:11 +0100 Subject: [PATCH 40/68] Fix search on country --- htdocs/admin/dict.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index af07dc9bfc6..d634f547ff9 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -58,6 +58,7 @@ if ($id == 10 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1 if ($id == 17 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Dictionary with type of expense report and accounting account allowed to manager of chart account if (!$allowed) accessforbidden(); +$acts =array(); $actl =array(); $acts[0] = "activate"; $acts[1] = "disable"; $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off'); @@ -76,7 +77,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; $search_country_id = GETPOST('search_country_id', 'int'); -if ($search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only. +if (! GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only. { $search_country_id = $mysoc->country_id; } @@ -178,7 +179,7 @@ $tablib[38] = "DictionarySocialNetworks"; $tabsql = array(); $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid"; $tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1"; -$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1"; +$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as state_code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1"; $tabsql[4] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.favorite FROM ".MAIN_DB_PREFIX."c_country AS c"; $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c"; $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a"; @@ -759,12 +760,13 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]); } if ($i) $sql .= ","; + if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position' { - $sql .= "'".(int) $db->escape($_POST['position'])."'"; + $sql .= "'".(int) $db->escape(GETPOST('position'))."'"; } elseif ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = '' - else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + else $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i], 'nohtml'))."'"; $i++; } $sql .= ",1)"; @@ -1011,6 +1013,7 @@ if ($id) if ($search_code != '' && $id == 9) $sql .= natural_search("code_iso", $search_code); elseif ($search_code != '' && $id == 28) $sql .= natural_search("h.code", $search_code); elseif ($search_code != '' && $id == 32) $sql .= natural_search("a.code", $search_code); + elseif ($search_code != '' && $id == 3) $sql .= natural_search("r.code_region", $search_code); elseif ($search_code != '' && $id != 9) $sql .= natural_search("code", $search_code); if ($sortfield) @@ -1146,7 +1149,7 @@ if ($id) if ($fieldlist[$field] == 'revenuestamp_type') { $valuetoshow = $langs->trans('TypeOfRevenueStamp'); } if ($fieldlist[$field] == 'use_default') { $valuetoshow = $langs->trans('Default'); } - if ($id == 2) // Special cas for state page + if ($id == 2) // Special case for state page { if ($fieldlist[$field] == 'region_id') { $valuetoshow = ' '; $showfield = 1; } if ($fieldlist[$field] == 'region') { $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region"); $showfield = 1; } @@ -1228,6 +1231,7 @@ if ($id) // List of available record in database dol_syslog("htdocs/admin/dict", LOG_DEBUG); + $resql = $db->query($sql); if ($resql) { @@ -1620,7 +1624,9 @@ if ($id) $key = $langs->trans($obj->label); $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$fieldlist[$field]}); } - + elseif ($fieldlist[$field] == 'code' && $id == 3) { + $valuetoshow = $obj->state_code; + } $class .= ($class ? ' ' : '').'tddict'; if ($fieldlist[$field] == 'note' && $id == 10) $class .= ' tdoverflowmax200'; if ($fieldlist[$field] == 'tracking') $class .= ' tdoverflowauto'; From 4c2c2461f949e0998175213319b93d58287c67dd Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 2 Feb 2020 14:43:46 +0100 Subject: [PATCH 41/68] NEW : Add French association chart of accounts 2018 --- .../mysql/data/llx_accounting_account_fr.sql | 219 ++++++++++-------- 1 file changed, 117 insertions(+), 102 deletions(-) diff --git a/htdocs/install/mysql/data/llx_accounting_account_fr.sql b/htdocs/install/mysql/data/llx_accounting_account_fr.sql index 601a772901c..8f64f5d108b 100644 --- a/htdocs/install/mysql/data/llx_accounting_account_fr.sql +++ b/htdocs/install/mysql/data/llx_accounting_account_fr.sql @@ -28,7 +28,7 @@ -- ID 0 - 438 -- ID 1501 - 5999 --- ID +-- ID 7000 - 7208 -- ADD 100000 to rowid # Do no remove this comment -- INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 1401,'PCG99-ABREGE','CAPIT', 'XXXXXX', '1', '0', 'Fonds propres, provisions pour risques et charges et dettes à plus d''un an', 1); @@ -1480,105 +1480,120 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7206,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '6', '0', 'Charges', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7207,'PCG18-ASSOC','INCOME', 'XXXXXX', '7', '0', 'Produits', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7208,'PCG18-ASSOC','SPECIAL', 'XXXXXX', '8', '0', 'Comptes spéciaux', 1); + INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7000,'PCG18-ASSOC','CAPIT', 'XXXXXX', '10', '7201', 'Fonds propres et réserves', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7001,'PCG18-ASSOC','CAPIT', 'XXXXXX', '102', '7201', 'Fonds propres sans droit de reprise', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7002,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1021', '7201', 'Première situation nette établie', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7003,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1022', '7201', 'Fonds statutaires (à subdiviser en fonction des statuts)', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7004,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1023', '7201', 'Dotations non consomptibles', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7005,'PCG18-ASSOC','CAPIT', 'XXXXXX','10231', '7201', 'Dotations non consomptibles initiales', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7006,'PCG18-ASSOC','CAPIT', 'XXXXXX','10232', '7201', 'Dotations non consomptibles complémentaires', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7007,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1024', '7201', 'Autres fonds propres sans droit de reprise', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7008,'PCG18-ASSOC','CAPIT', 'XXXXXX', '103', '7201', 'Fonds propres avec droit de reprise', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7009,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1032', '7201', 'Fonds statutaires (à subdiviser en fonction des statuts)', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7010,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1034', '7201', 'Autres fonds propres avec droit de reprise', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7011,'PCG18-ASSOC','CAPIT', 'XXXXXX', '105', '7201', 'Ecarts de réévaluation', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7012,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1051', '7201', 'Ecarts de réévaluation sur des biens sans droit de reprise', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7013,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1052', '7201', 'Ecarts de réévaluation sur des biens avec droit de reprise', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7014,'PCG18-ASSOC','CAPIT', 'XXXXXX', '106', '7201', 'Réserves', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7015,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1068', '7201', 'Réserves pour projetde l’entité', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7016,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '206', '15', 'Droit au bail', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7017,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '207', '15', 'Fonds commercial', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7018,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '208', '15', 'Autres immobilisations incorporelles', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7019,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '21', '1402', 'Immobilisations corporelles', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7020,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '23', '1402', 'Immobilisations en cours', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7021,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '27', '1402', 'Autres immobilisations financieres', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7022,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '280', '1402', 'Amortissements des immobilisations incorporelles', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 24,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '281', '1402', 'Amortissements des immobilisations corporelles', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 25,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '290', '1402', 'Provisions pour dépréciation des immobilisations incorporelles', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 26,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '291', '1402', 'Provisions pour dépréciation des immobilisations corporelles', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 27,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '297', '1402', 'Provisions pour dépréciation des autres immobilisations financières', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 28,'PCG18-ASSOC','STOCK', 'XXXXXX', '31', '1403', 'Matieres premières', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 29,'PCG18-ASSOC','STOCK', 'XXXXXX', '32', '1403', 'Autres approvisionnements', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 30,'PCG18-ASSOC','STOCK', 'XXXXXX', '33', '1403', 'En-cours de production de biens', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 31,'PCG18-ASSOC','STOCK', 'XXXXXX', '34', '1403', 'En-cours de production de services', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 32,'PCG18-ASSOC','STOCK', 'XXXXXX', '35', '1403', 'Stocks de produits', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 33,'PCG18-ASSOC','STOCK', 'XXXXXX', '37', '1403', 'Stocks de marchandises', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 34,'PCG18-ASSOC','STOCK', 'XXXXXX', '391', '1403', 'Provisions pour dépréciation des matières premières', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 35,'PCG18-ASSOC','STOCK', 'XXXXXX', '392', '1403', 'Provisions pour dépréciation des autres approvisionnements', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 36,'PCG18-ASSOC','STOCK', 'XXXXXX', '393', '1403', 'Provisions pour dépréciation des en-cours de production de biens', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 37,'PCG18-ASSOC','STOCK', 'XXXXXX', '394', '1403', 'Provisions pour dépréciation des en-cours de production de services', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 38,'PCG18-ASSOC','STOCK', 'XXXXXX', '395', '1403', 'Provisions pour dépréciation des stocks de produits', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 39,'PCG18-ASSOC','STOCK', 'XXXXXX', '397', '1403', 'Provisions pour dépréciation des stocks de marchandises', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 40,'PCG18-ASSOC','THIRDPARTY', 'SUPPLIER', '400', '1404', 'Fournisseurs et Comptes rattachés', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 41,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '409', '1404', 'Fournisseurs débiteurs', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 42,'PCG18-ASSOC','THIRDPARTY', 'CUSTOMER', '410', '1404', 'Clients et Comptes rattachés', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 43,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '419', '1404', 'Clients créditeurs', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 44,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '421', '1404', 'Personnel', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 45,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '428', '1404', 'Personnel', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 46,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '43', '1404', 'Sécurité sociale et autres organismes sociaux', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 47,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '444', '1404', 'Etat - impôts sur bénéfice', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 48,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '445', '1404', 'Etat - Taxes sur chiffre affaires', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 49,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '447', '1404', 'Autres impôts, taxes et versements assimilés', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 50,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '45', '1404', 'Groupe et associes', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 51,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '455', '50', 'Associés', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 52,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '46', '1404', 'Débiteurs divers et créditeurs divers', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 53,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '47', '1404', 'Comptes transitoires ou d''attente', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 54,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '481', '1404', 'Charges à répartir sur plusieurs exercices', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 55,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '486', '1404', 'Charges constatées d''avance', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 56,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '487', '1404', 'Produits constatés d''avance', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 57,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '491', '1404', 'Provisions pour dépréciation des comptes de clients', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 58,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '496', '1404', 'Provisions pour dépréciation des comptes de débiteurs divers', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 59,'PCG18-ASSOC','FINAN', 'XXXXXX', '50', '1405', 'Valeurs mobilières de placement', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 60,'PCG18-ASSOC','FINAN', 'BANK', '51', '1405', 'Banques, établissements financiers et assimilés', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 61,'PCG18-ASSOC','FINAN', 'CASH', '53', '1405', 'Caisse', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 62,'PCG18-ASSOC','FINAN', 'XXXXXX', '54', '1405', 'Régies d''avance et accréditifs', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 63,'PCG18-ASSOC','FINAN', 'XXXXXX', '58', '1405', 'Virements internes', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 64,'PCG18-ASSOC','FINAN', 'XXXXXX', '590', '1405', 'Provisions pour dépréciation des valeurs mobilières de placement', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 65,'PCG18-ASSOC','EXPENSE','PRODUCT', '60', '1406', 'Achats', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 66,'PCG18-ASSOC','EXPENSE','XXXXXX', '603', '65', 'Variations des stocks', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 67,'PCG18-ASSOC','EXPENSE','SERVICE', '61', '1406', 'Services extérieurs', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 68,'PCG18-ASSOC','EXPENSE','XXXXXX', '62', '1406', 'Autres services extérieurs', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 69,'PCG18-ASSOC','EXPENSE','XXXXXX', '63', '1406', 'Impôts, taxes et versements assimiles', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 70,'PCG18-ASSOC','EXPENSE','SALARY', '641', '1406', 'Rémunérations du personnel', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 71,'PCG18-ASSOC','EXPENSE','SALARY', '644', '1406', 'Rémunération du travail de l''exploitant', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 72,'PCG18-ASSOC','EXPENSE','SOCIAL', '645', '1406', 'Charges de sécurité sociale et de prévoyance', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 73,'PCG18-ASSOC','EXPENSE','XXXXXX', '646', '1406', 'Cotisations sociales personnelles de l''exploitant', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 74,'PCG18-ASSOC','EXPENSE','XXXXXX', '65', '1406', 'Autres charges de gestion courante', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 75,'PCG18-ASSOC','EXPENSE','XXXXXX', '66', '1406', 'Charges financières', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 76,'PCG18-ASSOC','EXPENSE','XXXXXX', '67', '1406', 'Charges exceptionnelles', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 77,'PCG18-ASSOC','EXPENSE','XXXXXX', '681', '1406', 'Dotations aux amortissements et aux provisions', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 78,'PCG18-ASSOC','EXPENSE','XXXXXX', '686', '1406', 'Dotations aux amortissements et aux provisions', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 79,'PCG18-ASSOC','EXPENSE','XXXXXX', '687', '1406', 'Dotations aux amortissements et aux provisions', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 80,'PCG18-ASSOC','EXPENSE','XXXXXX', '691', '1406', 'Participation des salariés aux résultats', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 81,'PCG18-ASSOC','EXPENSE','TAX', '695', '1406', 'Impôts sur les bénéfices', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 82,'PCG18-ASSOC','EXPENSE','TAX', '697', '1406', 'Imposition forfaitaire annuelle des sociétés', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 83,'PCG18-ASSOC','EXPENSE','XXXXXX', '699', '1406', 'Produits', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 84,'PCG18-ASSOC','INCOME', 'PRODUCT', '701', '1407', 'Ventes de produits finis', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 85,'PCG18-ASSOC','INCOME', 'SERVICE', '706', '1407', 'Prestations de services', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 86,'PCG18-ASSOC','INCOME', 'PRODUCT', '707', '1407', 'Ventes de marchandises', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 87,'PCG18-ASSOC','INCOME', 'SERVICE', '708', '1407', 'Produits des activités annexes', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 88,'PCG18-ASSOC','INCOME', 'XXXXXX', '709', '1407', 'Rabais, remises et ristournes accordés par l''entreprise', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 89,'PCG18-ASSOC','INCOME', 'XXXXXX', '713', '1407', 'Variation des stocks', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 90,'PCG18-ASSOC','INCOME', 'XXXXXX', '72', '1407', 'Production immobilisée', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 91,'PCG18-ASSOC','INCOME', 'XXXXXX', '73', '1407', 'Produits nets partiels sur opérations à long terme', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 92,'PCG18-ASSOC','INCOME', 'XXXXXX', '74', '1407', 'Subventions d''exploitation', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 93,'PCG18-ASSOC','INCOME', 'XXXXXX', '75', '1407', 'Autres produits de gestion courante', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 94,'PCG18-ASSOC','INCOME', 'XXXXXX', '753', '93', 'Jetons de présence et rémunérations d''administrateurs, gérants,...', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 95,'PCG18-ASSOC','INCOME', 'XXXXXX', '754', '93', 'Ristournes perçues des coopératives', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 96,'PCG18-ASSOC','INCOME', 'XXXXXX', '755', '93', 'Quotes-parts de résultat sur opérations faites en commun', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 97,'PCG18-ASSOC','INCOME', 'FIN', '76', '1407', 'Produits financiers', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 98,'PCG18-ASSOC','INCOME', 'XXXXXX', '77', '1407', 'Produits exceptionnels', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 99,'PCG18-ASSOC','INCOME', 'XXXXXX', '781', '1407', 'Reprises sur amortissements et provisions', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 100,'PCG18-ASSOC','INCOME', 'XXXXXX', '786', '1407', 'Reprises sur provisions pour risques', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 101,'PCG18-ASSOC','INCOME', 'XXXXXX', '787', '1407', 'Reprises sur provisions', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 102,'PCG18-ASSOC','INCOME', 'XXXXXX', '79', '1407', 'Transferts de charges', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7001,'PCG18-ASSOC','CAPIT', 'XXXXXX', '102', '7000', 'Fonds propres sans droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7002,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1021', '7001', 'Première situation nette établie', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7003,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1022', '7001', 'Fonds statutaires (à subdiviser en fonction des statuts)', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7004,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1023', '7001', 'Dotations non consomptibles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7005,'PCG18-ASSOC','CAPIT', 'XXXXXX','10231', '7004', 'Dotations non consomptibles initiales', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7006,'PCG18-ASSOC','CAPIT', 'XXXXXX','10232', '7004', 'Dotations non consomptibles complémentaires', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7007,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1024', '7001', 'Autres fonds propres sans droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7008,'PCG18-ASSOC','CAPIT', 'XXXXXX', '103', '7000', 'Fonds propres avec droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7009,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1032', '7008', 'Fonds statutaires (à subdiviser en fonction des statuts)', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7010,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1034', '7008', 'Autres fonds propres avec droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7011,'PCG18-ASSOC','CAPIT', 'XXXXXX', '105', '7000', 'Ecarts de réévaluation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7012,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1051', '7011', 'Ecarts de réévaluation sur des biens sans droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7013,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1052', '7011', 'Ecarts de réévaluation sur des biens avec droit de reprise', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7014,'PCG18-ASSOC','CAPIT', 'XXXXXX', '106', '7000', 'Réserves', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7015,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1068', '7014', 'Réserves pour projet de l’entité', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7016,'PCG18-ASSOC','CAPIT', 'XXXXXX', '108', '7000', 'Dotations consomptibles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7017,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1081', '7016', 'Dotations consomptibles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7018,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1089', '7016', 'Dotations consomptibles inscrites au compte de résultat', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7019,'PCG18-ASSOC','CAPIT', 'XXXXXX', '15', '7201', 'Provisions', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7020,'PCG18-ASSOC','CAPIT', 'XXXXXX', '152', '7019', 'Provisions pour charges sur legs ou donations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7021,'PCG18-ASSOC','CAPIT', 'XXXXXX', '16', '7201', 'Emprunts et dettes assimilées', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7022,'PCG18-ASSOC','CAPIT', 'XXXXXX', '163', '7021', 'Autres emprunts obligataires', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7023,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1631', '7022', 'Titres associatifs et assimilés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7024,'PCG18-ASSOC','CAPIT', 'XXXXXX', '19', '7201', 'Fonds dédiés ou reportés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7025,'PCG18-ASSOC','CAPIT', 'XXXXXX', '191', '7024', 'Fonds reportés liés aux legs ou donations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7026,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1911', '7025', 'Legs ou donations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7027,'PCG18-ASSOC','CAPIT', 'XXXXXX', '1912', '7025', 'Donations temporaires d’usufruit', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7028,'PCG18-ASSOC','CAPIT', 'XXXXXX', '194', '7024', 'Fonds dédiés sur subventions d’exploitation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7029,'PCG18-ASSOC','CAPIT', 'XXXXXX', '195', '7024', 'Fonds dédiés sur contributions financières d’autres organismes', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7030,'PCG18-ASSOC','CAPIT', 'XXXXXX', '196', '7024', 'Fonds dédiés sur ressources liées à la générosité du public', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7031,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '20', '7202', 'Immobilisations incorporelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7032,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '204', '7031', 'Donations temporaires d’usufruit', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7033,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '24', '7202', 'Biens reçus par legs ou donations destinés à être cédés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7034,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '27', '7202', 'Autres immobilisations financières', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7035,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '2742', '7034', 'Prêts aux partenaires', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7036,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '28', '7202', 'Amortissements des immobilisations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7037,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '280', '7036', 'Amortissements des immobilisations incorporelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7038,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '2804', '7037', 'Donations temporaires d’usufruit', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7039,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '29', '7202', 'Dépréciations des immobilisations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7040,'PCG18-ASSOC', 'IMMO', 'XXXXXX', '294', '7039', 'Dépréciationsdes biens reçus par legs ou donations destinés à être cédés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7041,'PCG18-ASSOC','THIRDPARTY','CUSTOMER', '41', '7204', 'Clients, adhérents, usagers et comptes rattachés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7042,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '45', '7204', 'Confédération, fédération, union, entités affiliées', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7043,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '455', '7042', 'Partenaires - comptes courants', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7044,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '46', '7204', 'Débiteurs et créditeurs divers', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7045,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '461', '7044', 'Créances reçues par legs ou donations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7046,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '466', '7044', 'Dettes des legs ou donations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7047,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '468', '7044', 'Divers – charges à payer et produits à recevoir', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7048,'PCG18-ASSOC','THIRDPARTY', 'XXXXXX', '4681', '7047', 'Frais des bénévoles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7049,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '62', '7206', 'Autres services extérieurs', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7050,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '622', '7049', 'Rémunérations d’intermédiaires et honoraires', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7051,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '6226', '7050', 'Honoraires', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7052,'PCG18-ASSOC','EXPENSE', 'XXXXXX','62264', '7051', 'Honoraires sur legs ou donations destinés à être cédés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7053,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '65', '7206', 'Autres charges de gestion courante', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7054,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '653', '7053', 'Charges de la générosité du public', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7055,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '6531', '7054', 'Autres charges sur legs ou donations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7056,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '657', '7053', 'Aides financières', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7057,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '67', '7206', 'Charges exceptionnelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7058,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '673', '7057', 'Apports ou affectations en numéraire', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7059,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '675', '7057', 'Valeurs comptables des éléments d’actifs cédés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7060,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '6754', '7059', 'Immobilisations reçues par legs ou donations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7061,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '68', '7206', 'Dotations aux amortissements, provisions et engagements', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7062,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '6816', '7061', 'Dotations pour dépréciations des immobilisations incorporelles et corporelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7063,'PCG18-ASSOC','EXPENSE', 'XXXXXX','68164', '7062', 'Dotations pour dépréciation d’actifs reçus par legs ou donations destinés à être cédés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7064,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '689', '7061', 'Reports en fonds dédiés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7065,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '6891', '7064', 'Reports en fonds reportés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7066,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '6894', '7064', 'Reports en fonds dédiés sur subventions d’exploitation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7067,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '6895', '7064', 'Reports en fonds dédiés sur contributions financières d’autres organismes', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7068,'PCG18-ASSOC','EXPENSE', 'XXXXXX', '6896', '7064', 'Reports en fonds dédiés sur ressources liées à la générosité du public', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7069,'PCG18-ASSOC','INCOME', 'XXXXXX', '70', '7207', 'Ventes de produits fabriqués, prestations de services, marchandises', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7070,'PCG18-ASSOC','INCOME', 'SERVICE', '706', '7069', 'Ventes de prestations de services', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7071,'PCG18-ASSOC','INCOME', 'SERVICE', '7063', '7070', 'Parrainages', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7072,'PCG18-ASSOC','INCOME', 'PRODUCT', '707', '7069', 'Ventes de marchandises', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7073,'PCG18-ASSOC','INCOME', 'PRODUCT', '7073', '7073', 'Ventes de dons en nature', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7074,'PCG18-ASSOC','INCOME', 'XXXXXX', '73', '7207', 'Concours publics', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7075,'PCG18-ASSOC','INCOME', 'XXXXXX', '75', '7207', 'Autres produits de gestion courante', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7076,'PCG18-ASSOC','INCOME', 'XXXXXX', '753', '7075', 'Versements des fondateurs ou consommation de la dotation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7077,'PCG18-ASSOC','INCOME', 'XXXXXX', '7531', '7076', 'Versements des fondateurs', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7078,'PCG18-ASSOC','INCOME', 'XXXXXX', '7532', '7076', 'Quotes-parts de dotation consomptible virée au compte de résultat', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7079,'PCG18-ASSOC','INCOME', 'XXXXXX', '754', '7075', 'Ressources liées à la générosité du public', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7080,'PCG18-ASSOC','INCOME', 'XXXXXX', '7541', '7079', 'Dons manuels', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7081,'PCG18-ASSOC','INCOME', 'XXXXXX','75411', '7080', 'Dons manuels', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7082,'PCG18-ASSOC','INCOME', 'XXXXXX','75412', '7080', 'Abandons de frais par les bénévoles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7083,'PCG18-ASSOC','INCOME', 'XXXXXX', '7542', '7079', 'Mécénats', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7084,'PCG18-ASSOC','INCOME', 'XXXXXX', '7543', '7079', 'Legs, donations et assurances-vie', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7085,'PCG18-ASSOC','INCOME', 'XXXXXX','75431', '7084', 'Assurances-vie', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7086,'PCG18-ASSOC','INCOME', 'XXXXXX','75432', '7084', 'Legs ou donations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7087,'PCG18-ASSOC','INCOME', 'XXXXXX','75433', '7084', 'Autres produits sur legs ou donations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7088,'PCG18-ASSOC','INCOME', 'XXXXXX', '755', '7075', 'Contributions financières', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7089,'PCG18-ASSOC','INCOME', 'XXXXXX', '7551', '7088', 'Contributions financières d’autres organismes', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7090,'PCG18-ASSOC','INCOME', 'XXXXXX', '7552', '7088', 'Quotes-parts de générosité reçues', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7091,'PCG18-ASSOC','INCOME', 'XXXXXX', '756', '7075', 'Cotisations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7092,'PCG18-ASSOC','INCOME', 'XXXXXX', '7561', '7091', 'Cotisations sans contrepartie', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7093,'PCG18-ASSOC','INCOME', 'XXXXXX', '7562', '7091', 'Cotisations avec contrepartie', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7094,'PCG18-ASSOC','INCOME', 'XXXXXX', '757', '7075', 'Gains de change sur créances et dettes d’exploitation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7095,'PCG18-ASSOC','INCOME', 'XXXXXX', '77', '7207', 'Produits exceptionnels', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7096,'PCG18-ASSOC','INCOME', 'XXXXXX', '775', '7095', 'Produits des cessions d’éléments d’actifs', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7097,'PCG18-ASSOC','INCOME', 'XXXXXX', '7754', '7096', 'Immobilisations reçues en legs ou donations destinées à être cédées', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7098,'PCG18-ASSOC','INCOME', 'XXXXXX', '78', '7207', 'Reprises sur amortissements, dépréciations et provisions', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7099,'PCG18-ASSOC','INCOME', 'XXXXXX', '781', '7098', 'Reprises sur amortissements des immobilisations dépréciations et provisions (à inscrire dans les produits d’exploitation)', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7100,'PCG18-ASSOC','INCOME', 'XXXXXX', '7816', '7099', 'Reprises sur dépréciations des immobilisations incorporelles et corporelles', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7101,'PCG18-ASSOC','INCOME', 'XXXXXX','78164', '7100', 'Reprises sur dépréciations d’actifs reçus par legs ou donations destinés à être cédés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7102,'PCG18-ASSOC','INCOME', 'XXXXXX', '789', '7098', 'Utilisations de fonds reportés et de fonds dédiés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7103,'PCG18-ASSOC','INCOME', 'XXXXXX', '7891', '7102', 'Utilisations de fonds reportés', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7104,'PCG18-ASSOC','INCOME', 'XXXXXX', '7894', '7102', 'Utilisations des fonds dédiés sur subventions d’exploitation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7105,'PCG18-ASSOC','INCOME', 'XXXXXX', '7895', '7102', 'Utilisations des fonds dédiés sur contributions financières d’autres organismes', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7106,'PCG18-ASSOC','INCOME', 'XXXXXX', '7896', '7102', 'Utilisations des fonds dédiés sur ressources liées à la générosité du public', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7107,'PCG18-ASSOC','INCOME', 'XXXXXX', '86', '7208', 'Emplois des contributions volontaires en nature', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7108,'PCG18-ASSOC','INCOME', 'XXXXXX', '860', '7107', 'Secours en nature', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7109,'PCG18-ASSOC','INCOME', 'XXXXXX', '861', '7107', 'Mises à disposition gratuite de biens', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7110,'PCG18-ASSOC','INCOME', 'XXXXXX', '862', '7107', 'Prestations', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7111,'PCG18-ASSOC','INCOME', 'XXXXXX', '864', '7107', 'Personnel bénévole', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7112,'PCG18-ASSOC','INCOME', 'XXXXXX', '87', '7208', 'Contributions volontaires en nature', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7113,'PCG18-ASSOC','INCOME', 'XXXXXX', '870', '7112', 'Dons en nature', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7114,'PCG18-ASSOC','INCOME', 'XXXXXX', '871', '7112', 'Prestations en nature', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (__ENTITY__, 7115,'PCG18-ASSOC','INCOME', 'XXXXXX', '875', '7112', 'Bénévolat', 1); \ No newline at end of file From 967d97ccd74935a65db7d04cbc6d5a8b1012dd28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Feb 2020 15:01:57 +0100 Subject: [PATCH 42/68] FIX CVE-2020-7994 --- htdocs/admin/company.php | 14 +++++++------- htdocs/admin/const.php | 2 +- htdocs/admin/defaultvalues.php | 24 ++++++++++++------------ htdocs/admin/translation.php | 19 +++++++++---------- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index ce75d83505a..df72e1bde04 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -95,15 +95,15 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency", 'aZ09'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("tel", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", GETPOST("mail", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB", GETPOST("web", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("tel", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", GETPOST("mail", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB", GETPOST("web", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE", GETPOST("note", 'none'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD", GETPOST("barcode", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD", GETPOST("barcode", 'alphanohtml'), 'chaine', 0, '', $conf->entity); $dirforimage = $conf->mycompany->dir_output.'/logos/'; diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index eed7f40910c..baeac243ce0 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -40,7 +40,7 @@ $update=GETPOST('update', 'alpha'); $delete=GETPOST('delete', 'none'); // Do not use alpha here $debug=GETPOST('debug', 'int'); $consts=GETPOST('const', 'array'); -$constname=GETPOST('constname', 'alpha'); +$constname=GETPOST('constname', 'alphanohtml'); $constvalue=GETPOST('constvalue', 'none'); // We shoul dbe able to send everything here $constnote=GETPOST('constnote', 'alpha'); diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 29043720dee..d6981448ea6 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2020 Laurent Destailleur * Copyright (C) 2017-2018 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -52,15 +52,15 @@ $pagenext = $page + 1; if (!$sortfield) $sortfield = 'page,param'; if (!$sortorder) $sortorder = 'ASC'; -$defaulturl = GETPOST('defaulturl'); -$defaultkey = GETPOST('defaultkey', 'alpha'); -$defaultvalue = GETPOST('defaultvalue'); +$defaulturl = GETPOST('defaulturl', 'alphanohtml'); +$defaultkey = GETPOST('defaultkey', 'alphanohtml'); +$defaultvalue = GETPOST('defaultvalue', 'none'); $defaulturl = preg_replace('/^\//', '', $defaulturl); -$urlpage = GETPOST('urlpage'); -$key = GETPOST('key'); -$value = GETPOST('value'); +$urlpage = GETPOST('urlpage', 'alphanohtml'); +$key = GETPOST('key', 'alphanohtml'); +$value = GETPOST('value', 'none'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admindefaultvalues', 'globaladmin')); @@ -210,9 +210,9 @@ print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'titl print ''.$langs->trans("DefaultValuesDesc")."
\n"; print "
\n"; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; -if ($optioncss != '') $param .= '&optioncss='.$optioncss; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl); if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey); if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue); @@ -359,7 +359,7 @@ if ($result) // Page print ''; - if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->page; + if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) print $obj->page; else print ''; print ''."\n"; @@ -378,7 +378,7 @@ if ($result) print ''; print ''; */ - if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->value; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print dol_escape_htmltag($obj->value); else print ''; print ''; } diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 5e98d7c5503..c641be11a59 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2020 Laurent Destailleur * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2017 Frédéric France * @@ -35,9 +35,9 @@ if (!$user->admin) accessforbidden(); $id = GETPOST('rowid', 'int'); $action = GETPOST('action', 'alpha'); -$langcode = GETPOST('langcode', 'alpha'); -$transkey = GETPOST('transkey', 'alpha'); -$transvalue = GETPOST('transvalue', 'alpha'); +$langcode = GETPOST('langcode', 'alphanohtml'); +$transkey = GETPOST('transkey', 'alphanohtml'); +$transvalue = GETPOST('transvalue', 'none'); $mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'overwrite'; @@ -190,7 +190,6 @@ if ($action == 'delete') - /* * View */ @@ -231,9 +230,9 @@ print ''.$form->textwithpicto($langs->trans("Current print '
'; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($optioncss != '') $param.='&optioncss='.$optioncss; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); if ($langcode) $param.='&langcode='.urlencode($langcode); if ($transkey) $param.='&transkey='.urlencode($transkey); if ($transvalue) $param.='&transvalue='.urlencode($transvalue); @@ -348,11 +347,11 @@ if ($mode == 'overwrite') */ if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) { - print ''; + print ''; } else { - print $obj->transvalue; + print dol_escape_htmltag($obj->transvalue); } print ''; From f741c9cd4280f5f88176f896281a19cc44321e82 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 2 Feb 2020 15:05:43 +0100 Subject: [PATCH 43/68] NEW : Add French association chart of accounts 2018 --- htdocs/install/mysql/data/llx_accounting_abc.sql | 2 +- htdocs/install/mysql/migration/11.0.0-12.0.0.sql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_accounting_abc.sql b/htdocs/install/mysql/data/llx_accounting_abc.sql index 7fc9b066244..be87c743c38 100644 --- a/htdocs/install/mysql/data/llx_accounting_abc.sql +++ b/htdocs/install/mysql/data/llx_accounting_abc.sql @@ -46,7 +46,7 @@ INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUE -- Description of chart of account FR PCG14-DEV INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG14-DEV', 'The developed accountancy french plan 2014', 1); -- Description of chart of account FR PCG18-ASSOC -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG18-ASSOC', 'French association chart of accounts 2018', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG18-ASSOC', 'French foundation chart of accounts 2018', 1); -- Description of chart of account BE PCMN-BASE INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 2, 'PCMN-BASE', 'The base accountancy belgium plan', 1); diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index c392f05fdd9..91b068a3fea 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -129,3 +129,4 @@ UPDATE llx_c_forme_juridique set libelle = 'SRL - Société à responsabilité l ALTER TABLE llx_c_country ADD COLUMN eec integer; UPDATE llx_c_country SET eec = 1 WHERE code IN ('AT','BE','BG','CY','CZ','DE','DK','EE','ES','FI','FR','GB','GR','HR','NL','HU','IE','IM','IT','LT','LU','LV','MC','MT','PL','PT','RO','SE','SK','SI','UK'); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG18-ASSOC', 'French foundation chart of accounts 2018', 1); \ No newline at end of file From 71b5e1daf9cf62c548d3c1f12d425164ba12cbb1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Feb 2020 15:57:41 +0100 Subject: [PATCH 44/68] FIX Log of authentication ko or ko --- htdocs/admin/system/browser.php | 7 +++++-- htdocs/core/lib/security2.lib.php | 2 +- htdocs/core/login/functions_dolibarr.php | 8 ++++---- htdocs/core/login/functions_ldap.php | 8 ++++---- htdocs/main.inc.php | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/system/browser.php b/htdocs/admin/system/browser.php index 5035c6c4a7d..cae6e568d65 100644 --- a/htdocs/admin/system/browser.php +++ b/htdocs/admin/system/browser.php @@ -49,12 +49,15 @@ $tmp=getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); print '
'; print ''; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 26e97499482..8d3adfa2df7 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -104,7 +104,7 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth } else { - dol_syslog("Authentification ko - failed to load file '".$authfile."'", LOG_ERR); + dol_syslog("Authentication KO - failed to load file '".$authfile."'", LOG_ERR); sleep(1); // Load translation files required by the page $langs->loadLangs(array('other', 'main', 'errors')); diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 7e5439fa66a..861c31a0e37 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -110,7 +110,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes else { sleep(2); // Anti brut force protection - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."', cryptType=".$cryptType); + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO bad password for '".$usertotest."', cryptType=".$cryptType, LOG_NOTICE); // Load translation files required by the page $langs->loadLangs(array('main', 'errors')); @@ -129,7 +129,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes $ret = $mc->checkRight($obj->rowid, $entitytotest); if ($ret < 0) { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '" . $entitytotest . "' not allowed for user '" . $obj->rowid . "'"); + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO entity '" . $entitytotest . "' not allowed for user '" . $obj->rowid . "'", LOG_NOTICE); $login = ''; // force authentication failure } } @@ -137,7 +137,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes } else { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko user not found for '".$usertotest."'"); + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO user not found for '".$usertotest."'", LOG_NOTICE); sleep(1); // Load translation files required by the page @@ -148,7 +148,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes } else { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko db error for '".$usertotest."' error=".$db->lasterror()); + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO db error for '".$usertotest."' error=".$db->lasterror(), LOG_ERR); sleep(1); $_SESSION["dol_loginmesg"]=$db->lasterror(); } diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index 63a4c6d01e6..81bbfdf5b84 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -52,7 +52,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) if (! function_exists("ldap_connect")) { - dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP. LDAP functions are disabled on this PHP"); + dol_syslog("functions_ldap::check_user_password_ldap Authentication KO failed to connect to LDAP. LDAP functions are disabled on this PHP", LOG_ERR); sleep(1); // Load translation files required by the page @@ -202,7 +202,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) $ret=$mc->checkRight($usertmp->id, $entitytotest); if ($ret < 0) { - dol_syslog("functions_ldap::check_user_password_ldap Authentification ko entity '".$entitytotest."' not allowed for user '".$usertmp->id."'"); + dol_syslog("functions_ldap::check_user_password_ldap Authentication KO entity '".$entitytotest."' not allowed for user '".$usertmp->id."'", LOG_NOTICE); $login=''; // force authentication failure } unset($usertmp); @@ -210,7 +210,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) } if ($result == 1) { - dol_syslog("functions_ldap::check_user_password_ldap Authentification ko bad user/password for '".$usertotest."'"); + dol_syslog("functions_ldap::check_user_password_ldap Authentication KO bad user/password for '".$usertotest."'", LOG_NOTICE); sleep(1); // Load translation files required by the page @@ -229,7 +229,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) ** 49 - Wrong password ** 53 - Account inactive (manually locked out by administrator) */ - dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP for '".$usertotest."'"); + dol_syslog("functions_ldap::check_user_password_ldap Authentication KO failed to connect to LDAP for '".$usertotest."'", LOG_NOTICE); if (is_resource($ldap->connection)) // If connection ok but bind ko { $ldap->ldapErrorCode = ldap_errno($ldap->connection); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d396ad4cadc..4e1745413ce 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -957,7 +957,7 @@ if (!defined('NOLOGIN')) { // If not active, we refuse the user $langs->load("other"); - dol_syslog("Authentification ko as login is disabled"); + dol_syslog("Authentication KO as login is disabled", LOG_NOTICE); accessforbidden($langs->trans("ErrorLoginDisabled")); exit; } From be9ac4f959405bee1aa1970e67aae25e9201cf90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Feb 2020 18:10:28 +0100 Subject: [PATCH 45/68] CSS --- htdocs/theme/eldy/global.inc.php | 5 ----- htdocs/theme/eldy/info-box.inc.php | 11 +++++++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 7f44fccaa19..5aebfacfdc0 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -5901,11 +5901,6 @@ div.tabsElem a.tab { border-right: none; border-left: none; } - - .box-flex-container { - margin: 0 0 0 -8px !important; - } - } @media only screen and (max-width: 1024px) diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 8f5820c6d6f..365218be8b1 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -299,7 +299,7 @@ if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENES flex-direction: row; flex-wrap: wrap; width: 100%; - margin: 0 0 0 -15px; + margin: 0 0 0 -8px; /*justify-content: space-between;*/ } @@ -309,7 +309,7 @@ if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENES flex-basis: auto; width: 280px; - margin: 5px 0px 0px 15px; + margin: 5px 8px 0px 8px; } .box-flex-item.filler{ margin: 0px 0px 0px 15px !important; @@ -321,3 +321,10 @@ if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENES overflow: visible; } */ + +@media only screen and (max-width: 767px) +{ + .box-flex-container { + margin: 0 0 0 -8px !important; + } +} From 4765198af2ed75c563c4c6c5c4e0cb5b70625152 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Feb 2020 19:03:37 +0100 Subject: [PATCH 46/68] Clean code from using deprecated field amount --- htdocs/comm/card.php | 8 ++++---- htdocs/compta/paiement.php | 12 +++++++----- htdocs/compta/recap-compta.php | 2 +- htdocs/core/boxes/box_factures_fourn_imp.php | 2 +- htdocs/core/boxes/box_factures_imp.php | 4 ++-- htdocs/fourn/facture/paiement.php | 8 ++++---- htdocs/fourn/recap-fourn.php | 2 +- htdocs/stripe/payment.php | 12 ++++++------ 8 files changed, 26 insertions(+), 24 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 43628d0aca9..b5164d6078c 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1032,7 +1032,7 @@ if ($object->id > 0) */ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { - $sql = 'SELECT f.rowid as id, f.titre as ref, f.amount'; + $sql = 'SELECT f.rowid as id, f.titre as ref'; $sql .= ', f.total as total_ht'; $sql .= ', f.tva as total_tva'; $sql .= ', f.total_ttc'; @@ -1045,7 +1045,7 @@ if ($object->id > 0) $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; $sql .= " AND f.entity = ".$conf->entity; - $sql .= ' GROUP BY f.rowid, f.titre, f.amount, f.total, f.tva, f.total_ttc,'; + $sql .= ' GROUP BY f.rowid, f.titre, f.total, f.tva, f.total_ttc,'; $sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,'; $sql .= ' f.suspended, f.date_when,'; $sql .= ' s.nom, s.rowid'; @@ -1140,7 +1140,7 @@ if ($object->id > 0) */ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { - $sql = 'SELECT f.rowid as facid, f.ref, f.type, f.amount'; + $sql = 'SELECT f.rowid as facid, f.ref, f.type'; $sql .= ', f.total as total_ht'; $sql .= ', f.tva as total_tva'; $sql .= ', f.total_ttc'; @@ -1151,7 +1151,7 @@ if ($object->id > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture'; $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; $sql .= " AND f.entity IN (".getEntity('invoice').")"; - $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.amount, f.total, f.tva, f.total_ttc,'; + $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.total, f.tva, f.total_ttc,'; $sql .= ' f.datef, f.datec, f.paye, f.fk_statut,'; $sql .= ' s.nom, s.rowid'; $sql .= " ORDER BY f.datef DESC, f.datec DESC"; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 5b297eed309..fb2a3edfd9c 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -75,6 +75,8 @@ if ($facid > 0) // Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('paiementcard', 'globalcard')); +$formquestion = array(); + /* * Actions @@ -859,7 +861,7 @@ if (!GETPOST('action', 'aZ09')) if (!$sortorder) $sortorder = 'DESC'; if (!$sortfield) $sortfield = 'p.datep'; - $sql = 'SELECT p.datep as dp, p.amount, f.amount as fa_amount, f.ref'; + $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref'; $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql .= ', '.MAIN_DB_PREFIX.'facture as f'; @@ -882,10 +884,10 @@ if (!GETPOST('action', 'aZ09')) print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num); print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("UserAgent").''.$_SERVER['HTTP_USER_AGENT'].'
'.$langs->trans("UserAgent").''.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).'
'.$langs->trans("BrowserName").''.$tmp['browsername'].'
'.$langs->trans("BrowserOS").''.$tmp['browseros'].'
'.$langs->trans("Version").''.$tmp['browserversion'].'
'.$langs->trans("Layout").' (phone/tablet/classic)'.$tmp['layout'].'
'.$langs->trans("IPAddress").''.$_SERVER['REMOTE_ADDR'].'
'.$langs->trans("IPAddress").''.dol_escape_htmltag($_SERVER['REMOTE_ADDR']); +if (! empty($_SERVER['HTTP_CLIENT_IP'])) print ' (HTTP_CLIENT_IP='.dol_escape_htmltag($_SERVER['HTTP_CLIENT_IP']).')'; +if (! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) print ' (HTTP_X_FORWARDED_FOR='.dol_escape_htmltag($_SERVER['HTTP_X_FORWARDED_FOR']).')'; +print '
'.$langs->trans("SessionName").''.session_name().'
'.$langs->trans("SessionId").''.session_id().'
'; print ''; - print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'ref', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'dp', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'libelle', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'fa_amount', '', '', '', $sortfield, $sortorder, 'right '); + print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.libelle', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right '); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 0043cf31811..60ea008a834 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -117,7 +117,7 @@ if ($id > 0) $TData = array(); - $sql = "SELECT s.nom, s.rowid as socid, f.ref, f.amount, f.datef as df,"; + $sql = "SELECT s.nom, s.rowid as socid, f.ref, f.total_ttc, f.datef as df,"; $sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,"; $sql .= " u.login, u.rowid as userid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."user as u"; diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index d4cb4143463..b1b108931b1 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -84,7 +84,7 @@ class box_factures_fourn_imp extends ModeleBoxes { $sql = "SELECT s.nom as name, s.rowid as socid,"; $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,"; - $sql.= " f.amount, f.datef as df,"; + $sql.= " f.datef as df,"; $sql.= " f.total_ht as total_ht,"; $sql.= " f.tva as total_tva,"; $sql.= " f.total_ttc,"; diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index ab9dc42fca9..0a44105a853 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -93,7 +93,7 @@ class box_factures_imp extends ModeleBoxes $sql .= " s.logo,"; $sql .= " f.ref, f.date_lim_reglement as datelimite,"; $sql .= " f.type,"; - $sql .= " f.amount, f.datef as df,"; + $sql .= " f.datef as df,"; $sql .= " f.total as total_ht,"; $sql .= " f.tva as total_tva,"; $sql .= " f.total_ttc,"; @@ -110,7 +110,7 @@ class box_factures_imp extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; $sql .= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; - $sql .= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; + $sql .= " f.type, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; $sql .= " ORDER BY datelimite ASC, f.ref ASC "; $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index e9198ebcc91..e0a679d1321 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -370,7 +370,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $dateinvoice = ($datefacture == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datefacture); $sql = 'SELECT s.nom as name, s.rowid as socid,'; - $sql .= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total, f.fk_mode_reglement, f.fk_account'; + $sql .= ' f.rowid, f.ref, f.ref_supplier, f.total_ttc as total, f.fk_mode_reglement, f.fk_account'; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f'; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -821,7 +821,7 @@ if (empty($action) || $action == 'list') $sql .= ' c.code as paiement_type, c.libelle as paiement_libelle,'; $sql .= ' ba.rowid as bid, ba.label,'; if (!$user->rights->societe->client->voir) $sql .= ' sc.fk_soc, sc.fk_user,'; - $sql .= ' SUM(f.amount)'; + $sql .= ' SUM(pf.amount)'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn'; @@ -1013,9 +1013,9 @@ if (empty($action) || $action == 'list') // Amount print ''; - if (!$i) $totalarray['nbfield']++; - $totalarray['pos'][7] = 'amount'; + $totalarray['pos'][$totalarray['nbfield']] = 'amount'; $totalarray['val']['amount'] += $objp->pamount; + if (!$i) $totalarray['nbfield']++; // Ref invoice /*$invoicesupplierstatic->ref=$objp->ref_supplier; diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index 1fda453ffe4..2cd52bfeb77 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -72,7 +72,7 @@ if ($socid > 0) print '
'.price($objp->pamount).'
'; - $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.amount, f.datef as df,"; + $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.datef as df,"; $sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,"; $sql .= " u.login, u.rowid as userid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u"; diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index b6bc81a91e2..062b62ffb21 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -1087,8 +1087,8 @@ if (!GETPOST('action')) if (!$sortorder) $sortorder = 'DESC'; if (!$sortfield) $sortfield = 'p.datep'; - $sql = 'SELECT p.datep as dp, p.amount, f.amount as fa_amount, f.ref'; - $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; + $sql = 'SELECT p.datep as dp, p.amount, f.ref,'; + $sql .= ' f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; $sql .= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; $sql .= ' AND f.entity IN ('.getEntity('invoice').")"; @@ -1109,10 +1109,10 @@ if (!GETPOST('action')) print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num); print '
'; print ''; - print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'ref', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'dp', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'libelle', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'fa_amount', '', '', '', $sortfield, $sortorder, 'right '); + print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.paiement_type', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right '); $tmpobject = new Paiement($db); $parameters = array(); From be0a25e5ed7bbac158cd86e6e7a024e7782ce04d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Feb 2020 19:03:59 +0100 Subject: [PATCH 47/68] Removed never called page --- htdocs/stripe/payment.php | 1147 ------------------------------------- 1 file changed, 1147 deletions(-) delete mode 100644 htdocs/stripe/payment.php diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php deleted file mode 100644 index 062b62ffb21..00000000000 --- a/htdocs/stripe/payment.php +++ /dev/null @@ -1,1147 +0,0 @@ - - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2007 Franky Van Liedekerke - * Copyright (C) 2012 Cédric Salvador - * Copyright (C) 2014 Raphaël Doursenaud - * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> - * Copyright (C) 2015 Juanjo Menent - * Copyright (C) 2018-2019 Thibault FOUCART - * Copyright (C) 2018 Frédéric France - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/stripe/payment.php - * \ingroup stripe - * \brief Payment page for customers invoices. @todo Seems deprecated and bugged and not used (no link to this page) ! - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array('companies', 'bills', 'banks', 'multicurrency', 'stripe')); - -$action = GETPOST('action', 'alpha'); -$confirm = GETPOST('confirm'); - -$facid = GETPOST('facid', 'int'); -$socname = GETPOST('socname'); -$source = GETPOST('source_id'); -$accountid = GETPOST('accountid'); -$paymentnum = GETPOST('num_paiement'); - -$sortfield = GETPOST('sortfield', 'alpha'); -$sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); - -$amounts=array(); -$amountsresttopay=array(); -$addwarning=0; - -$multicurrency_amounts=array(); -$multicurrency_amountsresttopay=array(); - -// Security check -$socid=0; -if ($user->socid > 0) -{ - $socid = $user->socid; -} - -$object=new Facture($db); -$stripe=new Stripe($db); - -// Load object -if ($facid > 0) -{ - $ret=$object->fetch($facid); -} - -if (empty($conf->stripe->enabled)) -{ - accessforbidden(); -} - -if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) -{ - $service = 'StripeTest'; - $servicestatus = '0'; - dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); -} -else -{ - $service = 'StripeLive'; - $servicestatus = '1'; -} -$stripeacc = $stripe->getStripeAccount($service); -/*if (empty($stripeaccount)) -{ - print $langs->trans('ErrorStripeAccountNotDefined'); -}*/ - -// Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('paiementcard', 'globalcard')); - -/* - * Actions - */ - -$parameters = array('socid'=>$socid); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - -if (empty($reshook)) -{ - if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) - { - $error = 0; - - $datepaye = dol_now(); - $paiement_id = 0; - $totalpayment = 0; - $multicurrency_totalpayment = 0; - $atleastonepaymentnotnull = 0; - - // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice = new Facture($db); - foreach ($_POST as $key => $value) - { - if (substr($key, 0, 7) == 'amount_') - { - $cursorfacid = substr($key, 7); - $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); - $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result = $tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); - if ($amounts[$cursorfacid]) - { - // Check amount - if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) - { - $addwarning = 1; - $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); - } - // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { - $langs->load("errors"); - //$error++; - setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); - } - } - - $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); - } - elseif (substr($key, 0, 21) == 'multicurrency_amount_') - { - $cursorfacid = substr($key, 21); - $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key))); - $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; - if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result = $tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); - $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); - if ($multicurrency_amounts[$cursorfacid]) - { - // Check amount - if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) - { - $addwarning = 1; - $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); - } - // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { - $langs->load("errors"); - //$error++; - setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); - } - } - - $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int')); - } - } - - // Check parameters - /*if (! GETPOST('paiementcode')) - { - setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), null, 'errors'); - $error++; - }*/ - - if (!empty($conf->banque->enabled)) - { - // If bank module is on, account is required to enter a payment - if (GETPOST('accountid') <= 0) - { - setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); - $error++; - } - } - - if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) - { - setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors'); - $error++; - } - - /*if (empty($datepaye)) - { - setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors'); - $error++; - }*/ - - // Check if payments in both currency - if ($totalpayment > 0 && $multicurrency_totalpayment > 0) - { - setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors'); - $error++; - } - } - - /* - * Action add_paiement - */ - if ($action == 'add_paiement') { - if ($error) { - $action = 'create'; - if (!$source) { - setEventMessages($langs->transnoentities('NoSource'), null, 'errors'); - } - $error++; - } - // Le reste propre a cette action s'affiche en bas de page. - } - - /* - * Action confirm_paiement - */ - if ($action == 'confirm_paiement' && $confirm == 'yes') - { - $error = 0; - - $datepaye = dol_now(); - - $db->begin(); - - // Clean parameters amount if payment is for a credit note - if (GETPOST('type') == 2) - { - foreach ($amounts as $key => $value) // How payment is dispatch - { - $newvalue = price2num($value, 'MT'); - $amounts[$key] = -$newvalue; - } - - foreach ($multicurrency_amounts as $key => $value) // How payment is dispatch - { - $newvalue = price2num($value, 'MT'); - $multicurrency_amounts[$key] = -$newvalue; - } - } - - if (!empty($conf->banque->enabled)) - { - // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement - if (GETPOST('accountid') <= 0) - { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); - $error++; - } - } - - $facture = new Facture($db); - $facture->fetch($facid); - $facture->fetch_thirdparty(); - - $error = 0; - - if (is_object($stripe) && $stripeacc) - { - $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); - - if ($customerstripe->id) { - $listofsources = $customerstripe->sources->data; - } - } - - $stripeamount = 0; - foreach ($amounts as $key => $value) // How payment is dispatch - { - $stripeamount += price2num($value, 'MT'); - } - - if (preg_match('/acct_/i', $source)) - { - $paiementcode = "VIR"; - } - elseif (preg_match('/card_/i', $source)) - { - $paiementcode = "CB"; - } - elseif (preg_match('/src_/i', $source)) - { - $customer2 = $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); - $src = $customer2->sources->retrieve("$source"); - if ($src->type == 'card') - { - $paiementcode = "CB"; - } - } - - - - $societe = new Societe($db); - $societe->fetch($facture->socid); - dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); - - $stripecu = $stripe->getStripeCustomerAccount($societe->id, $servicestatus); // Get thirdparty cu_... - - $charge = $stripe->createPaymentStripe($stripeamount, $facture->multicurrency_code, "invoice", $facid, $source, $stripecu, $stripeacc, $servicestatus); - - if (!$error) - { - // Creation of payment line - $paiement = new Paiement($db); - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = dol_getIdFromCode($db, $paiementcode, 'c_paiement'); - $paiement->num_paiement = $charge->message; - $paiement->note = GETPOST('comment'); - $paiement->ext_payment_id = $charge->id; - $paiement->ext_payment_site = $service; - } - - if (!$error) - { - $paiement_id = $paiement->create($user, 0); - if ($paiement_id < 0) - { - setEventMessages($paiement->error, $paiement->errors, 'errors'); - $error++; - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($facture->lines)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $facture->thirdparty->default_lang; - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model = $facture->modelpdf; - $ret = $facture->fetch($facid); // Reload to get new records - - $facture->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - - if (!$error) - { - $label = '(CustomerInvoicePayment)'; - if (GETPOST('type') == 2) $label = '(CustomerInvoicePaymentBack)'; - $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), '', ''); - if ($result < 0) - { - setEventMessages($paiement->error, $paiement->errors, 'errors'); - $error++; - } - elseif (GETPOST('closepaidinvoices') == 'on') { - $facture->set_paid($user); - } - } - - if (!$error) - { - $db->commit(); - - // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card - $invoiceid = 0; - foreach ($paiement->amounts as $key => $amount) - { - $facid = $key; - if (is_numeric($amount) && $amount <> 0) - { - if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment - else $invoiceid = $facid; - } - } - if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; - else $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id; - header('Location: '.$loc); - exit; - } - else - { - $loc = DOL_URL_ROOT.'/stripe/payment.php?facid='.$facid.'&action=create&error='.$charge->message; - $db->rollback(); - - header('Location: '.$loc); - exit; - } - } -} - - -/* - * View - */ - -$form = new Form($db); - -llxHeader(); - -if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { - $service = 'StripeLive'; - $servicestatus = 0; -} else { - dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); -} - -if (GETPOST('error')) { - setEventMessages(GETPOST('error'), null, 'errors'); -} - -if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') -{ - $facture = new Facture($db); - $result = $facture->fetch($facid); - - if ($result >= 0) - { - $facture->fetch_thirdparty(); - - $title = ''; - if ($facture->type != 2) $title .= $langs->trans("EnterPaymentReceivedFromCustomer"); - if ($facture->type == 2) $title .= $langs->trans("EnterPaymentDueToCustomer"); - print load_fiche_titre($title); - - // Initialize data for confirmation (this is used because data can be change during confirmation) - if ($action == 'add_paiement') - { - $i = 0; - - $formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id); - $formquestion[$i++] = array('type' => 'hidden', 'name' => 'socid', 'value' => $facture->socid); - $formquestion[$i++] = array('type' => 'hidden', 'name' => 'type', 'value' => $facture->type); - } - - - // Add realtime total information - if ($conf->use_javascript_ajax) - { - print "\n".''."\n"; - } - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - dol_fiche_head(); - - print '
'; - - // Invoice - /*if ($facture->id > 0) - { - print '\n"; - }*/ - - // Third party - print '\n"; - - // Bank account - if (!empty($conf->banque->enabled)) - { - //$form->select_comptes($accountid,'accountid',0,'',2); - print ''; - } - else - { - print ''; - } - - // Cheque number - //print ''; - //print ''; - - // Check transmitter - //print ''; - //print ''; - - // Bank name - //print ''; - //print ''; - - // Comments - print ''; - print ''; - - print '
'.$langs->trans('Invoice').''.$facture->getNomUrl(4)."
'.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
'.$langs->trans('Numero'); - //print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - //print '
'.$langs->trans('CheckTransmitter'); - //print ' ('.$langs->trans("ChequeMaker").')'; - //print '
'.$langs->trans('Bank'); - //print ' ('.$langs->trans("ChequeBank").')'; - //print '
'.$langs->trans('Comments').''; - print '
'; - - dol_fiche_end(); - - - $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); - - print '
'; - print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); - - print ''."\n"; - // Titles with sort buttons - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - foreach ($customerstripe->sources->data as $src) { - print ''; - - print ''; - - print ''; - print ''; - // Default - print ''; - print ''; - } - // TODO more dolibarize with new stripe function and stripeconnect - //if ($stripe->getStripeCustomerAccount($facture->socid)) { - // $account=\Stripe\Account::retrieve("".$stripe->getStripeCustomerAccount($facture->socid).""); - //} - - if (($account->type == 'custom' or $account->type == 'express') && $entity == 1) { - print ''; - - print ''; - - print ''; - // Default - print ''; - print ''; - } - if (empty($input) && !$stripe->getStripeCustomerAccount($facture->socid)) { - print ''; - } - - print "
'.$langs->trans('Type').''.$langs->trans('Informations').'
id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { - print'class="opacitymedium"'; - } - print '>id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { - print ' disabled'; - } elseif (($customerstripe->default_source == $src->id && $action != 'add_paiement') or ($source == $src->id && $action == 'add_paiement')) { - print ' checked'; - } - print '>id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { - print'class="opacitymedium"'; - } - - print' >'; - if ($src->object == 'card') { - print img_credit_card($src->brand); - } elseif ($src->object == 'source' && $src->type == 'card') { - print img_credit_card($src->card->brand); - } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { - print ''; - } - print 'id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { - print'class="opacitymedium"'; - } - print' >'; - if ($src->object == 'card') { - print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; - print ''; - if ($src->country) { - $img = picto_from_langcode($src->country); - print $img ? $img.' ' : ''; - print getCountry($src->country, 1); - } else { - print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; - } - } elseif ($src->object == 'source' && $src->type == 'card') { - print $src->owner->name.'
....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; - print '
'; - if ($src->card->country) { - $img = picto_from_langcode($src->card->country); - print $img ? $img.' ' : ''; - print getCountry($src->card->country, 1); - } else { - print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; - } - } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { - print 'info sepa'; - print ''; - if ($src->sepa_debit->country) { - $img = picto_from_langcode($src->sepa_debit->country); - print $img ? $img.' ' : ''; - print getCountry($src->sepa_debit->country, 1); - } else { - print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; - } - } - print 'id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { - print'class="opacitymedium"'; - } - print'>'; - if (($customerstripe->default_source == $src->id)) { - print ""; - } - print '
getStripeCustomerAccount($facture->socid) != $source) { - print'class="opacitymedium"'; - } - print'>global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { - print ' checked'; - } elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT != $source) { - print ' disabled'; - } - print '>getStripeCustomerAccount($facture->socid) != $source) { - print'class="opacitymedium"'; - } - print '>getStripeCustomerAccount($facture->socid) != $source) { - print'class="opacitymedium"'; - } - print'>'.$langs->trans('sold'); - print'id != $source) { - print'class="opacitymedium"'; - } - print'>'; - - print 'id != $source) { - print'class="opacitymedium"'; - } - print'>'; - //if (($customer->default_source!=$src->id)) { - // print img_picto($langs->trans("Disabled"),'off'); - //} else { - // print img_picto($langs->trans("Default"),'on'); - //} - print '
'.$langs->trans("None").'
"; - - - /* - * List of unpaid invoices - */ - - $sql = 'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, '; - $sql .= ' f.datef as df, f.fk_soc as socid'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - - if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; - } - - $sql .= ' WHERE f.entity IN ('.getEntity('invoice').")"; - $sql .= ' AND (f.fk_soc = '.$facture->socid; - - if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { - $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; - } - - $sql .= ') AND f.paye = 0'; - $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled - if ($facture->type != 2) - { - $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation - } - else - { - $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes - } - - // Sort invoices by date and serial number: the older one comes first - $sql .= ' ORDER BY f.datef ASC, f.ref ASC'; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - if ($num > 0) - { - $sign = 1; - if ($facture->type == 2) $sign = -1; - - $arraytitle = $langs->trans('Invoice'); - if ($facture->type == 2) $arraytitle = $langs->trans("CreditNotes"); - $alreadypayedlabel = $langs->trans('Received'); - $multicurrencyalreadypayedlabel = $langs->trans('MulticurrencyReceived'); - if ($facture->type == 2) { $alreadypayedlabel = $langs->trans("PaidBack"); $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack"); } - $remaindertopay = $langs->trans('RemainderToTake'); - $multicurrencyremaindertopay = $langs->trans('MulticurrencyRemainderToTake'); - if ($facture->type == 2) { $remaindertopay = $langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack"); } - - $i = 0; - - print '
'; - - print_barre_liste($langs->trans('StripeInvoiceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); - - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->multicurrency->enabled)) { - print ''; - print ''; - print ''; - print ''; - } - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->multicurrency->enabled)) { - print ''; - } - - $tmpinvoice = new Facture($db); - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpinvoice, $action); // Note that $action and $object may have been modified by hook - - print ''; - print "\n"; - - $total = 0; - $totalrecu = 0; - $totalrecucreditnote = 0; - $totalrecudeposits = 0; - - while ($i < $num) - { - $objp = $db->fetch_object($resql); - - $soc = new Societe($db); - $soc->fetch($objp->socid); - - $invoice = new Facture($db); - $invoice->fetch($objp->facid); - $paiement = $invoice->getSommePaiement(); - $creditnotes = $invoice->getSumCreditNotesUsed(); - $deposits = $invoice->getSumDepositsUsed(); - $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); - $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); - - // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) - { - $multicurrency_payment = $invoice->getSommePaiement(1); - $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1); - $multicurrency_deposits = $invoice->getSumDepositsUsed(1); - $multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT'); - $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT'); - } - - print ''; - - print '\n"; - - // Date - print '\n"; - - // Currency - if (!empty($conf->multicurrency->enabled)) print '\n"; - - // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) - { - print ''; - - // Multicurrency Price - print ''; - - // Multicurrency Price - print ''; - } - - // Price - print ''; - - // Received or paid back - print ''; - - // Remain to take or to pay back - print ''; - //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits)); - - // Amount - print '"; - - // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) - { - print '"; - } - - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook - - // Warning - print ''; - - print "\n"; - - $total += $objp->total; - $total_ttc += $objp->total_ttc; - $totalrecu += $paiement; - $totalrecucreditnote += $creditnotes; - $totalrecudeposits += $deposits; - $i++; - } - if ($i > 1) - { - $amount = round(price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')) * 100); - - // Print total - print ''; - print ''; - if (!empty($conf->multicurrency->enabled)) { - print ''; - print ''; - print ''; - } - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->multicurrency->enabled)) { - print ''; - } - print ''; - print "\n"; - } - print "
'.$arraytitle.''.$langs->trans('Date').''.$langs->trans('Currency').''.$langs->trans('MulticurrencyAmountTTC').''.$multicurrencyalreadypayedlabel.''.$multicurrencyremaindertopay.''.$langs->trans('AmountTTC').''.$alreadypayedlabel.''.$remaindertopay.''.$langs->trans('PaymentAmount').''.$langs->trans('MulticurrencyPaymentAmount').' 
'; - print $invoice->getNomUrl(1, ''); - if ($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' '; - print "'.dol_print_date($db->jdate($objp->df), 'day')."'.$objp->multicurrency_code."'; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $objp->multicurrency_total_ttc); - print ''; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) - { - print price($sign * $multicurrency_payment); - if ($multicurrency_creditnotes) print '+'.price($multicurrency_creditnotes); - if ($multicurrency_deposits) print '+'.price($multicurrency_deposits); - } - print ''; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay); - print ''.price($sign * $objp->total_ttc).''.price($sign * $paiement); - if ($creditnotes) print '+'.price($creditnotes); - if ($deposits) print '+'.price($deposits); - print ''.price($sign * $remaintopay).''; - - // Add remind amount - $namef = 'amount_'.$objp->facid; - $nameRemain = 'remain_'.$objp->facid; - - if ($action != 'add_paiement') - { - if (!empty($conf->use_javascript_ajax)) - print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); - print ''; - print ''; - } - else - { - print ''; - print ''; - } - print "'; - - // Add remind multicurrency amount - $namef = 'multicurrency_amount_'.$objp->facid; - $nameRemain = 'multicurrency_remain_'.$objp->facid; - - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) - { - if ($action != 'add_paiement') - { - if (!empty($conf->use_javascript_ajax)) - print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); - print ''; - print ''; - } - else - { - print ''; - print ''; - } - } - print "'; - //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."
"; - if ($amounts[$invoice->id] && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id])) - || $multicurrency_amounts[$invoice->id] && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) - { - print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay")); - } - print '
'.$langs->trans('TotalTTC').''.price($sign * $total_ttc).''.price($sign * $totalrecu); - if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); - if ($totalrecudeposits) print '+'.price($totalrecudeposits); - print ''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'
"; - //print "\n"; - } - $db->free($resql); - } - else - { - dol_print_error($db); - } - - - // Bouton Enregistrer - if ($action != 'add_paiement') - { - $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically"); - if ($facture->type == 2) $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically"); - $buttontitle = $langs->trans('ToMakePayment'); - if ($facture->type == 2) $buttontitle = $langs->trans('ToMakePaymentBack'); - - print '
'; - print ' '.$checkboxlabel; - /*if (! empty($conf->prelevement->enabled)) - { - $langs->load("withdrawals"); - if (! empty($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS)) print '
'.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed"); - }*/ - print '


'; - print '
'; - } - - // Form to confirm payment - if ($action == 'add_paiement') - { - $preselectedchoice = $addwarning ? 'no' : 'yes'; - - print '
'; - if (!empty($totalpayment)) { - $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency)); - } - if (!empty($multicurrency_totalpayment)) { - $text .= '
'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency")); - } - if (GETPOST('closepaidinvoices')) - { - $text .= '
'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); - print ''; - } - print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice); - } - - print "\n"; - } -} - - -/** - * Show list of payments - */ - -if (!GETPOST('action')) -{ - if ($page == -1 || empty($page)) $page = 0; - $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; - $offset = $limit * $page; - - if (!$sortorder) $sortorder = 'DESC'; - if (!$sortfield) $sortfield = 'p.datep'; - - $sql = 'SELECT p.datep as dp, p.amount, f.ref,'; - $sql .= ' f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; - $sql .= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; - $sql .= ' AND f.entity IN ('.getEntity('invoice').")"; - if ($socid) - { - $sql .= ' AND f.fk_soc = '.$socid; - } - - $sql .= ' ORDER BY '.$sortfield.' '.$sortorder; - $sql .= $db->plimit($limit + 1, $offset); - $resql = $db->query($sql); - - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - - print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num); - print ''; - print ''; - print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.paiement_type', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right '); - - $tmpobject = new Paiement($db); - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpobject, $action); // Note that $action and $object may have been modified by hook - - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); - print "\n"; - - while ($i < min($num, $limit)) - { - $objp = $db->fetch_object($resql); - - print ''; - print '\n"; - print '\n"; - print '\n"; - print ''; - - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook - - print ''; - print ''; - $i++; - } - print '
'.$objp->ref."'.dol_print_date($db->jdate($objp->dp))."'.$objp->paiement_type.' '.$objp->num_paiement."'.price($objp->amount).' 
'; - } -} - -// End of page -llxFooter(); -$db->close(); From 075b1ea7443d9dd17b5bfd5c0e8da160c88307ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Feb 2020 15:57:41 +0100 Subject: [PATCH 48/68] FIX Log of authentication ko or ko + CVE-2020-7996 --- htdocs/admin/system/browser.php | 7 +++++-- htdocs/core/lib/security2.lib.php | 2 +- htdocs/core/login/functions_dolibarr.php | 8 ++++---- htdocs/core/login/functions_ldap.php | 8 ++++---- htdocs/main.inc.php | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/system/browser.php b/htdocs/admin/system/browser.php index 5035c6c4a7d..cae6e568d65 100644 --- a/htdocs/admin/system/browser.php +++ b/htdocs/admin/system/browser.php @@ -49,12 +49,15 @@ $tmp=getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); print '
'; print ''; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 26e97499482..8d3adfa2df7 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -104,7 +104,7 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth } else { - dol_syslog("Authentification ko - failed to load file '".$authfile."'", LOG_ERR); + dol_syslog("Authentication KO - failed to load file '".$authfile."'", LOG_ERR); sleep(1); // Load translation files required by the page $langs->loadLangs(array('other', 'main', 'errors')); diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 7e5439fa66a..861c31a0e37 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -110,7 +110,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes else { sleep(2); // Anti brut force protection - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."', cryptType=".$cryptType); + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO bad password for '".$usertotest."', cryptType=".$cryptType, LOG_NOTICE); // Load translation files required by the page $langs->loadLangs(array('main', 'errors')); @@ -129,7 +129,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes $ret = $mc->checkRight($obj->rowid, $entitytotest); if ($ret < 0) { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '" . $entitytotest . "' not allowed for user '" . $obj->rowid . "'"); + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO entity '" . $entitytotest . "' not allowed for user '" . $obj->rowid . "'", LOG_NOTICE); $login = ''; // force authentication failure } } @@ -137,7 +137,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes } else { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko user not found for '".$usertotest."'"); + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO user not found for '".$usertotest."'", LOG_NOTICE); sleep(1); // Load translation files required by the page @@ -148,7 +148,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes } else { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko db error for '".$usertotest."' error=".$db->lasterror()); + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO db error for '".$usertotest."' error=".$db->lasterror(), LOG_ERR); sleep(1); $_SESSION["dol_loginmesg"]=$db->lasterror(); } diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index 63a4c6d01e6..81bbfdf5b84 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -52,7 +52,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) if (! function_exists("ldap_connect")) { - dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP. LDAP functions are disabled on this PHP"); + dol_syslog("functions_ldap::check_user_password_ldap Authentication KO failed to connect to LDAP. LDAP functions are disabled on this PHP", LOG_ERR); sleep(1); // Load translation files required by the page @@ -202,7 +202,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) $ret=$mc->checkRight($usertmp->id, $entitytotest); if ($ret < 0) { - dol_syslog("functions_ldap::check_user_password_ldap Authentification ko entity '".$entitytotest."' not allowed for user '".$usertmp->id."'"); + dol_syslog("functions_ldap::check_user_password_ldap Authentication KO entity '".$entitytotest."' not allowed for user '".$usertmp->id."'", LOG_NOTICE); $login=''; // force authentication failure } unset($usertmp); @@ -210,7 +210,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) } if ($result == 1) { - dol_syslog("functions_ldap::check_user_password_ldap Authentification ko bad user/password for '".$usertotest."'"); + dol_syslog("functions_ldap::check_user_password_ldap Authentication KO bad user/password for '".$usertotest."'", LOG_NOTICE); sleep(1); // Load translation files required by the page @@ -229,7 +229,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) ** 49 - Wrong password ** 53 - Account inactive (manually locked out by administrator) */ - dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP for '".$usertotest."'"); + dol_syslog("functions_ldap::check_user_password_ldap Authentication KO failed to connect to LDAP for '".$usertotest."'", LOG_NOTICE); if (is_resource($ldap->connection)) // If connection ok but bind ko { $ldap->ldapErrorCode = ldap_errno($ldap->connection); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d396ad4cadc..4e1745413ce 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -957,7 +957,7 @@ if (!defined('NOLOGIN')) { // If not active, we refuse the user $langs->load("other"); - dol_syslog("Authentification ko as login is disabled"); + dol_syslog("Authentication KO as login is disabled", LOG_NOTICE); accessforbidden($langs->trans("ErrorLoginDisabled")); exit; } From 9781c20f84d3b4951ce9b36abf40ff28eb606031 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Sun, 2 Feb 2020 18:34:09 +0000 Subject: [PATCH 49/68] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/adherents/class/adherent.class.php | 1322 ++++++++++----------- htdocs/index.php | 72 +- htdocs/projet/element.php | 218 ++-- htdocs/user/class/user.class.php | 6 +- 4 files changed, 809 insertions(+), 809 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 71046b400b1..9dbe3bb5928 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -46,12 +46,12 @@ class Adherent extends CommonObject /** * @var string ID to identify managed object */ - public $element='member'; + public $element = 'member'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='adherent'; + public $table_element = 'adherent'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -220,7 +220,7 @@ class Adherent extends CommonObject public $user_id; public $user_login; - public $datefin; // From member table + public $datefin; // From member table // Fields loaded by fetch_subscriptions() public $first_subscription_date; @@ -229,7 +229,7 @@ class Adherent extends CommonObject public $last_subscription_date_start; public $last_subscription_date_end; public $last_subscription_amount; - public $subscriptions=array(); + public $subscriptions = array(); /** * @var Adherent To contains a clone of this when we need to save old properties of object @@ -253,7 +253,7 @@ class Adherent extends CommonObject // l'adherent n'est pas public par defaut $this->public = 0; // les champs optionnels sont vides - $this->array_options=array(); + $this->array_options = array(); } @@ -277,7 +277,7 @@ class Adherent extends CommonObject public function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') { // phpcs:enable - global $conf,$langs; + global $conf, $langs; // Detect if message is HTML if ($msgishtml == -1) @@ -288,13 +288,13 @@ class Adherent extends CommonObject dol_syslog('send_an_email msgishtml='.$msgishtml); - $texttosend=$this->makeSubstitution($text); - $subjecttosend=$this->makeSubstitution($subject); - if ($msgishtml) $texttosend=dol_htmlentitiesbr($texttosend); + $texttosend = $this->makeSubstitution($text); + $subjecttosend = $this->makeSubstitution($subject); + if ($msgishtml) $texttosend = dol_htmlentitiesbr($texttosend); // Envoi mail confirmation - $from=$conf->email_from; - if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM; + $from = $conf->email_from; + if (!empty($conf->global->ADHERENT_MAIL_FROM)) $from = $conf->global->ADHERENT_MAIL_FROM; $trackid = 'mem'.$this->id; @@ -307,7 +307,7 @@ class Adherent extends CommonObject } else { - $this->error=$langs->trans("ErrorFailedToSendMail", $from, $this->email).'. '.$mailfile->error; + $this->error = $langs->trans("ErrorFailedToSendMail", $from, $this->email).'. '.$mailfile->error; return -1; } } @@ -321,57 +321,57 @@ class Adherent extends CommonObject */ public function makeSubstitution($text) { - global $conf,$langs; + global $conf, $langs; $birthday = dol_print_date($this->birth, 'day'); $msgishtml = 0; if (dol_textishtml($text, 1)) $msgishtml = 1; - $infos=''; - if ($this->civility_id) $infos.= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n"; - $infos.= $langs->transnoentities("id").": ".$this->id."\n"; - $infos.= $langs->transnoentities("Lastname").": ".$this->lastname."\n"; - $infos.= $langs->transnoentities("Firstname").": ".$this->firstname."\n"; - $infos.= $langs->transnoentities("Company").": ".$this->company."\n"; - $infos.= $langs->transnoentities("Address").": ".$this->address."\n"; - $infos.= $langs->transnoentities("Zip").": ".$this->zip."\n"; - $infos.= $langs->transnoentities("Town").": ".$this->town."\n"; - $infos.= $langs->transnoentities("Country").": ".$this->country."\n"; - $infos.= $langs->transnoentities("EMail").": ".$this->email."\n"; - $infos.= $langs->transnoentities("PhonePro").": ".$this->phone."\n"; - $infos.= $langs->transnoentities("PhonePerso").": ".$this->phone_perso."\n"; - $infos.= $langs->transnoentities("PhoneMobile").": ".$this->phone_mobile."\n"; + $infos = ''; + if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n"; + $infos .= $langs->transnoentities("id").": ".$this->id."\n"; + $infos .= $langs->transnoentities("Lastname").": ".$this->lastname."\n"; + $infos .= $langs->transnoentities("Firstname").": ".$this->firstname."\n"; + $infos .= $langs->transnoentities("Company").": ".$this->company."\n"; + $infos .= $langs->transnoentities("Address").": ".$this->address."\n"; + $infos .= $langs->transnoentities("Zip").": ".$this->zip."\n"; + $infos .= $langs->transnoentities("Town").": ".$this->town."\n"; + $infos .= $langs->transnoentities("Country").": ".$this->country."\n"; + $infos .= $langs->transnoentities("EMail").": ".$this->email."\n"; + $infos .= $langs->transnoentities("PhonePro").": ".$this->phone."\n"; + $infos .= $langs->transnoentities("PhonePerso").": ".$this->phone_perso."\n"; + $infos .= $langs->transnoentities("PhoneMobile").": ".$this->phone_mobile."\n"; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - $infos.= $langs->transnoentities("Login").": ".$this->login."\n"; - $infos.= $langs->transnoentities("Password").": ".$this->pass."\n"; + $infos .= $langs->transnoentities("Login").": ".$this->login."\n"; + $infos .= $langs->transnoentities("Password").": ".$this->pass."\n"; } - $infos.= $langs->transnoentities("Birthday").": ".$birthday."\n"; - $infos.= $langs->transnoentities("Photo").": ".$this->photo."\n"; - $infos.= $langs->transnoentities("Public").": ".yn($this->public); + $infos .= $langs->transnoentities("Birthday").": ".$birthday."\n"; + $infos .= $langs->transnoentities("Photo").": ".$this->photo."\n"; + $infos .= $langs->transnoentities("Public").": ".yn($this->public); // Substitutions - $substitutionarray=array( + $substitutionarray = array( '__ID__'=>$this->id, '__MEMBER_ID__'=>$this->id, '__CIVILITY__'=>$this->getCivilityLabel(), - '__FIRSTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->firstname):($this->firstname?$this->firstname:''), - '__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):($this->lastname?$this->lastname:''), - '__FULLNAME__'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs), - '__COMPANY__'=>$msgishtml?dol_htmlentitiesbr($this->company):($this->company?$this->company:''), - '__ADDRESS__'=>$msgishtml?dol_htmlentitiesbr($this->address):($this->address?$this->address:''), - '__ZIP__'=>$msgishtml?dol_htmlentitiesbr($this->zip):($this->zip?$this->zip:''), - '__TOWN__'=>$msgishtml?dol_htmlentitiesbr($this->town):($this->town?$this->town:''), - '__COUNTRY__'=>$msgishtml?dol_htmlentitiesbr($this->country):($this->country?$this->country:''), - '__EMAIL__'=>$msgishtml?dol_htmlentitiesbr($this->email):($this->email?$this->email:''), - '__BIRTH__'=>$msgishtml?dol_htmlentitiesbr($birthday):($birthday?$birthday:''), - '__PHOTO__'=>$msgishtml?dol_htmlentitiesbr($this->photo):($this->photo?$this->photo:''), - '__LOGIN__'=>$msgishtml?dol_htmlentitiesbr($this->login):($this->login?$this->login:''), - '__PASSWORD__'=>$msgishtml?dol_htmlentitiesbr($this->pass):($this->pass?$this->pass:''), - '__PHONE__'=>$msgishtml?dol_htmlentitiesbr($this->phone):($this->phone?$this->phone:''), - '__PHONEPRO__'=>$msgishtml?dol_htmlentitiesbr($this->phone_perso):($this->phone_perso?$this->phone_perso:''), - '__PHONEMOBILE__'=>$msgishtml?dol_htmlentitiesbr($this->phone_mobile):($this->phone_mobile?$this->phone_mobile:'') + '__FIRSTNAME__'=>$msgishtml ?dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname : ''), + '__LASTNAME__'=>$msgishtml ?dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname : ''), + '__FULLNAME__'=>$msgishtml ?dol_htmlentitiesbr($this->getFullName($langs)) : $this->getFullName($langs), + '__COMPANY__'=>$msgishtml ?dol_htmlentitiesbr($this->company) : ($this->company ? $this->company : ''), + '__ADDRESS__'=>$msgishtml ?dol_htmlentitiesbr($this->address) : ($this->address ? $this->address : ''), + '__ZIP__'=>$msgishtml ?dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip : ''), + '__TOWN__'=>$msgishtml ?dol_htmlentitiesbr($this->town) : ($this->town ? $this->town : ''), + '__COUNTRY__'=>$msgishtml ?dol_htmlentitiesbr($this->country) : ($this->country ? $this->country : ''), + '__EMAIL__'=>$msgishtml ?dol_htmlentitiesbr($this->email) : ($this->email ? $this->email : ''), + '__BIRTH__'=>$msgishtml ?dol_htmlentitiesbr($birthday) : ($birthday ? $birthday : ''), + '__PHOTO__'=>$msgishtml ?dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo : ''), + '__LOGIN__'=>$msgishtml ?dol_htmlentitiesbr($this->login) : ($this->login ? $this->login : ''), + '__PASSWORD__'=>$msgishtml ?dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass : ''), + '__PHONE__'=>$msgishtml ?dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone : ''), + '__PHONEPRO__'=>$msgishtml ?dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso : ''), + '__PHONEMOBILE__'=>$msgishtml ?dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile : '') ); complete_substitutions_array($substitutionarray, $langs, $this); @@ -389,7 +389,7 @@ class Adherent extends CommonObject public function getmorphylib($morphy = '') { global $langs; - if (! $morphy) { $morphy=$this->morphy; } + if (!$morphy) { $morphy = $this->morphy; } if ($morphy == 'phy') { return $langs->trans("Physical"); } if ($morphy == 'mor') { return $langs->trans("Moral"); } return $morphy; @@ -404,23 +404,23 @@ class Adherent extends CommonObject */ public function create($user, $notrigger = 0) { - global $conf,$langs; + global $conf, $langs; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); // Clean parameters $this->import_key = trim($this->import_key); // Check parameters - if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email)) + if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) { $langs->load("errors"); $this->error = $langs->trans("ErrorBadEMail", $this->email); return -1; } - if (! $this->datec) $this->datec=$now; + if (!$this->datec) $this->datec = $now; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (empty($this->login)) @@ -434,16 +434,16 @@ class Adherent extends CommonObject // Insert member $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent"; - $sql.= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)"; - $sql.= " VALUES ("; - $sql.= " '".$this->db->idate($this->datec)."'"; - $sql.= ", ".($this->login?"'".$this->db->escape($this->login)."'":"null"); - $sql.= ", ".($user->id>0?$user->id:"null"); // Can be null because member can be created by a guest or a script - $sql.= ", null, null, '".$this->db->escape($this->morphy)."'"; - $sql.= ", ".$this->typeid; - $sql.= ", ".$conf->entity; - $sql.= ", ".(! empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'":"null"); - $sql.= ")"; + $sql .= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)"; + $sql .= " VALUES ("; + $sql .= " '".$this->db->idate($this->datec)."'"; + $sql .= ", ".($this->login ? "'".$this->db->escape($this->login)."'" : "null"); + $sql .= ", ".($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script + $sql .= ", null, null, '".$this->db->escape($this->morphy)."'"; + $sql .= ", ".$this->typeid; + $sql .= ", ".$conf->entity; + $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); @@ -452,11 +452,11 @@ class Adherent extends CommonObject $id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent"); if ($id > 0) { - $this->id=$id; - $this->ref=(string) $id; + $this->id = $id; + $this->ref = (string) $id; // Update minor fields - $result=$this->update($user, 1, 1, 0, 0, 'add'); // nosync is 1 to avoid update data of user + $result = $this->update($user, 1, 1, 0, 0, 'add'); // nosync is 1 to avoid update data of user if ($result < 0) { $this->db->rollback(); @@ -468,22 +468,22 @@ class Adherent extends CommonObject { // Add link to user $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; - $sql.= " fk_member = ".$this->id; - $sql.= " WHERE rowid = ".$this->user_id; + $sql .= " fk_member = ".$this->id; + $sql .= " WHERE rowid = ".$this->user_id; dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error='Failed to update user to make link with member'; + $this->error = 'Failed to update user to make link with member'; $this->db->rollback(); return -4; } } - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_CREATE', $user); + $result = $this->call_trigger('MEMBER_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -502,7 +502,7 @@ class Adherent extends CommonObject } else { - $this->error='Failed to get last insert id'; + $this->error = 'Failed to get last insert id'; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); $this->db->rollback(); return -2; @@ -510,7 +510,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -532,27 +532,27 @@ class Adherent extends CommonObject { global $conf, $langs, $hookmanager; - $nbrowsaffected=0; - $error=0; + $nbrowsaffected = 0; + $error = 0; dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass." nosyncthirdparty=".$nosyncthirdparty.", email=".$this->email); // Clean parameters - $this->lastname = trim($this->lastname)?trim($this->lastname):trim($this->lastname); - $this->firstname = trim($this->firstname)?trim($this->firstname):trim($this->firstname); + $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname); + $this->firstname = trim($this->firstname) ?trim($this->firstname) : trim($this->firstname); $this->gender = trim($this->gender); - $this->address = ($this->address?$this->address:$this->address); - $this->zip = ($this->zip?$this->zip:$this->zip); - $this->town = ($this->town?$this->town:$this->town); - $this->country_id = ($this->country_id > 0?$this->country_id:$this->country_id); - $this->state_id = ($this->state_id > 0?$this->state_id:$this->state_id); - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords(trim($this->lastname)); - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords(trim($this->firstname)); - $this->note_public = ($this->note_public?$this->note_public:$this->note_public); - $this->note_private = ($this->note_private?$this->note_private:$this->note_private); + $this->address = ($this->address ? $this->address : $this->address); + $this->zip = ($this->zip ? $this->zip : $this->zip); + $this->town = ($this->town ? $this->town : $this->town); + $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); + $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(trim($this->lastname)); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(trim($this->firstname)); + $this->note_public = ($this->note_public ? $this->note_public : $this->note_public); + $this->note_private = ($this->note_private ? $this->note_private : $this->note_private); // Check parameters - if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email)) + if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) { $langs->load("errors"); $this->error = $langs->trans("ErrorBadEMail", $this->email); @@ -562,49 +562,49 @@ class Adherent extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql.= " civility = ".($this->civility_id?"'".$this->db->escape($this->civility_id)."'":"null"); - $sql.= ", firstname = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null"); - $sql.= ", lastname = ".($this->lastname?"'".$this->db->escape($this->lastname)."'":"null"); - $sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' - $sql.= ", login = ".($this->login?"'".$this->db->escape($this->login)."'":"null"); - $sql.= ", societe = ".($this->company?"'".$this->db->escape($this->company)."'":($this->societe?"'".$this->db->escape($this->societe)."'":"null")); - $sql.= ", fk_soc = ".($this->socid > 0?$this->db->escape($this->socid):"null"); - $sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null"); - $sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null"); - $sql.= ", town = ".($this->town?"'".$this->db->escape($this->town)."'":"null"); - $sql.= ", country = ".($this->country_id>0?$this->db->escape($this->country_id):"null"); - $sql.= ", state_id = ".($this->state_id>0?$this->db->escape($this->state_id):"null"); - $sql.= ", email = '".$this->db->escape($this->email)."'"; - $sql.= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; - $sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null"); - $sql.= ", phone_perso = ".($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null"); - $sql.= ", phone_mobile = ".($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null"); - $sql.= ", note_private = ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); - $sql.= ", note_public = ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); - $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null"); - $sql.= ", public = '".$this->db->escape($this->public)."'"; - $sql.= ", statut = ".$this->db->escape($this->statut); - $sql.= ", fk_adherent_type = ".$this->db->escape($this->typeid); - $sql.= ", morphy = '".$this->db->escape($this->morphy)."'"; - $sql.= ", birth = ".($this->birth?"'".$this->db->idate($this->birth)."'":"null"); - if ($this->socid) $sql.= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party - if ($this->datefin) $sql.= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription - if ($this->datevalid) $sql.= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member - $sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest - $sql.= " WHERE rowid = ".$this->id; + $sql .= " civility = ".($this->civility_id ? "'".$this->db->escape($this->civility_id)."'" : "null"); + $sql .= ", firstname = ".($this->firstname ? "'".$this->db->escape($this->firstname)."'" : "null"); + $sql .= ", lastname = ".($this->lastname ? "'".$this->db->escape($this->lastname)."'" : "null"); + $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' + $sql .= ", login = ".($this->login ? "'".$this->db->escape($this->login)."'" : "null"); + $sql .= ", societe = ".($this->company ? "'".$this->db->escape($this->company)."'" : ($this->societe ? "'".$this->db->escape($this->societe)."'" : "null")); + $sql .= ", fk_soc = ".($this->socid > 0 ? $this->db->escape($this->socid) : "null"); + $sql .= ", address = ".($this->address ? "'".$this->db->escape($this->address)."'" : "null"); + $sql .= ", zip = ".($this->zip ? "'".$this->db->escape($this->zip)."'" : "null"); + $sql .= ", town = ".($this->town ? "'".$this->db->escape($this->town)."'" : "null"); + $sql .= ", country = ".($this->country_id > 0 ? $this->db->escape($this->country_id) : "null"); + $sql .= ", state_id = ".($this->state_id > 0 ? $this->db->escape($this->state_id) : "null"); + $sql .= ", email = '".$this->db->escape($this->email)."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + $sql .= ", phone = ".($this->phone ? "'".$this->db->escape($this->phone)."'" : "null"); + $sql .= ", phone_perso = ".($this->phone_perso ? "'".$this->db->escape($this->phone_perso)."'" : "null"); + $sql .= ", phone_mobile = ".($this->phone_mobile ? "'".$this->db->escape($this->phone_mobile)."'" : "null"); + $sql .= ", note_private = ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ", note_public = ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); + $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null"); + $sql .= ", public = '".$this->db->escape($this->public)."'"; + $sql .= ", statut = ".$this->db->escape($this->statut); + $sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid); + $sql .= ", morphy = '".$this->db->escape($this->morphy)."'"; + $sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null"); + if ($this->socid) $sql .= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party + if ($this->datefin) $sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription + if ($this->datevalid) $sql .= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member + $sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest + $sql .= " WHERE rowid = ".$this->id; // If we change the type of membership, we set also label of new type - if (! empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) + if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) { $sql2 = "SELECT libelle as label"; - $sql2.= " FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql2.= " WHERE rowid = ".$this->typeid; + $sql2 .= " FROM ".MAIN_DB_PREFIX."adherent_type"; + $sql2 .= " WHERE rowid = ".$this->typeid; $resql2 = $this->db->query($sql2); if ($resql2) { - while ($obj=$this->db->fetch_object($resql2)) + while ($obj = $this->db->fetch_object($resql2)) { - $this->type=$obj->label; + $this->type = $obj->label; } } } @@ -618,14 +618,14 @@ class Adherent extends CommonObject unset($this->state_code); unset($this->state); - $nbrowsaffected+=$this->db->affected_rows($resql); + $nbrowsaffected += $this->db->affected_rows($resql); - $action='update'; + $action = 'update'; // Actions on extra fields - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -633,48 +633,48 @@ class Adherent extends CommonObject } // Update password - if (! $error && $this->pass) + if (!$error && $this->pass) { dol_syslog(get_class($this)."::update update password"); if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) { - $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED)?0:1; + $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1; // If password to set differs from the one found into database - $result=$this->setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass); - if (! $nbrowsaffected) $nbrowsaffected++; + $result = $this->setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass); + if (!$nbrowsaffected) $nbrowsaffected++; } } // Remove links to user and replace with new one - if (! $error) + if (!$error) { dol_syslog(get_class($this)."::update update link to user"); $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; } + if (!$resql) { $this->error = $this->db->error(); $this->db->rollback(); return -5; } // If there is a user linked to this member if ($this->user_id > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id." WHERE rowid = ".$this->user_id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; } + if (!$resql) { $this->error = $this->db->error(); $this->db->rollback(); return -5; } } } - if (! $error && $nbrowsaffected) // If something has change in main data + if (!$error && $nbrowsaffected) // If something has change in main data { // Update information on linked user if it is an update - if (! $error && $this->user_id > 0 && ! $nosyncuser) + if (!$error && $this->user_id > 0 && !$nosyncuser) { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; dol_syslog(get_class($this)."::update update linked user"); - $luser=new User($this->db); - $result=$luser->fetch($this->user_id); + $luser = new User($this->db); + $result = $luser->fetch($this->user_id); if ($result >= 0) { @@ -682,47 +682,47 @@ class Adherent extends CommonObject //var_dump($this->login);exit; // If option ADHERENT_LOGIN_NOT_REQUIRED is on, there is no login of member, so we do not overwrite user login to keep existing one. - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $luser->login=$this->login; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $luser->login = $this->login; - $luser->civility_id=$this->civility_id; - $luser->firstname=$this->firstname; - $luser->lastname=$this->lastname; - $luser->gender=$this->gender; - $luser->pass=$this->pass; + $luser->civility_id = $this->civility_id; + $luser->firstname = $this->firstname; + $luser->lastname = $this->lastname; + $luser->gender = $this->gender; + $luser->pass = $this->pass; //$luser->socid=$this->fk_soc; // We do not enable this. This may transform a user into an external user. - $luser->birth=$this->birth; + $luser->birth = $this->birth; - $luser->address=$this->address; - $luser->zip=$this->zip; - $luser->town=$this->town; - $luser->country_id=$this->country_id; - $luser->state_id=$this->state_id; + $luser->address = $this->address; + $luser->zip = $this->zip; + $luser->town = $this->town; + $luser->country_id = $this->country_id; + $luser->state_id = $this->state_id; - $luser->email=$this->email; - $luser->socialnetworks=$this->socialnetworks; - $luser->office_phone=$this->phone; - $luser->user_mobile=$this->phone_mobile; + $luser->email = $this->email; + $luser->socialnetworks = $this->socialnetworks; + $luser->office_phone = $this->phone; + $luser->user_mobile = $this->phone_mobile; - $luser->fk_member=$this->id; + $luser->fk_member = $this->id; - $result=$luser->update($user, 0, 1, 1); // Use nosync to 1 to avoid cyclic updates + $result = $luser->update($user, 0, 1, 1); // Use nosync to 1 to avoid cyclic updates if ($result < 0) { - $this->error=$luser->error; + $this->error = $luser->error; dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); $error++; } } else { - $this->error=$luser->error; + $this->error = $luser->error; $error++; } } // Update information on linked thirdparty if it is an update - if (! $error && $this->fk_soc > 0 && ! $nosyncthirdparty) + if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) { require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -730,48 +730,48 @@ class Adherent extends CommonObject // This member is linked with a thirdparty, so we also update thirdparty informations // if this is an update. - $lthirdparty=new Societe($this->db); - $result=$lthirdparty->fetch($this->fk_soc); + $lthirdparty = new Societe($this->db); + $result = $lthirdparty->fetch($this->fk_soc); if ($result > 0) { - $lthirdparty->address=$this->address; - $lthirdparty->zip=$this->zip; - $lthirdparty->town=$this->town; - $lthirdparty->email=$this->email; - $lthirdparty->socialnetworks=$this->socialnetworks; - $lthirdparty->phone=$this->phone; - $lthirdparty->state_id=$this->state_id; - $lthirdparty->country_id=$this->country_id; + $lthirdparty->address = $this->address; + $lthirdparty->zip = $this->zip; + $lthirdparty->town = $this->town; + $lthirdparty->email = $this->email; + $lthirdparty->socialnetworks = $this->socialnetworks; + $lthirdparty->phone = $this->phone; + $lthirdparty->state_id = $this->state_id; + $lthirdparty->country_id = $this->country_id; //$lthirdparty->phone_mobile=$this->phone_mobile; - $result=$lthirdparty->update($this->fk_soc, $user, 0, 1, 1, 'update'); // Use sync to 0 to avoid cyclic updates + $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1, 'update'); // Use sync to 0 to avoid cyclic updates if ($result < 0) { - $this->error=$lthirdparty->error; - $this->errors=$lthirdparty->errors; + $this->error = $lthirdparty->error; + $this->errors = $lthirdparty->errors; dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); $error++; } } elseif ($result < 0) { - $this->error=$lthirdparty->error; + $this->error = $lthirdparty->error; $error++; } } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_MODIFY', $user); + $result = $this->call_trigger('MEMBER_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return $nbrowsaffected; @@ -785,7 +785,7 @@ class Adherent extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -2; } } @@ -806,31 +806,31 @@ class Adherent extends CommonObject // Search for last subscription id and end date $sql = "SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin"; - $sql.= " FROM ".MAIN_DB_PREFIX."subscription"; - $sql.= " WHERE fk_adherent=".$this->id; - $sql.= " ORDER by dateadh DESC"; // Sort by start subscription date + $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; + $sql .= " WHERE fk_adherent=".$this->id; + $sql .= " ORDER by dateadh DESC"; // Sort by start subscription date dol_syslog(get_class($this)."::update_end_date", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - $dateop=$this->db->jdate($obj->dateop); - $datedeb=$this->db->jdate($obj->datedeb); - $datefin=$this->db->jdate($obj->datefin); + $obj = $this->db->fetch_object($resql); + $dateop = $this->db->jdate($obj->dateop); + $datedeb = $this->db->jdate($obj->datedeb); + $datefin = $this->db->jdate($obj->datefin); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql.= " datefin=".($datefin != '' ? "'".$this->db->idate($datefin)."'" : "null"); - $sql.= " WHERE rowid = ".$this->id; + $sql .= " datefin=".($datefin != '' ? "'".$this->db->idate($datefin)."'" : "null"); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_end_date", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->last_subscription_date=$dateop; - $this->last_subscription_date_start=$datedeb; - $this->last_subscription_date_end=$datefin; - $this->datefin=$datefin; + $this->last_subscription_date = $dateop; + $this->last_subscription_date_start = $datedeb; + $this->last_subscription_date_end = $datefin; + $this->datefin = $datefin; $this->db->commit(); return 1; } @@ -842,7 +842,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -861,18 +861,18 @@ class Adherent extends CommonObject global $conf, $langs; $result = 0; - $error=0; - $errorflag=0; + $error = 0; + $errorflag = 0; // Check parameters - if (empty($rowid)) $rowid=$this->id; + if (empty($rowid)) $rowid = $this->id; $this->db->begin(); - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_DELETE', $user); + $result = $this->call_trigger('MEMBER_DELETE', $user); if ($result < 0) $error++; // End call triggers } @@ -880,70 +880,70 @@ class Adherent extends CommonObject // Remove category $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); - $errorflag=-1; + $errorflag = -1; } // Remove subscription - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".$rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); - $errorflag=-2; + $errorflag = -2; } } // Remove linked user - if (! $error) + if (!$error) { - $ret=$this->setUserId(0); + $ret = $this->setUserId(0); if ($ret < 0) { $error++; $this->error .= $this->db->lasterror(); - $errorflag=-3; + $errorflag = -3; } } // Removed extrafields - if (! $error) + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->deleteExtraFields(); + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; - $errorflag=-4; + $errorflag = -4; dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); } } } // Remove adherent - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); - $errorflag=-5; + $errorflag = -5; } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -970,22 +970,22 @@ class Adherent extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted); // If new password not provided, we generate one - if (! $password) + if (!$password) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $password=getRandomPassword(false); + $password = getRandomPassword(false); } // Crypt password $password_crypted = dol_hash($password); $password_indatabase = ''; - if (! $isencrypted) + if (!$isencrypted) { $password_indatabase = $password; } @@ -994,61 +994,61 @@ class Adherent extends CommonObject // Mise a jour $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql.= " SET pass_crypted = '".$this->db->escape($password_crypted)."'"; + $sql .= " SET pass_crypted = '".$this->db->escape($password_crypted)."'"; //if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) if ($isencrypted) { - $sql.= ", pass = null"; + $sql .= ", pass = null"; } else { - $sql.= ", pass = '".$this->db->escape($password_indatabase)."'"; + $sql .= ", pass = '".$this->db->escape($password_indatabase)."'"; } - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; //dol_syslog("Adherent::Password sql=hidden"); dol_syslog(get_class($this)."::setPassword", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $nbaffectedrows=$this->db->affected_rows($result); + $nbaffectedrows = $this->db->affected_rows($result); if ($nbaffectedrows) { - $this->pass=$password; - $this->pass_indatabase=$password_indatabase; - $this->pass_indatabase_crypted=$password_crypted; + $this->pass = $password; + $this->pass_indatabase = $password_indatabase; + $this->pass_indatabase_crypted = $password_crypted; - if ($this->user_id && ! $nosyncuser) + if ($this->user_id && !$nosyncuser) { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // This member is linked with a user, so we also update users informations // if this is an update. - $luser=new User($this->db); - $result=$luser->fetch($this->user_id); + $luser = new User($this->db); + $result = $luser->fetch($this->user_id); if ($result >= 0) { - $result=$luser->setPassword($user, $this->pass, 0, 0, 1); + $result = $luser->setPassword($user, $this->pass, 0, 0, 1); if ($result < 0) { - $this->error=$luser->error; + $this->error = $luser->error; dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR); $error++; } } else { - $this->error=$luser->error; + $this->error = $luser->error; $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_NEW_PASSWORD', $user); + $result = $this->call_trigger('MEMBER_NEW_PASSWORD', $user); if ($result < 0) { $error++; $this->db->rollback(); return -1; } // End call triggers } @@ -1087,16 +1087,16 @@ class Adherent extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id; dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -1; } + if (!$resql) { $this->error = $this->db->error(); $this->db->rollback(); return -1; } // Set link to user if ($userid > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id; - $sql.= " WHERE rowid = ".$userid; + $sql .= " WHERE rowid = ".$userid; dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -2; } + if (!$resql) { $this->error = $this->db->error(); $this->db->rollback(); return -2; } } $this->db->commit(); @@ -1121,15 +1121,15 @@ class Adherent extends CommonObject if ($thirdpartyid > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = null"; - $sql.= " WHERE fk_soc = '".$thirdpartyid."'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " WHERE fk_soc = '".$thirdpartyid."'"; + $sql .= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::setThirdPartyId", LOG_DEBUG); $resql = $this->db->query($sql); } // Add link to third party for current member - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = ".($thirdpartyid>0 ? $thirdpartyid : 'null'); - $sql.= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = ".($thirdpartyid > 0 ? $thirdpartyid : 'null'); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::setThirdPartyId", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1140,7 +1140,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -1160,10 +1160,10 @@ class Adherent extends CommonObject global $conf; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql.= " WHERE login='".$this->db->escape($login)."'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " WHERE login='".$this->db->escape($login)."'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -1192,11 +1192,11 @@ class Adherent extends CommonObject global $conf; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql.= " WHERE firstname='".$this->db->escape($firstname)."'"; - $sql.= " AND lastname='".$this->db->escape($lastname)."'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " WHERE firstname='".$this->db->escape($firstname)."'"; + $sql .= " AND lastname='".$this->db->escape($lastname)."'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -1227,113 +1227,113 @@ class Adherent extends CommonObject global $langs; $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; - $sql.= " d.note_public,"; - $sql.= " d.email, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; - $sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; - $sql.= " d.datec as datec,"; - $sql.= " d.tms as datem,"; - $sql.= " d.datefin as datefin,"; - $sql.= " d.birth as birthday,"; - $sql.= " d.datevalid as datev,"; - $sql.= " d.country,"; - $sql.= " d.state_id,"; - $sql.= " d.model_pdf,"; - $sql.= " c.rowid as country_id, c.code as country_code, c.label as country,"; - $sql.= " dep.nom as state, dep.code_departement as state_code,"; - $sql.= " t.libelle as type, t.subscription as subscription,"; - $sql.= " u.rowid as user_id, u.login as user_login"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = dep.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member"; - $sql.= " WHERE d.fk_adherent_type = t.rowid"; - if ($rowid) $sql.= " AND d.rowid=".$rowid; + $sql .= " d.note_public,"; + $sql .= " d.email, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; + $sql .= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; + $sql .= " d.datec as datec,"; + $sql .= " d.tms as datem,"; + $sql .= " d.datefin as datefin,"; + $sql .= " d.birth as birthday,"; + $sql .= " d.datevalid as datev,"; + $sql .= " d.country,"; + $sql .= " d.state_id,"; + $sql .= " d.model_pdf,"; + $sql .= " c.rowid as country_id, c.code as country_code, c.label as country,"; + $sql .= " dep.nom as state, dep.code_departement as state_code,"; + $sql .= " t.libelle as type, t.subscription as subscription,"; + $sql .= " u.rowid as user_id, u.login as user_login"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = dep.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member"; + $sql .= " WHERE d.fk_adherent_type = t.rowid"; + if ($rowid) $sql .= " AND d.rowid=".$rowid; elseif ($ref || $fk_soc) { - $sql.= " AND d.entity IN (".getEntity('adherent').")"; - if ($ref) $sql.= " AND d.rowid='".$this->db->escape($ref)."'"; - elseif ($fk_soc > 0) $sql.= " AND d.fk_soc=".$fk_soc; + $sql .= " AND d.entity IN (".getEntity('adherent').")"; + if ($ref) $sql .= " AND d.rowid='".$this->db->escape($ref)."'"; + elseif ($fk_soc > 0) $sql .= " AND d.fk_soc=".$fk_soc; } elseif ($ref_ext) { - $sql.= " AND d.ref_ext='".$this->db->escape($ref_ext)."'"; + $sql .= " AND d.ref_ext='".$this->db->escape($ref_ext)."'"; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->entity = $obj->entity; - $this->ref = $obj->rowid; - $this->id = $obj->rowid; - $this->ref_ext = $obj->ref_ext; + $this->entity = $obj->entity; + $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref_ext = $obj->ref_ext; - $this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility + $this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility $this->civility_code = $obj->civility_code; - $this->civility = $obj->civility_code?($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code):''; + $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; $this->firstname = $obj->firstname; $this->lastname = $obj->lastname; - $this->gender = $obj->gender; + $this->gender = $obj->gender; $this->login = $obj->login; $this->societe = $obj->company; $this->company = $obj->company; $this->socid = $obj->fk_soc; - $this->fk_soc = $obj->fk_soc; // For backward compatibility + $this->fk_soc = $obj->fk_soc; // For backward compatibility $this->address = $obj->address; - $this->zip = $obj->zip; + $this->zip = $obj->zip; $this->town = $obj->town; $this->pass = $obj->pass; - $this->pass_indatabase = $obj->pass; + $this->pass_indatabase = $obj->pass; $this->pass_indatabase_crypted = $obj->pass_crypted; - $this->state_id = $obj->state_id; - $this->state_code = $obj->state_id?$obj->state_code:''; - $this->state = $obj->state_id?$obj->state:''; + $this->state_id = $obj->state_id; + $this->state_code = $obj->state_id ? $obj->state_code : ''; + $this->state = $obj->state_id ? $obj->state : ''; $this->country_id = $obj->country_id; - $this->country_code = $obj->country_code; + $this->country_code = $obj->country_code; if ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) $this->country = $langs->transnoentitiesnoconv("Country".$obj->country_code); else - $this->country=$obj->country; + $this->country = $obj->country; $this->phone = $obj->phone; - $this->phone_perso = $obj->phone_perso; - $this->phone_mobile = $obj->phone_mobile; + $this->phone_perso = $obj->phone_perso; + $this->phone_mobile = $obj->phone_mobile; $this->email = $obj->email; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); - $this->photo = $obj->photo; + $this->photo = $obj->photo; $this->statut = $obj->statut; $this->public = $obj->public; $this->datec = $this->db->jdate($obj->datec); $this->date_creation = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); - $this->date_modification= $this->db->jdate($obj->datem); - $this->datefin = $this->db->jdate($obj->datefin); - $this->datevalid = $this->db->jdate($obj->datev); - $this->date_validation = $this->db->jdate($obj->datev); - $this->birth = $this->db->jdate($obj->birthday); + $this->date_modification = $this->db->jdate($obj->datem); + $this->datefin = $this->db->jdate($obj->datefin); + $this->datevalid = $this->db->jdate($obj->datev); + $this->date_validation = $this->db->jdate($obj->datev); + $this->birth = $this->db->jdate($obj->birthday); - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; $this->morphy = $obj->morphy; $this->typeid = $obj->fk_adherent_type; - $this->type = $obj->type; - $this->need_subscription = $obj->subscription; + $this->type = $obj->type; + $this->need_subscription = $obj->subscription; - $this->user_id = $obj->user_id; - $this->user_login = $obj->user_login; + $this->user_id = $obj->user_id; + $this->user_login = $obj->user_login; - $this->model_pdf = $obj->model_pdf; + $this->model_pdf = $obj->model_pdf; // Retreive all extrafield // fetch optionals attributes and labels @@ -1343,7 +1343,7 @@ class Adherent extends CommonObject // Load other properties if ($fetch_subscriptions) { - $result=$this->fetch_subscriptions(); + $result = $this->fetch_subscriptions(); } return $this->id; @@ -1355,7 +1355,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1377,47 +1377,47 @@ class Adherent extends CommonObject require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $sql = "SELECT c.rowid, c.fk_adherent, c.subscription, c.note, c.fk_bank,"; - $sql.= " c.tms as datem,"; - $sql.= " c.datec as datec,"; - $sql.= " c.dateadh as dateh,"; - $sql.= " c.datef as datef"; - $sql.= " FROM ".MAIN_DB_PREFIX."subscription as c"; - $sql.= " WHERE c.fk_adherent = ".$this->id; - $sql.= " ORDER BY c.dateadh"; + $sql .= " c.tms as datem,"; + $sql .= " c.datec as datec,"; + $sql .= " c.dateadh as dateh,"; + $sql .= " c.datef as datef"; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription as c"; + $sql .= " WHERE c.fk_adherent = ".$this->id; + $sql .= " ORDER BY c.dateadh"; dol_syslog(get_class($this)."::fetch_subscriptions", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->subscriptions=array(); + $this->subscriptions = array(); - $i=0; + $i = 0; while ($obj = $this->db->fetch_object($resql)) { - if ($i==0) + if ($i == 0) { - $this->first_subscription_date=$this->db->jdate($obj->datec); - $this->first_subscription_date_start=$this->db->jdate($obj->dateh); - $this->first_subscription_date_end=$this->db->jdate($obj->datef); - $this->first_subscription_amount=$obj->subscription; + $this->first_subscription_date = $this->db->jdate($obj->datec); + $this->first_subscription_date_start = $this->db->jdate($obj->dateh); + $this->first_subscription_date_end = $this->db->jdate($obj->datef); + $this->first_subscription_amount = $obj->subscription; } - $this->last_subscription_date=$this->db->jdate($obj->datec); - $this->last_subscription_date_start=$this->db->jdate($obj->datef); - $this->last_subscription_date_end=$this->db->jdate($obj->datef); - $this->last_subscription_amount=$obj->subscription; + $this->last_subscription_date = $this->db->jdate($obj->datec); + $this->last_subscription_date_start = $this->db->jdate($obj->datef); + $this->last_subscription_date_end = $this->db->jdate($obj->datef); + $this->last_subscription_amount = $obj->subscription; - $subscription=new Subscription($this->db); - $subscription->id=$obj->rowid; - $subscription->fk_adherent=$obj->fk_adherent; - $subscription->amount=$obj->subscription; - $subscription->note=$obj->note; - $subscription->fk_bank=$obj->fk_bank; - $subscription->datem=$this->db->jdate($obj->datem); - $subscription->datec=$this->db->jdate($obj->datec); - $subscription->dateh=$this->db->jdate($obj->dateh); - $subscription->datef=$this->db->jdate($obj->datef); + $subscription = new Subscription($this->db); + $subscription->id = $obj->rowid; + $subscription->fk_adherent = $obj->fk_adherent; + $subscription->amount = $obj->subscription; + $subscription->note = $obj->note; + $subscription->fk_bank = $obj->fk_bank; + $subscription->datem = $this->db->jdate($obj->datem); + $subscription->datec = $this->db->jdate($obj->datec); + $subscription->dateh = $this->db->jdate($obj->dateh); + $subscription->datef = $this->db->jdate($obj->datef); - $this->subscriptions[]=$subscription; + $this->subscriptions[] = $subscription; $i++; } @@ -1425,7 +1425,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error = $this->db->error().' sql='.$sql; return -1; } } @@ -1447,20 +1447,20 @@ class Adherent extends CommonObject */ public function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0) { - global $conf,$langs,$user; + global $conf, $langs, $user; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; - $error=0; + $error = 0; // Clean parameters - if (! $amount) $amount=0; + if (!$amount) $amount = 0; $this->db->begin(); if ($datesubend) { - $datefin=$datesubend; + $datefin = $datesubend; } else { @@ -1470,30 +1470,30 @@ class Adherent extends CommonObject } // Create subscription - $subscription=new Subscription($this->db); - $subscription->fk_adherent=$this->id; - $subscription->dateh=$date; // Date of new subscription - $subscription->datef=$datefin; // End data of new subscription - $subscription->amount=$amount; - $subscription->note=$label; // deprecated - $subscription->note_public=$label; + $subscription = new Subscription($this->db); + $subscription->fk_adherent = $this->id; + $subscription->dateh = $date; // Date of new subscription + $subscription->datef = $datefin; // End data of new subscription + $subscription->amount = $amount; + $subscription->note = $label; // deprecated + $subscription->note_public = $label; - $rowid=$subscription->create($user); + $rowid = $subscription->create($user); if ($rowid > 0) { // Update denormalized subscription end date (read database subscription to find values) // This will also update this->datefin - $result=$this->update_end_date($user); + $result = $this->update_end_date($user); if ($result > 0) { // Change properties of object (used by triggers) - $this->last_subscription_date=dol_now(); - $this->last_subscription_date_start=$date; - $this->last_subscription_date_end=$datefin; - $this->last_subscription_amount=$amount; + $this->last_subscription_date = dol_now(); + $this->last_subscription_date_start = $date; + $this->last_subscription_date_end = $datefin; + $this->last_subscription_amount = $amount; } - if (! $error) + if (!$error) { $this->db->commit(); return $rowid; @@ -1506,8 +1506,8 @@ class Adherent extends CommonObject } else { - $this->error=$subscription->error; - $this->errors=$subscription->errors; + $this->error = $subscription->error; + $this->errors = $subscription->errors; $this->db->rollback(); return -1; } @@ -1537,7 +1537,7 @@ class Adherent extends CommonObject $error = 0; - $this->invoice = null; // This will contains invoice if an invoice is created + $this->invoice = null; // This will contains invoice if an invoice is created dol_syslog("subscriptionComplementaryActions subscriptionid=".$subscriptionid." option=".$option." accountid=".$accountid." datesubscription=".$datesubscription." paymentdate=".$paymentdate." label=".$label." amount=".$amount." num_chq=".$num_chq." autocreatethirdparty=".$autocreatethirdparty); @@ -1546,42 +1546,42 @@ class Adherent extends CommonObject { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $acct=new Account($this->db); - $result=$acct->fetch($accountid); + $acct = new Account($this->db); + $result = $acct->fetch($accountid); - $dateop=$paymentdate; + $dateop = $paymentdate; - $insertid=$acct->addline($dateop, $operation, $label, $amount, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); + $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); if ($insertid > 0) { - $inserturlid=$acct->add_url_line($insertid, $this->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $this->getFullname($langs), 'member'); + $inserturlid = $acct->add_url_line($insertid, $this->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $this->getFullname($langs), 'member'); if ($inserturlid > 0) { // Update table subscription - $sql ="UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; - $sql.=" WHERE rowid=".$subscriptionid; + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; + $sql .= " WHERE rowid=".$subscriptionid; dol_syslog("subscription::subscription", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->error=$this->db->lasterror(); - $this->errors[]=$this->error; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; } } else { $error++; - $this->error=$acct->error; - $this->errors=$acct->errors; + $this->error = $acct->error; + $this->errors = $acct->errors; } } else { $error++; - $this->error=$acct->error; - $this->errors=$acct->errors; + $this->error = $acct->error; + $this->errors = $acct->errors; } } @@ -1591,31 +1591,31 @@ class Adherent extends CommonObject require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; - $invoice=new Facture($this->db); - $customer=new Societe($this->db); + $invoice = new Facture($this->db); + $customer = new Societe($this->db); - if (! $error) + if (!$error) { - if (! ($this->fk_soc > 0)) // If not yet linked to a company + if (!($this->fk_soc > 0)) // If not yet linked to a company { if ($autocreatethirdparty) { // Create a linked thirdparty to member - $companyalias=''; + $companyalias = ''; $fullname = $this->getFullName($langs); if ($this->morphy == 'mor') { - $companyname=$this->company; - if (! empty($fullname)) $companyalias=$fullname; + $companyname = $this->company; + if (!empty($fullname)) $companyalias = $fullname; } else { - $companyname=$fullname; - if (! empty($this->company)) $companyalias=$this->company; + $companyname = $fullname; + if (!empty($this->company)) $companyalias = $this->company; } - $result=$customer->create_from_member($this, $companyname, $companyalias); + $result = $customer->create_from_member($this, $companyname, $companyalias); if ($result < 0) { $this->error = $customer->error; @@ -1630,54 +1630,54 @@ class Adherent extends CommonObject else { $langs->load("errors"); - $this->error=$langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst"); - $this->errors[]=$this->error; + $this->error = $langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst"); + $this->errors[] = $this->error; $error++; } } } - if (! $error) + if (!$error) { - $result=$customer->fetch($this->fk_soc); + $result = $customer->fetch($this->fk_soc); if ($result <= 0) { - $this->error=$customer->error; - $this->errors=$customer->errors; + $this->error = $customer->error; + $this->errors = $customer->errors; $error++; } } - if (! $error) + if (!$error) { // Create draft invoice - $invoice->type=Facture::TYPE_STANDARD; - $invoice->cond_reglement_id=$customer->cond_reglement_id; + $invoice->type = Facture::TYPE_STANDARD; + $invoice->cond_reglement_id = $customer->cond_reglement_id; if (empty($invoice->cond_reglement_id)) { - $paymenttermstatic=new PaymentTerm($this->db); - $invoice->cond_reglement_id=$paymenttermstatic->getDefaultId(); + $paymenttermstatic = new PaymentTerm($this->db); + $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId(); if (empty($invoice->cond_reglement_id)) { $error++; - $this->error='ErrorNoPaymentTermRECEPFound'; - $this->errors[]=$this->error; + $this->error = 'ErrorNoPaymentTermRECEPFound'; + $this->errors[] = $this->error; } } - $invoice->socid=$this->fk_soc; - $invoice->date=$datesubscription; + $invoice->socid = $this->fk_soc; + $invoice->date = $datesubscription; // Possibility to add external linked objects with hooks $invoice->linked_objects['subscription'] = $subscriptionid; - if (! empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects'])) + if (!empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects'])) { $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']); } - $result=$invoice->create($user); + $result = $invoice->create($user); if ($result <= 0) { - $this->error=$invoice->error; - $this->errors=$invoice->errors; + $this->error = $invoice->error; + $this->errors = $invoice->errors; $error++; } else @@ -1686,46 +1686,46 @@ class Adherent extends CommonObject } } - if (! $error) + if (!$error) { // Add line to draft invoice - $idprodsubscription=0; - if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS; + $idprodsubscription = 0; + if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS; - $vattouse=0; + $vattouse = 0; if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry') { - $vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription); + $vattouse = get_default_tva($mysoc, $mysoc, $idprodsubscription); } //print xx".$vattouse." - ".$mysoc." - ".$customer;exit; - $result=$invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription, '', 0, 0, '', 'TTC', $amount, 1); + $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription, '', 0, 0, '', 'TTC', $amount, 1); if ($result <= 0) { - $this->error=$invoice->error; - $this->errors=$invoice->errors; + $this->error = $invoice->error; + $this->errors = $invoice->errors; $error++; } } - if (! $error) + if (!$error) { // Validate invoice - $result=$invoice->validate($user); + $result = $invoice->validate($user); if ($result <= 0) { - $this->error=$invoice->error; - $this->errors=$invoice->errors; + $this->error = $invoice->error; + $this->errors = $invoice->errors; $error++; } } - if (! $error) + if (!$error) { // TODO Link invoice with subscription ? } // Add payment onto invoice - if (! $error && $option == 'bankviainvoice' && $accountid) + if (!$error && $option == 'bankviainvoice' && $accountid) { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -1741,61 +1741,61 @@ class Adherent extends CommonObject $paiement->num_payment = $num_chq; $paiement->note_public = $label; - if (! $error) + if (!$error) { // Create payment line for invoice $paiement_id = $paiement->create($user); - if (! $paiement_id > 0) + if (!$paiement_id > 0) { - $this->error=$paiement->error; - $this->errors=$paiement->errors; + $this->error = $paiement->error; + $this->errors = $paiement->errors; $error++; } } - if (! $error) + if (!$error) { // Add transaction into bank account - $bank_line_id=$paiement->addPaymentToBank($user, 'payment', '(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque); - if (! ($bank_line_id > 0)) + $bank_line_id = $paiement->addPaymentToBank($user, 'payment', '(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque); + if (!($bank_line_id > 0)) { - $this->error=$paiement->error; - $this->errors=$paiement->errors; + $this->error = $paiement->error; + $this->errors = $paiement->errors; $error++; } } - if (! $error && !empty($bank_line_id)) + if (!$error && !empty($bank_line_id)) { // Update fk_bank into subscription table $sql = 'UPDATE '.MAIN_DB_PREFIX.'subscription SET fk_bank='.$bank_line_id; - $sql.= ' WHERE rowid='.$subscriptionid; + $sql .= ' WHERE rowid='.$subscriptionid; $result = $this->db->query($sql); - if (! $result) + if (!$result) { $error++; } } - if (! $error) + if (!$error) { // Set invoice as paid $invoice->set_paid($user); } } - if (! $error) + if (!$error) { // Define output language $outputlangs = $langs; $newlang = ''; - $lang_id=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($lang_id)) + $lang_id = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($lang_id)) $newlang = $lang_id; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $customer->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -1825,10 +1825,10 @@ class Adherent extends CommonObject */ public function validate($user) { - global $langs,$conf; + global $langs, $conf; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Check parameters if ($this->statut == 1) @@ -1840,19 +1840,19 @@ class Adherent extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql.= " statut = 1"; - $sql.= ", datevalid = '".$this->db->idate($now)."'"; - $sql.= ", fk_user_valid=".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " statut = 1"; + $sql .= ", datevalid = '".$this->db->idate($now)."'"; + $sql .= ", fk_user_valid=".$user->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::validate", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $this->statut=1; + $this->statut = 1; // Call trigger - $result=$this->call_trigger('MEMBER_VALIDATE', $user); + $result = $this->call_trigger('MEMBER_VALIDATE', $user); if ($result < 0) { $error++; $this->db->rollback(); return -1; } // End call triggers @@ -1863,7 +1863,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -1878,9 +1878,9 @@ class Adherent extends CommonObject */ public function resiliate($user) { - global $langs,$conf; + global $langs, $conf; - $error=0; + $error = 0; // Check parameters if ($this->statut == 0) @@ -1892,17 +1892,17 @@ class Adherent extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql.= " statut = 0"; - $sql.= ", fk_user_valid=".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " statut = 0"; + $sql .= ", fk_user_valid=".$user->id; + $sql .= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); if ($result) { - $this->statut=0; + $this->statut = 0; // Call trigger - $result=$this->call_trigger('MEMBER_RESILIATE', $user); + $result = $this->call_trigger('MEMBER_RESILIATE', $user); if ($result < 0) { $error++; $this->db->rollback(); return -1; } // End call triggers @@ -1911,7 +1911,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -1927,43 +1927,43 @@ class Adherent extends CommonObject public function add_to_abo() { // phpcs:enable - global $conf,$langs; + global $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; - $mailmanspip=new MailmanSpip($this->db); + $mailmanspip = new MailmanSpip($this->db); - $err=0; + $err = 0; // mailman - if (! empty($conf->global->ADHERENT_USE_MAILMAN) && ! empty($conf->mailmanspip->enabled)) + if (!empty($conf->global->ADHERENT_USE_MAILMAN) && !empty($conf->mailmanspip->enabled)) { - $result=$mailmanspip->add_to_mailman($this); + $result = $mailmanspip->add_to_mailman($this); if ($result < 0) { - if (! empty($mailmanspip->error)) $this->errors[]=$mailmanspip->error; - $err+=1; + if (!empty($mailmanspip->error)) $this->errors[] = $mailmanspip->error; + $err += 1; } foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) { $langs->load("errors"); - $this->errors[]=$langs->trans("ErrorFailedToAddToMailmanList", $tmpemail, $tmplist); + $this->errors[] = $langs->trans("ErrorFailedToAddToMailmanList", $tmpemail, $tmplist); } foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) { $langs->load("mailmanspip"); - $this->mesgs[]=$langs->trans("SuccessToAddToMailmanList", $tmpemail, $tmplist); + $this->mesgs[] = $langs->trans("SuccessToAddToMailmanList", $tmpemail, $tmplist); } } // spip - if (! empty($conf->global->ADHERENT_USE_SPIP) && ! empty($conf->mailmanspip->enabled)) + if (!empty($conf->global->ADHERENT_USE_SPIP) && !empty($conf->mailmanspip->enabled)) { - $result=$mailmanspip->add_to_spip($this); + $result = $mailmanspip->add_to_spip($this); if ($result < 0) { - $this->errors[]=$mailmanspip->error; - $err+=1; + $this->errors[] = $mailmanspip->error; + $err += 1; } } if ($err) @@ -1986,42 +1986,42 @@ class Adherent extends CommonObject public function del_to_abo() { // phpcs:enable - global $conf,$langs; + global $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; - $mailmanspip=new MailmanSpip($this->db); + $mailmanspip = new MailmanSpip($this->db); - $err=0; + $err = 0; // mailman - if (! empty($conf->global->ADHERENT_USE_MAILMAN)) + if (!empty($conf->global->ADHERENT_USE_MAILMAN)) { - $result=$mailmanspip->del_to_mailman($this); + $result = $mailmanspip->del_to_mailman($this); if ($result < 0) { - if (! empty($mailmanspip->error)) $this->errors[]=$mailmanspip->error; - $err+=1; + if (!empty($mailmanspip->error)) $this->errors[] = $mailmanspip->error; + $err += 1; } foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) { $langs->load("errors"); - $this->errors[]=$langs->trans("ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist); + $this->errors[] = $langs->trans("ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist); } foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) { $langs->load("mailmanspip"); - $this->mesgs[]=$langs->trans("SuccessToRemoveToMailmanList", $tmpemail, $tmplist); + $this->mesgs[] = $langs->trans("SuccessToRemoveToMailmanList", $tmpemail, $tmplist); } } - if ($conf->global->ADHERENT_USE_SPIP && ! empty($conf->mailmanspip->enabled)) + if ($conf->global->ADHERENT_USE_SPIP && !empty($conf->mailmanspip->enabled)) { - $result=$mailmanspip->del_to_spip($this); + $result = $mailmanspip->del_to_spip($this); if ($result < 0) { - $this->errors[]=$mailmanspip->error; - $err+=1; + $this->errors[] = $mailmanspip->error; + $err += 1; } } if ($err) @@ -2046,7 +2046,7 @@ class Adherent extends CommonObject global $langs; $langs->load("dict"); - $code=(empty($this->civility_id)?'':$this->civility_id); + $code = (empty($this->civility_id) ? '' : $this->civility_id); if (empty($code)) return ''; return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); } @@ -2067,27 +2067,27 @@ class Adherent extends CommonObject { global $conf, $langs; - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg = 0; - $result=''; $label=''; - $linkstart=''; $linkend=''; + $result = ''; $label = ''; + $linkstart = ''; $linkend = ''; - if (! empty($this->photo)) + if (!empty($this->photo)) { - $label.= '
'; - $label.= Form::showphoto('memberphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1); - $label.= '
'; + $label .= '
'; + $label .= Form::showphoto('memberphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1); + $label .= '
'; } - $label.= '
'; - $label.= '' . $langs->trans("Member") . ''; - if (! empty($this->ref)) - $label.= '
' . $langs->trans('Ref') . ': ' . $this->ref; - if (! empty($this->firstname) || ! empty($this->lastname)) - $label.= '
' . $langs->trans('Name') . ': ' . $this->getFullName($langs); - if (! empty($this->company)) - $label.= '
' . $langs->trans('Company') . ': ' . $this->company; - $label.='
'; + $label .= '
'; + $label .= ''.$langs->trans("Member").''; + if (!empty($this->ref)) + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->firstname) || !empty($this->lastname)) + $label .= '
'.$langs->trans('Name').': '.$this->getFullName($langs); + if (!empty($this->company)) + $label .= '
'.$langs->trans('Company').': '.$this->company; + $label .= '
'; $url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id; if ($option == 'subscription') @@ -2098,54 +2098,54 @@ class Adherent extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkstart.= 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("users"); - $label=$langs->trans("ShowUser"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowUser"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - $linkstart.=$linkclose.'>'; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; - $result.=$linkstart; - if ($withpictoimg) $result.='
'; + $result .= $linkstart; + if ($withpictoimg) $result .= '
'; if ($withpictoimg) { - $paddafterimage=''; - if (abs($withpictoimg) == 1) $paddafterimage='style="margin-right: 3px;"'; + $paddafterimage = ''; + if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-right: 3px;"'; // Only picto - if ($withpictoimg > 0) $picto=''.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).''; + if ($withpictoimg > 0) $picto = ''.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).''; // Picto must be a photo else { - $picto=''; - $picto.=Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1); - $picto.=''; + $picto = ''; + $picto .= Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1); + $picto .= ''; } - $result.=$picto; + $result .= $picto; } if ($withpictoimg > -2 && $withpictoimg != 2) { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.=''; - if ($mode == 'login') $result.=dol_trunc($this->login, $maxlen); - elseif ($mode == 'ref') $result.=$this->id; - else $result.=$this->getFullName($langs, '', ($mode == 'firstname' ? 2 : -1), $maxlen); - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.=''; + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= ''; + if ($mode == 'login') $result .= dol_trunc($this->login, $maxlen); + elseif ($mode == 'ref') $result .= $this->id; + else $result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : -1), $maxlen); + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= ''; } - if ($withpictoimg) $result.='
'; - $result.=$linkend; + if ($withpictoimg) $result .= '
'; + $result .= $linkend; return $result; } @@ -2194,7 +2194,7 @@ class Adherent extends CommonObject $labelStatus = $langs->trans("MemberStatusNoSubscription"); $labelStatusShort = $langs->trans("MemberStatusNoSubscriptionShort"); } - elseif (! $date_end_subscription) + elseif (!$date_end_subscription) { $statusType = 'status1'; $labelStatus = $langs->trans("MemberStatusActive"); @@ -2237,16 +2237,16 @@ class Adherent extends CommonObject $this->nb = array(); $sql = "SELECT count(a.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; - $sql.= " WHERE a.statut > 0"; - $sql.= " AND a.entity IN (".getEntity('adherent').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; + $sql .= " WHERE a.statut > 0"; + $sql .= " AND a.entity IN (".getEntity('adherent').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["members"]=$obj->nb; + $this->nb["members"] = $obj->nb; } $this->db->free($resql); return 1; @@ -2254,7 +2254,7 @@ class Adherent extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2341,7 +2341,7 @@ class Adherent extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2360,16 +2360,16 @@ class Adherent extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("orders"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'standard'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->ADHERENT_ADDON_PDF)) { + } elseif (!empty($conf->global->ADHERENT_ADDON_PDF)) { $modele = $conf->global->ADHERENT_ADDON_PDF; } } @@ -2389,17 +2389,17 @@ class Adherent extends CommonObject */ public function initAsSpecimen() { - global $user,$langs; + global $user, $langs; // Initialise parametres - $this->id=0; - $this->specimen=1; + $this->id = 0; + $this->specimen = 1; $this->civility_id = 0; $this->lastname = 'DOLIBARR'; $this->firstname = 'SPECIMEN'; - $this->gender='man'; - $this->login='dolibspec'; - $this->pass='dolibspec'; + $this->gender = 'man'; + $this->login = 'dolibspec'; + $this->pass = 'dolibspec'; $this->company = 'Societe ABC'; $this->address = '61 jump street'; $this->zip = '75000'; @@ -2418,28 +2418,28 @@ class Adherent extends CommonObject $this->phone = '0999999999'; $this->phone_perso = '0999999998'; $this->phone_mobile = '0999999997'; - $this->note_private='No comment'; - $this->birth=time(); - $this->photo=''; - $this->public=1; - $this->statut=0; + $this->note_private = 'No comment'; + $this->birth = time(); + $this->photo = ''; + $this->public = 1; + $this->statut = 0; - $this->datefin=time(); - $this->datevalid=time(); + $this->datefin = time(); + $this->datevalid = time(); - $this->typeid=1; // Id type adherent - $this->type='Type adherent'; // Libelle type adherent - $this->need_subscription=0; + $this->typeid = 1; // Id type adherent + $this->type = 'Type adherent'; // Libelle type adherent + $this->need_subscription = 0; - $this->first_subscription_date=time(); - $this->first_subscription_date_start=$this->first_subscription_date; - $this->first_subscription_date_end=dol_time_plus_duree($this->first_subscription_date_start, 1, 'y'); - $this->first_subscription_amount=10; + $this->first_subscription_date = time(); + $this->first_subscription_date_start = $this->first_subscription_date; + $this->first_subscription_date_end = dol_time_plus_duree($this->first_subscription_date_start, 1, 'y'); + $this->first_subscription_amount = 10; - $this->last_subscription_date=$this->first_subscription_date; - $this->last_subscription_date_start=$this->first_subscription_date; - $this->last_subscription_date_end=dol_time_plus_duree($this->last_subscription_date_start, 1, 'y'); - $this->last_subscription_amount=10; + $this->last_subscription_date = $this->first_subscription_date; + $this->last_subscription_date_start = $this->first_subscription_date; + $this->last_subscription_date_end = dol_time_plus_duree($this->last_subscription_date_start, 1, 'y'); + $this->last_subscription_amount = 10; } @@ -2458,10 +2458,10 @@ class Adherent extends CommonObject { // phpcs:enable global $conf; - $dn=''; - if ($mode==0) $dn=$conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS].",".$conf->global->LDAP_MEMBER_DN; - if ($mode==1) $dn=$conf->global->LDAP_MEMBER_DN; - if ($mode==2) $dn=$conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS]; + $dn = ''; + if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS].",".$conf->global->LDAP_MEMBER_DN; + if ($mode == 1) $dn = $conf->global->LDAP_MEMBER_DN; + if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS]; return $dn; } @@ -2476,15 +2476,15 @@ class Adherent extends CommonObject public function _load_ldap_info() { // phpcs:enable - global $conf,$langs; + global $conf, $langs; - $info=array(); - $keymodified=false; + $info = array(); + $keymodified = false; // Object classes - $info["objectclass"]=explode(',', $conf->global->LDAP_MEMBER_OBJECT_CLASS); + $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_OBJECT_CLASS); - $this->fullname=$this->getFullName($langs); + $this->fullname = $this->getFullName($langs); // For avoid ldap error when firstname and lastname are empty if ($this->morphy == 'mor' && (empty($this->fullname) || $this->fullname == $this->company)) { @@ -2504,53 +2504,53 @@ class Adherent extends CommonObject // Member foreach ($ldapkey as $constname => $varname) { - if (! empty($this->$varname) && ! empty($conf->global->$constname)) + if (!empty($this->$varname) && !empty($conf->global->$constname)) { $info[$conf->global->$constname] = $this->$varname; // Check if it is the LDAP key and if its value has been changed - if (! empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) + if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) { - if (! empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) $keymodified=true; // For check if LDAP key has been modified + if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) $keymodified = true; // For check if LDAP key has been modified } } } - if ($this->firstname && ! empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname; - if ($this->poste && ! empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste; - if ($this->company && ! empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company; - if ($this->address && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address; - if ($this->zip && ! empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; - if ($this->town && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; - if ($this->country_code && ! empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; - if ($this->skype && ! empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; - if ($this->twitter && ! empty($conf->global->LDAP_MEMBER_FIELD_TWITTER)) $info[$conf->global->LDAP_MEMBER_FIELD_TWITTER] = $this->twitter; - if ($this->facebook && ! empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook; - if ($this->linkedin && ! empty($conf->global->LDAP_MEMBER_FIELD_LINKEDIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LINKEDIN] = $this->linkedin; - if ($this->phone && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; - if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; - if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; - if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; - if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); - if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 2); - if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth, 'dayhourldap'); - if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut; - if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin, 'dayhourldap'); + if ($this->firstname && !empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname; + if ($this->poste && !empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste; + if ($this->company && !empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company; + if ($this->address && !empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address; + if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; + if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; + if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; + if ($this->skype && !empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; + if ($this->twitter && !empty($conf->global->LDAP_MEMBER_FIELD_TWITTER)) $info[$conf->global->LDAP_MEMBER_FIELD_TWITTER] = $this->twitter; + if ($this->facebook && !empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook; + if ($this->linkedin && !empty($conf->global->LDAP_MEMBER_FIELD_LINKEDIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LINKEDIN] = $this->linkedin; + if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; + if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; + if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; + if ($this->fax && !empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; + if ($this->note_private && !empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); + if ($this->note_public && !empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 2); + if ($this->birth && !empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth, 'dayhourldap'); + if (isset($this->statut) && !empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut; + if ($this->datefin && !empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin, 'dayhourldap'); // When password is modified - if (! empty($this->pass)) + if (!empty($this->pass)) { - if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte - if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) + if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte + if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) } // Set LDAP password if possible elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password { - if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) + if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { // Just for the default MD5 ! if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) { - if ($this->pass_indatabase_crypted && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) { + if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) { // Create OpenLDAP MD5 password from Dolibarr MD5 password // Note: This suppose that "pass_indatabase_crypted" is a md5 (guaranted by the previous test if "(empty($conf->global->MAIN_SECURITY_HASH_ALGO))" $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}'.base64_encode(hex2bin($this->pass_indatabase_crypted)); @@ -2558,18 +2558,18 @@ class Adherent extends CommonObject } } // Use $this->pass_indatabase value if exists - elseif (! empty($this->pass_indatabase)) + elseif (!empty($this->pass_indatabase)) { - if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase; // $this->pass_indatabase = mot de passe non crypte - if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase, 4); // md5 for OpenLdap TODO add type of encryption + if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase; // $this->pass_indatabase = mot de passe non crypte + if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase, 4); // md5 for OpenLdap TODO add type of encryption } } // Subscriptions - if ($this->first_subscription_date && ! empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] = dol_print_date($this->first_subscription_date, 'dayhourldap'); - if (isset($this->first_subscription_amount) && ! empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount; - if ($this->last_subscription_date && ! empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] = dol_print_date($this->last_subscription_date, 'dayhourldap'); - if (isset($this->last_subscription_amount) && ! empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount; + if ($this->first_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] = dol_print_date($this->first_subscription_date, 'dayhourldap'); + if (isset($this->first_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount; + if ($this->last_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] = dol_print_date($this->last_subscription_date, 'dayhourldap'); + if (isset($this->last_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount; return $info; } @@ -2584,14 +2584,14 @@ class Adherent extends CommonObject public function info($id) { $sql = 'SELECT a.rowid, a.datec as datec,'; - $sql.= ' a.datevalid as datev,'; - $sql.= ' a.tms as datem,'; - $sql.= ' a.fk_user_author, a.fk_user_valid, a.fk_user_mod'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'adherent as a'; - $sql.= ' WHERE a.rowid = '.$id; + $sql .= ' a.datevalid as datev,'; + $sql .= ' a.tms as datem,'; + $sql .= ' a.fk_user_author, a.fk_user_valid, a.fk_user_mod'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'adherent as a'; + $sql .= ' WHERE a.rowid = '.$id; dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -2602,7 +2602,7 @@ class Adherent extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -2640,22 +2640,22 @@ class Adherent extends CommonObject public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql.= " WHERE mc.email = '".$this->db->escape($this->email)."'"; - $sql.= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " WHERE mc.email = '".$this->db->escape($this->email)."'"; + $sql .= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - $nb=$obj->nb; + $nb = $obj->nb; $this->db->free($resql); return $nb; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2678,7 +2678,7 @@ class Adherent extends CommonObject } // Get current categories - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, Categorie::TYPE_MEMBER, 'id'); @@ -2734,7 +2734,7 @@ class Adherent extends CommonObject //Only valid members if ($this->statut <= 0) return false; - if (! $this->datefin) return false; + if (!$this->datefin) return false; $now = dol_now(); @@ -2756,7 +2756,7 @@ class Adherent extends CommonObject $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; $blockingerrormsg = ''; @@ -2780,24 +2780,24 @@ class Adherent extends CommonObject $listofmembersok = array(); $listofmembersko = array(); - $arraydaysbeforeend=explode(';', $daysbeforeendlist); - foreach($arraydaysbeforeend as $daysbeforeend) // Loop on each delay + $arraydaysbeforeend = explode(';', $daysbeforeendlist); + foreach ($arraydaysbeforeend as $daysbeforeend) // Loop on each delay { dol_syslog(__METHOD__.' - Process delta = '.$daysbeforeend, LOG_DEBUG); - if (! is_numeric($daysbeforeend)) + if (!is_numeric($daysbeforeend)) { - $blockingerrormsg="Value for delta is not a positive or negative numeric"; + $blockingerrormsg = "Value for delta is not a positive or negative numeric"; $nbko++; break; } - $tmp=dol_getdate($now); + $tmp = dol_getdate($now); $datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), $daysbeforeend, 'd'); $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent'; - $sql.= " WHERE entity = ".$conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only; - $sql.= " AND datefin = '".$this->db->idate($datetosearchfor)."'"; + $sql .= " WHERE entity = ".$conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only; + $sql .= " AND datefin = '".$this->db->idate($datetosearchfor)."'"; $resql = $this->db->query($sql); if ($resql) @@ -2808,7 +2808,7 @@ class Adherent extends CommonObject $adherent = new Adherent($this->db); $formmail = new FormMail($this->db); - $i=0; + $i = 0; while ($i < $num_rows) { $obj = $this->db->fetch_object($resql); @@ -2818,7 +2818,7 @@ class Adherent extends CommonObject if (empty($adherent->email)) { $nbko++; - $listofmembersko[$adherent->id]=$adherent->id; + $listofmembersko[$adherent->id] = $adherent->id; } else { @@ -2834,14 +2834,14 @@ class Adherent extends CommonObject $outputlangs->loadLangs(array("main", "members")); dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang." mysoc->default_lang=".$mysoc->default_lang); - $arraydefaultmessage=null; + $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION; - if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $adherent); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $adherent); //if (is_array($adherent->thirdparty)) $substitutionarraycomp = ... complete_substitutions_array($substitutionarray, $outputlangs, $adherent); @@ -2851,42 +2851,42 @@ class Adherent extends CommonObject $to = $adherent->email; $trackid = 'mem'.$adherent->id; - $moreinheader='X-Dolibarr-Info: sendReminderForExpiredSubscription'."\r\n"; + $moreinheader = 'X-Dolibarr-Info: sendReminderForExpiredSubscription'."\r\n"; include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, $moreinheader); $result = $cmail->sendfile(); - if (! $result) + if (!$result) { $error++; $this->error = $cmail->error; - if (! is_null($cmail->errors)) { + if (!is_null($cmail->errors)) { $this->errors += $cmail->errors; } $nbko++; - $listofmembersko[$adherent->id]=$adherent->id; + $listofmembersko[$adherent->id] = $adherent->id; } else { $nbok++; - $listofmembersok[$adherent->id]=$adherent->id; + $listofmembersok[$adherent->id] = $adherent->id; $message = $msg; $sendto = $to; $sendtocc = ''; $sendtobcc = ''; - $actioncode='EMAIL'; - $extraparams=''; + $actioncode = 'EMAIL'; + $extraparams = ''; - $actionmsg=''; - $actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1); + $actionmsg = ''; + $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1); if ($message) { - $actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); - $actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc)); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); $actionmsg = dol_concatdesc($actionmsg, $message); } @@ -2895,22 +2895,22 @@ class Adherent extends CommonObject // Insert record of emails sent $actioncomm = new ActionComm($this->db); - $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$actioncode; $actioncomm->label = $actionmsg2; - $actioncomm->note_private= $actionmsg; + $actioncomm->note_private = $actionmsg; $actioncomm->fk_project = 0; $actioncomm->datep = $now; $actioncomm->datef = $now; - $actioncomm->percentage = -1; // Not applicable + $actioncomm->percentage = -1; // Not applicable $actioncomm->socid = $adherent->thirdparty->id; $actioncomm->contactid = 0; - $actioncomm->authorid = $user->id; // User saving action - $actioncomm->userownerid = $user->id; // Owner of action + $actioncomm->authorid = $user->id; // User saving action + $actioncomm->userownerid = $user->id; // Owner of action // Fields when action is en email (content should be added into note) $actioncomm->email_msgid = $cmail->msgid; $actioncomm->email_from = $from; - $actioncomm->email_sender= ''; + $actioncomm->email_sender = ''; $actioncomm->email_to = $to; $actioncomm->email_tocc = $sendtocc; $actioncomm->email_tobcc = $sendtobcc; @@ -2927,10 +2927,10 @@ class Adherent extends CommonObject } else { - $blockingerrormsg="Can't find email template, defined into member module setup, to use for reminding"; + $blockingerrormsg = "Can't find email template, defined into member module setup, to use for reminding"; $nbko++; - $listofmembersko[$adherent->id]=$adherent->id; + $listofmembersko[$adherent->id] = $adherent->id; break; } @@ -2954,10 +2954,10 @@ class Adherent extends CommonObject else { $this->output = 'Found '.($nbok + $nbko).' members to send reminder to.'; - $this->output.= ' Send email successfuly to '.$nbok.' members'; + $this->output .= ' Send email successfuly to '.$nbok.' members'; if (is_array($listofmembersok)) { $listofids = ''; $i = 0; - foreach($listofmembersok as $idmember) { + foreach ($listofmembersok as $idmember) { if ($i > 100) { $listofids .= ', ...'; break; @@ -2971,10 +2971,10 @@ class Adherent extends CommonObject $this->output .= $listofids; } if ($nbko) { - $this->output.= ' - Canceled for '.$nbko.' member (no email or email sending error)'; + $this->output .= ' - Canceled for '.$nbko.' member (no email or email sending error)'; if (is_array($listofmembersko)) { $listofids = ''; $i = 0; - foreach($listofmembersko as $idmember) { + foreach ($listofmembersko as $idmember) { if ($i > 100) { $listofids .= ', ...'; break; diff --git a/htdocs/index.php b/htdocs/index.php index c73dbf25ea8..a856a51ac8d 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -285,7 +285,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) DOL_URL_ROOT.'/don/list.php?leftmenu=donations' ); // Translation lang files - $langfile=array( + $langfile = array( "users", "companies", "prospects", @@ -359,89 +359,89 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $dashboardlines = array(); // Do not include sections without management permission - require_once DOL_DOCUMENT_ROOT . '/core/class/workboardresponse.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; // Number of actions to do (late) if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) { - include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; + include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $board = new ActionComm($db); $dashboardlines[$board->element] = $board->load_board($user); } // Number of project opened if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $board = new Project($db); $dashboardlines[$board->element] = $board->load_board($user); } // Number of tasks to do (late) if (!empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php'; + include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $board = new Task($db); $dashboardlines[$board->element] = $board->load_board($user); } // Number of commercial proposals opened (expired) if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { - include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $board = new Propal($db); - $dashboardlines[$board->element . '_opened'] = $board->load_board($user, "opened"); + $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened"); // Number of commercial proposals CLOSED signed (billed) - $dashboardlines[$board->element . '_signed'] = $board->load_board($user, "signed"); + $dashboardlines[$board->element.'_signed'] = $board->load_board($user, "signed"); } // Number of commercial proposals opened (expired) if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { - include_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; + include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; $board = new SupplierProposal($db); - $dashboardlines[$board->element . '_opened'] = $board->load_board($user, "opened"); + $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened"); // Number of commercial proposals CLOSED signed (billed) - $dashboardlines[$board->element . '_signed'] = $board->load_board($user, "signed"); + $dashboardlines[$board->element.'_signed'] = $board->load_board($user, "signed"); } // Number of customer orders a deal if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { - include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $board = new Commande($db); $dashboardlines[$board->element] = $board->load_board($user); } // Number of suppliers orders a deal if (!empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire) { - include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $board = new CommandeFournisseur($db); - $dashboardlines[$board->element . '_opened'] = $board->load_board($user, "opened"); - $dashboardlines[$board->element . '_awaiting'] = $board->load_board($user, 'awaiting'); + $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened"); + $dashboardlines[$board->element.'_awaiting'] = $board->load_board($user, 'awaiting'); } // Number of services enabled (delayed) if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { - include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $board = new Contrat($db); - $dashboardlines[$board->element . '_inactive'] = $board->load_board($user, "inactive"); + $dashboardlines[$board->element.'_inactive'] = $board->load_board($user, "inactive"); // Number of active services (expired) - $dashboardlines[$board->element . '_active'] = $board->load_board($user, "active"); + $dashboardlines[$board->element.'_active'] = $board->load_board($user, "active"); } // Number of invoices customers (has paid) if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { - include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $board = new Facture($db); $dashboardlines[$board->element] = $board->load_board($user); } // Number of supplier invoices (has paid) if (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->fournisseur->facture->lire)) { - include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $board = new FactureFournisseur($db); $dashboardlines[$board->element] = $board->load_board($user); } // Number of transactions to conciliate if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->socid) { - include_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $board = new Account($db); - $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate + $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate if ($nb > 0) { $dashboardlines[$board->element] = $board->load_board($user); } @@ -449,36 +449,36 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { // Number of cheque to send if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->socid && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) { - include_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php'; + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; $board = new RemiseCheque($db); $dashboardlines['RemiseCheque'] = $board->load_board($user); } // Number of foundation members if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire && !$user->socid) { - include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $board = new Adherent($db); - $dashboardlines[$board->element . '_shift'] = $board->load_board($user, 'shift'); - $dashboardlines[$board->element . '_expired'] = $board->load_board($user, 'expired'); + $dashboardlines[$board->element.'_shift'] = $board->load_board($user, 'shift'); + $dashboardlines[$board->element.'_expired'] = $board->load_board($user, 'expired'); } // Number of expense reports to approve if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) { - include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; + include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $board = new ExpenseReport($db); $dashboardlines['ExpenseReport'] = $board->load_board($user, 'toapprove'); } // Number of expense reports to pay if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) { - include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; + include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $board = new ExpenseReport($db); $dashboardlines['ExpenseReport'] = $board->load_board($user, 'topay'); } // Number of holidays to approve if (!empty($conf->holiday->enabled) && $user->rights->holiday->approve) { - include_once DOL_DOCUMENT_ROOT . '/holiday/class/holiday.class.php'; + include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; $board = new Holiday($db); $dashboardlines['Holiday'] = $board->load_board($user); } @@ -877,23 +877,23 @@ print '
'; * Show boxes */ -$boxlist.='
'; +$boxlist .= '
'; -$boxlist.='
'; -if(!empty($nbworkboardcount)) +$boxlist .= '
'; +if (!empty($nbworkboardcount)) { - $boxlist.=$boxwork; + $boxlist .= $boxwork; } -$boxlist.=$resultboxes['boxlista']; +$boxlist .= $resultboxes['boxlista']; -$boxlist.= '
'; +$boxlist .= '
'; if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { // Remove allready present info in new dash board - if(!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0){ + if (!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0) { foreach ($boxstatItems as $boxstatItemKey => $boxstatItemHtml) { if (in_array($boxstatItemKey, $globalStatInTopOpenedDashBoard)) { unset($boxstatItems[$boxstatItemKey]); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 8ae94aa536b..c288314947f 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -34,54 +34,54 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (! empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -if (! empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; -if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; -if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; -if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; -if (! empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; -if (! empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (!empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; +if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +if (!empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +if (!empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +if (!empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; +if (!empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; +if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; // Load translation files required by the page $langs->loadLangs(array('projects', 'companies', 'suppliers', 'compta')); -if (! empty($conf->facture->enabled)) $langs->load("bills"); -if (! empty($conf->commande->enabled)) $langs->load("orders"); -if (! empty($conf->propal->enabled)) $langs->load("propal"); -if (! empty($conf->ficheinter->enabled)) $langs->load("interventions"); -if (! empty($conf->deplacement->enabled)) $langs->load("trips"); -if (! empty($conf->expensereport->enabled)) $langs->load("trips"); -if (! empty($conf->don->enabled)) $langs->load("donations"); -if (! empty($conf->loan->enabled)) $langs->load("loan"); -if (! empty($conf->salaries->enabled)) $langs->load("salaries"); +if (!empty($conf->facture->enabled)) $langs->load("bills"); +if (!empty($conf->commande->enabled)) $langs->load("orders"); +if (!empty($conf->propal->enabled)) $langs->load("propal"); +if (!empty($conf->ficheinter->enabled)) $langs->load("interventions"); +if (!empty($conf->deplacement->enabled)) $langs->load("trips"); +if (!empty($conf->expensereport->enabled)) $langs->load("trips"); +if (!empty($conf->don->enabled)) $langs->load("donations"); +if (!empty($conf->loan->enabled)) $langs->load("loan"); +if (!empty($conf->salaries->enabled)) $langs->load("salaries"); -$id=GETPOST('id', 'int'); -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$datesrfc=GETPOST('datesrfc'); -$dateerfc=GETPOST('dateerfc'); -$dates=dol_mktime(0, 0, 0, GETPOST('datesmonth'), GETPOST('datesday'), GETPOST('datesyear')); -$datee=dol_mktime(23, 59, 59, GETPOST('dateemonth'), GETPOST('dateeday'), GETPOST('dateeyear')); -if (empty($dates) && ! empty($datesrfc)) $dates=dol_stringtotime($datesrfc); -if (empty($datee) && ! empty($dateerfc)) $datee=dol_stringtotime($dateerfc); -if (! isset($_POST['datesrfc']) && ! isset($_POST['datesday']) && ! empty($conf->global->PROJECT_LINKED_ELEMENT_DEFAULT_FILTER_YEAR)) +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$datesrfc = GETPOST('datesrfc'); +$dateerfc = GETPOST('dateerfc'); +$dates = dol_mktime(0, 0, 0, GETPOST('datesmonth'), GETPOST('datesday'), GETPOST('datesyear')); +$datee = dol_mktime(23, 59, 59, GETPOST('dateemonth'), GETPOST('dateeday'), GETPOST('dateeyear')); +if (empty($dates) && !empty($datesrfc)) $dates = dol_stringtotime($datesrfc); +if (empty($datee) && !empty($dateerfc)) $datee = dol_stringtotime($dateerfc); +if (!isset($_POST['datesrfc']) && !isset($_POST['datesday']) && !empty($conf->global->PROJECT_LINKED_ELEMENT_DEFAULT_FILTER_YEAR)) { - $new=dol_now(); - $tmp=dol_getdate($new); + $new = dol_now(); + $tmp = dol_getdate($new); //$datee=$now //$dates=dol_time_plus_duree($datee, -1, 'y'); - $dates=dol_get_first_day($tmp['year'], 1); + $dates = dol_get_first_day($tmp['year'], 1); } if ($id == '' && $ref == '') { @@ -90,18 +90,18 @@ if ($id == '' && $ref == '') exit(); } -$mine = $_REQUEST['mode']=='mine' ? 1 : 0; +$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $object = new Project($db); -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check -$socid=$object->socid; +$socid = $object->socid; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -$result = restrictedArea($user, 'projet', $object->id, 'projet&project'); +$result = restrictedArea($user, 'projet', $object->id, 'projet&project'); $hookmanager->initHooks(array('projectOverview')); @@ -163,23 +163,23 @@ print '
'; print ''; foreach ($listofreferent as $key => $value) { - $name=$langs->trans($value['name']); - $title=$value['title']; - $classname=$value['class']; - $tablename=$value['table']; - $datefieldname=$value['datefieldname']; - $qualified=$value['test']; + $name = $langs->trans($value['name']); + $title = $value['title']; + $classname = $value['class']; + $tablename = $value['table']; + $datefieldname = $value['datefieldname']; + $qualified = $value['test']; $margin = $value['margin']; $project_field = $value['project_field']; if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'plus') { $element = new $classname($db); - $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field)?$project_field:'fk_projet'); + $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field : 'fk_projet'); - if (count($elementarray)>0 && is_array($elementarray)) + if (count($elementarray) > 0 && is_array($elementarray)) { $total_ht = 0; $total_ttc = 0; - $num=count($elementarray); + $num = count($elementarray); for ($i = 0; $i < $num; $i++) { - $tmp=explode('_', $elementarray[$i]); - $idofelement=$tmp[0]; - $idofelementuser=$tmp[1]; + $tmp = explode('_', $elementarray[$i]); + $idofelement = $tmp[0]; + $idofelementuser = $tmp[1]; $element->fetch($idofelement); if ($idofelementuser) $elementuser->fetch($idofelementuser); // Define if record must be used for total or not - $qualifiedfortotal=true; + $qualifiedfortotal = true; if ($key == 'invoice') { - if (! empty($element->close_code) && $element->close_code == 'replaced') $qualifiedfortotal=false; // Replacement invoice, do not include into total - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $element->type == Facture::TYPE_DEPOSIT) $qualifiedfortotal=false; // If hidden option to use deposits as payment (deprecated, not recommended to use this), deposits are not included + if (!empty($element->close_code) && $element->close_code == 'replaced') $qualifiedfortotal = false; // Replacement invoice, do not include into total + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $element->type == Facture::TYPE_DEPOSIT) $qualifiedfortotal = false; // If hidden option to use deposits as payment (deprecated, not recommended to use this), deposits are not included } if ($key == 'propal') { - if ($element->statut == Propal::STATUS_NOTSIGNED) $qualifiedfortotal=false; // Refused proposal must not be included in total + if ($element->statut == Propal::STATUS_NOTSIGNED) $qualifiedfortotal = false; // Refused proposal must not be included in total } if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); // Define $total_ht_by_line - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ht_by_line=$element->amount; - elseif ($tablename == 'fichinter') $total_ht_by_line=$element->getAmount(); - elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty); + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ht_by_line = $element->amount; + elseif ($tablename == 'fichinter') $total_ht_by_line = $element->getAmount(); + elseif ($tablename == 'stock_mouvement') $total_ht_by_line = $element->price * abs($element->qty); elseif ($tablename == 'projet_task') { if ($idofelementuser) @@ -759,49 +759,49 @@ foreach ($listofreferent as $key => $value) $element = new $classname($db); - $addform=''; + $addform = ''; - $idtofilterthirdparty=0; + $idtofilterthirdparty = 0; $array_of_element_linkable_with_different_thirdparty = array('facture_fourn', 'commande_fournisseur'); - if (! in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) + if (!in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) { - $idtofilterthirdparty=$object->thirdparty->id; - if (! empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty.=','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS; + $idtofilterthirdparty = $object->thirdparty->id; + if (!empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty .= ','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS; } if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) { - $selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300', -2, !empty($project_field)?$project_field:'fk_projet'); - if ($selectList<0) + $selectList = $formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300', -2, !empty($project_field) ? $project_field : 'fk_projet'); + if ($selectList < 0) { setEventMessages($formproject->error, $formproject->errors, 'errors'); } - elseif($selectList) + elseif ($selectList) { // Define form with the combo list of elements to link - $addform.='
'; - $addform.=''; - $addform.=''; - $addform.=''; - $addform.=''; - $addform.=''; - $addform.=''; - $addform.='
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("UserAgent").''.$_SERVER['HTTP_USER_AGENT'].'
'.$langs->trans("UserAgent").''.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).'
'.$langs->trans("BrowserName").''.$tmp['browsername'].'
'.$langs->trans("BrowserOS").''.$tmp['browseros'].'
'.$langs->trans("Version").''.$tmp['browserversion'].'
'.$langs->trans("Layout").' (phone/tablet/classic)'.$tmp['layout'].'
'.$langs->trans("IPAddress").''.$_SERVER['REMOTE_ADDR'].'
'.$langs->trans("IPAddress").''.dol_escape_htmltag($_SERVER['REMOTE_ADDR']); +if (! empty($_SERVER['HTTP_CLIENT_IP'])) print ' (HTTP_CLIENT_IP='.dol_escape_htmltag($_SERVER['HTTP_CLIENT_IP']).')'; +if (! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) print ' (HTTP_X_FORWARDED_FOR='.dol_escape_htmltag($_SERVER['HTTP_X_FORWARDED_FOR']).')'; +print '
'.$langs->trans("SessionName").''.session_name().'
'.$langs->trans("SessionId").''.session_id().'
'; print $langs->trans("Usage"); print ''; -if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
'; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; + print 'usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
'; } -if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) +if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
'; @@ -510,19 +510,19 @@ $listofreferent = array( */ ); -$parameters=array('listofreferent'=>$listofreferent); +$parameters = array('listofreferent'=>$listofreferent); $resHook = $hookmanager->executeHooks('completeListOfReferent', $parameters, $object, $action); -if(!empty($hookmanager->resArray)) { +if (!empty($hookmanager->resArray)) { $listofreferent = array_merge($listofreferent, $hookmanager->resArray); } -if ($action=="addelement") +if ($action == "addelement") { $tablename = GETPOST("tablename"); $elementselectid = GETPOST("elementselect"); - $result=$object->update_element($tablename, $elementselectid); - if ($result<0) + $result = $object->update_element($tablename, $elementselectid); + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -549,7 +549,7 @@ $showdatefilter = 0; if (!$showdatefilter) { print '
'; - print '
'; + print ''; print ''; print ''; print ''; @@ -590,53 +590,53 @@ print '
'; - $addform.=''; - $addform.=''; - $addform.='
'.$langs->trans("SelectElement").''.$selectList.'
'; - $addform.=''; - $addform.='
'; + $addform .= '
'; + $addform .= '
'; + $addform .= ''; + $addform .= ''; + $addform .= ''; + $addform .= ''; + $addform .= ''; + $addform .= ''; + $addform .= ''; + $addform .= ''; + $addform .= '
'.$langs->trans("SelectElement").''.$selectList.'
'; + $addform .= '
'; + $addform .= '
'; } } if (empty($conf->global->PROJECT_CREATE_ON_OVERVIEW_DISABLED) && $urlnew) { - $addform.='
'; - if ($testnew) $addform.=''.($buttonnew?$langs->trans($buttonnew):$langs->trans("Create")).''; + $addform .= '
'; + if ($testnew) $addform .= ''.($buttonnew ? $langs->trans($buttonnew) : $langs->trans("Create")).''; elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { - $addform.=''.($buttonnew?$langs->trans($buttonnew):$langs->trans("Create")).''; + $addform .= ''.($buttonnew ? $langs->trans($buttonnew) : $langs->trans("Create")).''; } - $addform.='
'; + $addform .= '
'; } print load_fiche_titre($langs->trans($title), $addform, ''); @@ -827,7 +827,7 @@ foreach ($listofreferent as $key => $value) else print $langs->trans("ThirdParty"); print ''; // Duration of intervention - if($tablename == 'fichinter') + if ($tablename == 'fichinter') { print ''; print $langs->trans("TotalDuration"); @@ -915,7 +915,7 @@ foreach ($listofreferent as $key => $value) { if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) // PROJECT_DISABLE_UNLINK_FROM_OVERVIEW is empty by defaut, so this test true { - print ''; + print 'id.($project_field ? '&projectfield='.$project_field : '').'" class="reposition">'; print img_picto($langs->trans('Unlink'), 'unlink'); print ''; } @@ -1033,7 +1033,7 @@ foreach ($listofreferent as $key => $value) print ''; // Add duration and store it in counter for fichinter - if($tablename == 'fichinter') + if ($tablename == 'fichinter') { print ''; print convertSecondToTime($element->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); @@ -1085,9 +1085,9 @@ foreach ($listofreferent as $key => $value) if ($othermessage) print $othermessage; if (isset($total_ht_by_line)) { - if (! $qualifiedfortotal) print ''; + if (!$qualifiedfortotal) print ''; print price($total_ht_by_line); - if (! $qualifiedfortotal) print ''; + if (!$qualifiedfortotal) print ''; } if ($warning) print ' '.img_warning($warning); print ''; @@ -1132,9 +1132,9 @@ foreach ($listofreferent as $key => $value) if ($othermessage) print $othermessage; if (isset($total_ttc_by_line)) { - if (! $qualifiedfortotal) print ''; + if (!$qualifiedfortotal) print ''; print price($total_ttc_by_line); - if (! $qualifiedfortotal) print ''; + if (!$qualifiedfortotal) print ''; } if ($warning) print ' '.img_warning($warning); print ''; @@ -1219,7 +1219,7 @@ foreach ($listofreferent as $key => $value) //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("TotalHT").' : '.price($total_ht).''; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''.$langs->trans("Total").' : '.price($total_ht).''; // If fichinter add the total_duration - if($tablename == 'fichinter') print ''.convertSecondToTime($total_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).''; + if ($tablename == 'fichinter') print ''.convertSecondToTime($total_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).''; print ''; if (empty($value['disableamount'])) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index d7078e3b3a3..c35fdc0465e 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1420,16 +1420,16 @@ class User extends CommonObject $result = $this->create($user); if ($result > 0) { - if (! empty($this->pass)) { // If a clear password was received (this situation should not happen anymore now), we use it to save it into database + if (!empty($this->pass)) { // If a clear password was received (this situation should not happen anymore now), we use it to save it into database $newpass = $this->setPassword($user, $this->pass); if (is_numeric($newpass) && $newpass < 0) $result = -2; - } elseif (! empty($this->pass_crypted)) { // If a crypted password is already known, we save it directly into database because the previous create did not save it. + } elseif (!empty($this->pass_crypted)) { // If a crypted password is already known, we save it directly into database because the previous create did not save it. $sql = "UPDATE ".MAIN_DB_PREFIX."user"; $sql .= " SET pass_crypted = '".$this->db->escape($this->pass_crypted)."'"; $sql .= " WHERE rowid=".$this->id; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $result = -1; } From 7cb2c21dc2fe32b856c8e0e4eba91e3fce3270e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Feb 2020 19:50:53 +0100 Subject: [PATCH 50/68] FIX #12974 --- htdocs/core/menus/standard/eldy.lib.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 5a5a2c5628d..0428f5e1dba 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -239,11 +239,20 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = !empty($user->rights->contrat->lire) || !empty($user->rights->ficheinter->lire) ), - 'module'=>'propal|commande|supplier_order|contrat|ficheinter' + 'module'=>'propal|commande|supplier_order|supplier_proposal|contrat|ficheinter' ); + + $onlysupplierorder = ! empty($user->rights->fournisseur->commande->lire) && + empty($user->rights->propal->lire) && + empty($user->rights->commande->lire) && + empty($user->rights->supplier_order->lire) && + empty($user->rights->supplier_proposal->lire) && + empty($user->rights->contrat->lire) && + empty($user->rights->ficheinter->lire); + $menu_arr[] = array( 'name' => 'Commercial', - 'link' => '/comm/index.php?mainmenu=commercial&leftmenu=', + 'link' => ($onlysupplierorder ? '/fourn/commande/index.php?mainmenu=commercial&leftmenu=' : '/comm/index.php?mainmenu=commercial&leftmenu='), 'title' => "Commercial", 'level' => 0, 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), From 12b63606df5c626ceca38402c4e41d7c40872f08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Feb 2020 20:21:16 +0100 Subject: [PATCH 51/68] Fix look and feel of v11 --- htdocs/core/lib/project.lib.php | 12 ++++++------ htdocs/projet/activity/permonth.php | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index f39856f1bc1..16e78d24414 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1811,7 +1811,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & if ($projectstatic->title) { print ' - '; - print $projectstatic->title; + print ''.$projectstatic->title.''; } print ''; print ''; @@ -1853,18 +1853,18 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & print "\n"; // Planned Workload - print ''; + print ''; if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); else print '--:--'; print ''; // Progress declared % - print ''; + print ''; print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); print ''; // Time spent by everybody - print ''; + print ''; // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user if ($lines[$i]->duration) { @@ -1876,7 +1876,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & print "\n"; // Time spent by user - print ''; + print ''; $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); else print '--:--'; @@ -1935,7 +1935,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & } // Warning - print ''; + print ''; if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); elseif ($disabledtask) { diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 398f4c67199..d121b39b683 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -386,7 +386,7 @@ $head=project_timesheet_prepare_head($mode, $usertoprocess); dol_fiche_head($head, 'inputpermonth', $langs->trans('TimeSpent'), -1, 'task'); // Show description of content -print '
'; +print '
'; if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; else { @@ -502,11 +502,11 @@ print ''.$langs->trans("ProgressDeclared"). if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByYou").''; else print ''.$langs->trans("TimeSpentByUser").'';*/ print ''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')'; -print ''.$langs->trans("TimeSpent").($usertoprocess->firstname?'
('.$usertoprocess->firstname.')':'').''; +print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
('.dol_trunc($usertoprocess->firstname, 10).')' : '').''; foreach ($TWeek as $week_number) { - print ''.$langs->trans("Week").'
'.$week_number.'
('.$langs->trans('From').' '.$TFirstDays[$week_number].' '.$langs->trans('to').' '.$TLastDays[$week_number].')'; + print ''.$langs->trans("Week").' '.$week_number.'
('.$TFirstDays[$week_number].'...'.$TLastDays[$week_number].')'; } print ''; print "\n"; @@ -597,7 +597,7 @@ if (count($tasksarray) > 0) print ' '; print $langs->trans("Total"); - print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; + print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print ''; foreach ($TWeek as $weekNb) From a0e3c5292f11a6839848d9bd960ce4b88844e087 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 02:20:38 +0100 Subject: [PATCH 52/68] FIX #12992 --- htdocs/install/upgrade2.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index dd9e3b1ed95..c5d1d7837e9 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4978,16 +4978,16 @@ function migrate_users_socialnetworks() $db->begin(); print ''; $sql = 'SELECT rowid, socialnetworks'; - $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'user WHERE '; - $sql .= ' skype IS NOT NULL OR skype !=""'; - $sql .= ' OR twitter IS NOT NULL OR twitter !=""'; - $sql .= ' OR facebook IS NOT NULL OR facebook!=""'; - $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""'; - $sql .= ' OR instagram IS NOT NULL OR instagram!=""'; - $sql .= ' OR snapchat IS NOT NULL OR snapchat!=""'; - $sql .= ' OR googleplus IS NOT NULL OR googleplus!=""'; - $sql .= ' OR youtube IS NOT NULL OR youtube!=""'; - $sql .= ' OR whatsapp IS NOT NULL OR whatsapp!=""'; + $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'user WHERE'; + $sql .= " skype IS NOT NULL OR skype <> ''"; + $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; + $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; + $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; + $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; + $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; + $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; + $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; + $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; //print $sql; $resql = $db->query($sql); if ($resql) { From 69a0a1410eca32287634e461759b7c92491c2c7a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 02:28:23 +0100 Subject: [PATCH 53/68] FIX #12991 --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 350e3d2065a..9f3d092e846 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -206,7 +206,9 @@ ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_c_type_co ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); -ALTER TABLE llx_accounting_account MODIFY COLUMN rowid bigint AUTO_INCREMENT; +-- VMYSQL4.3 ALTER TABLE llx_accounting_account MODIFY COLUMN rowid bigint AUTO_INCREMENT; +-- VPGSQL8.2 ALTER TABLE llx_accounting_account MODIFY COLUMN rowid bigint; + ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL; From 90cde17bdbe6f6c65e9fb2ecb6502608aadce813 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 02:48:05 +0100 Subject: [PATCH 54/68] FIX #12986 --- htdocs/projet/class/project.class.php | 19 +++++++++++++------ htdocs/user/perms.php | 16 ++++++++++++---- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 54d13a51549..bb1ca3e1d2e 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1211,7 +1211,7 @@ class Project extends CommonObject * Return array of projects a user has permission on, is affected to, or all projects * * @param User $user User object - * @param int $mode 0=All project I have permission on (assigned to me and public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts + * @param int $mode 0=All project I have permission on (assigned to me or public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts * @param int $list 0=Return array, 1=Return string list * @param int $socid 0=No filter on third party, id of third party * @param string $filter additionnal filter on project (statut, ref, ...) @@ -1224,9 +1224,17 @@ class Project extends CommonObject $sql = "SELECT ".(($mode == 0 || $mode == 1) ? "DISTINCT " : "")."p.rowid, p.ref"; $sql.= " FROM " . MAIN_DB_PREFIX . "projet as p"; - if ($mode == 0 || $mode == 1) + if ($mode == 0) { - $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON ec.element_id = p.rowid"; + } + elseif ($mode == 1) + { + $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec"; + } + elseif ($mode == 2) + { + // No filter. Use this if user has permission to see all project } $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Internal users must see project he is contact to even if project linked to a third party he can't see. @@ -1251,13 +1259,12 @@ class Project extends CommonObject if ($mode == 0) { - $sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ( p.public = 1"; $sql.= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; $sql.= " AND ec.fk_socpeople = ".$user->id.")"; $sql.= " )"; } - if ($mode == 1) + elseif ($mode == 1) { $sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ("; @@ -1265,7 +1272,7 @@ class Project extends CommonObject $sql.= " AND ec.fk_socpeople = ".$user->id.")"; $sql.= " )"; } - if ($mode == 2) + elseif ($mode == 2) { // No filter. Use this if user has permission to see all project } diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 26758f52ab0..62070e3b31e 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -89,9 +89,13 @@ if (empty($reshook)) { if ($action == 'addrights' && $caneditperms) { $edituser = new User($db); $edituser->fetch($object->id); - $edituser->addrights($rights, $module, '', $entity); + $result = $edituser->addrights($rights, $module, '', $entity); + if ($result < 0) + { + setEventMessages($edituser->error, $edituser->errors, 'errors'); + } - // Si on a touche a ses propres droits, on recharge + // If we are changing our own permissions, we reload if ($object->id == $user->id) { $user->clearrights(); $user->getrights(); @@ -105,9 +109,13 @@ if (empty($reshook)) { if ($action == 'delrights' && $caneditperms) { $edituser = new User($db); $edituser->fetch($object->id); - $edituser->delrights($rights, $module, '', $entity); + $result = $edituser->delrights($rights, $module, '', $entity); + if ($result < 0) + { + setEventMessages($edituser->error, $edituser->errors, 'errors'); + } - // Si on a touche a ses propres droits, on recharge + // If we are changing our own permissions, we reload if ($object->id == $user->id) { $user->clearrights(); $user->getrights(); From 3f73339818a328e88181b238ea062658ca9ffee7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 03:01:23 +0100 Subject: [PATCH 55/68] Fix trans --- htdocs/core/modules/modLabel.class.php | 2 +- htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index 89e9fca5ba9..5edd3bd3200 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -47,7 +47,7 @@ class modLabel extends DolibarrModules $this->module_position = '75'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Gestion des etiquettes"; + $this->description = "Management of stickers"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'development'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 7fbcf449bed..7d2d622887e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -545,6 +545,8 @@ Module58Name=ClickToDial Module58Desc=Integration of a ClickToDial system (Asterisk, ...) Module59Name=Bookmark4u Module59Desc=Add function to generate Bookmark4u account from a Dolibarr account +Module60Name=Stickers +Module60Desc=Management of stickers Module70Name=Interventions Module70Desc=Intervention management Module75Name=Expense and trip notes From 240727c3e18124e16c673488364f453f63d26972 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 03:08:54 +0100 Subject: [PATCH 56/68] FIX #12975 --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 ++ htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 603ffbbd3d6..c3fc7677f80 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -901,6 +901,8 @@ class pdf_crabe extends ModelePDFFactures $i++; } + + return $tab3_top + $y + 3; } else { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 1c59a9839b3..b5e94e62aff 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1029,6 +1029,8 @@ class pdf_sponge extends ModelePDFFactures $i++; } + + return $tab3_top + $y + 3; } else { From ff6bcbdcf883f96a6e5f1da0b5236bf4c2f0011c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 03:01:23 +0100 Subject: [PATCH 57/68] Fix trans --- htdocs/core/modules/modLabel.class.php | 2 +- htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index c387ed69e6e..c6f2c5267b5 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -47,7 +47,7 @@ class modLabel extends DolibarrModules $this->module_position = '75'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Gestion des etiquettes"; + $this->description = "Management of stickers"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'development'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5cac95078c0..0bf914d0e22 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -545,6 +545,8 @@ Module58Name=ClickToDial Module58Desc=Integration of a ClickToDial system (Asterisk, ...) Module59Name=Bookmark4u Module59Desc=Add function to generate Bookmark4u account from a Dolibarr account +Module60Name=Stickers +Module60Desc=Management of stickers Module70Name=Interventions Module70Desc=Intervention management Module75Name=Expense and trip notes From ccf8e81f93779264198ae6cd5857eb16b52012b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 03:08:54 +0100 Subject: [PATCH 58/68] FIX #12975 --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 ++ htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 64aa3c52e25..fa661610d3b 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -903,6 +903,8 @@ class pdf_crabe extends ModelePDFFactures $i++; } + + return $tab3_top + $y + 3; } else { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 3e00e2cab68..2911cf5d5bc 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1021,6 +1021,8 @@ class pdf_sponge extends ModelePDFFactures $i++; } + + return $tab3_top + $y + 3; } else { From 5633f584770ca81de3f82d3739050006cf1a4063 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 03:25:41 +0100 Subject: [PATCH 59/68] FIX #12978 --- htdocs/core/modules/modStock.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 6b2dc11605c..bc1971ee3ed 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -348,6 +348,7 @@ class modStock extends DolibarrModules $this->import_examplevalues_array[$r]=array( 'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10" ); + $this->import_updatekeys_array[$r]=array('ps.fk_product'=>'Product', 'ps.fk_entrepot'=>"Warehouse"); $this->import_run_sql_after_array[$r]=array( // Because we may change data that are denormalized, we must update dernormalized data after. 'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' ); From a30da7860f2cfc4afecd606668fb838886669ee7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 03:32:31 +0100 Subject: [PATCH 60/68] FIX #12892 --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 15200582ced..e0c63ca0a8f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3889,7 +3889,7 @@ elseif ($id > 0 || !empty($ref)) } // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid, 'remainingtopay' => &$resteapayer); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; From b3a50bd4b0e701bb68bd2ed6654f061bae344c91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 03:47:45 +0100 Subject: [PATCH 61/68] FIX #12874 --- htdocs/user/class/api_users.class.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index be768a3e15a..fa139e2c69f 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -132,15 +132,15 @@ class Users extends DolibarrApi /** * Get properties of an user object - * * Return an array with user informations * - * @param int $id ID of user + * @param int $id ID of user + * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) * @return array|mixed data without useless information * * @throws RestException */ - public function get($id) + public function get($id, $includepermissions = 0) { //if (!DolibarrApiAccess::$user->rights->user->user->lire) { //throw new RestException(401); @@ -157,6 +157,10 @@ class Users extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + if ($includepermissions) { + $this->useraccount->getRights(); + } + return $this->_cleanObjectDatas($this->useraccount); } @@ -544,6 +548,12 @@ class Users extends DolibarrApi unset($object->clicktodial_password); unset($object->openid); + unset($object->lines); + unset($object->modelpdf); + unset($object->skype); + unset($object->twitter); + unset($object->facebook); + unset($object->linkedin); $canreadsalary = ((!empty($conf->salaries->enabled) && !empty(DolibarrApiAccess::$user->rights->salaries->read)) || (!empty($conf->hrm->enabled) && !empty(DolibarrApiAccess::$user->rights->hrm->employee->read))); From 1dab308e4a50261e5c83f52a0f55b00c6a1efcac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 03:55:37 +0100 Subject: [PATCH 62/68] FIX #12932 --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index c4c0aed1756..e0a1fd35092 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -508,7 +508,7 @@ class CMailFile $res = false; - if (empty($conf->global->MAIN_DISABLE_ALL_MAILS) || !empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) + if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); From 7c35e9aaa862f7b8b50c2f22aa0af2e830c8a9ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 03:55:37 +0100 Subject: [PATCH 63/68] FIX #12932 --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 4d796bbcd07..402b19701d7 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -485,7 +485,7 @@ class CMailFile $res=false; - if (empty($conf->global->MAIN_DISABLE_ALL_MAILS) || !empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) + if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); From e5808e3335591c32ec87628a3f9b6b65b30698fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 04:48:17 +0100 Subject: [PATCH 64/68] FIX #12995 --- htdocs/bom/bom_card.php | 8 ++++++++ htdocs/core/class/commonobject.class.php | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 87396dccb30..3f1be6c7e4c 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -155,6 +155,8 @@ if (empty($reshook)) if (!$error) { + $lastposition = 0; + $bomline = new BOMLine($db); $bomline->fk_bom = $id; $bomline->fk_product = $idprod; @@ -163,6 +165,12 @@ if (empty($reshook)) $bomline->disable_stock_change = (int) $disable_stock_change; $bomline->efficiency = $efficiency; + // Rang to use + $rangmax = $object->line_max(0); + $ranktouse = $rangmax + 1; + + $bomline->position = ($ranktouse + 1); + $result = $bomline->create($user); if ($result <= 0) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 14433ff79db..dd2973cb1fb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2744,10 +2744,13 @@ abstract class CommonObject public function line_max($fk_parent_line = 0) { // phpcs:enable + $positionfield = 'rang'; + if ($this->table_element = 'bom') $positionfield = 'position'; + // Search the last rang with fk_parent_line if ($fk_parent_line) { - $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; $sql .= ' AND fk_parent_line = '.$fk_parent_line; @@ -2769,7 +2772,7 @@ abstract class CommonObject // If not, search the last rang of element else { - $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; dol_syslog(get_class($this)."::line_max", LOG_DEBUG); From 8957a299906807e31523f635a8be4990f7de5ef3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 06:28:04 +0100 Subject: [PATCH 65/68] FIX #12973 --- dev/dolibarr_changes.txt | 43 +++++++++++++++++++++- htdocs/includes/tecnickcom/tcpdf/tcpdf.php | 6 ++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 51eeef8af31..107f561eca6 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -63,10 +63,49 @@ with if (isset($this->imagekeys)) { foreach($this->imagekeys as $file) { -// unlink($file); + // DOL CHANGE If we keep this, source image files are physically destroyed + // unlink($file); } } +* Replace in tcpdf.php + + $preserve = array( + 'file_id', + 'internal_encoding', + 'state', + 'bufferlen', + 'buffer', + 'cached_files', + +with + + $preserve = array( + 'file_id', + 'internal_encoding', + 'state', + 'bufferlen', + 'buffer', + 'cached_files', + // @CHANGE DOL + 'imagekeys', + +* Replace in tcpdf.php + + if (!@TCPDF_STATIC::file_exists($file)) { + return false; + } + +with + + if (!@TCPDF_STATIC::file_exists($file)) { + // DOL CHANGE If we keep this, the image is not visible on pages after the first one. + //var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file))); + //return false; + } + + + * In tecnickcom/tcpdf/include/tcpdf_static, in function fopenLocal, replace if (strpos($filename, '://') === false) { @@ -102,7 +141,7 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php + protected $default_monospaced_font = 'freemono'; - + TCPDI: ------ diff --git a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php index aa66879f7a1..dd20e957d5b 100644 --- a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php +++ b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php @@ -6878,7 +6878,9 @@ class TCPDF { } // check if file exist and it is valid if (!@TCPDF_STATIC::file_exists($file)) { - return false; + // DOL CHANGE If we keep this, the image is not visible on pages after the first one. + //var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file))); + //return false; } if (($imsize = @getimagesize($file)) === FALSE) { if (in_array($file, $this->imagekeys)) { @@ -7810,6 +7812,8 @@ class TCPDF { 'bufferlen', 'buffer', 'cached_files', +// @CHANGE DOL +// 'imagekeys', 'sign', 'signature_data', 'signature_max_length', From d8ed62ea330edc42990e4e76c2ee668017f62d5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 06:28:51 +0100 Subject: [PATCH 66/68] Fix line_max for BOM --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dd2973cb1fb..750fbc59135 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2745,7 +2745,7 @@ abstract class CommonObject { // phpcs:enable $positionfield = 'rang'; - if ($this->table_element = 'bom') $positionfield = 'position'; + if ($this->table_element == 'bom') $positionfield = 'position'; // Search the last rang with fk_parent_line if ($fk_parent_line) From 87f84e5b17cdac337aeedb9c2b1ad525aea154de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 06:28:04 +0100 Subject: [PATCH 67/68] FIX #12973 --- dev/dolibarr_changes.txt | 43 +++++++++++++++++++++- htdocs/includes/tecnickcom/tcpdf/tcpdf.php | 6 ++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 51eeef8af31..107f561eca6 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -63,10 +63,49 @@ with if (isset($this->imagekeys)) { foreach($this->imagekeys as $file) { -// unlink($file); + // DOL CHANGE If we keep this, source image files are physically destroyed + // unlink($file); } } +* Replace in tcpdf.php + + $preserve = array( + 'file_id', + 'internal_encoding', + 'state', + 'bufferlen', + 'buffer', + 'cached_files', + +with + + $preserve = array( + 'file_id', + 'internal_encoding', + 'state', + 'bufferlen', + 'buffer', + 'cached_files', + // @CHANGE DOL + 'imagekeys', + +* Replace in tcpdf.php + + if (!@TCPDF_STATIC::file_exists($file)) { + return false; + } + +with + + if (!@TCPDF_STATIC::file_exists($file)) { + // DOL CHANGE If we keep this, the image is not visible on pages after the first one. + //var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file))); + //return false; + } + + + * In tecnickcom/tcpdf/include/tcpdf_static, in function fopenLocal, replace if (strpos($filename, '://') === false) { @@ -102,7 +141,7 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php + protected $default_monospaced_font = 'freemono'; - + TCPDI: ------ diff --git a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php index aa66879f7a1..dd20e957d5b 100644 --- a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php +++ b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php @@ -6878,7 +6878,9 @@ class TCPDF { } // check if file exist and it is valid if (!@TCPDF_STATIC::file_exists($file)) { - return false; + // DOL CHANGE If we keep this, the image is not visible on pages after the first one. + //var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file))); + //return false; } if (($imsize = @getimagesize($file)) === FALSE) { if (in_array($file, $this->imagekeys)) { @@ -7810,6 +7812,8 @@ class TCPDF { 'bufferlen', 'buffer', 'cached_files', +// @CHANGE DOL +// 'imagekeys', 'sign', 'signature_data', 'signature_max_length', From 2813c9d4b4a663265b5c45a858bc3265b8bc5b6a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 06:31:40 +0100 Subject: [PATCH 68/68] FIX #12973 --- htdocs/includes/tecnickcom/tcpdf/tcpdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php index 24ef434ab8a..f5a6b9aa931 100644 --- a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php +++ b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php @@ -6846,7 +6846,7 @@ class TCPDF { } // check if file exist and it is valid if (!@TCPDF_STATIC::file_exists($file)) { - return false; + //return false; } if (($imsize = @getimagesize($file)) === FALSE) { if (in_array($file, $this->imagekeys)) {