From ca4023fe23148687ab38274ae93390e9b88051c1 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 22 Feb 2021 05:31:01 +0100 Subject: [PATCH 001/618] Migration --- ChangeLog | 3 ++- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_facture.sql | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f5449fa601b..650bd89eed6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,7 +19,8 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The ICS value for direct debit or credit transfer is now store on each bank account instead of into the global setup. * API /setup/shipment_methods has been replaced with API /setup/shipping_methods -* Field "tva" renamed into to "total_tva" in llx_propal, llx_supplier_proposal, llx_commande for better field name consistency +* Field "total" renamed into to "total_ht" in llx_facture for better field name consistency +* Field "tva" renamed into to "total_tva" in llx_facture, llx_propal, llx_supplier_proposal, llx_commande for better field name consistency * Field "total" renamed into "total_ttc" in llx_supplier_proposal for better field name consistency diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 8fa464adb92..c755ba1b359 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -180,4 +180,6 @@ ALTER TABLE llx_commande CHANGE COLUMN tva total_tva double(24,8) default 0; ALTER TABLE llx_supplier_proposal CHANGE COLUMN tva total_tva double(24,8) default 0; ALTER TABLE llx_supplier_proposal CHANGE COLUMN total total_ttc double(24,8) default 0; ALTER TABLE llx_propal CHANGE COLUMN tva total_tva double(24,8) default 0; +ALTER TABLE llx_facture CHANGE COLUMN tva total_tva double(24,8) default 0; +ALTER TABLE llx_facture CHANGE COLUMN total total_ht double(24,8) default 0; diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index 010cf1c1573..acb43444ad2 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -50,11 +50,11 @@ create table llx_facture close_code varchar(16), -- Code motif cloture sans paiement complet close_note varchar(128), -- Commentaire cloture sans paiement complet - tva double(24,8) DEFAULT 0, -- amount total tva apres remise totale + total_tva double(24,8) DEFAULT 0, -- amount total tva apres remise totale localtax1 double(24,8) DEFAULT 0, -- amount total localtax1 localtax2 double(24,8) DEFAULT 0, -- amount total localtax2 revenuestamp double(24,8) DEFAULT 0, -- amount total revenuestamp - total double(24,8) DEFAULT 0, -- amount total ht apres remise totale + total_ht double(24,8) DEFAULT 0, -- amount total ht apres remise totale total_ttc double(24,8) DEFAULT 0, -- amount total ttc apres remise totale fk_statut smallint DEFAULT 0 NOT NULL, From d7993253e7fe4b37952970777be99fc16d92fa4b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 22 Feb 2021 05:33:40 +0100 Subject: [PATCH 002/618] Export --- htdocs/core/modules/modFacture.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 9212fa1f7ce..0eda657b8a9 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -218,8 +218,8 @@ class modFacture extends DolibarrModules 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', - 'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT", - 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment', + 'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total_ht'=>"TotalHT", + 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment', 'none.rest'=>'Rest', 'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription", @@ -245,7 +245,7 @@ class modFacture extends DolibarrModules 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", - 'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text', + 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text', 'none.rest'=>"NumericCompute", 'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text', 'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric", @@ -305,8 +305,8 @@ class modFacture extends DolibarrModules 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', - 'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT", - 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment', + 'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total_ht'=>"TotalHT", + 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment', 'none.rest'=>'Rest', 'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', 'p.rowid'=>'PaymentId', 'p.ref'=>'PaymentRef', @@ -332,7 +332,7 @@ class modFacture extends DolibarrModules 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", - 'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.close_code'=>'Text', 'f.close_note'=>'Text', + 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.close_code'=>'Text', 'f.close_note'=>'Text', 'none.rest'=>'NumericCompute', 'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text', 'pj.ref'=>'Text', 'pj.title'=>'Text', 'p.amount'=>'Numeric', 'pf.amount'=>'Numeric', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 'p.title'=>'Text', 'p.datep'=>'Date', 'p.num_paiement'=>'Numeric', From ae4fc565e187880f635d8fa7a5fe173e7aec00e8 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 22 Feb 2021 05:38:31 +0100 Subject: [PATCH 003/618] Widget & commonobject --- htdocs/core/boxes/box_factures.php | 4 ++-- htdocs/core/boxes/box_factures_imp.php | 6 +++--- htdocs/core/class/commonobject.class.php | 2 +- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_facture_rec.sql | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 20e83fb442c..8daabcf840c 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -89,8 +89,8 @@ class box_factures extends ModeleBoxes if ($user->rights->facture->lire) { $sql = "SELECT f.rowid as facid"; - $sql .= ", f.ref, f.type, f.total as total_ht"; - $sql .= ", f.tva as total_tva"; + $sql .= ", f.ref, f.type, f.total_ht"; + $sql .= ", f.total_tva"; $sql .= ", f.total_ttc"; $sql .= ", f.datef as df"; $sql .= ", f.paye, f.fk_statut, f.datec, f.tms"; diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index b47f948f4ca..68d03ce56af 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -95,8 +95,8 @@ class box_factures_imp extends ModeleBoxes $sql .= ", f.ref, f.date_lim_reglement as datelimite"; $sql .= ", f.type"; $sql .= ", f.datef as df"; - $sql .= ", f.total as total_ht"; - $sql .= ", f.tva as total_tva"; + $sql .= ", f.total_ht"; + $sql .= ", f.total_tva"; $sql .= ", f.total_ttc"; $sql .= ", f.paye, f.fk_statut, f.rowid as facid"; $sql .= ", sum(pf.amount) as am"; @@ -112,7 +112,7 @@ class box_factures_imp extends ModeleBoxes if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; $sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,"; $sql .= " f.ref, f.date_lim_reglement,"; - $sql .= " f.type, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; + $sql .= " f.type, f.datef, f.total_ht, f.total_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/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 394138ce2ce..92d312a055e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3228,7 +3228,7 @@ abstract class CommonObject $fieldlocaltax2 = 'localtax2'; $fieldttc = 'total_ttc'; // Specific code for backward compatibility with old field names - if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht = 'total'; + if ($this->element == 'facture' || $this->element == 'facturerec') $fieldtva = 'total_tva'; if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva = 'total_tva'; if ($this->element == 'propal') { $fieldttc = 'total'; diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index c755ba1b359..dd932d639c8 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -182,4 +182,6 @@ ALTER TABLE llx_supplier_proposal CHANGE COLUMN total total_ttc double(24,8) def ALTER TABLE llx_propal CHANGE COLUMN tva total_tva double(24,8) default 0; ALTER TABLE llx_facture CHANGE COLUMN tva total_tva double(24,8) default 0; ALTER TABLE llx_facture CHANGE COLUMN total total_ht double(24,8) default 0; +ALTER TABLE llx_facture_rec CHANGE COLUMN tva total_tva double(24,8) default 0; +ALTER TABLE llx_facture_rec CHANGE COLUMN total total_ht double(24,8) default 0; diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index 0db78d62252..c3cb6aeed46 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -36,11 +36,11 @@ create table llx_facture_rec remise_absolue real DEFAULT 0, vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. - tva double(24,8) DEFAULT 0, + total_tva double(24,8) DEFAULT 0, localtax1 double(24,8) DEFAULT 0, -- amount localtax1 localtax2 double(24,8) DEFAULT 0, -- amount localtax2 revenuestamp double(24,8) DEFAULT 0, -- amount total revenuestamp - total double(24,8) DEFAULT 0, + total_ht double(24,8) DEFAULT 0, total_ttc double(24,8) DEFAULT 0, fk_user_author integer, -- user creating From 70dddd9bdfd8181f49a97552d0857d8610b30a32 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 22 Feb 2021 05:58:46 +0100 Subject: [PATCH 004/618] Index & module --- ChangeLog | 4 +-- htdocs/compta/accounting-files.php | 2 +- .../facture/class/facture-rec.class.php | 10 +++--- htdocs/compta/facture/class/facture.class.php | 14 ++++---- .../compta/facture/invoicetemplate_list.php | 32 +++++++++---------- htdocs/compta/facture/list.php | 26 +++++++-------- htdocs/compta/index.php | 12 +++---- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 650bd89eed6..360d4a97b7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,8 +19,8 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The ICS value for direct debit or credit transfer is now store on each bank account instead of into the global setup. * API /setup/shipment_methods has been replaced with API /setup/shipping_methods -* Field "total" renamed into to "total_ht" in llx_facture for better field name consistency -* Field "tva" renamed into to "total_tva" in llx_facture, llx_propal, llx_supplier_proposal, llx_commande for better field name consistency +* Field "total" renamed into to "total_ht" in llx_facture, llx_facture_rec for better field name consistency +* Field "tva" renamed into to "total_tva" in llx_facture, llx_facture_rec, llx_propal, llx_supplier_proposal, llx_commande for better field name consistency * Field "total" renamed into "total_ttc" in llx_supplier_proposal for better field name consistency diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 02098e986ba..16ebfd07951 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -149,7 +149,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { // Customer invoices if (GETPOST('selectinvoices')) { if (!empty($sql)) $sql .= " UNION ALL"; - $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens"; + $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 13a58a3e075..c0ccf389bd1 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -147,10 +147,10 @@ class FactureRec extends CommonInvoice '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), - 'tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>55, 'isameasure'=>1), + 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>55, 'isameasure'=>1), 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'isameasure'=>1), 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>65, 'isameasure'=>1), - 'total' =>array('type'=>'double(24,8)', 'label'=>'Total', 'enabled'=>1, 'visible'=>-1, 'position'=>70, 'isameasure'=>1), + 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'Total', 'enabled'=>1, 'visible'=>-1, 'position'=>70, 'isameasure'=>1), 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Total ttc', 'enabled'=>1, 'visible'=>-1, 'position'=>75, 'isameasure'=>1), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>80), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>85), @@ -494,7 +494,7 @@ class FactureRec extends CommonInvoice */ public function fetch($rowid, $ref = '', $ref_ext = '') { - $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 = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.total_tva, f.localtax1, f.localtax2, f.total_ht, 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'; @@ -539,8 +539,8 @@ class FactureRec extends CommonInvoice $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; $this->remise = $obj->remise; - $this->total_ht = $obj->total; - $this->total_tva = $obj->tva; + $this->total_ht = $obj->total_ht; + $this->total_tva = $obj->total_tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total_ttc; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7f686accb4e..8e65d1d1de0 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -293,11 +293,11 @@ class Facture extends CommonInvoice //'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>100), '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), + 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'TotalVAT', 'enabled'=>1, 'visible'=>-1, 'position'=>115, 'isameasure'=>1), 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LT1', 'enabled'=>1, 'visible'=>-1, 'position'=>120, 'isameasure'=>1), 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LT2', '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'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), + 'total_ht' =>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_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), @@ -1524,7 +1524,7 @@ class Facture extends CommonInvoice if (empty($rowid) && empty($ref) && empty($ref_ext)) return -1; $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.total_tva, f.localtax1, f.localtax2, f.total_ht, f.total_ttc, f.revenuestamp'; $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; $sql .= ', f.datef as df, f.date_pointoftax'; $sql .= ', f.date_lim_reglement as dlr'; @@ -1579,8 +1579,8 @@ class Facture extends CommonInvoice $this->datem = $this->db->jdate($obj->datem); $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; - $this->total_ht = $obj->total; - $this->total_tva = $obj->tva; + $this->total_ht = $obj->total_ht; + $this->total_tva = $obj->total_tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total_ttc; @@ -1888,10 +1888,10 @@ class Facture extends CommonInvoice $sql .= " remise_absolue=".(isset($this->remise_absolue) ? $this->db->escape($this->remise_absolue) : "null").","; $sql .= " close_code=".(isset($this->close_code) ? "'".$this->db->escape($this->close_code)."'" : "null").","; $sql .= " close_note=".(isset($this->close_note) ? "'".$this->db->escape($this->close_note)."'" : "null").","; - $sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; + $sql .= " total_tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; $sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").","; $sql .= " localtax2=".(isset($this->total_localtax2) ? $this->total_localtax2 : "null").","; - $sql .= " total=".(isset($this->total_ht) ? $this->total_ht : "null").","; + $sql .= " total_ht=".(isset($this->total_ht) ? $this->total_ht : "null").","; $sql .= " total_ttc=".(isset($this->total_ttc) ? $this->total_ttc : "null").","; $sql .= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '') ? $this->db->escape($this->revenuestamp) : "null").","; $sql .= " fk_statut=".(isset($this->statut) ? $this->db->escape($this->statut) : "null").","; diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 6f3f8088a63..f51a15dea36 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -119,8 +119,8 @@ $permissiontoedit = $user->rights->facture->creer; // Used by the include of act $arrayfields = array( 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), - 'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), - 'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1), + 'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), + 'f.total_tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1), 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>0), 'f.fk_cond_reglement'=>array('label'=>$langs->trans("PaymentTerm"), 'checked'=>0), @@ -225,7 +225,7 @@ $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray[' * List mode */ -$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,"; +$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total_ht, f.total_tva, f.total_ttc, f.frequency, f.unit_frequency,"; $sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,"; $sql .= " f.datec, f.tms,"; $sql .= " f.fk_cond_reglement, f.fk_mode_reglement"; @@ -252,8 +252,8 @@ if (!$user->rights->societe->client->voir && !$socid) { if ($search_ref) $sql .= natural_search('f.titre', $search_ref); if ($socid) $sql .= ' AND s.rowid = '.(int) $socid; if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); +if ($search_montant_ht != '') $sql .= natural_search('f.total_ht', $search_montant_ht, 1); +if ($search_montant_vat != '') $sql .= natural_search('f.total_tva', $search_montant_vat, 1); if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); if (!empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1); if (!empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1); @@ -359,14 +359,14 @@ if ($resql) { print ''; } - if (!empty($arrayfields['f.total']['checked'])) + if (!empty($arrayfields['f.total_ht']['checked'])) { // Amount net print ''; print ''; print ''; } - if (!empty($arrayfields['f.tva']['checked'])) + if (!empty($arrayfields['f.total_tva']['checked'])) { // Amount Vat print ''; @@ -480,8 +480,8 @@ if ($resql) print ''; if (!empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'], $_SERVER['PHP_SELF'], "f.total", "", $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'], $_SERVER['PHP_SELF'], "f.tva", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], "f.total_ht", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_tva']['checked'])) print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], "f.total_tva", "", $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); @@ -534,19 +534,19 @@ if ($resql) print ''.$companystatic->getNomUrl(1, 'customer').''; if (!$i) $totalarray['nbfield']++; } - if (!empty($arrayfields['f.total']['checked'])) + if (!empty($arrayfields['f.total_ht']['checked'])) { print ''.price($objp->total).''."\n"; if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total'; - $totalarray['val']['f.total'] += $objp->total; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; + $totalarray['val']['f.total_ht'] += $objp->total_ht; } - if (!empty($arrayfields['f.tva']['checked'])) + if (!empty($arrayfields['f.total_tva']['checked'])) { - print ''.price($objp->total_vat).''."\n"; + print ''.price($objp->total_tva).''."\n"; if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.tva'; - $totalarray['val']['f.tva'] += $objp->total_vat; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva'; + $totalarray['val']['f.total_tva'] += $objp->total_tva; } if (!empty($arrayfields['f.total_ttc']['checked'])) { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 249df885435..2539494907e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -194,7 +194,7 @@ $arrayfields = array( 'f.module_source'=>array('label'=>"Module", 'checked'=>($contextpage == 'poslist' ? 1 : 0), 'enabled'=>($conf->cashdesk->enabled || $conf->takepos->enabled || $conf->global->INVOICE_SHOW_POS), 'position'=>90), 'f.pos_source'=>array('label'=>"Terminal", 'checked'=>($contextpage == 'poslist' ? 1 : 0), 'enabled'=>($conf->cashdesk->enabled || $conf->takepos->enabled || $conf->global->INVOICE_SHOW_POS), 'position'=>91), 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>95), - 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>100), + 'f.total_tva'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>100), 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj == "1"), 'position'=>110), 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj == "1"), 'position'=>120), 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>130), @@ -417,7 +417,7 @@ $thirdpartystatic = new Societe($db); $sql = 'SELECT'; if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT'; -$sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; +$sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total_ht, f.total_tva, f.total_ttc,'; $sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql .= ' f.fk_user_author,'; $sql .= ' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva as multicurrency_total_vat, f.multicurrency_total_ttc,'; @@ -497,8 +497,8 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($se if ($search_type_thirdparty != '' && $search_type_thirdparty != '-1') $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); if ($search_company_alias) $sql .= natural_search('s.name_alias', $search_company_alias); -if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); +if ($search_montant_ht != '') $sql .= natural_search('f.total_ht', $search_montant_ht, 1); +if ($search_montant_vat != '') $sql .= natural_search('f.total_tva', $search_montant_vat, 1); if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); if ($search_montant_localtax2 != '') $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1); if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); @@ -548,7 +548,7 @@ $sql .= $hookmanager->resPrint; if (!$sall) { - $sql .= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total, f.tva, f.total_ttc,'; + $sql .= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total_ht, f.total_tva, f.total_ttc,'; $sql .= ' f.localtax1, f.localtax2,'; $sql .= ' f.datef, f.date_valid, f.date_lim_reglement, f.module_source, f.pos_source,'; $sql .= ' f.paye, f.fk_statut, f.close_code,'; @@ -932,7 +932,7 @@ if ($resql) print ''; print ''; } - if (!empty($arrayfields['f.total_vat']['checked'])) + if (!empty($arrayfields['f.total_tva']['checked'])) { // Amount print ''; @@ -1120,8 +1120,8 @@ if ($resql) if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['f.module_source']['checked'])) print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['f.pos_source']['checked'])) print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_tva']['checked'])) print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], 'f.total_tva', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); @@ -1174,7 +1174,7 @@ if ($resql) $facturestatic->ref_client = $obj->ref_client; $facturestatic->type = $obj->type; $facturestatic->total_ht = $obj->total_ht; - $facturestatic->total_tva = $obj->total_vat; + $facturestatic->total_tva = $obj->total_tva; $facturestatic->total_ttc = $obj->total_ttc; $facturestatic->multicurrency_code = $obj->multicurrency_code; $facturestatic->multicurrency_tx = $obj->multicurrency_tx; @@ -1476,12 +1476,12 @@ if ($resql) $totalarray['val']['f.total_ht'] += $obj->total_ht; } // Amount VAT - if (!empty($arrayfields['f.total_vat']['checked'])) + if (!empty($arrayfields['f.total_tva']['checked'])) { - print ''.price($obj->total_vat)."\n"; + print ''.price($obj->total_tva)."\n"; if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat'; - $totalarray['val']['f.total_vat'] += $obj->total_vat; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva'; + $totalarray['val']['f.total_tva'] += $obj->total_tva; } // Amount LocalTax1 if (!empty($arrayfields['f.total_localtax1']['checked'])) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 8a50619f17c..2d695482352 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -138,7 +138,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $tmpinvoice = new Facture($db); - $sql = "SELECT f.rowid, f.ref, f.datef as date, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client"; + $sql = "SELECT f.rowid, f.ref, f.datef as date, f.total_ht, f.total_tva, f.total_ttc, f.ref_client"; $sql .= ", f.type, f.fk_statut as status, f.paye"; $sql .= ", s.nom as name"; $sql .= ", s.rowid as socid, s.email"; @@ -160,7 +160,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); $sql .= $hookmanager->resPrint; - $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, f.fk_statut, f.paye,"; + $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total_ht, f.total_tva, f.total_ttc, f.ref_client, f.type, f.fk_statut, f.paye,"; $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,"; $sql .= " cc.rowid, cc.code"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user"; @@ -383,7 +383,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $langs->load("boxes"); $tmpinvoice = new Facture($db); - $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; + $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms"; $sql .= ", f.date_lim_reglement as datelimite"; $sql .= ", s.nom as name"; $sql .= ", s.rowid as socid"; @@ -402,7 +402,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerLastModified', $parameters); $sql .= $hookmanager->resPrint; - $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; $sql .= " s.nom, s.rowid, s.code_client, s.code_compta, s.email,"; $sql .= " cc.rowid, cc.code"; $sql .= " ORDER BY f.tms DESC"; @@ -971,7 +971,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $tmpinvoice = new Facture($db); - $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; + $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.datef, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms"; $sql .= ", f.date_lim_reglement as datelimite"; $sql .= ", s.nom as name"; $sql .= ", s.rowid as socid, s.email"; @@ -990,7 +990,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerUnpaid', $parameters); $sql .= $hookmanager->resPrint; - $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code"; $sql .= " ORDER BY f.datef ASC, f.ref ASC"; From d04b04c10f493bb2ec83a07c1deb6e36c63517bb Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 22 Feb 2021 06:22:47 +0100 Subject: [PATCH 005/618] Fix --- htdocs/compta/facture/invoicetemplate_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index f51a15dea36..f1c478c64e3 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -536,7 +536,7 @@ if ($resql) } if (!empty($arrayfields['f.total_ht']['checked'])) { - print ''.price($objp->total).''."\n"; + print ''.price($objp->total_ht).''."\n"; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; $totalarray['val']['f.total_ht'] += $objp->total_ht; From 8548715a1806f39d378d5ae47513e234fe6ec599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 27 Feb 2021 15:48:41 +0100 Subject: [PATCH 006/618] add experimental repair script to utf8mb4 --- htdocs/install/repair.php | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 2a9c2bb11f2..85b425e22a5 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2021 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 @@ -94,6 +95,7 @@ print 'Option repair_link_dispatch_lines_supplier_order_lines, (\'test\' or \'co print 'Option set_empty_time_spent_amount (\'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount', 'alpha') ?GETPOST('set_empty_time_spent_amount', 'alpha') : 'undefined').'
'."\n"; // Structure print 'Option force_utf8_on_tables, for mysql/mariadb only (\'test\' or \'confirmed\') is '.(GETPOST('force_utf8_on_tables', 'alpha') ?GETPOST('force_utf8_on_tables', 'alpha') : 'undefined').'
'."\n"; +print "Option force_utf8mb4_on_tables (EXPERIMENTAL!), for mysql/mariadb only ('test' or 'confirmed') is ".(GETPOST('force_utf8mb4_on_tables', 'alpha') ? GETPOST('force_utf8mb4_on_tables', 'alpha') : 'undefined')."
\n"; print '
'; print ''; @@ -1253,6 +1255,54 @@ if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) { } } +// force utf8mb4 on tables EXPERIMENTAL ! +if ($ok && GETPOST('force_utf8mb4_on_tables', 'alpha')) { + print ''; + + if ($db->type == "mysql" || $db->type == "mysqli") { + $force_utf8mb4_on_tables = GETPOST('force_utf8mb4_on_tables', 'alpha'); + + $listoftables = $db->DDLListTables($db->database_name); + + // Disable foreign key checking for avoid errors + if ($force_utf8mb4_on_tables == 'confirmed') { + $sql = 'SET FOREIGN_KEY_CHECKS=0'; + print ''; + $resql = $db->query($sql); + } + + foreach ($listoftables as $table) { + // do not convert llx_const if mysql encrypt/decrypt is used + if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) { + continue; + } + + print ''; + flush(); + ob_flush(); + } + + // Enable foreign key checking + if ($force_utf8mb4_on_tables == 'confirmed') { + $sql = 'SET FOREIGN_KEY_CHECKS=1'; + print ''; + $resql = $db->query($sql); + } + } else { + print ''; + } +} + // if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { /* From 94a861c1c8123d30dda4ffead8f8f756cd506166 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 1 Mar 2021 04:07:31 +0100 Subject: [PATCH 007/618] Code enhanced - Standardize field name --- htdocs/comm/card.php | 12 +++--- .../facture/class/facture-rec.class.php | 12 +++++- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/compta/facture/index.php | 6 +-- htdocs/compta/index.php | 38 +++++++++---------- htdocs/compta/resultat/clientfourn.php | 4 +- htdocs/compta/resultat/index.php | 4 +- htdocs/compta/stats/cabyuser.php | 2 +- htdocs/compta/stats/casoc.php | 2 +- htdocs/compta/stats/index.php | 4 +- htdocs/compta/tva/class/tva.class.php | 2 +- htdocs/core/class/html.form.class.php | 4 +- htdocs/core/modules/modApi.class.php | 4 +- htdocs/core/modules/modGravatar.class.php | 4 +- htdocs/core/modules/modHoliday.class.php | 6 +-- .../core/modules/modMultiCurrency.class.php | 8 ++-- htdocs/core/modules/modPaybox.class.php | 6 +-- htdocs/core/modules/modPaypal.class.php | 6 +-- htdocs/fourn/facture/list.php | 2 +- .../class/intracommreport.class.php | 2 +- htdocs/margin/customerMargins.php | 4 +- htdocs/margin/productMargins.php | 4 +- htdocs/margin/tabs/productMargins.php | 4 +- htdocs/margin/tabs/thirdpartyMargins.php | 4 +- htdocs/recruitment/recruitmentindex.php | 2 +- test/phpunit/ExportTest.php | 2 +- 26 files changed, 80 insertions(+), 70 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 07ab4f797de..21cc9b0f5e2 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1147,8 +1147,8 @@ if ($object->id > 0) { */ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $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_ht'; + $sql .= ', f.total_tva'; $sql .= ', f.total_ttc'; $sql .= ', f.datec as dc'; $sql .= ', f.date_last_gen, f.date_when'; @@ -1159,7 +1159,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 IN (".getEntity('invoice').")"; - $sql .= ' GROUP BY f.rowid, f.titre, f.total, f.tva, f.total_ttc,'; + $sql .= ' GROUP BY f.rowid, f.titre, f.total_ht, f.total_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'; @@ -1241,8 +1241,8 @@ if ($object->id > 0) { */ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $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_ht'; + $sql .= ', f.total_tva'; $sql .= ', f.total_ttc'; $sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as status'; $sql .= ', s.nom, s.rowid as socid'; @@ -1251,7 +1251,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.total, f.tva, f.total_ttc,'; + $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.total_ht, f.total_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/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index d663a816088..f9f6eeb28e4 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -82,8 +82,18 @@ class FactureRec extends CommonInvoice public $number; public $date; public $remise; - public $tva; + + /** + * @deprecated + * @see $total_ht + */ public $total; + + /** + * @deprecated + * @see $total_tva + */ + public $tva; public $db_table; public $propalid; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 989a0ba1a67..604147e3966 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4182,7 +4182,7 @@ class Facture extends CommonInvoice $clause = " WHERE"; - $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut, f.total"; + $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut, f.total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; diff --git a/htdocs/compta/facture/index.php b/htdocs/compta/facture/index.php index 4939fbb6a95..86a2fc85c7d 100644 --- a/htdocs/compta/facture/index.php +++ b/htdocs/compta/facture/index.php @@ -222,7 +222,7 @@ function getDraftTable($maxCount = 500, $socid = 0) { global $db, $langs, $user; - $sql = "SELECT f.rowid, f.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client, f.total as total_ttc"; + $sql = "SELECT f.rowid, f.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client, f.total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) { @@ -285,7 +285,7 @@ function getDraftTable($maxCount = 500, $socid = 0) $result .= ''; $result .= ''; $result .= ''; - $result .= ''; + $result .= ''; $result .= ''; $i++; @@ -418,7 +418,7 @@ function getOpenTable($maxCount = 500, $socid = 0) global $conf, $db, $langs, $user; $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; - $sql .= ", f.rowid as id, f.entity, f.total as total_ttc, f.total as total_ht, f.ref, f.fk_statut"; + $sql .= ", f.rowid as id, f.entity, f.total_ttc, f.total_ht, f.ref, f.fk_statut"; $sql .= ", f.datef as df, f.date_lim_reglement as datelimite"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture as f"; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index e50a8266c58..f46b1e7f8fb 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -433,14 +433,14 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { print ''; print ''; if ($num) { - $total_ttc = $totalam = $total = 0; + $total_ttc = $totalam = $total_ht = 0; while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); if ($i >= $max) { $othernb += 1; $i++; - $total += $obj->total_ht; + $total_ht += $obj->total_ht; $total_ttc += $obj->total_ttc; continue; } @@ -499,7 +499,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { print ''; $total_ttc += $obj->total_ttc; - $total += $obj->total_ht; + $total_ht += $obj->total_ht; $totalam += $obj->am; $i++; @@ -577,7 +577,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print "\n"; if ($num) { $i = 0; - $total = $total_ttc = $totalam = 0; + $total_ht = $total_ttc = $totalam = 0; $othernb = 0; while ($i < $num) { @@ -586,7 +586,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU if ($i >= $max) { $othernb += 1; $i++; - $total += $obj->total_ht; + $total_ht += $obj->total_ht; $total_ttc += $obj->total_ttc; continue; } @@ -624,7 +624,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; print ''; print ''; - $total += $obj->total_ht; + $total_ht += $obj->total_ht; $total_ttc += $obj->total_ttc; $totalam += $obj->am; $i++; @@ -687,7 +687,7 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire) { print ''; print ''; if ($num) { - $total_ttc = $totalam = $total = 0; + $total_ttc = $totalam = $total_ht = 0; while ($i < $num && $i < $max) { $objp = $db->fetch_object($result); @@ -695,7 +695,7 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire) { if ($i >= $max) { $othernb += 1; $i++; - $total += $obj->total_ht; + $total_ht += $obj->total_ht; $total_ttc += $obj->total_ttc; continue; } @@ -786,7 +786,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { if ($i >= $max) { $othernb += 1; $i++; - $total += $obj->total_ht; + $total_ht += $obj->total_ht; $total_ttc += $obj->total_ttc; continue; } @@ -840,7 +840,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user $commandestatic = new Commande($db); $langs->load("orders"); - $sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc"; + $sql = "SELECT sum(f.total_ht) as tot_fht, sum(f.total_ttc) as tot_fttc"; $sql .= ", s.nom as name, s.email"; $sql .= ", s.rowid as socid"; $sql .= ", s.code_client, s.code_compta"; @@ -905,7 +905,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user if ($i >= $max) { $othernb += 1; $i++; - $total += $obj->total_ht; + $total_ht += $obj->total_ht; $total_ttc += $obj->total_ttc; continue; } @@ -1048,14 +1048,14 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { print ''; if ($num) { $societestatic = new Societe($db); - $total_ttc = $totalam = $total = 0; + $total_ttc = $totalam = $total_ht = 0; while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); if ($i >= $max) { $othernb += 1; $i++; - $total += $obj->total_ht; + $total_ht += $obj->total_ht; $total_ttc += $obj->total_ttc; continue; } @@ -1114,7 +1114,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { print ''; $total_ttc += $obj->total_ttc; - $total += $obj->total_ht; + $total_ht += $obj->total_ht; $totalam += $obj->am; $i++; @@ -1135,7 +1135,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { print ''; print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { - print ''; + print ''; } print ''; print ''; @@ -1221,14 +1221,14 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $societestatic = new Societe($db); if ($num) { $i = 0; - $total = $total_ttc = $totalam = 0; + $total_ht = $total_ttc = $totalam = 0; while ($i < $num) { $obj = $db->fetch_object($resql); if ($i >= $max) { $othernb += 1; $i++; - $total += $obj->total_ht; + $total_ht += $obj->total_ht; $total_ttc += $obj->total_ttc; continue; } @@ -1264,7 +1264,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; print ''; print ''; - $total += $obj->total_ht; + $total_ht += $obj->total_ht; $total_ttc += $obj->total_ttc; $totalam += $obj->am; $i++; @@ -1285,7 +1285,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { - print ''; + print ''; } print ''; print ''; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index d9073488567..374b2b3377e 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -367,7 +367,7 @@ if ($modecompta == 'BOOKKEEPING') { print ''; if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc"; + $sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE f.fk_soc = s.rowid"; @@ -1149,7 +1149,7 @@ if ($modecompta == 'BOOKKEEPING') { if ($modecompta == 'CREANCES-DETTES') { // VAT to pay $amount = 0; - $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.tva) as amount"; + $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE f.fk_statut IN (1,2)"; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 3c1d6d3fb0d..a56b44d6d7c 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -205,7 +205,7 @@ $subtotal_ht = 0; $subtotal_ttc = 0; if (!empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm"; + $sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE f.fk_soc = s.rowid"; @@ -386,7 +386,7 @@ $subtotal_ttc = 0; if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { if ($modecompta == 'CREANCES-DETTES') { // TVA collected to pay - $sql = "SELECT sum(f.tva) as amount, date_format(f.datef,'%Y-%m') as dm"; + $sql = "SELECT sum(f.total_tva) as amount, date_format(f.datef,'%Y-%m') as dm"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE f.fk_statut IN (1,2)"; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 494786bd8a2..bad94809672 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -224,7 +224,7 @@ foreach ($headerparams as $key => $value) { $catotal = 0; if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT u.rowid as rowid, u.lastname as name, u.firstname as firstname, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; + $sql = "SELECT u.rowid as rowid, u.lastname as name, u.firstname as firstname, sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.fk_user_author = u.rowid"; $sql .= " WHERE f.fk_statut in (1,2)"; diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 829e196a82e..0bee53574a0 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -239,7 +239,7 @@ $name = array(); $catotal = 0; if ($modecompta == 'CREANCES-DETTES') { $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,"; - $sql .= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; + $sql .= " sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; if ($selected_cat === -2) { // Without any category $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index eb039a63f92..eb30010b4b8 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -194,7 +194,7 @@ if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') { if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; + $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE f.fk_statut in (1,2)"; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { @@ -648,7 +648,7 @@ print ''; Je commente toute cette partie car les chiffres affichees sont faux - Eldy. En attendant correction. - $sql = "SELECT sum(f.total) as tot_fht,sum(f.total_ttc) as tot_fttc, p.rowid, p.ref, s.nom, s.rowid as socid, p.total_ht, p.total_ttc + $sql = "SELECT sum(f.total_ht) as tot_fht,sum(f.total_ttc) as tot_fttc, p.rowid, p.ref, s.nom, s.rowid as socid, p.total_ht, p.total_ttc FROM ".MAIN_DB_PREFIX."commande AS p, ".MAIN_DB_PREFIX."societe AS s LEFT JOIN ".MAIN_DB_PREFIX."co_fa AS co_fa ON co_fa.fk_commande = p.rowid LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON co_fa.fk_facture = f.rowid diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index f45112aedda..44c8a84ac53 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -427,7 +427,7 @@ class Tva extends CommonObject { // phpcs:enable - $sql = "SELECT sum(f.tva) as amount"; + $sql = "SELECT sum(f.total_tva) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; if ($year) { $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5f2497a5827..a7dff201e1c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7631,8 +7631,8 @@ class Form $possiblelinks = array( 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'), 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande').')'), - 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), - 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), + 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), + 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), 'contrat'=>array('enabled'=>$conf->contrat->enabled, 'perms'=>1, 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'), diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index aea29d25357..2120082ff95 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -195,7 +195,7 @@ class modApi extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' @@ -203,7 +203,7 @@ class modApi extends DolibarrModules // $this->export_entities_array[$r]=array( // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice", + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice", // 'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line", // 'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line", // 'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' diff --git a/htdocs/core/modules/modGravatar.class.php b/htdocs/core/modules/modGravatar.class.php index a7d8899b0c2..873c4642995 100644 --- a/htdocs/core/modules/modGravatar.class.php +++ b/htdocs/core/modules/modGravatar.class.php @@ -174,7 +174,7 @@ class modGravatar extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty", // 'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd", // 'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' @@ -182,7 +182,7 @@ class modGravatar extends DolibarrModules // $this->export_entities_array[$r]=array( // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice", + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice", // 'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line", // 'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line", // 'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index c3bbf2c3faf..ade56b048fa 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -241,7 +241,7 @@ class modHoliday extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' @@ -249,7 +249,7 @@ class modHoliday extends DolibarrModules // $this->export_entities_array[$r]=array( // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice", + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice", // 'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line", // 'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line", // 'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' @@ -258,7 +258,7 @@ class modHoliday extends DolibarrModules // 's.rowid'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.zip'=>'soc_zip','s.town'=>'soc_town','s.fk_pays'=>'soc_pays','s.phone'=>'soc_tel', // 's.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','s.code_compta'=>'soc_customer_accountancy', // 's.code_compta_fournisseur'=>'soc_supplier_accountancy','f.rowid'=>"invoiceid",'f.ref'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice", - // 'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid', + // 'f.total_ht'=>"totalht",'f.total_ttc'=>"totalttc",'f.total_tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid', // 'fd.description'=>"linedescription",'fd.price'=>"lineprice",'fd.total_ht'=>"linetotalht",'fd.total_tva'=>"linetotaltva",'fd.total_ttc'=>"linetotalttc", // 'fd.tva_tx'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend",'fd.fk_product'=>'productid', // 'p.ref'=>'productref' diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index f281c99dc37..52e99ff7ab9 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -221,7 +221,7 @@ class modMultiCurrency extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' @@ -230,7 +230,7 @@ class modMultiCurrency extends DolibarrModules // 't.date'=>'Date', 't.qte'=>'Numeric', 't.poids'=>'Numeric', 't.fad'=>'Numeric', 't.paq'=>'Numeric', 't.stockage'=>'Numeric', 't.fadparliv'=>'Numeric', // 't.livau100'=>'Numeric', 't.forfait'=>'Numeric', 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text', // 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text', - // 'f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric", + // 'f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric", // 'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'fd.description'=>"Text",'fd.subprice'=>"Numeric", // 'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date", // 'fd.date_end'=>"Date",'fd.special_code'=>'Numeric','fd.product_type'=>"Numeric",'fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text', @@ -239,8 +239,8 @@ class modMultiCurrency extends DolibarrModules // $this->export_entities_array[$r]=array( // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice", - // 'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line", + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice", + // 'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line", // 'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line", // 'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' //); diff --git a/htdocs/core/modules/modPaybox.class.php b/htdocs/core/modules/modPaybox.class.php index 1dfe76f471a..288fe51c8b6 100644 --- a/htdocs/core/modules/modPaybox.class.php +++ b/htdocs/core/modules/modPaybox.class.php @@ -168,8 +168,8 @@ class modPayBox extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town', // 's.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3', // 's.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', - // 'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT", - // 'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId', + // 'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT", + // 'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId', // 'fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT", // 'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef', // ); @@ -177,7 +177,7 @@ class modPayBox extends DolibarrModules // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company', // 's.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company', // 's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice", - // 'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice', + // 'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice', // 'f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line", // 'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line", // 'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product', diff --git a/htdocs/core/modules/modPaypal.class.php b/htdocs/core/modules/modPaypal.class.php index 82490dc0c4b..63d71d75363 100644 --- a/htdocs/core/modules/modPaypal.class.php +++ b/htdocs/core/modules/modPaypal.class.php @@ -175,7 +175,7 @@ class modPaypal extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' @@ -183,8 +183,8 @@ class modPaypal extends DolibarrModules // $this->export_entities_array[$r]=array( // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice", - // 'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line", + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice", + // 'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line", // 'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line", // 'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' // ); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 7c6ed0c5e16..d19b8a70505 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1252,7 +1252,7 @@ if ($resql) { print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); } if (!empty($arrayfields['f.total_vat']['checked'])) { - print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.total_tva', '', $param, '', $sortfield, $sortorder, 'right '); } if (!empty($arrayfields['f.total_localtax1']['checked'])) { print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right '); diff --git a/htdocs/intracommreport/class/intracommreport.class.php b/htdocs/intracommreport/class/intracommreport.class.php index cd4765161e9..35114b2de84 100644 --- a/htdocs/intracommreport/class/intracommreport.class.php +++ b/htdocs/intracommreport/class/intracommreport.class.php @@ -286,7 +286,7 @@ class IntracommReport extends CommonObject global $mysoc, $conf; if ($type == 'expedition' || $exporttype == 'des') { - $sql = 'SELECT f.ref as refinvoice, f.total as total_ht'; + $sql = 'SELECT f.ref as refinvoice, f.total_ht'; $table = 'facture'; $table_extraf = 'facture_extrafields'; $tabledet = 'facturedet'; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 05d5aa1ca5c..794c5637c53 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -216,7 +216,7 @@ $invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABAND $sql = "SELECT"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.client,"; if ($client) { - $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; + $sql .= " f.rowid as facid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut as statut,"; } $sql .= " sum(d.total_ht) as selling_price,"; // Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this) @@ -261,7 +261,7 @@ if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPr $sql .= " AND d.buy_price_ht <> 0"; } if ($client) { - $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; + $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut"; } else { $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client"; } diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 0ac47243723..22ef162ec19 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -179,7 +179,7 @@ if ($id > 0) { $sql .= " d.fk_product,"; } if ($id > 0) { - $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; + $sql .= " f.rowid as facid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut as statut,"; } $sql .= " SUM(d.total_ht) as selling_price,"; // Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this) @@ -214,7 +214,7 @@ if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPr $sql .= " AND d.buy_price_ht <> 0"; } if ($id > 0) { - $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; + $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut"; } else { $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity"; } diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 031c49e4cd0..6998b97faad 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -137,7 +137,7 @@ if ($id > 0 || !empty($ref)) { if ($user->rights->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client,"; - $sql .= " f.rowid as facid, f.ref, f.total as total_ht,"; + $sql .= " f.rowid as facid, f.ref, f.total_ht,"; $sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,"; if (!$user->rights->societe->client->voir && !$socid) { $sql .= " sc.fk_soc, sc.fk_user,"; @@ -167,7 +167,7 @@ if ($id > 0 || !empty($ref)) { if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { $sql .= " AND d.buy_price_ht <> 0"; } - $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; + $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut, f.type"; if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", sc.fk_soc, sc.fk_user"; } diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 0103bd03aca..7719990bc55 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -160,7 +160,7 @@ if ($socid > 0) { print '
'; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; - $sql .= " f.rowid as facid, f.ref, f.total as total_ht,"; + $sql .= " f.rowid as facid, f.ref, f.total_ht,"; $sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,"; $sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive $sql .= " sum(d.qty * d.buy_price_ht * (d.situation_percent / 100)) as buying_price,"; // always positive @@ -177,7 +177,7 @@ if ($socid > 0) { if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { $sql .= " AND d.buy_price_ht <> 0"; } - $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; + $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut, f.type"; $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); diff --git a/htdocs/recruitment/recruitmentindex.php b/htdocs/recruitment/recruitmentindex.php index 844cd8a221a..51e49370b6a 100644 --- a/htdocs/recruitment/recruitmentindex.php +++ b/htdocs/recruitment/recruitmentindex.php @@ -246,7 +246,7 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->read) { $langs->load("orders"); - $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index 4051deb125b..ff1ded90bd6 100644 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -248,7 +248,7 @@ class ExportTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - $sql = "SELECT f.ref as f_ref, f.total as f_total, f.tva as f_tva FROM ".MAIN_DB_PREFIX."facture f"; + $sql = "SELECT f.ref as f_ref, f.total_ht as f_total, f.total_tva as f_tva FROM ".MAIN_DB_PREFIX."facture f"; $objexport=new Export($db); //$objexport->load_arrays($user,$datatoexport); From cb507a61b965838e329cb19ad86ab05006758986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Mar 2021 09:54:52 +0100 Subject: [PATCH 008/618] backup with utf8mb4 --- htdocs/core/class/utils.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 3806e5bda4d..d91428d11bb 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -194,6 +194,7 @@ class Utils { global $db, $conf, $langs, $dolibarr_main_data_root; global $dolibarr_main_db_name, $dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_port, $dolibarr_main_db_pass; + global $dolibarr_main_db_character_set; $langs->load("admin"); @@ -314,7 +315,12 @@ class Utils } else { $param .= " -d"; // No row information (no data) } - $param .= " --default-character-set=utf8"; // We always save output into utf8 charset + if ($dolibarr_main_db_character_set == 'utf8mb4') { + // We save output into utf8mb4 charset + $param .= " --default-character-set=utf8mb4"; + } else { + $param .= " --default-character-set=utf8"; // We always save output into utf8 charset + } $paramcrypted = $param; $paramclear = $param; if (!empty($dolibarr_main_db_pass)) { From 4c81f0a52adcda855b33f29652fd84884dc7156e Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Fri, 5 Mar 2021 10:46:26 +0100 Subject: [PATCH 009/618] Add fields property to ProductFournisseur class --- .../fourn/class/fournisseur.product.class.php | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 6ae9a3491ab..f15b300346d 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -134,7 +134,43 @@ class ProductFournisseur extends Product public $packaging; - + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0,), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,), + 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>-1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>25, 'notnull'=>1, 'visible'=>-1,), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), + 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), + 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), + 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), + 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), + 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), + 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), + 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), + 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), + 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), + 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), + 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), + 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), + 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), + 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>900, 'notnull'=>0, 'visible'=>-2,), + 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), + 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), + 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), + 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), + 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), + 'barcode' => array('type'=>'varchar(180)', 'label'=>'Barcode', 'enabled'=>'1', 'position'=>170, 'notnull'=>0, 'visible'=>-1,), + 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), + 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), + ); /** * Constructor * From 5a47e4b7ec9b99796f458551e7a3666e3b6b564e Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Fri, 5 Mar 2021 10:59:11 +0100 Subject: [PATCH 010/618] add standard fetchAll method on ProductFournisseur --- .../fourn/class/fournisseur.product.class.php | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index f15b300346d..c334e939a74 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1277,4 +1277,81 @@ class ProductFournisseur extends Product return 1; } } + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = 'SELECT '; + $sql .= $this->getFieldList(); + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; + + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } } From 76858f06cd03bbb6f7f20e066e4b2721b893b036 Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Mon, 8 Mar 2021 16:49:04 +0100 Subject: [PATCH 011/618] ProductFournisseur fields update to reflect Product Class inheritance --- .../fourn/class/fournisseur.product.class.php | 71 +++++++++---------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index c334e939a74..0234c5c8cd7 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -134,43 +134,6 @@ class ProductFournisseur extends Product public $packaging; - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0,), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,), - 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>-1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>25, 'notnull'=>1, 'visible'=>-1,), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), - 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), - 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), - 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), - 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), - 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), - 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), - 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), - 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), - 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), - 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), - 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), - 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), - 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>900, 'notnull'=>0, 'visible'=>-2,), - 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), - 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), - 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), - 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), - 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), - 'barcode' => array('type'=>'varchar(180)', 'label'=>'Barcode', 'enabled'=>'1', 'position'=>170, 'notnull'=>0, 'visible'=>-1,), - 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), - 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - ); /** * Constructor * @@ -183,6 +146,37 @@ class ProductFournisseur extends Product $this->db = $db; $langs->load("suppliers"); $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); + $this->fields = array_merge($this->fields, array( + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), + 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), + 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), + 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), + 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), + 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), + 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), + 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), + 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), + 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), + 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), + 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), + 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), + 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), + 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), + 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), + 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), + 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), + 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), + 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), + 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), + 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), + )) } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1354,4 +1348,7 @@ class ProductFournisseur extends Product return -1; } } + public function getFieldList() { + return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') + } } From 0986f1082ca009e492f0565d50b55ba528ef6d09 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 8 Mar 2021 15:49:39 +0000 Subject: [PATCH 012/618] Fixing style errors. --- htdocs/fourn/class/fournisseur.product.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 0234c5c8cd7..aee2a284610 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1348,7 +1348,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') } } From c0b5ba4bb56162f72f1d7b537ab12b8b4d1a9815 Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Mon, 8 Mar 2021 16:51:55 +0100 Subject: [PATCH 013/618] correct mistakes --- htdocs/fourn/class/fournisseur.product.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 0234c5c8cd7..371a5581c55 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -176,7 +176,7 @@ class ProductFournisseur extends Product 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - )) + )); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1349,6 +1349,6 @@ class ProductFournisseur extends Product } } public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') + return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); } } From 8b71418c0a54a77b06065e4fded66261d72396c7 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 8 Mar 2021 15:54:15 +0000 Subject: [PATCH 014/618] Fixing style errors. --- .../fourn/class/fournisseur.product.class_20210308165002.php | 3 ++- .../fourn/class/fournisseur.product.class_20210308165033.php | 3 ++- .../fourn/class/fournisseur.product.class_20210308165051.php | 3 ++- .../fourn/class/fournisseur.product.class_20210308165324.php | 3 ++- htdocs/fourn/class/fournisseur.product.class.php | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php index 06713c4dc73..d445e2b2a50 100644 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php +++ b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php @@ -1338,7 +1338,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') } } diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php index 8c0a23b14d7..93677623bbf 100644 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php +++ b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php @@ -1338,7 +1338,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') } } diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php index 885ce24f01f..6d440236388 100644 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php +++ b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php @@ -1338,7 +1338,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); } } diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php index 371a5581c55..6c6ddc2509d 100644 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php +++ b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php @@ -1348,7 +1348,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); } } diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 371a5581c55..6c6ddc2509d 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1348,7 +1348,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); } } From ae5a581175bc68612175945c9c1eca9615229bd1 Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Mon, 8 Mar 2021 16:59:13 +0100 Subject: [PATCH 015/618] correct mistakes --- ...urnisseur.product.class_20210308165002.php | 1344 ---------------- ...urnisseur.product.class_20210308165033.php | 1344 ---------------- ...urnisseur.product.class_20210308165051.php | 1344 ---------------- ...urnisseur.product.class_20210308165324.php | 1354 ----------------- .../fourn/class/fournisseur.product.class.php | 10 +- 5 files changed, 8 insertions(+), 5388 deletions(-) delete mode 100644 .history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php delete mode 100644 .history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php delete mode 100644 .history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php delete mode 100644 .history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php deleted file mode 100644 index 06713c4dc73..00000000000 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php +++ /dev/null @@ -1,1344 +0,0 @@ - - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009-2014 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2019 Frédéric France - * Copyright (C) 2020 Pierre Ardoin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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/fourn/class/fournisseur.product.class.php - * \ingroup produit - * \brief File of class to manage predefined suppliers products - */ - -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - - -/** - * Class to manage predefined suppliers products - */ -class ProductFournisseur extends Product -{ - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $product_fourn_price_id; // id of ligne product-supplier - - /** - * @var int ID - */ - public $id; - - /** - * @deprecated - * @see $ref_supplier - */ - public $fourn_ref; - - public $delivery_time_days; - public $ref_supplier; // ref supplier (can be set by get_buyprice) - public $desc_supplier; - public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) - - public $product_id; - public $product_ref; - - public $fourn_id; //supplier id - public $fourn_qty; // quantity for price (can be set by get_buyprice) - public $fourn_pu; // unit price for quantity (can be set by get_buyprice) - - public $fourn_price; // price for quantity - public $fourn_remise_percent; // discount for quantity (percent) - public $fourn_remise; // discount for quantity (amount) - - public $product_fourn_id; // product-supplier id - public $product_fourn_entity; - - /** - * @var int ID user_id - user who created/updated supplier price - */ - public $user_id; - - /** - * @var int ID availability delay - visible/used if option FOURN_PRODUCT_AVAILABILITY is on (duplicate information compared to delivery delay) - */ - public $fk_availability; - - public $fourn_unitprice; - public $fourn_tva_tx; - public $fourn_tva_npr; - - /** - * @var int ID - */ - public $fk_supplier_price_expression; - - public $supplier_reputation; // reputation of supplier - public $reputations = array(); // list of available supplier reputations - - // Multicurreny - public $fourn_multicurrency_id; - public $fourn_multicurrency_code; - public $fourn_multicurrency_tx; - public $fourn_multicurrency_price; - public $fourn_multicurrency_unitprice; - - /** - * @deprecated - * @see $supplier_barcode - */ - public $fourn_barcode; - - /** - * @var string $supplier_barcode - Supplier barcode - */ - public $supplier_barcode; - - /** - * @deprecated - * @see $supplier_fk_barcode_type - */ - public $fourn_fk_barcode_type; - - /** - * @var string $supplier_fk_barcode_type - Supplier barcode type - */ - public $supplier_fk_barcode_type; - - public $packaging; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs; - - $this->db = $db; - $langs->load("suppliers"); - $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); - $this->fields = array_merge($this->fields, array( - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), - 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), - 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), - 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), - 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), - 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), - 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), - 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), - 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), - 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), - 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), - 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), - 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), - 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), - 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), - 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), - 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), - 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), - 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), - 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), - 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - )) - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove all prices for this couple supplier-product - * - * @param int $id_fourn Supplier Id - * @return int < 0 if error, > 0 if ok - */ - public function remove_fournisseur($id_fourn) - { - // phpcs:enable - $ok = 1; - - $this->db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; - - dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); - $resql2 = $this->db->query($sql); - if (!$resql2) - { - $this->error = $this->db->lasterror(); - $ok = 0; - } - - if ($ok) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove a price for a couple supplier-product - * - * @param int $rowid Line id of price - * @return int <0 if KO, >0 if OK - */ - public function remove_product_fournisseur_price($rowid) - { - // phpcs:enable - global $conf, $user; - - $error = 0; - - $this->db->begin(); - - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); - if ($result < 0) $error++; - // End call triggers - - if (empty($error)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE rowid = ".$rowid; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - - if (empty($error)) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Modify the purchase price for a supplier - * - * @param float $qty Min quantity for which price is valid - * @param float $buyprice Purchase price for the quantity min - * @param User $user Object user user made changes - * @param string $price_base_type HT or TTC - * @param Societe $fourn Supplier - * @param int $availability Product availability - * @param string $ref_fourn Supplier ref - * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string) - * @param string $charges costs affering to product - * @param float $remise_percent Discount regarding qty (percent) - * @param float $remise Discount regarding qty (amount) - * @param int $newnpr Set NPR or not - * @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. - * @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). - * @param string $newdefaultvatcode Default vat code - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param string $multicurrency_price_base_type HT or TTC in currency - * @param float $multicurrency_tx Rate currency - * @param string $multicurrency_code Currency code - * @param string $desc_fourn Custom description for product_fourn_price - * @param string $barcode Barcode - * @param int $fk_barcode_type Barcode type - * @return int <0 if KO, >=0 if OK - */ - public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '') - { - // phpcs:enable - global $conf, $langs; - //global $mysoc; - - // Clean parameter - if (empty($qty)) $qty = 0; - if (empty($buyprice)) $buyprice = 0; - if (empty($charges)) $charges = 0; - if (empty($availability)) $availability = 0; - if (empty($remise_percent)) $remise_percent = 0; - if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = ''; - if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = ''; - if ($price_base_type == 'TTC') - { - $ttx = $tva_tx; - $buyprice = $buyprice / (1 + ($ttx / 100)); - } - - // Multicurrency - $multicurrency_unitBuyPrice = null; - $fk_multicurrency = null; - if (!empty($conf->multicurrency->enabled)) { - if (empty($multicurrency_tx)) $multicurrency_tx = 1; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; - if ($multicurrency_price_base_type == 'TTC') - { - $ttx = $tva_tx; - $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100)); - } - $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU'); - $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU'); - - $buyprice = $multicurrency_buyprice / $multicurrency_tx; - $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code); - } - - $buyprice = price2num($buyprice, 'MU'); - $charges = price2num($charges, 'MU'); - $qty = price2num($qty, 'MS'); - $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - - $packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS'); - - $error = 0; - $now = dol_now(); - - $newvat = $tva_tx; - - if (count($localtaxes_array) > 0) - { - $localtaxtype1 = $localtaxes_array['0']; - $localtax1 = $localtaxes_array['1']; - $localtaxtype2 = $localtaxes_array['2']; - $localtax2 = $localtaxes_array['3']; - } else { // old method. deprecated because ot can't retrieve type - $localtaxtype1 = '0'; - $localtax1 = get_localtax($newvat, 1); - $localtaxtype2 = '0'; - $localtax2 = get_localtax($newvat, 2); - } - if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 - if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 - - // Check parameters - if ($buyprice != '' && !is_numeric($buyprice)) - { - } - - $this->db->begin(); - - if ($this->product_fourn_price_id > 0) - { - // check if price already logged, if not first log current price - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id); - if (is_array($logPrices) && count($logPrices) == 0) - { - $currentPfp = new self($this->db); - $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); - if ($result > 0 && $currentPfp->fourn_price != 0) - { - $currentPfpUser = new User($this->db); - $result = $currentPfpUser->fetch($currentPfp->user_id); - if ($result > 0) { - $currentPfp->logPrice( - $currentPfpUser, - $currentPfp->date_creation, - $currentPfp->fourn_price, - $currentPfp->fourn_qty, - $currentPfp->fourn_multicurrency_price, - $currentPfp->fourn_multicurrency_unitprice, - $currentPfp->fourn_multicurrency_tx, - $currentPfp->fourn_multicurrency_id, - $currentPfp->fourn_multicurrency_code - ); - } - } - } - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_user = ".$user->id." ,"; - $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; - $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; - $sql .= " price = ".$buyprice.","; - $sql .= " quantity = ".$qty.","; - $sql .= " remise_percent = ".$remise_percent.","; - $sql .= " remise = ".$remise.","; - $sql .= " unitprice = ".$unitBuyPrice.","; - $sql .= " fk_availability = ".$availability.","; - $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " entity = ".$conf->entity.","; - $sql .= " tva_tx = ".price2num($tva_tx).","; - // TODO Add localtax1 and localtax2 - //$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; - //$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; - //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$this->db->escape($localtaxtype1)."'":"'0'").","; - //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$this->db->escape($localtaxtype2)."'":"'0'").","; - $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " info_bits = ".$newnpr.","; - $sql .= " charges = ".$charges.","; // deprecated - $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - // TODO Add price_base_type and price_ttc - - dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); - if ($result < 0) $error++; - // End call triggers - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) - { - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - if (empty($error)) - { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); - - // Delete price for this quantity - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - // Add price for this quantity to supplier - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging"; - $sql .= " values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " '".$this->db->idate($now)."',"; - $sql .= " ".$this->id.","; - $sql .= " ".$fourn->id.","; - $sql .= " '".$this->db->escape($ref_fourn)."',"; - $sql .= " '".$this->db->escape($desc_fourn)."',"; - $sql .= " ".$user->id.","; - $sql .= " ".$buyprice.","; - $sql .= " ".$qty.","; - $sql .= " ".$remise_percent.","; - $sql .= " ".$remise.","; - $sql .= " ".$unitBuyPrice.","; - $sql .= " ".$tva_tx.","; - $sql .= " ".$charges.","; - $sql .= " ".$availability.","; - $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " ".$newnpr.","; - $sql .= $conf->entity.","; - $sql .= ($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)); - $sql .= ")"; - - $this->product_fourn_price_id = 0; - - $resql = $this->db->query($sql); - if ($resql) { - $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); - } else { - $error++; - } - - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { - // Add record into log table - // $this->product_fourn_price_id must be set - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - - if (!$error) { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); - if ($result < 0) - $error++; - // End call triggers - - if (empty($error)) { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Loads the price information of a provider - * - * @param int $rowid Line id - * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead - * @return int < 0 if KO, 0 if OK but not found, > 0 if OK - */ - public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,"; - $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; - $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging,"; - $sql .= " p.ref as product_ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p"; - $sql .= " WHERE pfp.rowid = ".(int) $rowid; - $sql .= " AND pfp.fk_product = p.rowid"; - - dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj) - { - $this->product_fourn_price_id = $rowid; - $this->id = $obj->fk_product; - - $this->fk_product = $obj->fk_product; - $this->product_id = $obj->fk_product; - $this->product_ref = $obj->product_ref; - - $this->fourn_id = $obj->fk_soc; - $this->fourn_ref = $obj->ref_fourn; // deprecated - $this->ref_supplier = $obj->ref_fourn; - $this->desc_supplier = $obj->desc_fourn; - $this->fourn_price = $obj->price; - $this->fourn_charges = $obj->charges; // deprecated - $this->fourn_qty = $obj->quantity; - $this->fourn_remise_percent = $obj->remise_percent; - $this->fourn_remise = $obj->remise; - $this->fourn_unitprice = $obj->unitprice; - $this->fourn_tva_tx = $obj->tva_tx; - $this->fourn_tva_npr = $obj->fourn_tva_npr; - // Add also localtaxes - $this->fk_availability = $obj->fk_availability; - $this->delivery_time_days = $obj->delivery_time_days; - $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; - $this->supplier_reputation = $obj->supplier_reputation; - $this->default_vat_code = $obj->default_vat_code; - $this->user_id = $obj->fk_user; - $this->date_creation = $this->db->jdate($obj->datec); - $this->fourn_multicurrency_price = $obj->multicurrency_price; - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; - $this->fourn_multicurrency_id = $obj->fk_multicurrency; - $this->fourn_multicurrency_code = $obj->multicurrency_code; - if (!empty($conf->barcode->enabled)) { - $this->fourn_barcode = $obj->barcode; // deprecated - $this->fourn_fk_barcode_type = $obj->fk_barcode_type; // deprecated - $this->supplier_barcode = $obj->barcode; - $this->supplier_fk_barcode_type = $obj->fk_barcode_type; - } - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->packaging = $obj->packaging; - if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty; - } - - if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) - { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($this); - if ($price_result >= 0) { - $this->fourn_price = $price_result; - //recalculation of unitprice, as probably the price changed... - if ($this->fourn_qty != 0) - { - $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU'); - } else { - $this->fourn_unitprice = ""; - } - } - } - - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * List all supplier prices of a product - * - * @param int $prodid Id of product - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Products with new properties to define supplier price - */ - public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id, p.ref as product_ref,"; - $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; - $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; - $sql .= " AND s.status=1"; // only enabled company selected - $sql .= " AND pfp.fk_product = ".$prodid; - if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($record = $this->db->fetch_array($resql)) - { - //define base attribute - $prodfourn = new ProductFournisseur($this->db); - - $prodfourn->product_ref = $record["product_ref"]; - $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; - $prodfourn->product_fourn_id = $record["product_fourn_id"]; - $prodfourn->product_fourn_entity = $record["entity"]; - $prodfourn->ref_supplier = $record["ref_fourn"]; - $prodfourn->fourn_ref = $record["ref_fourn"]; - $prodfourn->desc_supplier = $record["desc_fourn"]; - $prodfourn->fourn_price = $record["price"]; - $prodfourn->fourn_qty = $record["quantity"]; - $prodfourn->fourn_remise_percent = $record["remise_percent"]; - $prodfourn->fourn_remise = $record["remise"]; - $prodfourn->fourn_unitprice = $record["unitprice"]; - $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_tva_tx = $record["tva_tx"]; - $prodfourn->fourn_id = $record["fourn_id"]; - $prodfourn->fourn_name = $record["supplier_name"]; - $prodfourn->fk_availability = $record["fk_availability"]; - $prodfourn->delivery_time_days = $record["delivery_time_days"]; - $prodfourn->id = $prodid; - $prodfourn->fourn_tva_npr = $record["info_bits"]; - $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $prodfourn->supplier_reputation = $record["supplier_reputation"]; - $prodfourn->fourn_date_creation = $this->db->jdate($record['datec']); - $prodfourn->fourn_date_modification = $this->db->jdate($record['tms']); - - $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"]; - $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; - $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $prodfourn->packaging = $record["packaging"]; - if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty; - } - - if (!empty($conf->barcode->enabled)) { - $prodfourn->supplier_barcode = $record["barcode"]; - $prodfourn->supplier_fk_barcode_type = $record["fk_barcode_type"]; - } - - if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prodfourn); - if ($price_result >= 0) { - $prodfourn->fourn_price = $price_result; - $prodfourn->fourn_unitprice = null; //force recalculation of unitprice, as probably the price changed... - } - } - - if (!isset($prodfourn->fourn_unitprice)) - { - if ($prodfourn->fourn_qty != 0) - { - $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU'); - } else { - $prodfourn->fourn_unitprice = ""; - } - } - - $retarray[] = $prodfourn; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load properties for minimum price - * - * @param int $prodid Product id - * @param int $qty Minimum quantity - * @param int $socid get min price for specific supplier - * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK - */ - public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) - { - // phpcs:enable - global $conf; - - if (empty($prodid)) - { - dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING); - return 0; - } - - $this->product_fourn_price_id = ''; - $this->product_fourn_id = ''; - $this->fourn_ref = ''; - $this->fourn_price = ''; - $this->fourn_qty = ''; - $this->fourn_remise_percent = ''; - $this->fourn_remise = ''; - $this->fourn_unitprice = ''; - $this->fourn_id = ''; - $this->fourn_name = ''; - $this->delivery_time_days = ''; - $this->id = ''; - - $this->fourn_multicurrency_price = ''; - $this->fourn_multicurrency_unitprice = ''; - $this->fourn_multicurrency_tx = ''; - $this->fourn_multicurrency_id = ''; - $this->fourn_multicurrency_code = ''; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; - $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; - $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE s.entity IN (".getEntity('societe').")"; - $sql .= " AND pfp.entity = ".$conf->entity; // only current entity - $sql .= " AND pfp.fk_product = ".$prodid; - $sql .= " AND pfp.fk_soc = s.rowid"; - $sql .= " AND s.status = 1"; // only enabled society - if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid; - - dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $record_array = array(); - - //Store each record to array for later search of min - while ($record = $this->db->fetch_array($resql)) - { - $record_array[] = $record; - } - - if (count($record_array) == 0) - { - $this->db->free($resql); - return 0; - } else { - $min = -1; - foreach ($record_array as $record) - { - $fourn_price = $record["price"]; - // discount calculated buy price - $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; - if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { - $prod_supplier = new ProductFournisseur($this->db); - $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; - $prod_supplier->id = $prodid; - $prod_supplier->fourn_qty = $record["quantity"]; - $prod_supplier->fourn_tva_tx = $record["tva_tx"]; - $prod_supplier->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prod_supplier); - if ($price_result >= 0) { - $fourn_price = price2num($price_result, 'MU'); - if ($record["quantity"] != 0) - { - $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU'); - } else { - $fourn_unitprice = $fourn_price; - } - } - } - if ($fourn_unitprice < $min || $min == -1) - { - $this->product_fourn_price_id = $record["product_fourn_price_id"]; - $this->ref_supplier = $record["ref_fourn"]; - $this->ref_fourn = $record["ref_fourn"]; // deprecated - $this->fourn_ref = $record["ref_fourn"]; // deprecated - $this->fourn_price = $fourn_price; - $this->fourn_qty = $record["quantity"]; - $this->fourn_remise_percent = $record["remise_percent"]; - $this->fourn_remise = $record["remise"]; - $this->fourn_unitprice = $record["unitprice"]; - $this->fourn_charges = $record["charges"]; // deprecated - $this->fourn_tva_tx = $record["tva_tx"]; - $this->fourn_id = $record["fourn_id"]; - $this->fourn_name = $record["supplier_name"]; - $this->delivery_time_days = $record["delivery_time_days"]; - $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $this->id = $prodid; - $this->fourn_multicurrency_price = $record["multicurrency_price"]; - $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $this->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $this->fourn_multicurrency_id = $record["fk_multicurrency"]; - $this->fourn_multicurrency_code = $record["multicurrency_code"]; - $min = $fourn_unitprice; - } - } - } - - $this->db->free($resql); - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Sets the supplier price expression - * - * @param int $expression_id Expression - * @return int <0 if KO, >0 if OK - */ - public function setSupplierPriceExpression($expression_id) - { - global $conf; - - // Clean parameters - $this->db->begin(); - $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; - - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_supplier_price_expression = ".$expression_id; - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - - dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - - /** - * Display supplier of product - * - * @param int $withpicto Add picto - * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @return string String with supplier price - * TODO Remove this method. Use getNomUrl directly. - */ - public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) - { - $thirdparty = new Fournisseur($this->db); - $thirdparty->fetch($this->fourn_id); - - return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display price of product - * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects - * to display in table format. - * @return string String with supplier price - */ - public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) - { - // phpcs:enable - global $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournList) > 0) { - $out .= '

*** Force page code and collation of tables into utf8mb4/utf8mb4_unicode_ci (for mysql/mariadb only)
'; + print $table; + $sql = 'ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'; + print ''; + if ($force_utf8mb4_on_tables == 'confirmed') { + $resql = $db->query($sql); + print ' - Done ('.($resql ? 'OK' : 'KO').')'; + } else { + print ' - Disabled'; + } + print '
Not available with database type '.$db->type.'
'.$objectstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer', 24).''.price($obj->total_ttc).''.price($obj->total_ht).'
 
'.dol_print_date($db->jdate($obj->tms), 'day').''.$facstatic->getLibStatut(3).'
 
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToTake").': '.price($total_ttc - $totalam).')  '.price($total).''.price($total_ht).''.price($total_ttc).''.price($totalam).''.price($obj->am).''.$facstatic->getLibStatut(3, $obj->am).'
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToPay").': '.price($total_ttc - $totalam).')  '.price($total).''.price($total_ht).''.price($total_ttc).''.price($totalam).'
'.$langs->trans("CustomersInvoices").'
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - foreach ($productFournList as $productFourn) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - } - $out .= '
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; - } else { - $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); - } - return $out; - } - - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'product_fournisseur_price' - ); - - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } - - /** - * List supplier prices log of a supplier price - * - * @param int $product_fourn_price_id Id of supplier price - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Log prices - */ - public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - $sql = "SELECT"; - $sql .= " u.lastname,"; - $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec,"; - $sql .= " pfpl.price, pfpl.quantity,"; - $sql .= " pfpl.fk_multicurrency, pfpl.multicurrency_code, pfpl.multicurrency_tx, pfpl.multicurrency_price, pfpl.multicurrency_unitprice"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl,"; - $sql .= " ".MAIN_DB_PREFIX."product_fournisseur_price as pfp,"; - $sql .= " ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")"; - $sql .= " AND pfpl.fk_user = u.rowid"; - $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; - $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($obj = $this->db->fetch_object($resql)) - { - $tmparray = array(); - $tmparray['rowid'] = $obj->rowid; - $tmparray['supplier_ref'] = $obj->supplier_ref; - $tmparray['datec'] = $this->db->jdate($obj->datec); - $tmparray['lastname'] = $obj->lastname; - $tmparray['price'] = $obj->price; - $tmparray['quantity'] = $obj->quantity; - $tmparray['fk_multicurrency'] = $obj->fk_multicurrency; - $tmparray['multicurrency_code'] = $obj->multicurrency_code; - $tmparray['multicurrency_tx'] = $obj->multicurrency_tx; - $tmparray['multicurrency_price'] = $obj->multicurrency_price; - $tmparray['multicurrency_unitprice'] = $obj->multicurrency_unitprice; - - $retarray[] = $tmparray; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Display log price of product supplier price - * - * @param array $productFournLogList list of ProductFournisseur price log objects - * to display in table format. - * @return string HTML String with supplier price - */ - public function displayPriceProductFournisseurLog($productFournLogList = array()) - { - global $conf, $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournLogList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - //$out .= ''; - $out .= ''; - foreach ($productFournLogList as $productFournLog) { - $out .= ''; - $out .= ''; - //$out.= ''; - $out .= ''; - } - $out .= '
'.$langs->trans("Date").''.$langs->trans("Price").''.$langs->trans("QtyMin").''.$langs->trans("User").'
'.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').''.price($productFournLog['price'], 0, $langs, 1, -1, -1, $conf->currency); - if ($productFournLog['multicurrency_code'] != $conf->currency) { - $out .= ' ('.price($productFournLog['multicurrency_price'], 0, $langs, 1, -1, -1, $productFournLog['multicurrency_code']).')'; - } - $out .= ''.$productFournLog['quantity'].''.$productFournLog['lastname'].'
'; - } - return $out; - } - - - /** - * Return a link to the object card (with optionaly the picto). - * Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl(). - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs; - - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - - $result = ''; - - if (!empty($this->entity)) { - $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); - if ($this->nbphoto > 0) { - $label .= '
'; - $label .= $tmpphoto; - $label .= '
'; - } - } - - if ($this->type == Product::TYPE_PRODUCT) { - $label .= img_picto('', 'product').' '.$langs->trans("Product").''; - } elseif ($this->type == Product::TYPE_SERVICE) { - $label .= img_picto('', 'service').' '.$langs->trans("Service").''; - } - if (isset($this->status) && isset($this->status_buy)) { - $label .= ' '.$this->getLibStatut(5, 0); - $label .= ' '.$this->getLibStatut(5, 1); - } - - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('ProductRef').': '.($this->ref ? $this->ref : $this->product_ref); - } - if (!empty($this->label)) { - $label .= '
'.$langs->trans('ProductLabel').': '.$this->label; - } - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - - if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (!empty($conf->productbatch->enabled)) { - $langs->load("productbatch"); - $label .= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); - } - } - if (!empty($conf->barcode->enabled)) { - $label .= '
'.$langs->trans('BarCode').': '.$this->barcode; - } - - if ($this->type == Product::TYPE_PRODUCT) - { - if ($this->weight) { - $label .= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); - } - $labelsize = ""; - if ($this->length) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); - } - if ($this->width) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); - } - if ($this->height) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); - } - if ($labelsize) $label .= "
".$labelsize; - - $labelsurfacevolume = ""; - if ($this->surface) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); - } - if ($this->volume) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); - } - if ($labelsurfacevolume) $label .= "
".$labelsurfacevolume; - } - - if (!empty($conf->accounting->enabled) && $this->status) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); - $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); - $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); - } - if (!empty($conf->accounting->enabled) && $this->status_buy) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); - $label .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); - $label .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); - } - - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here - if (is_array($logPrices) && count($logPrices) > 0) { - $label .= '

'; - $label .= ''.$langs->trans("History").''; - $label .= $this->displayPriceProductFournisseurLog($logPrices); - } - - $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; - - 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'; - } - - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("SupplierRef"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - - $linkstart = ''; - $linkend = ''; - - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - - return $result; - } - - /** - * Private function to log price history - * - * @param User $user Object user who adds/changes price - * @param integer $datec date create - * @param float $buyprice price for qty - * @param float $qty qty for price - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param float $multicurrency_unitBuyPrice Unit Purchase price in currency - * @param float $multicurrency_tx Rate currency - * @param int $fk_multicurrency key multi currency - * @param string $multicurrency_code Currency code - * - * @return int < 0 NOK > 0 OK - */ - private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null) - { - // Add record into log table - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; - $sql .= "values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= "'".$this->db->idate($datec)."',"; - $sql .= " ".$this->product_fourn_price_id.","; - $sql .= " ".$user->id.","; - $sql .= " ".price2num($buyprice).","; - $sql .= " ".$qty; - $sql .= ")"; - - $resql = $this->db->query($sql); - if (!$resql) { - return -1; - } else { - return 1; - } - } - - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $records = array(); - - $sql = 'SELECT '; - $sql .= $this->getFieldList(); - $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as t'; - $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid') { - $sqlwhere[] = $key.'='.$value; - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } - - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { - $obj = $this->db->fetch_object($resql); - - $record = new self($this->db); - $record->setVarsFromFetchObj($obj); - $records[$record->id] = $record; - - $i++; - } - $this->db->free($resql); - - return $records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - - return -1; - } - } - public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') - } -} diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php deleted file mode 100644 index 8c0a23b14d7..00000000000 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php +++ /dev/null @@ -1,1344 +0,0 @@ - - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009-2014 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2019 Frédéric France - * Copyright (C) 2020 Pierre Ardoin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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/fourn/class/fournisseur.product.class.php - * \ingroup produit - * \brief File of class to manage predefined suppliers products - */ - -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - - -/** - * Class to manage predefined suppliers products - */ -class ProductFournisseur extends Product -{ - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $product_fourn_price_id; // id of ligne product-supplier - - /** - * @var int ID - */ - public $id; - - /** - * @deprecated - * @see $ref_supplier - */ - public $fourn_ref; - - public $delivery_time_days; - public $ref_supplier; // ref supplier (can be set by get_buyprice) - public $desc_supplier; - public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) - - public $product_id; - public $product_ref; - - public $fourn_id; //supplier id - public $fourn_qty; // quantity for price (can be set by get_buyprice) - public $fourn_pu; // unit price for quantity (can be set by get_buyprice) - - public $fourn_price; // price for quantity - public $fourn_remise_percent; // discount for quantity (percent) - public $fourn_remise; // discount for quantity (amount) - - public $product_fourn_id; // product-supplier id - public $product_fourn_entity; - - /** - * @var int ID user_id - user who created/updated supplier price - */ - public $user_id; - - /** - * @var int ID availability delay - visible/used if option FOURN_PRODUCT_AVAILABILITY is on (duplicate information compared to delivery delay) - */ - public $fk_availability; - - public $fourn_unitprice; - public $fourn_tva_tx; - public $fourn_tva_npr; - - /** - * @var int ID - */ - public $fk_supplier_price_expression; - - public $supplier_reputation; // reputation of supplier - public $reputations = array(); // list of available supplier reputations - - // Multicurreny - public $fourn_multicurrency_id; - public $fourn_multicurrency_code; - public $fourn_multicurrency_tx; - public $fourn_multicurrency_price; - public $fourn_multicurrency_unitprice; - - /** - * @deprecated - * @see $supplier_barcode - */ - public $fourn_barcode; - - /** - * @var string $supplier_barcode - Supplier barcode - */ - public $supplier_barcode; - - /** - * @deprecated - * @see $supplier_fk_barcode_type - */ - public $fourn_fk_barcode_type; - - /** - * @var string $supplier_fk_barcode_type - Supplier barcode type - */ - public $supplier_fk_barcode_type; - - public $packaging; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs; - - $this->db = $db; - $langs->load("suppliers"); - $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); - $this->fields = array_merge($this->fields, array( - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), - 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), - 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), - 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), - 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), - 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), - 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), - 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), - 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), - 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), - 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), - 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), - 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), - 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), - 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), - 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), - 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), - 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), - 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), - 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), - 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - )); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove all prices for this couple supplier-product - * - * @param int $id_fourn Supplier Id - * @return int < 0 if error, > 0 if ok - */ - public function remove_fournisseur($id_fourn) - { - // phpcs:enable - $ok = 1; - - $this->db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; - - dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); - $resql2 = $this->db->query($sql); - if (!$resql2) - { - $this->error = $this->db->lasterror(); - $ok = 0; - } - - if ($ok) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove a price for a couple supplier-product - * - * @param int $rowid Line id of price - * @return int <0 if KO, >0 if OK - */ - public function remove_product_fournisseur_price($rowid) - { - // phpcs:enable - global $conf, $user; - - $error = 0; - - $this->db->begin(); - - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); - if ($result < 0) $error++; - // End call triggers - - if (empty($error)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE rowid = ".$rowid; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - - if (empty($error)) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Modify the purchase price for a supplier - * - * @param float $qty Min quantity for which price is valid - * @param float $buyprice Purchase price for the quantity min - * @param User $user Object user user made changes - * @param string $price_base_type HT or TTC - * @param Societe $fourn Supplier - * @param int $availability Product availability - * @param string $ref_fourn Supplier ref - * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string) - * @param string $charges costs affering to product - * @param float $remise_percent Discount regarding qty (percent) - * @param float $remise Discount regarding qty (amount) - * @param int $newnpr Set NPR or not - * @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. - * @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). - * @param string $newdefaultvatcode Default vat code - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param string $multicurrency_price_base_type HT or TTC in currency - * @param float $multicurrency_tx Rate currency - * @param string $multicurrency_code Currency code - * @param string $desc_fourn Custom description for product_fourn_price - * @param string $barcode Barcode - * @param int $fk_barcode_type Barcode type - * @return int <0 if KO, >=0 if OK - */ - public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '') - { - // phpcs:enable - global $conf, $langs; - //global $mysoc; - - // Clean parameter - if (empty($qty)) $qty = 0; - if (empty($buyprice)) $buyprice = 0; - if (empty($charges)) $charges = 0; - if (empty($availability)) $availability = 0; - if (empty($remise_percent)) $remise_percent = 0; - if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = ''; - if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = ''; - if ($price_base_type == 'TTC') - { - $ttx = $tva_tx; - $buyprice = $buyprice / (1 + ($ttx / 100)); - } - - // Multicurrency - $multicurrency_unitBuyPrice = null; - $fk_multicurrency = null; - if (!empty($conf->multicurrency->enabled)) { - if (empty($multicurrency_tx)) $multicurrency_tx = 1; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; - if ($multicurrency_price_base_type == 'TTC') - { - $ttx = $tva_tx; - $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100)); - } - $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU'); - $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU'); - - $buyprice = $multicurrency_buyprice / $multicurrency_tx; - $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code); - } - - $buyprice = price2num($buyprice, 'MU'); - $charges = price2num($charges, 'MU'); - $qty = price2num($qty, 'MS'); - $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - - $packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS'); - - $error = 0; - $now = dol_now(); - - $newvat = $tva_tx; - - if (count($localtaxes_array) > 0) - { - $localtaxtype1 = $localtaxes_array['0']; - $localtax1 = $localtaxes_array['1']; - $localtaxtype2 = $localtaxes_array['2']; - $localtax2 = $localtaxes_array['3']; - } else { // old method. deprecated because ot can't retrieve type - $localtaxtype1 = '0'; - $localtax1 = get_localtax($newvat, 1); - $localtaxtype2 = '0'; - $localtax2 = get_localtax($newvat, 2); - } - if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 - if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 - - // Check parameters - if ($buyprice != '' && !is_numeric($buyprice)) - { - } - - $this->db->begin(); - - if ($this->product_fourn_price_id > 0) - { - // check if price already logged, if not first log current price - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id); - if (is_array($logPrices) && count($logPrices) == 0) - { - $currentPfp = new self($this->db); - $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); - if ($result > 0 && $currentPfp->fourn_price != 0) - { - $currentPfpUser = new User($this->db); - $result = $currentPfpUser->fetch($currentPfp->user_id); - if ($result > 0) { - $currentPfp->logPrice( - $currentPfpUser, - $currentPfp->date_creation, - $currentPfp->fourn_price, - $currentPfp->fourn_qty, - $currentPfp->fourn_multicurrency_price, - $currentPfp->fourn_multicurrency_unitprice, - $currentPfp->fourn_multicurrency_tx, - $currentPfp->fourn_multicurrency_id, - $currentPfp->fourn_multicurrency_code - ); - } - } - } - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_user = ".$user->id." ,"; - $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; - $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; - $sql .= " price = ".$buyprice.","; - $sql .= " quantity = ".$qty.","; - $sql .= " remise_percent = ".$remise_percent.","; - $sql .= " remise = ".$remise.","; - $sql .= " unitprice = ".$unitBuyPrice.","; - $sql .= " fk_availability = ".$availability.","; - $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " entity = ".$conf->entity.","; - $sql .= " tva_tx = ".price2num($tva_tx).","; - // TODO Add localtax1 and localtax2 - //$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; - //$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; - //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$this->db->escape($localtaxtype1)."'":"'0'").","; - //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$this->db->escape($localtaxtype2)."'":"'0'").","; - $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " info_bits = ".$newnpr.","; - $sql .= " charges = ".$charges.","; // deprecated - $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - // TODO Add price_base_type and price_ttc - - dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); - if ($result < 0) $error++; - // End call triggers - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) - { - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - if (empty($error)) - { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); - - // Delete price for this quantity - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - // Add price for this quantity to supplier - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging"; - $sql .= " values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " '".$this->db->idate($now)."',"; - $sql .= " ".$this->id.","; - $sql .= " ".$fourn->id.","; - $sql .= " '".$this->db->escape($ref_fourn)."',"; - $sql .= " '".$this->db->escape($desc_fourn)."',"; - $sql .= " ".$user->id.","; - $sql .= " ".$buyprice.","; - $sql .= " ".$qty.","; - $sql .= " ".$remise_percent.","; - $sql .= " ".$remise.","; - $sql .= " ".$unitBuyPrice.","; - $sql .= " ".$tva_tx.","; - $sql .= " ".$charges.","; - $sql .= " ".$availability.","; - $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " ".$newnpr.","; - $sql .= $conf->entity.","; - $sql .= ($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)); - $sql .= ")"; - - $this->product_fourn_price_id = 0; - - $resql = $this->db->query($sql); - if ($resql) { - $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); - } else { - $error++; - } - - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { - // Add record into log table - // $this->product_fourn_price_id must be set - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - - if (!$error) { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); - if ($result < 0) - $error++; - // End call triggers - - if (empty($error)) { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Loads the price information of a provider - * - * @param int $rowid Line id - * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead - * @return int < 0 if KO, 0 if OK but not found, > 0 if OK - */ - public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,"; - $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; - $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging,"; - $sql .= " p.ref as product_ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p"; - $sql .= " WHERE pfp.rowid = ".(int) $rowid; - $sql .= " AND pfp.fk_product = p.rowid"; - - dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj) - { - $this->product_fourn_price_id = $rowid; - $this->id = $obj->fk_product; - - $this->fk_product = $obj->fk_product; - $this->product_id = $obj->fk_product; - $this->product_ref = $obj->product_ref; - - $this->fourn_id = $obj->fk_soc; - $this->fourn_ref = $obj->ref_fourn; // deprecated - $this->ref_supplier = $obj->ref_fourn; - $this->desc_supplier = $obj->desc_fourn; - $this->fourn_price = $obj->price; - $this->fourn_charges = $obj->charges; // deprecated - $this->fourn_qty = $obj->quantity; - $this->fourn_remise_percent = $obj->remise_percent; - $this->fourn_remise = $obj->remise; - $this->fourn_unitprice = $obj->unitprice; - $this->fourn_tva_tx = $obj->tva_tx; - $this->fourn_tva_npr = $obj->fourn_tva_npr; - // Add also localtaxes - $this->fk_availability = $obj->fk_availability; - $this->delivery_time_days = $obj->delivery_time_days; - $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; - $this->supplier_reputation = $obj->supplier_reputation; - $this->default_vat_code = $obj->default_vat_code; - $this->user_id = $obj->fk_user; - $this->date_creation = $this->db->jdate($obj->datec); - $this->fourn_multicurrency_price = $obj->multicurrency_price; - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; - $this->fourn_multicurrency_id = $obj->fk_multicurrency; - $this->fourn_multicurrency_code = $obj->multicurrency_code; - if (!empty($conf->barcode->enabled)) { - $this->fourn_barcode = $obj->barcode; // deprecated - $this->fourn_fk_barcode_type = $obj->fk_barcode_type; // deprecated - $this->supplier_barcode = $obj->barcode; - $this->supplier_fk_barcode_type = $obj->fk_barcode_type; - } - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->packaging = $obj->packaging; - if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty; - } - - if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) - { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($this); - if ($price_result >= 0) { - $this->fourn_price = $price_result; - //recalculation of unitprice, as probably the price changed... - if ($this->fourn_qty != 0) - { - $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU'); - } else { - $this->fourn_unitprice = ""; - } - } - } - - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * List all supplier prices of a product - * - * @param int $prodid Id of product - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Products with new properties to define supplier price - */ - public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id, p.ref as product_ref,"; - $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; - $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; - $sql .= " AND s.status=1"; // only enabled company selected - $sql .= " AND pfp.fk_product = ".$prodid; - if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($record = $this->db->fetch_array($resql)) - { - //define base attribute - $prodfourn = new ProductFournisseur($this->db); - - $prodfourn->product_ref = $record["product_ref"]; - $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; - $prodfourn->product_fourn_id = $record["product_fourn_id"]; - $prodfourn->product_fourn_entity = $record["entity"]; - $prodfourn->ref_supplier = $record["ref_fourn"]; - $prodfourn->fourn_ref = $record["ref_fourn"]; - $prodfourn->desc_supplier = $record["desc_fourn"]; - $prodfourn->fourn_price = $record["price"]; - $prodfourn->fourn_qty = $record["quantity"]; - $prodfourn->fourn_remise_percent = $record["remise_percent"]; - $prodfourn->fourn_remise = $record["remise"]; - $prodfourn->fourn_unitprice = $record["unitprice"]; - $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_tva_tx = $record["tva_tx"]; - $prodfourn->fourn_id = $record["fourn_id"]; - $prodfourn->fourn_name = $record["supplier_name"]; - $prodfourn->fk_availability = $record["fk_availability"]; - $prodfourn->delivery_time_days = $record["delivery_time_days"]; - $prodfourn->id = $prodid; - $prodfourn->fourn_tva_npr = $record["info_bits"]; - $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $prodfourn->supplier_reputation = $record["supplier_reputation"]; - $prodfourn->fourn_date_creation = $this->db->jdate($record['datec']); - $prodfourn->fourn_date_modification = $this->db->jdate($record['tms']); - - $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"]; - $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; - $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $prodfourn->packaging = $record["packaging"]; - if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty; - } - - if (!empty($conf->barcode->enabled)) { - $prodfourn->supplier_barcode = $record["barcode"]; - $prodfourn->supplier_fk_barcode_type = $record["fk_barcode_type"]; - } - - if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prodfourn); - if ($price_result >= 0) { - $prodfourn->fourn_price = $price_result; - $prodfourn->fourn_unitprice = null; //force recalculation of unitprice, as probably the price changed... - } - } - - if (!isset($prodfourn->fourn_unitprice)) - { - if ($prodfourn->fourn_qty != 0) - { - $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU'); - } else { - $prodfourn->fourn_unitprice = ""; - } - } - - $retarray[] = $prodfourn; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load properties for minimum price - * - * @param int $prodid Product id - * @param int $qty Minimum quantity - * @param int $socid get min price for specific supplier - * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK - */ - public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) - { - // phpcs:enable - global $conf; - - if (empty($prodid)) - { - dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING); - return 0; - } - - $this->product_fourn_price_id = ''; - $this->product_fourn_id = ''; - $this->fourn_ref = ''; - $this->fourn_price = ''; - $this->fourn_qty = ''; - $this->fourn_remise_percent = ''; - $this->fourn_remise = ''; - $this->fourn_unitprice = ''; - $this->fourn_id = ''; - $this->fourn_name = ''; - $this->delivery_time_days = ''; - $this->id = ''; - - $this->fourn_multicurrency_price = ''; - $this->fourn_multicurrency_unitprice = ''; - $this->fourn_multicurrency_tx = ''; - $this->fourn_multicurrency_id = ''; - $this->fourn_multicurrency_code = ''; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; - $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; - $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE s.entity IN (".getEntity('societe').")"; - $sql .= " AND pfp.entity = ".$conf->entity; // only current entity - $sql .= " AND pfp.fk_product = ".$prodid; - $sql .= " AND pfp.fk_soc = s.rowid"; - $sql .= " AND s.status = 1"; // only enabled society - if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid; - - dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $record_array = array(); - - //Store each record to array for later search of min - while ($record = $this->db->fetch_array($resql)) - { - $record_array[] = $record; - } - - if (count($record_array) == 0) - { - $this->db->free($resql); - return 0; - } else { - $min = -1; - foreach ($record_array as $record) - { - $fourn_price = $record["price"]; - // discount calculated buy price - $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; - if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { - $prod_supplier = new ProductFournisseur($this->db); - $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; - $prod_supplier->id = $prodid; - $prod_supplier->fourn_qty = $record["quantity"]; - $prod_supplier->fourn_tva_tx = $record["tva_tx"]; - $prod_supplier->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prod_supplier); - if ($price_result >= 0) { - $fourn_price = price2num($price_result, 'MU'); - if ($record["quantity"] != 0) - { - $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU'); - } else { - $fourn_unitprice = $fourn_price; - } - } - } - if ($fourn_unitprice < $min || $min == -1) - { - $this->product_fourn_price_id = $record["product_fourn_price_id"]; - $this->ref_supplier = $record["ref_fourn"]; - $this->ref_fourn = $record["ref_fourn"]; // deprecated - $this->fourn_ref = $record["ref_fourn"]; // deprecated - $this->fourn_price = $fourn_price; - $this->fourn_qty = $record["quantity"]; - $this->fourn_remise_percent = $record["remise_percent"]; - $this->fourn_remise = $record["remise"]; - $this->fourn_unitprice = $record["unitprice"]; - $this->fourn_charges = $record["charges"]; // deprecated - $this->fourn_tva_tx = $record["tva_tx"]; - $this->fourn_id = $record["fourn_id"]; - $this->fourn_name = $record["supplier_name"]; - $this->delivery_time_days = $record["delivery_time_days"]; - $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $this->id = $prodid; - $this->fourn_multicurrency_price = $record["multicurrency_price"]; - $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $this->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $this->fourn_multicurrency_id = $record["fk_multicurrency"]; - $this->fourn_multicurrency_code = $record["multicurrency_code"]; - $min = $fourn_unitprice; - } - } - } - - $this->db->free($resql); - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Sets the supplier price expression - * - * @param int $expression_id Expression - * @return int <0 if KO, >0 if OK - */ - public function setSupplierPriceExpression($expression_id) - { - global $conf; - - // Clean parameters - $this->db->begin(); - $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; - - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_supplier_price_expression = ".$expression_id; - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - - dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - - /** - * Display supplier of product - * - * @param int $withpicto Add picto - * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @return string String with supplier price - * TODO Remove this method. Use getNomUrl directly. - */ - public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) - { - $thirdparty = new Fournisseur($this->db); - $thirdparty->fetch($this->fourn_id); - - return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display price of product - * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects - * to display in table format. - * @return string String with supplier price - */ - public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) - { - // phpcs:enable - global $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - foreach ($productFournList as $productFourn) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - } - $out .= '
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; - } else { - $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); - } - return $out; - } - - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'product_fournisseur_price' - ); - - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } - - /** - * List supplier prices log of a supplier price - * - * @param int $product_fourn_price_id Id of supplier price - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Log prices - */ - public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - $sql = "SELECT"; - $sql .= " u.lastname,"; - $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec,"; - $sql .= " pfpl.price, pfpl.quantity,"; - $sql .= " pfpl.fk_multicurrency, pfpl.multicurrency_code, pfpl.multicurrency_tx, pfpl.multicurrency_price, pfpl.multicurrency_unitprice"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl,"; - $sql .= " ".MAIN_DB_PREFIX."product_fournisseur_price as pfp,"; - $sql .= " ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")"; - $sql .= " AND pfpl.fk_user = u.rowid"; - $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; - $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($obj = $this->db->fetch_object($resql)) - { - $tmparray = array(); - $tmparray['rowid'] = $obj->rowid; - $tmparray['supplier_ref'] = $obj->supplier_ref; - $tmparray['datec'] = $this->db->jdate($obj->datec); - $tmparray['lastname'] = $obj->lastname; - $tmparray['price'] = $obj->price; - $tmparray['quantity'] = $obj->quantity; - $tmparray['fk_multicurrency'] = $obj->fk_multicurrency; - $tmparray['multicurrency_code'] = $obj->multicurrency_code; - $tmparray['multicurrency_tx'] = $obj->multicurrency_tx; - $tmparray['multicurrency_price'] = $obj->multicurrency_price; - $tmparray['multicurrency_unitprice'] = $obj->multicurrency_unitprice; - - $retarray[] = $tmparray; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Display log price of product supplier price - * - * @param array $productFournLogList list of ProductFournisseur price log objects - * to display in table format. - * @return string HTML String with supplier price - */ - public function displayPriceProductFournisseurLog($productFournLogList = array()) - { - global $conf, $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournLogList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - //$out .= ''; - $out .= ''; - foreach ($productFournLogList as $productFournLog) { - $out .= ''; - $out .= ''; - //$out.= ''; - $out .= ''; - } - $out .= '
'.$langs->trans("Date").''.$langs->trans("Price").''.$langs->trans("QtyMin").''.$langs->trans("User").'
'.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').''.price($productFournLog['price'], 0, $langs, 1, -1, -1, $conf->currency); - if ($productFournLog['multicurrency_code'] != $conf->currency) { - $out .= ' ('.price($productFournLog['multicurrency_price'], 0, $langs, 1, -1, -1, $productFournLog['multicurrency_code']).')'; - } - $out .= ''.$productFournLog['quantity'].''.$productFournLog['lastname'].'
'; - } - return $out; - } - - - /** - * Return a link to the object card (with optionaly the picto). - * Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl(). - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs; - - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - - $result = ''; - - if (!empty($this->entity)) { - $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); - if ($this->nbphoto > 0) { - $label .= '
'; - $label .= $tmpphoto; - $label .= '
'; - } - } - - if ($this->type == Product::TYPE_PRODUCT) { - $label .= img_picto('', 'product').' '.$langs->trans("Product").''; - } elseif ($this->type == Product::TYPE_SERVICE) { - $label .= img_picto('', 'service').' '.$langs->trans("Service").''; - } - if (isset($this->status) && isset($this->status_buy)) { - $label .= ' '.$this->getLibStatut(5, 0); - $label .= ' '.$this->getLibStatut(5, 1); - } - - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('ProductRef').': '.($this->ref ? $this->ref : $this->product_ref); - } - if (!empty($this->label)) { - $label .= '
'.$langs->trans('ProductLabel').': '.$this->label; - } - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - - if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (!empty($conf->productbatch->enabled)) { - $langs->load("productbatch"); - $label .= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); - } - } - if (!empty($conf->barcode->enabled)) { - $label .= '
'.$langs->trans('BarCode').': '.$this->barcode; - } - - if ($this->type == Product::TYPE_PRODUCT) - { - if ($this->weight) { - $label .= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); - } - $labelsize = ""; - if ($this->length) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); - } - if ($this->width) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); - } - if ($this->height) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); - } - if ($labelsize) $label .= "
".$labelsize; - - $labelsurfacevolume = ""; - if ($this->surface) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); - } - if ($this->volume) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); - } - if ($labelsurfacevolume) $label .= "
".$labelsurfacevolume; - } - - if (!empty($conf->accounting->enabled) && $this->status) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); - $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); - $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); - } - if (!empty($conf->accounting->enabled) && $this->status_buy) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); - $label .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); - $label .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); - } - - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here - if (is_array($logPrices) && count($logPrices) > 0) { - $label .= '

'; - $label .= ''.$langs->trans("History").''; - $label .= $this->displayPriceProductFournisseurLog($logPrices); - } - - $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; - - 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'; - } - - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("SupplierRef"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - - $linkstart = ''; - $linkend = ''; - - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - - return $result; - } - - /** - * Private function to log price history - * - * @param User $user Object user who adds/changes price - * @param integer $datec date create - * @param float $buyprice price for qty - * @param float $qty qty for price - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param float $multicurrency_unitBuyPrice Unit Purchase price in currency - * @param float $multicurrency_tx Rate currency - * @param int $fk_multicurrency key multi currency - * @param string $multicurrency_code Currency code - * - * @return int < 0 NOK > 0 OK - */ - private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null) - { - // Add record into log table - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; - $sql .= "values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= "'".$this->db->idate($datec)."',"; - $sql .= " ".$this->product_fourn_price_id.","; - $sql .= " ".$user->id.","; - $sql .= " ".price2num($buyprice).","; - $sql .= " ".$qty; - $sql .= ")"; - - $resql = $this->db->query($sql); - if (!$resql) { - return -1; - } else { - return 1; - } - } - - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $records = array(); - - $sql = 'SELECT '; - $sql .= $this->getFieldList(); - $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as t'; - $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid') { - $sqlwhere[] = $key.'='.$value; - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } - - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { - $obj = $this->db->fetch_object($resql); - - $record = new self($this->db); - $record->setVarsFromFetchObj($obj); - $records[$record->id] = $record; - - $i++; - } - $this->db->free($resql); - - return $records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - - return -1; - } - } - public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') - } -} diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php deleted file mode 100644 index 885ce24f01f..00000000000 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php +++ /dev/null @@ -1,1344 +0,0 @@ - - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009-2014 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2019 Frédéric France - * Copyright (C) 2020 Pierre Ardoin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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/fourn/class/fournisseur.product.class.php - * \ingroup produit - * \brief File of class to manage predefined suppliers products - */ - -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - - -/** - * Class to manage predefined suppliers products - */ -class ProductFournisseur extends Product -{ - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $product_fourn_price_id; // id of ligne product-supplier - - /** - * @var int ID - */ - public $id; - - /** - * @deprecated - * @see $ref_supplier - */ - public $fourn_ref; - - public $delivery_time_days; - public $ref_supplier; // ref supplier (can be set by get_buyprice) - public $desc_supplier; - public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) - - public $product_id; - public $product_ref; - - public $fourn_id; //supplier id - public $fourn_qty; // quantity for price (can be set by get_buyprice) - public $fourn_pu; // unit price for quantity (can be set by get_buyprice) - - public $fourn_price; // price for quantity - public $fourn_remise_percent; // discount for quantity (percent) - public $fourn_remise; // discount for quantity (amount) - - public $product_fourn_id; // product-supplier id - public $product_fourn_entity; - - /** - * @var int ID user_id - user who created/updated supplier price - */ - public $user_id; - - /** - * @var int ID availability delay - visible/used if option FOURN_PRODUCT_AVAILABILITY is on (duplicate information compared to delivery delay) - */ - public $fk_availability; - - public $fourn_unitprice; - public $fourn_tva_tx; - public $fourn_tva_npr; - - /** - * @var int ID - */ - public $fk_supplier_price_expression; - - public $supplier_reputation; // reputation of supplier - public $reputations = array(); // list of available supplier reputations - - // Multicurreny - public $fourn_multicurrency_id; - public $fourn_multicurrency_code; - public $fourn_multicurrency_tx; - public $fourn_multicurrency_price; - public $fourn_multicurrency_unitprice; - - /** - * @deprecated - * @see $supplier_barcode - */ - public $fourn_barcode; - - /** - * @var string $supplier_barcode - Supplier barcode - */ - public $supplier_barcode; - - /** - * @deprecated - * @see $supplier_fk_barcode_type - */ - public $fourn_fk_barcode_type; - - /** - * @var string $supplier_fk_barcode_type - Supplier barcode type - */ - public $supplier_fk_barcode_type; - - public $packaging; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs; - - $this->db = $db; - $langs->load("suppliers"); - $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); - $this->fields = array_merge($this->fields, array( - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), - 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), - 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), - 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), - 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), - 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), - 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), - 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), - 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), - 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), - 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), - 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), - 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), - 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), - 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), - 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), - 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), - 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), - 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), - 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), - 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - )); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove all prices for this couple supplier-product - * - * @param int $id_fourn Supplier Id - * @return int < 0 if error, > 0 if ok - */ - public function remove_fournisseur($id_fourn) - { - // phpcs:enable - $ok = 1; - - $this->db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; - - dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); - $resql2 = $this->db->query($sql); - if (!$resql2) - { - $this->error = $this->db->lasterror(); - $ok = 0; - } - - if ($ok) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove a price for a couple supplier-product - * - * @param int $rowid Line id of price - * @return int <0 if KO, >0 if OK - */ - public function remove_product_fournisseur_price($rowid) - { - // phpcs:enable - global $conf, $user; - - $error = 0; - - $this->db->begin(); - - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); - if ($result < 0) $error++; - // End call triggers - - if (empty($error)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE rowid = ".$rowid; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - - if (empty($error)) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Modify the purchase price for a supplier - * - * @param float $qty Min quantity for which price is valid - * @param float $buyprice Purchase price for the quantity min - * @param User $user Object user user made changes - * @param string $price_base_type HT or TTC - * @param Societe $fourn Supplier - * @param int $availability Product availability - * @param string $ref_fourn Supplier ref - * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string) - * @param string $charges costs affering to product - * @param float $remise_percent Discount regarding qty (percent) - * @param float $remise Discount regarding qty (amount) - * @param int $newnpr Set NPR or not - * @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. - * @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). - * @param string $newdefaultvatcode Default vat code - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param string $multicurrency_price_base_type HT or TTC in currency - * @param float $multicurrency_tx Rate currency - * @param string $multicurrency_code Currency code - * @param string $desc_fourn Custom description for product_fourn_price - * @param string $barcode Barcode - * @param int $fk_barcode_type Barcode type - * @return int <0 if KO, >=0 if OK - */ - public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '') - { - // phpcs:enable - global $conf, $langs; - //global $mysoc; - - // Clean parameter - if (empty($qty)) $qty = 0; - if (empty($buyprice)) $buyprice = 0; - if (empty($charges)) $charges = 0; - if (empty($availability)) $availability = 0; - if (empty($remise_percent)) $remise_percent = 0; - if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = ''; - if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = ''; - if ($price_base_type == 'TTC') - { - $ttx = $tva_tx; - $buyprice = $buyprice / (1 + ($ttx / 100)); - } - - // Multicurrency - $multicurrency_unitBuyPrice = null; - $fk_multicurrency = null; - if (!empty($conf->multicurrency->enabled)) { - if (empty($multicurrency_tx)) $multicurrency_tx = 1; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; - if ($multicurrency_price_base_type == 'TTC') - { - $ttx = $tva_tx; - $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100)); - } - $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU'); - $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU'); - - $buyprice = $multicurrency_buyprice / $multicurrency_tx; - $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code); - } - - $buyprice = price2num($buyprice, 'MU'); - $charges = price2num($charges, 'MU'); - $qty = price2num($qty, 'MS'); - $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - - $packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS'); - - $error = 0; - $now = dol_now(); - - $newvat = $tva_tx; - - if (count($localtaxes_array) > 0) - { - $localtaxtype1 = $localtaxes_array['0']; - $localtax1 = $localtaxes_array['1']; - $localtaxtype2 = $localtaxes_array['2']; - $localtax2 = $localtaxes_array['3']; - } else { // old method. deprecated because ot can't retrieve type - $localtaxtype1 = '0'; - $localtax1 = get_localtax($newvat, 1); - $localtaxtype2 = '0'; - $localtax2 = get_localtax($newvat, 2); - } - if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 - if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 - - // Check parameters - if ($buyprice != '' && !is_numeric($buyprice)) - { - } - - $this->db->begin(); - - if ($this->product_fourn_price_id > 0) - { - // check if price already logged, if not first log current price - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id); - if (is_array($logPrices) && count($logPrices) == 0) - { - $currentPfp = new self($this->db); - $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); - if ($result > 0 && $currentPfp->fourn_price != 0) - { - $currentPfpUser = new User($this->db); - $result = $currentPfpUser->fetch($currentPfp->user_id); - if ($result > 0) { - $currentPfp->logPrice( - $currentPfpUser, - $currentPfp->date_creation, - $currentPfp->fourn_price, - $currentPfp->fourn_qty, - $currentPfp->fourn_multicurrency_price, - $currentPfp->fourn_multicurrency_unitprice, - $currentPfp->fourn_multicurrency_tx, - $currentPfp->fourn_multicurrency_id, - $currentPfp->fourn_multicurrency_code - ); - } - } - } - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_user = ".$user->id." ,"; - $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; - $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; - $sql .= " price = ".$buyprice.","; - $sql .= " quantity = ".$qty.","; - $sql .= " remise_percent = ".$remise_percent.","; - $sql .= " remise = ".$remise.","; - $sql .= " unitprice = ".$unitBuyPrice.","; - $sql .= " fk_availability = ".$availability.","; - $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " entity = ".$conf->entity.","; - $sql .= " tva_tx = ".price2num($tva_tx).","; - // TODO Add localtax1 and localtax2 - //$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; - //$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; - //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$this->db->escape($localtaxtype1)."'":"'0'").","; - //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$this->db->escape($localtaxtype2)."'":"'0'").","; - $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " info_bits = ".$newnpr.","; - $sql .= " charges = ".$charges.","; // deprecated - $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - // TODO Add price_base_type and price_ttc - - dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); - if ($result < 0) $error++; - // End call triggers - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) - { - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - if (empty($error)) - { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); - - // Delete price for this quantity - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - // Add price for this quantity to supplier - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging"; - $sql .= " values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " '".$this->db->idate($now)."',"; - $sql .= " ".$this->id.","; - $sql .= " ".$fourn->id.","; - $sql .= " '".$this->db->escape($ref_fourn)."',"; - $sql .= " '".$this->db->escape($desc_fourn)."',"; - $sql .= " ".$user->id.","; - $sql .= " ".$buyprice.","; - $sql .= " ".$qty.","; - $sql .= " ".$remise_percent.","; - $sql .= " ".$remise.","; - $sql .= " ".$unitBuyPrice.","; - $sql .= " ".$tva_tx.","; - $sql .= " ".$charges.","; - $sql .= " ".$availability.","; - $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " ".$newnpr.","; - $sql .= $conf->entity.","; - $sql .= ($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)); - $sql .= ")"; - - $this->product_fourn_price_id = 0; - - $resql = $this->db->query($sql); - if ($resql) { - $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); - } else { - $error++; - } - - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { - // Add record into log table - // $this->product_fourn_price_id must be set - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - - if (!$error) { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); - if ($result < 0) - $error++; - // End call triggers - - if (empty($error)) { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Loads the price information of a provider - * - * @param int $rowid Line id - * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead - * @return int < 0 if KO, 0 if OK but not found, > 0 if OK - */ - public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,"; - $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; - $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging,"; - $sql .= " p.ref as product_ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p"; - $sql .= " WHERE pfp.rowid = ".(int) $rowid; - $sql .= " AND pfp.fk_product = p.rowid"; - - dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj) - { - $this->product_fourn_price_id = $rowid; - $this->id = $obj->fk_product; - - $this->fk_product = $obj->fk_product; - $this->product_id = $obj->fk_product; - $this->product_ref = $obj->product_ref; - - $this->fourn_id = $obj->fk_soc; - $this->fourn_ref = $obj->ref_fourn; // deprecated - $this->ref_supplier = $obj->ref_fourn; - $this->desc_supplier = $obj->desc_fourn; - $this->fourn_price = $obj->price; - $this->fourn_charges = $obj->charges; // deprecated - $this->fourn_qty = $obj->quantity; - $this->fourn_remise_percent = $obj->remise_percent; - $this->fourn_remise = $obj->remise; - $this->fourn_unitprice = $obj->unitprice; - $this->fourn_tva_tx = $obj->tva_tx; - $this->fourn_tva_npr = $obj->fourn_tva_npr; - // Add also localtaxes - $this->fk_availability = $obj->fk_availability; - $this->delivery_time_days = $obj->delivery_time_days; - $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; - $this->supplier_reputation = $obj->supplier_reputation; - $this->default_vat_code = $obj->default_vat_code; - $this->user_id = $obj->fk_user; - $this->date_creation = $this->db->jdate($obj->datec); - $this->fourn_multicurrency_price = $obj->multicurrency_price; - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; - $this->fourn_multicurrency_id = $obj->fk_multicurrency; - $this->fourn_multicurrency_code = $obj->multicurrency_code; - if (!empty($conf->barcode->enabled)) { - $this->fourn_barcode = $obj->barcode; // deprecated - $this->fourn_fk_barcode_type = $obj->fk_barcode_type; // deprecated - $this->supplier_barcode = $obj->barcode; - $this->supplier_fk_barcode_type = $obj->fk_barcode_type; - } - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->packaging = $obj->packaging; - if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty; - } - - if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) - { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($this); - if ($price_result >= 0) { - $this->fourn_price = $price_result; - //recalculation of unitprice, as probably the price changed... - if ($this->fourn_qty != 0) - { - $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU'); - } else { - $this->fourn_unitprice = ""; - } - } - } - - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * List all supplier prices of a product - * - * @param int $prodid Id of product - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Products with new properties to define supplier price - */ - public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id, p.ref as product_ref,"; - $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; - $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; - $sql .= " AND s.status=1"; // only enabled company selected - $sql .= " AND pfp.fk_product = ".$prodid; - if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($record = $this->db->fetch_array($resql)) - { - //define base attribute - $prodfourn = new ProductFournisseur($this->db); - - $prodfourn->product_ref = $record["product_ref"]; - $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; - $prodfourn->product_fourn_id = $record["product_fourn_id"]; - $prodfourn->product_fourn_entity = $record["entity"]; - $prodfourn->ref_supplier = $record["ref_fourn"]; - $prodfourn->fourn_ref = $record["ref_fourn"]; - $prodfourn->desc_supplier = $record["desc_fourn"]; - $prodfourn->fourn_price = $record["price"]; - $prodfourn->fourn_qty = $record["quantity"]; - $prodfourn->fourn_remise_percent = $record["remise_percent"]; - $prodfourn->fourn_remise = $record["remise"]; - $prodfourn->fourn_unitprice = $record["unitprice"]; - $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_tva_tx = $record["tva_tx"]; - $prodfourn->fourn_id = $record["fourn_id"]; - $prodfourn->fourn_name = $record["supplier_name"]; - $prodfourn->fk_availability = $record["fk_availability"]; - $prodfourn->delivery_time_days = $record["delivery_time_days"]; - $prodfourn->id = $prodid; - $prodfourn->fourn_tva_npr = $record["info_bits"]; - $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $prodfourn->supplier_reputation = $record["supplier_reputation"]; - $prodfourn->fourn_date_creation = $this->db->jdate($record['datec']); - $prodfourn->fourn_date_modification = $this->db->jdate($record['tms']); - - $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"]; - $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; - $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $prodfourn->packaging = $record["packaging"]; - if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty; - } - - if (!empty($conf->barcode->enabled)) { - $prodfourn->supplier_barcode = $record["barcode"]; - $prodfourn->supplier_fk_barcode_type = $record["fk_barcode_type"]; - } - - if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prodfourn); - if ($price_result >= 0) { - $prodfourn->fourn_price = $price_result; - $prodfourn->fourn_unitprice = null; //force recalculation of unitprice, as probably the price changed... - } - } - - if (!isset($prodfourn->fourn_unitprice)) - { - if ($prodfourn->fourn_qty != 0) - { - $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU'); - } else { - $prodfourn->fourn_unitprice = ""; - } - } - - $retarray[] = $prodfourn; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load properties for minimum price - * - * @param int $prodid Product id - * @param int $qty Minimum quantity - * @param int $socid get min price for specific supplier - * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK - */ - public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) - { - // phpcs:enable - global $conf; - - if (empty($prodid)) - { - dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING); - return 0; - } - - $this->product_fourn_price_id = ''; - $this->product_fourn_id = ''; - $this->fourn_ref = ''; - $this->fourn_price = ''; - $this->fourn_qty = ''; - $this->fourn_remise_percent = ''; - $this->fourn_remise = ''; - $this->fourn_unitprice = ''; - $this->fourn_id = ''; - $this->fourn_name = ''; - $this->delivery_time_days = ''; - $this->id = ''; - - $this->fourn_multicurrency_price = ''; - $this->fourn_multicurrency_unitprice = ''; - $this->fourn_multicurrency_tx = ''; - $this->fourn_multicurrency_id = ''; - $this->fourn_multicurrency_code = ''; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; - $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; - $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE s.entity IN (".getEntity('societe').")"; - $sql .= " AND pfp.entity = ".$conf->entity; // only current entity - $sql .= " AND pfp.fk_product = ".$prodid; - $sql .= " AND pfp.fk_soc = s.rowid"; - $sql .= " AND s.status = 1"; // only enabled society - if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid; - - dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $record_array = array(); - - //Store each record to array for later search of min - while ($record = $this->db->fetch_array($resql)) - { - $record_array[] = $record; - } - - if (count($record_array) == 0) - { - $this->db->free($resql); - return 0; - } else { - $min = -1; - foreach ($record_array as $record) - { - $fourn_price = $record["price"]; - // discount calculated buy price - $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; - if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { - $prod_supplier = new ProductFournisseur($this->db); - $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; - $prod_supplier->id = $prodid; - $prod_supplier->fourn_qty = $record["quantity"]; - $prod_supplier->fourn_tva_tx = $record["tva_tx"]; - $prod_supplier->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prod_supplier); - if ($price_result >= 0) { - $fourn_price = price2num($price_result, 'MU'); - if ($record["quantity"] != 0) - { - $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU'); - } else { - $fourn_unitprice = $fourn_price; - } - } - } - if ($fourn_unitprice < $min || $min == -1) - { - $this->product_fourn_price_id = $record["product_fourn_price_id"]; - $this->ref_supplier = $record["ref_fourn"]; - $this->ref_fourn = $record["ref_fourn"]; // deprecated - $this->fourn_ref = $record["ref_fourn"]; // deprecated - $this->fourn_price = $fourn_price; - $this->fourn_qty = $record["quantity"]; - $this->fourn_remise_percent = $record["remise_percent"]; - $this->fourn_remise = $record["remise"]; - $this->fourn_unitprice = $record["unitprice"]; - $this->fourn_charges = $record["charges"]; // deprecated - $this->fourn_tva_tx = $record["tva_tx"]; - $this->fourn_id = $record["fourn_id"]; - $this->fourn_name = $record["supplier_name"]; - $this->delivery_time_days = $record["delivery_time_days"]; - $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $this->id = $prodid; - $this->fourn_multicurrency_price = $record["multicurrency_price"]; - $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $this->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $this->fourn_multicurrency_id = $record["fk_multicurrency"]; - $this->fourn_multicurrency_code = $record["multicurrency_code"]; - $min = $fourn_unitprice; - } - } - } - - $this->db->free($resql); - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Sets the supplier price expression - * - * @param int $expression_id Expression - * @return int <0 if KO, >0 if OK - */ - public function setSupplierPriceExpression($expression_id) - { - global $conf; - - // Clean parameters - $this->db->begin(); - $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; - - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_supplier_price_expression = ".$expression_id; - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - - dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - - /** - * Display supplier of product - * - * @param int $withpicto Add picto - * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @return string String with supplier price - * TODO Remove this method. Use getNomUrl directly. - */ - public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) - { - $thirdparty = new Fournisseur($this->db); - $thirdparty->fetch($this->fourn_id); - - return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display price of product - * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects - * to display in table format. - * @return string String with supplier price - */ - public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) - { - // phpcs:enable - global $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - foreach ($productFournList as $productFourn) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - } - $out .= '
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; - } else { - $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); - } - return $out; - } - - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'product_fournisseur_price' - ); - - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } - - /** - * List supplier prices log of a supplier price - * - * @param int $product_fourn_price_id Id of supplier price - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Log prices - */ - public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - $sql = "SELECT"; - $sql .= " u.lastname,"; - $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec,"; - $sql .= " pfpl.price, pfpl.quantity,"; - $sql .= " pfpl.fk_multicurrency, pfpl.multicurrency_code, pfpl.multicurrency_tx, pfpl.multicurrency_price, pfpl.multicurrency_unitprice"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl,"; - $sql .= " ".MAIN_DB_PREFIX."product_fournisseur_price as pfp,"; - $sql .= " ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")"; - $sql .= " AND pfpl.fk_user = u.rowid"; - $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; - $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($obj = $this->db->fetch_object($resql)) - { - $tmparray = array(); - $tmparray['rowid'] = $obj->rowid; - $tmparray['supplier_ref'] = $obj->supplier_ref; - $tmparray['datec'] = $this->db->jdate($obj->datec); - $tmparray['lastname'] = $obj->lastname; - $tmparray['price'] = $obj->price; - $tmparray['quantity'] = $obj->quantity; - $tmparray['fk_multicurrency'] = $obj->fk_multicurrency; - $tmparray['multicurrency_code'] = $obj->multicurrency_code; - $tmparray['multicurrency_tx'] = $obj->multicurrency_tx; - $tmparray['multicurrency_price'] = $obj->multicurrency_price; - $tmparray['multicurrency_unitprice'] = $obj->multicurrency_unitprice; - - $retarray[] = $tmparray; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Display log price of product supplier price - * - * @param array $productFournLogList list of ProductFournisseur price log objects - * to display in table format. - * @return string HTML String with supplier price - */ - public function displayPriceProductFournisseurLog($productFournLogList = array()) - { - global $conf, $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournLogList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - //$out .= ''; - $out .= ''; - foreach ($productFournLogList as $productFournLog) { - $out .= ''; - $out .= ''; - //$out.= ''; - $out .= ''; - } - $out .= '
'.$langs->trans("Date").''.$langs->trans("Price").''.$langs->trans("QtyMin").''.$langs->trans("User").'
'.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').''.price($productFournLog['price'], 0, $langs, 1, -1, -1, $conf->currency); - if ($productFournLog['multicurrency_code'] != $conf->currency) { - $out .= ' ('.price($productFournLog['multicurrency_price'], 0, $langs, 1, -1, -1, $productFournLog['multicurrency_code']).')'; - } - $out .= ''.$productFournLog['quantity'].''.$productFournLog['lastname'].'
'; - } - return $out; - } - - - /** - * Return a link to the object card (with optionaly the picto). - * Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl(). - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs; - - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - - $result = ''; - - if (!empty($this->entity)) { - $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); - if ($this->nbphoto > 0) { - $label .= '
'; - $label .= $tmpphoto; - $label .= '
'; - } - } - - if ($this->type == Product::TYPE_PRODUCT) { - $label .= img_picto('', 'product').' '.$langs->trans("Product").''; - } elseif ($this->type == Product::TYPE_SERVICE) { - $label .= img_picto('', 'service').' '.$langs->trans("Service").''; - } - if (isset($this->status) && isset($this->status_buy)) { - $label .= ' '.$this->getLibStatut(5, 0); - $label .= ' '.$this->getLibStatut(5, 1); - } - - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('ProductRef').': '.($this->ref ? $this->ref : $this->product_ref); - } - if (!empty($this->label)) { - $label .= '
'.$langs->trans('ProductLabel').': '.$this->label; - } - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - - if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (!empty($conf->productbatch->enabled)) { - $langs->load("productbatch"); - $label .= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); - } - } - if (!empty($conf->barcode->enabled)) { - $label .= '
'.$langs->trans('BarCode').': '.$this->barcode; - } - - if ($this->type == Product::TYPE_PRODUCT) - { - if ($this->weight) { - $label .= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); - } - $labelsize = ""; - if ($this->length) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); - } - if ($this->width) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); - } - if ($this->height) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); - } - if ($labelsize) $label .= "
".$labelsize; - - $labelsurfacevolume = ""; - if ($this->surface) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); - } - if ($this->volume) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); - } - if ($labelsurfacevolume) $label .= "
".$labelsurfacevolume; - } - - if (!empty($conf->accounting->enabled) && $this->status) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); - $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); - $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); - } - if (!empty($conf->accounting->enabled) && $this->status_buy) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); - $label .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); - $label .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); - } - - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here - if (is_array($logPrices) && count($logPrices) > 0) { - $label .= '

'; - $label .= ''.$langs->trans("History").''; - $label .= $this->displayPriceProductFournisseurLog($logPrices); - } - - $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; - - 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'; - } - - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("SupplierRef"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - - $linkstart = ''; - $linkend = ''; - - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - - return $result; - } - - /** - * Private function to log price history - * - * @param User $user Object user who adds/changes price - * @param integer $datec date create - * @param float $buyprice price for qty - * @param float $qty qty for price - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param float $multicurrency_unitBuyPrice Unit Purchase price in currency - * @param float $multicurrency_tx Rate currency - * @param int $fk_multicurrency key multi currency - * @param string $multicurrency_code Currency code - * - * @return int < 0 NOK > 0 OK - */ - private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null) - { - // Add record into log table - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; - $sql .= "values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= "'".$this->db->idate($datec)."',"; - $sql .= " ".$this->product_fourn_price_id.","; - $sql .= " ".$user->id.","; - $sql .= " ".price2num($buyprice).","; - $sql .= " ".$qty; - $sql .= ")"; - - $resql = $this->db->query($sql); - if (!$resql) { - return -1; - } else { - return 1; - } - } - - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $records = array(); - - $sql = 'SELECT '; - $sql .= $this->getFieldList(); - $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as t'; - $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid') { - $sqlwhere[] = $key.'='.$value; - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } - - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { - $obj = $this->db->fetch_object($resql); - - $record = new self($this->db); - $record->setVarsFromFetchObj($obj); - $records[$record->id] = $record; - - $i++; - } - $this->db->free($resql); - - return $records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - - return -1; - } - } - public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); - } -} diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php deleted file mode 100644 index 371a5581c55..00000000000 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php +++ /dev/null @@ -1,1354 +0,0 @@ - - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009-2014 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2019-2021 Frédéric France - * Copyright (C) 2020 Pierre Ardoin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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/fourn/class/fournisseur.product.class.php - * \ingroup produit - * \brief File of class to manage predefined suppliers products - */ - -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - - -/** - * Class to manage predefined suppliers products - */ -class ProductFournisseur extends Product -{ - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $product_fourn_price_id; // id of ligne product-supplier - - /** - * @var int ID - */ - public $id; - - /** - * @deprecated - * @see $ref_supplier - */ - public $fourn_ref; - - public $delivery_time_days; - public $ref_supplier; // ref supplier (can be set by get_buyprice) - public $desc_supplier; - public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) - - public $product_id; - public $product_ref; - - public $fourn_id; //supplier id - public $fourn_qty; // quantity for price (can be set by get_buyprice) - public $fourn_pu; // unit price for quantity (can be set by get_buyprice) - - public $fourn_price; // price for quantity - public $fourn_remise_percent; // discount for quantity (percent) - public $fourn_remise; // discount for quantity (amount) - - public $product_fourn_id; // product-supplier id - public $product_fourn_entity; - - /** - * @var int ID user_id - user who created/updated supplier price - */ - public $user_id; - - /** - * @var int ID availability delay - visible/used if option FOURN_PRODUCT_AVAILABILITY is on (duplicate information compared to delivery delay) - */ - public $fk_availability; - - public $fourn_unitprice; - public $fourn_tva_tx; - public $fourn_tva_npr; - - /** - * @var int ID - */ - public $fk_supplier_price_expression; - - public $supplier_reputation; // reputation of supplier - public $reputations = array(); // list of available supplier reputations - - // Multicurreny - public $fourn_multicurrency_id; - public $fourn_multicurrency_code; - public $fourn_multicurrency_tx; - public $fourn_multicurrency_price; - public $fourn_multicurrency_unitprice; - - /** - * @deprecated - * @see $supplier_barcode - */ - public $fourn_barcode; - - /** - * @var string $supplier_barcode - Supplier barcode - */ - public $supplier_barcode; - - /** - * @deprecated - * @see $supplier_fk_barcode_type - */ - public $fourn_fk_barcode_type; - - /** - * @var string $supplier_fk_barcode_type - Supplier barcode type - */ - public $supplier_fk_barcode_type; - - public $packaging; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs; - - $this->db = $db; - $langs->load("suppliers"); - $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); - $this->fields = array_merge($this->fields, array( - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), - 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), - 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), - 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), - 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), - 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), - 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), - 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), - 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), - 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), - 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), - 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), - 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), - 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), - 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), - 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), - 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), - 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), - 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), - 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), - 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - )); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove all prices for this couple supplier-product - * - * @param int $id_fourn Supplier Id - * @return int < 0 if error, > 0 if ok - */ - public function remove_fournisseur($id_fourn) - { - // phpcs:enable - $ok = 1; - - $this->db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; - - dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); - $resql2 = $this->db->query($sql); - if (!$resql2) - { - $this->error = $this->db->lasterror(); - $ok = 0; - } - - if ($ok) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove a price for a couple supplier-product - * - * @param int $rowid Line id of price - * @return int <0 if KO, >0 if OK - */ - public function remove_product_fournisseur_price($rowid) - { - // phpcs:enable - global $conf, $user; - - $error = 0; - - $this->db->begin(); - - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); - if ($result < 0) $error++; - // End call triggers - - if (empty($error)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE rowid = ".$rowid; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - - if (empty($error)) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Modify the purchase price for a supplier - * - * @param float $qty Min quantity for which price is valid - * @param float $buyprice Purchase price for the quantity min - * @param User $user Object user user made changes - * @param string $price_base_type HT or TTC - * @param Societe $fourn Supplier - * @param int $availability Product availability - * @param string $ref_fourn Supplier ref - * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string) - * @param string $charges costs affering to product - * @param float $remise_percent Discount regarding qty (percent) - * @param float $remise Discount regarding qty (amount) - * @param int $newnpr Set NPR or not - * @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. - * @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). - * @param string $newdefaultvatcode Default vat code - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param string $multicurrency_price_base_type HT or TTC in currency - * @param float $multicurrency_tx Rate currency - * @param string $multicurrency_code Currency code - * @param string $desc_fourn Custom description for product_fourn_price - * @param string $barcode Barcode - * @param int $fk_barcode_type Barcode type - * @return int <0 if KO, >=0 if OK - */ - public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '') - { - // phpcs:enable - global $conf, $langs; - //global $mysoc; - - // Clean parameter - if (empty($qty)) $qty = 0; - if (empty($buyprice)) $buyprice = 0; - if (empty($charges)) $charges = 0; - if (empty($availability)) $availability = 0; - if (empty($remise_percent)) $remise_percent = 0; - if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = ''; - if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = ''; - if ($price_base_type == 'TTC') - { - $ttx = $tva_tx; - $buyprice = $buyprice / (1 + ($ttx / 100)); - } - - // Multicurrency - $multicurrency_unitBuyPrice = null; - $fk_multicurrency = null; - if (!empty($conf->multicurrency->enabled)) { - if (empty($multicurrency_tx)) $multicurrency_tx = 1; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; - if ($multicurrency_price_base_type == 'TTC') - { - $ttx = $tva_tx; - $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100)); - } - $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU'); - $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU'); - - $buyprice = $multicurrency_buyprice / $multicurrency_tx; - $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code); - } - - $buyprice = price2num($buyprice, 'MU'); - $charges = price2num($charges, 'MU'); - $qty = price2num($qty, 'MS'); - $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - - $packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS'); - - $error = 0; - $now = dol_now(); - - $newvat = $tva_tx; - - if (count($localtaxes_array) > 0) - { - $localtaxtype1 = $localtaxes_array['0']; - $localtax1 = $localtaxes_array['1']; - $localtaxtype2 = $localtaxes_array['2']; - $localtax2 = $localtaxes_array['3']; - } else { // old method. deprecated because ot can't retrieve type - $localtaxtype1 = '0'; - $localtax1 = get_localtax($newvat, 1); - $localtaxtype2 = '0'; - $localtax2 = get_localtax($newvat, 2); - } - if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 - if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 - - // Check parameters - if ($buyprice != '' && !is_numeric($buyprice)) - { - } - - $this->db->begin(); - - if ($this->product_fourn_price_id > 0) - { - // check if price already logged, if not first log current price - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id); - if (is_array($logPrices) && count($logPrices) == 0) - { - $currentPfp = new self($this->db); - $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); - if ($result > 0 && $currentPfp->fourn_price != 0) - { - $currentPfpUser = new User($this->db); - $result = $currentPfpUser->fetch($currentPfp->user_id); - if ($result > 0) { - $currentPfp->logPrice( - $currentPfpUser, - $currentPfp->date_creation, - $currentPfp->fourn_price, - $currentPfp->fourn_qty, - $currentPfp->fourn_multicurrency_price, - $currentPfp->fourn_multicurrency_unitprice, - $currentPfp->fourn_multicurrency_tx, - $currentPfp->fourn_multicurrency_id, - $currentPfp->fourn_multicurrency_code - ); - } - } - } - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_user = ".$user->id." ,"; - $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; - $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; - $sql .= " price = ".$buyprice.","; - $sql .= " quantity = ".$qty.","; - $sql .= " remise_percent = ".$remise_percent.","; - $sql .= " remise = ".$remise.","; - $sql .= " unitprice = ".$unitBuyPrice.","; - $sql .= " fk_availability = ".$availability.","; - $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " entity = ".$conf->entity.","; - $sql .= " tva_tx = ".price2num($tva_tx).","; - // TODO Add localtax1 and localtax2 - //$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; - //$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; - //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$this->db->escape($localtaxtype1)."'":"'0'").","; - //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$this->db->escape($localtaxtype2)."'":"'0'").","; - $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " info_bits = ".$newnpr.","; - $sql .= " charges = ".$charges.","; // deprecated - $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - // TODO Add price_base_type and price_ttc - - dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); - if ($result < 0) $error++; - // End call triggers - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) - { - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - if (empty($error)) - { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); - - // Delete price for this quantity - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - // Add price for this quantity to supplier - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging"; - $sql .= " values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " '".$this->db->idate($now)."',"; - $sql .= " ".$this->id.","; - $sql .= " ".$fourn->id.","; - $sql .= " '".$this->db->escape($ref_fourn)."',"; - $sql .= " '".$this->db->escape($desc_fourn)."',"; - $sql .= " ".$user->id.","; - $sql .= " ".$buyprice.","; - $sql .= " ".$qty.","; - $sql .= " ".$remise_percent.","; - $sql .= " ".$remise.","; - $sql .= " ".$unitBuyPrice.","; - $sql .= " ".$tva_tx.","; - $sql .= " ".$charges.","; - $sql .= " ".$availability.","; - $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " ".$newnpr.","; - $sql .= $conf->entity.","; - $sql .= ($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)); - $sql .= ")"; - - $this->product_fourn_price_id = 0; - - $resql = $this->db->query($sql); - if ($resql) { - $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); - } else { - $error++; - } - - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { - // Add record into log table - // $this->product_fourn_price_id must be set - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - - if (!$error) { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); - if ($result < 0) - $error++; - // End call triggers - - if (empty($error)) { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Loads the price information of a provider - * - * @param int $rowid Line id - * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead - * @return int < 0 if KO, 0 if OK but not found, > 0 if OK - */ - public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,"; - $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; - $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging,"; - $sql .= " p.ref as product_ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p"; - $sql .= " WHERE pfp.rowid = ".(int) $rowid; - $sql .= " AND pfp.fk_product = p.rowid"; - - dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj) - { - $this->product_fourn_price_id = $rowid; - $this->id = $obj->fk_product; - - $this->fk_product = $obj->fk_product; - $this->product_id = $obj->fk_product; - $this->product_ref = $obj->product_ref; - - $this->fourn_id = $obj->fk_soc; - $this->fourn_ref = $obj->ref_fourn; // deprecated - $this->ref_supplier = $obj->ref_fourn; - $this->desc_supplier = $obj->desc_fourn; - $this->fourn_price = $obj->price; - $this->fourn_charges = $obj->charges; // deprecated - $this->fourn_qty = $obj->quantity; - $this->fourn_remise_percent = $obj->remise_percent; - $this->fourn_remise = $obj->remise; - $this->fourn_unitprice = $obj->unitprice; - $this->fourn_tva_tx = $obj->tva_tx; - $this->fourn_tva_npr = $obj->fourn_tva_npr; - // Add also localtaxes - $this->fk_availability = $obj->fk_availability; - $this->delivery_time_days = $obj->delivery_time_days; - $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; - $this->supplier_reputation = $obj->supplier_reputation; - $this->default_vat_code = $obj->default_vat_code; - $this->user_id = $obj->fk_user; - $this->date_creation = $this->db->jdate($obj->datec); - $this->fourn_multicurrency_price = $obj->multicurrency_price; - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; - $this->fourn_multicurrency_id = $obj->fk_multicurrency; - $this->fourn_multicurrency_code = $obj->multicurrency_code; - if (!empty($conf->barcode->enabled)) { - $this->fourn_barcode = $obj->barcode; // deprecated - $this->fourn_fk_barcode_type = $obj->fk_barcode_type; // deprecated - $this->supplier_barcode = $obj->barcode; - $this->supplier_fk_barcode_type = $obj->fk_barcode_type; - } - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->packaging = $obj->packaging; - if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty; - } - - if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) - { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($this); - if ($price_result >= 0) { - $this->fourn_price = $price_result; - //recalculation of unitprice, as probably the price changed... - if ($this->fourn_qty != 0) - { - $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU'); - } else { - $this->fourn_unitprice = ""; - } - } - } - - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * List all supplier prices of a product - * - * @param int $prodid Id of product - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Products with new properties to define supplier price - */ - public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id, p.ref as product_ref,"; - $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; - $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; - $sql .= " AND s.status=1"; // only enabled company selected - $sql .= " AND pfp.fk_product = ".$prodid; - if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($record = $this->db->fetch_array($resql)) - { - //define base attribute - $prodfourn = new ProductFournisseur($this->db); - - $prodfourn->product_ref = $record["product_ref"]; - $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; - $prodfourn->product_fourn_id = $record["product_fourn_id"]; - $prodfourn->product_fourn_entity = $record["entity"]; - $prodfourn->ref_supplier = $record["ref_fourn"]; - $prodfourn->fourn_ref = $record["ref_fourn"]; - $prodfourn->desc_supplier = $record["desc_fourn"]; - $prodfourn->fourn_price = $record["price"]; - $prodfourn->fourn_qty = $record["quantity"]; - $prodfourn->fourn_remise_percent = $record["remise_percent"]; - $prodfourn->fourn_remise = $record["remise"]; - $prodfourn->fourn_unitprice = $record["unitprice"]; - $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_tva_tx = $record["tva_tx"]; - $prodfourn->fourn_id = $record["fourn_id"]; - $prodfourn->fourn_name = $record["supplier_name"]; - $prodfourn->fk_availability = $record["fk_availability"]; - $prodfourn->delivery_time_days = $record["delivery_time_days"]; - $prodfourn->id = $prodid; - $prodfourn->fourn_tva_npr = $record["info_bits"]; - $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $prodfourn->supplier_reputation = $record["supplier_reputation"]; - $prodfourn->fourn_date_creation = $this->db->jdate($record['datec']); - $prodfourn->fourn_date_modification = $this->db->jdate($record['tms']); - - $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"]; - $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; - $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $prodfourn->packaging = $record["packaging"]; - if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty; - } - - if (!empty($conf->barcode->enabled)) { - $prodfourn->supplier_barcode = $record["barcode"]; - $prodfourn->supplier_fk_barcode_type = $record["fk_barcode_type"]; - } - - if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prodfourn); - if ($price_result >= 0) { - $prodfourn->fourn_price = $price_result; - $prodfourn->fourn_unitprice = null; //force recalculation of unitprice, as probably the price changed... - } - } - - if (!isset($prodfourn->fourn_unitprice)) - { - if ($prodfourn->fourn_qty != 0) - { - $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU'); - } else { - $prodfourn->fourn_unitprice = ""; - } - } - - $retarray[] = $prodfourn; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load properties for minimum price - * - * @param int $prodid Product id - * @param int $qty Minimum quantity - * @param int $socid get min price for specific supplier - * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK - */ - public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) - { - // phpcs:enable - global $conf; - - if (empty($prodid)) - { - dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING); - return 0; - } - - $this->product_fourn_price_id = ''; - $this->product_fourn_id = ''; - $this->fourn_ref = ''; - $this->fourn_price = ''; - $this->fourn_qty = ''; - $this->fourn_remise_percent = ''; - $this->fourn_remise = ''; - $this->fourn_unitprice = ''; - $this->fourn_id = ''; - $this->fourn_name = ''; - $this->delivery_time_days = ''; - $this->id = ''; - - $this->fourn_multicurrency_price = ''; - $this->fourn_multicurrency_unitprice = ''; - $this->fourn_multicurrency_tx = ''; - $this->fourn_multicurrency_id = ''; - $this->fourn_multicurrency_code = ''; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; - $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; - $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE s.entity IN (".getEntity('societe').")"; - $sql .= " AND pfp.entity = ".$conf->entity; // only current entity - $sql .= " AND pfp.fk_product = ".$prodid; - $sql .= " AND pfp.fk_soc = s.rowid"; - $sql .= " AND s.status = 1"; // only enabled society - if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid; - - dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $record_array = array(); - - //Store each record to array for later search of min - while ($record = $this->db->fetch_array($resql)) - { - $record_array[] = $record; - } - - if (count($record_array) == 0) - { - $this->db->free($resql); - return 0; - } else { - $min = -1; - foreach ($record_array as $record) - { - $fourn_price = $record["price"]; - // discount calculated buy price - $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; - if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { - $prod_supplier = new ProductFournisseur($this->db); - $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; - $prod_supplier->id = $prodid; - $prod_supplier->fourn_qty = $record["quantity"]; - $prod_supplier->fourn_tva_tx = $record["tva_tx"]; - $prod_supplier->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prod_supplier); - if ($price_result >= 0) { - $fourn_price = price2num($price_result, 'MU'); - if ($record["quantity"] != 0) - { - $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU'); - } else { - $fourn_unitprice = $fourn_price; - } - } - } - if ($fourn_unitprice < $min || $min == -1) - { - $this->product_fourn_price_id = $record["product_fourn_price_id"]; - $this->ref_supplier = $record["ref_fourn"]; - $this->ref_fourn = $record["ref_fourn"]; // deprecated - $this->fourn_ref = $record["ref_fourn"]; // deprecated - $this->fourn_price = $fourn_price; - $this->fourn_qty = $record["quantity"]; - $this->fourn_remise_percent = $record["remise_percent"]; - $this->fourn_remise = $record["remise"]; - $this->fourn_unitprice = $record["unitprice"]; - $this->fourn_charges = $record["charges"]; // deprecated - $this->fourn_tva_tx = $record["tva_tx"]; - $this->fourn_id = $record["fourn_id"]; - $this->fourn_name = $record["supplier_name"]; - $this->delivery_time_days = $record["delivery_time_days"]; - $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $this->id = $prodid; - $this->fourn_multicurrency_price = $record["multicurrency_price"]; - $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $this->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $this->fourn_multicurrency_id = $record["fk_multicurrency"]; - $this->fourn_multicurrency_code = $record["multicurrency_code"]; - $min = $fourn_unitprice; - } - } - } - - $this->db->free($resql); - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Sets the supplier price expression - * - * @param int $expression_id Expression - * @return int <0 if KO, >0 if OK - */ - public function setSupplierPriceExpression($expression_id) - { - global $conf; - - // Clean parameters - $this->db->begin(); - $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; - - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_supplier_price_expression = ".$expression_id; - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - - dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - - /** - * Display supplier of product - * - * @param int $withpicto Add picto - * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @return string String with supplier price - * TODO Remove this method. Use getNomUrl directly. - */ - public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) - { - $thirdparty = new Fournisseur($this->db); - $thirdparty->fetch($this->fourn_id); - - return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display price of product - * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects - * to display in table format. - * @return string String with supplier price - */ - public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) - { - // phpcs:enable - global $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - foreach ($productFournList as $productFourn) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - } - $out .= '
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; - } else { - $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); - } - return $out; - } - - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'product_fournisseur_price' - ); - - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } - - /** - * List supplier prices log of a supplier price - * - * @param int $product_fourn_price_id Id of supplier price - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Log prices - */ - public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - $sql = "SELECT"; - $sql .= " u.lastname,"; - $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec,"; - $sql .= " pfpl.price, pfpl.quantity,"; - $sql .= " pfpl.fk_multicurrency, pfpl.multicurrency_code, pfpl.multicurrency_tx, pfpl.multicurrency_price, pfpl.multicurrency_unitprice"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl,"; - $sql .= " ".MAIN_DB_PREFIX."product_fournisseur_price as pfp,"; - $sql .= " ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")"; - $sql .= " AND pfpl.fk_user = u.rowid"; - $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; - $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($obj = $this->db->fetch_object($resql)) - { - $tmparray = array(); - $tmparray['rowid'] = $obj->rowid; - $tmparray['supplier_ref'] = $obj->supplier_ref; - $tmparray['datec'] = $this->db->jdate($obj->datec); - $tmparray['lastname'] = $obj->lastname; - $tmparray['price'] = $obj->price; - $tmparray['quantity'] = $obj->quantity; - $tmparray['fk_multicurrency'] = $obj->fk_multicurrency; - $tmparray['multicurrency_code'] = $obj->multicurrency_code; - $tmparray['multicurrency_tx'] = $obj->multicurrency_tx; - $tmparray['multicurrency_price'] = $obj->multicurrency_price; - $tmparray['multicurrency_unitprice'] = $obj->multicurrency_unitprice; - - $retarray[] = $tmparray; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Display log price of product supplier price - * - * @param array $productFournLogList list of ProductFournisseur price log objects - * to display in table format. - * @return string HTML String with supplier price - */ - public function displayPriceProductFournisseurLog($productFournLogList = array()) - { - global $conf, $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournLogList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - //$out .= ''; - $out .= ''; - foreach ($productFournLogList as $productFournLog) { - $out .= ''; - $out .= ''; - //$out.= ''; - $out .= ''; - } - $out .= '
'.$langs->trans("Date").''.$langs->trans("Price").''.$langs->trans("QtyMin").''.$langs->trans("User").'
'.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').''.price($productFournLog['price'], 0, $langs, 1, -1, -1, $conf->currency); - if ($productFournLog['multicurrency_code'] != $conf->currency) { - $out .= ' ('.price($productFournLog['multicurrency_price'], 0, $langs, 1, -1, -1, $productFournLog['multicurrency_code']).')'; - } - $out .= ''.$productFournLog['quantity'].''.$productFournLog['lastname'].'
'; - } - return $out; - } - - - /** - * Return a link to the object card (with optionaly the picto). - * Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl(). - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs; - - if (!empty($conf->dol_no_mouse_hover)) { - $notooltip = 1; // Force disable tooltips - } - - $result = ''; - $label = ''; - - if (!empty($this->entity)) { - $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); - if ($this->nbphoto > 0) { - $label .= '
'; - $label .= $tmpphoto; - $label .= '
'; - } - } - - if ($this->type == Product::TYPE_PRODUCT) { - $label .= img_picto('', 'product').' '.$langs->trans("Product").''; - } elseif ($this->type == Product::TYPE_SERVICE) { - $label .= img_picto('', 'service').' '.$langs->trans("Service").''; - } - if (isset($this->status) && isset($this->status_buy)) { - $label .= ' '.$this->getLibStatut(5, 0); - $label .= ' '.$this->getLibStatut(5, 1); - } - - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('ProductRef').': '.($this->ref ? $this->ref : $this->product_ref); - } - if (!empty($this->label)) { - $label .= '
'.$langs->trans('ProductLabel').': '.$this->label; - } - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - - if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (!empty($conf->productbatch->enabled)) { - $langs->load("productbatch"); - $label .= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); - } - } - if (!empty($conf->barcode->enabled)) { - $label .= '
'.$langs->trans('BarCode').': '.$this->barcode; - } - - if ($this->type == Product::TYPE_PRODUCT) { - if ($this->weight) { - $label .= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); - } - $labelsize = ""; - if ($this->length) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); - } - if ($this->width) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); - } - if ($this->height) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); - } - if ($labelsize) $label .= "
".$labelsize; - - $labelsurfacevolume = ""; - if ($this->surface) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); - } - if ($this->volume) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); - } - if ($labelsurfacevolume) $label .= "
".$labelsurfacevolume; - } - - if (!empty($conf->accounting->enabled) && $this->status) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); - $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); - $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); - } - if (!empty($conf->accounting->enabled) && $this->status_buy) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); - $label .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); - $label .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); - } - - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here - if (is_array($logPrices) && count($logPrices) > 0) { - $label .= '

'; - $label .= ''.$langs->trans("History").''; - $label .= $this->displayPriceProductFournisseurLog($logPrices); - } - - $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; - - 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'; - } - } - - $linkclose = ''; - if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label = $langs->trans("SupplierRef"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - } - - $linkstart = ''; - $linkend = ''; - - $result .= $linkstart; - if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - } - if ($withpicto != 2) { - $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); - } - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - - return $result; - } - - /** - * Private function to log price history - * - * @param User $user Object user who adds/changes price - * @param integer $datec date create - * @param float $buyprice price for qty - * @param float $qty qty for price - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param float $multicurrency_unitBuyPrice Unit Purchase price in currency - * @param float $multicurrency_tx Rate currency - * @param int $fk_multicurrency key multi currency - * @param string $multicurrency_code Currency code - * - * @return int < 0 NOK > 0 OK - */ - private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null) - { - // Add record into log table - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; - $sql .= "values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= "'".$this->db->idate($datec)."',"; - $sql .= " ".$this->product_fourn_price_id.","; - $sql .= " ".$user->id.","; - $sql .= " ".price2num($buyprice).","; - $sql .= " ".$qty; - $sql .= ")"; - - $resql = $this->db->query($sql); - if (!$resql) { - return -1; - } else { - return 1; - } - } - - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $records = array(); - - $sql = 'SELECT '; - $sql .= $this->getFieldList(); - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid') { - $sqlwhere[] = $key.'='.$value; - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } - - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { - $obj = $this->db->fetch_object($resql); - - $record = new self($this->db); - $record->setVarsFromFetchObj($obj); - - $records[$record->id] = $record; - - $i++; - } - $this->db->free($resql); - - return $records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - - return -1; - } - } - public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); - } -} diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 371a5581c55..0f39005a708 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1348,7 +1348,13 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); + /** + * Function to concat keys of fields + * + * @return string + */ + protected function getFieldList() { + $keys = array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); + return implode(',', $keys); } } From e7f24e21099b8b358cb4387f1ed7d945408c16ad Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 8 Mar 2021 16:00:49 +0000 Subject: [PATCH 016/618] Fixing style errors. --- htdocs/fourn/class/fournisseur.product.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 0f39005a708..836ae7b6d8c 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1353,7 +1353,8 @@ class ProductFournisseur extends Product * * @return string */ - protected function getFieldList() { + protected function getFieldList() + { $keys = array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); return implode(',', $keys); } From 061e797d6499fe76c2a500d6b2608d861d5dc4de Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Mon, 8 Mar 2021 17:35:12 +0100 Subject: [PATCH 017/618] correct product fournisseur class fetchAll --- htdocs/fourn/class/fournisseur.product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 836ae7b6d8c..6b3c309ceb4 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1293,7 +1293,7 @@ class ProductFournisseur extends Product $sql = 'SELECT '; $sql .= $this->getFieldList(); - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as t'; $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; // Manage filter From cfc56da26312106a59364207ea65ff518753438a Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Mon, 8 Mar 2021 17:59:58 +0100 Subject: [PATCH 018/618] fournisseur product class - update style code --- htdocs/fourn/class/fournisseur.product.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 6b3c309ceb4..d826183d93f 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1355,7 +1355,12 @@ class ProductFournisseur extends Product */ protected function getFieldList() { - $keys = array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); + $keys = array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', + 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', + 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', + 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', + 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', + 'fk_barcode_type', 'packaging'); return implode(',', $keys); } } From d2650d31cf167026d7ffcb0af6e1c42f44ae2814 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 11 Mar 2021 09:50:05 +0100 Subject: [PATCH 019/618] add multicompany module --- htdocs/custom/multicompany/COPYING | 674 + htdocs/custom/multicompany/ChangeLog.md | 335 + htdocs/custom/multicompany/INSTALL | 16 + htdocs/custom/multicompany/README | 11 + htdocs/custom/multicompany/README.md | 36 + htdocs/custom/multicompany/README_FR | 14 + htdocs/custom/multicompany/admin/about.php | 76 + htdocs/custom/multicompany/admin/caches.php | 103 + htdocs/custom/multicompany/admin/index.html | 0 .../multicompany/admin/multicompany.php | 131 + .../admin/multicompany_extrafields.php | 115 + htdocs/custom/multicompany/admin/options.php | 494 + .../multicompany/admin/tpl/caches.tpl.php | 118 + .../multicompany/admin/tpl/card.tpl.php | 386 + .../custom/multicompany/admin/tpl/index.html | 0 .../multicompany/admin/tpl/list.tpl.php | 230 + .../multicompany/admin/tpl/switch.tpl.php | 122 + .../class/actions_multicompany.class.php | 4608 +++++ .../class/api_multicompany.class.php | 334 + .../class/dao_multicompany.class.php | 990 + htdocs/custom/multicompany/class/index.html | 0 .../custom/multicompany/class/ssp.class.php | 412 + .../multicompany/core/ajax/functions.php | 286 + .../custom/multicompany/core/ajax/index.html | 0 htdocs/custom/multicompany/core/ajax/list.php | 248 + htdocs/custom/multicompany/core/js/index.html | 0 .../custom/multicompany/core/js/lib_head.js | 214 + .../multicompany/core/login/functions_mc.php | 166 + .../custom/multicompany/core/login/index.html | 0 .../multicompany/core/modules/index.html | 0 .../core/modules/modMultiCompany.class.php | 587 + .../multicompany/core/triggers/index.html | 0 ...ulticompany_MulticompanyWorkflow.class.php | 86 + .../custom/multicompany/css/dropdown.inc.php | 199 + htdocs/custom/multicompany/css/index.html | 0 .../multicompany/css/multicompany.css.php | 355 + htdocs/custom/multicompany/img/gplv3.png | Bin 0 -> 2666 bytes htdocs/custom/multicompany/img/index.html | 0 htdocs/custom/multicompany/img/inodbox.png | Bin 0 -> 6316 bytes .../custom/multicompany/img/multicompany.png | Bin 0 -> 4380 bytes .../multicompany/img/object_multicompany.png | Bin 0 -> 1269 bytes .../img/object_multicompany_eldy.png | Bin 0 -> 972 bytes .../img/object_multicompany_md.png | Bin 0 -> 954 bytes .../buttons/css/buttons.dataTables.css | 354 + .../buttons/css/buttons.dataTables.min.css | 1 + .../inc/datatables/buttons/css/common.scss | 27 + .../inc/datatables/buttons/css/mixins.scss | 136 + .../datatables/buttons/js/buttons.colVis.js | 206 + .../buttons/js/buttons.colVis.min.js | 6 + .../datatables/buttons/js/buttons.flash.js | 1441 ++ .../datatables/buttons/js/buttons.html5.js | 1370 ++ .../buttons/js/buttons.html5.min.js | 26 + .../datatables/buttons/js/buttons.print.js | 194 + .../buttons/js/buttons.print.min.js | 4 + .../buttons/js/dataTables.buttons.js | 1705 ++ .../buttons/js/dataTables.buttons.min.js | 37 + .../inc/datatables/css/jquery.dataTables.css | 455 + .../datatables/css/jquery.dataTables.min.css | 1 + .../inc/datatables/images/sort_asc.png | Bin 0 -> 160 bytes .../datatables/images/sort_asc_disabled.png | Bin 0 -> 148 bytes .../inc/datatables/images/sort_both.png | Bin 0 -> 201 bytes .../inc/datatables/images/sort_desc.png | Bin 0 -> 158 bytes .../datatables/images/sort_desc_disabled.png | Bin 0 -> 146 bytes .../multicompany/inc/datatables/index.html | 0 .../inc/datatables/js/jquery.dataTables.js | 15345 ++++++++++++++++ .../datatables/js/jquery.dataTables.min.js | 167 + .../responsive/css/responsive.dataTables.css | 178 + .../css/responsive.dataTables.min.css | 1 + .../responsive/js/dataTables.responsive.js | 1255 ++ .../js/dataTables.responsive.min.js | 26 + htdocs/custom/multicompany/inc/index.html | 0 .../multicompany/inc/multiselect/CHANGELOG.md | 25 + .../multicompany/inc/multiselect/LICENSE | 22 + .../multicompany/inc/multiselect/README.md | 66 + .../inc/multiselect/css/bootstrap-iso.min.css | 7 + .../fonts/glyphicons-halflings-regular.eot | Bin 0 -> 20127 bytes .../fonts/glyphicons-halflings-regular.svg | 288 + .../fonts/glyphicons-halflings-regular.ttf | Bin 0 -> 45404 bytes .../fonts/glyphicons-halflings-regular.woff | Bin 0 -> 23424 bytes .../fonts/glyphicons-halflings-regular.woff2 | Bin 0 -> 18028 bytes .../inc/multiselect/js/bootstrap.min.js | 7 + .../inc/multiselect/js/multiselect.js | 813 + .../inc/multiselect/js/multiselect.min.js | 11 + htdocs/custom/multicompany/index.html | 0 .../langs/ca_ES/multicompany.lang | 250 + .../langs/de_AT/multicompany.lang | 250 + .../langs/de_CH/multicompany.lang | 250 + .../langs/de_DE/multicompany.lang | 250 + .../langs/en_GB/multicompany.lang | 250 + .../langs/en_US/multicompany.lang | 250 + .../langs/es_CL/multicompany.lang | 250 + .../langs/es_ES/multicompany.lang | 250 + .../langs/es_MX/multicompany.lang | 250 + .../langs/fr_FR/multicompany.lang | 250 + .../langs/hu_HU/multicompany.lang | 250 + htdocs/custom/multicompany/langs/index.html | 0 .../langs/it_IT/multicompany.lang | 250 + .../langs/nl_NL/multicompany.lang | 250 + .../langs/pt_PT/multicompany.lang | 250 + .../lib/PHP_Markdown/License.text | 36 + .../multicompany/lib/PHP_Markdown/Readme.text | 777 + .../multicompany/lib/PHP_Markdown/index.html | 0 .../lib/PHP_Markdown/markdown.php | 1732 ++ htdocs/custom/multicompany/lib/index.html | 0 .../multicompany/lib/multicompany.lib.php | 484 + .../sql/dict/init_new_entity_c_paiement.sql | 37 + .../dict/init_new_entity_c_payment_term.sql | 42 + htdocs/custom/multicompany/sql/index.html | 0 .../multicompany/sql/init_new_entity.sql | 68 + .../sql/init_new_entity_nocrypt.sql | 68 + .../multicompany/sql/llx_entity.key.sql | 23 + htdocs/custom/multicompany/sql/llx_entity.sql | 33 + .../sql/llx_entity_extrafields.sql | 26 + .../sql/llx_entity_thirdparty.key.sql | 24 + .../sql/llx_entity_thirdparty.sql | 27 + .../multicompany/sql/update_3.1.0-3.2.0.sql | 8 + .../multicompany/sql/update_3.6.0-3.7.0.sql | 14 + .../multicompany/sql/update_3.8.0-3.9.0.sql | 20 + .../multicompany/sql/update_5.0.0-6.0.0.sql | 14 + 119 files changed, 42453 insertions(+) create mode 100755 htdocs/custom/multicompany/COPYING create mode 100755 htdocs/custom/multicompany/ChangeLog.md create mode 100755 htdocs/custom/multicompany/INSTALL create mode 100755 htdocs/custom/multicompany/README create mode 100755 htdocs/custom/multicompany/README.md create mode 100755 htdocs/custom/multicompany/README_FR create mode 100755 htdocs/custom/multicompany/admin/about.php create mode 100755 htdocs/custom/multicompany/admin/caches.php create mode 100755 htdocs/custom/multicompany/admin/index.html create mode 100755 htdocs/custom/multicompany/admin/multicompany.php create mode 100755 htdocs/custom/multicompany/admin/multicompany_extrafields.php create mode 100755 htdocs/custom/multicompany/admin/options.php create mode 100755 htdocs/custom/multicompany/admin/tpl/caches.tpl.php create mode 100755 htdocs/custom/multicompany/admin/tpl/card.tpl.php create mode 100755 htdocs/custom/multicompany/admin/tpl/index.html create mode 100755 htdocs/custom/multicompany/admin/tpl/list.tpl.php create mode 100755 htdocs/custom/multicompany/admin/tpl/switch.tpl.php create mode 100755 htdocs/custom/multicompany/class/actions_multicompany.class.php create mode 100755 htdocs/custom/multicompany/class/api_multicompany.class.php create mode 100755 htdocs/custom/multicompany/class/dao_multicompany.class.php create mode 100755 htdocs/custom/multicompany/class/index.html create mode 100755 htdocs/custom/multicompany/class/ssp.class.php create mode 100755 htdocs/custom/multicompany/core/ajax/functions.php create mode 100755 htdocs/custom/multicompany/core/ajax/index.html create mode 100755 htdocs/custom/multicompany/core/ajax/list.php create mode 100755 htdocs/custom/multicompany/core/js/index.html create mode 100755 htdocs/custom/multicompany/core/js/lib_head.js create mode 100755 htdocs/custom/multicompany/core/login/functions_mc.php create mode 100755 htdocs/custom/multicompany/core/login/index.html create mode 100755 htdocs/custom/multicompany/core/modules/index.html create mode 100755 htdocs/custom/multicompany/core/modules/modMultiCompany.class.php create mode 100755 htdocs/custom/multicompany/core/triggers/index.html create mode 100755 htdocs/custom/multicompany/core/triggers/interface_25_modMulticompany_MulticompanyWorkflow.class.php create mode 100755 htdocs/custom/multicompany/css/dropdown.inc.php create mode 100755 htdocs/custom/multicompany/css/index.html create mode 100755 htdocs/custom/multicompany/css/multicompany.css.php create mode 100755 htdocs/custom/multicompany/img/gplv3.png create mode 100755 htdocs/custom/multicompany/img/index.html create mode 100755 htdocs/custom/multicompany/img/inodbox.png create mode 100755 htdocs/custom/multicompany/img/multicompany.png create mode 100755 htdocs/custom/multicompany/img/object_multicompany.png create mode 100755 htdocs/custom/multicompany/img/object_multicompany_eldy.png create mode 100755 htdocs/custom/multicompany/img/object_multicompany_md.png create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/css/buttons.dataTables.css create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/css/buttons.dataTables.min.css create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/css/common.scss create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/css/mixins.scss create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/js/buttons.colVis.js create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/js/buttons.colVis.min.js create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/js/buttons.flash.js create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/js/buttons.html5.js create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/js/buttons.html5.min.js create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/js/buttons.print.js create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/js/buttons.print.min.js create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/js/dataTables.buttons.js create mode 100755 htdocs/custom/multicompany/inc/datatables/buttons/js/dataTables.buttons.min.js create mode 100755 htdocs/custom/multicompany/inc/datatables/css/jquery.dataTables.css create mode 100755 htdocs/custom/multicompany/inc/datatables/css/jquery.dataTables.min.css create mode 100755 htdocs/custom/multicompany/inc/datatables/images/sort_asc.png create mode 100755 htdocs/custom/multicompany/inc/datatables/images/sort_asc_disabled.png create mode 100755 htdocs/custom/multicompany/inc/datatables/images/sort_both.png create mode 100755 htdocs/custom/multicompany/inc/datatables/images/sort_desc.png create mode 100755 htdocs/custom/multicompany/inc/datatables/images/sort_desc_disabled.png create mode 100755 htdocs/custom/multicompany/inc/datatables/index.html create mode 100755 htdocs/custom/multicompany/inc/datatables/js/jquery.dataTables.js create mode 100755 htdocs/custom/multicompany/inc/datatables/js/jquery.dataTables.min.js create mode 100755 htdocs/custom/multicompany/inc/datatables/responsive/css/responsive.dataTables.css create mode 100755 htdocs/custom/multicompany/inc/datatables/responsive/css/responsive.dataTables.min.css create mode 100755 htdocs/custom/multicompany/inc/datatables/responsive/js/dataTables.responsive.js create mode 100755 htdocs/custom/multicompany/inc/datatables/responsive/js/dataTables.responsive.min.js create mode 100755 htdocs/custom/multicompany/inc/index.html create mode 100755 htdocs/custom/multicompany/inc/multiselect/CHANGELOG.md create mode 100755 htdocs/custom/multicompany/inc/multiselect/LICENSE create mode 100755 htdocs/custom/multicompany/inc/multiselect/README.md create mode 100755 htdocs/custom/multicompany/inc/multiselect/css/bootstrap-iso.min.css create mode 100755 htdocs/custom/multicompany/inc/multiselect/fonts/glyphicons-halflings-regular.eot create mode 100755 htdocs/custom/multicompany/inc/multiselect/fonts/glyphicons-halflings-regular.svg create mode 100755 htdocs/custom/multicompany/inc/multiselect/fonts/glyphicons-halflings-regular.ttf create mode 100755 htdocs/custom/multicompany/inc/multiselect/fonts/glyphicons-halflings-regular.woff create mode 100755 htdocs/custom/multicompany/inc/multiselect/fonts/glyphicons-halflings-regular.woff2 create mode 100755 htdocs/custom/multicompany/inc/multiselect/js/bootstrap.min.js create mode 100755 htdocs/custom/multicompany/inc/multiselect/js/multiselect.js create mode 100755 htdocs/custom/multicompany/inc/multiselect/js/multiselect.min.js create mode 100755 htdocs/custom/multicompany/index.html create mode 100755 htdocs/custom/multicompany/langs/ca_ES/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/de_AT/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/de_CH/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/de_DE/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/en_GB/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/en_US/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/es_CL/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/es_ES/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/es_MX/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/fr_FR/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/hu_HU/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/index.html create mode 100755 htdocs/custom/multicompany/langs/it_IT/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/nl_NL/multicompany.lang create mode 100755 htdocs/custom/multicompany/langs/pt_PT/multicompany.lang create mode 100755 htdocs/custom/multicompany/lib/PHP_Markdown/License.text create mode 100755 htdocs/custom/multicompany/lib/PHP_Markdown/Readme.text create mode 100755 htdocs/custom/multicompany/lib/PHP_Markdown/index.html create mode 100755 htdocs/custom/multicompany/lib/PHP_Markdown/markdown.php create mode 100755 htdocs/custom/multicompany/lib/index.html create mode 100755 htdocs/custom/multicompany/lib/multicompany.lib.php create mode 100755 htdocs/custom/multicompany/sql/dict/init_new_entity_c_paiement.sql create mode 100755 htdocs/custom/multicompany/sql/dict/init_new_entity_c_payment_term.sql create mode 100755 htdocs/custom/multicompany/sql/index.html create mode 100755 htdocs/custom/multicompany/sql/init_new_entity.sql create mode 100755 htdocs/custom/multicompany/sql/init_new_entity_nocrypt.sql create mode 100755 htdocs/custom/multicompany/sql/llx_entity.key.sql create mode 100755 htdocs/custom/multicompany/sql/llx_entity.sql create mode 100755 htdocs/custom/multicompany/sql/llx_entity_extrafields.sql create mode 100755 htdocs/custom/multicompany/sql/llx_entity_thirdparty.key.sql create mode 100755 htdocs/custom/multicompany/sql/llx_entity_thirdparty.sql create mode 100755 htdocs/custom/multicompany/sql/update_3.1.0-3.2.0.sql create mode 100755 htdocs/custom/multicompany/sql/update_3.6.0-3.7.0.sql create mode 100755 htdocs/custom/multicompany/sql/update_3.8.0-3.9.0.sql create mode 100755 htdocs/custom/multicompany/sql/update_5.0.0-6.0.0.sql diff --git a/htdocs/custom/multicompany/COPYING b/htdocs/custom/multicompany/COPYING new file mode 100755 index 00000000000..94a9ed024d3 --- /dev/null +++ b/htdocs/custom/multicompany/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/htdocs/custom/multicompany/ChangeLog.md b/htdocs/custom/multicompany/ChangeLog.md new file mode 100755 index 00000000000..c1860df345f --- /dev/null +++ b/htdocs/custom/multicompany/ChangeLog.md @@ -0,0 +1,335 @@ +# ChangeLog MULTICOMPANY + +## 12.0.1 + +NEW add stock warehouse sharing list +NEW add triggers create, update, delete +FIX uniformize trigger +FIX uniformize extrafields management + +## 12.0.0 + +FIX compatibility with Dolibarr 12 +FIX look and feel V12 + +## 11.0.2 + +NEW add stock warehouse sharing list + +## 11.0.1 + +FIX form is not printed to addgroups on user card in Dolibarr 11.0 + +## 11.0.0 + +FIX compatibility with Dolibarr 11 +FIX better warning for upgrade message + +## 10.0.3 + +NEW add templates of entities management +NEW pre-format modules and shares of new entities with templates +NEW possibility to duplicate usergroup rights by entities in transversal mode +NEW add label of current entity in right top menu + +## 10.0.1.3 + +FIX compatibility with Two-Factor Authentication module + +## 10.0.1.2 + +FIX missing rename facture ref field (ref instead facnumber) + +## 10.0.1.1 + +FIX wrong Font Awesome css class for check/uncheck button + +## 10.0.1 + +FIX wrong sql request for show users in transversal mode + +## 10.0.0 + +NEW add dropdown menu (look and feel v10) +NEW change logo and background of entity in login page +FIX compatibility with Dolibarr 10 + +## 9.0.4 + +FIX wrong sql request for show users in transversal mode + +## 9.0.3 + +FIX display rights of allowed entity for user when it's not entity 1 on perms card + +## 9.0.2 + +FIX better test for compatibility with multiple Dolibarr versions + +## 9.0.1 + +FIX superadmin can always edit groups of another entities +FIX need php 5.6 min +FIX possibility to hide html title with constant MULTICOMPANY\_HIDE\_HTML\_TITLE +FIX translation + +## 9.0.0 + +NEW add customer invoices sharing +NEW add proposal numbering sharing +NEW an external plugin can easily include its own sharing settings +NEW add buttons to stay in entity card +FIX compatibility between proposal sharing and proposalnumber sharing +FIX compatibility between invoice sharing and invoicenumber sharing +FIX possibility to use a different referrer for numbering sharing +FIX compatibility with Dolibarr 9 + +## 8.0.6 + +FIX backport from newest version for avoid error + +## 8.0.5.4 + +FIX display rights of allowed entity for user when it's not entity 1 on perms card + +## 8.0.5.3 + +FIX Make retrocompatibility for external modules using old method + +## 8.0.5.2 + +FIX when using switchentityautoopen, this avoid to have the autopen always after first use + +## 8.0.5.1 + +FIX missing cashdesk module authentication + +## 8.0.5 + +FIX better check entities in user permissions tab + +## 8.0.4 + +FIX autoopen of the "switch entity popup" was broken (used by DoliDroid) +FIX version checking refactorization + +## 8.0.3 + +FIX missing "printUserPasswordField" hook for mc authentication + +## 8.0.2 + +FIX use POST instead GET for avoid false positive error with firewall (datatables) +FIX avoid error when SHMOP cache is used + +## 8.0.1 + +FIX Look and feel v8 + +## 8.0.0 + +NEW can share leave requests - holidays +NEW ad possibility to change third party entity +NEW add customer proposals sharing with read/write permissions +NEW add read/write permissions for products/services sharing +NEW add entity field in products/services list +NEW add entity field in third parties list +NEW add entity field in customer proposals list +NEW add entity information in banner of elements sharing +NEW add warning message when hide the entity in login page +NEW add warning message if user not linked with group/entity (transversal mode) +NEW change icons add specific icon by theme +NEW Can set a parameter switchentityautoopen=1 on any urls to force open of the switch entity box, with no need to click: +- This is required to provide a compatibility with native android application when menu is not managed by Dolibarr but by the android application + +NEW change multiselect library +NEW add product reseller prices sharing +NEW add new parameters for enable and make visible an entity by default + +FIX compatibility with Dolibarr 8 +FIX better redirection when you switch to another entity +FIX better user/group management in transversal mode +FIX many improvements and fixes for look and performance + +## 7.0.4 + +FIX use POST instead GET for avoid false positive error with firewall (datatables) +FIX avoid error when SHMOP cache is used + +## 7.0.3 + +Fix: datatables error when "multicompany" directory is in root of dolibarr +Fix: use REQUEST_URI by default when switch to another entity +Fix: use dol_include_once() by default + +## 7.0.2 + +Fix: broken feature when dropdown list in login page is hidden + +## 7.0.1 + +Fix: hide dictionnaries sharings for the moment + +## 7.0.0 + +Fix: compatibility with Dolibarr 7 +New: add cache system (memcached) +New: use datatables for entities list +New: add multiselect entities for rights management in transverse mode + +## 6.0.1 + +Fix: compatibility with Dolibarr 7 + +## 6.0.0 + +Fix: compatibility with Dolibarr 6 +New: add members sharing +New: add possibility to customizing dictionnaries by entity (llx\_c\_paiement and llc\_c\_payment\_term) +New: getEntity function use true $shared value by default +New: big refactorization of transverse mode + +Improvements to the transverse mode: +- A module activated in the main entity is no longer activated in the child entities, each entity can have its own modules activated. +- You can define different rights per entity in the same group. +- You can customize/supplement the rights of a user by entity + +For developers: +* You can remove $multicompany_transverse_mode in conf.php +* Use $conf->global->MULTICOMPANY\_TRANSVERSE\_MODE instead $conf->multicompany->transverse_mode +* Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx') +* Use getEntity('thirdparty') instead getEntity('societe') +* Use getEntity('member') instead getEntity('adherent') +* Use getEntity('bankaccount') instead getEntity('bank_account') + +## 5.0.0 + +Fix: compatibility with Dolibarr 5 +New: add expense report sharing + +## 4.0.0 + +Fix: compatibility with Dolibarr 4 +New: add project sharing + +## 3.8.2 + +Fix: compatibility with transverse modes + +## 3.8.1 + +Fix: folder sharing was not working when more than 2 entities + +## 3.8.0 + +Fix: compatibility with Dolibarr 3.8.x + +## 3.7.3 + +Fix: folder sharing was not working when more than 2 entities + +## 3.7.2 + +New: add transifex management +New: change the development platform + +## 3.7.1 + +New: add extrafields +Fix: more bugs + +## 3.7.0 + +Fix: compatibility with Dolibarr 3.7.x +New: add invoice number sharing +New: add script to move master entity with another entity +New: add about page + +## 3.6.2 + +Fix: folder sharing was not working when more than 2 entities + +## 3.6.1 + +Fix: add stock sharing parameters + +## 3.6.0 + +Fix: compatibility with Dolibarr 3.6.x +Fix: show entities combobox only in transverse mode or with admin users +Fix: automatic connection to the entity of the user if the drop down list of entities is hidden (use different login strictly by entity) +New: add multicompany function login + +## 3.5.0 + +Fix: compatibility with Dolibarr 3.5.0 + +## 3.4.0 + +New: add bank sharing +New: add product prices sharing +New: add agenda sharing +New: add stock sharing +New: add Hungary translation +Fix: compatibility with Dolibarr 3.4 +Fix: grant access for user card in transverse mode +Fix: sharing services was not functional if the module product was not activated +Fix: more bugs + +## 3.2.2 + +New: add Netherland translation +Fix: minor bugs and uniformize code +Fix: add check method for login +Fix: check permission in combobox +Fix: remove constantes already defined by module +Fix: compatibility with bureau2crea theme +Fix: possibility to force entity un login page +Fix: bad rights verification + +## 3.2.1 + +no release + +## 3.2.0 + +New: add sharing system for products/services and thirdparties/contacts between entities +New: add category sharing between entities +Fix: problem with user card access and wrong carriage return +Fix: show login page options with hook manager +Fix: update es\_ES and ca\_ES translations +Fix: replace serialize by json +Fix: security +Fix: more bugs + +## 3.1.2 + +Fix: invalid path if you do not use the custom directory + +## 3.1.1 + +Fix: convert current admin to superadmin +The administrator of the primary entity was not converted into superadministrator when activating the module, +this happened during an update of a version of Dolibarr < 3.1 to >= 3.1 + +## 3.1.0 + +New: change logo +New: add italian translation +New: stay connected for switch entity +New: add options tab in module configuration +New: possibility to hide combobox in login page +New: add transverse mode +* Off mode: The rights and groups are managed in each entity: users belong to the entity for their rights +* One mode: Groups can only belong to the entity = 0 and that the user belongs to a particular entity + +Fix: translation + +## 3.0.1 + +New: add spanish translation +Fix: minor bugfix + +## 3.0.0 + +First release of this module diff --git a/htdocs/custom/multicompany/INSTALL b/htdocs/custom/multicompany/INSTALL new file mode 100755 index 00000000000..7e987f02a8f --- /dev/null +++ b/htdocs/custom/multicompany/INSTALL @@ -0,0 +1,16 @@ +INSTALL +------- + +Since version 3 it is possible to define an alternative root directory, +This allows you to store, same place, plug-ins and custom templates. +Just create a directory at the root of Dolibarr (eg custom), +then declare it in the file conf.php : + +examples : + +$dolibarr_main_url_root='http://myserver'; +$dolibarr_main_document_root='/path/of/dolibarr/htdocs'; +$dolibarr_main_url_root_alt='/custom'; +$dolibarr_main_document_root_alt='/path/of/dolibarr/htdocs/custom'; + +Copy "multicompany" directory to the root of "custom" directory. diff --git a/htdocs/custom/multicompany/README b/htdocs/custom/multicompany/README new file mode 100755 index 00000000000..6e822ca85b6 --- /dev/null +++ b/htdocs/custom/multicompany/README @@ -0,0 +1,11 @@ +Thank you for your contribution + +Developer: +Régis Houssin +https://www.inodbox.com + +Development platform: +https://git.framasoft.org/inodbox/multicompany + +Translation platform: +https://www.transifex.com/inodbox/multicompany/ diff --git a/htdocs/custom/multicompany/README.md b/htdocs/custom/multicompany/README.md new file mode 100755 index 00000000000..d453b59fca2 --- /dev/null +++ b/htdocs/custom/multicompany/README.md @@ -0,0 +1,36 @@ +Module for Multi-Company Management +========= + +This module enables multi-company to handle multiple entities on a single installation Dolibarr. + +The sharing of the base product, customer base/contacts and user base and more... + +This module required Dolibarr >= 9.0.0 stable installation + +Thank you for your contribution + +Contact +-------- +This module is developped by Régis Houssin () + +Website: +www.inodbox.com + +Heypster french social network: +iNodbox + +Development platform: +git.framasoft.org/inodbox/multicompany/ + +Translation platform: +www.transifex.com/inodbox/multicompany/ + +Licence +------- +GPLv3 or (at your option) any later version. + +See COPYING for more information. + +Other Licences +-------------- +Uses Michel Fortin's PHP Markdown Licensed under BSD to display this README. diff --git a/htdocs/custom/multicompany/README_FR b/htdocs/custom/multicompany/README_FR new file mode 100755 index 00000000000..6b22b2f1f37 --- /dev/null +++ b/htdocs/custom/multicompany/README_FR @@ -0,0 +1,14 @@ +Merci pour votre contribution + +Développeur : +Régis Houssin +https://www.inodbox.com + +Heypster réseau social français +https://www.heypster.com/fr/profile/21956 + +Plateforme de développement : +https://git.framasoft.org/inodbox/multicompany + +Plateforme de traduction : +https://www.transifex.com/inodbox/multicompany/ \ No newline at end of file diff --git a/htdocs/custom/multicompany/admin/about.php b/htdocs/custom/multicompany/admin/about.php new file mode 100755 index 00000000000..d9137aaadea --- /dev/null +++ b/htdocs/custom/multicompany/admin/about.php @@ -0,0 +1,76 @@ + + * + * 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 /multicompany/admin/about.php + * \ingroup multicompany + * \brief About Page + */ + +$res=@include("../../main.inc.php"); // For root directory +if (! $res && file_exists($_SERVER['DOCUMENT_ROOT']."/main.inc.php")) + $res=@include($_SERVER['DOCUMENT_ROOT']."/main.inc.php"); // Use on dev env only +if (! $res) $res=@include("../../../main.inc.php"); // For "custom" directory + + +// Libraries +dol_include_once('/multicompany/lib/multicompany.lib.php'); +dol_include_once('/multicompany/lib/PHP_Markdown/markdown.php'); + +// Translations +$langs->loadLangs(array('admin', 'multicompany@multicompany')); + +// Security check +if (empty($user->admin) || ! empty($user->entity)) { + accessforbidden(); +} + +/* + * View + */ + +$help_url='EN:Module_MultiCompany|FR:Module_MultiSociété'; +llxHeader('', $langs->trans("Module5000Name"), $help_url); + +// Subheader +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("MultiCompanySetup"), $linkback, 'multicompany@multicompany',0,'multicompany_title'); + +// Configuration header +$head = multicompany_prepare_head(); +dol_fiche_head($head, 'about', $langs->trans("Module5000Name")); + +// About page goes here + +$buffer = file_get_contents(dol_buildpath('/multicompany/README.md',0)); +print Markdown($buffer); + +print '
'; + +$url = 'https://www.inodbox.com/'; +$link = 'iNodbox'; +print $langs->trans("MulticompanyMoreModules", $link).'

'; +print ''; +print '


'; + +print ''; + +dol_fiche_end(); + +llxFooter(); + +$db->close(); diff --git a/htdocs/custom/multicompany/admin/caches.php b/htdocs/custom/multicompany/admin/caches.php new file mode 100755 index 00000000000..8d7735c92f9 --- /dev/null +++ b/htdocs/custom/multicompany/admin/caches.php @@ -0,0 +1,103 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file /multicompany/admin/options.php + * \ingroup multicompany + * \brief Page to setup options for Multicompany module + */ + + +$res=@include("../../main.inc.php"); // For root directory +if (! $res && file_exists($_SERVER['DOCUMENT_ROOT']."/main.inc.php")) + $res=@include($_SERVER['DOCUMENT_ROOT']."/main.inc.php"); // Use on dev env only +if (! $res) $res=@include("../../../main.inc.php"); // For "custom" directory + +dol_include_once('/multicompany/lib/multicompany.lib.php'); +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; + +$langs->loadLangs(array('admin', 'multicompany@multicompany')); + +// Security check +if (empty($user->admin) || ! empty($user->entity)) { + accessforbidden(); +} + +$action = GETPOST('action','alpha'); + + +/* + * Action + */ + +if ($action == 'setvalue') +{ + $result=dolibarr_set_const($db, "MULTICOMPANY_MEMCACHED_SERVER",GETPOST('MULTICOMPANY_MEMCACHED_SERVER', 'alpha'),'chaine',0,'',0); + + if ($result >= 0) + { + setEventMessage($langs->trans("SetupSaved")); + + // Force new value + $conf->global->MULTICOMPANY_MEMCACHED_SERVER=GETPOST('MULTICOMPANY_MEMCACHED_SERVER', 'alpha'); + } + else + { + dol_print_error($db); + } +} + + +/* + * View + */ + +$form=new Form($db); + +$arrayofjs=array( + '/multicompany/core/js/lib_head.js' +); + +$help_url='EN:Module_MultiCompany|FR:Module_MultiSociété'; +llxHeader('', $langs->trans("MultiCompanySetup"), $help_url, '', '', '', $arrayofjs); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("MultiCompanySetup"),$linkback,'multicompany@multicompany',0,'multicompany_title'); + +$head=multicompany_prepare_head(); +dol_fiche_head($head, 'caches', $langs->trans("ModuleSetup"), -1); + +print '
'.info_admin($langs->trans("MulticompanyCacheSystemInfo"), 0, 0, '1', 'clearboth').'
'; + +print '
'; +print ''; +print ''; + +dol_include_once('/multicompany/admin/tpl/caches.tpl.php'); + +print ''; + +// Boutons actions +print '
'; +print ''; +print ''."\n"; +print '
'; + +llxFooter(); +$db->close(); diff --git a/htdocs/custom/multicompany/admin/index.html b/htdocs/custom/multicompany/admin/index.html new file mode 100755 index 00000000000..e69de29bb2d diff --git a/htdocs/custom/multicompany/admin/multicompany.php b/htdocs/custom/multicompany/admin/multicompany.php new file mode 100755 index 00000000000..d1d6ace4054 --- /dev/null +++ b/htdocs/custom/multicompany/admin/multicompany.php @@ -0,0 +1,131 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file multicompany/admin/multicompany.php + * \ingroup multicompany + * \brief Page d'administration/configuration du module Multi-societe + */ + +$res=@include("../../main.inc.php"); // For root directory +if (! $res && file_exists($_SERVER['DOCUMENT_ROOT']."/main.inc.php")) + $res=@include($_SERVER['DOCUMENT_ROOT']."/main.inc.php"); // Use on dev env only +if (! $res) $res=@include("../../../main.inc.php"); // For "custom" directory + +dol_include_once('/multicompany/class/actions_multicompany.class.php', 'ActionsMulticompany'); +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; + +$langs->loadLangs(array('admin', 'languages', 'multicompany@multicompany')); + +if (! $user->admin || $user->entity) { + accessforbidden(); +} + +$action=GETPOST('action', 'alpha'); + +$object = new ActionsMulticompany($db); + +$form=new Form($db); +$formadmin=new FormAdmin($db); +$formcompany=new FormCompany($db); + +/* + * Actions + */ + +$object->doAdminActions($action); + +//$test = new DaoMulticompany($db); +//$test->deleteEntityRecords(4); + +/* + * View + */ + +$extrajs=''; +$extracss=''; + +if (empty($action) || $action == "update" || $action == "add") { + $extrajs = array( + '/multicompany/inc/datatables/js/jquery.dataTables.min.js', + //'/multicompany/inc/datatables/responsive/js/dataTables.responsive.min.js', + '/multicompany/inc/datatables/buttons/js/dataTables.buttons.min.js', + '/multicompany/inc/datatables/buttons/js/buttons.colVis.min.js', + '/multicompany/inc/datatables/buttons/js/buttons.html5.min.js' + ); + $extracss = array( + '/multicompany/inc/datatables/css/jquery.dataTables.min.css', + //'/multicompany/inc/datatables/responsive/css/responsive.dataTables.min.css', + '/multicompany/inc/datatables/buttons/css/buttons.dataTables.min.css' + ); +} else if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) { + $extrajs = array( + '/multicompany/inc/multiselect/js/multiselect.min.js', + //'/multicompany/inc/multiselect/js/multiselect.js' + ); + $extracss = array( + '/multicompany/inc/multiselect/css/bootstrap-iso.min.css' + ); +} + +$help_url='EN:Module_MultiCompany|FR:Module_MultiSociété'; +llxHeader('', $langs->trans("MultiCompanySetup"), $help_url, '', '', '', $extrajs, $extracss); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("MultiCompanySetup"), $linkback, 'multicompany@multicompany', 0, 'multicompany_title'); + +$head = multicompany_prepare_head(); +dol_fiche_head($head, 'entities', $object->getTitle($action), -1); + +$level = checkMultiCompanyVersion(); +if ($level === 1 || $level === -1) +{ + $text = $langs->trans("MultiCompanyIsOlderThanDolibarr"); + if ($level === -1) $text = $langs->trans("DolibarrIsOlderThanMulticompany"); + + print '
'; + dol_htmloutput_mesg($text, '', 'warning', 1); + print '
'; + +} + +// Assign template values +$object->assign_values($action); + +// Isolate Boostrap for avoid conflicts +if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) && ! empty($action) && $action != "update" && $action != "add") { + print '
'; +} + +// Show the template +$object->display(); + +// Isolate Boostrap for avoid conflicts +if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) && ! empty($action) && $action != "update" && $action != "add") { + print '
'; +} + +// Card end +dol_fiche_end(); +// Footer +llxFooter(); +// Close database handler +$db->close(); diff --git a/htdocs/custom/multicompany/admin/multicompany_extrafields.php b/htdocs/custom/multicompany/admin/multicompany_extrafields.php new file mode 100755 index 00000000000..91a8d5f4081 --- /dev/null +++ b/htdocs/custom/multicompany/admin/multicompany_extrafields.php @@ -0,0 +1,115 @@ + + * Copyright (C) 2016-2020 Regis Houssin + * + * 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 multicompany/admin/multicompany.php + * \ingroup multicompany + * \brief Page to setup extra fields of entities + */ + +// Dolibarr environment +$res=@include("../../main.inc.php"); // For root directory +if (! $res && file_exists($_SERVER['DOCUMENT_ROOT']."/main.inc.php")) + $res=@include($_SERVER['DOCUMENT_ROOT']."/main.inc.php"); // Use on dev env only +if (! $res) $res=@include("../../../main.inc.php"); // For "custom" directory + +require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +dol_include_once('/multicompany/lib/multicompany.lib.php'); + +// Security check +if (empty($user->admin) || ! empty($user->entity)) { + accessforbidden(); +} + +$langs->loadLangs(array('admin', 'other')); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); + +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'entity'; // Must be the $table_element of the class that manage extrafield + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT . '/core/actions_extrafields.inc.php'; + + +/* + * View + */ + +$textobject = $langs->transnoentitiesnoconv("Entities"); + +$help_url='EN:Module_MultiCompany|FR:Module_MultiSociété'; +llxHeader('', $langs->trans("MultiCompanySetup"), $help_url); + +$linkback = '' . $langs->trans("BackToModuleList") . ''; +print load_fiche_titre($langs->trans("MultiCompanySetup"), $linkback, 'multicompany@multicompany',0,'multicompany_title'); + +// Configuration header +$head = multicompany_prepare_head(); +dol_fiche_head($head, 'attributes', $langs->trans("ModuleSetup"), -1); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + +// Buttons +if ($action != 'create' && $action != 'edit') { + print ''; +} + +/* ************************************************************************* */ +/* */ +/* Creation d'un champ optionnel */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') { + print "
"; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************* */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) { + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_edit.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/custom/multicompany/admin/options.php b/htdocs/custom/multicompany/admin/options.php new file mode 100755 index 00000000000..806a45caf6d --- /dev/null +++ b/htdocs/custom/multicompany/admin/options.php @@ -0,0 +1,494 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file multicompany/admin/parameters.php + * \ingroup multicompany + * \brief Page d'administration/configuration du module Multi-Company + */ + +$res=@include("../../main.inc.php"); // For root directory +if (! $res && file_exists($_SERVER['DOCUMENT_ROOT']."/main.inc.php")) + $res=@include($_SERVER['DOCUMENT_ROOT']."/main.inc.php"); // Use on dev env only +if (! $res) $res=@include("../../../main.inc.php"); // For "custom" directory + +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +dol_include_once('/multicompany/class/actions_multicompany.class.php', 'ActionsMulticompany'); + +$langs->loadLangs(array('admin', 'multicompany@multicompany')); + +// Security check +if (empty($user->admin) || ! empty($user->entity)) { + accessforbidden(); +} + +$action=GETPOST('action','alpha'); + +$object = new ActionsMulticompany($db); + + +/* + * Action + */ + + +/* + * View + */ + +$extrajs = array( + '/multicompany/core/js/lib_head.js' +); + +$help_url='EN:Module_MultiCompany|FR:Module_MultiSociété'; +llxHeader('', $langs->trans("MultiCompanySetup"), $help_url,'','','',$extrajs); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("MultiCompanySetup"),$linkback,'multicompany@multicompany',0,'multicompany_title'); + +$head = multicompany_prepare_head(); +dol_fiche_head($head, 'options', $langs->trans("ModuleSetup"), -1); + +$level = checkMultiCompanyVersion(); +if ($level === 1 || $level === -1) +{ + $text = $langs->trans("MultiCompanyIsOlderThanDolibarr"); + if ($level === -1) $text = $langs->trans("DolibarrIsOlderThanMulticompany"); + + print '
'; + dol_htmloutput_mesg($text, '', 'warning', 1); + print '
'; + +} + +$form=new Form($db); + +$hidden=true; +$checkconfig = checkMulticompanyAutentication(); +if ($checkconfig !== true) { + if (! empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX)) { + $hidden=false; + } + print ''; +} else { + if (empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX)) { + $hidden=false; + } + print ''; +} + +print ''; +print ''; +print ''."\n"; +print ''; +print ''."\n"; +print ''; + +/* + * System parameters + */ + +// Login page combobox activation +print ''; +print ''; +print ''; +print ''; + +// Replace entity logo in login page +print 'global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX) ? ' style="display:none;"' : '').'>'; +print ''; +print ''; + +print ''; + +// Replace entity background in login page +print 'global->MULTICOMPANY_LOGIN_LOGO_BY_ENTITY) ? ' style="display:none;"' : '').'>'; +print ''; +print ''; +print ''; + +// Disable the new dropdown menu +print ''; +print ''; +print ''; +print ''; + +// Hide/View top menu entity label +print ''; +print ''; +print ''; +print ''; + +// Active by default during create +print ''; +print ''; +print ''; +print ''; + +// Visible by default during create +print 'global->MULTICOMPANY_ACTIVE_BY_DEFAULT) ? ' style="display:none;"' : '').'>'; +print ''; +print ''; +print ''; + +// Template management +$text = img_picto('', 'info','class="linkobject"'); +$htmltext = $langs->trans("TemplateOfEntityManagementInfo"); + +print ''; +print ''; +print ''; +print ''; + +/* + * Sharings parameters + */ +print ''; +print ''."\n"; +print ''; +print ''."\n"; +print ''; + +/* Mode de gestion des droits : + * Mode Off : mode Off : pyramidale. Les droits et les groupes sont gérés dans chaque entité : les utilisateurs appartiennent au groupe de l'entity pour obtenir leurs droits + * Mode On : mode On : transversale : Les groupes ne peuvent appartenir qu'a l'entity = 0 et c'est l'utilisateur qui appartient à tel ou tel entity + */ + +$text = img_picto('', 'info','class="linkobject"'); +$htmltext = $langs->trans("GroupModeTransversalInfoFull"); + +print ''; +print ''; +print ''; + +print ''; + +// Enable global sharings +if (! empty($conf->societe->enabled) + || ! empty($conf->product->enabled) + || ! empty($conf->service->enabled) + || ! empty($conf->categorie->enabled) + || ! empty($conf->adherent->enabled) + || ! empty($conf->agenda->enabled)) +{ + print ''; + print ''; + print ''; + + print ''; +} + +$text = img_picto('', 'info','class="linkobject"'); +$htmltext = $langs->trans("GlobalSharingsInfo"); + +print 'global->MULTICOMPANY_SHARINGS_ENABLED) ? ' style="display:none;"' : '').'>'; +print ''."\n"; +print ''; +print ''."\n"; +print ''; + +// Share thirparties and contacts +if (! empty($conf->societe->enabled)) +{ + print 'global->MULTICOMPANY_SHARINGS_ENABLED) ? ' style="display:none;"' : '').'>'; + print ''; + print ''; + + print ''; +} + +// Elements sharings +$text = img_picto('', 'info','class="linkobject"'); + +foreach ($object->sharingelements as $element => $params) +{ + if (! isset($params['disable']) && $params['type'] === 'element') + { + $tooltip = null; + $display = ! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED); + $module = ((isset($object->sharingmodulename[$element]) && !empty($object->sharingmodulename[$element])) ? $object->sharingmodulename[$element] : $element); + $enabled = (! empty($params['enable']) ? dol_eval($params['enable'], 1) : $conf->$module->enabled); + if (! empty($enabled)) + { + $icon = (! empty($params['icon'])?$params['icon']:'cogs'); + + if (! empty($params['lang'])) { + $langs->load($params['lang']); + } + + if (! empty($params['tooltip'])) { + $htmltext = $langs->trans($params['tooltip']); + $tooltip = $form->textwithtooltip('', $htmltext, 2, 1, $text); + } + + if (! empty($params['display'])) { + $display = ($display && dol_eval($params['display'], 1)); + } + + $display = ($display ? '' : ' style="display:none;"'); + + print ''; + print ''; + print ''; + + print ''; + } + } +} + +// Objects sharings +$text = img_picto('', 'info','class="linkobject"'); +$htmltext = $langs->trans("ObjectSharingsInfo"); +$display=(! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) && ! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED) ? '' : ' style="display:none;"'); +print ''; +print ''."\n"; +print ''; +print ''."\n"; +print ''; + +foreach ($object->sharingelements as $element => $params) +{ + if (! isset($params['disable']) && ($params['type'] === 'object' || $params['type'] === 'objectnumber')) + { + $tooltip = null; + $display = ! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED); + $module = ((isset($object->sharingmodulename[$element]) && !empty($object->sharingmodulename[$element])) ? $object->sharingmodulename[$element] : $element); + $enabled = (! empty($params['enable']) ? dol_eval($params['enable'], 1) : $conf->$module->enabled); + if (! empty($enabled)) + { + $icon = (! empty($params['icon'])?$params['icon']:'cogs'); + + if (! empty($params['lang'])) { + $langs->load($params['lang']); + } + + if (! empty($params['tooltip'])) { + $htmltext = $langs->trans($params['tooltip']); + $tooltip = $form->textwithtooltip('', $htmltext, 2, 1, $text); + } + + if (! empty($params['display'])) { + $display = ($display && dol_eval($params['display'], 1)); + } + + $display = ($display ? '' : ' style="display:none;"'); + + print ''; + print ''; + print ''; + + print ''; + } + } +} + +// Dictionnaries +if (1==2 && ! empty($object->sharingdicts)) +{ + $text = img_picto('', 'info','class="linkobject"'); + $htmltext = $langs->trans("DictsSharingsInfo"); + + print ''; + print ''."\n"; + print ''; + print ''."\n"; + print ''; + + foreach ($object->sharingdicts as $dict => $data) + { + print ''; + print ''; + print ''; + + print ''; + } +} + +print '
'.$langs->trans("Parameters").' '.$langs->trans("Value").'
'.$langs->trans("HideLoginCombobox").' '; +if ($checkconfig !== true) { + $input = array( + 'showhide' => array( + '#mc_hide_login_combobox_error' + ) + ); +} else { + $input = array( + 'hideshow' => array( + '#dol_hide_login_combobox_error' + ) + ); +} +$input['hideshow'][] = '#changeloginlogo'; +$input['hideshow'][] = '#changeloginbackground'; +$input['del'] = array('MULTICOMPANY_LOGIN_LOGO_BY_ENTITY', 'MULTICOMPANY_LOGIN_BACKGROUND_BY_ENTITY'); +print ajax_mcconstantonoff('MULTICOMPANY_HIDE_LOGIN_COMBOBOX', $input, 0); +print '
'.$langs->trans("EntityBackgroundInLoginPage").' '; +print ajax_mcconstantonoff('MULTICOMPANY_LOGIN_BACKGROUND_BY_ENTITY', '', 0); +print '
'.$langs->trans("DisableSwitchEntityDropdownMenu").' '; +$input = array( + 'reload' => true +); +print ajax_mcconstantonoff('MULTICOMPANY_DROPDOWN_MENU_DISABLED', $input, 0); +print '
'.$langs->trans("ShowTopMenuEntityLabel").' '; +$input = array( + 'reload' => true +); +print ajax_mcconstantonoff('MULTICOMPANY_NO_TOP_MENU_ENTITY_LABEL', $input, 0, 1); +print '
'.$langs->trans("EntityActiveByDefault").' '; +$input = array( + 'showhide' => array( + '#visiblebydefault' + ), + 'del' => array( + 'MULTICOMPANY_VISIBLE_BY_DEFAULT' + ) +); +print ajax_mcconstantonoff('MULTICOMPANY_ACTIVE_BY_DEFAULT', $input, 0); +print '
'.$langs->trans("EntityVisibleByDefault").' '; +print ajax_mcconstantonoff('MULTICOMPANY_VISIBLE_BY_DEFAULT', '', 0); +print '
'.$langs->trans("TemplateOfEntityManagement").' '.$form->textwithtooltip('',$htmltext,2,1,$text).' '; +print ajax_mcconstantonoff('MULTICOMPANY_TEMPLATE_MANAGEMENT', '', 0); +print '
'.$langs->trans("Parameters").' '.$langs->trans("Value").'
'.$langs->trans("GroupModeTransversal").' '.$form->textwithtooltip('',$htmltext,2,1,$text).' '; +$input = array( + 'alert' => array( + 'set' => array( + 'info' => true, + 'height' => 200, + 'yesButton' => $langs->trans('Ok'), + 'title' => $langs->transnoentities('GroupModeTransversalTitle'), + 'content' => img_warning().' '.$langs->trans('GroupModeTransversalInfo') + ) + ) +); +print ajax_mcconstantonoff('MULTICOMPANY_TRANSVERSE_MODE', $input, 0); +print '
'.$langs->trans("EnableGlobalSharings").' '; + $input = array( + 'alert' => array( + 'set' => array( + 'info' => true, + 'yesButton' => $langs->trans('Ok'), + 'title' => $langs->transnoentities('GlobalSharings'), + 'content' => img_warning().' '.$langs->trans('GlobalSharingsInfo') + ) + ), + 'showhide' => array( + '#shareelementtitle', + '#sharethirdparty' + ), + 'hide' => array( + '#shareelementtitle', + '#shareobjecttitle', + '#sharethirdparty' + ), + 'del' => array( + 'MULTICOMPANY_THIRDPARTY_SHARING_ENABLED' + ) + ); + foreach ($object->sharingelements as $key => $values) + { + if (! isset($values['disable'])) { + if (isset($values['input']) && isset($values['input']['global'])) { + if (isset($values['input']['global']['showhide']) && $values['input']['global']['showhide'] === true) { + if (! isset($input['showhide'])) $input['showhide'] = array(); + array_push($input['showhide'], '#share'.$key); + } + if (isset($values['input']['global']['hide']) && $values['input']['global']['hide'] === true) { + if (! isset($input['hide'])) $input['hide'] = array(); + array_push($input['hide'], '#share'.$key); + } + if (isset($values['input']['global']['del']) && $values['input']['global']['del'] === true) { + if (! isset($input['del'])) $input['del'] = array(); + array_push($input['del'], 'MULTICOMPANY_'.strtoupper($key).'_SHARING_ENABLED'); + } + } + } + } + print ajax_mcconstantonoff('MULTICOMPANY_SHARINGS_ENABLED', $input, 0); + print '
'.$langs->trans("ActivatingShares").' '.$form->textwithtooltip('',$htmltext,2,1,$text).' '.$langs->trans("Value").'
'.$langs->trans("ShareThirdpartiesAndContacts").' '; + $input = array( + 'showhide' => array( + '#shareobjecttitle' + ) + ); + foreach ($object->sharingelements as $key => $values) + { + if (! isset($values['disable']) && ($values['type'] === 'object' || $values['type'] === 'objectnumber')) + { + if (isset($values['input']) && isset($values['input']['thirdparty'])) { + if (isset($values['input']['thirdparty']['showhide']) && $values['input']['thirdparty']['showhide'] === true) { + if (! isset($input['showhide'])) $input['showhide'] = array(); + array_push($input['showhide'], '#share'.$key); + } + if (isset($values['input']['thirdparty']['hide']) && $values['input']['thirdparty']['hide'] === true) { + if (! isset($input['hide'])) $input['hide'] = array(); + array_push($input['hide'], '#share'.$key); + } + if (isset($values['input']['thirdparty']['del']) && $values['input']['thirdparty']['del'] === true) { + if (! isset($input['del'])) $input['del'] = array(); + array_push($input['del'], 'MULTICOMPANY_'.strtoupper($key).'_SHARING_ENABLED'); + } + } + } + } + print ajax_mcconstantonoff('MULTICOMPANY_THIRDPARTY_SHARING_ENABLED', $input, 0); + print '
'; + print ''.$langs->trans("Share".ucfirst($element)).(! empty($tooltip) ? ' '.$tooltip : '').' '; + + $input = array(); + foreach ($object->sharingelements as $key => $values) { + if (! isset($values['disable']) && isset($values['input']) && isset($values['input'][$element])) { + if (isset($values['input'][$element]['showhide']) && $values['input'][$element]['showhide'] === true) { + if (! isset($input['showhide'])) $input['showhide'] = array(); + array_push($input['showhide'], '#share'.$key); + } + if (isset($values['input'][$element]['hide']) && $values['input'][$element]['hide'] === true) { + if (! isset($input['hide'])) $input['hide'] = array(); + array_push($input['hide'], '#share'.$key); + } + if (isset($values['input'][$element]['del']) && $values['input'][$element]['del'] === true) { + if (! isset($input['del'])) $input['del'] = array(); + array_push($input['del'], 'MULTICOMPANY_'.strtoupper($key).'_SHARING_ENABLED'); + } + } + } + + print ajax_mcconstantonoff('MULTICOMPANY_'.strtoupper($element).'_SHARING_ENABLED', $input, 0); + print '
'.$langs->trans("ActivatingObjectShares").' '.$form->textwithtooltip('', $htmltext, 2, 1, $text).' '.$langs->trans("Value").'
'; + print ''.$langs->trans("Share".ucfirst($element)).(! empty($tooltip) ? ' '.$tooltip : '').' '; + $input = array(); + print ajax_mcconstantonoff('MULTICOMPANY_'.strtoupper($element).'_SHARING_ENABLED', $input, 0); + print '
'.$langs->trans("ActivatingDictsShares").' '.$form->textwithtooltip('',$htmltext,2,1,$text).' '.$langs->trans("Value").'
'.$langs->trans("Share".ucfirst($dict)).' '; + print ajax_mcconstantonoff('MULTICOMPANY_'.strtoupper($dict).'_SHARING_DISABLED', '', 0); + print '
'; + +// Card end +dol_fiche_end(); +// Footer +llxFooter(); +// Close database handler +$db->close(); diff --git a/htdocs/custom/multicompany/admin/tpl/caches.tpl.php b/htdocs/custom/multicompany/admin/tpl/caches.tpl.php new file mode 100755 index 00000000000..8e4357cd6f7 --- /dev/null +++ b/htdocs/custom/multicompany/admin/tpl/caches.tpl.php @@ -0,0 +1,118 @@ + + * + * 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 . + * + */ +global $form; +?> + + +
+
"> +
trans("MulticompanySession"); ?>
trans('MulticompanySessionDescription'); ?>

+
+
+
+
+ array('MULTICOMPANY_MEMCACHED_ENABLED','MULTICOMPANY_SHMOP_ENABLED'), + 'disabled' => array('MULTICOMPANY_MEMCACHED_SERVER') + ); + echo ajax_mcconstantonoff('MULTICOMPANY_SESSION_ENABLED', $input, 0); + ?> +
+
+
+ +
+
"> +
trans("MulticompanyMemcached"); ?>
trans('MulticompanyMemcachedDescription'); ?>

+
+
+ global->MULTICOMPANY_MEMCACHED_SERVER)?$conf->global->MULTICOMPANY_MEMCACHED_SERVER:(!empty($conf->global->MEMCACHED_SERVER)?$conf->global->MEMCACHED_SERVER:'127.0.0.1:11211')); + + $tmparray=explode(':',$serveraddress); + $server=$tmparray[0]; + $port=$tmparray[1]?$tmparray[1]:11211; + + $result=$m->addServer($server, $port); + $arraycache=$m->getStats(); + + if (is_array($arraycache)) + echo $form->textwithtooltip('',$langs->trans("MemcachedServerIsReady"),2,1,img_picto('','tick'),'',3); + else + echo $form->textwithtooltip('',$langs->trans("MemcachedServerIsNotReady"),2,1,img_warning(''),'',3); + + echo ' global->MULTICOMPANY_MEMCACHED_ENABLED) ? ' disabled="disabled"' : '').' />'; + } + else + echo img_warning($langs->trans("MulticompanyMemcachedUnavailable")).' '.$langs->trans("MulticompanyMemcachedUnavailable"); + ?> +
+
+
+ array('MULTICOMPANY_SHMOP_ENABLED','MULTICOMPANY_SESSION_ENABLED'), + 'disabledenabled' => array('MULTICOMPANY_MEMCACHED_SERVER') + ); + echo ajax_mcconstantonoff('MULTICOMPANY_MEMCACHED_ENABLED', $input, 0); + } + else + echo ''.img_picto($langs->trans("Disabled"),'switch_off', 'class="button-not-allowed"').''; + ?> +
+
+
+ +
+
"> +
trans("MulticompanyShmop"); ?>
trans('MulticompanyShmopDescription'); ?>

+
+
+ trans("MulticompanyShmopAvailable"),'tick').' '.$langs->trans("MulticompanyShmopAvailable"); + else + echo img_warning($langs->trans("MulticompanyShmopUnavailable")).' '.$langs->trans("MulticompanyShmopUnavailable"); + ?> +
+
+
+ array('MULTICOMPANY_MEMCACHED_ENABLED','MULTICOMPANY_SESSION_ENABLED'), + 'disabled' => array('MULTICOMPANY_MEMCACHED_SERVER') + ); + echo ajax_mcconstantonoff('MULTICOMPANY_SHMOP_ENABLED', $input, 0); + } + else + echo ''.img_picto($langs->trans("Disabled"),'switch_off', 'class="button-not-allowed"').''; + ?> +
+
+
+ \ No newline at end of file diff --git a/htdocs/custom/multicompany/admin/tpl/card.tpl.php b/htdocs/custom/multicompany/admin/tpl/card.tpl.php new file mode 100755 index 00000000000..b41ff737d7c --- /dev/null +++ b/htdocs/custom/multicompany/admin/tpl/card.tpl.php @@ -0,0 +1,386 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ +?> + + + +
" method="POST"> + + +tpl['action'] === 'create') { ?> + + + + + + + + + + + + + + + + + + + +global->MULTICOMPANY_TEMPLATE_MANAGEMENT)) { + if ($this->tpl['action'] === 'create') { ?> + + + + + + + + +tpl['template'] === 1) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +tpl['extrafields']->attribute_label)) { + print $this->dao->showOptionals($this->tpl['extrafields'], 'edit'); +} +if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) { + +foreach($this->sharingelements as $element => $params) { + if ($params['type'] === 'element' && ! empty($this->tpl['multiselect_from_' . $element])) { + $uppername = strtoupper($element); + $icon = (! empty($params['icon'])?$params['icon']:'edit'); +?> + + + + + + + +global->MULTICOMPANY_TEMPLATE_MANAGEMENT)) { ?> + + + + + + + + + +sharingelements as $element => $params) { + if ($params['type'] !== 'element' && ! empty($this->tpl['multiselect_from_' . $element])) { + $uppername = strtoupper($element); + $icon = (! empty($params['icon'])?$params['icon']:'edit'); +?> + + + + + + + + +global->MULTICOMPANY_PROPOSALNUMBER_SHARING_ENABLED)) { ?> + + + + + + + +global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) { ?> + + + + + + + +global->MULTICOMPANY_TEMPLATE_MANAGEMENT)) { ?> + + + + + + + + + +
trans("CompanyInfo"); ?>trans("Value"); ?>
trans("Label"); ?>
trans("CompanyName"); ?>
trans("TemplateOfCompany"); ?>tpl['template']; ?>
trans("SelectTemplateOfCompany"); ?>tpl['select_template']; ?>
trans("WarningThisIsATemplate"); ?>
trans("CompanyAddress"); ?>
trans("CompanyZip"); ?>tpl['select_zip']; ?>
trans("CompanyTown"); ?>tpl['select_town']; ?>
trans("Country"); ?>tpl['select_country'].$this->tpl['info_admin']; ?>
trans("State"); ?>tpl['select_state']; ?>
trans("CompanyCurrency"); ?>tpl['select_currency']; ?>
trans("DefaultLanguage"); ?>tpl['select_language']; ?>
trans("Description"); ?>
trans($uppername . "Sharing"); ?>
trans($uppername . "SharingDescription"); ?> +
+
+
trans("EntitiesSelected"); ?>
+ tpl['multiselect_to_' . $element]; ?> +
+
+ + + + + + +
+
+
trans("EntitiesAvailable"); ?>
+ tpl['multiselect_from_' . $element]; ?> +
+
+
trans("AddNewEntityInAllOtherEntities"); ?>tpl['addtoallother_' . $element]; ?>
 
trans($uppername . "Sharing"); ?>
trans($uppername . "SharingDescription"); ?> +
+
+
trans("EntitiesSelected"); ?>
+ tpl['multiselect_to_' . $element]; ?> +
+
+ + + + + + +
+
+
trans("EntitiesAvailable"); ?>
+ tpl['multiselect_from_' . $element]; ?> +
+
+
trans("ReferringEntityForProposalNumber"); ?>tpl['select_proposalnumber_entity']; ?>
 
trans("ReferringEntityForInvoiceNumber"); ?>tpl['select_invoicenumber_entity']; ?>
 
trans("AddNewEntityInAllOtherEntities"); ?>tpl['addtoallother_' . $element]; ?>
 
+ + +
+tpl['action'] === 'create') { ?> + +" /> + + + +" /> + +" /> +
+ +
+ + diff --git a/htdocs/custom/multicompany/admin/tpl/index.html b/htdocs/custom/multicompany/admin/tpl/index.html new file mode 100755 index 00000000000..e69de29bb2d diff --git a/htdocs/custom/multicompany/admin/tpl/list.tpl.php b/htdocs/custom/multicompany/admin/tpl/list.tpl.php new file mode 100755 index 00000000000..81d297f88bc --- /dev/null +++ b/htdocs/custom/multicompany/admin/tpl/list.tpl.php @@ -0,0 +1,230 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +dol_include_once('/multicompany/admin/tpl/switch.tpl.php'); + +$colHidden = (! empty($conf->global->MULTICOMPANY_COLHIDDEN) ? implode(",", json_decode($conf->global->MULTICOMPANY_COLHIDDEN, true)) : null); +$colOrder = (! empty($conf->global->MULTICOMPANY_COLORDER) ? json_decode($conf->global->MULTICOMPANY_COLORDER, true) : array('id' => 0, 'direction' => 'asc')); + +$columns = array(); + +$columns['id'] = array( + 'label' => 'ID', + 'sortable' => true, + 'searchable' => true, + 'priority' => 12, + 'center' => 'dt-center' +); +$columns['label'] = array( + 'label' => 'Label', + 'sortable' => true, + 'searchable' => true, + 'priority' => 1, +); +$columns['description'] = array( + 'label' => 'Description', + 'sortable' => true, + 'searchable' => true, + 'priority' => 11, +); +$columns['name'] = array( + 'label' => 'Name', + 'priority' => 10, + 'center' => 'dt-center' +); +$columns['zip'] = array( + 'label' => 'Zip', + 'priority' => 9, + 'center' => 'dt-center' +); +$columns['town'] = array( + 'label' => 'Town', + 'priority' => 8, + 'center' => 'dt-center' +); +$columns['country'] = array( + 'label' => 'Country', + 'priority' => 7, + 'center' => 'dt-center' +); +$columns['currency'] = array( + 'label' => 'Currency', + 'priority' => 6, + 'center' => 'dt-center' +); +$columns['language'] = array( + 'label' => 'DefaultLanguageShort', + 'priority' => 5, + 'center' => 'dt-center' +); +if (! empty($this->tpl['extrafields']->attribute_label)) { + foreach ($this->tpl['extrafields']->attribute_label as $key => $value) + { + $columns[$key] = array( + 'label' => $value, + 'center' => 'dt-center' + ); + } +} +$columns['visible'] = array( + 'label' => 'Visible', + 'width' => '20px', + 'priority' => 3, + 'center' => 'dt-center' +); +$columns['active'] = array( + 'label' => 'Status', + 'width' => '20px', + 'priority' => 2, + 'center' => 'dt-center' +); +$columns['tools'] = array( + 'label' => 'Tools', + 'width' => '50px', + 'priority' => 4, + 'center' => 'dt-center' +); + +//var_dump($columns); + +?> + + + + + + + $values) { + //$moreattr = (! empty($values['priority'])?'data-priority="'.$values['priority'].'"':''); + echo getTitleFieldOfList($values['label'], 1, '', '', '', '', $moreattr, '', '', 'entity_' . $key . ' '); + } + ?> + + + + + + + +
trans('LoadingDataFromServer'); ?>
+ + \ No newline at end of file diff --git a/htdocs/custom/multicompany/admin/tpl/switch.tpl.php b/htdocs/custom/multicompany/admin/tpl/switch.tpl.php new file mode 100755 index 00000000000..4261a0ef6c2 --- /dev/null +++ b/htdocs/custom/multicompany/admin/tpl/switch.tpl.php @@ -0,0 +1,122 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ +?> + + +
+

trans('ConfirmDeleteEntity'); ?>

+
+ + \ No newline at end of file diff --git a/htdocs/custom/multicompany/class/actions_multicompany.class.php b/htdocs/custom/multicompany/class/actions_multicompany.class.php new file mode 100755 index 00000000000..f73d69db5bd --- /dev/null +++ b/htdocs/custom/multicompany/class/actions_multicompany.class.php @@ -0,0 +1,4608 @@ + + * Copyright (C) 2011 Herve Prot + * Copyright (C) 2014 Philippe Grand + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/multicompany/actions_multicompany.class.php + * \ingroup multicompany + * \brief File Class multicompany + */ + +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +dol_include_once('/multicompany/class/dao_multicompany.class.php', 'DaoMulticompany'); +dol_include_once('/multicompany/lib/multicompany.lib.php'); + +/** + * Class Actions of the module multicompany + */ +class ActionsMulticompany +{ + /** @var DoliDB */ + var $db; + /** @var DaoMulticompany */ + var $dao; + + var $mesg; + var $error; + var $errors=array(); + //! Numero de l'erreur + var $errno = 0; + + var $template_dir; + var $template; + + var $label; + var $description; + + var $referent; + + var $sharings=array(); + var $options=array(); + var $entities=array(); + var $dict=array(); + var $tpl=array(); + + var $addzero=array(); + var $sharingelements=array(); + var $sharingobjects=array(); + var $sharingdicts=array(); + + private $config=array(); + + // For Hookmanager return + var $resprints; + var $results=array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf; + + $this->db = $db; + + $this->addzero = array( + 'user', + 'usergroup', + 'c_email_templates', + 'email_template', + 'default_values' + ); + + // Default sharing elements + $this->sharingelements = array( + 'thirdparty' => array( + 'type' => 'element', + 'icon' => 'building', + 'active' => true, // for setEntity() function + 'disable' => true // disable in options tab + ), + 'member' => array( + 'type' => 'element', + 'icon' => 'address-card', + 'input' => array( + 'global' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ) + ), + 'member_type' => array( + 'type' => 'element', + 'icon' => 'address-card', + 'display' => '! empty($conf->global->MULTICOMPANY_MEMBER_SHARING_ENABLED)', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ), + 'member' => array( + 'showhide' => true, + 'del' => true + ) + ) + ), + 'product' => array( + 'type' => 'element', + 'icon' => 'cube', + 'tooltip' => 'ProductSharingInfo', + 'enable' => '(! empty($conf->product->enabled) || ! empty($conf->service->enabled))', + 'input' => array( + 'global' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ), + 'active' => true + ), + 'productprice' => array( + 'type' => 'element', + 'icon' => 'money', + 'tooltip' => 'ProductPriceSharingInfo', + 'enable' => '(! empty($conf->product->enabled) || ! empty($conf->service->enabled))', + 'display' => '! empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED)', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ), + 'product' => array( + 'showhide' => true, + 'del' => true + ) + ) + ), + 'productsupplierprice' => array( + 'type' => 'element', + 'icon' => 'money', + 'enable' => '((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ! empty($conf->fournisseur->enabled))', + 'display' => '! empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED)', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ), + 'product' => array( + 'showhide' => true, + 'del' => true + ) + ), + ), + 'stock' => array( + 'type' => 'element', + 'icon' => 'cubes', + //'tooltip' => 'SharingStockInfo', + 'enable' => '(! empty($conf->stock->enabled) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))', + 'display' => '! empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED)', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ), + 'product' => array( + 'showhide' => true, + 'del' => true + ) + ) + ), + 'category' => array( + 'type' => 'element', + 'icon' => 'paperclip', + 'input' => array( + 'global' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ) + ), + 'agenda' => array( + 'type' => 'element', + 'icon' => 'calendar', + 'input' => array( + 'global' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ) + ), + 'bankaccount' => array( + 'type' => 'element', + 'icon' => 'bank', + 'input' => array( + 'global' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ) + ), + 'expensereport' => array( + 'type' => 'element', + 'icon' => 'edit', + 'input' => array( + 'global' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ) + ), + 'holiday' => array( + 'type' => 'element', + 'icon' => 'paper-plane-o', + 'input' => array( + 'global' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ) + ), + 'project' => array( + 'type' => 'element', + 'icon' => 'code-fork', + 'input' => array( + 'global' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ) + ), + + // Object + + 'proposal' => array( + 'type' => 'object', + 'icon' => 'file-pdf-o', + 'mandatory' => 'thirdparty', + 'enable' => '(! empty($conf->propal->enabled) && ! empty($conf->societe->enabled))', + 'display' => '! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED)', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ), + 'thirdparty' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ), + 'active' => true + ), + 'proposalnumber' => array( + 'type' => 'objectnumber', + 'icon' => 'cogs', + 'mandatory' => 'thirdparty', + 'tooltip' => 'ProposalNumberSharingInfo', + 'enable' => '(! empty($conf->propal->enabled) && ! empty($conf->societe->enabled))', + 'display' => '! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED)', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ), + 'thirdparty' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ) + ), + 'order' => array( + 'type' => 'object', + 'icon' => 'file-pdf-o', // Font Awesome icon + 'mandatory' => 'thirdparty', + 'enable' => '(! empty($conf->commande->enabled) && ! empty($conf->societe->enabled))', + 'display' => '! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED)', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ), + 'thirdparty' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ), + 'active' => true, + //'disable' => true // Disable if not stable + ), + 'ordernumber' => array( + 'type' => 'objectnumber', + 'icon' => 'cogs', + 'mandatory' => 'thirdparty', + 'tooltip' => 'OrderNumberSharingInfo', + 'enable' => '(! empty($conf->commande->enabled) && ! empty($conf->societe->enabled))', + 'display' => '! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED)', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ), + 'thirdparty' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ), + //'disable' => true + ), + 'invoice' => array( + 'type' => 'object', + 'icon' => 'file-pdf-o', + 'mandatory' => 'thirdparty', + 'enable' => '(! empty($conf->facture->enabled) && ! empty($conf->societe->enabled))', + 'display' => '! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED)', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ), + 'thirdparty' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ), + 'active' => true + ), + 'invoicenumber' => array( + 'type' => 'objectnumber', + 'icon' => 'cogs', + 'mandatory' => 'thirdparty', + 'tooltip' => 'InvoiceNumberSharingInfo', + 'enable' => '(! empty($conf->facture->enabled) && ! empty($conf->societe->enabled))', + 'display' => '! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED)', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ), + 'thirdparty' => array( + 'showhide' => true, + 'hide' => true, + 'del' => true + ) + ) + ), + 'supplier_proposal' => array( + 'type' => 'object', + 'icon' => 'file-pdf-o', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ) + ), + 'disable' => true + ), + 'supplier_order' => array( + 'type' => 'object', + 'icon' => 'file-pdf-o', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ) + ), + 'disable' => true + ), + 'supplier_invoice' => array( + 'type' => 'object', + 'icon' => 'file-pdf-o', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ) + ), + 'disable' => true + ), + 'intervention' => array( + 'type' => 'object', + 'icon' => 'wrench', + 'input' => array( + 'global' => array( + 'hide' => true, + 'del' => true + ) + ), + 'disable' => true + ) + ); + + // Module name if different of object name (eg $conf->commande->enabled) + $this->sharingmodulename = array( + 'thirdparty' => 'societe', + 'proposal' => 'propal', + 'proposalnumber' => 'propal', + 'order' => 'commande', + 'ordernumber' => 'commande', + 'invoice' => 'facture', + 'invoicenumber' => 'facture', + 'product' => (empty($conf->product->enabled) && !empty($conf->service->enabled) ? 'service' : 'product'), + 'productprice' => 'product', + 'productsupplierprice' => 'product', + 'project' => 'projet', + 'member' => 'adherent', + 'membertype' => 'adherent', + 'member_type' => 'adherent', // deprecated + //'membertype' => 'member_type', // deprecated + 'intervention' => 'ficheinter', + 'category' => 'categorie', + 'bankaccount' => 'banque', + 'bank_account' => 'banque', // deprecated + //'bankaccount' => 'banque_account', // deprecated + ); + + $this->sharingdicts = array( + 'c_paiement' => array( + 'societe' => array( + 'mode_reglement', + 'mode_reglement_supplier' + ), + 'propal' => 'fk_mode_reglement', + 'commande' => 'fk_mode_reglement', + 'facture' => 'fk_mode_reglement', + 'facture_rec' => 'fk_mode_reglement', + 'commande_fournisseur' => 'fk_mode_reglement', + 'facture_fourn' => 'fk_mode_reglement', + 'supplier_proposal' => 'fk_mode_reglement', + 'chargesociales' => 'fk_mode_reglement', + 'don' => 'fk_payment', + 'paiement' => 'fk_paiement', + 'paiementfourn' => 'fk_paiement', + 'paiement_facture' => 'fk_paiement', + 'expensereport' => 'fk_c_paiement', + 'paiementcharge' => 'fk_typepaiement', + 'tva' => 'fk_typepayment', + 'payment_various' => 'fk_typepayment', + 'payment_salary' => 'fk_typepayment', + 'payment_expensereport' => 'fk_typepayment', + 'payment_donation' => 'fk_typepayment', + 'loan_schedule' => 'fk_typepayment', + 'payment_loan' => 'fk_typepayment' + ), + 'c_payment_term' => array( + 'societe' => array( + 'cond_reglement', + 'cond_reglement_supplier' + ), + 'propal' => 'fk_cond_reglement', + 'commande' => 'fk_cond_reglement', + 'facture' => 'fk_cond_reglement', + 'facture_rec' => 'fk_cond_reglement', + 'commande_fournisseur' => 'fk_cond_reglement', + 'facture_fourn' => 'fk_cond_reglement', + 'supplier_proposal' => 'fk_cond_reglement' + ) + ); + + if (! empty($conf->global->MULTICOMPANY_EXTERNAL_MODULES_SHARING)) + { + $externalmodules = json_decode($conf->global->MULTICOMPANY_EXTERNAL_MODULES_SHARING, true); + + if (is_array($externalmodules) && ! empty($externalmodules)) + { + foreach($externalmodules as $params) + { + if (is_array($params) && ! empty($params)) + { + if (is_array($params['addzero']) && ! empty($params['addzero'])) { + array_push($this->addzero, $params['addzero']); + } + + if (is_array($params['sharingelements']) && ! empty($params['sharingelements'])) { + $this->sharingelements = array_merge($this->sharingelements, $params['sharingelements']); + } + + if (is_array($params['sharingmodulename']) && ! empty($params['sharingmodulename'])) + { + $this->sharingmodulename = array_merge($this->sharingmodulename, $params['sharingmodulename']); + } + } + } + } + } + } + + /** + * Instantiation of DAO class + * + * @return void + */ + private function getInstanceDao() + { + if (! is_object($this->dao)) + { + $this->dao = new DaoMulticompany($this->db); + } + } + + + /** + * setHtmlTitle + * + * @param array $parameters Hook metadatas (context, etc...) + */ + public function setHtmlTitle($parameters=false) + { + global $conf; + + if (empty($conf->global->MULTICOMPANY_HIDE_HTML_TITLE)) { + $this->resprints = ' + multicompany'; + } + + return 0; + } + + + /** + * Enter description here ... + * + * @param string $action Action type + */ + public function doAdminActions(&$action='') + { + global $conf, $user, $langs; + + $this->getInstanceDao(); + + $id = GETPOST('id','int'); + $label = GETPOST('label','alpha'); + $name = GETPOST('name','alpha'); + $description = GETPOST('description','alpha'); + $cancel = GETPOST('cancel', 'alpha'); + $addandstay = GETPOST('addandstay', 'alpha'); + $cancelandstay = GETPOST('cancelandstay', 'alpha'); + $updateandstay = GETPOST('updateandstay', 'alpha'); + $template = (empty($conf->global->MULTICOMPANY_TEMPLATE_MANAGEMENT) ? null : GETPOST('template', 'int')); + $usetemplate = (empty($conf->global->MULTICOMPANY_TEMPLATE_MANAGEMENT) ? null : GETPOST('usetemplate', 'int')); + $visible = GETPOST('visible', 'int'); + $active = GETPOST('active', 'int'); + + if ($action === 'add' && empty($cancel) && $user->admin && ! $user->entity) + { + $error=0; + + if (empty($label)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), 'errors'); + $action = 'create'; + } + else if (empty($name)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("CompanyName")), 'errors'); + $action = 'create'; + } + + // Verify if label already exist in database + if (! $error) + { + $this->dao->getEntities(); + if (! empty($this->dao->entities)) + { + foreach($this->dao->entities as $entity) + { + if (strtolower($entity->label) == strtolower($label)) $error++; + } + if ($error) + { + setEventMessage($langs->trans("ErrorEntityLabelAlreadyExist"), 'errors'); + $action = 'create'; + } + } + } + + if (! $error) + { + $this->db->begin(); + + $this->dao->label = $label; + $this->dao->description = $description; + $this->dao->visible = ((! empty($template) && empty($usetemplate)) ? 2 : ((! empty($visible) || ! empty($conf->global->MULTICOMPANY_VISIBLE_BY_DEFAULT)) ? 1 : 0)); + $this->dao->active = ((! empty($active) || ! empty($conf->global->MULTICOMPANY_ACTIVE_BY_DEFAULT))?1:0); + + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) { + $this->dao->options['proposalnumber_referent'] = (GETPOST('proposalnumber_referring_entity', 'int') ? GETPOST('proposalnumber_referring_entity', 'int') : null); + $this->dao->options['invoicenumber_referent'] = (GETPOST('invoicenumber_referring_entity', 'int') ? GETPOST('invoicenumber_referring_entity', 'int') : null); + foreach ($this->sharingelements as $element => $params) { + if ((($params['object'] || $params['objectnumber']) && ! isset($params['disable'])) && (empty($conf->societe->enabled) || empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED))) continue; + $uppername = strtoupper($element); + $constname = 'MULTICOMPANY_' . $uppername . '_SHARING_ENABLED'; + if (! empty($conf->global->$constname)) { + $shareentities = GETPOST($element.'_to', 'array'); + $shareentities = array_unique($shareentities); sort($shareentities); + $this->dao->options['sharings'][$element] = (! empty($shareentities) ? $shareentities : null); + if (! empty($conf->global->MULTICOMPANY_TEMPLATE_MANAGEMENT)) { + $this->dao->options['addtoallother'][$element] = GETPOST('addtoallother_'.$element, 'int'); + } + } + } + } + + $extrafields = new ExtraFields($this->db); + $extralabels = $extrafields->fetch_name_optionals_label($this->dao->table_element, true); + $extrafields->setOptionalsFromPost($extralabels, $this->dao); + + $id = $this->dao->create($user); + if ($id <= 0) + { + $error++; + $errors=($this->dao->error ? array($this->dao->error) : $this->dao->errors); + setEventMessage($errors, 'errors'); + $action = 'create'; + } + + if (! $error && $id > 0) + { + if (! empty($usetemplate) && is_numeric($usetemplate)) + { + $const = $this->dao->getEntityConfig($usetemplate); + if (! empty($const)) + { + // Reload modules + foreach ($const as $key => $value) + { + if (preg_match('/^MAIN\_MODULE\_([0-9A-Z]+)$/', $key, $reg)) + { + if (! empty($reg[1])) + { + $classname = 'mod' . ucfirst(strtolower($reg[1])); + + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/'.$classname.'.class.php'; + + if ($res) { + dol_syslog(get_class($this)."::reloadModules template=".$usetemplate." module=".$key." classname=".$classname, LOG_DEBUG); + $mod=new $classname($this->db); + $mod->init('forceactivate'); + } else { + dol_syslog(get_class($this)."::reloadModules template=".$usetemplate." module=".$key." classname=".$classname, LOG_ERR); + } + } + } + } + + // Overwrite with template + foreach ($const as $key => $value) + { + dolibarr_set_const($this->db, $key, $value, 'chaine', 0, '', $id); + } + } + } + + $country_id = GETPOST('country_id', 'int'); + $country = getCountry($country_id, 'all'); + $country_code = $country['code']; + $country_label = $country['label']; + + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_COUNTRY", $country_id.':'.$country_code.':'.$country_label,'chaine',0,'',$id); + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_NOM",$name,'chaine',0,'',$id); + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_ADDRESS",GETPOST('address', 'alpha'),'chaine',0,'',$id); + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_TOWN",GETPOST('town', 'alpha'),'chaine',0,'',$id); + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_ZIP",GETPOST('zipcode', 'alpha'),'chaine',0,'',$id); + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_STATE",GETPOST('departement_id', 'int'),'chaine',0,'',$id); + dolibarr_set_const($this->db, "MAIN_MONNAIE",GETPOST('currency_code', 'alpha'),'chaine',0,'',$id); + dolibarr_set_const($this->db, "MAIN_LANG_DEFAULT",GETPOST('main_lang_default', 'alpha'),'chaine',0,'',$id); + + if (empty($usetemplate)) + { + $dir = "/multicompany/sql/"; + + // Load sql init_new_entity.sql file + $file = 'init_new_entity_nocrypt.sql'; + if (! empty($conf->db->dolibarr_main_db_encryption) && ! empty($conf->db->dolibarr_main_db_cryptkey)) + { + $file = 'init_new_entity.sql'; + } + $fullpath = dol_buildpath($dir.$file); + + if (file_exists($fullpath)) + { + $result=run_sql($fullpath,1,$id); + } + + $dir = "/multicompany/sql/dict/"; + + foreach($this->sharingdicts as $dict => $data) + { + // Load sql init_new_entity_dict.sql file + $file = 'init_new_entity_'.$dict.'.sql'; + $fullpath = dol_buildpath($dir.$file); + + if (file_exists($fullpath)) + { + $result = run_sql($fullpath, 1, $id); + } + } + } + else + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + + $modulesdir = dolGetModulesDirs(); + + foreach ($modulesdir as $dir) + { + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
"; + $handle=@opendir(dol_osencode($dir)); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + { + $modName = substr($file, 0, dol_strlen($file) - 10); + + if ($modName) + { + include_once $dir."/".$file; + $objMod = new $modName($this->db); + // Load all lang files of module + if (isset($objMod->langfiles) && is_array($objMod->langfiles)) + { + foreach($objMod->langfiles as $domain) + { + $langs->load($domain); + } + } + // Load all permissions + if ($objMod->rights_class) + { + $ret=$objMod->insert_permissions(0, $id); + } + } + } + } + } + } + + // Add entity to all others entities + if (! empty($this->dao->options['addtoallother'])) + { + $this->dao->getEntities(true, array($id), false); + foreach ($this->dao->entities as $entity) + { + if (! is_array($entity->options)) $entity->options = array(); + if (! is_array($entity->options['sharings'])) $entity->options['sharings'] = array(); + + foreach($this->dao->options['sharings'] as $element => $values) + { + if (! is_array($entity->options['sharings'][$element])) $entity->options['sharings'][$element] = array(); + + if ($this->dao->options['addtoallother'][$element] == '1') + { + array_push($entity->options['sharings'][$element], (string) $id); + $entity->update($entity->id, $user); + } + } + } + } + + $listofgroups = $this->dao->getListOfGroups(); + if (! empty($listofgroups)) + { + foreach($listofgroups as $groupid) + { + // Duplicate usergroup rights + $ret = $this->duplicateUserGroupRights($groupid, $usetemplate, array($id)); + if ($ret < 0) $error++; + + // Add users to groups if linked with template + $userslist = $this->dao->getListOfUsersInGroupByTemplate($groupid, $usetemplate); + if ($userslist < 0) $error++; + elseif (! empty($userslist)) + { + foreach($userslist as $usertemplate) + { + $result = $usertemplate->SetInGroup($groupid, $id); + if ($result < 0) + { + $error++; + break; + } + } + } + } + } + } + + if (! $error) + { + $this->db->commit(); + } + else + { + $this->db->rollback(); + } + + if (! empty($addandstay)) + { + header("Location: " . $_SERVER['PHP_SELF'].'?action=edit&id='.$id); + exit; + } + } + else + { + $this->db->rollback(); + } + } + } + else if ($action === 'edit' && $user->admin && ! $user->entity) + { + $error=0; + + if (! empty($cancel)) + { + header("Location: " . $_SERVER['PHP_SELF']); + exit; + } + + if ($this->dao->fetch($id) < 0) + { + $error++; + setEventMessage($langs->trans("ErrorEntityIsNotValid"), 'errors'); + $action = ''; + } + } + else if ($action === 'update' && empty($cancel) && $id > 0 && $user->admin && ! $user->entity) + { + $error=0; + + if (! empty($cancelandstay)) + { + $action = 'edit'; + return; + } + + $ret = $this->dao->fetch($id); + if ($ret < 0) + { + $error++; + setEventMessage($langs->trans("ErrorEntityIsNotValid"), 'errors'); + $action = ''; + } + else if (empty($label)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), 'errors'); + $action = 'edit'; + } + else if (empty($name)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("CompanyName")), 'errors'); + $action = 'edit'; + } + + // Verify if label already exist in database + if (! $error) + { + $this->dao->getEntities(); + if (! empty($this->dao->entities)) + { + foreach($this->dao->entities as $entity) + { + if ($entity->id == $this->dao->id) continue; + if (strtolower($entity->label) == strtolower($label)) $error++; + } + if ($error) + { + setEventMessage($langs->trans("ErrorEntityLabelAlreadyExist"), 'errors'); + $action = 'edit'; + } + } + } + + if (! $error) + { + $this->db->begin(); + + $this->dao->label = $label; + $this->dao->description = $description; + + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) { + $this->dao->options['proposalnumber_referent'] = (GETPOST('proposalnumber_referring_entity', 'int') ? GETPOST('proposalnumber_referring_entity', 'int') : null); + $this->dao->options['invoicenumber_referent'] = (GETPOST('invoicenumber_referring_entity', 'int') ? GETPOST('invoicenumber_referring_entity', 'int') : null); + foreach ($this->sharingelements as $element => $params) { + if ((($params['object'] || $params['objectnumber']) && ! isset($params['disable'])) && (empty($conf->societe->enabled) || empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED))) continue; + $uppername = strtoupper($element); + $constname = 'MULTICOMPANY_' . $uppername . '_SHARING_ENABLED'; + if (! empty($conf->global->$constname)) { + $shareentities = GETPOST($element.'_to', 'array'); + $shareentities = array_unique($shareentities); sort($shareentities); + $this->dao->options['sharings'][$element] = (! empty($shareentities) ? $shareentities : null); + if (! empty($conf->global->MULTICOMPANY_TEMPLATE_MANAGEMENT)) { + $this->dao->options['addtoallother'][$element] = GETPOST('addtoallother_'.$element, 'int'); + } + } + } + } + + $extrafields = new ExtraFields($this->db); + $extralabels = $extrafields->fetch_name_optionals_label($this->dao->table_element, true); + $extrafields->setOptionalsFromPost($extralabels, $this->dao); + + $ret = $this->dao->update($this->dao->id, $user); + if ($ret <= 0) + { + $error++; + $errors=($this->dao->error ? array($this->dao->error) : $this->dao->errors); + setEventMessage($errors, 'errors'); + $action = 'edit'; + } + + if (! $error && $ret > 0) + { + $country_id = GETPOST('country_id', 'int'); + $country = getCountry($country_id, 'all'); + $country_code = $country['code']; + $country_label = $country['label']; + + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_COUNTRY", $country_id.':'.$country_code.':'.$country_label,'chaine',0,'',$this->dao->id); + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_NOM",$name,'chaine',0,'',$this->dao->id); + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_ADDRESS",GETPOST('address', 'alpha'),'chaine',0,'',$this->dao->id); + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_TOWN",GETPOST('town', 'alpha'),'chaine',0,'',$this->dao->id); + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_ZIP",GETPOST('zipcode', 'alpha'),'chaine',0,'',$this->dao->id); + dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_STATE",GETPOST('departement_id', 'int'),'chaine',0,'',$this->dao->id); + dolibarr_set_const($this->db, "MAIN_MONNAIE",GETPOST('currency_code', 'alpha'),'chaine',0,'',$this->dao->id); + dolibarr_set_const($this->db, "MAIN_LANG_DEFAULT",GETPOST('main_lang_default', 'alpha'),'chaine',0,'',$this->dao->id); + + $this->db->commit(); + + if (! empty($updateandstay)) { + $action = 'edit'; + } + } + else + { + $this->db->rollback(); + } + } + } + } + + /** + * Return action of hook + * @param object Linked object + */ + public function doActions($parameters=false, &$object, &$action='') + { + global $conf, $user; + global $mc; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + // Clear constants cache after company infos update + if (is_array($currentcontext)) + { + if ((in_array('admincompany', $currentcontext) || in_array('adminihm', $currentcontext)) && ($action == 'update' || $action == 'updateedit')) + { + clearCache($conf->entity); + clearCache('constants_' . $conf->entity); + } + else if ((in_array('groupcard', $currentcontext) || in_array('groupperms', $currentcontext)) && $object->element == 'usergroup') + { + global $entity; + + // Users/Groups management only in master entity if transverse mode + if ($conf->entity > 1 && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + accessforbidden(); + } + + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $entity=(GETPOST('entity','int') ? GETPOST('entity','int') : $conf->entity); + } else { + $entity=(! empty($object->entity) ? $object->entity : $conf->entity); + } + + // Add/Remove user into group + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && in_array('groupcard', $currentcontext) && ($action == 'adduser' || $action =='removeuser') && (! empty($userid) && $userid > 0) && $caneditperms) + { + if ($action == 'adduser') + { + $entities = GETPOST("entities", "array", 3); + + if (is_array($entities) && ! empty($entities)) + { + $error=0; + + foreach ($entities as $entity_id) + { + $object->fetch($id); + $object->oldcopy = clone $object; + + $edituser = new User($this->db); + $edituser->fetch($userid); + $result=$edituser->SetInGroup($object->id, $entity_id); + if ($result < 0) + { + $error++; + break; + } + } + if (!$error) + { + header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $object->id); + exit; + } + else + { + $this->error = $edituser->error; + $this->errors = $edituser->errors; + return -1; + } + } + } + else if ($action == 'removeuser') + { + $object->fetch($id); + $object->oldcopy = clone $object; + + $edituser = new User($this->db); + $edituser->fetch($userid); + $result=$edituser->RemoveFromGroup($object->id, $entity); + + if ($result > 0) + { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit; + } + else + { + $this->error = $object->error; + $this->errors = $object->errors; + return -1; + } + } + return 1; + } + } + else if ((in_array('usercard', $currentcontext) || in_array('userperms', $currentcontext)) && $object->element == 'user') + { + global $entity, $caneditperms; + + // Users/Groups management only in master entity if transverse mode + if ($conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) + { + if (in_array('usercard', $currentcontext) && ($action == 'create' || $action == 'adduserldap')) { + accessforbidden(); + } else if (in_array('userperms', $currentcontext)) { + $caneditperms = false; + } + } + + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (GETPOSTISSET('entity')) { + + $entity = GETPOST('entity','int'); + + } else { + + $entity = $conf->entity; + + // Check usergroup if user not in master entity + if (in_array('userperms', $currentcontext) && ! empty($user->admin) && empty($user->entity) && $conf->entity == 1) + { + require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; + $group = new UserGroup($this->db); + $ret = $group->listGroupsForUser($object->id, false); + if (! empty(current($ret)->usergroup_entity)) { + sort(current($ret)->usergroup_entity); + if (current($ret)->usergroup_entity[0] > 1) { + $entity = current($ret)->usergroup_entity[0]; + } + } + } + } + } else { + $entity=(! empty($object->entity) ? $object->entity : $conf->entity); + } + + // Action add usergroup + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && in_array('usercard', $currentcontext) && ($action == 'addgroup' || $action == 'removegroup') && (! empty($group) && $group > 0) && $caneditgroup) + { + if ($action == 'addgroup') + { + $entities = GETPOST("entities", "array", 3); + + if (is_array($entities) && ! empty($entities)) + { + $error=0; + + foreach ($entities as $entity_id) + { + $object->fetch($id); + $result = $object->SetInGroup($group, $entity_id); + if ($result < 0) + { + $error++; + break; + } + } + if ($error) + { + $this->error = $object->error; + $this->errors = $object->errors; + return -1; + } + else + { + header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $object->id); + exit; + } + } + } + else if ($action == 'removegroup') + { + $object->fetch($id); + $result = $object->RemoveFromGroup($group, $entity); + if ($result > 0) { + header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $object->id); + exit; + } + else + { + $this->error = $object->error; + $this->errors = $object->errors; + return -1; + } + } + return 1; + } + } + else if (in_array('productcard', $currentcontext) && ($object->element == 'product' || $object->element == 'service')) + { + if ($action != 'create' && $action != 'add') + { + if ($object->entity != $conf->entity) + { + global $usercanread, $usercancreate, $usercandelete; + + /*if (empty($user->rights->multicompany->product->read)) { + $usercanread = false; + }*/ + if (empty($user->rights->multicompany->product->write)) { + $usercancreate = false; + } + if (empty($user->rights->multicompany->product->delete)) { + $usercandelete = false; + } + } + } + } + else if (in_array('propalcard', $currentcontext) && $object->element == 'propal') + { + if ($action != 'create' && $action != 'add') + { + if ($object->entity != $conf->entity) + { + global $usercanread, $usercancreate, $usercandelete, $usercanvalidate, $usercansend, $usercanclose; + global $permissionnote, $permissiondellink, $permissiontoedit; + global $disableedit, $disablemove, $disableremove; + + $this->getInstanceDao(); + + $constants = array( + 'PROPALE_ADDON', + 'PROPALE_SAPHIR_MASK', + 'PROPALE_ADDON_PDF', + 'PROPALE_ADDON_PDF_ODT_PATH' + ); + + if (empty($conf->global->MULTICOMPANY_PROPOSALNUMBER_SHARING_ENABLED) || empty($mc->sharings['proposalnumber'])) // Check if current entity not use the proposalnumber sharing + { + foreach ($constants as $constname) + { + $res = $this->dao->getEntityConfig($object->entity, $constname); + if (! empty($res[$constname])) { + $conf->global->$constname = $res[$constname]; // override current entity config with object entity config + } + } + } + else + { + foreach ($constants as $constname) + { + $referent = (! empty($mc->proposalnumber_referent)?$mc->proposalnumber_referent:1); + $res = $this->dao->getEntityConfig($referent, $constname); + if (! empty($res[$constname])) { + $conf->global->$constname = $res[$constname]; // override current entity config with referent config + } + } + } + + // Override $mysoc with data of object entity + if ($action == 'builddoc') + { + global $mysoc; + + $current = $this->dao->getEntityConfig($conf->entity, 'MAIN_INFO_*'); + if (! empty($current)) + { + foreach($current as $constname => $value) + { + unset($conf->global->$constname); + } + } + + $other = $this->dao->getEntityConfig($object->entity, 'MAIN_INFO_*'); + if (! empty($other)) + { + foreach($other as $constname => $value) + { + $conf->global->$constname = $value; // override current entity config with referent config + } + } + + $mysoc->setMysoc($conf); + } + + if (empty($user->rights->multicompany->propal->read)) { + $usercanread = false; + } + if (empty($user->rights->multicompany->propal->write)) { + $usercancreate = false; + + $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php + $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php + $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php + + // for object lines + $disableedit = true; + $disablemove = true; + $disableremove = true; + } + if (empty($user->rights->multicompany->propal->delete)) { + $usercandelete = false; + } + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->multicompany->propal_advance->validate))) { + $usercanvalidate = false; + } + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($usercanread)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->multicompany->propal_advance->send))) { + $usercansend = false; + } + if (empty($user->rights->multicompany->propal->close)) { + $usercanclose = false; + } + } + } + } + else if (in_array('ordercard', $currentcontext) && $object->element == 'commande') + { + if ($action != 'create' && $action != 'add') + { + if ($object->entity != $conf->entity) + { + global $usercanread, $usercancreate, $usercandelete, $usercanvalidate, $usercansend, $usercanclose, $usercancancel; + global $permissionnote, $permissiondellink, $permissiontoedit; + global $disableedit, $disablemove, $disableremove; + + $this->getInstanceDao(); + + $constants = array( + 'COMMANDE_ADDON', + 'COMMANDE_SAPHIR_MASK', + 'COMMANDE_ADDON_PDF', + 'COMMANDE_ADDON_PDF_ODT_PATH' + ); + + if (empty($conf->global->MULTICOMPANY_ORDERNUMBER_SHARING_ENABLED) || empty($mc->sharings['ordernumber'])) // Check if current entity not use the proposalnumber sharing + { + foreach ($constants as $constname) + { + $res = $this->dao->getEntityConfig($object->entity, $constname); + if (! empty($res[$constname])) { + $conf->global->$constname = $res[$constname]; // override current entity config with object entity config + } + } + } + else + { + foreach ($constants as $constname) + { + $referent = (! empty($mc->ordernumber_referent)?$mc->ordernumber_referent:1); + $res = $this->dao->getEntityConfig($referent, $constname); + if (! empty($res[$constname])) { + $conf->global->$constname = $res[$constname]; // override current entity config with referent config + } + } + } + + // Override $mysoc with data of object entity + if ($action == 'builddoc') + { + global $mysoc; + + $current = $this->dao->getEntityConfig($conf->entity, 'MAIN_INFO_*'); + if (! empty($current)) + { + foreach($current as $constname => $value) + { + unset($conf->global->$constname); + } + } + + $other = $this->dao->getEntityConfig($object->entity, 'MAIN_INFO_*'); + if (! empty($other)) + { + foreach($other as $constname => $value) + { + $conf->global->$constname = $value; // override current entity config with referent config + } + } + + $mysoc->setMysoc($conf); + } + + if (empty($user->rights->multicompany->order->read)) { + $usercanread = false; + } + if (empty($user->rights->multicompany->order->write)) { + $usercancreate = false; + + $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php + $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php + $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php + + // for object lines + $disableedit = true; + $disablemove = true; + $disableremove = true; + } + if (empty($user->rights->multicompany->order->delete)) { + $usercandelete = false; + } + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->multicompany->order_advance->validate))) { + $usercanvalidate = false; + } + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->multicompany->order_advance->cancel))) { + $usercancancel = false; + } + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($usercanread)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->multicompany->order_advance->send))) { + $usercansend = false; + } + if (empty($user->rights->multicompany->order->close)) { + $usercanclose = false; + } + } + } + } + else if (in_array('invoicecard', $currentcontext) && $object->element == 'facture') + { + if ($action != 'create' && $action != 'add') + { + if ($object->entity != $conf->entity) + { + global $usercanread, $usercancreate, $usercandelete, $usercanvalidate, $usercansend, $usercanreopen, $usercanunvalidate; + global $permissionnote, $permissiondellink, $permissiontoedit; + global $disableedit, $disablemove, $disableremove; + + $this->getInstanceDao(); + + $constants = array( + 'FACTURE_ADDON', + 'FACTURE_MERCURE_MASK_INVOICE', + 'FACTURE_MERCURE_MASK_CREDIT', + 'FACTURE_MERCURE_MASK_DEPOSIT', + 'FACTURE_MERCURE_MASK_REPLACEMENT', + 'PROPALE_ADDON_PDF', + 'FACTURE_ADDON_PDF_ODT_PATH' + ); + + if (empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED) || empty($mc->sharings['invoicenumber'])) // Check if current entity not use the proposalnumber sharing + { + foreach ($constants as $constname) + { + $res = $this->dao->getEntityConfig($object->entity, $constname); + if (! empty($res[$constname])) { + $conf->global->$constname = $res[$constname]; // override current entity config with object entity config + } + } + } + else + { + foreach ($constants as $constname) + { + $referent = (! empty($mc->invoicenumber_referent)?$mc->invoicenumber_referent:1); + $res = $this->dao->getEntityConfig($referent, $constname); + if (! empty($res[$constname])) { + $conf->global->$constname = $res[$constname]; // override current entity config with referent config + } + } + } + + // Override $mysoc with data of object entity + if ($action == 'builddoc') + { + global $mysoc; + + $current = $this->dao->getEntityConfig($conf->entity, 'MAIN_INFO_*'); + if (! empty($current)) + { + foreach($current as $constname => $value) + { + unset($conf->global->$constname); + } + } + + $other = $this->dao->getEntityConfig($object->entity, 'MAIN_INFO_*'); + if (! empty($other)) + { + foreach($other as $constname => $value) + { + $conf->global->$constname = $value; // override current entity config with referent config + } + } + + $mysoc->setMysoc($conf); + } + + if (empty($user->rights->multicompany->invoice->read)) { + $usercanread = false; + } + if (empty($user->rights->multicompany->invoice->write)) { + $usercancreate = false; + + $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php + $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php + $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php + + // for object lines + $disableedit = true; + $disablemove = true; + $disableremove = true; + } + if (empty($user->rights->multicompany->invoice->delete)) { + $usercandelete = false; + } + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->multicompany->invoice_advance->validate))) { + $usercanvalidate = false; + } + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($usercanread)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->multicompany->invoice_advance->send))) { + $usercansend = false; + } + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->multicompany->invoice_advance->reopen))) { + $usercanreopen = false; + } + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->multicompany->invoice_advance->unvalidate))) { + $usercanunvalidate = false; + } + } + } + } + } + + //var_dump($_POST); +/* + if (empty($_SESSION['dol_tables_list_fk_soc'])) + { + $_SESSION['dol_tables_list_fk_soc'] = getTablesWithField('fk_soc', array()); + } + var_dump($_SESSION['dol_tables_list_fk_soc']); +*/ + //$include=false; + //$exclude=false; +/* + $exclude = array( + MAIN_DB_PREFIX . 'user', + MAIN_DB_PREFIX . 'user_employment', + MAIN_DB_PREFIX . 'user_param', + MAIN_DB_PREFIX . 'user_rib', + MAIN_DB_PREFIX . 'user_rights', + MAIN_DB_PREFIX . 'usergroup', + MAIN_DB_PREFIX . 'usergroup_rights', + MAIN_DB_PREFIX . 'usergroup_user', + MAIN_DB_PREFIX . 'rights_def', + ); +*/ + //$exclude = '/(const|user|rights\_def)+/'; + //$include = '/(const|user|rights\_def)+/'; + + //if (empty($_SESSION['dol_tables_list_entity'])) +/* { + $_SESSION['dol_tables_list_entity'] = getTablesWithField('entity', $exclude, $include); + } + + var_dump($_SESSION['dol_tables_list_entity']); +*/ +/* + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) && ! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED) && ! empty($mc->sharings['thirdparty'])) + { + if (in_array($contextpage, $this->thirdpartycontextlist) || in_array($contextpage, $this->contactcontextlist)) + { + if (GETPOST('confirmmassaction') && GETPOST('massaction') == 'modify_entity') + { + var_dump($_POST['toselect']); + } + } + } +*/ + return 0; + } + + /** + * + */ + public function showLinkedObjectBlock($parameters=false, &$object, &$action='') + { + global $conf, $user, $langs; + global $mc; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + //var_dump($object->linkedObjects); + + foreach($object->linkedObjects as $objecttype => $objects) + { + foreach($objects as $key => $tmpobj) + { + if (empty($tmpobj->entity)) continue; // for debug + + if ($tmpobj->entity != $conf->entity) + { + $element = $objecttype; + if ($objecttype == 'propal') $element = 'proposal'; + if ($objecttype == 'commande') $element = 'order'; + if ($objecttype == 'facture') $element = 'invoice'; + + //var_dump($element);var_dump($mc->sharings[$element]); + //var_dump($object->linkedObjects[$objecttype][$key]); + + if (! empty($mc->sharings[$element]) && in_array($tmpobj->entity, $mc->sharings[$element])) + { + //nothing + } + else + { + unset($object->linkedObjects[$objecttype][$key]); + } + } + } + } + + return 0; + } + + /** + * + */ + public function showLinkToObjectBlock($parameters=false, &$object, &$action='') + { + global $conf, $user, $langs; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + $perms = 1; + $propalperms = 1; + $orderperms = 1 ; + $invoiceperms = 1 ; + + if (in_array('propalcard', $currentcontext) && $object->element == 'propal') + { + if ($object->entity != $conf->entity) + { + $propalperms = ! empty($user->rights->multicompany->propal->write); + } + } + elseif (in_array('ordercard', $currentcontext) && $object->element == 'commande') + { + if ($object->entity != $conf->entity) + { + $orderperms = ! empty($user->rights->multicompany->order->write); + } + } + elseif (in_array('invoicecard', $currentcontext) && $object->element == 'facture') + { + if ($object->entity != $conf->entity) + { + $invoiceperms = ! empty($user->rights->multicompany->invoice->write); + } + } + + $this->results = array('propal' => array('enabled'=>$conf->propal->enabled, 'perms'=>$propalperms, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'), + 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>$orderperms, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande').')'), + 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>$invoiceperms, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), + 'contrat'=>array('enabled'=>$conf->contrat->enabled , 'perms'=>$perms, 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), + 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>$perms, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'), + 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled , 'perms'=>$perms, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'), + 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled , 'perms'=>$perms, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), + 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled , 'perms'=>$perms, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')') + ); + + return 1; + } + + /** + * + */ + public function addMoreActionsButtons($parameters=false, &$object, &$action='') + { + global $conf, $user, $langs; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + /*if (in_array('productcard', $currentcontext) && ($object->element == 'product' || $object->element == 'service')) + { + if ($object->entity != $conf->entity) + { + $user->rights->produit->creer = 0; + $user->rights->produit->supprimer = 0; + $user->rights->service->creer = 0; + $user->rights->service->supprimer = 0; + + //return 1; + } + }*/ + + return 0; + } + + /** + * + */ + public function printUserPasswordField($parameters=false, &$object, &$action='') + { + global $conf, $user, $langs; + + if (empty($conf->multicompany->enabled)) return 0; + + $langs->load('multicompany@multicompany'); + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + $this->resprints = "\n".''."\n"; + + if (in_array('usercard', $currentcontext) && $object->element == 'user' && ! empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX) && checkMulticompanyAutentication()) + { + if ($action == 'create') + { + $this->resprints.= ''; + } + else if ($action == 'edit') + { + if ($caneditpassword) + { + $this->resprints.= ''; + } + else + { + $this->resprints.= preg_replace('/./i','*',$object->pass); + } + } + else + { + if ($object->pass) $this->resprints.= preg_replace('/./i','*',$object->pass); + else + { + if ($user->admin) $this->resprints.= ($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("Crypted").': '.$object->pass_indatabase_crypted; + else $this->resprints.= $langs->trans("Hidden"); + } + } + } + + $this->resprints.= ''."\n"; + + return 0; + } + + /** + * + */ + public function formConfirm($parameters=false, &$object, &$action='') + { + global $conf, $langs; + global $mc, $form; + + if (empty($conf->multicompany->enabled)) return 0; + + $langs->load('multicompany@multicompany'); + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $return = 0; + $currentcontext = explode(':', $parameters['context']); + + $this->resprints = "\n".''."\n"; + + if (in_array('propalcard', $currentcontext) && $object->element == 'propal') + { + if ($action == 'clone' && ! empty($mc->entities['proposal'])) { + // Create an array for form + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)')), + array('type' => 'other', 'name' => 'entity', 'label' => $langs->trans("SelectEntity"), 'value' => $mc->select_entities($conf->entity, 'entity', '', false, false, false, explode(',', $mc->entities['proposal']))) + ); + if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->date_livraison)) { + $formquestion[] = array('type' => 'date', 'name' => 'date_delivery', 'label' => $langs->trans("DeliveryDate"), 'value' => $object->date_livraison); + } + // Incomplete payment. We ask if reason = discount or other + $this->resprints.= $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $return++; + } + } + + $this->resprints.= ''."\n"; + + return $return; + } + + /** + * + */ + public function formObjectOptions($parameters=false, &$object, &$action='') + { + global $conf, $user, $langs; + global $form; + + if (empty($conf->multicompany->enabled)) return 0; + + $langs->load('multicompany@multicompany'); + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + $this->resprints = "\n".''."\n"; + + if (in_array('thirdpartycard', $currentcontext) && $object->element == 'societe' && ! empty($user->admin) && empty($user->entity)) + { + if ($action == 'create') + { + $this->resprints.= ''.fieldLabel('Entity','entity').''; + $s = $this->select_entities($conf->entity); + $this->resprints.= $form->textwithpicto($s,$langs->trans("ThirdpartyEntityDesc"),1); + $this->resprints.= ''."\n"; + } + } + else if (in_array('contactcard', $currentcontext) && $object->element == 'contact' && ! empty($user->admin) && empty($user->entity)) + { + if ($action == 'create' && empty($objsoc)) + { + $this->resprints.= ''.fieldLabel('Entity','entity').''; + $s = $this->select_entities($conf->entity); + $this->resprints.= $form->textwithpicto($s,$langs->trans("ContactEntityDesc"),1); + $this->resprints.= ''."\n"; + } + } + else if (in_array('usercard', $currentcontext) && $object->element == 'user') + { + if ($action == 'edit') + { + // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && ! empty($user->admin) && empty($user->entity)) + { + $this->resprints.= ''.$langs->trans("Entity").''; + $this->resprints.= ''.$this->select_entities($object->entity); + $this->resprints.= "\n"; + } + else + { + $this->resprints.= ''; + } + } + else if ($action == 'create') + { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && ! empty($user->admin) && empty($user->entity)) + { + $this->resprints.= ''.$langs->trans("Entity").''; + $this->resprints.= ''.$this->select_entities($conf->entity); + $this->resprints.= "\n"; + } + else + { + $this->resprints.= ''; + } + } + else if ($action != 'adduserldap') + { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && ! empty($user->admin) && empty($user->entity)) + { + $this->resprints.= ''.$langs->trans("Entity").''; + if (empty($object->entity)) + { + $this->resprints.= $langs->trans("AllEntities"); + } + else + { + $this->getInfo($object->entity); + $this->resprints.= $this->label; + } + $this->resprints.= "\n"; + } + } + } + else if ((in_array('propalcard', $currentcontext) && $object->element == 'propal') + || (in_array('ordercard', $currentcontext) && $object->element == 'commande') + || (in_array('invoicecard', $currentcontext) && $object->element == 'facture') + ) + { + if ($action == 'create') + { + $this->resprints.= ''.$langs->trans("Entity").''; + $this->resprints.= ''.$this->select_entities($conf->entity); + $this->resprints.= "\n"; + } + } + + $this->resprints.= ''."\n"; + + return 0; + } + + /** + * + */ + public function formCreateThirdpartyOptions($parameters=false, &$object, &$action='') + { + global $conf, $user, $langs; + global $form; + + if (empty($conf->multicompany->enabled)) return 0; + + $langs->load('multicompany@multicompany'); + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + //echo 'OK'; + + //$this->resprints = 'OK'; + + return 0; + } + + /** + * + */ + public function formAddUserToGroup($parameters=false, &$object, &$action='') + { + global $conf, $user, $langs; + global $form, $mc, $exclude; + + if (empty($conf->multicompany->enabled)) return 0; + + $langs->load('multicompany@multicompany'); + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + $this->resprints = ''; + + if (is_array($currentcontext)) + { + if (in_array('usercard', $currentcontext) && $object->element == 'user') + { + if ($action != 'edit' && $action != 'presend' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + { + $this->resprints = "\n".''."\n"; + + if (! empty($groupslist)) + { + $exclude=array(); + } + + if ($caneditgroup) + { + $this->resprints.= '
'."\n"; + $this->resprints.= ''; + $this->resprints.= ''; + } + $this->resprints.= ''."\n"; + + $this->resprints.= ''."\n"; + if (! empty($user->admin)) + { + $this->resprints.= ''; + } + $this->resprints.= ''."\n"; + + /* + * Groups assigned to user + */ + if (! empty($groupslist)) + { + foreach($groupslist as $group) + { + $this->resprints.= ''; + $this->resprints.= ''; + if (! empty($user->admin)) + { + $this->resprints.= ''."\n"; + } + } + else + { + $this->resprints.= ''; + } + + $this->resprints.= "
'.$langs->trans("Groups").''.$langs->trans("Entity").''; + if ($caneditgroup && empty($user->entity)) + { + // Users/Groups management only in master entity if transverse mode + if ($conf->entity == 1) + { + $this->resprints.= $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); + $this->resprints.= '   '; + if ($conf->entity == 1) + { + $entities = $this->getEntitiesList(); + $this->resprints.= $form->multiselectarray('entities', $entities, GETPOST('entities', 'array'), '', 0, '', 0, '20%'); + } + else + { + $this->resprints.= ''; + } + $this->resprints.= ''; + } + } + $this->resprints.= '
'; + if ($caneditgroup) + { + $this->resprints.= ''.img_object($langs->trans("ShowGroup"),"group").' '.$group->name.''; + } + else + { + $this->resprints.= img_object($langs->trans("ShowGroup"),"group").' '.$group->name; + } + $this->resprints.= ''; + if (! empty($group->usergroup_entity)) + { + $nb=0; + foreach($group->usergroup_entity as $group_entity) + { + $mc->getInfo($group_entity); + if (empty($conf->global->MULTICOMPANY_TEMPLATE_MANAGEMENT) && $mc->visible == 2) continue; + + $this->resprints.= ''; + if ($mc->visible == 2) { + $this->resprints.= ''; + } else { + $this->resprints.= ''; + } + $this->resprints.= $mc->label . (empty($mc->active) ? ' ('.$langs->trans('Disabled').')' : ($mc->visible == 2 ? ' ('.$langs->trans('Template').')' : (empty($mc->visible) ? ' ('.$langs->trans('Hidden').')' : '')) ); + if ($conf->entity == 1 && empty($user->entity)) { + $this->resprints.= ''; + $this->resprints.= img_picto($langs->trans("RemoveFromGroup"), 'unlink'); + $this->resprints.= ''; + } + $this->resprints.= ''; + } + } + } + $this->resprints.= ' 
'.$langs->trans("None").'
"; + + if ($caneditgroup) + { + $this->resprints.= '
'; + } + + $this->resprints.= ''."\n"; + + return 1; + } + } + else if (in_array('groupcard', $currentcontext) && $object->element == 'usergroup') + { + if ($action != 'edit' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + { + $this->resprints = "\n".''."\n"; + + if (! empty($object->members)) + { + $exclude=array(); + } + + if ($caneditperms && empty($user->entity)) + { + $this->resprints.= '
'."\n"; + $this->resprints.= ''; + $this->resprints.= ''; + $this->resprints.= ''."\n"; + $this->resprints.= ''."\n"; + $this->resprints.= ''."\n"; + $this->resprints.= '
'.$langs->trans("NonAffectedUsers").''; + $this->resprints.= $form->select_dolusers('', 'user', 1, $exclude, 0, '', '', $object->entity); + $this->resprints.= '   '; + if ($conf->entity == 1) + { + $entities = $this->getEntitiesList(false, false, false, (empty($conf->global->MULTICOMPANY_TEMPLATE_MANAGEMENT) ? false : true)); + $this->resprints.= $form->multiselectarray('entities', $entities, GETPOST('entities', 'array'), '', 0, '', 0, '20%'); + } + else + { + $this->resprints.= ''; + } + $this->resprints.= ''; + $this->resprints.= '
'."\n"; + $this->resprints.= '
'; + } + + /* + * Group members + */ + $this->resprints.= ''; + $this->resprints.= ''; + $this->resprints.= ''; + $this->resprints.= ''; + $this->resprints.= ''; + if ($conf->entity == 1) + { + $this->resprints.= ''; + } + $this->resprints.= ''; + $this->resprints.= ''; + $this->resprints.= "\n"; + + if (! empty($object->members)) + { + foreach($object->members as $useringroup) + { + $this->resprints.= ''; + $this->resprints.= ''; + $this->resprints.= ''; + $this->resprints.= ''; + if ($conf->entity == 1 && ! empty($user->admin)) + { + $this->resprints.= ''; + } + $this->resprints.= ''; + $this->resprints.= '\n"; + } + } + else + { + $this->resprints.= ''; + } + $this->resprints.= "
'.$langs->trans("Login").''.$langs->trans("Lastname").''.$langs->trans("Firstname").''.$langs->trans("Entity").''.$langs->trans("Status").' 
'; + $this->resprints.= $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login'); + if ($useringroup->admin && ! $useringroup->entity) $this->resprints.= img_picto($langs->trans("SuperAdministrator"),'redstar'); + else if ($useringroup->admin) $this->resprints.= img_picto($langs->trans("Administrator"),'star'); + $this->resprints.= ''.$useringroup->lastname.''.$useringroup->firstname.''; + if (! empty($useringroup->usergroup_entity)) + { + foreach($useringroup->usergroup_entity as $group_entity) + { + $mc->getInfo($group_entity); + if (empty($conf->global->MULTICOMPANY_TEMPLATE_MANAGEMENT) && $mc->visible == 2) continue; + + $this->resprints.= ''; + if ($mc->visible == 2) { + $this->resprints.= ''; + } else { + $this->resprints.= ''; + } + $this->resprints.= $mc->label . (empty($mc->active) ? ' ('.$langs->trans('Disabled').')' : ($mc->visible == 2 ? ' ('.$langs->trans('Template').')' : (empty($mc->visible) ? ' ('.$langs->trans('Hidden').')' : '')) ); + if (empty($user->entity)) { + $this->resprints.= ''; + $this->resprints.= img_picto($langs->trans("RemoveFromGroup"), 'unlink'); + $this->resprints.= ''; + } + $this->resprints.= ''; + } + } + $this->resprints.= ''.$useringroup->getLibStatut(3).''; + $this->resprints.= "-"; + $this->resprints.= "
'.$langs->trans("None").'
"; + + $this->resprints.= ''."\n"; + + return 1; + } + } + } + + return 0; + } + + /** + * + */ + public function moreHtmlRef($parameters=false, &$object, &$action='') + { + global $conf, $user, $langs; + global $mc; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + $this->resprints = "\n".''."\n"; + + // if global sharings is enabled + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) + { + $this->getInfo(! empty($object->entity) ? $object->entity : $conf->entity); + + // if third party sharing is enabled (is mandatory for some sharings) + if (! empty($conf->societe->enabled) && ! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED) && ! empty($mc->sharings['thirdparty'])) + { + if ($object->element == 'societe') + { + if (in_array('thirdpartycard', $currentcontext)) + { + if ($action != 'create' && $action != 'edit') + { + if ($object->isObjectUsed($object->id) === 0 && ((! empty($user->admin) && ! $user->entity) || ! empty($user->rights->multicompany->thirdparty->write))) + { + $selectEntities = $this->getModifyEntityDialog('thirdparty', 'modifyEntity', $object); + + if (! empty($selectEntities)) { + $this->resprints.= '
'; + $this->resprints.= ''.$this->label.''; + $this->resprints.= '
'; + $this->resprints.= $selectEntities; + } else { + $this->resprints.= '
'; + $this->resprints.= ''.$this->label.''; + $this->resprints.= '
'; + } + } + else + { + $this->resprints.= '
'; + $this->resprints.= ''.$this->label.''; + $this->resprints.= '
'; + } + } + } + else + { + $this->resprints.= '
'; + $this->resprints.= ''.$this->label.''; + $this->resprints.= '
'; + } + } + else if ($object->element == 'contact') + { + if (in_array('contactcard', $currentcontext)) + { + if ($action != 'create' && $action != 'edit') + { + if (empty($object->socid) && ((! empty($user->admin) && ! $user->entity) || ! empty($user->rights->multicompany->contact->write))) + { + $selectEntities = $this->getModifyEntityDialog('contact', 'modifyEntity', $object); + + if (! empty($selectEntities)) { + $this->resprints.= '
'; + $this->resprints.= ''.$this->label.''; + $this->resprints.= '
'; + $this->resprints.= $selectEntities; + } else { + $this->resprints.= '
'; + $this->resprints.= ''.$this->label.''; + $this->resprints.= '
'; + } + } + else + { + $this->resprints.= '
'; + $this->resprints.= ''.$this->label.''; + $this->resprints.= '
'; + } + } + } + else + { + $this->resprints.= '
'; + $this->resprints.= ''.$this->label.''; + $this->resprints.= '
'; + } + } + } + + if (((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && $object->element == 'product' && ! empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && ! empty($mc->sharings['product'])) + || (! empty($conf->propal->enabled) && $object->element == 'propal' && in_array('propalcard', $currentcontext) && ! empty($conf->global->MULTICOMPANY_PROPOSAL_SHARING_ENABLED) && ! empty($mc->sharings['proposal'])) + || (! empty($conf->commande->enabled) && $object->element == 'commande' && in_array('ordercard', $currentcontext) && ! empty($conf->global->MULTICOMPANY_ORDER_SHARING_ENABLED) && ! empty($mc->sharings['order'])) + || (! empty($conf->facture->enabled) && $object->element == 'facture' && in_array('invoicecard', $currentcontext) && ! empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) && ! empty($mc->sharings['invoice'])) + || (! empty($conf->stock->enabled) && $object->element == 'stock' && in_array('warehousecard', $currentcontext) && ! empty($conf->global->MULTICOMPANY_STOCK_SHARING_ENABLED) && ! empty($mc->sharings['stock'])) + ) + { + $this->resprints.= '
'; + $this->resprints.= ''.$this->label.''; + $this->resprints.= '
'; + } + } + + if ($object->element == 'user' || $object->element == 'usergroup') + { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && ! empty($user->admin) && empty($user->entity)) + { + $this->getInfo($object->entity); + $this->resprints.= '
'; + $this->resprints.= ''.$this->label.''; + $this->resprints.= '
'; + } + } + + $this->resprints.= ''."\n"; + + return 0; + } + + /** + * + */ + public function moreHtmlStatus($parameters=false, &$object, &$action='') + { + global $conf, $user; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + //$this->resprints.= 'OK'; + + return 0; + } + + /** + * + */ + public function printUserListWhere($parameters=false) + { + global $conf, $user; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $this->resprints = ''; + + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) { + $this->resprints.= " WHERE u.entity IS NOT NULL"; // Show all users + } else { + $this->resprints.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + $this->resprints.= " WHERE ((ug.fk_user = u.rowid"; + $this->resprints.= " AND ug.entity IN (".getEntity('usergroup')."))"; + $this->resprints.= " OR u.entity = 0)"; // Show always superadmin + } + return 1; + } + + return 0; + } + + /** + * + * @return number + */ + public function addMoreMassActions($parameters=false) + { + global $conf, $user, $langs; + global $mc; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) + { + // name="massaction" + if (! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED) && ! empty($mc->sharings['thirdparty'])) + { + if (in_array('thirdpartylist', $currentcontext) || in_array('contactlist', $currentcontext)) + { + $langs->load('multicompany@multicompany'); + $this->resprints = ''; + } + } + } + + return 0; + } + + /** + * + * @return number + */ + public function printFieldListSelect($parameters=false) + { + global $conf; + global $mc; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) + { + // Thirdparty sharing is mandatory to share document (propal, etc...) + if (! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED) && ! empty($mc->sharings['thirdparty'])) + { + if (in_array('thirdpartylist', $currentcontext)) + { + //if (! empty($arrayfields['s.entity']['checked'])) + { + $this->resprints = ", s.entity"; + } + } + else if (in_array('contactlist', $currentcontext)) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->resprints = ", p.entity"; + } + } + else if (in_array('propallist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_PROPOSAL_SHARING_ENABLED) && ! empty($mc->sharings['proposal'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->resprints = ", p.entity"; + } + } + else if (in_array('orderlist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_ORDER_SHARING_ENABLED) && ! empty($mc->sharings['order'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->resprints = ", c.entity"; + } + } + else if (in_array('invoicelist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) && ! empty($mc->sharings['invoice'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->resprints = ", f.entity"; + } + } + } + + if (in_array('productservicelist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && ! empty($mc->sharings['product'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->resprints = ", p.entity"; + } + } + } + + return 0; + } + + /** + * + * @param boolean $parameters + * @return number + */ + public function printFieldListWhere($parameters=false) + { + global $conf; + global $mc; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) + { + if (! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED) && ! empty($mc->sharings['thirdparty'])) + { + if (in_array('thirdpartylist', $currentcontext)) + { + //if (! empty($arrayfields['s.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + if ($search_entity > 0) + { + $this->resprints = " AND s.entity = " . $search_entity; + } + } + } + else if (in_array('contactlist', $currentcontext)) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + if ($search_entity > 0) + { + $this->resprints = " AND p.entity = " . $search_entity; + } + } + } + else if (in_array('propallist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_PROPOSAL_SHARING_ENABLED) && ! empty($mc->sharings['proposal'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + if ($search_entity > 0) + { + $this->resprints = " AND p.entity = " . $search_entity; + } + } + } + else if (in_array('orderlist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_ORDER_SHARING_ENABLED) && ! empty($mc->sharings['order'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + if ($search_entity > 0) + { + $this->resprints = " AND c.entity = " . $search_entity; + } + } + } + else if (in_array('invoicelist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) && ! empty($mc->sharings['invoice'])) + { + //if (! empty($arrayfields['f.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + if ($search_entity > 0) + { + $this->resprints = " AND f.entity = " . $search_entity; + } + } + } + } + + if (in_array('productservicelist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && ! empty($mc->sharings['product'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + if ($search_entity > 0) + { + $this->resprints = " AND p.entity = " . $search_entity; + } + } + } + if (in_array('stocklist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_STOCK_SHARING_ENABLED) && ! empty($mc->sharings['stock'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + if ($search_entity > 0) + { + $this->resprints = " AND t.entity = " . $search_entity; + } + } + } + } + + return 0; + } + + /** + * + * @param boolean $parameters + * @return number + */ + public function printFieldListOption($parameters=false) + { + global $conf; + global $mc; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) + { + if (! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED) && ! empty($mc->sharings['thirdparty'])) + { + if (in_array('thirdpartylist', $currentcontext) || in_array('contactlist', $currentcontext)) + { + //if (! empty($arrayfields['s.entity']['checked']) || ! empty($arrayfields['p.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + // Entity + $this->resprints = ''; + $this->resprints.= $this->select_entities($search_entity,'search_entity','',false,false,true,explode(",", $mc->entities['thirdparty']),'','minwidth100imp'); + $this->resprints.= ''; + } + } + else if (in_array('propallist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_PROPOSAL_SHARING_ENABLED) && ! empty($mc->sharings['proposal'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + // Entity + $this->resprints = ''; + $this->resprints.= $this->select_entities($search_entity,'search_entity','',false,false,true,explode(",", $mc->entities['proposal']),'','minwidth100imp'); + $this->resprints.= ''; + } + } + else if (in_array('orderlist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_ORDER_SHARING_ENABLED) && ! empty($mc->sharings['order'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + // Entity + $this->resprints = ''; + $this->resprints.= $this->select_entities($search_entity,'search_entity','',false,false,true,explode(",", $mc->entities['order']),'','minwidth100imp'); + $this->resprints.= ''; + } + } + else if (in_array('invoicelist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) && ! empty($mc->sharings['invoice'])) + { + //if (! empty($arrayfields['f.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + // Entity + $this->resprints = ''; + $this->resprints.= $this->select_entities($search_entity,'search_entity','',false,false,true,explode(",", $mc->entities['invoice']),'','minwidth100imp'); + $this->resprints.= ''; + } + } + } + + if (in_array('productservicelist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && ! empty($mc->sharings['product'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + // Entity + $this->resprints = ''; + $this->resprints.= $this->select_entities($search_entity,'search_entity','',false,false,true,explode(",", $mc->entities['product']),'','minwidth100imp'); + $this->resprints.= ''; + } + } + if (in_array('stocklist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_STOCK_SHARING_ENABLED) && ! empty($mc->sharings['stock'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $search_entity = GETPOST('search_entity','int'); + + 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 + { + $search_entity = ''; + } + + // Entity + $this->resprints = ''; + $this->resprints.= $this->select_entities($search_entity,'search_entity','',false,false,true,explode(",", $mc->entities['stock']),'','minwidth100imp'); + $this->resprints.= ''; + } + } + } + + return 0; + } + + /** + * + * @param boolean $parameters + * @return number + */ + public function printFieldListTitle($parameters=false) + { + global $conf; + global $mc; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) + { + if (! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED) && ! empty($mc->sharings['thirdparty'])) + { + if (in_array('thirdpartylist', $currentcontext)) + { + //if (! empty($arrayfields['s.entity']['checked'])) + { + $this->resprints = getTitleFieldOfList('Entity',0,$_SERVER["PHP_SELF"],"s.entity","",$param,'align="center"',$sortfield,$sortorder); + } + } + else if (in_array('contactlist', $currentcontext)) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->resprints = getTitleFieldOfList('Entity',0,$_SERVER["PHP_SELF"],"p.entity","",$param,'align="center"',$sortfield,$sortorder); + } + } + else if (in_array('propallist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_PROPOSAL_SHARING_ENABLED) && ! empty($mc->sharings['proposal'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->resprints = getTitleFieldOfList('Entity',0,$_SERVER["PHP_SELF"],"p.entity","",$param,'align="center"',$sortfield,$sortorder); + } + } + else if (in_array('orderlist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_ORDER_SHARING_ENABLED) && ! empty($mc->sharings['order'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->resprints = getTitleFieldOfList('Entity',0,$_SERVER["PHP_SELF"],"c.entity","",$param,'align="center"',$sortfield,$sortorder); + } + } + else if (in_array('invoicelist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) && ! empty($mc->sharings['invoice'])) + { + //if (! empty($arrayfields['f.entity']['checked'])) + { + $this->resprints = getTitleFieldOfList('Entity',0,$_SERVER["PHP_SELF"],"f.entity","",$param,'align="center"',$sortfield,$sortorder); + } + } + } + + if (in_array('productservicelist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && ! empty($mc->sharings['product'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->resprints = getTitleFieldOfList('Entity',0,$_SERVER["PHP_SELF"],"p.entity","",$param,'align="center"',$sortfield,$sortorder); + } + } + + if (in_array('stocklist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_STOCK_SHARING_ENABLED) && ! empty($mc->sharings['stock'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->resprints = getTitleFieldOfList('Entity',0,$_SERVER["PHP_SELF"],"t.entity","",$param,'align="center"',$sortfield,$sortorder); + } + } + } + + return 0; + } + + /** + * + * @param boolean $parameters + * @return number + */ + public function printFieldListValue($parameters=false) + { + global $conf; + global $totalarray; + global $mc; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) + { + if (! empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED) && ! empty($mc->sharings['thirdparty'])) + { + if (in_array('thirdpartylist', $currentcontext) || in_array('contactlist', $currentcontext)) + { + //if (! empty($arrayfields['s.entity']['checked']) || ! empty($arrayfields['p.entity']['checked'])) + { + $this->getInfo($obj->entity); + $this->resprints = ''.$this->label."\n"; + } + } + else if (in_array('propallist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_PROPOSAL_SHARING_ENABLED) && ! empty($mc->sharings['proposal'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->getInfo($obj->entity); + $this->resprints = ''.$this->label."\n"; + if (! $i) $totalarray['nbfield']++; + } + } + else if (in_array('orderlist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_ORDER_SHARING_ENABLED) && ! empty($mc->sharings['order'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->getInfo($obj->entity); + $this->resprints = ''.$this->label."\n"; + if (! $i) $totalarray['nbfield']++; + } + } + else if (in_array('invoicelist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) && ! empty($mc->sharings['invoice'])) + { + //if (! empty($arrayfields['f.entity']['checked'])) + { + $this->getInfo($obj->entity); + $this->resprints = ''.$this->label."\n"; + if (! $i) $totalarray['nbfield']++; + } + } + } + + if (in_array('productservicelist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && ! empty($mc->sharings['product'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->getInfo($obj->entity); + $this->resprints = ''.$this->label."\n"; + } + } + + if (in_array('stocklist', $currentcontext) && ! empty($conf->global->MULTICOMPANY_STOCK_SHARING_ENABLED) && ! empty($mc->sharings['stock'])) + { + //if (! empty($arrayfields['p.entity']['checked'])) + { + $this->getInfo($obj->entity); + $this->resprints = ''.$this->label."\n"; + } + } + } + + return 0; + } + + /** + * + */ + public function insertExtraHeader($parameters=false, &$object, &$action='') + { + global $conf, $user, $langs; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1 && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + { + if (in_array('userperms', $currentcontext) || in_array('groupperms', $currentcontext)) + { + $this->getInstanceDao(); + + if ($object->element == 'user') + { + $aEntities=array_keys($permsgroupbyentity); + + // Check usergroup if user not in master entity + if (empty($aEntities) || ! array_key_exists(1, $permsgroupbyentity)) + { + require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; + $aEntities=array(); + $group = new UserGroup($this->db); + $ret = $group->listGroupsForUser($object->id, false); + if (! empty($ret)) { + foreach($ret as $groupid => $data) + { + $aEntities = array_merge($aEntities, $data->usergroup_entity); + } + sort($aEntities); + } + } + + if (! empty($aEntities)) + { + $entity = (GETPOST('entity', 'int')?GETPOST('entity', 'int'):$aEntities[0]); + $head = entity_prepare_head($object, $aEntities); + $title = $langs->trans("Entities"); + dol_fiche_head($head, $entity, $title, 1, 'multicompany@multicompany'); + } + else + { + print get_htmloutput_mesg(img_warning('default') . ' ' . $langs->trans("ErrorLinkUserGroupEntity"), '', 'mc-upgrade-alert', 1); + } + } + else if ($object->element == 'usergroup') + { + $this->dao->getEntities(); + $aEntities=array(); + + foreach ($this->dao->entities as $objEntity) + { + $aEntities[] = $objEntity->id; + } + + $entity = (GETPOST('entity', 'int')?GETPOST('entity', 'int'):$aEntities[0]); + $head = entity_prepare_head($object, $aEntities); + $title = $langs->trans("Entities"); + dol_fiche_head($head, $entity, $title, 1, 'multicompany@multicompany'); + + if (! empty($conf->global->MULTICOMPANY_TEMPLATE_MANAGEMENT)) { + print ' +
+

'.img_info().' '.$langs->transnoentities('DuplicateRightsInfo').'

+

'.$langs->transnoentities('SelectRightsOfEntityToDuplicate').' '.$this->select_entities('', 'template', '', false, false, false, false, '', 'minwidth200imp', true, true).'

+

'.$langs->transnoentities('SelectEntitiesToOverride').'

+

+
+
+
'.$langs->transnoentities("EntitiesSelected").'
+ '.$this->multiselectEntitiesToOverride('overrideentities', true).' +
+
+ + + + + + +
+
+
'.$langs->transnoentities("EntitiesAvailable").'
+ '.$this->multiselectEntitiesToOverride('overrideentities', false).' +
+
+

+
+ + '; + } + } + + // Check if advanced perms is enabled for current object entity + $res = $this->dao->getEntityConfig($entity, 'MAIN_USE_ADVANCED_PERMS'); + if (empty($res['MAIN_USE_ADVANCED_PERMS'])) { + unset($conf->global->MAIN_USE_ADVANCED_PERMS); + } + } + } + + return 0; + } + + /** + * + */ + public function insertExtraFooter($parameters=false, &$object, &$action='') + { + global $conf, $user; + + if (empty($conf->multicompany->enabled)) return 0; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key=>$value) + { + $$key=$value; + } + } + + $currentcontext = explode(':', $parameters['context']); + + if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1 && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + { + if (in_array('userperms', $currentcontext) || in_array('groupperms', $currentcontext)) + { + // Restore advanced perms if enabled for current entity + $this->getInstanceDao(); + $res = $this->dao->getEntityConfig($conf->entity, 'MAIN_USE_ADVANCED_PERMS'); + if (! empty($res['MAIN_USE_ADVANCED_PERMS'])) { + $conf->global->MAIN_USE_ADVANCED_PERMS = $res['MAIN_USE_ADVANCED_PERMS']; + } + } + } + + return 0; + } + + /** + * Return combo list of entities. + * + * @param int $selected Preselected entity + * @param int $htmlname Name + * @param string $option Option + * @param boolean $login If use in login page or not + * @param boolean $exclude Exclude + * @param boolean $emptyvalue Emptyvalue + * @param boolean $only Only + * @param string $all Add 'All entities' value in combo list + * @param string $cssclass specific css class. eg 'minwidth150imp mycssclass' + * @param bool $ajax Enable ajax combobox + * @param bool $template Show template of entities + * @return string + */ + public function select_entities($selected = '', $htmlname = 'entity', $option = '', $login = false, $exclude = false, $emptyvalue = false, $only = false, $all = '', $cssclass = 'minwidth150imp', $ajax = true, $template = false) + { + global $conf, $user, $langs; + + $this->getInstanceDao(); + + $this->dao->getEntities($login, $exclude); + + $out = ''; + + if (is_array($this->dao->entities) && ! empty($this->dao->entities)) + { + $out.= ''; + + // Make select dynamic + if ($ajax) { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out.= ajax_combobox($htmlname); + } + } + + return $out; + } + + /** + * Return multiselect list of entities. + * + * @param string $htmlname Name of select + * @param DaoMulticompany $current Current entity to manage + * @param bool $onlyselected true: show only selected, false: hide only selected + * @return string + */ + public function multiselect_entities($htmlname, $current, $onlyselected=false) + { + global $langs; + + $this->getInstanceDao(); + $this->dao->getEntities(); + + $selectname = ($onlyselected ? $htmlname.'_to[]' : 'from[]'); + $selectid = ($onlyselected ? 'multiselect_shared_'.$htmlname.'_to' : 'multiselect_shared_'.$htmlname); + + $return = ''; + + return $return; + } + + /** + * Return multiselect list of entities to override. + * + * @param string $htmlname Name of select + * @param bool $onlyselected true: show only selected, false: hide only selected + * @return string + */ + public function multiselectEntitiesToOverride($htmlname, $onlyselected=false) + { + global $langs; + + $this->getInstanceDao(); + $this->dao->getEntities(); + + $selectname = ($onlyselected ? $htmlname.'_to[]' : 'from[]'); + $selectid = ($onlyselected ? 'multiselect_'.$htmlname.'_to' : 'multiselect_'.$htmlname); + + $out = ''; + + return $out; + } + + /** + * Return multiselect list of entities. + * + * @param string $htmlname Name of select + * @param array $selected Entities already selected + * @param string $option Option + * @return string + */ + public function multiSelectEntities($htmlname, $selected=null, $option=null) + { + global $langs; + + $this->getInstanceDao(); + $this->dao->getEntities(); + + $return = ''; + + return $return; + } + + /** + * Switch to another entity. + * + * @param int $id User id + * @param int $entity Entity id + * @return int + */ + public function checkRight($id, $entity) + { + global $user; + + $this->getInstanceDao(); + + if ($this->dao->fetch($entity) > 0) + { + // Controle des droits sur le changement + if ($this->dao->verifyRight($entity, $id) || $user->admin) + { + return 1; + } + else + { + return -2; + } + } + else + { + return -1; + } + } + + /** + * Switch to another entity. + * @param int $id Id of the destination entity + * @param int $userid + * @return int + */ + public function switchEntity($id, $userid=null) + { + global $conf, $user; + + $this->getInstanceDao(); + + if (!empty($userid)) + { + $user=new User($this->db); + $user->fetch($userid); + } + + if ($this->dao->fetch($id) > 0 && ! empty($this->dao->active)) // check if the entity is still active + { + // Controle des droits sur le changement + if (!empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX) + || (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $this->dao->verifyRight($id, $user->id)) + || $user->admin) + { + $_SESSION['dol_entity'] = $id; + //$conf = new Conf(); FIXME some constants disappear + $conf->entity = $id; + $conf->setValues($this->db); + return 1; + } + else + { + //var_dump($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX); + //var_dump($conf->global->MULTICOMPANY_TRANSVERSE_MODE); + //var_dump($this->dao->verifyRight($id, $user->id)); + return -2; + } + } + else + { + return -1; + } + } + + /** + * Get entity info + * @param int $id Object id + */ + public function getInfo($id) + { + $this->getInstanceDao(); + $this->dao->fetch($id); + + $this->id = $this->dao->id; + $this->label = $this->dao->label; + $this->country_id = $this->dao->country_id; + $this->country_code = $this->dao->country_code; + $this->currency_code = $this->dao->currency_code; + $this->language_code = $this->dao->language_code; + $this->description = $this->dao->description; + $this->options = $this->dao->options; + $this->active = $this->dao->active; + $this->visible = $this->dao->visible; + } + + /** + * Get action title + * @param string $action Type of action + * @return string + */ + public function getTitle($action='') + { + global $langs; + + if ($action == 'create') return $langs->trans("AddEntity"); + else if ($action == 'edit') return $langs->trans("EditEntity"); + else return $langs->trans("EntitiesManagement"); + } + + + /** + * Assigne les valeurs pour les templates + * @param string $action Type of action + */ + public function assign_values($action='view') + { + global $conf, $langs, $user; + global $form, $formcompany, $formadmin; + + require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; + + $this->tpl['extrafields'] = new ExtraFields($this->db); + // fetch optionals attributes and labels + $this->tpl['extralabels'] = $this->tpl['extrafields']->fetch_name_optionals_label('entity'); + + $this->getInstanceDao(); + + $this->template_dir = dol_buildpath('/multicompany/admin/tpl/'); + $this->template = 'list.tpl.php'; + + if ($action == 'create' || $action == 'edit') + { + $this->template = 'card.tpl.php'; + + if ($action == 'edit' && GETPOSTISSET('id')) { + $ret = $this->dao->fetch(GETPOST('id', 'int')); + } + + if (! empty($conf->global->MULTICOMPANY_TEMPLATE_MANAGEMENT)) + { + $templatevalue = (GETPOSTISSET('template') ? GETPOST('template', 'int') : ($this->dao->visible === '2' ? 1 : 0)); + + if ($action == 'create') { + $this->tpl['template'] = $form->selectyesno('template', $templatevalue, 1); + $this->tpl['select_template'] = $this->select_entities('','usetemplate','',false,false,true,'','','minwidth200imp',true,'only'); + } elseif ($templatevalue === 1) { + $this->tpl['template'] = $templatevalue; + } + } + + // action + $this->tpl['action'] = $action; + + // id + $this->tpl['id'] = (GETPOSTISSET('id')?GETPOST('id', 'int'):null); + + // Label + $this->tpl['label'] = (GETPOSTISSET('label')?GETPOST('label', 'alpha'):$this->dao->label); + + // Description + $this->tpl['description'] = (GETPOSTISSET('description')?GETPOST('description', 'alpha'):$this->dao->description); + + // Company name + $this->tpl['name'] = (GETPOSTISSET('name')?GETPOST('name', 'alpha'):$this->dao->name); + + // Address + $this->tpl['address'] = (GETPOSTISSET('address')?GETPOST('address', 'alpha'):$this->dao->address); + + // Zip + $this->tpl['select_zip'] = $formcompany->select_ziptown((GETPOSTISSET('zipcode')?GETPOST('zipcode', 'alpha'):$this->dao->zip),'zipcode',array('town','selectcountry_id','departement_id'),6); + + // Town + $this->tpl['select_town'] = $formcompany->select_ziptown((GETPOSTISSET('town')?GETPOST('town', 'alpha'):$this->dao->town),'town',array('zipcode','selectcountry_id','departement_id'),40); + + if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + + + // We define country_id + if (GETPOSTISSET('country_id')) + { + $country_id = GETPOST('country_id', 'int'); + } + else if (! empty($this->dao->country_id)) + { + $country_id = $this->dao->country_id; + } + else if (! empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) + { + $tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_COUNTRY); + $country_id = $tmp[0]; + } + else + { + $country_id = 0; + } + + $this->tpl['select_country'] = $form->select_country($country_id,'country_id'); + $this->tpl['select_state'] = $formcompany->select_state((GETPOSTISSET('departement_id')?GETPOST('departement_id', 'int'):$this->dao->state_id),$country_id,'departement_id'); + $this->tpl['select_currency'] = $form->selectCurrency((GETPOSTISSET('currency_code')?GETPOST('currency_code', 'alpha'):($this->dao->currency_code?$this->dao->currency_code:$conf->currency)),"currency_code"); + $this->tpl['select_language'] = $formadmin->select_language((GETPOSTISSET('main_lang_default')?GETPOST('main_lang_default', 'alpha'):($this->dao->language_code?$this->dao->language_code:$conf->global->MAIN_LANG_DEFAULT)),'main_lang_default',1); + + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) { + foreach ($this->sharingelements as $element => $params) { + if ((($params['object'] || $params['objectnumber']) && ! isset($params['disable'])) && (empty($conf->societe->enabled) || empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED))) continue; + $uppername = strtoupper($element); + $constname = 'MULTICOMPANY_' . $uppername . '_SHARING_ENABLED'; + if (! empty($conf->global->$constname)) { + $this->tpl['multiselect_from_' . $element] = $this->multiselect_entities($element, $this->dao, false); + $this->tpl['multiselect_to_' . $element] = $this->multiselect_entities($element, $this->dao, true); + if ($element == 'proposalnumber' || $element == 'invoicenumber') { + $this->tpl['select_'.$element.'_entity'] = $this->select_entities($this->dao->options[$element.'_referent'], $element.'_referring_entity'); + } + $addtoallother = (GETPOSTISSET('addtoallother_' . $element) ? GETPOST('addtoallother_' . $element, 'int') : $this->dao->options['addtoallother'][$element]); + $this->tpl['addtoallother_' . $element] = $form->selectyesno('addtoallother_' . $element, $addtoallother, 1); + } + } + } + } + } + + /** + * Display the template + */ + public function display() + { + global $conf, $langs; + global $form, $object; + + include $this->template_dir.$this->template; + } + + /** + * Set values of global conf for multicompany + * + * @param Conf $conf Object conf + * @return void + */ + public function setValues(&$conf) + { + if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) + { + $this->getInstanceDao(); + $this->dao->fetch($conf->entity); + + $this->sharings = $this->dao->options['sharings']; + //$this->referent = $this->dao->options['referent']; + $this->proposalnumber_referent = (isset($this->dao->options['proposalnumber_referent'])?$this->dao->options['proposalnumber_referent']:''); + $this->invoicenumber_referent = (isset($this->dao->options['invoicenumber_referent'])?$this->dao->options['invoicenumber_referent']:''); + + // Load shared elements + $this->loadSharedElements(); + + // Define output dir for others entities + $this->setMultiOutputDir($conf); + } + + if (! empty($this->sharingdicts)) + { + foreach($this->sharingdicts as $dict => $data) + { + $constname = 'MULTICOMPANY_'.strtoupper($dict).'_SHARING_DISABLED'; + if (! empty($conf->global->$constname)) { + $this->dict[$dict] = true; + } + } + } + } + + /** + * Set status of an entity + * + * @param int $id Id of entity + * @param string $type Type of status (visible or active) + * @param string $value Value of status (0: disable, 1: enable) + * @return int + */ + public function setStatus($id, $type='active', $value) + { + global $user; + + if (! empty($user->admin) && ! $user->entity) { + $this->getInstanceDao(); + return $this->dao->setEntity($id, $type, $value); + } + else { + return -1; + } + } + + /** + * Delete an entity + * + * @param int $id Id of entity + * @return int + */ + public function deleteEntity($id) + { + global $user; + + if (! empty($user->admin) && ! $user->entity && $id != 1) { + $this->getInstanceDao(); + return $this->dao->delete($id); + } + else { + return -1; + } + } + + /** + * Get list of entity id to use. + * + * @param string $element Current element + * 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource', + * 'product', 'productprice', 'stock', + * 'propal', 'supplier_proposal', 'invoice', 'facture_fourn', 'payment_various', + * 'categorie', 'bank_account', 'bank_account', 'adherent', 'user', + * 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey', + * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', + * 'email_template', 'event', 'donation' + * 'c_paiement', 'c_payment_term', ... + * @param int $shared 0=Return id of current entity only, + * 1=Return id of current entity + shared entities (default) + * @param object $currentobject Current object if needed + * @return mixed Entity id(s) to use ( eg. entity IN ('.getEntity(elementname).')' ) + */ + public function getEntity($element=false, $shared=1, $currentobject=null) + { + global $conf, $user; + + $element = str_replace(MAIN_DB_PREFIX, '', $element); + + if (in_array($element, $this->addzero)) + { + if ($element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + return '0,1'; // In transverse mode all users except superadmin and groups are in entity 1 + } else { + if ($element == 'usergroup' && $conf->entity == 1 && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && !empty($user->admin) && empty($user->entity)) + { + return '0,'.implode(',', array_keys($this->getEntitiesList(true, false, true))); // Superadmin can always edit groups of another entities + } + + return '0,'.$conf->entity; + } + } + + // Sharing dictionnaries + if (array_key_exists($element, $this->sharingdicts)) + { + if (! empty($this->dict[$element])) { + return $conf->entity; + } else { + return 1; // Master entity + } + } + + // Check object entity when number sharing is disabled + if (is_object($currentobject) && + (($element == 'proposalnumber' && empty($conf->global->MULTICOMPANY_PROPOSALNUMBER_SHARING_ENABLED)) + || ($element == 'ordernumber' && empty($conf->global->MULTICOMPANY_ORDERNUMBER_SHARING_ENABLED)) + || ($element == 'invoicenumber' && empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) + ) + ) + { + // Use object entity ID + $entity = ((isset($currentobject->entity) && is_numeric($currentobject->entity)) ? $currentobject->entity : $conf->entity); + return $entity; + } + + $elementkey = $element; + if ($element == 'societe' || $element == 'socpeople' || $element == 'contact') { + $elementkey = 'thirdparty'; + } + if ($element == 'adherent') $elementkey = 'member'; + if ($element == 'bank_account') $elementkey = 'bankaccount'; + if ($element == 'adherent_type') $elementkey = 'member_type'; + if ($element == 'categorie') $elementkey = 'category'; + if ($element == 'propal') $elementkey = 'proposal'; + if ($element == 'commande') $elementkey = 'order'; + if ($element == 'facture') $elementkey = 'invoice'; + + if (! empty($element) && ! empty($this->entities[$elementkey])) + { + if (! empty($shared)) + { + return $this->entities[$elementkey]; + } + else if (! empty($this->sharings['referent'])) + { + if ($element == 'societe') return $this->sharings['referent']; + } + } + + return $conf->entity; + } + + /** + * Set entity id to use when to create an object + * + * @param object $currentobject Current object + * @return int Entity id to use + */ + public function setEntity($currentobject) + { + global $conf; + + $entity = $conf->entity; + + if (is_object($currentobject) && ! empty($currentobject->element)) + { + $element = array_search($currentobject->element, $this->sharingmodulename); + $element = (! empty($element) ? $element : $currentobject->element); + $constname = 'MULTICOMPANY_'.strtoupper($element).'_SHARING_ENABLED'; + $newentity = $entity; + + if (isset($this->sharingelements[$element]) + && isset($this->sharingelements[$element]['active']) + && ! empty($conf->global->$constname) + ) + { + if (GETPOSTISSET('entity') && GETPOST('entity', 'int', 2)) + { + $newentity = GETPOST('entity', 'int', 2); + } + else if (isset($currentobject->entity) && is_numeric($currentobject->entity)) + { + $newentity = $currentobject->entity; + } + + if (isset($this->sharings[$element]) && in_array($newentity, $this->sharings[$element])) + { + $entity = $newentity; + } + } + else + { + $entity = (($currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity : $conf->entity); + } + } + + return $entity; + } + + /** + * Get entities list + * + * @param int $login If use in login page or not + * @param array $exclude Entity ids to exclude + * @param bool $onlyactive sort only active entities + * @param bool $showtemplate Show or not templates + * @return array Array of entities (id => label) + */ + public function getEntitiesList($login = false, $exclude = false, $onlyactive = false, $showtemplate = false) + { + global $langs; + + $this->getInstanceDao(); + $this->dao->getEntities($login, $exclude, $onlyactive); + + $entities=array(); + + foreach ($this->dao->entities as $entity) + { + if (empty($showtemplate) && $entity->visible == 2) continue; + $entities[$entity->id] = dol_html_entity_decode($entity->label, null) . (empty($entity->active) ? ' ('.$langs->transnoentities('Disabled').')' : ($entity->visible == 2 ? ' ('.$langs->transnoentities('Template').')' : (empty($entity->visible) ? ' ('.$langs->transnoentities('Hidden').')' : '')) ); + } + + return $entities; + } + + /** + * Set object documents directory to use + * + * @param Conf $conf Object Conf + * @return void + */ + public function setMultiOutputDir(&$conf) + { + if (! empty($this->entities)) + { + foreach($this->entities as $element => $shares) + { + if ($element == 'thirdparty') $element = 'societe'; + elseif ($element == 'member') $element = 'adherent'; + elseif ($element == 'proposal') $element = 'propal'; + elseif ($element == 'order') $element = 'commande'; + elseif ($element == 'invoice') $element = 'facture'; + elseif ($element == 'intervention') $element = 'ficheinter'; + + if (! empty($conf->$element->enabled) && isset($conf->$element->multidir_output) && isset($conf->$element->multidir_temp)) + { + $elementpath=$element; + if ($element == 'product') $elementpath='produit'; + elseif ($element == 'category') $elementpath='categorie'; + elseif ($element == 'propal') $elementpath='propale'; + + $entities = explode(",", $shares); + $dir_output = array(); + $dir_temp = array(); + foreach($entities as $entity) + { + if (! array_key_exists($entity, $conf->$element->multidir_output)) + { + $path = ($entity > 1 ? "/".$entity : ''); + + $dir_output[$entity] = DOL_DATA_ROOT.$path."/".$elementpath; + $dir_temp[$entity] = DOL_DATA_ROOT.$path."/".$elementpath."/temp"; + + $conf->$element->multidir_output += $dir_output; + $conf->$element->multidir_temp += $dir_temp; + } + + if (in_array($element, array('propal', 'commande', 'facture')) && isset($conf->mycompany->multidir_output)) + { + if (! array_key_exists($entity, $conf->mycompany->multidir_output)) + { + $path = ($entity > 1 ? "/".$entity : ''); + + $dir_output[$entity] = DOL_DATA_ROOT.$path."/mycompany"; + $dir_temp[$entity] = DOL_DATA_ROOT.$path."/mycompany/temp"; + + $conf->mycompany->multidir_output += $dir_output; + $conf->mycompany->multidir_temp += $dir_temp; + } + } + } + } + } + } + } + + /** + * @param bool $parameters + * @return int + */ + public function printTopRightMenu($parameters=false) + { + echo $this->getTopRightMenu(); + + return 0; + } + + /** + * + */ + public function printBugtrackInfo($parameters=false) + { + global $conf; + + if (! empty($conf->multicompany->enabled)) { + $this->resprints = urlencode("- **Multicompany**: " . $conf->global->MULTICOMPANY_MAIN_VERSION . "\n"); + } + + return 0; + } + + /** + * @param bool $parameters + * @return int + */ + /*public function afterLogin($parameters=false) + { + global $conf; + + return 0; + }*/ + + /** + * @param bool $parameters + * @return int + */ + public function updateSession($parameters=false) + { + global $conf; + + // Switch to another entity + if (! empty($conf->multicompany->enabled) && GETPOST('action','aZ') == 'switchentity') + { + if ($this->switchEntity(GETPOST('entity','int')) > 0) + { + header("Location: ".DOL_URL_ROOT.'/'); + exit; + } + } + + return 0; + } + + /** + * + */ + public function getLoginPageOptions($parameters=false) + { + global $conf, $langs; + + if (is_array($parameters) && ! empty($parameters)) + { + foreach($parameters as $key => $value) + { + $$key=$value; + } + } + + // Entity combobox + if (empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX)) + { + if (empty($entity)) $entity=1; + $lastentity=(! empty($conf->global->MULTICOMPANY_FORCE_ENTITY)?$conf->global->MULTICOMPANY_FORCE_ENTITY:$entity); + $currentcontext = explode(':', $parameters['context']); + + if (in_array('cashdeskloginpage', $currentcontext)) + { + $select_entity = $this->select_entities($lastentity, 'entity', ' tabindex="3"', true, false, false, false, '', 'minwidth100imp'); + + $tableformat = ''; + $tableformat.= ''.$langs->trans("Entity").''; + $tableformat.= ''.$select_entity.''; + $tableformat.= ''; + + $this->resprints = $tableformat; + } + else + { + $select_entity = $this->select_entities($lastentity, 'entity', ' tabindex="3"', true, false, false, false, '', 'login-entity minwidth180'); + + $divformat = "\n".'
'."\n"; + $divformat.= '
'."\n"; + $divformat.= ''.$select_entity.''."\n"; + $divformat.= '
'; + + if (! empty($conf->global->MULTICOMPANY_LOGIN_LOGO_BY_ENTITY)) { + $divformat.= ' + '; + } + + $this->resprints = $divformat; + } + } + + return 0; + } + + /** + * + */ + public function getPasswordForgottenPageOptions($parameters=false) + { + return $this->getLoginPageOptions($parameters); + } + + /** + * Add all entities default dictionnaries in database + */ + public function addAllEntitiesDefaultDicts() + { + if (! empty($this->sharingdicts)) + { + $this->getInstanceDao(); + $this->dao->getEntities(); + + $dir = "/multicompany/sql/dict/"; + + foreach($this->sharingdicts as $dict => $data) + { + // Load sql init_new_entity_dict.sql file + $file = 'init_new_entity_'.$dict.'.sql'; + $fullpath = dol_buildpath($dir.$file); + + if (file_exists($fullpath)) + { + foreach ($this->dao->entities as $entity) + { + if ($entity->id == 1) continue; + + $result=run_sql($fullpath,1,$entity->id); + } + } + } + } + } + + /** + * Load shared elements + * + * @return void + */ + private function loadSharedElements() + { + global $conf; + + if (! empty($this->sharings)) + { + $this->getInstanceDao(); + + foreach($this->sharings as $element => $ids) + { + $modulesharingenabled = 'MULTICOMPANY_'.strtoupper($element).'_SHARING_ENABLED'; + + $module = ((isset($this->sharingmodulename[$element]) && !empty($this->sharingmodulename[$element])) ? $this->sharingmodulename[$element] : $element); + + if (! empty($conf->$module->enabled) && ! empty($conf->global->$modulesharingenabled)) + { + $entities=array(); + + if (! empty($this->referent)) + { + // Load configuration of referent entity + $this->config = $this->dao->getEntityConfig($this->referent); + $this->setConstant($conf, $element); + } + + if (! empty($ids)) + { + foreach ($ids as $id) + { + $ret=$this->dao->fetch($id); + if ($ret > 0 && $this->dao->active) + { + $entities[] = $id; + } + } + + $this->entities[$element] = (! empty($entities) ? implode(",", $entities) : 0); + $this->entities[$element].= ','.$conf->entity; + } + } + } + } + //var_dump($this->entities); + } + + /** + * Get modify entity dialog + */ + private function getModifyEntityDialog($htmlname, $action, $object) + { + global $langs; + + $langs->loadLangs(array('errors','multicompany@multicompany')); + + $selectEntities = $this->select_entities('', 'entity' . $htmlname, '', false, array($object->entity)); + + $out = ''; + + if (! empty($selectEntities)) { + + $out.= ''; + + $out.= ' + '; + + $out.= '
'."\n"; + $out.= '

' . img_warning() . ' ' . $langs->trans(ucfirst($htmlname) . 'ModifyEntityDescription') . '

'."\n"; + $out.= '
' . $langs->trans('SelectAnEntity'); + $out.= $selectEntities . '
'."\n"; + $out.= '
'."\n"; + + $out.= ''; + } + + return $out; + } + + /** + * Show entity info + */ + private function getTopRightMenu() + { + global $conf, $user, $langs; + + $langs->loadLangs(array('languages','admin','multicompany@multicompany')); + + $out=''; + + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) || ! empty($user->admin)) + { + if (($conf->global->MAIN_THEME === 'eldy' && empty($conf->global->MULTICOMPANY_DROPDOWN_MENU_DISABLED) && ! GETPOSTISSET('theme')) || (GETPOSTISSET('theme') && GETPOST('theme', 'aZ', 1) === 'eldy')) + { + $out.= $this->getDropdownMenu(); + } + else + { + $form=new Form($this->db); + + $this->getInfo($conf->entity); + + $selectEntities = $this->select_entities('', 'changeentity', '', false, array($conf->entity), false, false, '', 'minwidth200imp', true, true); + + $text =''; + if (($conf->global->MAIN_THEME === 'eldy' && empty($conf->global->MULTICOMPANY_NO_TOP_MENU_ENTITY_LABEL) && ! GETPOSTISSET('theme')) || (GETPOSTISSET('theme') && GETPOST('theme', 'aZ', 1) === 'eldy')) { + $text.= ''.$this->label.''; + } + $text.= ''; + + if ($cache = getCache('country_' . $this->country_id)) { + $country = $cache; + } else { + $country = getCountry($this->country_id); + setCache('country_' . $this->country_id, $country); + } + $imgCountry=picto_from_langcode($this->country_code, 'class="multicompany-flag-country"'); + $imgLang=picto_from_langcode($this->language_code, 'class="multicompany-flag-language"'); + + $htmltext =''.$langs->trans("Entity").''."\n"; + $htmltext.= '
'; + $htmltext.='
'.$langs->trans("Label").': '.$this->label."\n"; + $htmltext.='
'.$langs->trans("Country").': '. ($imgCountry?$imgCountry.' ':'') . $country."\n"; + $htmltext.='
'.$langs->trans("Currency").': '. currency_name($this->currency_code) . ' (' . $langs->getCurrencySymbol($this->currency_code) . ')'."\n"; + $htmltext.='
'.$langs->trans("Language").': '. ($imgLang?$imgLang.' ':'') . ($this->language_code=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$this->language_code)); + if (! empty($this->description)) $htmltext.='
'.$langs->trans("Description").': '.$this->description."\n"; + $htmltext.= '

'; + + $out.= $form->textwithtooltip('', $htmltext, 2, 1, $text, 'login_block_elem multicompany_block', 2); + + if (! empty($selectEntities)) { + $out.= ' + '; + + $out.= '
'."\n"; + $out.= '
'.$langs->trans('SelectAnEntity'); + $out.= $selectEntities; + $out.= '
'."\n"; + } else { + + } + } + } + + if (($level = checkMultiCompanyVersion()) === -2) + { + $msg = get_htmloutput_mesg(img_warning('default') . ' ' . $langs->trans("MultiCompanyUpgradeIsNeeded"), '', 'mc-upgrade-alert', 1); + $out.= ' + '; + } + + $this->resprints = $out; + } + + /** + * + * @return string + */ + private function getDropdownMenu() + { + global $conf, $user, $langs; + + $this->getInfo($conf->entity); + + if ($cache = getCache('country_' . $this->country_id)) { + $country = $cache; + } else { + $country = getCountry($this->country_id); + setCache('country_' . $this->country_id, $country); + } + $imgCountry=picto_from_langcode($this->country_code, 'class="multicompany-flag-country"'); + $imgLang=picto_from_langcode($this->language_code, 'class="multicompany-flag-language"'); + + $dropdownBody = ''; + $dropdownBody.= ' '.$langs->trans("ShowMoreInfos").''; + $dropdownBody.= '
'; + $dropdownBody.= '
'.$langs->trans("Entity").''."\n"; + $dropdownBody.= '
'.$langs->trans("Label").': '.$this->label."\n"; + $dropdownBody.= '
'.$langs->trans("Country").': '. ($imgCountry?$imgCountry.' ':'') . $country."\n"; + $dropdownBody.= '
'.$langs->trans("Currency").': '. currency_name($this->currency_code) . ' (' . $langs->getCurrencySymbol($this->currency_code) . ')'."\n"; + $dropdownBody.= '
'.$langs->trans("Language").': '. ($imgLang?$imgLang.' ':'') . ($this->language_code=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$this->language_code)); + if (! empty($this->description)) $dropdownBody.= '
'.$langs->trans("Description").': '.$this->description."\n"; + $dropdownBody.= '
'; + + $selectEntities = $this->select_entities('', 'changeentity', '', false, array($conf->entity), false, false, '', 'minwidth200imp', true, true); + + $entitySwitchLink ='
'.$langs->trans("SwitchEntity").'
'; + $entityConfigLink =' '.$langs->trans("Setup").''; + + $out = '
'; + $out.= '
'; + + $out.= ' + '; + + return $out; + } + + /** + * Set parameters with referent entity + * + * @param Conf $conf + * @param string $element + */ + public function setConstant(&$conf, $element) + { + if (! empty($this->config)) + { + $constants=array(); + + if ($element == 'thirdparty') + { + $constants = array( + 'SOCIETE_CODECLIENT_ADDON', + 'COMPANY_ELEPHANT_MASK_CUSTOMER', + 'COMPANY_ELEPHANT_MASK_SUPPLIER', + 'SOCIETE_IDPROF1_UNIQUE', + 'SOCIETE_IDPROF2_UNIQUE', + 'SOCIETE_IDPROF3_UNIQUE', + 'SOCIETE_IDPROF4_UNIQUE' + ); + } + + if (! empty($constants)) + { + foreach($constants as $name) + { + if (! empty($this->config[$name])) $conf->global->$name = $this->config[$name]; + } + } + } + } + + /** + * + * @param int $groupid + * @param int $template + * @param array $entities + * @return number + */ + public function duplicateUserGroupRights($groupid, $template, $entities) + { + require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; + + $error=0; + + dol_syslog(get_class($this)."::duplicateUserGroupRights groupid=".$groupid." template=".$template." entities=".implode(",", $entities), LOG_DEBUG); + + $groupstatic = new UserGroup($this->db); + $ret = $groupstatic->fetch($groupid, '', false); + if ($ret > 0) + { + $this->getInstanceDao(); + $permsgroupbyentity = $this->dao->getGroupRightsByEntity($groupid, $template); + + if (! empty($entities)) + { + foreach($entities as $entity) + { + if ($error > 0) break; + + $ret = $groupstatic->delrights('', 'allmodules', '', $entity); + if ($ret < 0) { + $error++; + break; + } + + foreach($permsgroupbyentity as $rid) + { + $ret = $groupstatic->addrights($rid, '', '', $entity); + if ($ret < 0) { + $error++; + break; + } + } + } + + if (!$error) { + return 1; + } else { + return -1; + } + + } else { + return -2; + } + + } else { + return -3; + } + } + +} diff --git a/htdocs/custom/multicompany/class/api_multicompany.class.php b/htdocs/custom/multicompany/class/api_multicompany.class.php new file mode 100755 index 00000000000..46ba5284f75 --- /dev/null +++ b/htdocs/custom/multicompany/class/api_multicompany.class.php @@ -0,0 +1,334 @@ + + * + * 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 . + */ + +use Luracast\Restler\RestException; + +dol_include_once('/multicompany/class/dao_multicompany.class.php', 'DaoMulticompany'); + +/** + * API class for multicompany + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class Multicompany extends DolibarrApi +{ + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'label' + ); + + /** + * Constructor + */ + function __construct() + { + global $db, $conf; + $this->db = $db; + } + + /** + * Get properties of an entity + * + * Return an array with entity informations + * + * @param int $id ID of entity + * @return array|mixed data without useless information + * + * @throws RestException + */ + function get($id) + { + if (! DolibarrApiAccess::$user->rights->multicompany->read) { + throw new RestException(401); + } + + // The DaoMulticompany::fetch() method uses the global variable $user. + global $user; + $user = DolibarrApiAccess::$user; + + $multicompany = new DaoMulticompany($this->db); + $result = $multicompany->fetch($id); + if ( ! $result ) { + throw new RestException(404, 'entity not found'); + } + + return $this->_cleanObjectDatas($multicompany); + } + + /** + * List entities + * + * Get a list of entities + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%') and (t.visible:=:'1')" + * @return array Array of entities objects + * + * @throws RestException + */ + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $sqlfilters = '') { + global $db, $conf; + + $obj_ret = array(); + + if(! DolibarrApiAccess::$user->rights->multicompany->read) { + throw new RestException(401); + } + + $sql = "SELECT t.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."entity as t"; + $sql.= ' WHERE t.active = 1'; + + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + if ($result) + { + // The DaoMulticompany::fetch() method uses the global variable $user. + global $user; + $user = DolibarrApiAccess::$user; + + $i=0; + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) + { + $obj = $db->fetch_object($result); + $multicompany= new DaoMulticompany($this->db); + if ($multicompany->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($multicompany); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve entities list : '.$db->lasterror()); + } + if ( ! count($obj_ret)) { + throw new RestException(404, 'No entities found'); + } + + return $obj_ret; + } + + /** + * Create entity object + * + * @param array $request_data Request data + * @return int ID of entity + */ + /*function post($request_data = null) + { + if (! DolibarrApiAccess::$user->rights->adherent->configurer) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validate($request_data); + + $membertype = new AdherentType($this->db); + foreach($request_data as $field => $value) { + $membertype->$field = $value; + } + if ($membertype->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, 'Error creating member type', array_merge(array($membertype->error), $membertype->errors)); + } + return $membertype->id; + }*/ + + /** + * Update entity + * + * @param int $id ID of entity to update + * @param array $request_data Datas + * @return int + */ + /*function put($id, $request_data = null) + { + if (! DolibarrApiAccess::$user->rights->adherent->configurer) { + throw new RestException(401); + } + + $membertype = new AdherentType($this->db); + $result = $membertype->fetch($id); + if( ! $result ) { + throw new RestException(404, 'member type not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('member',$membertype->id,'adherent_type')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach($request_data as $field => $value) { + if ($field == 'id') continue; + // Process the status separately because it must be updated using + // the validate() and resiliate() methods of the class AdherentType. + $membertype->$field = $value; + } + + // If there is no error, update() returns the number of affected rows + // so if the update is a no op, the return value is zero. + if ($membertype->update(DolibarrApiAccess::$user) >= 0) + return $this->get($id); + + return false; + }*/ + + /** + * Delete entity + * + * @param int $id entity ID + * @return array + */ + /*function delete($id) + { + if (! DolibarrApiAccess::$user->rights->adherent->configurer) { + throw new RestException(401); + } + $membertype = new AdherentType($this->db); + $result = $membertype->fetch($id); + if( ! $result ) { + throw new RestException(404, 'member type not found'); + } + + if ( ! DolibarrApi::_checkAccessToResource('member',$membertype->id,'adherent_type')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (! $membertype->delete($membertype->id)) { + throw new RestException(401,'error when deleting member type'); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'member type deleted' + ) + ); + }*/ + + /** + * Validate fields before creating an object + * + * @param array|null $data Data to validate + * @return array + * + * @throws RestException + */ + function _validate($data) + { + $membertype = array(); + foreach (MembersTypes::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $membertype[$field] = $data[$field]; + } + return $membertype; + } + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + // Remove constants + foreach($object as $key => $value) + { + if (preg_match('/^MAIN_/', $key)) + { + unset($object->$key); + } + } + + unset($object->language); + unset($object->fk_tables); + unset($object->import_key); + unset($object->array_options); + unset($object->linkedObjectsIds); + unset($object->context); + unset($object->canvas); + unset($object->fk_project); + unset($object->contact); + unset($object->contact_id); + unset($object->thirdparty); + unset($object->user); + unset($object->origin); + unset($object->origin_id); + unset($object->ref_ext); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->fk_delivery_address); + unset($object->shipping_method_id); + unset($object->modelpdf); + unset($object->fk_account); + unset($object->note_public); + unset($object->note_private); + unset($object->fk_incoterms); + unset($object->libelle_incoterms); + unset($object->location_incoterms); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->ref); + unset($object->statut); + unset($object->note); + + return $object; + } + +} diff --git a/htdocs/custom/multicompany/class/dao_multicompany.class.php b/htdocs/custom/multicompany/class/dao_multicompany.class.php new file mode 100755 index 00000000000..1760b43094f --- /dev/null +++ b/htdocs/custom/multicompany/class/dao_multicompany.class.php @@ -0,0 +1,990 @@ + + * Copyright (C) 2011 Herve Prot + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/multicompany/dao_multicompany.class.php + * \ingroup multicompany + * \brief File Class multicompany + */ +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; + +/** + * \class DaoMulticompany + * \brief Class of the module multicompany + */ +class DaoMulticompany extends CommonObject +{ + public $element = 'entity'; // !< Id that identify managed objects + public $table_element = 'entity'; // !< Name of table without prefix where object is stored + + public $id; + public $label; + public $description; + + public $options=array(); + public $options_json; + + public $entity=array(); + public $entities=array(); + + public $fk_tables=array(); + + public $visible; + public $active; + public $currency; + public $language; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + + $this->fk_tables = array( + 'societe' => array( + 'key' => 'fk_soc', + 'childs' => array( + 'societe_address', + 'societe_commerciaux', + 'societe_log', + 'societe_prices', + 'societe_remise', + 'societe_remise_except', + 'societe_rib', + 'socpeople' + ) + ), + 'product' => array( + 'key' => 'fk_product', + 'childs' => array( + 'product_ca', + 'product_lang', + 'product_price', + 'product_stock', + 'product_fournisseur_price' => array( + 'key' => 'fk_product_fournisseur', + 'childs' => array('product_fournisseur_price_log') + ), + ) + ), + 'projet' => array( + 'key' => 'fk_projet', + 'childs' => array( + 'projet_task' => array( + 'key' => 'fk_task', + 'childs' => array('projet_task_time') + ) + ) + ) + ); + } + + /** + * Fetch entity + * + * @param int $id + * @return int + */ + public function fetch($id) + { + global $user; + + //clearCache($id); + if ($cache = getCache($id)) + { + foreach ($cache as $key => $value) + { + $this->$key = $value; + } + } + else + { + $sql = "SELECT rowid, label, description, options, visible, active"; + $sql.= " FROM ".MAIN_DB_PREFIX."entity"; + $sql.= " WHERE rowid = ".$id; + + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + + $this->id = $obj->rowid; + $this->label = $obj->label; + $this->description = $obj->description; + $this->options = json_decode($obj->options, true); + $this->visible = $obj->visible; + $this->active = $obj->active; + + if (is_array($this->options) && ! empty($this->options) && is_array($this->options['sharings'])) + { + // for backward compatibility + if (array_key_exists('referent', $this->options['sharings'])) + { + if (empty($this->options['referent'])) + { + $this->options['referent'] = $this->options['sharings']['referent']; + } + unset($this->options['sharings']['referent']); + } + + // for backward compatibility + if (array_key_exists('societe', $this->options['sharings'])) + { + if (empty($this->options['sharings']['thirdparty'])) + { + $this->options['sharings']['thirdparty'] = $this->options['sharings']['societe']; + } + unset($this->options['sharings']['societe']); + } + + // for backward compatibility + if (array_key_exists('bank_account', $this->options['sharings'])) + { + if (empty($this->options['sharings']['bankaccount'])) + { + $this->options['sharings']['bankaccount'] = $this->options['sharings']['bank_account']; + } + unset($this->options['sharings']['bank_account']); + } + } + + $this->fetch_optionals(); + + $cache = array( + 'id' => $this->id, + 'label' => $this->label, + 'description' => $this->description, + 'options' => $this->options, + 'visible' => $this->visible, + 'active' => $this->active, + 'array_options' => $this->array_options + ); + + setCache($this->id, $cache); + } + else + { + return -2; + } + } + else + { + return -3; + } + } + + if (! empty($user->login)) + { + $this->getConstants(); + } + + return 1; + } + + /** + * Create entity + * + * @param User $user Object of user that ask creation + * @param int $call_trigger false = no, true = yes + * @return int >= 0 if OK, < 0 if KO + */ + public function create(User $user, $call_trigger = true) + { + global $conf; + + $error=0; + + // Clean parameters + $this->label = trim($this->label); + $this->description = trim($this->description); + $this->options_json = json_encode($this->options); + + dol_syslog(get_class($this)."::create ".$this->label); + + $this->db->begin(); + + $now=dol_now(); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."entity ("; + $sql.= "label"; + $sql.= ", description"; + $sql.= ", datec"; + $sql.= ", fk_user_creat"; + $sql.= ", options"; + $sql.= ", visible"; + $sql.= ", active"; + $sql.= ") VALUES ("; + $sql.= "'".$this->db->escape($this->label)."'"; + $sql.= ", '".$this->db->escape($this->description)."'"; + $sql.= ", '".$this->db->idate($now)."'"; + $sql.= ", ".$user->id; + $sql.= ", '".$this->db->escape($this->options_json)."'"; + $sql.= ", ".(! empty($this->visible)?$this->db->escape($this->visible):0); + $sql.= ", ".(! empty($this->active)?$this->db->escape($this->active):0); + $sql.= ")"; + + dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); + $result=$this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."entity"); + + if (! $error) { + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + $result = $this->insertExtraFields(); + if ($result < 0) { + $error ++; + } + } + } + + dol_syslog(get_class($this)."::Create success id=".$this->id); + } + + if (!$error && $call_trigger) + { + // Call trigger + $result = $this->call_trigger('MULTICOMPANY_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } + + if (empty($error)) { + $this->db->commit(); + return $this->id; + } + else + { + dol_syslog(get_class($this)."::Create echec ".$this->error); + $this->db->rollback(); + return -1; + } + } + + /** + * Update entity + * + * @param int $id Id of entity (deprecated, use 0 here and call update on an object loaded by a fetch) + * @param User $user User who requests the update + * @param int $call_trigger false = no, true = yes + * @return int <0 if KO, >=0 if OK + */ + public function update($id, User $user, $call_trigger = true) + { + global $conf; + + $error=0; + + if (empty($id)) $id = $this->id; + + // Clean parameters + $this->label = trim($this->label); + $this->description = trim($this->description); + $this->options_json = json_encode($this->options); + + dol_syslog(get_class($this)."::update id=".$id." label=".$this->label); + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."entity SET"; + $sql.= " label = '" . $this->db->escape($this->label) ."'"; + $sql.= ", description = '" . $this->db->escape($this->description) ."'"; + $sql.= ", options = '" . $this->db->escape($this->options_json) ."'"; + $sql.= " WHERE rowid = " . $id; + + dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); + $result=$this->db->query($sql); + if ($result) + { + dol_syslog(get_class($this)."::Update success id=".$id); + + if (! $error) { + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + $result = $this->insertExtraFields(); + if ($result < 0) { + $error ++; + } + } + } + } + + if (!$error && $call_trigger) + { + // Call trigger + $result = $this->call_trigger('MULTICOMPANY_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } + + if (empty($error)) { + $this->db->commit(); + clearCache($id); + clearCache('constants_' . $id); + return 1; + } + else + { + dol_syslog(get_class($this)."::Update echec ".$this->error, LOG_ERR); + $this->db->rollback(); + return -1; + } + } + + /** + * Delete entity + * + * @param int $id Id of entity to delete + * @param int $call_trigger false = no, true = yes + * @return int <0 if KO, >0 if OK + */ + public function delete($id, $call_trigger = true) + { + global $user; + + $error=0; + + $this->db->begin(); + + if (!$error && $call_trigger) + { + // Call trigger + $result = $this->call_trigger('MULTICOMPANY_DELETE', $user); + if ($result < 0) $error++; + // End call triggers + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; + $sql.= " WHERE entity = " . $id; + dol_syslog(get_class($this)."::Delete sql=".$sql, LOG_DEBUG); + if ($this->db->query($sql)) + { + // TODO remove records of all tables + } + else + { + $error++; + $this->error .= $this->db->lasterror(); + dol_syslog(get_class($this)."::Delete erreur -1 ".$this->error, LOG_ERR); + } + } + + // Removed extrafields + if (!$error) + { + $result = $this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -2 ".$this->error, LOG_ERR); + } + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."entity"; + $sql.= " WHERE rowid = " . $id; + dol_syslog(get_class($this)."::Delete sql=".$sql, LOG_DEBUG); + if (!$this->db->query($sql)) { + $error++; + $this->error .= $this->db->lasterror(); + dol_syslog(get_class($this)."::Delete erreur -1 ".$this->error, LOG_ERR); + } + } + + if (! $error) + { + dol_syslog(get_class($this)."::Delete success id=".$id); + $this->db->commit(); + clearCache($id); + clearCache('constants_' . $id); + return 1; + } + else + { + dol_syslog(get_class($this)."::Delete echec ".$this->error); + $this->db->rollback(); + return -1; + } + } + + /** + * + * + */ + public function getConstants() + { + $key = 'constants_' . $this->id; + //clearCache('constants_' . $this->id); + + if ($cache = getCache($key)) + { + foreach ($cache as $key => $value) + { + $this->$key = $value; + } + } + else + { + $cache=array(); + + $sql = "SELECT "; + $sql.= $this->db->decrypt('name')." as name"; + $sql.= ", ".$this->db->decrypt('value')." as value"; + $sql.= " FROM ".MAIN_DB_PREFIX."const"; + $sql.= " WHERE entity = ".$this->id; + $sql.= " AND ".$this->db->decrypt('name')." LIKE 'MAIN_%'"; + + $result = $this->db->query($sql); + if ($result) + { + $num=$this->db->num_rows($result); + $i=0; + + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + + if ($obj->name === 'MAIN_INFO_SOCIETE_COUNTRY') + { + $tmp = explode(':', $obj->value); + $this->country_id = $tmp[0]; + $cache['country_id'] = $this->country_id; + $this->country_code = $tmp[1]; + $cache['country_code'] = $this->country_code; + } + else if ($obj->name === 'MAIN_MONNAIE') + { + $this->currency_code = $obj->value; + $cache['currency_code'] = $this->currency_code; + } + else if ($obj->name === 'MAIN_LANG_DEFAULT') + { + $this->language_code = $obj->value; + $cache['language_code'] = $this->language_code; + } + else if ($obj->name === 'MAIN_INFO_SOCIETE_NOM') + { + $this->name = $obj->value; + $cache['name'] = $this->name; + } + else if ($obj->name === 'MAIN_INFO_SOCIETE_ZIP') + { + $this->zip = $obj->value; + $cache['zip'] = $this->zip; + } + else if ($obj->name === 'MAIN_INFO_SOCIETE_ADDRESS') + { + $this->address = $obj->value; + $cache['address'] = $this->address; + } + else if ($obj->name === 'MAIN_INFO_SOCIETE_TOWN') + { + $this->town = $obj->value; + $cache['town'] = $this->town; + } + else if ($obj->name === 'MAIN_INFO_SOCIETE_STATE') + { + $this->state_id = $obj->value; + $cache['state_id'] = $this->state_id; + } + + $constname = $obj->name; + $this->$constname = $obj->value; + $cache[$constname] = $this->$constname; + + $i++; + } + + setCache($key, $cache); + } + else + { + return -1; + } + } + + return 1; + } + + /** + * Remove all records of an entity + * + * @param int $id Entity id + * @return int + */ + private function deleteEntityRecords($id) + { + $error=1; + + $this->db->begin(); + + $tables = $this->db->DDLListTables($this->db->database_name); + if (is_array($tables) && ! empty($tables)) + { + foreach($tables as $table) + { + $fields = $this->db->DDLInfoTable($table); + foreach ($fields as $field) + { + if (is_array($field) && in_array('entity', $field)) + { + $tablewithoutprefix = str_replace(MAIN_DB_PREFIX, '', $table); + $objIds = $this->getIdByForeignKey($tablewithoutprefix, $id); + if (! empty($objIds)) + { + if (array_key_exists($tablewithoutprefix, $this->fk_tables)) + { + // Level 0 + $foreignKey = $this->fk_tables[$tablewithoutprefix]['key']; + foreach($this->fk_tables[$tablewithoutprefix]['childs'] as $childTable => $child) + { + // Level 1 + if (! is_int($childTable) && is_array($child)) + { + echo 'childTableLevel1='.$childTable.'
'; + $objLevel1Ids = array(); + foreach($objIds as $rowid) + { + $ret = $this->getIdByForeignKey($childTable, $rowid, $foreignKey); + if (!empty($ret)) + $objLevel1Ids = array_merge($objLevel1Ids, $ret); + } + + sort($objLevel1Ids); + //var_dump($objLevel1Ids); + + // Level 2 + foreach($child['childs'] as $childLevel2) + { + echo 'childTableLevel2='.$childLevel2.'
'; + foreach($objLevel1Ids as $rowid) + { + $sql = "DELETE FROM " . MAIN_DB_PREFIX . $childLevel2; + $sql.= " WHERE " . $child['key'] . " = " . $rowid; + //echo $sql.'
'; + //dol_syslog(get_class($this)."::deleteEntityRecords sql=" . $sql, LOG_DEBUG); + /*if (!$this->db->query($sql)) { + $error++; + $this->error .= $this->db->lasterror(); + dol_syslog(get_class($this)."::deleteEntityRecords error -1 " . $this->error, LOG_ERR); + }*/ + } + } + + foreach($objIds as $rowid) + { + $sql = "DELETE FROM " . MAIN_DB_PREFIX . $childTable; + $sql.= " WHERE " . $foreignKey . " = " . $rowid; + //echo $sql.'
'; + //dol_syslog(get_class($this)."::deleteEntityRecords sql=" . $sql, LOG_DEBUG); + /*if (!$this->db->query($sql)) { + $error++; + $this->error .= $this->db->lasterror(); + dol_syslog(get_class($this)."::deleteEntityRecords error -1 " . $this->error, LOG_ERR); + }*/ + } + } + else + { + foreach($objIds as $rowid) + { + $sql = "DELETE FROM " . MAIN_DB_PREFIX . $child; + $sql.= " WHERE " . $foreignKey . " = " . $rowid; + //echo $sql.'
'; + //dol_syslog(get_class($this)."::deleteEntityRecords sql=" . $sql, LOG_DEBUG); + /*if (!$this->db->query($sql)) { + $error++; + $this->error .= $this->db->lasterror(); + dol_syslog(get_class($this)."::deleteEntityRecords error -1 " . $this->error, LOG_ERR); + }*/ + } + } + } + echo 'with childs = '.$table.'
'; + } + else + { + echo 'without childs = '.$table.'
'; + } + } + } + } + } + + if (! $error) + { + dol_syslog(get_class($this)."::deleteEntityRecords success entity=".$id); + $this->db->commit(); + return 1; + } + else + { + dol_syslog(get_class($this)."::deleteEntityRecords echec ".$this->error); + $this->db->rollback(); + return -1; + } + } + return 0; + } + + /** + * Get all rowid from a table by couple foreign key / id + * + * @param string $table + * @param int $id + * @param string $foreignkey + * @param string $fieldname + * @return int[] + */ + private function getIdByForeignKey($table, $id, $foreignkey = 'entity', $fieldname = 'rowid') + { + $objIds=array(); + $foreignkey = (! empty($foreignkey) ? $foreignkey : 'entity'); + $fieldname = (! empty($fieldname) ? $fieldname : 'rowid'); + + $sql = "SELECT " . $fieldname . " FROM " . MAIN_DB_PREFIX . $table; + $sql.= " WHERE " . $foreignkey . " = " . $id; + //echo $sql.'
'; + $resql = $this->db->query($sql); + if ($resql) + { + $i = 0; + $num = $this->db->num_rows($resql); + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $objIds[] = $obj->$fieldname; + $i++; + } + } + + return $objIds; + } + + /** + * Set status of an entity + * + * @param int $id Id of entity + * @param string $type Type of status (visible or active) + * @param string $value Value of status (0: disable, 1: enable) + * @return int + */ + public function setEntity($id, $type='active', $value) + { + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."entity"; + $sql.= " SET " . $this->db->escape($type) . " = " . (int) $value; + $sql.= " WHERE rowid = " . (int) $id; + + dol_syslog(get_class($this)."::setEntity sql=".$sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $this->db->commit(); + clearCache($id); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + + /** + * List of entities + * + * @param int $login If use in login page or not + * @param array $exclude Entity ids to exclude + * @param bool $onlyactive sort only active entities + * @return void + */ + public function getEntities($login = false, $exclude = false, $onlyactive = false) + { + global $conf, $user; + + $this->entities=array(); + + if ($login || empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) || (! empty($user->admin) && empty($user->entity))) + { + $sql = "SELECT DISTINCT(rowid), rang"; // Distinct parce que si user dans plusieurs groupes d'une entité, la liste d'entités de la petite terre affiche plusieurs fois la même entité + $sql.= " FROM ".MAIN_DB_PREFIX."entity"; + if (! empty($user->admin) && empty($user->entity) && is_array($exclude) && ! empty($exclude)) + { + $exclude = implode(",", $exclude); + $sql.= " WHERE rowid NOT IN (" . $exclude .")"; + if (! empty($onlyactive)) $sql.= " AND active = 1"; + } + else if (! empty($onlyactive)) { + $sql.= " WHERE active = 1"; + } + if (!$login) { + $sql.= " ORDER BY rowid"; + } + else { + $sql.= " ORDER BY rang DESC, rowid ASC"; + } + } + else + { + $sql = "SELECT DISTINCT(entity) as rowid"; // Distinct parce que si user dans plusieurs groupes d'une entité, la liste d'entités de la petite terre affiche plusieurs fois la même entité + $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user"; + $sql.= " WHERE fk_user = ".$user->id; + $sql.= " ORDER BY entity"; + } + + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + + $objectstatic = new self($this->db); + $ret = $objectstatic->fetch($obj->rowid); + + $this->entities[$i] = $objectstatic; + + $i++; + } + } + } + + /** + * Check user $userid belongs to at least one group created into entity $id + * + * @param int $entity + * @param int $userid + * @return int + */ + public function verifyRight($entity, $userid) + { + global $conf; + + $tmpuser=new User($this->db); + $tmpuser->fetch($userid); + //$tmpuser->fetch($userid, '', '',0, $entity); // TODO check compatibility with DAV authentication + + if ($tmpuser->id) + { + if (empty($tmpuser->entity)) return 1; // superadmin always allowed + if ($tmpuser->entity == $entity && $tmpuser->admin) return 1; // entity admin allowed + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + { + if ($tmpuser->entity == $entity) return 1; // user allowed if belong to entity + } + else + { + $sql = "SELECT count(rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user"; + $sql.= " WHERE fk_user=".$userid; + $sql.= " AND entity=".$entity; + //echo $sql; + + dol_syslog(get_class($this)."::verifyRight sql=".$sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $obj = $this->db->fetch_object($result); + return $obj->nb; // user allowed if at least in one group + } + } + } + + return 0; + } + + /** + * Get constants values of an entity + * + * @param int $entity Entity id + * @param string $constname Specific contant + * @return array Array of constants + */ + public function getEntityConfig($entity, $constname=null) + { + $const=array(); + + $sql = "SELECT ".$this->db->decrypt('value')." as value"; + $sql.= ", ".$this->db->decrypt('name')." as name"; + $sql.= " FROM ".MAIN_DB_PREFIX."const"; + $sql.= " WHERE entity = " . $entity; + if (! empty($constname)) { + if (preg_match('/\_\*$/', $constname)) + { + $constname = str_replace('*', '', $constname); + $sql.= " AND ".$this->db->decrypt('name')." LIKE '" . $this->db->escape($constname) ."%'"; + } + else + { + $sql.= " AND ".$this->db->decrypt('name')." = '" . $this->db->escape($constname) ."'"; + } + } + + dol_syslog(get_class($this)."::getEntityConfig sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $i = 0; + $num = $this->db->num_rows($resql); + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + + $const[$obj->name] = $obj->value; + + $i++; + } + + } + return $const; + } + + /** + * Get group rights by entity + * + * @param int $group + * @param int $entity + * @return array[] + */ + public function getGroupRightsByEntity($group, $entity) + { + $permsgroupbyentity = array(); + + $sql = "SELECT DISTINCT r.id, r.libelle, r.module, gr.entity"; + $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,"; + $sql.= " ".MAIN_DB_PREFIX."usergroup_rights as gr"; + $sql.= " WHERE gr.fk_id = r.id"; + $sql.= " AND gr.entity = " . (int) $entity; + $sql.= " AND gr.fk_usergroup = " . (int) $group; + + dol_syslog(get_class($this)."::getGroupRightsByEntity sql=".$sql, LOG_DEBUG); + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + array_push($permsgroupbyentity, $obj->id); + $i++; + } + + $this->db->free($result); + + return $permsgroupbyentity; + } + else + { + dol_print_error($db); + } + } + + /** + * Get list of groups + * + * @return array + */ + public function getListOfGroups() + { + $ret=array(); + + $sql = "SELECT g.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; + $sql.= " GROUP BY g.rowid"; + + $resql = $this->db->query($sql); + if ($resql) + { + while ($obj = $this->db->fetch_object($resql)) + { + $ret[] = $obj->rowid; + } + + $this->db->free($result); + + return $ret; + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + } + + /** + * + * @param unknown $groupid + * @param unknown $template + * @return User[]|number + */ + public function getListOfUsersInGroupByTemplate($groupid, $template) + { + $ret=array(); + + $sql = "SELECT u.rowid, ug.entity as usergroup_entity"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql.= " WHERE ug.fk_user = u.rowid"; + $sql.= " AND ug.fk_usergroup = " . (int) $groupid; + $sql.= " AND ug.entity = " . (int) $template; + + dol_syslog(get_class($this)."::getListOfUsersInGroupByEntity groupid=".$groupid." template=".$template, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + while ($obj = $this->db->fetch_object($resql)) + { + if (! array_key_exists($obj->rowid, $ret)) + { + $newuser=new User($this->db); + $newuser->fetch($obj->rowid); + $ret[$obj->rowid]=$newuser; + } + } + + $this->db->free($resql); + + return $ret; + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + } + +} diff --git a/htdocs/custom/multicompany/class/index.html b/htdocs/custom/multicompany/class/index.html new file mode 100755 index 00000000000..e69de29bb2d diff --git a/htdocs/custom/multicompany/class/ssp.class.php b/htdocs/custom/multicompany/class/ssp.class.php new file mode 100755 index 00000000000..d048ea745ca --- /dev/null +++ b/htdocs/custom/multicompany/class/ssp.class.php @@ -0,0 +1,412 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file /multicompany/class/ssp.class.php + * \ingroup multicompany + * \brief File of class to manage DataTables server-side processing + */ + +/** + * \class SSP + * \brief DataTables server-side processing class + */ +class SSP +{ + /** + * Create the data output array for the DataTables rows + * + * @param array $columns Column information array + * @param array $data Data from the SQL get + * @return array Formatted data in a row based format + */ + static function data_output ( $columns, $data ) + { + $out = array(); + + for ( $i=0, $ien=count($data) ; $i<$ien ; $i++ ) { + $row = array(); + + for ( $j=0, $jen=count($columns) ; $j<$jen ; $j++ ) { + $column = $columns[$j]; + + // Is there a formatter? + if ( isset( $column['formatter'] ) ) { + $row[ $column['dt'] ] = $column['formatter']( $data[$i][ $column['db'] ], $data[$i] ); + } + else { + $row[ $column['dt'] ] = $data[$i][ $columns[$j]['db'] ]; + } + } + + $out[] = $row; + } + + return $out; + } + + + /** + * Paging + * + * Construct the LIMIT clause for server-side processing SQL query + * + * @param array $request Data sent to server by DataTables + * @param array $columns Column information array + * @return string SQL limit clause + */ + static function limit ( $request, $columns, $db ) + { + $limit = ''; + + if ( isset($request['start']) && $request['length'] != -1 ) { + $limit = $db->plimit(intval($request['length']), intval($request['start'])); + } + + return $limit; + } + + + /** + * Ordering + * + * Construct the ORDER BY clause for server-side processing SQL query + * + * @param array $request Data sent to server by DataTables + * @param array $columns Column information array + * @return string SQL order by clause + */ + static function order ( $request, $columns, $db ) + { + $order = ''; + $sortfield = array(); + $sortorder = array(); + + if ( isset($request['order']) && count($request['order']) ) { + $dtColumns = self::pluck( $columns, 'dt' ); + for ( $i=0, $ien=count($request['order']) ; $i<$ien ; $i++ ) { + // Convert the column index into the column data property + $columnIdx = intval($request['order'][$i]['column']); + $requestColumn = $request['columns'][$columnIdx]; + + $columnIdx = array_search( $requestColumn['data'], $dtColumns ); + $column = $columns[ $columnIdx ]; + + if ( $requestColumn['orderable'] == 'true' ) { + $dir = $request['order'][$i]['dir'] === 'asc' ? 'ASC' : 'DESC'; + $sortfield[] = $column['db']; + $sortorder[] = $dir; + } + } + + $order = $db->order(implode(', ', $sortfield), implode(', ', $sortorder)); + } + + return $order; + } + + + /** + * Searching / Filtering + * + * Construct the WHERE clause for server-side processing SQL query. + * + * NOTE this does not match the built-in DataTables filtering which does it + * word by word on any field. It's possible to do here performance on large + * databases would be very poor + * + * @param array $request Data sent to server by DataTables + * @param array $columns Column information array + * @param array $bindings Array of values for PDO bindings, used in the + * sql_exec() function + * @return string SQL where clause + */ + static function filter ( $request, $columns, $db ) + { + $globalSearch = array(); + $columnSearch = array(); + $dtColumns = self::pluck( $columns, 'dt' ); + + if ( isset($request['search']) && $request['search']['value'] != '' ) { + $str = $request['search']['value']; + + for ( $i=0, $ien=count($request['columns']) ; $i<$ien ; $i++ ) { + $requestColumn = $request['columns'][$i]; + $columnIdx = array_search( $requestColumn['data'], $dtColumns ); + $column = $columns[ $columnIdx ]; + + if ( $requestColumn['searchable'] == 'true' ) { + $globalSearch[] = $column['db']." LIKE '%" . $db->escape($str)."%'"; + } + } + } + + // Individual column filtering + if ( isset( $request['columns'] ) ) { + for ( $i=0, $ien=count($request['columns']) ; $i<$ien ; $i++ ) { + $requestColumn = $request['columns'][$i]; + $columnIdx = array_search( $requestColumn['data'], $dtColumns ); + $column = $columns[ $columnIdx ]; + + $str = $requestColumn['search']['value']; + + if ( $requestColumn['searchable'] == 'true' && + $str != '' ) { + $columnSearch[] = $column['db']." LIKE '%" . $db->escape($str)."%'"; + } + } + } + + // Combine the filters into a single string + $where = ''; + + if ( count( $globalSearch ) ) { + $where = '('.implode(' OR ', $globalSearch).')'; + } + + if ( count( $columnSearch ) ) { + $where = $where === '' ? + implode(' AND ', $columnSearch) : + $where .' AND '. implode(' AND ', $columnSearch); + } + + if ( $where !== '' ) { + $where = 'WHERE '.$where; + } + + return $where; + } + + + /** + * Perform the SQL queries needed for an server-side processing requested, + * utilising the helper functions of this class, limit(), order() and + * filter() among others. The returned array is ready to be encoded as JSON + * in response to an SSP request, or can be modified if needed before + * sending back to the client. + * + * @param array $request Data sent to server by DataTables + * @param string $table SQL table to query + * @param string $primaryKey Primary key of the table + * @param array $columns Column information array + * @return array Server-side processing response array + */ + static function simple ( $request, $db, $table, $primaryKey, $columns ) + { + // Build the SQL query string from the request + $limit = self::limit( $request, $columns, $db ); + $order = self::order( $request, $columns, $db ); + $where = self::filter( $request, $columns, $db ); + + // Main query to actually get the data + $sql = + "SELECT ".implode(", ", self::pluck($columns, 'db'))." + FROM $table + $where + $order + $limit"; + + $data = self::sql_exec($db, $sql); + //print_r($data); + + // Data set length after filtering + $resFilterLength = self::sql_exec($db, + "SELECT COUNT({$primaryKey}) + FROM $table + $where" + ); + $recordsFiltered = $resFilterLength[0][0]; + + // Total data set length + $resTotalLength = self::sql_exec($db, + "SELECT COUNT({$primaryKey}) + FROM $table" + ); + $recordsTotal = $resTotalLength[0][0]; + + /* + * Output + */ + return array( + "draw" => isset ( $request['draw'] ) ? + intval( $request['draw'] ) : + 0, + "recordsTotal" => intval( $recordsTotal ), + "recordsFiltered" => intval( $recordsFiltered ), + "data" => self::data_output( $columns, $data ) + ); + } + + + /** + * The difference between this method and the `simple` one, is that you can + * apply additional `where` conditions to the SQL queries. These can be in + * one of two forms: + * + * * 'Result condition' - This is applied to the result set, but not the + * overall paging information query - i.e. it will not effect the number + * of records that a user sees they can have access to. This should be + * used when you want apply a filtering condition that the user has sent. + * * 'All condition' - This is applied to all queries that are made and + * reduces the number of records that the user can access. This should be + * used in conditions where you don't want the user to ever have access to + * particular records (for example, restricting by a login id). + * + * @param array $request Data sent to server by DataTables + * @param string $table SQL table to query + * @param string $primaryKey Primary key of the table + * @param array $columns Column information array + * @param string $whereResult WHERE condition to apply to the result set + * @param string $whereAll WHERE condition to apply to all queries + * @return array Server-side processing response array + */ + static function complex ( $request, $db, $table, $primaryKey, $columns, $whereResult=null, $whereAll=null ) + { + $whereAllSql = ''; + + // Build the SQL query string from the request + $limit = self::limit( $request, $columns, $db ); + $order = self::order( $request, $columns, $db ); + $where = self::filter( $request, $columns, $db ); + + $whereResult = self::_flatten( $whereResult ); + $whereAll = self::_flatten( $whereAll ); + + if ( $whereResult ) { + $where = $where ? + $where .' AND '.$whereResult : + 'WHERE '.$whereResult; + } + + if ( $whereAll ) { + $where = $where ? + $where .' AND '.$whereAll : + 'WHERE '.$whereAll; + + $whereAllSql = 'WHERE '.$whereAll; + } + + // Main query to actually get the data + $data = self::sql_exec($db, + "SELECT ".implode(", ", self::pluck($columns, 'db'))." + FROM $table + $where + $order + $limit" + ); + + // Data set length after filtering + $resFilterLength = self::sql_exec($db, + "SELECT COUNT({$primaryKey}) + FROM $table + $where" + ); + $recordsFiltered = $resFilterLength[0][0]; + + // Total data set length + $resTotalLength = self::sql_exec($db, + "SELECT COUNT({$primaryKey}) + FROM $table ". + $whereAllSql + ); + $recordsTotal = $resTotalLength[0][0]; + + /* + * Output + */ + return array( + "draw" => isset ( $request['draw'] ) ? + intval( $request['draw'] ) : + 0, + "recordsTotal" => intval( $recordsTotal ), + "recordsFiltered" => intval( $recordsFiltered ), + "data" => self::data_output( $columns, $data ) + ); + } + + + /** + * Execute an SQL query on the database + * + * @param string $sql SQL query to execute. + * @return array Result from the query (all rows) + */ + static function sql_exec ( $db, $sql ) + { + $out=array(); + + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num_rows=$db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($out, $array); + $i++; + } + } + + return $out; + } + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Internal methods + */ + + /** + * Pull a particular property from each assoc. array in a numeric array, + * returning and array of the property values from each item. + * + * @param array $a Array to get data from + * @param string $prop Property to read + * @return array Array of property values + */ + static function pluck ( $a, $prop ) + { + $out = array(); + + for ( $i=0, $len=count($a) ; $i<$len ; $i++ ) { + $out[] = $a[$i][$prop]; + } + + return $out; + } + + + /** + * Return a string from an array or a string + * + * @param array|string $a Array to join + * @param string $join Glue for the concatenation + * @return string Joined string + */ + static function _flatten ( $a, $join = ' AND ' ) + { + if ( ! $a ) { + return ''; + } + else if ( $a && is_array($a) ) { + return implode( $join, $a ); + } + return $a; + } +} + diff --git a/htdocs/custom/multicompany/core/ajax/functions.php b/htdocs/custom/multicompany/core/ajax/functions.php new file mode 100755 index 00000000000..335d84fc154 --- /dev/null +++ b/htdocs/custom/multicompany/core/ajax/functions.php @@ -0,0 +1,286 @@ + + * Copyright (C) 2011 Herve Prot + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file multicompany/core/ajax/functions.php + * \brief File to return ajax result + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK',1); + +if (isset($_GET['action']) && $_GET['action'] === 'getEntityLogo') { + define("NOLOGIN",1); // This means this output page does not require to be logged. + $entity=(! empty($_GET['id']) ? (int) $_GET['id'] : 1); + if (is_numeric($entity)) define("DOLENTITY", $entity); +} + +$res=@include("../../../main.inc.php"); // For root directory +if (! $res && file_exists($_SERVER['DOCUMENT_ROOT']."/main.inc.php")) + $res=@include($_SERVER['DOCUMENT_ROOT']."/main.inc.php"); // Use on dev env only +if (! $res) $res=@include("../../../../main.inc.php"); // For "custom" directory + +dol_include_once('/multicompany/class/actions_multicompany.class.php', 'ActionsMulticompany'); +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; + +$id = GETPOST('id', 'int'); // id of entity +$action = GETPOST('action', 'alpha'); // action method +$type = GETPOST('type', 'alpha'); // type of action +$element = GETPOST('element', 'alpha'); // type of element +$fk_element = GETPOST('fk_element', 'int'); // id of element + +$template = GETPOST('template', 'int'); +if (GETPOSTISSET('entities')) { + $entities = json_decode(GETPOST('entities', 'none'), true); +} + +/* + * View + */ + +// Ajout directives pour resoudre bug IE +//header('Cache-Control: Public, must-revalidate'); +//header('Pragma: public'); + +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead('application/json'); + +if (empty($conf->multicompany->enabled)) { + echo json_encode(array('status' => 'error')); + $db->close(); + exit(); +} + +//print ''."\n"; + +// Registering the location of boxes +if (! empty($action) && is_numeric($id)) +{ + if ($action == 'switchEntity' && ! empty($user->login)) + { + dol_syslog("multicompany action=".$action." entity=".$id, LOG_DEBUG); + + $object = new ActionsMulticompany($db); + echo $object->switchEntity($id); + } + else if ($action == 'setStatusEnable' && ! empty($user->admin) && ! $user->entity) + { + dol_syslog("multicompany action=".$action." type=".$type." entity=".$id, LOG_DEBUG); + + $object = new ActionsMulticompany($db); + $fieldname = ($type == 'activetemplate' ? 'active' : $type); + echo $object->setStatus($id, $fieldname, 1); + } + else if ($action == 'setStatusDisable' && ! empty($user->admin) && ! $user->entity) + { + dol_syslog("multicompany action=".$action." type=".$type." entity=".$id, LOG_DEBUG); + + $object = new ActionsMulticompany($db); + $fieldname = ($type == 'activetemplate' ? 'active' : $type); + $ret = $object->setStatus($id, $fieldname, 0); + if ($ret == 1 && $type == 'active') { + $ret = $object->setStatus($id, 'visible', 0); + } + echo $ret; + } + else if ($action == 'deleteEntity' && $id != 1 && ! empty($user->admin) && ! $user->entity) + { + dol_syslog("multicompany action=".$action." entity=".$id, LOG_DEBUG); + + $object = new ActionsMulticompany($db); + echo $object->deleteEntity($id); + } + else if ($action == 'setColOrder' && ! empty($user->admin) && ! $user->entity) + { + $id = (int) $id; + $direction = GETPOST('dir', 'aZ'); + $colOrder = array('id' => $id, 'direction' => $direction); + + if (dolibarr_set_const($db, 'MULTICOMPANY_COLORDER', json_encode($colOrder), 'chaine', 0, '', 0) > 0) { + $ret = json_encode(array('status' => 'success')); + } + else { + $ret = json_encode(array('status' => 'error')); + } + + echo $ret; + } + else if ($action == 'setColHidden' && ! empty($user->admin) && ! $user->entity) + { + $state = GETPOST('state', 'aZ'); + $colHidden = (! empty($conf->global->MULTICOMPANY_COLHIDDEN) ? json_decode($conf->global->MULTICOMPANY_COLHIDDEN, true) : array()); + + if ($state == 'visible') { + $colHidden = array_diff($colHidden, array(intval($id))); + } else if ($state == 'hidden') { + array_push($colHidden, intval($id)); + } + + sort($colHidden); + + if (dolibarr_set_const($db, 'MULTICOMPANY_COLHIDDEN', json_encode($colHidden), 'chaine', 0, '', 0) > 0) { + $ret = json_encode(array('status' => 'success')); + } + else { + $ret = json_encode(array('status' => 'error')); + } + + echo $ret; + } + else if ($action == 'modifyEntity' && ((! empty($user->admin) && ! $user->entity) || ! empty($user->rights->multicompany->thirdparty->write))) + { + if ($element == 'societe') + { + $object = new Societe($db); + $ret = $object->fetch($fk_element); + if ($ret > 0) { + + $object->oldcopy = clone $object; + + // To not set code if third party is not concerned. But if it had values, we keep them. + if (empty($object->client) && empty($object->oldcopy->code_client)) $object->code_client=''; + if (empty($object->fournisseur) && empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur=''; + + $object->entity = $id; + + $ret = $object->update($object->id, $user, 0, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(), 'update', 1); + if ($ret > 0) { + $ret = json_encode(array('status' => 'success')); + } + else { + $ret = json_encode(array('status' => 'error', 'error' => $object->errors)); + } + } + else { + $ret = json_encode(array('status' => 'error', 'error' => $object->errors)); + } + } + else if ($element == 'contact') + { + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + + $object = new Contact($db); + $ret = $object->fetch($fk_element); + if ($ret > 0) { + + $object->entity = $id; + + $ret = $object->update($object->id, $user, 1, 'update', 1); + if ($ret > 0) { + $ret = json_encode(array('status' => 'success')); + } + else { + $ret = json_encode(array('status' => 'error', 'error' => $object->errors)); + } + } + else { + $ret = json_encode(array('status' => 'error', 'error' => $object->errors)); + } + } + + echo $ret; + } + else if ($action === 'getEntityOptions' && ! empty($conf->global->MULTICOMPANY_TEMPLATE_MANAGEMENT) && ! empty($user->admin) && empty($user->entity)) + { + $object = new ActionsMulticompany($db); + $object->getInfo($id); + + $entities = $object->getEntitiesList(false, false, true, true); + + echo json_encode( + array( + 'status' => 'success', + 'options' => $object->options, + 'labels' => $entities + ) + ); + } + else if ($action === 'duplicateUserGroupRights' && ! empty($conf->global->MULTICOMPANY_TEMPLATE_MANAGEMENT) && ! empty($user->admin) && empty($user->entity) && ! empty($template) && ! empty($entities)) + { + $multicompany = new ActionsMulticompany($db); + $ret = $multicompany->duplicateUserGroupRights($id, $template, $entities); + if ($ret > 0) + { + echo json_encode(array('status' => 'success')); + } + else + { + echo json_encode(array( + 'status' => 'error', + 'id' => $id, + 'template' => $template, + 'entities' => $entities + ) + ); + } + } + else if ($action === 'getEntityLogo' && empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX)) + { + $urllogo = DOL_URL_ROOT.'/theme/login_logo.png'; + + if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) + { + $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&entity='.$id.'&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); + } + elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) + { + $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&entity='.$id.'&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo); + $width = 128; + } + elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png')) + { + $urllogo = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png'; + } + elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png')) + { + $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.png'; + } + + $bgimg = null; + $unsplashimg = null; + + if (! empty($conf->global->MULTICOMPANY_LOGIN_BACKGROUND_BY_ENTITY)) + { + if (! empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) + { + $unsplashimg = $conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND; + } + + if (! empty($conf->global->MAIN_LOGIN_BACKGROUND)) + { + $bgimg = DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&entity='.$id.'&modulepart=mycompany&file=logos/'.urlencode($conf->global->MAIN_LOGIN_BACKGROUND); + } + } + + echo json_encode(array( + 'status' => 'success', + 'urllogo' => dol_html_entity_decode($urllogo, null), + 'bgimg' => dol_html_entity_decode($bgimg, null), + 'unsplashimg' => dol_html_entity_decode($unsplashimg, null) + ) + ); + } +} + +$db->close(); diff --git a/htdocs/custom/multicompany/core/ajax/index.html b/htdocs/custom/multicompany/core/ajax/index.html new file mode 100755 index 00000000000..e69de29bb2d diff --git a/htdocs/custom/multicompany/core/ajax/list.php b/htdocs/custom/multicompany/core/ajax/list.php new file mode 100755 index 00000000000..30b48cce8bc --- /dev/null +++ b/htdocs/custom/multicompany/core/ajax/list.php @@ -0,0 +1,248 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file /multicompany/core/ajax/list.php + * \brief File to return datables output of entities list + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK',1); + +$res=@include("../../../main.inc.php"); // For root directory +if (! $res && file_exists($_SERVER['DOCUMENT_ROOT']."/main.inc.php")) + $res=@include($_SERVER['DOCUMENT_ROOT']."/main.inc.php"); // Use on dev env only +if (! $res) $res=@include("../../../../main.inc.php"); // For "custom" directory + +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +dol_include_once('/multicompany/class/dao_multicompany.class.php', 'DaoMulticompany'); +dol_include_once('/multicompany/lib/multicompany.lib.php'); +dol_include_once('/multicompany/class/ssp.class.php'); + +$langs->loadLangs(array('languages','admin','multicompany@multicompany')); + +// Defini si peux lire/modifier permisssions +$canreadEntity=! empty($user->admin); +$caneditEntity=! empty($user->admin); +$candeleteEntity=! empty($user->admin); + +top_httphead('application/json'); + +//print ''."\n"; + +//print_r($_GET); + +if (empty($user->admin) || empty($conf->multicompany->enabled)) { + echo json_encode(array('status' => 'error')); + $db->close(); + exit(); +} + +$object = new DaoMulticompany($db); + +$extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->element); + +$start = array('start' => GETPOST('start', 'int')); +$length = array('length' => GETPOST('length', 'int')); +$draw = array('draw' => GETPOST('draw', 'int')); +$order = array('order' => GETPOST('order', 'array')); +$columns = array('columns' => GETPOST('columns', 'array')); +$search = array('search' => GETPOST('search', 'array')); + +$request = $start + $length + $draw + $order + $columns + $search; +//print_r($request); + +// DB table to use +$table = MAIN_DB_PREFIX . "entity"; + +// Table's primary key +$primaryKey = 'rowid'; + +// Array of database columns which should be read and sent back to DataTables. +// The `db` parameter represents the column name in the database, while the `dt` +// parameter represents the DataTables column identifier. In this case simple +// indexes +$columns = array(); + +$columns[]= array( 'db' => 'rowid', 'dt' => 'entity_id' ); +$columns[]= array( 'db' => 'label', 'dt' => 'entity_label' ); +$columns[]= array( 'db' => 'description', 'dt' => 'entity_description' ); +$columns[]= array( + 'db' => 'rowid', + 'dt' => 'entity_name', + 'formatter' => function($value, $row) { + if (! empty($value)) { + global $object; + $object->fetch($value); + return $object->name; + } + } +); +$columns[]= array( + 'db' => 'rowid', + 'dt' => 'entity_zip', + 'formatter' => function($value, $row) { + if (! empty($value)) { + global $object; + $object->fetch($value); + return $object->zip; + } + } +); +$columns[]= array( + 'db' => 'rowid', + 'dt' => 'entity_town', + 'formatter' => function($value, $row) { + if (! empty($value)) { + global $object; + $object->fetch($value); + return $object->town; + } + } +); +$columns[]= array( + 'db' => 'rowid', + 'dt' => 'entity_country', + 'formatter' => function($value, $row) { + if (! empty($value)) { + global $object; + $object->fetch($value); + if ($cache = getCache('country_' . $object->country_id)) { + $country = $cache; + } else { + $country = getCountry($object->country_id); + setCache('country_' . $object->country_id, $country); + } + $img=picto_from_langcode($object->country_code, 'class="multicompany-flag-country"'); + return ($img?$img.' ':'') . $country; + } + } +); +$columns[]= array( + 'db' => 'rowid', + 'dt' => 'entity_currency', + 'formatter' => function($value, $row) { + if (! empty($value)) { + global $langs, $object; + $object->fetch($value); + return currency_name($object->currency_code) . ' (' . $langs->getCurrencySymbol($object->currency_code) . ')'; + } + } +); +$columns[]= array( + 'db' => 'rowid', + 'dt' => 'entity_language', + 'formatter' => function($value, $row) { + if (! empty($value)) { + global $langs, $object; + $object->fetch($value); + $img=picto_from_langcode($object->language_code, 'class="multicompany-flag-language"'); + return ($img?$img.' ':'') . ($object->language_code=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$object->language_code)); + } + } +); +if (! empty($extralabels)) { + foreach ($extralabels as $key => $name) + { + $columns[]= array( + 'db' => 'rowid', + 'dt' => 'entity_'.$key, + 'formatter' => function($value, $row) use ($key) { + global $object, $extrafields; + unset($object->array_options['options_'.$key]); // For avoid duplicate data in next row + $object->fetch_optionals(); + return $extrafields->showOutputField($key, $object->array_options['options_'.$key]); + } + ); + } +} +$columns[]= array( + 'db' => 'visible', + 'dt' => 'entity_visible', + 'formatter' => function($value, $row) { + global $langs; + if (! empty($value)) { + if ($value == 1) { + return img_picto($langs->trans("Enabled"),'on','id="visible_' . $row['rowid'] . '"',false,0,0,'','multicompany-button-visible-on'); + } else { + return ''; + } + } else if (! empty($row['active'])) { + return img_picto($langs->trans("Disabled"),'off','id="visible_' . $row['rowid'] . '"',false,0,0,'','multicompany-button-visible-off'); + } else { + return img_picto($langs->trans("Disabled"),'off','id="visible_' . $row['rowid'] . '"',false,0,0,'','multicompany-button-disabled'); + } + } +); +$columns[]= array( + 'db' => 'active', + 'dt' => 'entity_active', + 'formatter' => function($value, $row) { + global $conf, $langs; + if ($row['rowid'] == 1 || $conf->entity == $row['rowid']) { + return img_picto($langs->trans("Enabled"),'on','id="active_' . $row['rowid'] . '"',false,0,0,'','multicompany-button-disabled'); + } else if (! empty($value)) { + if ($row['visible'] == 2) { + return img_picto($langs->trans("Enabled"),'on','id="activetemplate_' . $row['rowid'] . '"',false,0,0,'','multicompany-button-active-on'); + } else { + return img_picto($langs->trans("Enabled"),'on','id="active_' . $row['rowid'] . '"',false,0,0,'','multicompany-button-active-on'); + } + } else { + if ($row['visible'] == 2) { + return img_picto($langs->trans("Disabled"),'off','id="activetemplate_' . $row['rowid'] . '"',false,0,0,'','multicompany-button-active-off'); + } else { + return img_picto($langs->trans("Disabled"),'off','id="active_' . $row['rowid'] . '"',false,0,0,'','multicompany-button-active-off'); + } + } + } +); +$columns[]= array( + 'db' => 'rowid', + 'dt' => 'entity_tools', + 'formatter' => function($value, $row) { + global $conf, $langs, $caneditEntity, $candeleteEntity; + $ret=''; + if ($caneditEntity) { + $ret.= img_edit($langs->transnoentities("Edit"),0, 'id="edit_' . $value . '" class="multicompany-button-setup"'); + } + if ($candeleteEntity) { + if ($value == 1 || $conf->entity == $value) { + $ret.= img_delete($langs->transnoentities("Delete"), 'id="delete_' . $value . '" class="multicompany-button-disabled"'); + } else { + $ret.= img_delete($langs->transnoentities("Delete"), 'id="delete_' . $value . '" class="multicompany-button-delete"'); + } + } + return $ret; + } +); + +//var_dump($columns); +echo json_encode( + SSP::simple( $request, $db, $table, $primaryKey, $columns ) +); + +$db->close(); diff --git a/htdocs/custom/multicompany/core/js/index.html b/htdocs/custom/multicompany/core/js/index.html new file mode 100755 index 00000000000..e69de29bb2d diff --git a/htdocs/custom/multicompany/core/js/lib_head.js b/htdocs/custom/multicompany/core/js/lib_head.js new file mode 100755 index 00000000000..668687e127e --- /dev/null +++ b/htdocs/custom/multicompany/core/js/lib_head.js @@ -0,0 +1,214 @@ +// Copyright (C) 2014-2019 Regis Houssin +// +// 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 . +// or see http://www.gnu.org/ + +// +// \file /multicompany/core/js/lib_head.js +// \brief File that include javascript functions (included if option use_javascript activated) +// + +/* + * + */ +function setMulticompanyConstant(url, code, input, entity) { + $.get( url, { + action: "set", + name: code, + entity: entity + }, + function() { + $("#set_" + code).hide(); + $("#del_" + code).show(); + $.each(input, function(type, data) { + // Enable another element + if (type == "enabled") { + $.each(data, function(key, value) { + var newvalue=(value.search("^#") < 0 ? "#" : "") + value; + $(newvalue).removeAttr("disabled"); + }); + // Disable another element + } else if (type == "disabled") { + $.each(data, function(key, value) { + var newvalue=(value.search("^#") < 0 ? "#" : "") + value; + $(newvalue).attr("disabled", true); + }); + // enable and disable another element + } else if (type == "disabledenabled") { + $.each(data, function(key, value) { + var newvalue=(value.search("^#") < 0 ? "#" : "") + value; + $(newvalue).removeAttr("disabled"); + }); + // Show another element + } else if (type == "showhide" || type == "show") { + $.each(data, function(key, value) { + var newvalue=(value.search("^#") < 0 ? "#" : "") + value; + $(newvalue).show(); + }); + } else if (type == "hideshow") { + $.each(data, function(key, value) { + var newvalue=(value.search("^#") < 0 ? "#" : "") + value; + $(newvalue).hide(); + }); + // Set another constant + } else if (type == "set" || type == "del") { + $.each(data, function(key, value) { + if (type == "set") { + $("#set_" + value).hide(); + $("#del_" + value).show(); + $.get( url, { + action: type, + name: key, + value: value, + entity: entity + }); + } else if (type == "del") { + $("#del_" + value).hide(); + $("#set_" + value).show(); + $.get( url, { + action: type, + name: value, + entity: entity + }); + } + }); + // reload the current page + } else if (type == "reload") { + var url = window.location.pathname; + location.href=url; + } + }); + }); +} + +/* + * + */ +function delMulticompanyConstant(url, code, input, entity) { + $.get( url, { + action: "del", + name: code, + entity: entity + }, + function() { + $("#del_" + code).hide(); + $("#set_" + code).show(); + $.each(input, function(type, data) { + // Enable another element + if (type == "enabled") { + $.each(data, function(key, value) { + var newvalue=(value.search("^#") < 0 ? "#" : "") + value; + $(newvalue).removeAttr("disabled"); + }); + // Disable another element + } else if (type == "disabled") { + $.each(data, function(key, value) { + var newvalue=(value.search("^#") < 0 ? "#" : "") + value; + $(newvalue).attr("disabled", true); + }); + // enable and disable another element + } else if (type == "disabledenabled") { + $.each(data, function(key, value) { + var newvalue=(value.search("^#") < 0 ? "#" : "") + value; + $(newvalue).attr("disabled", true); + }); + } else if (type == "showhide" || type == "hide") { + $.each(data, function(key, value) { + var newvalue=(value.search("^#") < 0 ? "#" : "") + value; + $(newvalue).hide(); + }); + } else if (type == "hideshow") { + $.each(data, function(key, value) { + var newvalue=(value.search("^#") < 0 ? "#" : "") + value; + $(newvalue).show(); + }); + // Delete another constant + } else if (type == "set" || type == "del") { + $.each(data, function(key, value) { + if (type == "set") { + $("#set_" + value).hide(); + $("#del_" + value).show(); + $.get( url, { + action: type, + name: key, + value: value, + entity: entity + }); + } else if (type == "del") { + $("#del_" + value).hide(); + $("#set_" + value).show(); + $.get( url, { + action: type, + name: value, + entity: entity + }); + } + }); + // reload the current page + } else if (type == "reload") { + var url = window.location.pathname; + location.href=url; + } + }); + }); +} + +/* + * + */ +function confirmMulticompanyConstantAction(action, url, code, input, box, entity, yesButton, noButton) { + var boxConfirm = box; + $("#confirm_" + code) + .attr("title", boxConfirm.title) + .html(boxConfirm.content) + .dialog({ + resizable: false, + height: 180, + width: 500, + modal: true, + buttons: [ + { + id : 'yesButton_' + code, + text : yesButton, + click : function() { + if (action == "set") { + setMulticompanyConstant(url, code, input, entity); + } else if (action == "del") { + delMulticompanyConstant(url, code, input, entity); + } + // Close dialog + $(this).dialog("close"); + // Execute another method + if (boxConfirm.method) { + var fnName = boxConfirm.method; + if (window.hasOwnProperty(fnName)) { + window[fnName](); + } + } + } + }, + { + id : 'noButton_' + code, + text : noButton, + click : function() { + $(this).dialog("close"); + } + } + ] + }); + // For information dialog box only, hide the noButton + if (boxConfirm.info) { + $("#noButton_" + code).button().hide(); + } +} diff --git a/htdocs/custom/multicompany/core/login/functions_mc.php b/htdocs/custom/multicompany/core/login/functions_mc.php new file mode 100755 index 00000000000..69dc4d86659 --- /dev/null +++ b/htdocs/custom/multicompany/core/login/functions_mc.php @@ -0,0 +1,166 @@ + + * + * 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 multicompany/core/login/functions_mc.php + * \ingroup multicompany + * \brief Authentication functions for Multicompany mode when combobox in login page is disabled + */ + + +/** + * Check validity of user/password/entity + * If test is ko, reason must be filled into $_SESSION["dol_loginmesg"] + * + * @param string $usertotest Login + * @param string $passwordtotest Password + * @param int $entitytotest Number of instance (always 1 if module multicompany not enabled) + * @return string Login if OK, '' if KO + */ +function check_user_password_mc($usertotest,$passwordtotest,$entitytotest=1) +{ + global $db,$conf,$langs; + global $mc; + + dol_syslog("functions_mc::check_user_password_mc usertotest=".$usertotest); + + $login=''; + + if (!empty($conf->multicompany->enabled)) + { + $langs->loadLangs(array('main','errors','multicompany@multicompany')); + + if (! empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX)) + { + $entity=$entitytotest; + + if (!empty($usertotest)) + { + // If test username/password asked, we define $test=false and $login var if ok, set $_SESSION["dol_loginmesg"] if ko + $table = MAIN_DB_PREFIX."user"; + $usernamecol = 'login'; + $entitycol = 'entity'; + + $sql ='SELECT rowid, entity, pass, pass_crypted'; + $sql.=' FROM '.$table; + $sql.=' WHERE '.$usernamecol." = '".$db->escape($usertotest)."'"; + $sql.=' AND statut = 1'; + + dol_syslog("functions_mc::check_user_password_mc sql=" . $sql); + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + if ($obj) + { + $passclear=$obj->pass; + $passcrypted=$obj->pass_crypted; + $passtyped=$passwordtotest; + + $passok=false; + + // Check crypted password + $cryptType=''; + if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) $cryptType=$conf->global->DATABASE_PWD_ENCRYPTED; + + // By default, we used MD5 + if (! in_array($cryptType,array('md5'))) $cryptType='md5'; + // Check crypted password according to crypt algorithm + if ($cryptType == 'md5') + { + if (dol_verifyHash($passtyped, $passcrypted)) + { + $passok=true; + dol_syslog("functions_mc::check_user_password_mc Authentification ok - " . $cryptType . " of pass is ok"); + } + } + + // For compatibility with old versions + if (! $passok) + { + if ((! $passcrypted || $passtyped) + && ($passclear && ($passtyped == $passclear))) + { + $passok=true; + dol_syslog("functions_mc::check_user_password_mc Authentification ok - found pass in database"); + } + } + + if ($passok && !empty($obj->entity)) + { + global $entitytotest; + + $entitytotest = $obj->entity; + + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + { + $sql = "SELECT uu.entity"; + $sql.= " FROM " . MAIN_DB_PREFIX . "usergroup_user as uu"; + $sql.= ", " . MAIN_DB_PREFIX . "entity as e"; + $sql.= " WHERE uu.entity = e.rowid AND e.visible < 2"; // Remove template of entity + $sql.= " AND fk_user = " . $obj->rowid; + + dol_syslog("functions_mc::check_user_password_mc sql=" . $sql, LOG_DEBUG); + $result = $db->query($sql); + if ($result) + { + while($array = $db->fetch_array($result)) // user allowed if at least in one group + { + $entitytotest = $array['entity']; + break; // stop in first entity + } + } + } + + $ret=$mc->switchEntity($entitytotest, $obj->rowid); + + if ($ret < 0) $passok=false; + } + + // Password ok ? + if ($passok) + { + $login=$usertotest; + } + else + { + dol_syslog("functions_mc::check_user_password_mc Authentification ko bad password pour '".$usertotest."'", LOG_ERR); + $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword"); + } + } + else + { + dol_syslog("functions_mc::check_user_password_mc Authentification ko user not found for '".$usertotest."'", LOG_ERR); + $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword"); + } + } + else + { + dol_syslog("functions_mc::check_user_password_mc Authentification ko db error for '".$usertotest."' error=".$db->lasterror(), LOG_ERR); + $_SESSION["dol_loginmesg"]=$db->lasterror(); + } + } + } + else + { + dol_syslog("functions_mc::check_user_password_mc Authentification ko, the drop-down list of entities on the login page must be hidden", LOG_ERR); + $_SESSION["dol_loginmesg"]=$langs->trans("ErrorDropDownListOfEntitiesMustBeHidden"); + } + } + + return $login; +} diff --git a/htdocs/custom/multicompany/core/login/index.html b/htdocs/custom/multicompany/core/login/index.html new file mode 100755 index 00000000000..e69de29bb2d diff --git a/htdocs/custom/multicompany/core/modules/index.html b/htdocs/custom/multicompany/core/modules/index.html new file mode 100755 index 00000000000..e69de29bb2d diff --git a/htdocs/custom/multicompany/core/modules/modMultiCompany.class.php b/htdocs/custom/multicompany/core/modules/modMultiCompany.class.php new file mode 100755 index 00000000000..6f2bd0f908c --- /dev/null +++ b/htdocs/custom/multicompany/core/modules/modMultiCompany.class.php @@ -0,0 +1,587 @@ + + * Copyright (C) 2011 Herve Prot + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \defgroup multicompany Module multicompany + * \brief Descriptor file for module multicompany + * \file htdocs/core/modules/modMultiCompany.class.php + * \ingroup multicompany + * \brief Description and activation file for module MultiCompany + */ +include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php'; + + +/** + * \class modMultiCompany + * \brief Description and activation class for module MultiCompany + */ +class modMultiCompany extends DolibarrModules +{ + /** + * Constructor. + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $langs; + + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 5000; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'multicompany'; + + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "base"; + // Gives the possibility to the module, to provide his own family info and position of this family. + $this->familyinfo = array( + 'core' => array( + 'position' => '001', + 'label' => $langs->trans("iNodbox") + ) + ); + // Module position in the family + $this->module_position = 1; + // 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)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Multi-Company Management"; + //$this->descriptionlong = "A very lon description. Can be a full HTML content"; + $this->editor_name = 'Régis Houssin'; + $this->editor_url = 'https://www.inodbox.com'; + // Can be enabled / disabled only in the main company with superadmin account + $this->core_enabled = 1; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = '12.0.1'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of png file (without png) used for this module. + // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png. + $this->picto='multicompany@multicompany'; + + // Data directories to create when module is enabled. + $this->dirs = array(); + + // Config pages. Put here list of php page names stored in admmin directory used to setup module. + $this->config_page_url = array("multicompany.php@multicompany"); + + // Defined all module parts (triggers, login, substitutions, menus, css, etc...) + $this->module_parts = array( + 'login' => array( + 'data' => 1, + 'entity' => '0' + ), + 'triggers' => array( + 'data' => 1, + 'entity' => '0' + ), + 'hooks' => array( + 'data' => array( + 'login', + 'main', + 'mainloginpage', + 'cashdeskloginpage', + 'passwordforgottenpage', + 'toprightmenu', + 'adminmodules', + 'admincompany', + 'commonobject', + 'thirdpartycard', + 'thirdpartylist', + 'customerlist', + 'prospectlist', + 'supplierlist', + 'usercard', + 'userperms', + 'groupcard', + 'groupperms', + 'userlist', + 'userhome', + 'userdao', + 'contactlist', + 'contactprospectlist', + 'contactcustomerlist', + 'contactsupplierlist', + 'contactotherlist', + 'productcard', + 'pricesuppliercard', + 'propalcard', + 'propallist', + 'ordercard', + 'orderlist', + 'invoicecard', + 'invoicelist', + 'warehousecard', + 'stocklist' + ), + 'entity' => '0' + ), + 'css' => array( + 'data' => '/multicompany/css/multicompany.css.php', + 'entity' => '0' + ) + ); + + // Dependencies + $this->depends = array(); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->phpmin = array(5,6); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(12,0,0); // Minimum version of Dolibarr required by module + $this->langfiles = array("multicompany@multicompany"); + + // Constants + // List of particular constants to add when module is enabled + $this->const=array( + 1 => array('MULTICOMPANY_MAIN_VERSION', 'chaine', $this->version, '', 0, 'multicompany', 1), + 2 => array('MULTICOMPANY_EXTERNAL_MODULES_SHARING', 'chaine', '', '', 0, 'multicompany', 0), + 3 => array('MULTICOMPANY_NO_TOP_MENU_ENTITY_LABEL', 'chaine', 1, '', 0, 'multicompany', 0) + ); + + // Boxes + $this->boxes = array(); // List of boxes + $r=0; + + // Permissions + $this->rights = array(); + $r=0; + + $r++; + $this->rights[$r][0] = 5001; + $this->rights[$r][1] = 'Read entities (For superadmin users)'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'read'; + + $r++; + $this->rights[$r][0] = 5002; + $this->rights[$r][1] = 'Create/modify entities (For superadmin users)'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'write'; + + $r++; + $this->rights[$r][0] = 5003; + $this->rights[$r][1] = 'Delete entities (For superadmin users)'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'delete'; + + // Thirdparty sharing (501x) + + $r++; + $this->rights[$r][0] = 5011; + $this->rights[$r][1] = 'Read shared third parties'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'thirdparty'; + $this->rights[$r][5] = 'read'; + + $r++; + $this->rights[$r][0] = 5012; + $this->rights[$r][1] = 'Create/modify shared third parties'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'thirdparty'; + $this->rights[$r][5] = 'write'; + + $r++; + $this->rights[$r][0] = 5013; + $this->rights[$r][1] = 'Delete shared third parties'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'thirdparty'; + $this->rights[$r][5] = 'delete'; + + // Contact sharing (502x) + + $r++; + $this->rights[$r][0] = 5021; + $this->rights[$r][1] = 'Read shared contacts'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'contact'; + $this->rights[$r][5] = 'read'; + + $r++; + $this->rights[$r][0] = 5022; + $this->rights[$r][1] = 'Create/modify shared contacts'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'contact'; + $this->rights[$r][5] = 'write'; + + $r++; + $this->rights[$r][0] = 5023; + $this->rights[$r][1] = 'Delete shared contacts'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'contact'; + $this->rights[$r][5] = 'delete'; + + // Product/service sharing (503x) + + $r++; + $this->rights[$r][0] = 5031; + $this->rights[$r][1] = 'Read shared products/services'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'product'; + $this->rights[$r][5] = 'read'; + + $r++; + $this->rights[$r][0] = 5032; + $this->rights[$r][1] = 'Create/modify shared products/services'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'product'; + $this->rights[$r][5] = 'write'; + + $r++; + $this->rights[$r][0] = 5033; + $this->rights[$r][1] = 'Delete shared products/services'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'product'; + $this->rights[$r][5] = 'delete'; + + // Proposal sharing (504x) + + $r++; + $this->rights[$r][0] = 5041; + $this->rights[$r][1] = 'Read shared customer proposals'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'propal'; + $this->rights[$r][5] = 'read'; + + $r++; + $this->rights[$r][0] = 5042; + $this->rights[$r][1] = 'Create/modify shared customer proposals'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'propal'; + $this->rights[$r][5] = 'write'; + + $r++; + $this->rights[$r][0] = 5043; + $this->rights[$r][1] = 'Validate shared customer proposals'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'propal_advance'; + $this->rights[$r][5] = 'validate'; + + $r++; + $this->rights[$r][0] = 5044; + $this->rights[$r][1] = 'Send shared customer proposals'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'propal_advance'; + $this->rights[$r][5] = 'send'; + + $r++; + $this->rights[$r][0] = 5045; + $this->rights[$r][1] = 'Close shared customer proposals'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'propal'; + $this->rights[$r][5] = 'close'; + + $r++; + $this->rights[$r][0] = 5046; + $this->rights[$r][1] = 'Delete shared customer proposals'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'propal'; + $this->rights[$r][5] = 'delete'; + + // Order sharing (505x) + + $r++; + $this->rights[$r][0] = 5051; + $this->rights[$r][1] = 'Read shared customer orders'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'order'; + $this->rights[$r][5] = 'read'; + + $r++; + $this->rights[$r][0] = 5052; + $this->rights[$r][1] = 'Close shared customer orders'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'order'; + $this->rights[$r][5] = 'write'; + + $r++; + $this->rights[$r][0] = 5054; + $this->rights[$r][1] = 'Validate shared customer orders'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'order_advance'; + $this->rights[$r][5] = 'validate'; + + $r++; + $this->rights[$r][0] = 5056; + $this->rights[$r][1] = 'Send shared customer orders'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'order_advance'; + $this->rights[$r][5] = 'send'; + + $r++; + $this->rights[$r][0] = 5057; + $this->rights[$r][1] = 'Close shared customer orders'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'order'; + $this->rights[$r][5] = 'close'; + + $r++; + $this->rights[$r][0] = 5058; + $this->rights[$r][1] = 'Cancel shared customer orders'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'order_advance'; + $this->rights[$r][5] = 'cancel'; + + $r++; + $this->rights[$r][0] = 5059; + $this->rights[$r][1] = 'Delete shared customer orders'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'order'; + $this->rights[$r][5] = 'delete'; + + // Invoice sharing (506x) + + $r++; + $this->rights[$r][0] = 5061; + $this->rights[$r][1] = 'Read shared customer invoices'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'invoice'; + $this->rights[$r][5] = 'read'; + + $r++; + $this->rights[$r][0] = 5062; + $this->rights[$r][1] = 'Create/modify shared customer invoices'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'invoice'; + $this->rights[$r][5] = 'write'; + + // There is a particular permission for unvalidate because this may be not forbidden by some laws + $r++; + $this->rights[$r][0] = 5063; + $this->rights[$r][1] = 'Devalidate shared customer invoices'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'invoice_advance'; + $this->rights[$r][5] = 'unvalidate'; + + $r++; + $this->rights[$r][0] = 5064; + $this->rights[$r][1] = 'Validate shared customer invoices'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'invoice_advance'; + $this->rights[$r][5] = 'validate'; + + $r++; + $this->rights[$r][0] = 5065; + $this->rights[$r][1] = 'Send shared customer invoices'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'invoice_advance'; + $this->rights[$r][5] = 'send'; + + $r++; + $this->rights[$r][0] = 5066; + $this->rights[$r][1] = 'Issue payments on shared customer invoices'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'invoice'; + $this->rights[$r][5] = 'payment'; + + $r++; + $this->rights[$r][0] = 5067; + $this->rights[$r][1] = 'Re-open a fully paid shared customer invoices'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'invoice_advance'; + $this->rights[$r][5] = 'reopen'; + + $r++; + $this->rights[$r][0] = 5069; + $this->rights[$r][1] = 'Delete shared customer invoices'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'invoice'; + $this->rights[$r][5] = 'delete'; + + // Main menu entries + $this->menus = array(); // List of menus to add + $r=0; + + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories. + * + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * 'noboxes' = Do not insert boxes + * 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation + * @return int 1 if OK, 0 if KO + */ + function init($options = '') + { + $sql = array(); + + $result=$this->load_tables(); + + $result=$this->setSuperAdmin(); + + $result=$this->setFirstEntity(); + + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted. + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function remove($options = '') + { + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('MAIN_MODULE_MULTICOMPANY_CSS', 1), + "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('MAIN_MODULE_MULTICOMPANY_LOGIN', 1) + ); + + return $this->_remove($sql, $options); + } + + /** + * Create tables and keys required by module + * This function is called by this->init. + * @return int <=0 if KO, >0 if OK + */ + function load_tables() + { + return $this->_load_tables('/multicompany/sql/'); + } + + /** + * Set the first entity + * + * @return int + */ + function setSuperAdmin() + { + global $user; + + $sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.'user'; + $sql.= ' WHERE admin = 1 AND entity = 0'; + $res = $this->db->query($sql); + if ($res) $num = $this->db->fetch_array($res); + else dol_print_error($this->db); + + if (empty($num[0])) + { + $this->db->begin(); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'user SET entity = 0'; + $sql.= ' WHERE admin = 1 AND rowid IN (1,'.$user->id.')'; + if ($this->db->query($sql)) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + else + { + return 0; + } + } + + /** + * Set the first entity + * + * @return int + */ + function setFirstEntity() + { + global $user, $langs; + + $langs->load('multicompany@multicompany'); + + $sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.'entity'; + $res = $this->db->query($sql); + if ($res) $num = $this->db->fetch_array($res); + else dol_print_error($this->db); + + if (empty($num[0])) + { + $this->db->begin(); + + $now = dol_now(); + + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'entity ('; + $sql.= 'label'; + $sql.= ', description'; + $sql.= ', datec'; + $sql.= ', fk_user_creat'; + $sql.= ') VALUES ('; + $sql.= '\''.$langs->trans("MasterEntity").'\''; + $sql.= ', \''.$langs->trans("MasterEntityDesc").'\''; + $sql.= ', \''.$this->db->idate($now).'\''; + $sql.= ', '.$user->id; + $sql.= ')'; + + if ($this->db->query($sql)) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + else + { + return 0; + } + } +} diff --git a/htdocs/custom/multicompany/core/triggers/index.html b/htdocs/custom/multicompany/core/triggers/index.html new file mode 100755 index 00000000000..e69de29bb2d diff --git a/htdocs/custom/multicompany/core/triggers/interface_25_modMulticompany_MulticompanyWorkflow.class.php b/htdocs/custom/multicompany/core/triggers/interface_25_modMulticompany_MulticompanyWorkflow.class.php new file mode 100755 index 00000000000..a8b444a7417 --- /dev/null +++ b/htdocs/custom/multicompany/core/triggers/interface_25_modMulticompany_MulticompanyWorkflow.class.php @@ -0,0 +1,86 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file /multicompany/core/triggers/interface_25_modMulticompany_MulticompanyWorkflow.class.php + * \ingroup multicompany + * \brief Trigger file for create multicompany data + */ + +require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; + +/** + * \class InterfaceMulticompanyWorkflow + * \brief Classe des fonctions triggers des actions personnalisees du module multicompany + */ + +class InterfaceMulticompanyWorkflow extends DolibarrTriggers +{ + public $family = 'multicompany'; + + public $description = "Triggers of this module allows to create multicompany data"; + + /** + * Version of the trigger + * + * @var string + */ + public $version = self::VERSION_DOLIBARR; + + /** + * + * @var string Image of the trigger + */ + public $picto = 'multicompany@multicompany'; + + /** + * Function called when a Dolibarrr business event is done. + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/core/triggers (and declared) + * + * Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database: + * $object->id (id of entity) + * $object->element (element type of object) + * + * @param string $action Event action code + * @param Object $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) + { + // Mettre ici le code a executer en reaction de l'action + // Les donnees de l'action sont stockees dans $object + + /*if ($action == 'COMPANY_CREATE') + { + $entity = GETPOST('new_entity', 'int', 2); // limit to POST + + if ($entity > 0) + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ". __FILE__ .". id=".$object->rowid); + + return $ret; + } + }*/ + + return 0; + } + +} diff --git a/htdocs/custom/multicompany/css/dropdown.inc.php b/htdocs/custom/multicompany/css/dropdown.inc.php new file mode 100755 index 00000000000..ef91f9078cb --- /dev/null +++ b/htdocs/custom/multicompany/css/dropdown.inc.php @@ -0,0 +1,199 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); +$colorbackhmenu1='60,70,100'; // topmenu +?> +/* '; if (empty($hidelabel)) { @@ -1264,7 +1268,7 @@ class Form } } else { // Immediate load of all database - $out .= $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam, $multiple); + $out .= $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam, $multiple, $excludeids); } return $out; @@ -1277,7 +1281,7 @@ class Form * * @param string $selected Preselected type * @param string $htmlname Name of field in form - * @param string $filter Optional filters criteras (example: 's.rowid <> x', 's.client in (1,3)') + * @param string $filter Optional filters criteras (example: 's.rowid NOT IN (x)', 's.client IN (1,3)'). Do not use a filter coming from input of users. * @param string $showempty Add an empty field (Can be '1' or text to use on empty line like 'SelectThirdParty') * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use standard HTML select component without beautification @@ -1288,9 +1292,10 @@ class Form * @param string $morecss Add more css styles to the SELECT component * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @param bool $multiple add [] in the name of element and add 'multiple' attribut + * @param array $excludeids Exclude IDs from the select combo * @return string HTML string with */ - public function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false) + public function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false, $excludeids = array()) { // phpcs:enable global $conf, $user, $langs; @@ -1338,6 +1343,9 @@ class Form if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) { $sql .= " AND s.status <> 0"; } + if (!empty($excludeids)) { + $sql .= " AND rowid NOT IN (".$this->db->sanitize(join(',', $excludeids)).")"; + } // Add criteria if ($filterkey && $filterkey != '') { $sql .= " AND ("; @@ -5472,15 +5480,16 @@ class Form * @param string $page Page * @param string $selected Id preselected * @param string $htmlname Name of HTML select - * @param string $filter optional filters criteras + * @param string $filter Optional filters criteras. Do not use a filter coming from input of users. * @param int $showempty Add an empty field * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param int $nooutput No print output. Return it only. + * @param array $excludeids Exclude IDs from the select combo * @return void|string */ - public function form_thirdparty($page, $selected = '', $htmlname = 'socid', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0) + public function form_thirdparty($page, $selected = '', $htmlname = 'socid', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0, $excludeids = array()) { // phpcs:enable global $langs; @@ -5490,7 +5499,7 @@ class Form $out .= '
'; $out .= ''; $out .= ''; - $out .= $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events); + $out .= $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, 0, 'minwidth100', '', '', 1, array(), false, $excludeids); $out .= ''; $out .= '
'; } else { diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index ba33386f360..57edbcebc1d 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -48,6 +48,7 @@ $filter = GETPOST('filter', 'alpha'); $outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0); $action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); +$excludeids = GETPOST('excludeids', 'intcomma'); $showtype = GETPOST('showtype', 'int'); @@ -102,6 +103,11 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { if (!is_object($form)) { $form = new Form($db); } + + if (!empty($excludeids)) { + $filter .= 'rowid NOT IN ('.$db->sanitize($excludeids).')'; + } + $arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson); $db->close(); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e7d40037155..d42ed635e82 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2399,7 +2399,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { 'name' => 'soc_origin', 'label' => $langs->trans('MergeOriginThirdparty'), 'type' => 'other', - 'value' => $form->select_company('', 'soc_origin', 's.rowid <> '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200') + 'value' => $form->select_company('', 'soc_origin', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200', '', '', 1, null, false, array($object->id)) ) ); @@ -2773,7 +2773,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; $html_name = ($action == 'editparentcompany') ? 'parent_id' : 'none'; - $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->parent, $html_name, 's.rowid <> '.$object->id, 1); + $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->parent, $html_name, '', 1, 0, 0, null, 0, array($object->id)); print ''; } From 2d5fbfc105ce5d5962632d54c663fe3c40f89e18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Mar 2021 23:43:28 +0100 Subject: [PATCH 074/618] Fix php8 --- .../compta/paiement/class/paiement.class.php | 2 +- htdocs/fourn/class/paiementfourn.class.php | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 91759ad824f..9dcc57a47f2 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1167,7 +1167,7 @@ class Paiement extends CommonObject $linkclose = ''; if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label = $langs->trans("ShowMyObject"); + $label = $langs->trans("Payment"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 41c780f70c8..b64cd32e4d6 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -529,9 +529,10 @@ class PaiementFourn extends Paiement * @param string $option Sur quoi pointe le lien * @param string $mode 'withlistofinvoices'=Include list of invoices into tooltip * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more CSS * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0, $morecss = '') { global $langs; @@ -547,13 +548,26 @@ class PaiementFourn extends Paiement $text = $langs->trans($reg[1]); } - $label = ''.$langs->trans("Payment").'
'; + $label = img_picto('', $this->picto).' '.$langs->trans("Payment").'
'; $label .= ''.$langs->trans("Ref").': '.$text; if ($this->datepaye ? $this->datepaye : $this->date) { - $label .= '
'.$langs->trans("Date").': '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour'); + $label .= '
'.$langs->trans("Date").': '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour', 'tzuser'); } - $linkstart = ''; + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("Payment"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } + + $linkstart = ''; $linkend = ''; $result .= $linkstart; From af593099dfe25a913ab2b3a14ae00bcef23ae2f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Mar 2021 23:52:14 +0100 Subject: [PATCH 075/618] Clean string --- htdocs/core/modules/societe/doc/doc_generic_odt.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 2a7e0cf287f..7926ea06cc5 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -243,6 +243,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc if (!empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) { $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp; + $newfiletmp = preg_replace('/__+/', '_', $newfiletmp); // Replace repeated _ into one _ (to avoid string with substitution syntax) } if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { From bc9b4fa637f6722c418ab3444c86d4e50ce95cce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 23 Mar 2021 00:35:30 +0100 Subject: [PATCH 076/618] Fix id --- htdocs/install/mysql/data/llx_accounting_account_dz.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_accounting_account_dz.sql b/htdocs/install/mysql/data/llx_accounting_account_dz.sql index 0a80cf0f4b4..3895c1ff604 100644 --- a/htdocs/install/mysql/data/llx_accounting_account_dz.sql +++ b/htdocs/install/mysql/data/llx_accounting_account_dz.sql @@ -24,7 +24,7 @@ -- ID 15000 - 15811 -- ADD 1300000 to rowid # Do no remove this comment -- -INSERT IGNORE INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (17000,'NSCF','CAPIT','1',0,'Comptes de capitaux','1'); +INSERT IGNORE INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (15000,'NSCF','CAPIT','1',0,'Comptes de capitaux','1'); INSERT IGNORE INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (15001,'NSCF','CAPIT','10',17000,'Capital, réserves et assimilés','1'); INSERT IGNORE INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (15002,'NSCF','CAPIT','101',15001,'Capital émis','1'); INSERT IGNORE INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (15003,'NSCF','CAPIT','1011',15002,'Capital souscrit, non appelé','1'); From e3b019f92373bbc2c195a40e1a35f8eabcc62be2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 23 Mar 2021 01:32:17 +0100 Subject: [PATCH 077/618] Clean code --- htdocs/adherents/card.php | 36 +++++++++---------- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/adherents/index.php | 2 +- htdocs/admin/eventorganization.php | 4 +-- htdocs/core/lib/functions.lib.php | 10 +++--- .../modules/modEventOrganization.class.php | 6 ++-- .../class/conferenceorbooth.class.php | 2 +- .../conferenceorbooth_list.php | 4 +-- htdocs/langs/en_US/eventorganization.lang | 4 +-- .../core/modules/modMyModule.class.php | 2 ++ htdocs/theme/eldy/badges.inc.php | 4 +-- htdocs/theme/eldy/btn.inc.php | 2 +- htdocs/theme/eldy/theme_vars.inc.php | 1 + htdocs/theme/md/badges.inc.php | 24 +++++++++++-- htdocs/theme/md/theme_vars.inc.php | 1 + 15 files changed, 65 insertions(+), 39 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 57e510719bb..b75bce38ca9 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1830,7 +1830,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Send if (empty($user->socid)) { if ($object->statut == 1) { - print ''; + print ''."\n"; } } @@ -1856,17 +1856,17 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Modify if ($user->rights->adherent->creer) { - print '"; + print ''."\n"; } else { - print '
'.$langs->trans("Modify").'
'; + print '
'.$langs->trans("Modify").'
'."\n"; } // Validate if ($object->statut == -1) { if ($user->rights->adherent->creer) { - print '\n"; + print ''."\n"; } else { - print '
'.$langs->trans("Validate").'
'; + print '
'.$langs->trans("Validate").'
'."\n"; } } @@ -1875,7 +1875,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($user->rights->adherent->creer) { print '\n"; } else { - print '
'.$langs->trans("Reenable")."
"; + print '
'.$langs->trans("Reenable").'
'."\n"; } } @@ -1884,7 +1884,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($user->rights->adherent->supprimer) { print '\n"; } else { - print '
'.$langs->trans("Resiliate")."
"; + print '
'.$langs->trans("Resiliate").'
'."\n"; } } @@ -1893,7 +1893,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($user->rights->adherent->supprimer) { print '\n"; } else { - print '
'.$langs->trans("Exclude")."
"; + print '
'.$langs->trans("Exclude").'
'."\n"; } } @@ -1901,12 +1901,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (!empty($conf->societe->enabled) && !$object->socid) { if ($user->rights->societe->creer) { if ($object->statut != -1) { - print ''; + print ''."\n";; } else { - print ''; + print ''."\n"; } } else { - print '
'.$langs->trans("CreateDolibarrThirdParty")."
"; + print '
'.$langs->trans("CreateDolibarrThirdParty").'
'."\n"; } } @@ -1914,12 +1914,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (!$user->socid && !$object->user_id) { if ($user->rights->user->user->creer) { if ($object->statut != -1) { - print ''; + print ''."\n"; } else { - print ''; + print ''."\n"; } } else { - print '
'.$langs->trans("CreateDolibarrLogin")."
"; + print '
'.$langs->trans("CreateDolibarrLogin").'
'."\n"; } } @@ -1928,18 +1928,18 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $isinspip = $mailmanspip->is_in_spip($object); if ($isinspip == 1) { - print '\n"; + print ''."\n"; } if ($isinspip == 0) { - print '\n"; + print ''."\n"; } } // Delete if ($user->rights->adherent->supprimer) { - print '\n"; + print ''."\n"; } else { - print '
'.$langs->trans("Delete")."
"; + print '
'.$langs->trans("Delete").'
'."\n"; } } } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index bb56eaf4947..8803ce032fa 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2279,7 +2279,7 @@ class Adherent extends CommonObject $labelStatus = $langs->trans("MemberStatusResiliated"); $labelStatusShort = $langs->trans("MemberStatusResiliatedShort"); } elseif ($status == -2) { - $statusType = 'status8'; + $statusType = 'status10'; $labelStatus = $langs->trans("MemberStatusExcluded"); $labelStatusShort = $langs->trans("MemberStatusExcludedShort"); } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 517649c4b61..803ef89bb22 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -233,7 +233,7 @@ if ($conf->use_javascript_ajax) { include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus8, $badgeStatus6, '-'.$badgeStatus0)); + $dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, '-'.$badgeStatus8, $badgeStatus6, '-'.$badgeStatus0)); $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 8625f182f47..23fc463f3b5 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -201,7 +201,7 @@ if ($action == 'edit') { print ''; print ''; - print ''; + print ''; foreach ($arrayofparameters as $constname => $val) { if ($val['enabled']==1) { @@ -266,7 +266,7 @@ if ($action == 'edit') { } else { if (!empty($arrayofparameters)) { print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print ''; + print ''; foreach ($arrayofparameters as $constname => $val) { if ($val['enabled']==1) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ab9a476c923..948ddc09499 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3524,7 +3524,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'info', 'intervention', 'inventory', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_asset', 'object_barcode', 'object_bill', 'object_billr', 'object_billa', 'object_billd', 'object_bom', - 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert', + 'object_category', 'conferenceorbooth', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert', 'object_folder', 'object_folder-open','object_generic', 'object_list-alt', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', 'object_cash-register', 'object_company', 'object_contact', 'object_contract', 'object_cron', 'object_donation', 'object_dynamicprice', @@ -3549,7 +3549,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', 'user-cog', 'website', - 'eventorganization', 'object_eventorganization' + 'conferenceorbooth', 'eventorganization', 'object_eventorganization' ))) { $pictowithouttext = str_replace('object_', '', $pictowithouttext); @@ -3597,7 +3597,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'uparrow'=>'mail-forward', 'vcard'=>'address-card', 'jabber'=>'comment-o', 'website'=>'globe-americas', - 'eventorganization'=>'id-badge' + 'conferenceorbooth'=>'chalkboard-teacher', 'eventorganization'=>'project-diagram' ); if ($pictowithouttext == 'off') { $fakey = 'fa-square'; @@ -3630,7 +3630,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (in_array($pictowithouttext, array('dollyrevert', 'member', 'members', 'contract', 'group', 'resource', 'shipment'))) { $morecss = 'em092'; } - if (in_array($pictowithouttext, array('collab', 'holiday', 'project'))) { + if (in_array($pictowithouttext, array('conferenceorbooth', 'collab', 'eventorganization', 'holiday', 'project'))) { $morecss = 'em088'; } if (in_array($pictowithouttext, array('intervention', 'info', 'payment', 'loan', 'stock', 'technic'))) { @@ -3652,6 +3652,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'action'=>'infobox-action', 'account'=>'infobox-bank_account', 'accountline'=>'infobox-bank_account', 'accountancy'=>'infobox-bank_account', 'asset'=>'infobox-bank_account', 'bank_account'=>'bg-infobox-bank_account', 'bill'=>'infobox-commande', 'billa'=>'infobox-commande', 'billr'=>'infobox-commande', 'billd'=>'infobox-commande', + 'conferenceorbooth'=>'infobox-project', 'cash-register'=>'infobox-bank_account', 'contract'=>'infobox-contrat', 'check'=>'font-status4', 'collab'=>'infobox-action', 'conversation'=>'infobox-contrat', 'donation'=>'infobox-commande', 'dollyrevert'=>'flip', 'ecm'=>'infobox-action', 'hrm'=>'infobox-adherent', 'group'=>'infobox-adherent', 'intervention'=>'infobox-contrat', @@ -3661,6 +3662,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'user'=>'infobox-adherent', 'users'=>'infobox-adherent', 'error'=>'pictoerror', 'warning'=>'pictowarning', 'switch_on'=>'font-status4', 'holiday'=>'infobox-holiday', 'info'=>'opacityhigh', 'invoice'=>'infobox-commande', 'loan'=>'infobox-bank_account', + 'eventorganization'=>'infobox-project', 'payment'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'pos'=>'infobox-bank_account', 'project'=>'infobox-project', 'projecttask'=>'infobox-project', 'propal'=>'infobox-propal', 'recruitmentjobposition'=>'infobox-adherent', 'recruitmentcandidature'=>'infobox-adherent', 'resource'=>'infobox-action', diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php index 386da21d798..244b4f41cab 100644 --- a/htdocs/core/modules/modEventOrganization.class.php +++ b/htdocs/core/modules/modEventOrganization.class.php @@ -341,6 +341,7 @@ class modEventOrganization extends DolibarrModules 'fk_menu'=>'fk_mainmenu=project', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry 'titre'=>'EventOrganizationMenuLeft', + 'prefix' => img_picto('', 'eventorganization', 'class="paddingright pictofixedwidth"'), 'mainmenu'=>'project', 'leftmenu'=>'eventorganization', 'url'=>'', @@ -355,7 +356,7 @@ class modEventOrganization extends DolibarrModules 'fk_menu'=>'fk_mainmenu=project,fk_leftmenu=eventorganization', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry 'titre'=>'List', - 'url'=>'/projet/list.php?search_usage_event_organization=1&mainmenu=project', + 'url'=>'/projet/list.php?search_usage_event_organization=1&mainmenu=project&contextpage=organizedevents', 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. @@ -378,7 +379,8 @@ class modEventOrganization extends DolibarrModules $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=project', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry - 'titre'=>'EventOrganizationMenuLeft', + 'titre'=>'ConferenceOrBooth', + 'prefix' => img_picto('', 'conferenceorbooth', 'class="paddingright pictofixedwidth"'), 'mainmenu'=>'project', 'leftmenu'=>'eventorganizationconforbooth', 'url'=>'', diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 7f28d40dd29..d91181d0c51 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -61,7 +61,7 @@ class ConferenceOrBooth extends ActionComm /** * @var string String with name of icon for conferenceorbooth. Must be the part after the 'object_' into object_conferenceorbooth.png */ - public $picto = 'conferenceorbooth@eventorganization'; + public $picto = 'conferenceorbooth'; const STATUS_DRAFT = 0; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index ea189d4be9b..89e614cc3ba 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -554,9 +554,9 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/eventorganization/conferenceorbooth_card.php', 1).'?action=create'.(!empty($project->id)?'&fk_project='.$project->id:'').(!empty($project->socid)?'&fk_soc='.$project->socid:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($project->id)?'?projectid='.$project->id:''), '', $permissiontoadd); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorbooth_card.php?action=create'.(!empty($project->id)?'&fk_project='.$project->id:'').(!empty($project->socid)?'&fk_soc='.$project->socid:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($project->id)?'?projectid='.$project->id:''), '', $permissiontoadd); -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); // Add code for pre mass action (confirmation or email presend form) $topicmail = "SendConferenceOrBoothRef"; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 5444ed59e3d..82f18107a5c 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -32,8 +32,8 @@ EventOrganizationConferenceOrBoothMenuLeft = Conference Or Booth EventOrganizationSetup = Event Organization setup Settings = Settings EventOrganizationSetupPage = Event Organization setup page -EVENTORGANIZATION_TASK_LABEL = Task label created when validate -EVENTORGANIZATION_TASK_LABELTooltip = When validate a Conference or a booth, some tasks will be created in the project

for example:
Send Call for Conference
Send Call for Booth
Receive call for conferences
Receive call for Booth
Open subscriptions to events for attendees
Send remind of event to speakers
Send remind of event to Booth hoster
Send remind of event to attendees +EVENTORGANIZATION_TASK_LABEL = Label of tasks to create automatically when project is validated +EVENTORGANIZATION_TASK_LABELTooltip = When you validate an organized event, some tasks can be automatically created in the project

For example:
Send Call for Conference
Send Call for Booth
Receive call for conferences
Receive call for Booth
Open subscriptions to events for attendees
Send remind of event to speakers
Send remind of event to Booth hoster
Send remind of event to attendees EVENTORGANIZATION_CATEG_THIRDPARTY_CONF = Category to add to third-parties automatically created when someone suggests a conference EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH = Category to add to third-parties automatically created when they suggests a booth EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF = Template of email to send after receiving a suggestion of a conference. diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index e4f662c9e99..322c043a26c 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -290,6 +290,7 @@ class modMyModule extends DolibarrModules 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'top', // This is a Top menu entry 'titre'=>'ModuleMyModuleName', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'mainmenu'=>'mymodule', 'leftmenu'=>'', 'url'=>'/mymodule/mymoduleindex.php', @@ -306,6 +307,7 @@ class modMyModule extends DolibarrModules 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Top menu entry 'titre'=>'MyObject', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'mainmenu'=>'mymodule', 'leftmenu'=>'myobject', 'url'=>'/mymodule/mymoduleindex.php', diff --git a/htdocs/theme/eldy/badges.inc.php b/htdocs/theme/eldy/badges.inc.php index f3f311eccca..dcb61499b63 100644 --- a/htdocs/theme/eldy/badges.inc.php +++ b/htdocs/theme/eldy/badges.inc.php @@ -205,7 +205,7 @@ a.badge-dark:focus, a.badge-dark:hover { /* STATUS BADGES */ em; + margin: 0em em; padding: 0.6em em; display: inline-block; text-align: center; diff --git a/htdocs/theme/eldy/theme_vars.inc.php b/htdocs/theme/eldy/theme_vars.inc.php index 8bb2fd3bbca..82cbf9cf2a9 100644 --- a/htdocs/theme/eldy/theme_vars.inc.php +++ b/htdocs/theme/eldy/theme_vars.inc.php @@ -114,6 +114,7 @@ $badgeStatus6 = '#cad2d2'; $badgeStatus7 = '#25a580'; $badgeStatus8 = '#993013'; $badgeStatus9 = '#e7f0f0'; +$badgeStatus10 = '#993013'; // status color ajustement for color blind $colorblind_deuteranopes_badgeStatus4 = $colorblind_deuteranopes_badgeStatus7 = $colorblind_deuteranopes_badgeSuccess; //! text color black diff --git a/htdocs/theme/md/badges.inc.php b/htdocs/theme/md/badges.inc.php index 7dd0229ae46..fd1b1122a17 100644 --- a/htdocs/theme/md/badges.inc.php +++ b/htdocs/theme/md/badges.inc.php @@ -1,7 +1,8 @@ +} +?> /* + + + '> + + + + + From 7c2e3c49309c875aab7890ebf075975d5c0a78e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Mar 2021 14:47:10 +0100 Subject: [PATCH 174/618] Removed old deprecated API browser --- htdocs/api/admin/explorer.php | 216 ---------------------------------- 1 file changed, 216 deletions(-) delete mode 100644 htdocs/api/admin/explorer.php diff --git a/htdocs/api/admin/explorer.php b/htdocs/api/admin/explorer.php deleted file mode 100644 index 53b9233c130..00000000000 --- a/htdocs/api/admin/explorer.php +++ /dev/null @@ -1,216 +0,0 @@ - - * Copyright (C) 2016 Laurent Destailleur - * - * 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 . - * - * @deprecated Old explorer. Not using Swagger. See instead explorer in htdocs/api/index.php. - */ - -/** - * \defgroup api Module DolibarrApi - * \brief API loader - * Search files htdocs//class/api_.class.php - * \file htdocs/api/admin/explorer.php - */ - -use Luracast\Restler\Routes; - -require_once '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php'; -require_once DOL_DOCUMENT_ROOT.'/api/class/api_access.class.php'; - -// Load translation files required by the page -$langs->load("admin"); - - -/* - * View - */ - -// Enable and test if module Api is enabled -if (empty($conf->global->MAIN_MODULE_API)) { - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); - print $langs->trans("WarningModuleNotActive", 'Api').'.

'; - print $langs->trans("ToActivateModule"); - exit; -} - - -$api = new DolibarrApi($db); - -$api->r->addAPIClass('Luracast\\Restler\\Resources'); //this creates resources.json at API Root -$api->r->setSupportedFormats('JsonFormat', 'XmlFormat'); -$api->r->addAuthenticationClass('DolibarrApiAccess', ''); - -$listofapis = array(); - -$modulesdir = dolGetModulesDirs(); -foreach ($modulesdir as $dir) { - /* - * Search available module - */ - //dol_syslog("Scan directory ".$dir." for API modules"); - - $handle = @opendir(dol_osencode($dir)); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) { - $modulename = $reg[1]; - - // Defined if module is enabled - $enabled = true; - $module = $part = $obj = strtolower(preg_replace('/^mod/i', '', $modulename)); - //if ($part == 'propale') $part='propal'; - if ($module == 'societe') { - $obj = 'thirdparty'; - } - if ($module == 'categorie') { - $part = 'categories'; - $obj = 'category'; - } - if ($module == 'facture') { - $part = 'compta/facture'; - $obj = 'facture'; - } - if ($module == 'ficheinter') { - $obj = 'fichinter'; - $part = 'fichinter'; - $module = 'fichinter'; - } - - if (empty($conf->$module->enabled)) { - $enabled = false; - } - - if ($enabled) { - /* - * If exists, load the API class for enable module - * - * Search files named api_.class.php into /htdocs//class directory - * - * @todo : take care of externals module! - * @todo : use getElementProperties() function ? - */ - $dir_part = DOL_DOCUMENT_ROOT.'/'.$part.'/class/'; - - $handle_part = @opendir(dol_osencode($dir_part)); - if (is_resource($handle_part)) { - while (($file_searched = readdir($handle_part)) !== false) { - if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $reg)) { - $classname = ucwords($reg[1]); - require_once $dir_part.$file_searched; - if (class_exists($classname)) { - dol_syslog("Found API classname=".$classname." into ".$dir); - $listofapis[] = $classname; - } - } - - /* - if (is_readable($dir_part.$file_searched) && preg_match("/^(api_.*)\.class\.php$/i",$file_searched,$reg)) - { - $classname=$reg[1]; - $classname = str_replace('Api_','',ucwords($reg[1])).'Api'; - //$classname = str_replace('Api_','',ucwords($reg[1])); - $classname = ucfirst($classname); - require_once $dir_part.$file_searched; - - // if (class_exists($classname)) - // { - // dol_syslog("Found API classname=".$classname); - // $api->r->addAPIClass($classname,''); - - // require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/Routes.php'; - // $tmpclass = new ReflectionClass($classname); - // try { - // $classMetadata = CommentParser::parse($tmpclass->getDocComment()); - // } catch (Exception $e) { - // throw new RestException(500, "Error while parsing comments of `$classname` class. " . $e->getMessage()); - // } - - // //$listofapis[]=array('classname'=>$classname, 'fullpath'=>$file_searched); - // } - }*/ - } - } - } - } - } - } -} - -//var_dump($listofapis); -$listofapis = Routes::toArray(); // @todo api for "status" is lost here -//var_dump($listofapis); - - -llxHeader(); - -$linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ApiSetup"), $linkback, 'title_setup'); - -// Define $urlwithroot -$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); -$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file -//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - -// Show message -print '
'; -$message = ''; -$url = ''.$urlwithroot.'/api/index.php/login?login='.urlencode($user->login).'&password=yourpassword[&reset=1]'; -$message .= $langs->trans("UrlToGetKeyToUseAPIs").':
'; -$message .= img_picto('', 'globe').' '.$url; -print $message; -print '
'; -print '
'; - -$oldclass = ''; - -print $langs->trans("ListOfAvailableAPIs").':
'; -foreach ($listofapis['v1'] as $key => $val) { - if ($key == 'login') { - continue; - } - if ($key == 'index') { - continue; - } - - if ($key) { - foreach ($val as $method => $val2) { - $newclass = $val2['className']; - - if (preg_match('/restler/i', $newclass)) { - continue; - } - - if ($oldclass != $newclass) { - print "\n
\n".$langs->trans("Class").': '.$newclass.'
'."\n"; - $oldclass = $newclass; - } - //print $key.' - '.$val['classname'].' - '.$val['fullpath']." - ".DOL_MAIN_URL_ROOT.'/api/index.php/'.strtolower(preg_replace('/Api$/','',$val['classname']))."/xxx
\n"; - $url = $urlwithroot.'/api/index.php/'.$key; - $url .= '?api_key=token'; - print img_picto('', 'globe').' '.$method.' '.$url."
\n"; - } - } -} - -print '
'; -print '
'; -print $langs->trans("OnlyActiveElementsAreExposed", DOL_URL_ROOT.'/admin/modules.php'); - - -llxFooter(); -$db->close(); From a4ca16db32afccd28176194f982b779dfa0fbf6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Mar 2021 14:48:14 +0100 Subject: [PATCH 175/618] Doc --- htdocs/api/admin/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index 45fa87a2e77..3299435a10d 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -152,7 +152,7 @@ if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/e $url = DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; print img_picto('', 'globe').' '.$url."
\n"; print '

'.$langs->trans("SwaggerDescriptionFile").':
'; - $urlswagger = DOL_MAIN_URL_ROOT.'/api/index.php/explorer/swagger.json?DOLAPIKEY=useauserapikey'; + $urlswagger = DOL_MAIN_URL_ROOT.'/api/index.php/explorer/swagger.json?DOLAPIKEY=youruserapikey'; print img_picto('', 'globe').' '.$urlswagger."
\n"; print '
'; } else { From 3a5f130ed578b9f080e4afb747bae7f4956ac76c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Mar 2021 14:54:12 +0100 Subject: [PATCH 176/618] Add protections --- htdocs/api/admin/explorer_withredoc.php | 32 +++++++++++++++++++++++++ htdocs/api/index.php | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/htdocs/api/admin/explorer_withredoc.php b/htdocs/api/admin/explorer_withredoc.php index 08711abede2..45dd31d57c9 100644 --- a/htdocs/api/admin/explorer_withredoc.php +++ b/htdocs/api/admin/explorer_withredoc.php @@ -26,6 +26,38 @@ require_once '../../main.inc.php'; +// Enable and test if module Api is enabled +if (empty($conf->global->MAIN_MODULE_API)) { + $langs->load("admin"); + dol_syslog("Call of Dolibarr API interfaces with module API REST are disabled"); + print $langs->trans("WarningModuleNotActive", 'Api').'.

'; + print $langs->trans("ToActivateModule"); + //session_destroy(); + exit(0); +} + +// Test if explorer is not disabled +if (!empty($conf->global->API_EXPLORER_DISABLED)) { + $langs->load("admin"); + dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + print $langs->trans("WarningAPIExplorerDisabled").'.

'; + //session_destroy(); + exit(0); +} + +// Restrict API to some IPs +if (!empty($conf->global->API_RESTRICT_ON_IP)) { + $allowedip = explode(' ', $conf->global->API_RESTRICT_ON_IP); + $ipremote = getUserRemoteIP(); + if (!in_array($ipremote, $allowedip)) { + dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->API_RESTRICT_ON_IP); + print 'APIs are not allowed from the IP '.$ipremote; + header('HTTP/1.1 503 API not allowed from your IP '.$ipremote); + //session_destroy(); + exit(0); + } +} + ?> diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 880d3263aaa..89b5a696462 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -95,7 +95,7 @@ if (!empty($conf->global->MAIN_NGINX_FIX)) { // Enable and test if module Api is enabled if (empty($conf->global->MAIN_MODULE_API)) { $langs->load("admin"); - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + dol_syslog("Call of Dolibarr API interfaces with module API REST are disabled"); print $langs->trans("WarningModuleNotActive", 'Api').'.

'; print $langs->trans("ToActivateModule"); //session_destroy(); From 4a22c8e87e4aea7973711056e779abfa674fa2bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Mar 2021 15:12:39 +0100 Subject: [PATCH 177/618] CSS --- htdocs/api/admin/index.php | 6 +++--- htdocs/theme/eldy/global.inc.php | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index 3299435a10d..05f372a3486 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -141,7 +141,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai $message = ''; $url = $urlwithroot.'/api/index.php/login?login=auserlogin&password=thepassword[&reset=1]'; $message .= ''.$langs->trans("UrlToGetKeyToUseAPIs").':
'; -$message .= img_picto('', 'globe').' '.$url; +$message .= ''; print $message; print '
'; print '
'; @@ -150,10 +150,10 @@ print '
'; print ''.$langs->trans("ApiExporerIs").':
'; if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer')) { $url = DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; - print img_picto('', 'globe').' '.$url."
\n"; + print '
\n"; print '

'.$langs->trans("SwaggerDescriptionFile").':
'; $urlswagger = DOL_MAIN_URL_ROOT.'/api/index.php/explorer/swagger.json?DOLAPIKEY=youruserapikey'; - print img_picto('', 'globe').' '.$urlswagger."
\n"; + print '
\n"; print '
'; } else { $langs->load("errors"); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index f14c7bba87f..62d040f2aff 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -767,6 +767,19 @@ textarea.centpercent { max-width: 100%; overflow-y: auto; } +div.urllink { + padding: 10px; + margin-top: 5px; + margin-bottom: 5px; + //border: 1px solid #ccc; + border-radius: 5px; + width: fit-content; + background-color: #eee; + opacity: 0.8; +} +div.urllink, div.urllink a { + color: #339 !important; +} i.fa-mars::before, i.fa-venus::before, i.fa-genderless::before { color: #888 !important; From f553ad3fc8f73a1251ccf86b80f73118617a7e20 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 26 Mar 2021 16:14:00 +0100 Subject: [PATCH 178/618] FIX : orders columns --- htdocs/compta/sociales/list.php | 112 ++++++++++++++-------------- htdocs/compta/sociales/payments.php | 91 ++++++++++++++++------ htdocs/compta/tva/list.php | 24 +++--- htdocs/compta/tva/payments.php | 62 +++++++++------ htdocs/salaries/list.php | 35 ++++----- htdocs/salaries/payments.php | 53 ++++++++++--- 6 files changed, 235 insertions(+), 142 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 48c6936a225..d6e19e61c6b 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -103,12 +103,12 @@ $arrayfields = array( 'cs.rowid' =>array('label'=>"Ref", 'checked'=>1, 'position'=>10), 'cs.libelle' =>array('label'=>"Label", 'checked'=>1, 'position'=>20), 'cs.fk_type' =>array('label'=>"Type", 'checked'=>1, 'position'=>30), - 'cs.fk_user' =>array('label'=>"Employee", 'checked'=>1, 'position'=>30), - 'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>40, 'enable'=>(!empty($conf->projet->enabled))), - 'cs.date_ech' =>array('label'=>"Date", 'checked'=>1, 'position'=>50), - 'cs.periode' =>array('label'=>"PeriodEndDate", 'checked'=>1, 'position'=>60), - 'cs.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70), - 'cs.paye' =>array('label'=>"Status", 'checked'=>1, 'position'=>80), + 'cs.date_ech' =>array('label'=>"Date", 'checked'=>1, 'position'=>40), + 'cs.periode' =>array('label'=>"PeriodEndDate", 'checked'=>1, 'position'=>50), + 'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>60, 'enable'=>(!empty($conf->projet->enabled))), + 'cs.fk_user' =>array('label'=>"Employee", 'checked'=>1, 'position'=>70), + 'cs.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>80), + 'cs.paye' =>array('label'=>"Status", 'checked'=>1, 'position'=>90), ); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -346,19 +346,6 @@ if (!empty($arrayfields['cs.fk_type']['checked'])) { print ''; } -if (!empty($arrayfields['cs.fk_user']['checked'])) { - // Employee - print '
'; -} - // Filter: Date (placeholder) if (!empty($arrayfields['cs.date_ech']['checked'])) { print ''; } +// Filter: Project ref +if (!empty($arrayfields['p.ref']['checked'])) { + print ''; +} + +if (!empty($arrayfields['cs.fk_user']['checked'])) { + // Employee + print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date if (!empty($arrayfields['cs.date_ech']['checked'])) { print ''; @@ -545,6 +514,37 @@ while ($i < min($num, $limit)) { } } + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['cs.fk_user']['checked'])) { + // Employee + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount if (!empty($arrayfields['cs.amount']['checked'])) { print ''; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 2dca06ca54f..81aeaf3d9b9 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -30,6 +30,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; @@ -44,7 +45,7 @@ $hookmanager = new HookManager($db); $hookmanager->initHooks(array('specialexpensesindex')); // Load translation files required by the page -$langs->loadLangs(array('compta', 'bills')); +$langs->loadLangs(array('compta', 'bills', 'hrm')); // Security check if ($user->socid) { @@ -96,8 +97,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $tva_static = new Tva($db); $socialcontrib = new ChargeSociales($db); $payment_sc_static = new PaymentSocialContribution($db); +$userstatic = new User($db); $sal_static = new Salary($db); $accountstatic = new Account($db); +$accountlinestatic = new AccountLine($db); $formsocialcontrib = new FormSocialContrib($db); $title = $langs->trans("SocialContributionsPayments"); @@ -140,6 +143,7 @@ $sql = "SELECT c.id, c.libelle as label,"; $sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; $sql .= " pct.code as payment_code,"; +$sql .= " u.rowid uid, u.lastname, u.firstname, u.email, u.login, u.admin,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs"; @@ -147,6 +151,7 @@ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = cs.fk_user"; $sql .= " WHERE cs.fk_type = c.id"; $sql .= " AND cs.entity IN (".getEntity("tax").")"; if ($search_sc_type > 0) { @@ -160,7 +165,11 @@ if ($year > 0) { $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; $sql .= ")"; } -if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) { +if (preg_match('/^cs\./', $sortfield) + || preg_match('/^c\./', $sortfield) + || preg_match('/^pc\./', $sortfield) + || preg_match('/^pct\./', $sortfield) + || preg_match('/^u\./', $sortfield)) { $sql .= $db->order($sortfield, $sortorder); } @@ -208,8 +217,11 @@ print ''; print ''; print ''; print ''; +print ''; +print ''; if (!empty($conf->banque->enabled)) { print ''; + print ''; } print ''; print ''; print "\n"; print ''; -print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'width="140px"', $sortfield, $sortorder); -print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "c.libelle", "", $param, '', $sortfield, $sortorder); -print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "cs.fk_type", "", $param, '', $sortfield, $sortorder); -print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder); +print_liste_field_titre("SocialContribution", $_SERVER["PHP_SELF"], "c.libelle", "", $param, '', $sortfield, $sortorder); +print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "cs.fk_type", "", $param, '', $sortfield, $sortorder); +print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'width="140px"', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder); -print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); +print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); +print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "pc.num_paiement", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber'); +print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "pc.fk_bank", "", $param, '', $sortfield, $sortorder); if (!empty($conf->banque->enabled)) { print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); } +print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre(''); print "\n"; @@ -246,40 +261,63 @@ $totalpaye = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); print ''; + // Ref payment + $payment_sc_static->id = $obj->pid; + $payment_sc_static->ref = $obj->pid; + print '\n"; + // Label + print ''; + // Type + print ''; // Date $date = $obj->periode; if (empty($date)) { $date = $obj->date_ech; } print ''; - // Label - print ''; - // Type - print ''; - // Expected to pay - print ''; - // Ref payment - $payment_sc_static->id = $obj->pid; - $payment_sc_static->ref = $obj->pid; - print '\n"; // Date payment print ''; + + // Employee + print "\n"; + } + // Type payment print ''; + print ''; + + print ''; + // Account if (!empty($conf->banque->enabled)) { + + // Bank transaction + print ''; + print ''; } + // Expected to pay + print ''; // Paid print ''; // A total here has no sense print ''; print ''; print ''; +print ''; +print ''; if (!empty($conf->banque->enabled)) { print ''; + print ''; } print '"; print ''; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 4027f7e2351..72563c62c6e 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -85,8 +85,8 @@ $arrayfields = array( 't.rowid' =>array('checked'=>1, 'position'=>10, 'label'=>"Ref",), 't.label' =>array('checked'=>1, 'position'=>20, 'label'=>"Label"), 't.datev' =>array('checked'=>1, 'position'=>30, 'label'=>"PeriodEndDate"), - 't.fk_typepayment' =>array('checked'=>1, 'position'=>50, 'label'=>"DefaultPaymentMode"), - 't.fk_account' =>array('checked'=>1, 'position'=>60, 'label'=>"DefaultBankAccount"), + /*'t.fk_typepayment' =>array('checked'=>1, 'position'=>50, 'label'=>"DefaultPaymentMode"), + 't.fk_account' =>array('checked'=>1, 'position'=>60, 'label'=>"DefaultBankAccount"),*/ 't.amount' =>array('checked'=>1, 'position'=>90, 'label'=>"Amount"), 't.status' =>array('checked'=>1, 'position'=>90, 'label'=>"Status"), ); @@ -351,7 +351,7 @@ if (!empty($arrayfields['t.datev']['checked'])) { }*/ // Filter: Type -if (!empty($arrayfields['t.fk_typepayment']['checked'])) { +/*if (!empty($arrayfields['t.fk_typepayment']['checked'])) { print ''; @@ -362,7 +362,7 @@ if (!empty($arrayfields['t.fk_account']['checked'])) { print ''; -} +}*/ // Filter: Amount if (!empty($arrayfields['t.amount']['checked'])) { @@ -404,12 +404,12 @@ if (!empty($arrayfields['t.label']['checked'])) { if (!empty($arrayfields['t.datev']['checked'])) { print_liste_field_titre($arrayfields['t.datev']['label'], $_SERVER['PHP_SELF'], 't.datev', '', $param, 'align="center"', $sortfield, $sortorder); } -if (!empty($arrayfields['t.fk_typepayment']['checked'])) { +/*if (!empty($arrayfields['t.fk_typepayment']['checked'])) { print_liste_field_titre($arrayfields['t.fk_typepayment']['label'], $_SERVER['PHP_SELF'], 't.fk_typepayment', '', $param, '', $sortfield, $sortorder, 'left '); } if (!empty($arrayfields['t.fk_account']['checked'])) { print_liste_field_titre($arrayfields['t.fk_account']['label'], $_SERVER['PHP_SELF'], 't.fk_account', '', $param, '', $sortfield, $sortorder, 'left '); -} +}*/ if (!empty($arrayfields['t.amount']['checked'])) { print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER['PHP_SELF'], 't.amount', '', $param, '', $sortfield, $sortorder, 'right '); } @@ -475,15 +475,15 @@ while ($i < min($num, $limit)) { }*/ // Type - if (!empty($arrayfields['t.fk_typepayment']['checked'])) { + /*if (!empty($arrayfields['t.fk_typepayment']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; } - } + }*/ // Account - if (!empty($arrayfields['t.fk_account']['checked'])) { + /*if (!empty($arrayfields['t.fk_account']['checked'])) { print ''; if (!$i) $totalarray['nbfield']++; - } + }*/ // Amount if (!empty($arrayfields['t.amount']['checked'])) { diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 4eec7ca85a1..5945a000eba 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -75,6 +75,7 @@ if (!$sortorder) { $tva_static = new Tva($db); $tva = new Tva($db); +$accountlinestatic = new AccountLine($db); $payment_vat_static = new PaymentVAT($db); $sal_static = new PaymentSalary($db); @@ -119,17 +120,19 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', '0', 0, '', 0, '', '', 0, 0, true); -} - -// Filter: Project ref -if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - print ''; - print ''; @@ -376,6 +363,19 @@ if (!empty($arrayfields['cs.periode']['checked'])) { print ''; + print ''; + print ''; + print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', '0', 0, '', 0, '', '', 0, 0, true); +} + // Filter: Amount if (!empty($arrayfields['cs.amount']['checked'])) { print ''; @@ -416,18 +416,18 @@ if (!empty($arrayfields['cs.libelle']['checked'])) { if (!empty($arrayfields['cs.fk_type']['checked'])) { print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type", '', $param, 'class="left"', $sortfield, $sortorder); } -if (!empty($arrayfields['cs.fk_user']['checked'])) { - print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname", "", $param, 'class="left"', $sortfield, $sortorder); -} -if (!empty($arrayfields['p.ref']['checked'])) { - print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder); -} if (!empty($arrayfields['cs.date_ech']['checked'])) { print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech", '', $param, 'align="center"', $sortfield, $sortorder); } if (!empty($arrayfields['cs.periode']['checked'])) { print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, 'align="center"', $sortfield, $sortorder); } +if (!empty($arrayfields['p.ref']['checked'])) { + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['cs.fk_user']['checked'])) { + print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname", "", $param, 'class="left"', $sortfield, $sortorder); +} if (!empty($arrayfields['cs.amount']['checked'])) { print_liste_field_titre($arrayfields['cs.amount']['label'], $_SERVER["PHP_SELF"], "cs.amount", '', $param, 'class="right"', $sortfield, $sortorder); } @@ -492,37 +492,6 @@ while ($i < min($num, $limit)) { } } - if (!empty($arrayfields['cs.fk_user']['checked'])) { - // Employee - print ""; - if (!empty($obj->fk_user)) { - if (!empty($TLoadedUsers[$obj->fk_user])) { - $ustatic = $TLoadedUsers[$obj->fk_user]; - } else { - $ustatic = new User($db); - $ustatic->fetch($obj->fk_user); - $TLoadedUsers[$obj->fk_user] = $ustatic; - } - print $ustatic->getNomUrl(-1); - } - print "'; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''.dol_print_date($db->jdate($obj->date_ech), 'day').''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print '"; + if (!empty($obj->fk_user)) { + if (!empty($TLoadedUsers[$obj->fk_user])) { + $ustatic = $TLoadedUsers[$obj->fk_user]; + } else { + $ustatic = new User($db); + $ustatic->fetch($obj->fk_user); + $TLoadedUsers[$obj->fk_user] = $ustatic; + } + print $ustatic->getNomUrl(-1); + } + print "'.price($obj->amount).''; @@ -219,16 +231,19 @@ print '
'.$payment_sc_static->getNomUrl(1)."'; + $socialcontrib->id = $obj->rowid; + $socialcontrib->ref = empty($obj->libelle) ? $obj->label : $obj->libelle; + $socialcontrib->label = empty($obj->libelle) ? $obj->label : $obj->libelle; + print $socialcontrib->getNomUrl(1, '20'); + print ''.$obj->label.''.dol_print_date($date, 'day').''; - $socialcontrib->id = $obj->rowid; - $socialcontrib->ref = $obj->label; - $socialcontrib->label = $obj->label; - print $socialcontrib->getNomUrl(1, '20'); - print ''.$obj->label.''.price($obj->total).''.$payment_sc_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').'"; + if(!empty($obj->uid)) { + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->admin = $obj->admin; + $userstatic->login = $obj->login; + $userstatic->email = $obj->email; + $userstatic->socid = $obj->fk_soc; + $userstatic->statut = $obj->status; + print $userstatic->getNomUrl(1); + print "'; if ($obj->payment_code) { print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; } - print $obj->num_payment.''.$obj->num_payment.''; + $accountlinestatic->id = $obj->fk_bank; + print $accountlinestatic->getNomUrl(1); + print ''; if ($obj->fk_bank > 0) { - //$accountstatic->fetch($obj->fk_bank); $accountstatic->id = $obj->bid; $accountstatic->ref = $obj->bref; $accountstatic->number = $obj->bnumber; @@ -292,6 +330,8 @@ while ($i < min($num, $limit)) { } print ''.price($obj->total).''; if ($obj->totalpaye) { @@ -315,8 +355,11 @@ print '     '.price($totalpaye)."'; $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 16); print ''; $form->select_comptes($search_account, 'search_account', 0, '', 1); print ''.$langs->trans("PaymentTypeShort".$obj->payment_code).''; if ($obj->fk_account > 0) { $bankstatic->id = $obj->fk_account; @@ -494,15 +494,15 @@ while ($i < min($num, $limit)) { $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code); $bankstatic->account_number = $obj->account_number; - /*$accountingjournal->fetch($obj->fk_accountancy_journal); - $bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);*/ + //$accountingjournal->fetch($obj->fk_accountancy_journal); + //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); $bankstatic->label = $obj->blabel; print $bankstatic->getNomUrl(1); } print '
'; print ''; print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "ptva.rowid", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "bank.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATDeclaration", $_SERVER["PHP_SELF"], "tva.label", "", $param, '', $sortfield, $sortorder); - //print_liste_field_titre("TypeContrib", $_SERVER["PHP_SELF"], "tva.fk_type", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "tva.datev", "", $param, 'width="140px"', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "pc.num_paiement", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber'); + print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "ptva.fk_bank", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "bank.ref", "", $param, '', $sortfield, $sortorder); + //print_liste_field_titre("TypeContrib", $_SERVER["PHP_SELF"], "tva.fk_type", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "tva.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "ptva.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; - $sql = "SELECT tva.rowid, tva.label as label, b.fk_account"; + $sql = "SELECT tva.rowid, tva.label as label, b.fk_account, ptva.fk_bank"; $sql .= ", tva.datev"; $sql .= ", tva.amount as total,"; $sql .= " ptva.rowid as pid, ptva.datep, ptva.amount as totalpaye, ptva.num_paiement as num_payment,"; @@ -175,22 +178,10 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $payment_vat_static->ref = $obj->pid; print ''; + // Ref payment print '\n"; - // Date payment - print ''; - // Type payment - print ''; - // Account - print ''; + // Label print ''; - // Type - //print ''; + // Date $date = $obj->datev; print ''; + + // Date payment + print ''; + + // Type payment + print ''; + + // Chq number + print ''; + + // Bank transaction + print ''; + + // Account + print ''; + // Type + //print ''; // Expected to pay print ''; // Paid @@ -224,6 +242,8 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print ''; print ''; print ''; + print ''; + print ''; print '"; print ""; } else { diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index e37a108c2da..ee4f69caeac 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -411,10 +411,6 @@ print ''; -// Employee -print ''; // Date start print ''; +// Employee +print ''; + // Type -print ''; @@ -446,7 +447,7 @@ if (!empty($conf->banque->enabled)) { print ''; -} +}*/ // Amount print ''; @@ -476,13 +477,13 @@ print ''."\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder); -print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("DateStart", $_SERVER["PHP_SELF"], "s.datesp,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("DateEnd", $_SERVER["PHP_SELF"], "s.dateep,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder); -print_liste_field_titre("DefaultPaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); +print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname", "", $param, "", $sortfield, $sortorder); +/*print_liste_field_titre("DefaultPaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); if (!empty($conf->banque->enabled)) { print_liste_field_titre("DefaultBankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); -} +}*/ print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre('Status', $_SERVER["PHP_SELF"], "s.paye", '', $param, 'class="right"', $sortfield, $sortorder); // Extra fields @@ -547,12 +548,6 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $totalarray['nbfield']++; } - // Employee - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - // Date Start print '\n"; if (!$i) { @@ -565,8 +560,14 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $totalarray['nbfield']++; } + // Employee + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + // Type - print ''; + /*print ''; if (!$i) { $totalarray['nbfield']++; } @@ -602,7 +603,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if (!$i) { $totalarray['nbfield']++; } - } + }*/ // if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 3e6630dbaf1..7e5bf65a575 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -77,6 +77,8 @@ $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int' $search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'int'); +$search_fk_bank = GETPOST('search_fk_bank', 'int'); +$search_chq_number = GETPOST('search_chq_number', 'int'); $filtre = GETPOST("filtre", 'restricthtml'); @@ -141,6 +143,8 @@ if (empty($reshook)) { $search_date_end = ''; $search_amount = ""; $search_account = ''; + $search_fk_bank = ''; + $search_chq_number = ''; $search_type_id = ""; } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') @@ -171,6 +175,7 @@ $salstatic = new Salary($db); $paymentsalstatic = new PaymentSalary($db); $userstatic = new User($db); $accountstatic = new Account($db); +$accountlinestatic = new AccountLine($db); $now = dol_now(); @@ -201,6 +206,9 @@ if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_ if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'"; if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1); if ($search_account > 0) $sql .= " AND b.fk_account=".((int) $search_account); +if($search_fk_bank) $sql .= " AND s.fk_bank=".((int) $search_fk_bank); +if($search_chq_number) $sql .= natural_search(array('s.num_payment'), $search_chq_number); + if ($search_type_id > 0) { $sql .= " AND s.fk_typepayment=".$search_type_id; } @@ -245,8 +253,10 @@ if ($search_type_id) $param .= '&search_type_id='.urlencode($search_type_id); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); if ($search_ref_salary) $param .= '&search_ref_salary='.urlencode($search_ref_salary); -if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); +if ($search_user) $param .= '&search_user='.urlencode($search_user); if ($search_label) $param .= '&search_label='.urlencode($search_label); +if ($search_fk_bank) $param .= '&search_fk_bank='.urlencode($search_fk_bank); +if ($search_chq_number) $param .= '&search_chq_number='.urlencode($search_chq_number); if ($search_account) $param .= '&search_account='.urlencode($search_account); if ($search_date_start) $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int')); if ($search_date_end) $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int')); @@ -292,10 +302,6 @@ print ''; print ''; -// Employee -print ''; // Salary print ''; // Date value print ''; +// Employee +print ''; // Type print ''; +// Chq number +print ''; +// Bank transaction +print ''; // Account if (!empty($conf->banque->enabled)) { print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Salary", $_SERVER["PHP_SELF"], "sal.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateValue", $_SERVER["PHP_SELF"], "b.datev,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); +print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pst.code", "", $param, 'class="left"', $sortfield, $sortorder); +print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "s.num_payment", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber'); +print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "s.fk_bank", "", $param, '', $sortfield, $sortorder); if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); // Extra fields @@ -407,10 +425,6 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print "\n"; if (!$i) $totalarray['nbfield']++; - // Employee - print "\n"; - if (!$i) $totalarray['nbfield']++; - print "\n"; if (!$i) $totalarray['nbfield']++; @@ -426,12 +440,27 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print '\n"; if (!$i) $totalarray['nbfield']++; + // Employee + print "\n"; + if (!$i) $totalarray['nbfield']++; + // Type - print ''; + print ''; + if (!$i) $totalarray['nbfield']++; + + // Chq number + print ''; if (!$i) $totalarray['nbfield']++; // Account if (!empty($conf->banque->enabled)) { + + // Bank transaction + print ''; + print ''; + } else { + print '
'; + } + } + + // Date signature + if (!empty($object->date_signature)) { + if ($usetable) { + print ''; + } else { + print '
'; + } + } + // User close if (!empty($object->user_cloture) || !empty($object->user_closing)) { if (isset($object->user_cloture) && !empty($object->user_cloture)) { diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 772f0e51bdf..0c71b94f4f1 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -282,5 +282,11 @@ DELETE FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ti ALTER TABLE llx_c_ticket_category ADD COLUMN public integer DEFAULT 0; +ALTER TABLE llx_propal ADD COLUMN date_signature datetime AFTER date_valid; +ALTER TABLE llx_propal ADD COLUMN fk_user_signature integer AFTER fk_user_valid; +ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (fk_user_signature) REFERENCES llx_user (rowid); +UPDATE llx_propal SET fk_user_signature = fk_user_cloture WHERE fk_user_signature IS NULL AND fk_user_cloture IS NOT NULL; +UPDATE llx_propal SET date_signature = date_cloture WHERE date_signature IS NULL AND date_cloture IS NOT NULL; + diff --git a/htdocs/install/mysql/tables/llx_propal.key.sql b/htdocs/install/mysql/tables/llx_propal.key.sql index 89a0c54ad83..d0265e6fcdf 100644 --- a/htdocs/install/mysql/tables/llx_propal.key.sql +++ b/htdocs/install/mysql/tables/llx_propal.key.sql @@ -24,6 +24,7 @@ ALTER TABLE llx_propal ADD UNIQUE INDEX uk_propal_ref (ref, entity); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_soc (fk_soc); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_author (fk_user_author); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_valid (fk_user_valid); +ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_signature (fk_user_signature); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_cloture (fk_user_cloture); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_projet (fk_projet); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_account(fk_account); @@ -33,6 +34,7 @@ ALTER TABLE llx_propal ADD INDEX idx_propal_fk_warehouse(fk_warehouse); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); +ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (fk_user_signature) REFERENCES llx_user (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_cloture FOREIGN KEY (fk_user_cloture) REFERENCES llx_user (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); --ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid); diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index 004bb027d35..7c94086b3b9 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -37,11 +37,13 @@ create table llx_propal datep date, -- date de la propal fin_validite datetime, -- date de fin de validite date_valid datetime, -- date de validation + date_signature datetime, -- date signature date_cloture datetime, -- date de cloture fk_user_author integer, -- user making creation fk_user_modif integer, -- user making last change fk_user_valid integer, -- user validating - fk_user_cloture integer, -- user closing (signed or not) + fk_user_signature integer, -- user signing (signed or not) + fk_user_cloture integer, -- user closing fk_statut smallint DEFAULT 0 NOT NULL, -- 0=draft, 1=validated, 2=accepted, 3=refused, 4=billed/closed price real DEFAULT 0, -- (obsolete) remise_percent real DEFAULT 0, -- remise globale relative en pourcent (obsolete) diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 86ba2247682..a8b13c7e914 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -278,6 +278,7 @@ DateModificationShort=Date modif. IPModification=Modification IP DateLastModification=Date de dernière modification DateValidation=Date validation +DateSigning=Date signature DateClosing=Date clôture DateDue=Date échéance DateValue=Date valeur diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 3023cd7216e..a8078129464 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -114,6 +114,7 @@ DemoCompanyAll=Société avec de multiples activités (tous les modules principa CreatedBy=Créé par %s ModifiedBy=Modifié par %s ValidatedBy=Validé par %s +SignedBy=Signé par %s ClosedBy=Clôturé par %s CreatedById=Id utilisateur créateur ModifiedById=Id utilisateur du dernier changement From 84ec032cc0215e89b745d74adcb3b0d9db6acab1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Mar 2021 17:58:00 +0100 Subject: [PATCH 181/618] Look and feel v14 --- htdocs/api/admin/index.php | 15 ++++++----- htdocs/core/ajax/selectsearchbox.php | 2 +- htdocs/core/class/html.form.class.php | 9 ++++--- htdocs/core/lib/functions.lib.php | 4 +-- htdocs/core/lib/payments.lib.php | 4 +-- htdocs/core/lib/signature.lib.php | 10 ++++++-- htdocs/theme/eldy/global.inc.php | 10 ++++---- htdocs/theme/eldy/main_menu_fa_icons.inc.php | 2 +- htdocs/theme/md/main_menu_fa_icons.inc.php | 2 +- htdocs/theme/md/style.css.php | 27 ++++++++++++++++---- 10 files changed, 56 insertions(+), 29 deletions(-) diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index 05f372a3486..1697318c5e8 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -139,21 +139,24 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai // Show message $message = ''; -$url = $urlwithroot.'/api/index.php/login?login=auserlogin&password=thepassword[&reset=1]'; +//$url = $urlwithroot.'/api/index.php/login?login=auserlogin&password=thepassword[&reset=1]'; +$url = $urlwithroot.'/api/index.php/login?login=auserlogin&password=thepassword[&reset=1]'; $message .= ''.$langs->trans("UrlToGetKeyToUseAPIs").':
'; -$message .= ''; +$message .= ''; print $message; +print ajax_autoselect("urltogettoken"); print '
'; print '
'; // Explorer -print ''.$langs->trans("ApiExporerIs").':
'; +print ''.$langs->trans("ApiExporerIs").':
'; if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer')) { $url = DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; - print '
\n"; - print '

'.$langs->trans("SwaggerDescriptionFile").':
'; + print '
\n"; + print '

'.$langs->trans("SwaggerDescriptionFile").':
'; $urlswagger = DOL_MAIN_URL_ROOT.'/api/index.php/explorer/swagger.json?DOLAPIKEY=youruserapikey'; - print '
\n"; + //$urlswaggerreal = DOL_MAIN_URL_ROOT.'/api/index.php/explorer/swagger.json?DOLAPIKEY='.$user->api_key; + print '
\n"; print '
'; } else { $langs->load("errors"); diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 2794243b7f3..d10324ef620 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -81,7 +81,7 @@ if (((!empty($conf->product->enabled) && $user->rights->produit->lire) || (!empt $arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); // search on lot/serial numbers if ( ! empty($conf->productbatch->enabled) ) { - $arrayresult['searchintobatch'] = array('position'=>32, 'shortcut'=>'B', 'img'=>'object_plot', 'label'=>$langs->trans("SearchIntoBatch", $search_boxvalue), 'text'=>img_picto('', 'object_lot').' '.$langs->trans("SearchIntoBatch", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/stock/productlot_list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintobatch'] = array('position'=>32, 'shortcut'=>'B', 'img'=>'object_lot', 'label'=>$langs->trans("SearchIntoBatch", $search_boxvalue), 'text'=>img_picto('', 'object_lot').' '.$langs->trans("SearchIntoBatch", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/stock/productlot_list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 36e7eca84b6..21c886cb2fa 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7721,16 +7721,17 @@ class Form print '
'; print ''; - print ''; + print ''; print ''; print ''; + print ''.price($objp->total_ht).''; + print ''; print ''; print ''; $i++; @@ -7760,7 +7761,7 @@ class Form '; // Ref diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index b4c63365bf8..453abff36b2 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1532,7 +1532,7 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['p.total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1543,7 +1543,7 @@ if ($resql) { } // Amount VAT if (!empty($arrayfields['p.total_tva']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1554,7 +1554,7 @@ if ($resql) { } // Amount TTC if (!empty($arrayfields['p.total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1563,9 +1563,9 @@ if ($resql) { } $totalarray['val']['p.total_ttc'] += $obj->total_ttc; } - // Amount invoiced + // Amount invoiced HT if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1574,9 +1574,9 @@ if ($resql) { } $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT; } - // Amount invoiced + // Amount invoiced TTC if (!empty($arrayfields['p.total_invoiced']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1604,35 +1604,35 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount VAT if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount TTC if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount invoiced if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount invoiced if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 117f7557db3..0b850e6b0e8 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1437,7 +1437,7 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['c.total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1448,7 +1448,7 @@ if ($resql) { } // Amount VAT if (!empty($arrayfields['c.total_vat']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1459,7 +1459,7 @@ if ($resql) { } // Amount TTC if (!empty($arrayfields['c.total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1488,21 +1488,21 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount VAT if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount TTC if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php index 6da20bf28d0..e08bc1073b6 100644 --- a/htdocs/core/boxes/box_members_last_subscriptions.php +++ b/htdocs/core/boxes/box_members_last_subscriptions.php @@ -153,7 +153,7 @@ class box_members_last_subscriptions extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', - 'text' => price($obj->subscription), + 'text' => ''.price($obj->subscription).'', ); $this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index ef796b75044..b6c146312bc 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -180,11 +180,11 @@ class box_members_subscriptions_by_year extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => price($value), + 'text' => ''.price($value).'', ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => price(price2num($value / $Number[$key], 'MT')), + 'text' => ''.price(price2num($value / $Number[$key], 'MT')).'', ); $line++; } @@ -205,11 +205,11 @@ class box_members_subscriptions_by_year extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => price($tot), + 'text' => ''.price($tot).'', ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT')), + 'text' => ''.price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT')).'', ); } } else { diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index e35d9d84824..09834f5c2af 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1439,7 +1439,7 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['cf.total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1450,7 +1450,7 @@ if ($resql) { } // Amount VAT if (!empty($arrayfields['cf.total_tva']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1461,7 +1461,7 @@ if ($resql) { } // Amount TTC if (!empty($arrayfields['cf.total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1490,21 +1490,21 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount VAT if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount TTC if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index e907ab3b06e..976e29b55bf 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -1107,7 +1107,7 @@ while ($i < min($num, $limit)) { print ''; @@ -1136,7 +1136,7 @@ while ($i < min($num, $limit)) { } print ''; @@ -1151,7 +1151,7 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['p.budget_amount']['checked'])) { print ''; @@ -1232,7 +1232,7 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['p.price_registration']['checked'])) { print ''; @@ -1247,7 +1247,7 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['p.price_booth']['checked'])) { print ''; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 6851bbb4021..f60f20f7f7a 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -954,7 +954,7 @@ if ($resql) { // Amount HT if (!empty($arrayfields['sp.total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -965,7 +965,7 @@ if ($resql) { } // Amount VAT if (!empty($arrayfields['sp.total_tva']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -976,7 +976,7 @@ if ($resql) { } // Amount TTC if (!empty($arrayfields['sp.total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1005,21 +1005,21 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount VAT if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount TTC if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } From 32246e4d69b3ebffe59d3d59b109328804af71e5 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 18:29:06 +0100 Subject: [PATCH 184/618] workiong attendees --- .../eventorganization/class/conferenceorbooth.class.php | 8 +------- htdocs/eventorganization/conferenceorbooth_card.php | 6 ------ .../lib/eventorganization_conferenceorbooth.lib.php | 2 ++ 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 4f3fa42b51f..c7118d7c589 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -109,7 +109,7 @@ class ConferenceOrBooth extends ActionComm 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1::eventorganization', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,), - 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1,), + 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'default'=>'', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1,), 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datep2' => array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -152,12 +152,6 @@ class ConferenceOrBooth extends ActionComm $this->fields['entity']['enabled'] = 0; } - // Example to show how to set values of fields definition dynamically - /*if ($user->rights->eventorganization->conferenceorbooth->read) { - $this->fields['myfield']['visible'] = 1; - $this->fields['myfield']['noteditable'] = 0; - }*/ - // Unset fields that are disabled foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 4ca3457b4fa..90c47b4806a 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -72,12 +72,6 @@ if (empty($action) && empty($id) && empty($ref)) { // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. - -/*$permissiontoread = $user->rights->eventorganization->conferenceorbooth->read; -$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->eventorganization->conferenceorbooth->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_dellink.inc.php*/ $permissiontoread = $user->rights->eventorganization->read; $permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php index f43eaa83f1a..0a1ddd27dce 100644 --- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -117,6 +117,8 @@ function conferenceorboothattendeePrepareHead($object) $head[$h][2] = 'card'; $h++; + //TODO : Note and docuement + complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization', 'remove'); From 3e12820f0e93d6b99999eb67e10f52b8db88cd66 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 18:37:11 +0100 Subject: [PATCH 185/618] fix comment --- htdocs/core/class/html.form.class.php | 2 +- htdocs/eventorganization/class/conferenceorbooth.class.php | 2 +- htdocs/eventorganization/conferenceorbooth_list.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 779e89c1f9f..df79fcfca7c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -96,7 +96,7 @@ class Form * @param string $preselected Value to show/edit (not used in this function) * @param object $object Object * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), '+:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'checkbox:ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) * @param string $moreparam More param to add on a href URL. * @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS. * @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':', 3=Do not output table tags but output a ' ' diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index c7118d7c589..ddc75a034d0 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -109,7 +109,7 @@ class ConferenceOrBooth extends ActionComm 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1::eventorganization', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,), - 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'default'=>'', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1,), + 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'default'=>'', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=> 1, 'visible'=>1,), 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datep2' => array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 85bdd52905f..96c67e09c0b 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2021 Florian Henry * * This program is free software; you can redistribute it and/or modify From a8b486c7b9b6c73b113e765e705bdd9ae6367e17 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 19:00:56 +0100 Subject: [PATCH 186/618] fix error translation --- htdocs/comm/action/class/actioncomm.class.php | 4 ++-- htdocs/eventorganization/class/conferenceorbooth.class.php | 2 +- htdocs/langs/en_US/errors.lang | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 4bef5ddcd16..03ca6ae0369 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -407,7 +407,7 @@ class ActionComm extends CommonObject // Check parameters if (!isset($this->userownerid) || $this->userownerid === '') { // $this->userownerid may be 0 (anonymous event) of > 0 dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); - $this->errors[] = 'ErrorPropertyUserowneridNotDefined'; + $this->errors[] = 'ErrorActionCommPropertyUserowneridNotDefined'; return -1; } @@ -478,7 +478,7 @@ class ActionComm extends CommonObject $this->type_id = $cactioncomm->id; $this->type_code = $cactioncomm->code; } elseif ($result == 0) { - $this->error = 'Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; + $this->error = $langs->trans('ErrorActionCommBadType', $this->type_id, $this->type_code); return -1; } else { $this->error = $cactioncomm->error; diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index ddc75a034d0..ecd2fcd191f 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -109,7 +109,7 @@ class ConferenceOrBooth extends ActionComm 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1::eventorganization', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,), - 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'default'=>'', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=> 1, 'visible'=>1,), + 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1,), 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datep2' => array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index bb5e7c5e287..002aa63fa62 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -293,4 +293,6 @@ WarningFailedToAddFileIntoDatabaseIndex=Warning, failed to add file entry into E WarningTheHiddenOptionIsOn=Warning, the hidden option %s is on. WarningCreateSubAccounts=Warning, you can't create directly a sub account, you must create a third party or an user and assign them an accounting code to find them in this list WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connection. -WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. \ No newline at end of file +WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. +ErrorActionCommPropertyUserowneridNotDefined=User's owner is required +ErrorActionCommBadType=Selected event type (id: %n, code: %s) do not exist in Event Type dictionary From a254bbcc02912845c03ca347f50c7e3145419d98 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 19:05:55 +0100 Subject: [PATCH 187/618] fix translation --- htdocs/install/mysql/data/llx_c_email_templates.sql | 2 +- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 +- htdocs/langs/en_US/eventorganization.lang | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index 713a7f31a4f..fabbbf2e700 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -36,5 +36,5 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendes)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index e2aed6fe5f9..8e75870b233 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -197,7 +197,7 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendes', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendes)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); ALTER TABLE llx_projet ADD COLUMN accept_conference_suggestions integer DEFAULT 0; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index dfb1b4faee5..33d74affd3e 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -62,7 +62,7 @@ EventOrganizationEmailAskConf = Request for conference EventOrganizationEmailAskBooth = Request for booth EventOrganizationEmailSubsBooth = Subscription for booth EventOrganizationEmailSubsEvent = Subscription for an event -EventOrganizationMassEmailAttendees = Communication to attendes +EventOrganizationMassEmailAttendees = Communication to attendees EventOrganizationMassEmailSpeakers = Communication to speakers # From 47675d28d79f4e6ac03b12122cf9d2ed6430899e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 19:47:48 +0100 Subject: [PATCH 188/618] add filter for select list attendees --- htdocs/admin/eventorganization.php | 36 +++++++++++-------- htdocs/langs/en_US/eventorganization.lang | 2 ++ htdocs/modulebuilder/template/admin/setup.php | 15 ++++++++ 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 23fc463f3b5..743da034060 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -52,6 +52,8 @@ $arrayofparameters = array( 'EVENTORGANIZATION_TASK_LABEL'=>array('type'=>'textarea','enabled'=>1), 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + 'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + 'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), @@ -144,7 +146,7 @@ if ($action == 'updateMask') { } } } -} elseif ($action == 'setdoc') { +}/* elseif ($action == 'setdoc') { // Set or unset default model $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { @@ -167,7 +169,7 @@ if ($action == 'updateMask') { $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; dolibarr_del_const($db, $constforval, $conf->entity); } -} +}*/ @@ -177,7 +179,7 @@ if ($action == 'updateMask') { $form = new Form($db); -$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); +//$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $page_name = "EventOrganizationSetup"; llxHeader('', $langs->trans($page_name)); @@ -249,6 +251,10 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + $formcompany = new FormCompany($db); + print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); } else { print ''; } @@ -309,6 +315,16 @@ if ($action == 'edit') { } print '
    ' . implode(' ', $toprint) . '
'; } + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + if ($conf->global->{$constname}==2) { + print $langs->trans("Prospect"); + } elseif ($conf->global->{$constname}==3) { + print $langs->trans("ProspectCustomer"); + } elseif ($conf->global->{$constname}==1) { + print $langs->trans("Customer"); + } elseif ($conf->global->{$constname}==0) { + print $langs->trans("NorProspectNorCustomer"); + } } else { print $conf->global->{$constname}; } @@ -327,7 +343,7 @@ if ($action == 'edit') { } -$moduledir = 'eventorganization'; +/*$moduledir = 'eventorganization'; $myTmpObjects = array(); $myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0); @@ -337,9 +353,6 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { continue; } if ($myTmpObjectArray['includerefgeneration']) { - /* - * Orders Numbering model - */ $setupnotempty++; print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', ''); @@ -444,9 +457,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { } if ($myTmpObjectArray['includedocgeneration']) { - /* - * Document templates generators - */ + $setupnotempty++; $type = strtolower($myTmpObjectKey); @@ -588,10 +599,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print '
'.$payment_vat_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; - if ($obj->payment_code) { - print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; - } - print $obj->num_payment.''; - $account = new Account($db); - $account->fetch($obj->fk_account); - print $account->getNomUrl(1); - print ''; $tva->id = $obj->rowid; @@ -198,11 +189,38 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $tva->label = $obj->label; print $tva->getNomUrl(1, '20'); print ''.$obj->type_label.''.dol_print_date($date, 'day').''.dol_print_date($db->jdate($obj->datep), 'day').''; + if ($obj->payment_code) { + print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + } + print ''.$obj->num_payment.''; + $accountlinestatic->id = $obj->fk_bank; + print $accountlinestatic->getNomUrl(1); + print ''; + $account = new Account($db); + $account->fetch($obj->fk_account); + print $account->getNomUrl(1); + print ''.$obj->type_label.''.price($obj->total).'     '.price($totalpaye)."
'; -print ''; -print ''; @@ -436,8 +432,13 @@ print $form->selectDate($search_date_end_to ? $search_date_end_to : -1, 'search_ print ''; print ''; +print ''; +print ''; +/*print ''; $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16); print ''; $form->select_comptes($search_account, 'search_account', 0, '', 1); print '
".$userstatic->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datesp), 'day')."".$userstatic->getNomUrl(1)."'.$langs->trans("PaymentTypeShort".$obj->payment_code).''.$langs->trans("PaymentTypeShort".$obj->payment_code).'
'; print ''; print ''; -print ''; -print ''; print ''; @@ -314,10 +320,20 @@ print ''; print ''; +print ''; +print ''; $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16); print ''; +print ''; +print ''; @@ -345,13 +361,15 @@ print '
".$paymentsalstatic->getNomUrl(1)."".$userstatic->getNomUrl(1)."".$salstatic->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datev), 'day')."".$userstatic->getNomUrl(1)."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''.$langs->trans("PaymentTypeShort".$obj->payment_code).''.$obj->num_payment.''; + $accountlinestatic->id = $obj->fk_bank; + print $accountlinestatic->getNomUrl(1); + print ''; if ($obj->fk_bank > 0) { //$accountstatic->fetch($obj->fk_bank); From 895c6efc144ed3132aec592e7b86440743cbe969 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 26 Mar 2021 15:26:05 +0000 Subject: [PATCH 179/618] Fixing style errors. --- htdocs/compta/sociales/payments.php | 3 +-- htdocs/salaries/payments.php | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 81aeaf3d9b9..89a841ff3ab 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -285,7 +285,7 @@ while ($i < min($num, $limit)) { // Employee print ""; - if(!empty($obj->uid)) { + if (!empty($obj->uid)) { $userstatic->id = $obj->uid; $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; @@ -309,7 +309,6 @@ while ($i < min($num, $limit)) { // Account if (!empty($conf->banque->enabled)) { - // Bank transaction print ''; $accountlinestatic->id = $obj->fk_bank; diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 7e5bf65a575..f02b33fb901 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -206,8 +206,8 @@ if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_ if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'"; if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1); if ($search_account > 0) $sql .= " AND b.fk_account=".((int) $search_account); -if($search_fk_bank) $sql .= " AND s.fk_bank=".((int) $search_fk_bank); -if($search_chq_number) $sql .= natural_search(array('s.num_payment'), $search_chq_number); +if ($search_fk_bank) $sql .= " AND s.fk_bank=".((int) $search_fk_bank); +if ($search_chq_number) $sql .= natural_search(array('s.num_payment'), $search_chq_number); if ($search_type_id > 0) { $sql .= " AND s.fk_typepayment=".$search_type_id; @@ -454,7 +454,6 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Account if (!empty($conf->banque->enabled)) { - // Bank transaction print ''; $accountlinestatic->id = $obj->fk_bank; From 8a2e49d6e7e67b08a72013028e830245d1e1bb9c Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 26 Mar 2021 17:44:41 +0100 Subject: [PATCH 180/618] NEW date and user signature on proposal (Issue 16062) --- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/class/propal.class.php | 112 +++++++++++++++++- htdocs/core/lib/functions2.lib.php | 55 +++++++++ .../install/mysql/migration/13.0.0-14.0.0.sql | 6 + .../install/mysql/tables/llx_propal.key.sql | 2 + htdocs/install/mysql/tables/llx_propal.sql | 4 +- htdocs/langs/fr_FR/main.lang | 1 + htdocs/langs/fr_FR/other.lang | 1 + 8 files changed, 179 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index cecb4fff28a..dc923e4e1dc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -642,7 +642,7 @@ if (empty($reshook)) { if ($object->statut == $object::STATUS_VALIDATED) { $db->begin(); - $result = $object->cloture($user, GETPOST('statut', 'int'), GETPOST('note_private', 'restricthtml')); + $result = $object->signature($user, GETPOST('statut', 'int'), GETPOST('note_private', 'restricthtml')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3674356af20..c9f736fcfff 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -140,6 +140,16 @@ class Propal extends CommonObject */ public $date_validation; + /** + * @var integer|string $date_signature; + */ + public $date_signature; + + /** + * @var User $user_signature + */ + public $user_signature; + /** * @var integer|string date of the quote; */ @@ -2489,6 +2499,97 @@ class Propal extends CommonObject } } + /** + * Sign the commercial proposal + * + * @param User $user Object user that close + * @param int $statut Status + * @param string $note Complete private note with this note + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + function signature($user, $statut, $note = '', $notrigger = 0) + { + global $langs,$conf; + + $error = 0; + $now = dol_now(); + + $this->db->begin(); + + $newprivatenote = dol_concatdesc($this->note_private, $note); + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql .= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($newprivatenote)."', date_signature='".$this->db->idate($now)."', fk_user_signature=".$user->id; + $sql .= " WHERE rowid = ".$this->id; + + $resql = $this->db->query($sql); + if ($resql) { + $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->model_pdf; + $trigger_name = 'PROPAL_CLOSE_REFUSED'; + + if ($statut == self::STATUS_SIGNED) { + $trigger_name = 'PROPAL_CLOSE_SIGNED'; + $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->model_pdf; + + // The connected company is classified as a client + $soc=new Societe($this->db); + $soc->id = $this->socid; + $result = $soc->set_as_client(); + + if ($result < 0) { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (!empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id','aZ09') ? GETPOST('lang_id','aZ09') : $this->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + + //$ret=$object->fetch($id); // Reload to get new records + $this->generateDocument($modelpdf, $outputlangs); + } + + if (!$error) { + $this->oldcopy= clone $this; + $this->statut = $statut; + $this->date_signature = $now; + $this->note_private = $newprivatenote; + } + + if (!$notrigger && empty($error)) { + // Call trigger + $result=$this->call_trigger($trigger_name, $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + + if (!$error ) { + $this->db->commit(); + return 1; + } else { + $this->statut = $this->oldcopy->statut; + $this->date_signature = $this->oldcopy->date_signature; + $this->note_private = $this->oldcopy->note_private; + + $this->db->rollback(); + return -1; + } + } else { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } /** * Close the commercial proposal @@ -3113,8 +3214,8 @@ class Propal extends CommonObject public function info($id) { $sql = "SELECT c.rowid, "; - $sql .= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; - $sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_cloture"; + $sql .= " c.datec, c.date_valid as datev, c.date_signature, c.date_cloture as dateo,"; + $sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_signature, c.fk_user_cloture"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; $sql .= " WHERE c.rowid = ".((int) $id); @@ -3128,6 +3229,7 @@ class Propal extends CommonObject $this->date_creation = $this->db->jdate($obj->datec); $this->date_validation = $this->db->jdate($obj->datev); + $this->date_signature = $this->db->jdate($obj->date_signature); $this->date_cloture = $this->db->jdate($obj->dateo); $cuser = new User($this->db); @@ -3140,6 +3242,12 @@ class Propal extends CommonObject $this->user_validation = $vuser; } + if ($obj->fk_user_signature) { + $user_signature = new User($this->db); + $user_signature->fetch($obj->fk_user_signature); + $this->user_signature = $user_signature; + } + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 0703df95255..3f7e02b9bad 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -507,6 +507,61 @@ function dol_print_object_info($object, $usetable = 0) } } + // User signature + if (!empty($object->user_signature)) { + if ($usetable) { + print '
'; + } + print $langs->trans('SignedBy'); + if ($usetable) { + print ''; + } else { + print ': '; + } + if (is_object($object->user_signature)) { + if ($object->user_signature->id) { + print $object->user_signature->getNomUrl(-1, '', 0, 0, 0); + } else { + print $langs->trans('Unknown'); + } + } else { + $userstatic = new User($db); + $userstatic->fetch($object->user_signature); + if ($userstatic->id) { + print $userstatic->getNomUrl(-1, '', 0, 0, 0); + } else { + print $langs->trans('Unknown'); + } + } + if ($usetable) { + print '
'; + } + print $langs->trans('DateSigning'); + if ($usetable) { + print ''; + } else { + print ': '; + } + print dol_print_date($object->date_signature, 'dayhour'); + if ($deltadateforuser) { + print ' '.$langs->trans('CurrentHour').'   /   '.dol_print_date($object->date_signature,'dayhour', 'tzuserrel').'  '.$langs->trans('ClientHour'); + } + if ($usetable) { + print '
'; - print ''; + print ''; print ''.$objp->ref.''.$objp->ref_client.''; if ($possiblelink['label'] == 'LinkToContract') { $form = new Form($this->db); print $form->textwithpicto('', $langs->trans("InformationOnLinkToContract")).' '; } - print price($objp->total_ht).''.$objp->name.'
'.price($obj->total_ht)."'.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.price($obj->total_ttc)."'.price($totalInvoicedHT)."'.price($totalInvoicedHT)."'.price($totalInvoicedTTC)."'.price($totalInvoicedTTC)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_tva)."'.price($obj->multicurrency_total_tva)."'.price($obj->multicurrency_total_ttc)."'.price($obj->multicurrency_total_ttc)."'.price($multicurrency_totalInvoicedHT)."'.price($multicurrency_totalInvoicedHT)."'.price($multicurrency_totalInvoicedTTC)."'.price($multicurrency_totalInvoicedTTC)."'.price($obj->total_ht)."'.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.price($obj->total_ttc)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'.price($obj->multicurrency_total_ttc)."'.price($obj->total_ht)."'.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.price($obj->total_ttc)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_tva)."'.price($obj->multicurrency_total_tva)."'.price($obj->multicurrency_total_ttc)."'.price($obj->multicurrency_total_ttc)."'; //if ($obj->opp_status_code) if (strcmp($obj->opp_amount, '')) { - print price($obj->opp_amount, 1, $langs, 1, -1, -1, ''); + print ''.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').''; $totalarray['val']['p.opp_amount'] += $obj->opp_amount; } print ''; if ($obj->opp_weighted_amount) { - print price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, ''); + print ''.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').''; $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; } print ''; if ($obj->budget_amount != '') { - print price($obj->budget_amount, 1, $langs, 1, -1, -1); + print ''.price($obj->budget_amount, 1, $langs, 1, -1, -1).''; $totalarray['val']['p.budget_amount'] += $obj->budget_amount; } print ''; if ($obj->price_registration != '') { - print price($obj->price_registration, 1, $langs, 1, -1, -1); + print ''.price($obj->price_registration, 1, $langs, 1, -1, -1).''; $totalarray['val']['p.price_registration'] += $obj->price_registration; } print ''; if ($obj->price_booth != '') { - print price($obj->price_booth, 1, $langs, 1, -1, -1); + print ''.price($obj->price_booth, 1, $langs, 1, -1, -1).''; $totalarray['val']['p.price_booth'] += $obj->price_booth; } print ''.price($obj->total_ht)."'.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.price($obj->total_ttc)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'.price($obj->multicurrency_total_ttc)."
'; } } - -if (empty($setupnotempty)) { - print '
'.$langs->trans("NothingToSetup"); -} +*/ // Page end print dol_get_fiche_end(); diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 33d74affd3e..c242904b074 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -42,6 +42,8 @@ EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH = Template of email to send aft EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT = Template of email to send after a subscription to an event has been paid. EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER = Template of email of massaction to attendes EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES = Template of email of massaction to speakers +EVENTORGANIZATION_FILTERATTENDEES_CAT=Categories to filter thirdpartie's select list in attendees creation card/form +EVENTORGANIZATION_FILTERATTENDEES_TYPE=Thirdparty type to filter thirdpartie's select list in attendees creation card/form # # Object diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 06b169863f5..2e00c5c7cf9 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -80,6 +80,7 @@ $arrayofparameters = array( //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), + //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), ); $error = 0; @@ -271,6 +272,10 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + $formcompany = new FormCompany($db); + print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); } else { print ''; } @@ -327,6 +332,16 @@ if ($action == 'edit') { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; } print '
      ' . implode(' ', $toprint) . '
    '; + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + if ($conf->global->{$constname}==2) { + print $langs->trans("Prospect"); + } elseif ($conf->global->{$constname}==3) { + print $langs->trans("ProspectCustomer"); + } elseif ($conf->global->{$constname}==1) { + print $langs->trans("Customer"); + } elseif ($conf->global->{$constname}==0) { + print $langs->trans("NorProspectNorCustomer"); + } } else { print $conf->global->{$constname}; } From 639942352629ee538cb1de2e0601750fa2e38630 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 19:56:06 +0100 Subject: [PATCH 189/618] fix translation --- htdocs/langs/en_US/eventorganization.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index c242904b074..180e04e6ccd 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -42,8 +42,8 @@ EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH = Template of email to send aft EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT = Template of email to send after a subscription to an event has been paid. EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER = Template of email of massaction to attendes EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES = Template of email of massaction to speakers -EVENTORGANIZATION_FILTERATTENDEES_CAT=Categories to filter thirdpartie's select list in attendees creation card/form -EVENTORGANIZATION_FILTERATTENDEES_TYPE=Thirdparty type to filter thirdpartie's select list in attendees creation card/form +EVENTORGANIZATION_FILTERATTENDEES_CAT = Filter thirdpartie's select list in attendees creation card/form with catagories +EVENTORGANIZATION_FILTERATTENDEES_TYPE = Filter thirdpartie's select list in attendees creation card/form with customer type # # Object From 7a6cc742a6981c31e8bac70b9277e0f8934ddc98 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 19:57:20 +0100 Subject: [PATCH 190/618] fix translation --- htdocs/langs/en_US/eventorganization.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 180e04e6ccd..57106492f12 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -42,7 +42,7 @@ EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH = Template of email to send aft EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT = Template of email to send after a subscription to an event has been paid. EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER = Template of email of massaction to attendes EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES = Template of email of massaction to speakers -EVENTORGANIZATION_FILTERATTENDEES_CAT = Filter thirdpartie's select list in attendees creation card/form with catagories +EVENTORGANIZATION_FILTERATTENDEES_CAT = Filter thirdpartie's select list in attendees creation card/form with category EVENTORGANIZATION_FILTERATTENDEES_TYPE = Filter thirdpartie's select list in attendees creation card/form with customer type # From aa9d4342cd5088920e77166f9f43b1f2fb82ed86 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 20:18:22 +0100 Subject: [PATCH 191/618] fix translation --- .../class/conferenceorboothattendee.class.php | 7 +++++++ htdocs/langs/en_US/eventorganization.lang | 1 + 2 files changed, 8 insertions(+) diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 4def01d2c7f..c8cec4172c7 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -194,6 +194,13 @@ class ConferenceOrBoothAttendee extends CommonObject $this->fields['entity']['enabled'] = 0; } + if (!empty($conf->global->EVENTORGANIZATION_FILTERATTENDEES_CAT)) { + $this->fields['fk_soc']['type'] .= ' AND rowid IN (SELECT DISTINCT c.fk_soc FROM '.MAIN_DB_PREFIX.'categorie_societe as c WHERE c.fk_categorie='.(int) $conf->global->EVENTORGANIZATION_FILTERATTENDEES_CAT.')'; + } + if ($conf->global->EVENTORGANIZATION_FILTERATTENDEES_TYPE!=='') { + $this->fields['fk_soc']['type'] .= ' AND client='.(int) $conf->global->EVENTORGANIZATION_FILTERATTENDEES_TYPE; + } + // Example to show how to set values of fields definition dynamically /*if ($user->rights->eventorganization->conferenceorboothattendee->read) { $this->fields['myfield']['visible'] = 1; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 57106492f12..8dadf5fdb97 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -54,6 +54,7 @@ ConferenceOrBooth = Conference Or Booth ConferenceOrBoothTab = Conference Or Booth AmountOfSubscriptionPaid = Amount of subscription paid DateSubscription = Date of subscription +ConferenceOrBoothAttendee = Conference Or Booth Attendee # # Template Mail From c1ceefb70f4a13d181ee4772cd12338742218bf1 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 27 Mar 2021 04:44:20 +0100 Subject: [PATCH 192/618] Update with new functionality --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/langs/en_US/main.lang | 1 - htdocs/main.inc.php | 21 +++++++-------------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d4e35f12d70..35d311a5416 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3548,7 +3548,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'object_salary', 'object_shipment', 'object_share-alt', 'object_supplier_invoice', 'object_supplier_invoicea', 'object_supplier_invoiced', 'object_supplier_order', 'object_supplier_proposal', 'object_service', 'object_stock', 'object_technic', 'object_ticket', 'object_trip', 'object_user', 'object_group', 'object_member', 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', 'object_movement', - 'off', 'on', 'order', 'copy', + 'off', 'on', 'order', 'paiment', 'play', 'pdf', 'phone', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'stock', 'resize', 'service', 'stats', 'trip', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', 'github', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index b1798aaf948..b13e15b4a9f 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1128,4 +1128,3 @@ ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected CategTypeNotFound=No tag type found for type of records CopiedToClipboard=Copied to clipboard InformationOnLinkToContract=This amount is only the total of all the lines of the contract. No notion of time is taken into consideration. -HelpCopyToClipboardShort=Copier dans le presse-papier diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 07551aaf9ea..baf9e3196cf 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1985,13 +1985,13 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= ' '.$langs->trans("ShowCompanyInfos").''; $dropdownBody .= '
    '; - if (!empty($conf->global->MAIN_INFO_SIREN)) $dropdownBody .= '
    '.$langs->transcountry("ProfId1Short", $mysoc->country_code).': '.$conf->global->MAIN_INFO_SIREN.' '.img_picto($langs->trans("HelpCopyToClipboardShort"), 'copy').''; - if (!empty($conf->global->MAIN_INFO_SIRET)) $dropdownBody .= '
    '.$langs->transcountry("ProfId2Short", $mysoc->country_code).': '.$conf->global->MAIN_INFO_SIRET.' '.img_picto($langs->trans("HelpCopyToClipboardShort"), 'copy').''; - if (!empty($conf->global->MAIN_INFO_APE)) $dropdownBody .= '
    '.$langs->transcountry("ProfId3Short", $mysoc->country_code).': '.$conf->global->MAIN_INFO_APE.' '.img_picto($langs->trans("HelpCopyToClipboardShort"), 'copy').''; - if (!empty($conf->global->MAIN_INFO_RCS)) $dropdownBody .= '
    '.$langs->transcountry("ProfId4Short", $mysoc->country_code).': '.$conf->global->MAIN_INFO_RCS.' '.img_picto($langs->trans("HelpCopyToClipboardShort"), 'copy').''; - if (!empty($conf->global->MAIN_INFO_PROFID5)) $dropdownBody .= '
    '.$langs->transcountry("ProfId5Short", $mysoc->country_code).': '.$conf->global->MAIN_INFO_PROFID5.' '.img_picto($langs->trans("HelpCopyToClipboardShort"), 'copy').''; - if (!empty($conf->global->MAIN_INFO_PROFID6)) $dropdownBody .= '
    '.$langs->transcountry("ProfId6Short", $mysoc->country_code).': '.$conf->global->MAIN_INFO_PROFID6.' '.img_picto($langs->trans("HelpCopyToClipboardShort"), 'copy').''; - if (!empty($conf->global->MAIN_INFO_TVAINTRA)) $dropdownBody .= '
    '.$langs->trans("VATIntraShort").': '.$conf->global->MAIN_INFO_TVAINTRA.' '.img_picto($langs->trans("HelpCopyToClipboardShort"), 'copy').''; + if (!empty($conf->global->MAIN_INFO_SIREN)) $dropdownBody .= '
    '.$langs->transcountry("ProfId1Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIREN).''; + if (!empty($conf->global->MAIN_INFO_SIRET)) $dropdownBody .= '
    '.$langs->transcountry("ProfId2Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIRET).''; + if (!empty($conf->global->MAIN_INFO_APE)) $dropdownBody .= '
    '.$langs->transcountry("ProfId3Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_APE).''; + if (!empty($conf->global->MAIN_INFO_RCS)) $dropdownBody .= '
    '.$langs->transcountry("ProfId4Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_RCS).''; + if (!empty($conf->global->MAIN_INFO_PROFID5)) $dropdownBody .= '
    '.$langs->transcountry("ProfId5Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID5).''; + if (!empty($conf->global->MAIN_INFO_PROFID6)) $dropdownBody .= '
    '.$langs->transcountry("ProfId6Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID6).''; + if (!empty($conf->global->MAIN_INFO_TVAINTRA)) $dropdownBody .= '
    '.$langs->trans("VATIntraShort").': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_TVAINTRA).''; $dropdownBody .= '
    '; @@ -2152,13 +2152,6 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $("#topmenu-login-dropdown").toggleClass("open"); }); - $(".copyToClipboard").on("click", function() { - var dummyContent = $(this).prevAll("span:first").text(); - var dummy = $("").val(dummyContent).appendTo("body").select(); - document.execCommand("copy"); - document.getElementById("dummy").remove(); - }); - $("#topmenulogincompanyinfo-btn").on("click", function() { $("#topmenulogincompanyinfo").slideToggle(); }); From 22f809c517a0ae12f60f1dfaff8f48330ee87614 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 27 Mar 2021 05:23:20 +0100 Subject: [PATCH 193/618] Move to _PERENTITY --- htdocs/accountancy/admin/productaccount.php | 10 +++++----- htdocs/accountancy/customer/card.php | 4 ++-- htdocs/accountancy/customer/index.php | 4 ++-- htdocs/accountancy/customer/lines.php | 4 ++-- htdocs/accountancy/customer/list.php | 10 +++++----- htdocs/accountancy/journal/sellsjournal.php | 4 ++-- htdocs/accountancy/supplier/list.php | 12 ++++++------ htdocs/compta/journal/sellsjournal.php | 4 ++-- htdocs/core/modules/modFacture.class.php | 4 ++-- htdocs/core/modules/modProduct.class.php | 6 +++--- htdocs/core/modules/modService.class.php | 4 ++-- ...tancy.key.sql => llx_product_perentity.key.sql} | 4 ++-- ...t_accountancy.sql => llx_product_perentity.sql} | 2 +- ...tancy.key.sql => llx_societe_perentity.key.sql} | 4 ++-- ...e_accountancy.sql => llx_societe_perentity.sql} | 2 +- htdocs/product/class/product.class.php | 14 +++++++------- htdocs/product/list.php | 8 ++++---- 17 files changed, 50 insertions(+), 50 deletions(-) rename htdocs/install/mysql/tables/{llx_product_accountancy.key.sql => llx_product_perentity.key.sql} (81%) rename htdocs/install/mysql/tables/{llx_product_accountancy.sql => llx_product_perentity.sql} (97%) rename htdocs/install/mysql/tables/{llx_societe_accountancy.key.sql => llx_societe_perentity.key.sql} (82%) rename htdocs/install/mysql/tables/{llx_societe_accountancy.sql => llx_societe_perentity.sql} (97%) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index be3347e1c9c..4f0085ceef6 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -188,7 +188,7 @@ if ($action == 'update') { } else { $db->begin(); - if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_accountancy (fk_product, entity, " . $accountancy_field_name . ")"; $sql .= " VALUES (" . ((int) $productid) . ", " . ((int) $conf->entity) . ", " . $accounting->account_number . ")"; $sql .= " ON DUPLICATE KEY UPDATE " . $accountancy_field_name . " = " . $accounting->account_number; @@ -269,7 +269,7 @@ if (empty($pcgvercode)) { } $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,"; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export,"; $sql .= " pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; } else { @@ -279,7 +279,7 @@ if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { $sql .= " p.tms, p.fk_product_type as product_type,"; $sql .= " aa.rowid as aaid"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = pa." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; } else { @@ -287,7 +287,7 @@ if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if (strlen(trim($search_current_account))) { - $sql .= natural_search((!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED) ? "pa." : "p.") . $accountancy_field_name, $search_current_account); + $sql .= natural_search((!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa." : "p.") . $accountancy_field_name, $search_current_account); } if ($search_current_account_valid == 'withoutvalidaccount') { $sql .= " AND aa.account_number IS NULL"; @@ -466,7 +466,7 @@ if ($result) { } else { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); } - print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], (empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED) ? "pa." : "p.") . $accountancy_field_name, "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa." : "p.") . $accountancy_field_name, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AssignDedicatedAccountingAccount"); $clickpitco = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center '); diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 20603a711b6..099cecc4a71 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -101,7 +101,7 @@ $formaccounting = new FormAccounting($db); if (!empty($id)) { $sql = "SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,"; $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,"; - if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " pa.accountancy_code_sell as code_sell,"; } else { $sql .= " p.accountancy_code_sell as code_sell,"; @@ -109,7 +109,7 @@ if (!empty($id)) { $sql .= " l.fk_code_ventilation, aa.account_number, aa.label"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; - if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 958630a2cc6..4b699281cfd 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -125,7 +125,7 @@ if ($action == 'validatehistory') { $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; - if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " pa.accountancy_code_sell as code_sell, pa.accountancy_code_sell_intra as code_sell_intra, pa.accountancy_code_sell_export as code_sell_export,"; } else { $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; @@ -148,7 +148,7 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $alias_company_accounting = !empty($conf->global->ACCOUNTANCY_COMPANY_SHARED) ? "sa" : "s"; - $alias_product_accounting = !empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED) ? "pa" : "p"; + $alias_product_accounting = !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_accounting . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_accounting . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_accounting . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 4a7ff6c0d81..42e4c268b86 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -183,7 +183,7 @@ $sql = "SELECT f.rowid as facid, f.ref as ref, f.type, f.datef, f.ref_client,"; $sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,"; $sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,"; $sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label,"; -if (empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " pa.accountancy_code_sell,"; } else { $sql .= " p.accountancy_code_sell,"; @@ -197,7 +197,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 82f2b3cf78a..07596350ef6 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -218,7 +218,7 @@ if (empty($chartaccountcode)) { $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; -if (empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " pa.accountancy_code_sell as code_sell, pa.accountancy_code_sell_intra as code_sell_intra, pa.accountancy_code_sell_export as code_sell_export,"; $sql .= " pa.accountancy_code_buy as code_buy, pa.accountancy_code_buy_intra as code_buy_intra, pa.accountancy_code_buy_export as code_buy_export,"; } else { @@ -229,7 +229,7 @@ $sql .= " p.tosell as status, p.tobuy as status_buy,"; $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " sa.accountancy_code_sell as company_code_sell"; } else { $sql .= " s.accountancy_code_sell as company_code_sell"; @@ -245,11 +245,11 @@ if (!empty($conf->global->ACCOUNTANCY_COMPANY_SHARED)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } -$alias_company_accounting = empty($conf->global->MAIN_COMPANY_ACCOUNTANCY_SHARED) ? "s" : "sa"; -$alias_product_accounting = empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED) ? "p" : "pa"; +$alias_company_accounting = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "sa"; +$alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_accounting . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_accounting . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_accounting . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 25ad7ec6116..8944fa958d9 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -109,13 +109,13 @@ $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_r $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " pa.accountancy_code_sell"; } else { $sql .= " p.accountancy_code_sell"; } $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 9acfeb1684d..13ad707af96 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -223,7 +223,7 @@ if (empty($chartaccountcode)) { $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " pa.accountancy_code_sell as code_sell, pa.accountancy_code_sell_intra as code_sell_intra, pa.accountancy_code_sell_export as code_sell_export,"; $sql .= " pa.accountancy_code_buy as code_buy, pa.accountancy_code_buy_intra as code_buy_intra, pa.accountancy_code_buy_export as code_buy_export,"; } else { @@ -234,7 +234,7 @@ $sql .= " p.tosell as status, p.tobuy as status_buy,"; $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; -if (!empty($conf->global->MAIN_COMPANY_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { $sql .= " sa.accountancy_code_buy as company_code_buy"; } else { $sql .= " s.accountancy_code_buy as company_code_buy"; @@ -244,16 +244,16 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; -if (!empty($conf->global->MAIN_COMPANY_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_accounting as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } -$alias_company_accounting = !empty($conf->global->MAIN_COMPANY_ACCOUNTANCY_SHARED) ? "sa" : "s"; -$alias_product_accounting = !empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED) ? "pa" : "p"; +$alias_company_accounting = !empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "sa" : "s"; +$alias_product_accounting = !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_accounting . ".accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_accounting . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_accounting . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 1ddbfa65731..e8b5a7e44b2 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -112,7 +112,7 @@ $sql = "SELECT f.rowid, f.ref, f.type, f.datef, f.ref_client,"; $sql .= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2, fd.rowid as id, fd.situation_percent,"; $sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.client,"; $sql .= " p.rowid as pid, p.ref as pref,"; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " pa.accountancy_code_sell,"; } else { $sql .= " p.accountancy_code_sell,"; @@ -120,7 +120,7 @@ if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { $sql .= " ct.accountancy_code_sell as account_tva, ct.recuperableonly"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 0acaf4bad1a..25653fb216a 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -207,7 +207,7 @@ class modFacture extends DolibarrModules //-------- $r = 1; - $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED) ? "pa" : "p"; + $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = 'CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r] = 'invoice'; @@ -295,7 +295,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'facturedet as fd'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet_extrafields as extra2 on fd.rowid = extra2.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; - if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 5ea4f7f6753..85cf49ebf73 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -176,7 +176,7 @@ class modProduct extends DolibarrModules //-------- $r = 0; - $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED) ? "pa" : "p"; + $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "Products"; // Translation key (used only if key ExportDataset_xxx_z not found) @@ -294,7 +294,7 @@ class modProduct extends DolibarrModules } $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; - if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { @@ -445,7 +445,7 @@ class modProduct extends DolibarrModules $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; - if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 5f0ae55dd5f..86ab42dfb5e 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -143,7 +143,7 @@ class modService extends DolibarrModules //-------- $r = 0; - $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED) ? "pa" : "p"; + $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "Services"; // Translation key (used only if key ExportDataset_xxx_z not found) @@ -257,7 +257,7 @@ class modService extends DolibarrModules } $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; - if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { diff --git a/htdocs/install/mysql/tables/llx_product_accountancy.key.sql b/htdocs/install/mysql/tables/llx_product_perentity.key.sql similarity index 81% rename from htdocs/install/mysql/tables/llx_product_accountancy.key.sql rename to htdocs/install/mysql/tables/llx_product_perentity.key.sql index 7f9bba54946..8e8ad48044c 100644 --- a/htdocs/install/mysql/tables/llx_product_accountancy.key.sql +++ b/htdocs/install/mysql/tables/llx_product_perentity.key.sql @@ -16,6 +16,6 @@ -- -- =================================================================== -ALTER TABLE llx_product_accountancy ADD INDEX idx_product_accountancy_fk_product (fk_product); +ALTER TABLE llx_product_perentity ADD INDEX idx_product_perentity_fk_product (fk_product); -ALTER TABLE llx_product_accountancy ADD UNIQUE INDEX uk_product_accountancy (fk_product, entity); +ALTER TABLE llx_product_perentity ADD UNIQUE INDEX uk_product_perentity (fk_product, entity); diff --git a/htdocs/install/mysql/tables/llx_product_accountancy.sql b/htdocs/install/mysql/tables/llx_product_perentity.sql similarity index 97% rename from htdocs/install/mysql/tables/llx_product_accountancy.sql rename to htdocs/install/mysql/tables/llx_product_perentity.sql index df00751e69d..6e32e506ddf 100644 --- a/htdocs/install/mysql/tables/llx_product_accountancy.sql +++ b/htdocs/install/mysql/tables/llx_product_perentity.sql @@ -16,7 +16,7 @@ -- -- ======================================================================== -create table llx_product_accountancy +create table llx_product_perentity ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_product integer, diff --git a/htdocs/install/mysql/tables/llx_societe_accountancy.key.sql b/htdocs/install/mysql/tables/llx_societe_perentity.key.sql similarity index 82% rename from htdocs/install/mysql/tables/llx_societe_accountancy.key.sql rename to htdocs/install/mysql/tables/llx_societe_perentity.key.sql index 7bf61fa9ca8..dd2970e16d2 100644 --- a/htdocs/install/mysql/tables/llx_societe_accountancy.key.sql +++ b/htdocs/install/mysql/tables/llx_societe_perentity.key.sql @@ -16,6 +16,6 @@ -- -- =================================================================== -ALTER TABLE llx_societe_accountancy ADD INDEX idx_societe_accountancy_fk_soc (fk_soc); +ALTER TABLE llx_societe_perentity ADD INDEX idx_societe_perentity_fk_soc (fk_soc); -ALTER TABLE llx_societe_accountancy ADD UNIQUE INDEX uk_societe_accountancy (fk_soc, entity); +ALTER TABLE llx_societe_perentity ADD UNIQUE INDEX uk_societe_perentity (fk_soc, entity); diff --git a/htdocs/install/mysql/tables/llx_societe_accountancy.sql b/htdocs/install/mysql/tables/llx_societe_perentity.sql similarity index 97% rename from htdocs/install/mysql/tables/llx_societe_accountancy.sql rename to htdocs/install/mysql/tables/llx_societe_perentity.sql index 0f099a59c1e..408169476d9 100644 --- a/htdocs/install/mysql/tables/llx_societe_accountancy.sql +++ b/htdocs/install/mysql/tables/llx_societe_perentity.sql @@ -16,7 +16,7 @@ -- -- ======================================================================== -create table llx_societe_accountancy +create table llx_societe_perentity ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_soc integer, diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 17f68476a35..77b73074b38 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -660,7 +660,7 @@ class Product extends CommonObject $sql .= ", price_base_type"; $sql .= ", tobuy"; $sql .= ", tosell"; - if (empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= ", accountancy_code_buy"; $sql .= ", accountancy_code_buy_intra"; $sql .= ", accountancy_code_buy_export"; @@ -687,7 +687,7 @@ class Product extends CommonObject $sql .= ", '".$this->db->escape($this->price_base_type)."'"; $sql .= ", ".$this->status; $sql .= ", ".$this->status_buy; - if (empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_buy_intra)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_buy_export)."'"; @@ -724,7 +724,7 @@ class Product extends CommonObject } // update accountancy for this entity - if (!$error && !empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_accounting ("; $sql .= " fk_product"; $sql .= ", entity"; @@ -1083,7 +1083,7 @@ class Product extends CommonObject $sql .= ", fk_state = ".($this->state_id > 0 ? (int) $this->state_id : 'null'); $sql .= ", note = ".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : 'null'); $sql .= ", duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."'"; - if (empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy) . "'"; $sql .= ", accountancy_code_buy_intra = '" . $this->db->escape($this->accountancy_code_buy_intra) . "'"; $sql .= ", accountancy_code_buy_export = '" . $this->db->escape($this->accountancy_code_buy_export) . "'"; @@ -1118,7 +1118,7 @@ class Product extends CommonObject $action = 'update'; // update accountancy for this entity - if (!$error && !empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "product_accounting WHERE fk_product = " . $this->id . " AND entity = " . $conf->entity); $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_accounting ("; @@ -2165,7 +2165,7 @@ class Product extends CommonObject $sql .= " p.tobuy, p.fk_product_type, p.duration, p.fk_default_warehouse, p.seuil_stock_alerte, p.canvas, p.net_measure, p.net_measure_units, p.weight, p.weight_units,"; $sql .= " p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,"; $sql .= " p.surface, p.surface_units, p.volume, p.volume_units, p.barcode, p.fk_barcode_type, p.finished,"; - if (empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; } else { $sql .= " pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export, pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export,"; @@ -2173,7 +2173,7 @@ class Product extends CommonObject $sql .= " p.stock,p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.fk_unit,"; $sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf"; $sql .= " FROM ".MAIN_DB_PREFIX."product"; - if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } if ($id) { diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 64ab0b592b7..8ce99e96b9b 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -191,7 +191,7 @@ if (empty($conf->global->PRODUIT_MULTIPRICES)) { $isInEEC = isInEEC($mysoc); -$alias_product_accounting = empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED) ? "p" : "pa"; +$alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; // Definition of fields for lists $arrayfields = array( @@ -361,7 +361,7 @@ if ($search_type != '' && $search_type != '-1') { $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type, p.entity,'; $sql .= ' p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; $sql .= ' p.tobatch,'; -if (empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; } else { $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export, pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; @@ -386,7 +386,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; -if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { @@ -520,7 +520,7 @@ $sql .= $hookmanager->resPrint; $sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type,"; $sql .= " p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; $sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.pmp, p.cost_price, p.stock,'; -if (empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_SHARED)) { +if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; } else { $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export, pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; From 1382323f77bc8642d6665ee61b33c4036bf87942 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 27 Mar 2021 06:56:34 +0100 Subject: [PATCH 194/618] FIX Start hour on ACCOUNTING_DATE_START_BINDING --- htdocs/accountancy/admin/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 64ebf2d1ab0..2febe354f2e 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -84,7 +84,7 @@ if ($action == 'update') { $constvalue = GETPOST($constname, 'alpha'); if ($constname == 'ACCOUNTING_DATE_START_BINDING') { - $constvalue = dol_mktime(12, 0, 0, GETPOST($constname.'month', 'int'), GETPOST($constname.'day', 'int'), GETPOST($constname.'year', 'int')); + $constvalue = dol_mktime(0, 0, 0, GETPOST($constname.'month', 'int'), GETPOST($constname.'day', 'int'), GETPOST($constname.'year', 'int')); } if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { From 56ae51375ddc12d1d94431423ca0e1bc2e700d72 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 27 Mar 2021 07:11:28 +0100 Subject: [PATCH 195/618] FIX Search on date in accountancy --- htdocs/accountancy/bookkeeping/list.php | 8 ++++---- htdocs/accountancy/bookkeeping/listbyaccount.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 7ada77d0bd6..28a3ac4e11c 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -42,14 +42,14 @@ $search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_doc_type = GETPOST("search_doc_type", 'alpha'); $search_doc_ref = GETPOST("search_doc_ref", 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); -$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $search_date_creation_start = dol_mktime(0, 0, 0, GETPOST('date_creation_startmonth', 'int'), GETPOST('date_creation_startday', 'int'), GETPOST('date_creation_startyear', 'int')); -$search_date_creation_end = dol_mktime(0, 0, 0, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int')); +$search_date_creation_end = dol_mktime(23, 59, 59, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int')); $search_date_modification_start = dol_mktime(0, 0, 0, GETPOST('date_modification_startmonth', 'int'), GETPOST('date_modification_startday', 'int'), GETPOST('date_modification_startyear', 'int')); -$search_date_modification_end = dol_mktime(0, 0, 0, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int')); +$search_date_modification_end = dol_mktime(23, 59, 59, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int')); $search_date_export_start = dol_mktime(0, 0, 0, GETPOST('date_export_startmonth', 'int'), GETPOST('date_export_startday', 'int'), GETPOST('date_export_startyear', 'int')); -$search_date_export_end = dol_mktime(0, 0, 0, GETPOST('date_export_endmonth', 'int'), GETPOST('date_export_endday', 'int'), GETPOST('date_export_endyear', 'int')); +$search_date_export_end = dol_mktime(23, 59, 59, GETPOST('date_export_endmonth', 'int'), GETPOST('date_export_endday', 'int'), GETPOST('date_export_endyear', 'int')); //var_dump($search_date_start);exit; if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index bacfdcb714a..18f6a5b8f16 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -42,7 +42,7 @@ $sortorder = GETPOST("sortorder"); $sortfield = GETPOST("sortfield"); $action = GETPOST('action', 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); -$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $search_accountancy_code = GETPOST("search_accountancy_code"); From 3c70a3d06c92ae5695df0150eccff25c60099591 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 27 Mar 2021 07:25:31 +0100 Subject: [PATCH 196/618] Move to _PERENTITY --- htdocs/accountancy/admin/productaccount.php | 2 +- htdocs/accountancy/customer/index.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 4f0085ceef6..c1541bd2214 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -189,7 +189,7 @@ if ($action == 'update') { $db->begin(); if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_accountancy (fk_product, entity, " . $accountancy_field_name . ")"; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity (fk_product, entity, " . $accountancy_field_name . ")"; $sql .= " VALUES (" . ((int) $productid) . ", " . ((int) $conf->entity) . ", " . $accounting->account_number . ")"; $sql .= " ON DUPLICATE KEY UPDATE " . $accountancy_field_name . " = " . $accounting->account_number; } else { diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 4b699281cfd..88a32340daa 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -144,8 +144,8 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; - if (!empty($conf->global->MAIN_PRODUCT_ACCOUNTANCY_NOT_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $alias_company_accounting = !empty($conf->global->ACCOUNTANCY_COMPANY_SHARED) ? "sa" : "s"; $alias_product_accounting = !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; From 992a4c7c2133bf5d89e7ca0c60e9fa1ec0297569 Mon Sep 17 00:00:00 2001 From: asolslk <52134143+asolslk@users.noreply.github.com> Date: Sat, 27 Mar 2021 16:05:42 +0800 Subject: [PATCH 197/618] Update contact.php fix for issue #16985 --- htdocs/supplier_proposal/contact.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index d106ce0506f..f21845b0a91 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -58,7 +58,9 @@ if ($action == 'addcontact' && $permissiontoedit) { if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, GETPOST("type"), GETPOST("source")); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source")); + } if ($result >= 0) { From 20ae94b84be4990215ed4d974fca43454562c7c9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 27 Mar 2021 08:08:26 +0000 Subject: [PATCH 198/618] Fixing style errors. --- htdocs/supplier_proposal/contact.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index f21845b0a91..8a4f80eda99 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -60,7 +60,6 @@ if ($action == 'addcontact' && $permissiontoedit) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source")); - } if ($result >= 0) { From 50de0777e4513a0c3f82bbd95dffd6ae29f93658 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Mar 2021 12:45:57 +0100 Subject: [PATCH 199/618] Look and feel v14 --- htdocs/contact/list.php | 32 ++++++++++++++++++-------------- htdocs/societe/list.php | 9 ++++++--- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 3890155f116..4535c0514e9 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -704,25 +704,29 @@ $moreforfilter = ''; if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('Categories').': '; - $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ, 'search_categ', 1); + $tmptitle = $langs->trans('ContactCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); + $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ, 'search_categ', 1, $tmptitle); $moreforfilter .= '
    '; if (empty($type) || $type == 'c' || $type == 'p') { $moreforfilter .= '
    '; + $tmptitle = ''; if ($type == 'c') { - $moreforfilter .= $langs->trans('CustomersCategoriesShort').': '; + $tmptitle .= $langs->trans('CustomersCategoriesShort'); } elseif ($type == 'p') { - $moreforfilter .= $langs->trans('ProspectsCategoriesShort').': '; + $tmptitle .= $langs->trans('ProspectsCategoriesShort'); } else { - $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $tmptitle .= $langs->trans('CustomersProspectsCategoriesShort'); } - $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty, 'search_categ_thirdparty', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); + $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty, 'search_categ_thirdparty', 1, $tmptitle); $moreforfilter .= '
    '; } if (empty($type) || $type == 'f') { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': '; - $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1); + $tmptitle = $langs->trans('SuppliersCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); + $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1, $tmptitle); $moreforfilter .= '
    '; } } @@ -1092,35 +1096,35 @@ while ($i < min($num, $limit)) { } // Phone if (!empty($arrayfields['p.phone']['checked'])) { - print ''.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''; + print ''.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''; if (!$i) { $totalarray['nbfield']++; } } // Phone perso if (!empty($arrayfields['p.phone_perso']['checked'])) { - print ''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''; + print ''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''; if (!$i) { $totalarray['nbfield']++; } } // Phone mobile if (!empty($arrayfields['p.phone_mobile']['checked'])) { - print ''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''; + print ''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''; if (!$i) { $totalarray['nbfield']++; } } // Fax if (!empty($arrayfields['p.fax']['checked'])) { - print ''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''; + print ''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''; if (!$i) { $totalarray['nbfield']++; } } // EMail if (!empty($arrayfields['p.email']['checked'])) { - print ''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''; + print ''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''; if (!$i) { $totalarray['nbfield']++; } @@ -1144,7 +1148,7 @@ while ($i < min($num, $limit)) { } // Company if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) { - print ''; + print ''; if ($obj->socid) { $objsoc = new Societe($db); $objsoc->fetch($obj->socid); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 47ef99490cb..74a04f34858 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -941,7 +941,8 @@ if (empty($type) || $type == 'c' || $type == 'p') { if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= img_picto('', 'category', 'class="pictofixedwidth"'); + $tmptitle = $langs->trans('Categories'); + $moreforfilter .= img_picto($tmptile, 'category', 'class="pictofixedwidth"'); $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort')); $moreforfilter .= '
    '; } @@ -950,7 +951,8 @@ if (empty($type) || $type == 'f') { if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= img_picto('', 'category', 'class="pictofixedwidth"'); + $tmptitle = $langs->trans('Categories'); + $moreforfilter .= img_picto($tmptilte, 'category', 'class="pictofixedwidth"'); $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $langs->trans('SuppliersCategoriesShort')); $moreforfilter .= '
    '; } @@ -959,7 +961,8 @@ if (empty($type) || $type == 'f') { // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $moreforfilter .= '
    '; - $moreforfilter .= img_picto('', 'user', 'class="pictofixedwidth"'); + $tmptile = $langs->trans('SalesRepresentatives'); + $moreforfilter .= img_picto($tmptile, 'user', 'class="pictofixedwidth"'); $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $langs->trans('SalesRepresentatives'), ($conf->dol_optimize_smallscreen ? 'maxwidth200' : 'maxwidth300'), 1); $moreforfilter .= '
    '; } From c8a455edf4887618b8d38619014a132909ef9c0a Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 27 Mar 2021 13:14:59 +0100 Subject: [PATCH 200/618] add excluded memer on graph --- htdocs/core/boxes/box_members_by_type.php | 38 ++++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 79610a3e988..c975cb5e230 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -93,12 +93,14 @@ class box_members_by_type extends ModeleBoxes $MembersToValidate = array(); $MembersValidated = array(); $MemberUpToDate = array(); + $MembersExcluded = array(); $MembersResiliated = array(); - $SommeA = 0; - $SommeB = 0; - $SommeC = 0; - $SommeD = 0; + $SumToValidate = 0; + $SumValidated = 0; + $SumUpToDate = 0; + $SumResiliated = 0; + $SumExcluded = 0; $AdherentType = array(); @@ -132,6 +134,9 @@ class box_members_by_type extends ModeleBoxes if ($objp->statut == 1) { $MembersValidated[$objp->rowid] = $objp->somme; } + if ($objp->statut == -2) { + $MembersExcluded[$objp->rowid] = $objp->somme; + } if ($objp->statut == 0) { $MembersResiliated[$objp->rowid] = $objp->somme; } @@ -181,16 +186,23 @@ class box_members_by_type extends ModeleBoxes 'td' => 'class="right"', 'text' => $langs->trans("UpToDate"), ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("MembersStatusExcluded"), + ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', 'text' => $langs->trans("MembersStatusResiliated"), ); $line++; foreach ($AdherentType as $key => $adhtype) { - $SommeA += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0; - $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; - $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; - $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + + $SumToValidate += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0; + $SumValidated += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0; + $SumUpToDate += isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0; + $SumExcluded += isset($MembersExcluded[$key]) ? $MembersExcluded [$key] : 0; + $SumResiliated += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $adhtype->getNomUrl(1, dol_size(32)), @@ -211,6 +223,11 @@ class box_members_by_type extends ModeleBoxes 'text' => (isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(1, 1, $now, 3), 'asis' => 1, ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($MembersExcluded[$key]) && $MembersExcluded[$key] > 0 ? $MembersExcluded[$key] : '') . ' ' . $staticmember->LibStatut(-2, 1, $now, 3), + 'asis' => 1, + ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', 'text' => (isset($MembersResiliated[$key]) && $MembersResiliated[$key] > 0 ? $MembersResiliated[$key] : '') . ' ' . $staticmember->LibStatut(0, 1, 0, 3), @@ -245,6 +262,11 @@ class box_members_by_type extends ModeleBoxes 'text' => $SommeC.' '.$staticmember->LibStatut(1, 1, $now, 3), 'asis' => 1 ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SommeD.' '.$staticmember->LibStatut(-2, 1, 0, 3), + 'asis' => 1 + ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', 'text' => $SommeD.' '.$staticmember->LibStatut(0, 1, 0, 3), From 1d48b883a7152bb1fbca10cb993703e603b8df32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Mar 2021 13:17:56 +0100 Subject: [PATCH 201/618] Look and feel v14 --- htdocs/core/class/html.form.class.php | 11 +++++++++-- htdocs/expedition/list.php | 24 +++++++++++++++--------- htdocs/product/list.php | 16 ++++++++-------- htdocs/product/stock/list.php | 16 +++++++++------- 4 files changed, 41 insertions(+), 26 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 21c886cb2fa..6139ad2b2fc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1831,7 +1831,7 @@ class Form * * @param string $selected User id or user object of user preselected. If 0 or < -2, we use id of current user. If -1, keep unselected (if empty is allowed) * @param string $htmlname Field name in form - * @param int $show_empty 0=list with no empty value, 1=add also an empty value into list + * @param int|string $show_empty 0=list with no empty value, 1=add also an empty value into list * @param array $exclude Array list of users id to exclude * @param int $disabled If select list must be disabled * @param array|string $include Array list of users id to include. User '' for all users or 'hierarchy' to have only supervised users or 'hierarchyme' to have supervised + me @@ -1949,7 +1949,14 @@ class Form // do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined $out .= ''; + print ''; print ''; // Entity @@ -252,7 +264,7 @@ if (($id || $ref) && $action == 'edit') { $head = establishment_prepare_head($object); if ($action == 'edit') { - print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), 0, 'building'); + print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), 0, $object->picto); print '
    '."\n"; print ''; @@ -335,7 +347,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $res = $object->fetch_optionals(); $head = establishment_prepare_head($object); - print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), -1, 'building'); + print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), -1, $object->picto); // Confirmation to delete if ($action == 'delete') { diff --git a/htdocs/hrm/establishment/info.php b/htdocs/hrm/establishment/info.php index f72b381a2d8..cff38ac7f42 100644 --- a/htdocs/hrm/establishment/info.php +++ b/htdocs/hrm/establishment/info.php @@ -76,12 +76,18 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id; } +$permissiontoadd = $user->rights->hrm->write; // Used by the include of actions_addupdatedelete.inc.php +$upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1]; + // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $object->id); -$permissiontoadd = $user->rights->hrm->write; // Used by the include of actions_addupdatedelete.inc.php +// Security check +if (!$user->admin) { + accessforbidden(); +} /* @@ -128,7 +134,7 @@ if ($object->id > 0) { $head = establishment_prepare_head($object); - print dol_get_fiche_head($head, 'info', $langs->trans("Establishment"), -1, 'building'); + print dol_get_fiche_head($head, 'info', $langs->trans("Establishment"), -1, $object->picto); // Object card // ------------------------------------------------------------ diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 76131c70719..fe4cd496df0 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -132,7 +132,7 @@ $upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object- // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); +//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); //restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft); //if (empty($conf->mymodule->enabled)) accessforbidden(); //if (empty($permissiontoread)) accessforbidden(); From d5bab315e3c83dbe6fe26aaec223ce292d37542c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Mar 2021 15:03:18 +0100 Subject: [PATCH 208/618] FIX #yogosha5738 --- htdocs/hrm/admin/admin_establishment.php | 15 ++++++++++----- htdocs/hrm/admin/admin_hrm.php | 13 ++++++++++--- htdocs/hrm/establishment/card.php | 12 ++++-------- htdocs/hrm/establishment/info.php | 11 +++++------ htdocs/hrm/index.html | 0 5 files changed, 29 insertions(+), 22 deletions(-) delete mode 100644 htdocs/hrm/index.html diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 11e965dc1d3..2772137284b 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -27,13 +27,18 @@ require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'hrm')); +$error = 0; + +$permissiontoread = $user->admin; $permissiontoadd = $user->admin; -if (!$user->admin) { - accessforbidden(); -} - -$error = 0; +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +//restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', 0); +if (empty($conf->hrm->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); /* diff --git a/htdocs/hrm/admin/admin_hrm.php b/htdocs/hrm/admin/admin_hrm.php index 09cccfed3db..d19b15e3499 100644 --- a/htdocs/hrm/admin/admin_hrm.php +++ b/htdocs/hrm/admin/admin_hrm.php @@ -34,9 +34,16 @@ $list = array( // 'HRM_EMAIL_EXTERNAL_SERVICE' // To prevent your public accountant for example ); -if (!$user->admin) { - accessforbidden(); -} +$permissiontoread = $user->admin; +$permissiontoadd = $user->admin; + +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +//restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', 0); +if (empty($conf->hrm->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); /* diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index b2f477b48e5..caec6191d0d 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -51,7 +51,8 @@ $object = new Establishment($db); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -$permissiontoadd = $user->rights->hrm->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = $user->admin; +$permissiontoadd = $user->admin; // Used by the include of actions_addupdatedelete.inc.php $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check - Protection if external user @@ -59,13 +60,8 @@ $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->enti //if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); //restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', 0); -//if (empty($conf->mymodule->enabled)) accessforbidden(); -//if (empty($permissiontoread)) accessforbidden(); - -// Security check -if (!$user->admin) { - accessforbidden(); -} +if (empty($conf->hrm->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); /* diff --git a/htdocs/hrm/establishment/info.php b/htdocs/hrm/establishment/info.php index cff38ac7f42..517b76de93a 100644 --- a/htdocs/hrm/establishment/info.php +++ b/htdocs/hrm/establishment/info.php @@ -76,18 +76,17 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id; } +$permissiontoread = $user->admin; $permissiontoadd = $user->rights->hrm->write; // Used by the include of actions_addupdatedelete.inc.php $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$result = restrictedArea($user, 'mymodule', $object->id); - -// Security check -if (!$user->admin) { - accessforbidden(); -} +//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +//restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft); +if (empty($conf->hrm->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); /* diff --git a/htdocs/hrm/index.html b/htdocs/hrm/index.html deleted file mode 100644 index e69de29bb2d..00000000000 From a2c2d46e5c4ca4ea561f05b0374bdc9bfe58bbcd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Mar 2021 15:22:48 +0100 Subject: [PATCH 209/618] Fix loosing html content in edit --- htdocs/externalsite/admin/index.php | 9 +++++++-- htdocs/langs/en_US/externalsite.lang | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/externalsite/admin/index.php b/htdocs/externalsite/admin/index.php index 1710a570c45..a9a41c5e555 100644 --- a/htdocs/externalsite/admin/index.php +++ b/htdocs/externalsite/admin/index.php @@ -58,7 +58,7 @@ if ($action == 'update') { $exturl = GETPOST('EXTERNALSITE_URL', 'none'); $exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1); - $exturl = dol_string_onlythesehtmlattributes($exturl); + $exturl = trim(dol_string_onlythesehtmlattributes($exturl)); $i += dolibarr_set_const($db, 'EXTERNALSITE_LABEL', trim($label), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'EXTERNALSITE_URL', trim($exturl), 'chaine', 0, '', $conf->entity); @@ -108,7 +108,12 @@ print ""; print ''; print ''.$langs->trans("ExternalSiteURL").""; print ''; print "http://localhost/myurl/"; print "
    https://wikipedia.org/"; diff --git a/htdocs/langs/en_US/externalsite.lang b/htdocs/langs/en_US/externalsite.lang index da4853df0df..452100c65b3 100644 --- a/htdocs/langs/en_US/externalsite.lang +++ b/htdocs/langs/en_US/externalsite.lang @@ -1,5 +1,5 @@ # Dolibarr language file - Source file is en_US - externalsite ExternalSiteSetup=Setup link to external website -ExternalSiteURL=External Site URL +ExternalSiteURL=External Site URL of HTML iframe content ExternalSiteModuleNotComplete=Module ExternalSite was not configured properly. ExampleMyMenuEntry=My menu entry From 4c90e931083c41b99a8e95905884d8ed57e0c564 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Mar 2021 15:49:18 +0100 Subject: [PATCH 210/618] Fix permissions --- htdocs/reception/card.php | 46 ++++++++++++++++---------------- htdocs/reception/contact.php | 24 ++++++++++++----- htdocs/reception/index.php | 10 ++++++- htdocs/reception/list.php | 14 +++++----- htdocs/reception/note.php | 34 ++++++++++++----------- htdocs/reception/stats/index.php | 14 +++++----- htdocs/reception/stats/month.php | 6 +++++ 7 files changed, 88 insertions(+), 60 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index bbfccb3b945..9392844adf2 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -86,25 +86,6 @@ if (empty($origin_id)) { $ref = GETPOST('ref', 'alpha'); $line_id = GETPOST('lineid', 'int') ?GETPOST('lineid', 'int') : ''; -// Security check -$socid = ''; -if ($user->socid) { - $socid = $user->socid; -} - -if ($origin == 'reception') { - $result = restrictedArea($user, $origin, $id); -} else { - $result = restrictedArea($user, 'reception'); - if ($origin == 'supplierorder') { - if (empty($user->rights->fournisseur->commande->lire) && empty($user->rights->fournisseur->commande->read)) { - accessforbidden(); - } - } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { - accessforbidden(); - } -} - $action = GETPOST('action', 'alpha'); //Select mail models is same action as presend if (GETPOST('modelselected')) { @@ -136,6 +117,25 @@ $permissiondellink = $user->rights->reception->creer; // Used by the include of $date_delivery = dol_mktime(GETPOST('date_deliveryhour', 'int'), GETPOST('date_deliverymin', 'int'), 0, GETPOST('date_deliverymonth', 'int'), GETPOST('date_deliveryday', 'int'), GETPOST('date_deliveryyear', 'int')); +// Security check +$socid = ''; +if ($user->socid) { + $socid = $user->socid; +} + +if ($origin == 'reception') { + $result = restrictedArea($user, $origin, $id); +} else { + $result = restrictedArea($user, 'reception'); + if ($origin == 'supplierorder') { + if (empty($user->rights->fournisseur->commande->lire) && empty($user->rights->fournisseur->commande->read)) { + accessforbidden(); + } + } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { + accessforbidden(); + } +} + /* * Actions @@ -784,7 +784,7 @@ if ($action == 'create') { print ''; print ''.$langs->trans("Project").''; $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - print '   id).'">'.$langs->trans("AddProject").''; + print '   id).'">'; print ''; print ''; } @@ -1122,12 +1122,12 @@ if ($action == 'create') { if (!empty($product->status_batch)) { print ''; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print ''; + print ''; print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc'.$indiceAsked, '', '', 1, ""); print ''; } if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print ''; + print ''; print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo'.$indiceAsked, '', '', 1, ""); print ''; } @@ -1798,7 +1798,7 @@ if ($action == 'create') { print ''.$formproduct->selectWarehouses($lines[$i]->fk_entrepot, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).''; // Batch number managment if ($conf->productbatch->enabled && !empty($lines[$i]->product->status_batch)) { - print '
    '; + print '
    '; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { print $langs->trans('EatByDate').' : '; print $form->selectDate($lines[$i]->eatby, 'dlc'.$line_id, '', '', 1, "").'
    '; diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index f814bbbf64a..f925388f0b6 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -43,12 +43,6 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'reception', $id, ''); - $object = new Reception($db); if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); @@ -69,6 +63,24 @@ if ($id > 0 || !empty($ref)) { } +// Security check +if ($user->socid > 0) { + $socid = $user->socid; +} +if ($origin == 'reception') { + $result = restrictedArea($user, $origin, $object->id); +} else { + $result = restrictedArea($user, 'reception'); + if ($origin == 'supplierorder') { + if (empty($user->rights->fournisseur->commande->lire) && empty($user->rights->fournisseur->commande->read)) { + accessforbidden(); + } + } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { + accessforbidden(); + } +} + + /* * Actions */ diff --git a/htdocs/reception/index.php b/htdocs/reception/index.php index 3aa6b8af754..a54eea592c0 100644 --- a/htdocs/reception/index.php +++ b/htdocs/reception/index.php @@ -36,13 +36,21 @@ $hookmanager->initHooks(array('receptionindex')); $langs->loadLangs(array("orders", "receptions")); +$reception = new Reception($db); + +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'reception', 0, ''); + + /* * View */ $orderstatic = new CommandeFournisseur($db); $companystatic = new Societe($db); -$reception = new Reception($db); $helpurl = 'EN:Module_Receptions|FR:Module_Receptions|ES:Módulo_Receptiones'; llxHeader('', $langs->trans("Reception"), $helpurl); diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index b77742dd71d..bdc65fb301b 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -40,13 +40,6 @@ $socid = GETPOST('socid', 'int'); $massaction = GETPOST('massaction', 'alpha'); $toselect = GETPOST('toselect', 'array'); -// Security check -$receptionid = GETPOST('id', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'reception', $receptionid, ''); - $diroutputmassaction = $conf->reception->dir_output.'/temp/massgeneration/'.$user->id; $search_ref_rcp = GETPOST("search_ref_rcp"); @@ -129,6 +122,13 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); $error = 0; +// Security check +$receptionid = GETPOST('id', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'reception', $receptionid, ''); + /* * Actions diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index b1588a07b14..a3a2b31589c 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -33,26 +33,12 @@ if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -$langs->load("receptions"); -$langs->load("companies"); -$langs->load("bills"); -$langs->load('deliveries'); -$langs->load('orders'); -$langs->load('stocks'); -$langs->load('other'); -$langs->load('propal'); +$langs->loadLangs(array("receptions", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal')); $id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -// Security check -$socid = ''; -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, $origin, $origin_id); - $object = new Reception($db); if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); @@ -77,6 +63,24 @@ if ($id > 0 || !empty($ref)) { $permissionnote = $user->rights->reception->creer; // Used by the include of actions_setnotes.inc.php +// Security check +if ($user->socid > 0) { + $socid = $user->socid; +} +if ($origin == 'reception') { + $result = restrictedArea($user, $origin, $object->id); +} else { + $result = restrictedArea($user, 'reception'); + if ($origin == 'supplierorder') { + if (empty($user->rights->fournisseur->commande->lire) && empty($user->rights->fournisseur->commande->read)) { + accessforbidden(); + } + } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { + accessforbidden(); + } +} + + /* * Actions diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 0b118c5d733..1fe3397ef66 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -34,11 +34,6 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); -// Security check -if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; -} $nowyear = strftime("%Y", dol_now()); $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; @@ -46,10 +41,13 @@ $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; $startyear = $year - 1; $endyear = $year; -$langs->load("reception"); -$langs->load("other"); -$langs->load("companies"); +$langs->loadLangs(array("reception", "other", "companies")); +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'reception', 0, ''); /* diff --git a/htdocs/reception/stats/month.php b/htdocs/reception/stats/month.php index 25c6b16e116..806006394df 100644 --- a/htdocs/reception/stats/month.php +++ b/htdocs/reception/stats/month.php @@ -29,6 +29,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $year = GETPOST("year", 'int'); +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'reception', 0, ''); + /* * View From e0551f1e32202e418771d7f548ac8889ebe4a1ee Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 27 Mar 2021 17:29:06 +0100 Subject: [PATCH 211/618] Add ADHERENT_DEFAULT_CREATE_THIRDPARTY --- htdocs/adherents/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index b75bce38ca9..1d007bf654b 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -207,7 +207,7 @@ if (empty($reshook)) { } // Create third party from a member - if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { + if (($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) || (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY))) { if ($result > 0) { // User creation $company = new Societe($db); From 8f29ff0c66a4d01226e34514e6655d9937671e89 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Mar 2021 17:42:38 +0200 Subject: [PATCH 212/618] css --- htdocs/theme/eldy/global.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index ad25301dac1..213c9652991 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -210,7 +210,10 @@ input, select { #mainbody input.buttongen, #mainbody button.buttongen { padding: 3px 4px; } - +input.button:hover { + -webkit-box-shadow: 0px 0px 6px 1px rgb(50 50 50 / 40%), 0px 0px 0px rgb(60 60 60 / 10%); + box-shadow: 0px 0px 6px 1px rgb(50 50 50 / 40%), 0px 0px 0px rgb(60 60 60 / 10%); +} input.button:focus { border-bottom: 0; } From 6fdff2c3abe71c0273195d077464920ff3c2d2b8 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sun, 28 Mar 2021 19:19:40 +0200 Subject: [PATCH 213/618] autoaffect individual status for thirdparty --- htdocs/adherents/card.php | 43 +++++++++++++++++++++----- htdocs/societe/class/societe.class.php | 15 ++++++--- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 1d007bf654b..a934f9ca607 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -207,7 +207,7 @@ if (empty($reshook)) { } // Create third party from a member - if (($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) || (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY))) { + if (($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer)) { if ($result > 0) { // User creation $company = new Societe($db); @@ -550,7 +550,7 @@ if (empty($reshook)) { $db->commit(); $rowid = $object->id; $id = $object->id; - $action = ''; + } else { $db->rollback(); @@ -559,12 +559,41 @@ if (empty($reshook)) { } else { setEventMessages($object->error, $object->errors, 'errors'); } - - $action = 'create'; } - } else { - $action = 'create'; - } + // Auto-create thirdparty on member creation + if (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY)) { + if ($result > 0) { + // User creation + $company = new Societe($db); + + $companyalias = ''; + $fullname = $object->getFullName($langs); + + if ($object->morphy == 'mor') { + $companyname = $object->company; + if (!empty($fullname)) { + $companyalias = $fullname; + } + } else { + $companyname = $fullname; + if (!empty($object->company)) { + $companyalias = $object->company; + } + } + + $result = $company->create_from_member($object, $companyname, $companyalias); + + if ($result < 0) { + $langs->load("errors"); + setEventMessages($langs->trans($company->error), null, 'errors'); + setEventMessages($company->error, $company->errors, 'errors'); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + $action = ($result < 0 || !$error) ? '' : 'create'; } if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c141290d9e9..7fb7d51377d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -868,6 +868,7 @@ class Societe extends CommonObject $sql .= ", name_alias"; $sql .= ", entity"; $sql .= ", datec"; + $sql .= ", fk_typent"; $sql .= ", fk_user_creat"; $sql .= ", canvas"; $sql .= ", status"; @@ -882,6 +883,7 @@ class Societe extends CommonObject $sql .= ", accountancy_code_sell"; $sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; $sql .= ", ".(!empty($user->id) ? ((int) $user->id) : "null"); + $sql .= ", ".(!empty($this->typent_id) ? ((int) $this->typent_id) : "null"); $sql .= ", ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null"); $sql .= ", ".$this->status; $sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); @@ -958,7 +960,7 @@ class Societe extends CommonObject * @param array $tags Array of tag to affect to contact * @return int <0 if KO, >0 if OK */ - public function create_individual(User $user, $no_email, $tags = array()) + public function create_individual(User $user, $no_email = 0, $tags = array()) { global $conf; @@ -3793,21 +3795,24 @@ class Societe extends CommonObject $this->client = 1; // A member is a customer by default $this->code_client = ($customercode ? $customercode : -1); $this->code_fournisseur = -1; - + $this->typent_id = ($member->morphy == 'phy' ? 8 : 0); // The type of thirdparty is private (individual) if the member is human (phy) + $this->db->begin(); - + // Cree et positionne $this->id $result = $this->create($user); + if ($result >= 0) { // Auto-create contact on thirdparty creation - if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT)) { + if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT)) { // Fill fields needed by contact - $this->name_bis = $member->lastname; + $this->name_bis = $member->lastname; $this->firstname = $member->firstname; $this->civility_id = $member->civility_id; dol_syslog("We ask to create a contact/address too", LOG_DEBUG); $result = $this->create_individual($user); + if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); $this->db->rollback(); From a5d84200dc194fc1acb35d72df992b0364056175 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Mar 2021 19:15:59 +0200 Subject: [PATCH 214/618] Clean code for invoice list --- htdocs/compta/facture/class/facture.class.php | 56 ++++++------ .../compta/facture/invoicetemplate_list.php | 38 ++++---- htdocs/compta/facture/list.php | 88 +++++++++++-------- htdocs/core/class/html.form.class.php | 16 +++- 4 files changed, 112 insertions(+), 86 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c3544ba214e..e3079f227f1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -283,44 +283,42 @@ class Facture extends CommonInvoice * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>15), + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>1), + 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>5), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), - 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>25), - 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>0, 'position'=>30), // deprecated - 'type' =>array('type'=>'smallint(6)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), - 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'Ref client', 'enabled'=>1, 'visible'=>-1, 'position'=>40), + 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'Ref client', 'enabled'=>1, 'visible'=>-1, 'position'=>10), + 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>12), + //'ref_int' =>array('type'=>'varchar(255)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>0, 'position'=>30), // deprecated + 'type' =>array('type'=>'smallint(6)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), //'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'=>'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), + 'datef' =>array('type'=>'date', 'label'=>'DateInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>20), + 'date_valid' =>array('type'=>'date', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>22), + 'date_lim_reglement' =>array('type'=>'date', 'label'=>'DateDue', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'date_closing' =>array('type'=>'datetime', 'label'=>'Date closing', 'enabled'=>1, 'visible'=>-1, 'position'=>30), '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'=>'RelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>90), - 'remise_absolue' =>array('type'=>'double', 'label'=>'CustomerRelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>95), + 'remise_absolue' =>array('type'=>'double', 'label'=>'CustomerRelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>91), //'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>100), - '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'=>'LT1', 'enabled'=>1, 'visible'=>-1, 'position'=>120, 'isameasure'=>1), - 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LT2', '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'=>'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_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'=>'UserClosing', 'enabled'=>1, 'visible'=>-1, 'position'=>165), + 'close_code' =>array('type'=>'varchar(16)', 'label'=>'EarlyClosingReason', 'enabled'=>1, 'visible'=>-1, 'position'=>92), + 'close_note' =>array('type'=>'varchar(128)', 'label'=>'EarlyClosingComment', 'enabled'=>1, 'visible'=>-1, 'position'=>93), + 'total' =>array('type'=>'double(24,8)', 'label'=>'AmountHT', 'enabled'=>1, 'visible'=>-1, 'position'=>95, 'isameasure'=>1), + 'tva' =>array('type'=>'double(24,8)', 'label'=>'AmountVAT', 'enabled'=>1, 'visible'=>-1, 'position'=>100, 'isameasure'=>1), + 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LT1', 'enabled'=>1, 'visible'=>-1, 'position'=>110, 'isameasure'=>1), + 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LT2', 'enabled'=>1, 'visible'=>-1, 'position'=>120, 'isameasure'=>1), + 'revenuestamp' =>array('type'=>'double(24,8)', 'label'=>'RevenueStamp', 'enabled'=>1, 'visible'=>-1, 'position'=>115, 'isameasure'=>1), + 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'AmountTTC', 'enabled'=>1, 'visible'=>1, 'position'=>130, 'isameasure'=>1), + 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'position'=>165), + 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>166), + 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>167), + 'fk_user_closing' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserClosing', 'enabled'=>1, 'visible'=>-1, 'position'=>168), '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'=>'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), @@ -335,8 +333,8 @@ class Facture extends CommonInvoice 'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'IncotermLabel', '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'=>'MulticurrencyCurrency', '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, 'isameasure'=>1), + 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'Currency', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>280), + 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'CurrencyRate', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>285, 'isameasure'=>1), 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountHT', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>290, 'isameasure'=>1), 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountVAT', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>295, 'isameasure'=>1), 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountTTC', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>300, 'isameasure'=>1), @@ -344,8 +342,10 @@ class Facture extends CommonInvoice 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>-1, 'position'=>310), '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), - 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Paid', 3=>'Abandonned')), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModificationShort', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900), + 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Paid', 3=>'Abandonned')), ); // END MODULEBUILDER PROPERTIES diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 5d511aa6cd6..a0a2e6d5e84 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -125,22 +125,22 @@ $permissiondellink = $user->rights->facture->creer; // Used by the include of ac $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php $arrayfields = array( - 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), - 'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), - 'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1), - 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), - 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>0), - 'f.fk_cond_reglement'=>array('label'=>$langs->trans("PaymentTerm"), 'checked'=>0), - 'recurring'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1), - 'f.frequency'=>array('label'=>$langs->trans("Frequency"), 'checked'=>1), - 'f.unit_frequency'=>array('label'=>$langs->trans("FrequencyUnit"), 'checked'=>1), - 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDoneShort"), 'checked'=>1), - 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGenerationShort"), 'checked'=>1), - 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecutionShort"), 'checked'=>1), - 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100), - 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'f.titre'=>array('label'=>"Ref", 'checked'=>1), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), + 'f.total'=>array('label'=>"AmountHT", 'checked'=>1), + 'f.tva'=>array('label'=>"AmountVAT", 'checked'=>1), + 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>1), + 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>0), + 'f.fk_cond_reglement'=>array('label'=>"PaymentTerm", 'checked'=>0), + 'recurring'=>array('label'=>"RecurringInvoiceTemplate", 'checked'=>1), + 'f.frequency'=>array('label'=>"Frequency", 'checked'=>1), + 'f.unit_frequency'=>array('label'=>"FrequencyUnit", 'checked'=>1), + 'f.nb_gen_done'=>array('label'=>"NbOfGenerationDoneShort", 'checked'=>1), + 'f.date_last_gen'=>array('label'=>"DateLastGenerationShort", 'checked'=>1), + 'f.date_when'=>array('label'=>"NextDateToExecutionShort", 'checked'=>1), + 'status'=>array('label'=>"Status", 'checked'=>1, 'position'=>100), + 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), + 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -655,7 +655,7 @@ if ($resql) { } } if (!empty($arrayfields['f.total']['checked'])) { - print ''.price($objp->total).''."\n"; + print ''.price($objp->total).''."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -665,7 +665,7 @@ if ($resql) { $totalarray['val']['f.total'] += $objp->total; } if (!empty($arrayfields['f.tva']['checked'])) { - print ''.price($objp->total_vat).''."\n"; + print ''.price($objp->total_vat).''."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -675,7 +675,7 @@ if ($resql) { $totalarray['val']['f.tva'] += $objp->total_vat; } if (!empty($arrayfields['f.total_ttc']['checked'])) { - print ''.price($objp->total_ttc).''."\n"; + print ''.price($objp->total_ttc).''."\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 6cf770cb79c..a3c5fb08133 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -189,33 +189,33 @@ $arrayfields = array( 'f.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), 'f.ref_client'=>array('label'=>"RefCustomer", 'checked'=>-1, 'position'=>10), 'f.type'=>array('label'=>"Type", 'checked'=>0, 'position'=>15), - 'f.date'=>array('label'=>"DateInvoice", 'checked'=>1, 'position'=>20), + 'f.datef'=>array('label'=>"DateInvoice", 'checked'=>1, 'position'=>20), 'f.date_valid'=>array('label'=>"DateValidation", 'checked'=>0, 'position'=>22), 'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1, 'position'=>25), 'f.date_closing'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>30), 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>40), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>40), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>41), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>50), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>51), - 's.town'=>array('label'=>"Town", 'checked'=>1, 'position'=>55), + 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>55), 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>60), 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>65), 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>70), 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>75), 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>80), 'f.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>1, 'position'=>85), - 'f.module_source'=>array('label'=>"Module", 'checked'=>($contextpage == 'poslist' ? 1 : 0), 'enabled'=>((empty($conf->cashdesk->enabled) && empty($conf->takepos->enabled) && empty($conf->global->INVOICE_SHOW_POS)) ? 0 : 1), 'position'=>90), - 'f.pos_source'=>array('label'=>"Terminal", 'checked'=>($contextpage == 'poslist' ? 1 : 0), 'enabled'=>((empty($conf->cashdesk->enabled) && empty($conf->takepos->enabled) && empty($conf->global->INVOICE_SHOW_POS)) ? 0 : 1), 'position'=>91), + 'f.module_source'=>array('label'=>"POSModule", 'checked'=>($contextpage == 'poslist' ? 1 : 0), 'enabled'=>((empty($conf->cashdesk->enabled) && empty($conf->takepos->enabled) && empty($conf->global->INVOICE_SHOW_POS)) ? 0 : 1), 'position'=>90), + 'f.pos_source'=>array('label'=>"POSTerminal", 'checked'=>($contextpage == 'poslist' ? 1 : 0), 'enabled'=>((empty($conf->cashdesk->enabled) && empty($conf->takepos->enabled) && empty($conf->global->INVOICE_SHOW_POS)) ? 0 : 1), 'position'=>91), 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>95), 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>100), 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj == "1"), 'position'=>110), 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj == "1"), 'position'=>120), 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>130), - 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>135), 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0, 'position'=>140), 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow - 'f.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>160), - 'f.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>170), + 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>165), + 'f.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>170), + 'f.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>171), 'f.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>180), 'f.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>190), 'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>200), @@ -235,7 +235,24 @@ $arrayfields = array( if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { $arrayfields['f.retained_warranty'] = array('label'=>$langs->trans("RetainedWarranty"), 'checked'=>0, 'position'=>86); } - +// Overwrite $arrayfields from columns into ->fields (transition before removal of $arrayoffields) +foreach ($object->fields as $key => $val) { + // If $val['visible']==0, then we never show the field + if (!empty($val['visible'])) { + $visible = (int) dol_eval($val['visible'], 1); + $newkey = ''; + if (array_key_exists($key, $arrayfields)) { $newkey = $key; } elseif (array_key_exists('t.'.$key, $arrayfields)) { $newkey = 't.'.$key; } elseif (array_key_exists('f.'.$key, $arrayfields)) { $newkey = 'f.'.$key; } elseif (array_key_exists('s.'.$key, $arrayfields)) { $newkey = 's.'.$key; } + if ($newkey) { + $arrayfields[$newkey] = array( + 'label'=>$val['label'], + 'checked'=>(($visible < 0) ? 0 : 1), + 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)), + 'position'=>$val['position'], + 'help'=>$val['help'] + ); + } + } +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -434,7 +451,7 @@ $sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_pub $sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql .= ' f.fk_user_author,'; $sql .= ' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva as multicurrency_total_vat, f.multicurrency_total_ttc,'; -$sql .= ' f.datef as df, f.date_valid, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,'; +$sql .= ' f.datef, f.date_valid, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,'; $sql .= ' f.paye as paye, f.fk_statut, f.close_code,'; $sql .= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; @@ -942,31 +959,31 @@ if ($resql) { if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $tmptitle = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
    '; } if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle); $moreforfilter .= '
    '; } $parameters = array(); @@ -985,6 +1002,7 @@ if ($resql) { $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + // Show the massaction checkboxes only when this page is not opend from the Extended POS if ($massactionbutton && $contextpage != 'poslist') { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); @@ -1028,7 +1046,7 @@ if ($resql) { print ''; } // Date invoice - if (!empty($arrayfields['f.date']['checked'])) { + if (!empty($arrayfields['f.datef']['checked'])) { print ''; print '
    '; print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -1291,7 +1309,7 @@ if ($resql) { if (!empty($arrayfields['f.type']['checked'])) { print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['f.date']['checked'])) { + if (!empty($arrayfields['f.datef']['checked'])) { print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); } if (!empty($arrayfields['f.date_valid']['checked'])) { @@ -1456,7 +1474,7 @@ if ($resql) { $facturestatic->paye = $obj->paye; $facturestatic->fk_soc = $obj->fk_soc; - $facturestatic->date = $db->jdate($obj->df); + $facturestatic->date = $db->jdate($obj->datef); $facturestatic->date_valid = $db->jdate($obj->date_valid); $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); @@ -1576,9 +1594,9 @@ if ($resql) { } // Date - if (!empty($arrayfields['f.date']['checked'])) { + if (!empty($arrayfields['f.datef']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->df), 'day'); + print dol_print_date($db->jdate($obj->datef), 'day'); print ''; if (!$i) { $totalarray['nbfield']++; @@ -1755,7 +1773,7 @@ if ($resql) { // Amount HT if (!empty($arrayfields['f.total_ht']['checked'])) { - print ''.price($obj->total_ht)."\n"; + print ''.price($obj->total_ht)."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1766,7 +1784,7 @@ if ($resql) { } // Amount VAT if (!empty($arrayfields['f.total_vat']['checked'])) { - print ''.price($obj->total_vat)."\n"; + print ''.price($obj->total_vat)."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1777,7 +1795,7 @@ if ($resql) { } // Amount LocalTax1 if (!empty($arrayfields['f.total_localtax1']['checked'])) { - print ''.price($obj->total_localtax1)."\n"; + print ''.price($obj->total_localtax1)."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1788,7 +1806,7 @@ if ($resql) { } // Amount LocalTax2 if (!empty($arrayfields['f.total_localtax2']['checked'])) { - print ''.price($obj->total_localtax2)."\n"; + print ''.price($obj->total_localtax2)."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1799,7 +1817,7 @@ if ($resql) { } // Amount TTC if (!empty($arrayfields['f.total_ttc']['checked'])) { - print ''.price($obj->total_ttc)."\n"; + print ''.price($obj->total_ttc)."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1826,11 +1844,11 @@ if ($resql) { } if (!empty($arrayfields['f.retained_warranty']['checked'])) { - print ''.(!empty($obj->retained_warranty) ?price($obj->retained_warranty).'%' : ' ').''; + print ''.(!empty($obj->retained_warranty) ?price($obj->retained_warranty).'%' : ' ').''; } if (!empty($arrayfields['dynamount_payed']['checked'])) { - print ''.(!empty($totalpay) ?price($totalpay, 0, $langs) : ' ').''; // TODO Use a denormalized field + print ''.(!empty($totalpay) ?price($totalpay, 0, $langs) : ' ').''; // TODO Use a denormalized field if (!$i) { $totalarray['nbfield']++; } @@ -1842,7 +1860,7 @@ if ($resql) { // Pending amount if (!empty($arrayfields['rtp']['checked'])) { - print ''; + print ''; print (!empty($remaintopay) ? price($remaintopay, 0, $langs) : ' '); print ''; // TODO Use a denormalized field if (!$i) { @@ -1874,27 +1892,27 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { - print ''.price($obj->multicurrency_total_ht)."\n"; + print ''.price($obj->multicurrency_total_ht)."\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount VAT if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { - print ''.price($obj->multicurrency_total_vat)."\n"; + print ''.price($obj->multicurrency_total_vat)."\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount TTC if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { - print ''.price($obj->multicurrency_total_ttc)."\n"; + print ''.price($obj->multicurrency_total_ttc)."\n"; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { - print ''.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : ' ').''; // TODO Use a denormalized field + print ''.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : ' ').''; // TODO Use a denormalized field if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6139ad2b2fc..f12aed42aca 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7341,7 +7341,7 @@ class Form /** - * Show a multiselect dropbox from an array. + * Show a multiselect dropbox from an array. If a saved selection of fields exists for user (into $user->conf->MAIN_SELECTEDFIELDS_contextofpage), we use this one instead of default. * * @param string $htmlname Name of HTML field * @param array $array Array with array of fields we could show. This array may be modified according to setup of user. @@ -7357,8 +7357,9 @@ class Form return ''; } - $tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved seleteced properties - if (!empty($user->conf->$tmpvar)) { + $tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved selected fields to show + + if (!empty($user->conf->$tmpvar)) { // A list of fields was already customized for user $tmparray = explode(',', $user->conf->$tmpvar); foreach ($array as $key => $val) { //var_dump($key); @@ -7369,6 +7370,12 @@ class Form $array[$key]['checked'] = 0; } } + } else { // There is no list of fields already customized for user + foreach ($array as $key => $val) { + if ($array[$key]['checked'] < 0) { + $array[$key]['checked'] = 0; + } + } } $lis = ''; @@ -7387,7 +7394,8 @@ class Form $langs->load($val['langfile']); } - $lis .= '
  • '; + // Note: $val['checked'] <> 0 means we must show the field into the combo list + $lis .= '
  • '; $listcheckedstring .= (empty($val['checked']) ? '' : $key.','); } } From 1ae0e2a920072cd9ffd4fc64dde90c6173c250aa Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sun, 28 Mar 2021 19:38:20 +0200 Subject: [PATCH 215/618] fix stafix style errorsle fix stale errorfix style errors --- htdocs/adherents/card.php | 3 +-- htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index a934f9ca607..d8931602557 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -549,8 +549,7 @@ if (empty($reshook)) { $db->commit(); $rowid = $object->id; - $id = $object->id; - + $id = $object->id; } else { $db->rollback(); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7fb7d51377d..dd73cb6e16c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3798,7 +3798,7 @@ class Societe extends CommonObject $this->typent_id = ($member->morphy == 'phy' ? 8 : 0); // The type of thirdparty is private (individual) if the member is human (phy) $this->db->begin(); - + // Cree et positionne $this->id $result = $this->create($user); From b7045ef3a031c76f40759d71eb0493290c0e4578 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 28 Mar 2021 17:42:18 +0000 Subject: [PATCH 216/618] Fixing style errors. --- htdocs/adherents/card.php | 62 +++++++++++++------------- htdocs/societe/class/societe.class.php | 10 ++--- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index d8931602557..12f0c2050ee 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -549,7 +549,7 @@ if (empty($reshook)) { $db->commit(); $rowid = $object->id; - $id = $object->id; + $id = $object->id; } else { $db->rollback(); @@ -561,37 +561,37 @@ if (empty($reshook)) { } // Auto-create thirdparty on member creation if (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY)) { - if ($result > 0) { - // User creation - $company = new Societe($db); - - $companyalias = ''; - $fullname = $object->getFullName($langs); - - if ($object->morphy == 'mor') { - $companyname = $object->company; - if (!empty($fullname)) { - $companyalias = $fullname; - } - } else { - $companyname = $fullname; - if (!empty($object->company)) { - $companyalias = $object->company; - } - } - - $result = $company->create_from_member($object, $companyname, $companyalias); - - if ($result < 0) { - $langs->load("errors"); - setEventMessages($langs->trans($company->error), null, 'errors'); - setEventMessages($company->error, $company->errors, 'errors'); - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result > 0) { + // User creation + $company = new Societe($db); + + $companyalias = ''; + $fullname = $object->getFullName($langs); + + if ($object->morphy == 'mor') { + $companyname = $object->company; + if (!empty($fullname)) { + $companyalias = $fullname; + } + } else { + $companyname = $fullname; + if (!empty($object->company)) { + $companyalias = $object->company; + } + } + + $result = $company->create_from_member($object, $companyname, $companyalias); + + if ($result < 0) { + $langs->load("errors"); + setEventMessages($langs->trans($company->error), null, 'errors'); + setEventMessages($company->error, $company->errors, 'errors'); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } } - } + } $action = ($result < 0 || !$error) ? '' : 'create'; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index dd73cb6e16c..d23c2cdf06c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3796,23 +3796,23 @@ class Societe extends CommonObject $this->code_client = ($customercode ? $customercode : -1); $this->code_fournisseur = -1; $this->typent_id = ($member->morphy == 'phy' ? 8 : 0); // The type of thirdparty is private (individual) if the member is human (phy) - + $this->db->begin(); // Cree et positionne $this->id $result = $this->create($user); - + if ($result >= 0) { // Auto-create contact on thirdparty creation - if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT)) { + if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT)) { // Fill fields needed by contact - $this->name_bis = $member->lastname; + $this->name_bis = $member->lastname; $this->firstname = $member->firstname; $this->civility_id = $member->civility_id; dol_syslog("We ask to create a contact/address too", LOG_DEBUG); $result = $this->create_individual($user); - + if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); $this->db->rollback(); From 2a431d495127b7f942047f32b0530481537d3dbd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Mar 2021 21:39:18 +0200 Subject: [PATCH 217/618] Protect backtourl from using external urls --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 812c14792cf..403aa59e66a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -634,8 +634,8 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null $out = checkVal($out, $check, $filter, $options); } - // Sanitizing for special parameters. There is no reason to allow the backtopage parameter to contains an external URL. - if ($paramname == 'backtopage' || $paramname == 'backtolist') { + // Sanitizing for special parameters. There is no reason to allow the backtopage, backtolist or backtourl parameter to contains an external URL. + if ($paramname == 'backtopage' || $paramname == 'backtolist' || $paramname == 'backtourl') { $out = str_replace('\\', '/', $out); $out = str_replace(array(':', ';', '@'), '', $out); From d9733b395e1aa90b6c76adbd651701cd0029e8d3 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sun, 28 Mar 2021 22:30:47 +0200 Subject: [PATCH 218/618] Copyright in adherents/card.php --- htdocs/adherents/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 12f0c2050ee..4267a801df5 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -7,6 +7,7 @@ * Copyright (C) 2012-2020 Philippe Grand * Copyright (C) 2015-2018 Alexandre Spangaro * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2021 Waël Almoman * * 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 @@ -207,7 +208,7 @@ if (empty($reshook)) { } // Create third party from a member - if (($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer)) { + if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { if ($result > 0) { // User creation $company = new Societe($db); From 8b1d4a60245b4012baa01204cf5bd654a3a78759 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sun, 28 Mar 2021 22:40:41 +0200 Subject: [PATCH 219/618] Copyright adherents/index.php --- htdocs/adherents/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 517649c4b61..1d899324b33 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 39933f97be659d3e8793c190e8116071f9236518 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sun, 28 Mar 2021 22:46:19 +0200 Subject: [PATCH 220/618] Copyright adherent.class.php --- htdocs/adherents/class/adherent.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0315b90df9d..34fce36b4c6 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -13,6 +13,7 @@ * Copyright (C) 2018-2019 Thibault FOUCART * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Josep Lluís Amador + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 28ff0f2bc3b54f86fd2f231168ac8def943686a0 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sun, 28 Mar 2021 22:50:27 +0200 Subject: [PATCH 221/618] Copyright adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index b4347277b5d..e8ccb57504e 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2019 Thibault Foucart + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From b6d03dcad08b373896cfe3f1c7741ad0fdfabc11 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 29 Mar 2021 03:27:02 +0200 Subject: [PATCH 222/618] Update copyright --- htdocs/adherents/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 4267a801df5..7a17937e051 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -7,7 +7,7 @@ * Copyright (C) 2012-2020 Philippe Grand * Copyright (C) 2015-2018 Alexandre Spangaro * Copyright (C) 2018-2020 Frédéric France - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From c700767b549938445b69ab80db6683083a957572 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 29 Mar 2021 03:28:32 +0200 Subject: [PATCH 223/618] Update copyright --- htdocs/adherents/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 1d899324b33..dd6f2473102 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2021 Frédéric France - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From f83cf3a17b6aea7a4bae974700cad78b97480add Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 29 Mar 2021 03:29:21 +0200 Subject: [PATCH 224/618] Update copyright --- htdocs/adherents/class/adherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 34fce36b4c6..a80818981c2 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -13,7 +13,7 @@ * Copyright (C) 2018-2019 Thibault FOUCART * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Josep Lluís Amador - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From ae94ce594ec4bf6b1e9f6e867a483e3e23538116 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 29 Mar 2021 03:30:44 +0200 Subject: [PATCH 225/618] Update copyright --- htdocs/adherents/class/adherent_type.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index e8ccb57504e..460cefdeed3 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2019 Thibault Foucart - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 8a43d6547650b4d066c5b94cb4f780b3c2f14626 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 29 Mar 2021 07:49:15 +0200 Subject: [PATCH 226/618] Copyright box_members_by_type.php --- htdocs/core/boxes/box_members_by_type.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 1819c7f47c5..5bc05b6fabd 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015-2020 Frederic France + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From ad6f5e5a64d4128cde169a61deeab3a30e482dbc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Mar 2021 10:26:17 +0200 Subject: [PATCH 227/618] Fix permission export of services --- htdocs/core/modules/modService.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 13ff4618483..cd646dc8364 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -277,7 +277,7 @@ class modService extends DolibarrModules $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r] = array(array("produit", "export")); + $this->export_permission[$r] = array(array("service", "export")); $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 'pr.price_base_type'=>"PriceBase", 'pr.price_level'=>"PriceLevel", 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", @@ -311,7 +311,7 @@ class modService extends DolibarrModules $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r] = array(array("produit", "export")); + $this->export_permission[$r] = array(array("service", "export")); $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 's.nom'=>'ThirdParty', 'pr.price_base_type'=>"PriceBase", @@ -344,7 +344,7 @@ class modService extends DolibarrModules $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r] = array(array("produit", "export")); + $this->export_permission[$r] = array(array("service", "export")); $this->export_fields_array[$r] = array( 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", From 85f6a15678ac3649e7bdaa4fdfa126fbdd13599f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Mar 2021 11:58:51 +0200 Subject: [PATCH 228/618] Fix position of users in combo list --- htdocs/commande/list.php | 20 ++++++++++---------- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/class/html.formother.class.php | 7 ++++++- htdocs/fourn/facture/list.php | 16 ++++++++-------- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 0b850e6b0e8..df79a9edffd 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -806,39 +806,39 @@ if ($resql) { if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view other users if ($user->rights->user->user->lire) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $tmptitle = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
    '; } if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle); $moreforfilter .= '
    '; } if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('Warehouse').': '; - $moreforfilter .= $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1); + $tmptitle = $langs->trans('Warehouse'); + $moreforfilter .= img_picto($tmptitle, 'warehouse', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', $tmptitle); $moreforfilter .= '
    '; } $parameters = array(); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f12aed42aca..628c6a2ff04 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1931,9 +1931,9 @@ class Form } if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname - $sql .= " ORDER BY u.firstname ASC"; + $sql .= " ORDER BY u.statut DESC, u.firstname ASC, u.lastname ASC"; } else { - $sql .= " ORDER BY u.lastname ASC"; + $sql .= " ORDER BY u.statut DESC, u.lastname ASC, u.firstname ASC"; } dol_syslog(get_class($this)."::select_dolusers", LOG_DEBUG); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 78212ca3580..533328599c8 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -481,7 +481,12 @@ class FormOther $sql_usr .= $hookmanager->resArray[1]; } } - $sql_usr .= " ORDER BY statut DESC, lastname ASC"; // Do not use 'ORDER BY u.statut' here, not compatible with the UNION. + + if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname + $sql_usr .= " ORDER BY statut DESC, firstname ASC, lastname ASC"; // Do not use 'ORDER BY u.statut' here, not compatible with the UNION. + } else { + $sql_usr .= " ORDER BY statut DESC, lastname ASC, firstname ASC"; // Do not use 'ORDER BY u.statut' here, not compatible with the UNION. + } //print $sql_usr;exit; $resql_usr = $this->db->query($sql_usr); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 50fdfef6e47..3efc19f86cc 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -934,32 +934,32 @@ if ($resql) { if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'company', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $tmptitle = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
    '; } if (!empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': '; - $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1); + $tmptitle = $langs->trans('SuppliersCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $tmptitle); $moreforfilter .= '
    '; } $parameters = array(); From 2970f1a96890aed3cd378bdaa744dcf1fc69b23e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 29 Mar 2021 12:07:47 +0200 Subject: [PATCH 229/618] retreive missing fileds... --- .../conferenceorbooth_list.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 96c67e09c0b..baa3ba6e69e 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -388,6 +388,39 @@ if ($projectid > 0) { print ""; } + print ''; + $typeofdata = 'checkbox:'.($project->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + $typeofdata = 'checkbox:'.($project->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''.$langs->trans("EventOrganizationICSLink").''; + print ''; + print ""; + + print ''; print '
    '; From b929641fe15a352f87be46ed7f5fe2ebec7b7505 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Mar 2021 13:00:17 +0200 Subject: [PATCH 230/618] Look and feel v14 --- htdocs/comm/propal/list.php | 16 +++--- htdocs/compta/bank/bankentries_list.php | 4 +- htdocs/compta/bank/budget.php | 4 +- htdocs/compta/bank/releve.php | 4 +- htdocs/compta/bank/various_payment/list.php | 4 +- htdocs/compta/cashcontrol/report.php | 2 +- htdocs/compta/charges/index.php | 10 ++-- htdocs/compta/deplacement/stats/index.php | 8 ++- htdocs/compta/facture/card.php | 30 +++++----- htdocs/compta/facture/index.php | 6 +- htdocs/compta/facture/stats/index.php | 4 +- htdocs/compta/index.php | 30 +++++----- htdocs/compta/localtax/list.php | 2 +- htdocs/compta/localtax/quadri_detail.php | 16 +++--- htdocs/compta/paiement.php | 8 +-- htdocs/compta/paiement/card.php | 6 +- htdocs/compta/paiement/cheque/card.php | 4 +- htdocs/compta/paiement/cheque/index.php | 2 +- htdocs/compta/paiement/cheque/list.php | 2 +- htdocs/compta/paiement/list.php | 2 +- htdocs/compta/paiement/tovalidate.php | 2 +- htdocs/compta/paiement_charge.php | 6 +- htdocs/compta/paiement_vat.php | 6 +- htdocs/compta/payment_sc/card.php | 4 +- htdocs/compta/payment_vat/card.php | 4 +- htdocs/compta/paymentbybanktransfer/index.php | 4 +- htdocs/compta/prelevement/card.php | 2 +- htdocs/compta/prelevement/create.php | 2 +- htdocs/compta/prelevement/factures.php | 4 +- htdocs/compta/prelevement/fiche-rejet.php | 4 +- htdocs/compta/prelevement/index.php | 2 +- htdocs/compta/prelevement/line.php | 2 +- htdocs/compta/prelevement/list.php | 2 +- htdocs/compta/prelevement/orders_list.php | 2 +- htdocs/compta/recap-compta.php | 2 +- htdocs/compta/resultat/clientfourn.php | 56 +++++++++---------- htdocs/compta/resultat/result.php | 16 +++--- htdocs/compta/sociales/card.php | 2 +- htdocs/compta/sociales/payments.php | 2 +- htdocs/compta/tva/card.php | 2 +- htdocs/compta/tva/clients.php | 8 +-- htdocs/compta/tva/payments.php | 2 +- htdocs/compta/tva/quadri_detail.php | 12 ++-- htdocs/contrat/list.php | 12 ++-- htdocs/core/class/html.formcategory.class.php | 6 +- htdocs/don/list.php | 2 +- htdocs/fourn/commande/list.php | 12 ++-- htdocs/langs/en_US/bills.lang | 2 + htdocs/loan/list.php | 2 +- htdocs/margin/agentMargins.php | 8 +-- htdocs/margin/checkMargins.php | 26 +++++---- htdocs/margin/customerMargins.php | 6 +- htdocs/margin/productMargins.php | 6 +- htdocs/projet/list.php | 26 ++++----- htdocs/projet/tasks/list.php | 16 +++--- htdocs/salaries/list.php | 2 +- htdocs/supplier_proposal/list.php | 12 ++-- 57 files changed, 231 insertions(+), 219 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 453abff36b2..f5ac2ebae7a 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -843,31 +843,31 @@ if ($resql) { if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view products if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $tmptitle = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
    '; } if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle); $moreforfilter .= '
    '; } $parameters = array(); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 22121fa7664..fc017a9707b 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1717,9 +1717,9 @@ if ($resql) { print ''.$langs->trans("Totalforthispage").''; } } elseif ($totalarray['totaldebfield'] == $i) { - print ''.price(-1 * $totalarray['totaldeb']).''; + print ''.price(-1 * $totalarray['totaldeb']).''; } elseif ($totalarray['totalcredfield'] == $i) { - print ''.price($totalarray['totalcred']).''; + print ''.price($totalarray['totalcred']).''; } elseif ($i == $posconciliatecol) { print ''; if ($user->rights->banque->consolidate && $action == 'reconcile') { diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php index d3ffbb37916..3e40e45b58e 100644 --- a/htdocs/compta/bank/budget.php +++ b/htdocs/compta/bank/budget.php @@ -82,8 +82,8 @@ if ($result) { print ''; print "rowid\">$objp->label"; print ''.$objp->nombre.''; - print ''.price(abs($objp->somme)).""; - print ''.price(abs(price2num($objp->somme / $objp->nombre, 'MT'))).""; + print ''.price(abs($objp->somme)).""; + print ''.price(abs(price2num($objp->somme / $objp->nombre, 'MT'))).""; print ""; $i++; $total += abs($objp->somme); diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index be91d475d4d..dc71a1d2d27 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -346,7 +346,7 @@ if (empty($numref)) { $balancestart[$objp->numr] = $obj->amount; $db->free($resql); } - print ''.price($balancestart[$objp->numr], '', $langs, 1, -1, -1, $conf->currency).''; + print ''.price($balancestart[$objp->numr], '', $langs, 1, -1, -1, $conf->currency).''; // Calculate end amount $sql = "SELECT sum(b.amount) as amount"; @@ -359,7 +359,7 @@ if (empty($numref)) { $content[$objp->numr] = $obj->amount; $db->free($resql); } - print ''.price(($balancestart[$objp->numr] + $content[$objp->numr]), '', $langs, 1, -1, -1, $conf->currency).''; + print ''.price(($balancestart[$objp->numr] + $content[$objp->numr]), '', $langs, 1, -1, -1, $conf->currency).''; print ''; if ($user->rights->banque->consolidate && $action != 'editbankreceipt') { diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 65542598351..dcc1f4aef97 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -671,7 +671,7 @@ if ($result) { if ($arrayfields['debit']['checked']) { print ''; if ($obj->sens == 0) { - print price($obj->amount); + print ''.price($obj->amount).''; $totalarray['val']['total_deb'] += $obj->amount; } if (!$i) { @@ -687,7 +687,7 @@ if ($result) { if ($arrayfields['credit']['checked']) { print ''; if ($obj->sens == 1) { - print price($obj->amount); + print ''.price($obj->amount).''; $totalarray['val']['total_cred'] += $obj->amount; } if (!$i) { diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 95c18dbf261..ee13f5540a1 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -204,7 +204,7 @@ if ($resql) { { print ''; print ''.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; - print ''.price($cashcontrol->opening).''; + print ''.price($cashcontrol->opening).''; print ''; $first = "no"; }*/ diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index b238e47c50e..d3604b0d7cc 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -206,7 +206,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { // Type print ''.$obj->label.''; // Expected to pay - print ''.price($obj->total).''; + print ''.price($obj->total).''; // Ref payment $payment_sc_static->id = $obj->pid; $payment_sc_static->ref = $obj->pid; @@ -323,7 +323,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $tva_static->ref = $obj->label; print "".$tva_static->getNomUrl(1)."\n"; - print ''.price($obj->amount_tva).""; + print ''.price($obj->amount_tva).""; // Ref payment $ptva_static->id = $obj->rowid; @@ -359,7 +359,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { } // Paid - print ''.price($obj->amount).""; + print ''.price($obj->amount).""; print "\n"; $i++; @@ -442,7 +442,7 @@ while ($j < $numlt) { print "".$obj->label."\n"; - print ''.price($obj->amount).""; + print ''.price($obj->amount).""; // Ref payment $ptva_static->id = $obj->rowid; @@ -450,7 +450,7 @@ while ($j < $numlt) { print ''.$ptva_static->getNomUrl(1)."\n"; print ''.dol_print_date($db->jdate($obj->dp), 'day')."\n"; - print ''.price($obj->amount).""; + print ''.price($obj->amount).""; print "\n"; $i++; diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 892b2b86dff..673cd7c1972 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -268,7 +268,7 @@ print '

    '; print '
    '; print ''; -print ''; +print ''; print ''; print ''; print ''; @@ -280,14 +280,16 @@ foreach ($data as $val) { $year = $val['year']; while ($year && $oldyear > $year + 1) { // If we have empty year $oldyear--; - print ''; + print ''; print ''; print ''; print ''; print ''; print ''; } - print ''; + + // Total + print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index fd8a9c1045d..35f4a3cb140 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4733,8 +4733,8 @@ if ($action == 'create') { if (!empty($conf->banque->enabled)) { print ''; } - print ''; - print ''; + print ''; + print ''; print ''; print ''; } @@ -4753,8 +4753,8 @@ if ($action == 'create') { if (!empty($conf->banque->enabled)) { print ''; } - print ''; - print ''; + print ''; + print ''; print ''; print ''; @@ -4808,8 +4808,8 @@ if ($action == 'create') { if (!empty($conf->banque->enabled)) { print ''; } - print ''; - print ''; + print ''; + print ''; print ''; print ''; } @@ -4914,7 +4914,7 @@ if ($action == 'create') { } print ''; } - print ''; + print ''; print ''; - print ''; + print ''; print ''; @@ -4994,7 +4994,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("Discount"), $langs->trans("HelpEscompte"), - 1); print ''; - print ''; + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -5014,7 +5014,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("ProductReturned"), $langs->trans("HelpAbandonProductReturned"), - 1); print ''; - print ''; + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -5028,7 +5028,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1); print ''; - print ''; + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -5037,7 +5037,7 @@ if ($action == 'create') { print ''; + print ''; // Remainder to pay print ''; - print ''; + print ''; print ''; // Retained warranty : usualy use on construction industry @@ -5076,10 +5076,10 @@ if ($action == 'create') { // Total already paid back print ''; + print ' :'; // Billed - print ''; + print ''; // Remainder to pay back print ''; $result .= ''; $result .= ''; - $result .= ''; + $result .= ''; $result .= ''; $i++; @@ -299,7 +299,7 @@ function getDraftTable($maxCount = 500, $socid = 0) } elseif ($total > 0) { $result .= ''; $result .= ''; - $result .= ''; + $result .= ''; $result .= ''; } @@ -508,7 +508,7 @@ function getOpenTable($maxCount = 500, $socid = 0) $result .= ''; $result .= ''; - $result .= ''; + $result .= ''; $result .= ''; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 96c414db350..9fcfff783b3 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -384,9 +384,9 @@ foreach ($data as $val) { print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; $oldyear = $year; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 9c3544b512e..a24bce0e0e2 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -351,7 +351,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; - print ''; + print ''; print ''; $tot_ttc += $obj->total_ttc; $i++; @@ -620,7 +620,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print $thirdpartystatic->getNomUrl(1, 'supplier'); print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { - print ''; + print ''; } print ''; print ''; @@ -951,7 +951,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user print $societestatic->getNomUrl(1, 'customer'); print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { - print ''; + print ''; } print ''; print ''; @@ -974,10 +974,10 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { - print ''; + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; print ''; print '
    '.$langs->trans("Year").''.$langs->trans("Number").''.$langs->trans("AmountTotal").'
    '.$oldyear.'000
    '.$year.''.$val['nb'].''.price(price2num($val['total'], 'MT'), 1).''.price($prev_invoice->total_ht).''.price($prev_invoice->total_ttc).''.price($prev_invoice->total_ht).''.price($prev_invoice->total_ttc).''.$prev_invoice->getLibStatut(3, $tmptotalpaidforthisinvoice).'
    '.price($object->total_ht).''.price($object->total_ttc).''.price($object->total_ht).''.price($object->total_ttc).''.$object->getLibStatut(3, $object->getSommePaiement()).'
    '.price($next_invoice->total_ht).''.price($next_invoice->total_ttc).''.price($next_invoice->total_ht).''.price($next_invoice->total_ttc).''.$next_invoice->getLibStatut(3, $totalpaye).'
    '.price($sign * $objp->amount).''.price($sign * $objp->amount).''; if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { print 'rowid.'">'; @@ -4972,7 +4972,7 @@ if ($action == 'create') { print $invoice->getNomUrl(0); print ''; print ''.price($obj->amount_ttc).''.price($obj->amount_ttc).''; print 'rowid.'">'.img_delete().''; print '
    '.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
    '.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
    '.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
    '.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
    '.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
    '.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
    '; print ''; print $langs->trans("Billed"); - print ''.price($object->total_ttc).' 
    '.price($object->total_ttc).' 
    '; print ''; @@ -5047,7 +5047,7 @@ if ($action == 'create') { } print ''; print ''.price($resteapayeraffiche).''.price($resteapayeraffiche).' 
    '; print $langs->trans('AlreadyPaidBack'); - print ' :'.price($sign * $totalpaye).' 
    '.price($sign * $totalpaye).' 
    '.$langs->trans("Billed").' :'.price($sign * $object->total_ttc).' 
    '.$langs->trans("Billed").' :'.price($sign * $object->total_ttc).' 
    '; diff --git a/htdocs/compta/facture/index.php b/htdocs/compta/facture/index.php index a4d6dd6fec7..ba0d8e2f2aa 100644 --- a/htdocs/compta/facture/index.php +++ b/htdocs/compta/facture/index.php @@ -285,7 +285,7 @@ function getDraftTable($maxCount = 500, $socid = 0) $result .= '
    '.$objectstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer', 24).''.price($obj->total_ttc).''.price($obj->total_ttc).'
    '.$langs->trans("Total").''.price($total).''.price($total).'
    '.$companystatic->getNomUrl(1, 'customer', 44).''.dol_print_date($db->jdate($obj->df), 'day').''.price($obj->total_ttc).''.price($obj->total_ttc).'
    0 ? '&userid='.$userid : '').'">'.$year.''.$val['nb'].''.round($val['nb_diff']).''.price(price2num($val['total'], 'MT'), 1).''.price(price2num($val['total'], 'MT'), 1).''.round($val['total_diff']).''.price(price2num($val['avg'], 'MT'), 1).''.price(price2num($val['avg'], 'MT'), 1).''.round($val['avg_diff']).'
    '; print $companystatic->getNomUrl(1, 'supplier'); print ''.price($obj->total_ttc).''.price($obj->total_ttc).'
    '.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->tms), 'day').''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->total_ttc - $obj->tot_fttc).'
    '.$langs->trans("Total").'   ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).') '.price($tot_ht).''.price($tot_ht).''.price($tot_ttc).''.price($tot_tobill).''.price($tot_ttc).''.price($tot_tobill).' 

    '; @@ -1110,10 +1110,10 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { print ''; print ''.dol_print_date($db->jdate($obj->datelimite), 'day').''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { - print ''.price($obj->total_ht).''; + print ''.price($obj->total_ht).''; } - print ''.price($obj->total_ttc).''; - print ''.price($obj->am).''; + print ''.price($obj->total_ttc).''; + print ''.price($obj->am).''; print ''.$tmpinvoice->getLibStatut(3, $obj->am).''; print ''; @@ -1139,10 +1139,10 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { print ''.$langs->trans("Total").'   ('.$langs->trans("RemainderToTake").': '.price($total_ttc - $totalam).') '; print ' '; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { - print ''.price($total).''; + print ''.price($total).''; } - print ''.price($total_ttc).''; - print ''.price($totalam).''; + print ''.price($total_ttc).''; + print ''.price($totalam).''; print ' '; print ''; } else { @@ -1260,10 +1260,10 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''.$societestatic->getNomUrl(1, 'supplier').''; print ''.dol_print_date($db->jdate($obj->date_lim_reglement), 'day').''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { - print ''.price($obj->total_ht).''; + print ''.price($obj->total_ht).''; } - print ''.price($obj->total_ttc).''; - print ''.price($obj->am).''; + print ''.price($obj->total_ttc).''; + print ''.price($obj->am).''; print ''.$facstatic->getLibStatut(3, $obj->am).''; print ''; $total += $obj->total_ht; diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 8742589a6a9..dd77938366a 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -91,7 +91,7 @@ if ($result) { $i++; } print ''.$langs->trans("Total").''; - print ''.price($total).''; + print ''.price($total).''; print ""; $db->free($result); diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index a2904c861f4..969376209eb 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -492,8 +492,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ' '; print ' '; } - print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; - print ''.price(price2num($subtot_coll_vat, 'MT')).''; + print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; + print ''.price(price2num($subtot_coll_vat, 'MT')).''; print ''; } @@ -505,8 +505,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ' '; print ' '; } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; print ''; } @@ -643,8 +643,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ' '; print ' '; } - print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; - print ''.price(price2num($subtot_paye_vat, 'MT')).''; + print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; + print ''.price(price2num($subtot_paye_vat, 'MT')).''; print ''; } @@ -656,8 +656,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ' '; print ' '; } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; print ''; } diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 7f03f4a569c..94b114c03d8 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -713,17 +713,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } // Price - print ''.price($sign * $objp->total_ttc).''; + print ''.price($sign * $objp->total_ttc).''; // Received + already paid - print ''.price($sign * $paiement); + print ''.price($sign * $paiement); if ($creditnotes) { print '+'.price($creditnotes).''; } if ($deposits) { print '+'.price($deposits).''; } - print ''; + print ''; // Remain to take or to pay back print ''.price($sign * $remaintopay).''; @@ -901,7 +901,7 @@ if (!GETPOST('action', 'aZ09')) { print ''.$objp->ref."\n"; print ''.dol_print_date($db->jdate($objp->dp))."\n"; print ''.$objp->paiement_type.' '.$objp->num_payment."\n"; - print ''.price($objp->amount).''; + print ''.price($objp->amount).''; print ' '; print ''; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 9096bfa5e5d..d43e1a2c84b 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -365,13 +365,13 @@ if ($resql) { print ''; } // Expected to pay - print ''.price($objp->total_ttc).''; + print ''.price($objp->total_ttc).''; // Amount payed - print ''.price($objp->amount).''; + print ''.price($objp->amount).''; // Remain to pay - print ''.price($remaintopay).''; + print ''.price($remaintopay).''; // Status print ''.$invoice->getLibStatut(5, $alreadypayed).''; diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 86153e4b38d..39b5ded892b 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -462,7 +462,7 @@ if ($action == 'new') { print ''.$value["numero"]."\n"; print ''.$value["emetteur"]."\n"; print ''.$value["banque"]."\n"; - print ''.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).''; + print ''.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).''; // Link to payment print ''; @@ -639,7 +639,7 @@ if ($action == 'new') { print ''.($objp->num_chq ? $objp->num_chq : ' ').''; print ''.dol_trunc($objp->emetteur, 24).''; print ''.dol_trunc($objp->banque, 24).''; - print ''.price($objp->amount).''; + print ''.price($objp->amount).''; // Link to payment print ''; $paymentstatic->id = $objp->pid; diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 8bdbb7478a7..8bde7fac19e 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -131,7 +131,7 @@ if ($resql) { print ''.dol_print_date($db->jdate($objp->db), 'day').''; print ''.$accountstatic->getNomUrl(1).''; print ''.$objp->nbcheque.''; - print ''.price($objp->amount).''; + print ''.price($objp->amount).''; print ''.$checkdepositstatic->LibStatut($objp->statut, 3).''; print ''; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index c13472dd1fe..0c4a6d9c478 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -228,7 +228,7 @@ if ($resql) { print ''.$objp->nbcheque.''; // Amount - print ''.price($objp->amount).''; + print ''.price($objp->amount).''; // Statut print ''; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 75c63620b0b..1e99cf8676f 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -547,7 +547,7 @@ while ($i < min($num, $limit)) { // Amount if (!empty($arrayfields['p.amount']['checked'])) { - print ''.price($objp->amount).''; + print ''.price($objp->amount).''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index f41d40115b6..4e464243df6 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -120,7 +120,7 @@ if ($resql) { print ''.img_object($langs->trans("ShowPayment"), "payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp), 'day')."\n"; print "$objp->paiement_type $objp->num_payment\n"; - print ''.price($objp->amount).''; + print ''.price($objp->amount).''; print ''; if ($objp->statut == 0) { diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index e796f039f80..6b47dacdd9d 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -266,11 +266,11 @@ if ($action == 'create') { print "!!!\n"; } - print ''.price($objp->amount).""; + print ''.price($objp->amount).""; - print ''.price($sumpaid).""; + print ''.price($sumpaid).""; - print ''.price($objp->amount - $sumpaid).""; + print ''.price($objp->amount - $sumpaid).""; print ''; if ($sumpaid < $objp->amount) { diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index 7fc81e5ac27..64952def30d 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -262,11 +262,11 @@ if ($action == 'create') { print "!!!\n"; } - print ''.price($objp->amount).""; + print ''.price($objp->amount).""; - print ''.price($sumpaid).""; + print ''.price($sumpaid).""; - print ''.price($objp->amount - $sumpaid).""; + print ''.price($objp->amount - $sumpaid).""; print ''; diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index 7be99cead28..c3640c1a760 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -207,11 +207,11 @@ if ($resql) { // Label print ''.$objp->label.''; // Expected to pay - print ''.price($objp->sc_amount).''; + print ''.price($objp->sc_amount).''; // Status print ''.$socialcontrib->getLibStatut(4, $objp->amount).''; // Amount paid - print ''.price($objp->amount).''; + print ''.price($objp->amount).''; print "\n"; if ($objp->paye == 1) { // If at least one invoice is paid, disable delete $disable_delete = 1; diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php index 70d958932e5..b671492c346 100644 --- a/htdocs/compta/payment_vat/card.php +++ b/htdocs/compta/payment_vat/card.php @@ -263,11 +263,11 @@ if ($resql) { // Label print ''.$objp->label.''; // Expected to pay - print ''.price($objp->tva_amount).''; + print ''.price($objp->tva_amount).''; // Status print ''.$tva->getLibStatut(4, $objp->amount).''; // Amount payed - print ''.price($objp->amount).''; + print ''.price($objp->amount).''; print "\n"; if ($objp->paye == 1) { // If at least one invoice is paid, disable delete $disable_delete = 1; diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index a705353112c..c77ad6ea7e3 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -216,8 +216,8 @@ if ($result) { print $bprev->getNomUrl(1); print "\n"; print ''.dol_print_date($db->jdate($obj->datec), "dayhour")."\n"; - print ''.price($obj->amount)."\n"; - print ''.$bprev->getLibStatut(3)."\n"; + print ''.price($obj->amount)."\n"; + print ''.$bprev->getLibStatut(3)."\n"; print "\n"; $i++; diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index d04e7131edc..20a11effdad 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -423,7 +423,7 @@ if ($id > 0 || $ref) { print $thirdparty->getNomUrl(1); print "\n"; - print ''.price($obj->amount)."\n"; + print ''.price($obj->amount)."\n"; print ''; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index e12c50b75f5..6793fb0a893 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -503,7 +503,7 @@ if ($result) print ''.dol_print_date($db->jdate($obj->datec),'day')."\n"; - print ''.price($obj->amount,0,$langs,0,0,-1,$conf->currency)."\n"; + print ''.price($obj->amount,0,$langs,0,0,-1,$conf->currency)."\n"; print "\n"; $i++; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 23511a4a00a..9cfeb860d33 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -281,10 +281,10 @@ if ($resql) { print "\n"; // Amount of invoice - print ''.price($obj->total_ttc)."\n"; + print ''.price($obj->total_ttc)."\n"; // Amount requested - print ''.price($obj->amount_requested)."\n"; + print ''.price($obj->amount_requested)."\n"; // Status of requests print ''; diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 9a4f209e134..b202d8ce0b7 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -222,7 +222,7 @@ if ($resql) { print ''; print ''.$obj->name."\n"; - print ''.price($obj->amount)."\n"; + print ''.price($obj->amount)."\n"; print ''.$rej->motifs[$obj->motif].''; print ''.yn($obj->afacturer).''; @@ -240,7 +240,7 @@ if ($resql) { if ($num > 0) { print ' '; print ''.$langs->trans("Total").''; - print ''.price($total)."\n"; + print ''.price($total)."\n"; print ' '; print "\n"; } diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 6e537159721..77595d53ace 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -218,7 +218,7 @@ if ($result) { print $bprev->getNomUrl(1); print "\n"; print ''.dol_print_date($db->jdate($obj->datec), "dayhour")."\n"; - print ''.price($obj->amount)."\n"; + print ''.price($obj->amount)."\n"; print ''.$bprev->getLibStatut(3)."\n"; print "\n"; diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 73c985355b1..dce5dd39b60 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -301,7 +301,7 @@ if ($id) { print ''; print img_object($langs->trans("ShowCompany"), "company").' '.$obj->name."\n"; - print ''.price($obj->total_ttc)."\n"; + print ''.price($obj->total_ttc)."\n"; print ''; $invoicestatic->fetch($obj->facid); diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index a966e8e8b93..0818dbb61d1 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -266,7 +266,7 @@ if ($result) { print ''.dol_print_date($db->jdate($obj->datec), 'day')."\n"; - print ''.price($obj->amount)."\n"; + print ''.price($obj->amount)."\n"; print ' '; diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index eda6be0cd98..5c6f058bff1 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -205,7 +205,7 @@ if ($result) { print ''.dol_print_date($db->jdate($obj->datec), 'day')."\n"; - print ''.price($obj->amount)."\n"; + print ''.price($obj->amount)."\n"; print ''; print $bon->LibStatut($obj->statut, 3); diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index f7abdab9c79..9f9ee72cc6d 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -286,7 +286,7 @@ if ($id > 0) { $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']); // Balance - print ''.price($data['balance'])."\n"; + print ''.price($data['balance'])."\n"; // Author print ''; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index a22c0c51b73..14fc650db97 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -311,7 +311,7 @@ if ($modecompta == 'BOOKKEEPING') { print ''; print ' '; print ''.$objp->pcg_type.($objp->name ? ' ('.$objp->name.')' : '')."\n"; - print ''.price($objp->amount)."\n"; + print ''.price($objp->amount)."\n"; print "\n"; $total_ht += (isset($objp->amount) ? $objp->amount : 0); @@ -350,7 +350,7 @@ if ($modecompta == 'BOOKKEEPING') { print ''; print ''; print '     '.length_accountg($cpt['account_number']).' - '.$cpt['account_label'].''; - print ''.price($resultN).''; + print ''.price($resultN).''; print "\n"; } } @@ -420,9 +420,9 @@ if ($modecompta == 'BOOKKEEPING') { print "".$langs->trans("Bills").' '.$objp->name."\n"; if ($modecompta == 'CREANCES-DETTES') { - print ''.price($objp->amount_ht)."\n"; + print ''.price($objp->amount_ht)."\n"; } - print ''.price($objp->amount_ttc)."\n"; + print ''.price($objp->amount_ttc)."\n"; $total_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0); $total_ttc += $objp->amount_ttc; @@ -465,9 +465,9 @@ if ($modecompta == 'BOOKKEEPING') { print "".$langs->trans("Bills")." ".$langs->trans("Other")." (".$langs->trans("PaymentsNotLinkedToInvoice").")\n"; if ($modecompta == 'CREANCES-DETTES') { - print ''.price($objp->amount_ht)."\n"; + print ''.price($objp->amount_ht)."\n"; } - print ''.price($objp->amount_ttc)."\n"; + print ''.price($objp->amount_ttc)."\n"; $total_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0); $total_ttc += $objp->amount_ttc; @@ -557,9 +557,9 @@ if ($modecompta == 'BOOKKEEPING') { print "".$langs->trans("Donation")." name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name." ".$obj->firstname." ".$obj->lastname."\n"; if ($modecompta == 'CREANCES-DETTES') { - print ''.price($obj->amount).''; + print ''.price($obj->amount).''; } - print ''.price($obj->amount).''; + print ''.price($obj->amount).''; print ''; $i++; } @@ -638,9 +638,9 @@ if ($modecompta == 'BOOKKEEPING') { print "".$langs->trans("Bills")." socid."\">".$objp->name."\n"; if ($modecompta == 'CREANCES-DETTES') { - print ''.price(-$objp->amount_ht)."\n"; + print ''.price(-$objp->amount_ht)."\n"; } - print ''.price(-$objp->amount_ttc)."\n"; + print ''.price(-$objp->amount_ttc)."\n"; $total_ht -= (isset($objp->amount_ht) ? $objp->amount_ht : 0); $total_ttc -= $objp->amount_ttc; @@ -733,9 +733,9 @@ if ($modecompta == 'BOOKKEEPING') { print ' '; print ''.$obj->label.''; if ($modecompta == 'CREANCES-DETTES') { - print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount).''; } - print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount).''; print ''; $i++; } @@ -820,9 +820,9 @@ if ($modecompta == 'BOOKKEEPING') { print ' '; print ''.$obj->label.''; if ($modecompta == 'CREANCES-DETTES') { - print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount).''; } - print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount).''; print ''; $i++; } @@ -903,9 +903,9 @@ if ($modecompta == 'BOOKKEEPING') { print "".$langs->trans("Salary")." fk_user."\">".$obj->firstname." ".$obj->lastname."\n"; if ($modecompta == 'CREANCES-DETTES') { - print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount).''; } - print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount).''; print ''; $i++; } @@ -989,9 +989,9 @@ if ($modecompta == 'BOOKKEEPING') { print "".$langs->trans("ExpenseReport")." userid."\">".$obj->firstname." ".$obj->lastname."\n"; if ($modecompta == 'CREANCES-DETTES') { - print ''.price(-$obj->amount_ht).''; + print ''.price(-$obj->amount_ht).''; } - print ''.price(-$obj->amount_ttc).''; + print ''.price(-$obj->amount_ttc).''; print ''; } } else { @@ -1050,9 +1050,9 @@ if ($modecompta == 'BOOKKEEPING') { print ' '; print "".$langs->trans("Debit")."\n"; if ($modecompta == 'CREANCES-DETTES') { - print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount).''; } - print ''.price(-$obj->amount)."\n"; + print ''.price(-$obj->amount)."\n"; print "\n"; // Credit (payment received from customer for example) @@ -1067,9 +1067,9 @@ if ($modecompta == 'BOOKKEEPING') { print ' '; print "".$langs->trans("Credit")."\n"; if ($modecompta == 'CREANCES-DETTES') { - print ''.price($obj->amount).''; + print ''.price($obj->amount).''; } - print ''.price($obj->amount)."\n"; + print ''.price($obj->amount)."\n"; print "\n"; // Total @@ -1117,9 +1117,9 @@ if ($modecompta == 'BOOKKEEPING') { print ' '; print "".$loan_static->getNomUrl(1).' - '.$obj->label."\n"; if ($modecompta == 'CREANCES-DETTES') { - print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount).''; } - print ''.price(-$obj->amount)."\n"; + print ''.price(-$obj->amount)."\n"; print "\n"; $subtotal_ht -= $obj->amount; $subtotal_ttc -= $obj->amount; @@ -1205,7 +1205,7 @@ if ($modecompta == 'BOOKKEEPING') { print ' '; print "".$langs->trans("VATToPay")."\n"; print ' '."\n"; - print ''.price($amount)."\n"; + print ''.price($amount)."\n"; print "\n"; // VAT to retreive @@ -1263,7 +1263,7 @@ if ($modecompta == 'BOOKKEEPING') { print ' '; print ''.$langs->trans("VATToCollect")."\n"; print ' '."\n"; - print ''.price($amount)."\n"; + print ''.price($amount)."\n"; print "\n"; } else { // VAT really already paid @@ -1319,7 +1319,7 @@ if ($modecompta == 'BOOKKEEPING') { if ($modecompta == 'CREANCES-DETTES') { print ''."\n"; } - print ''.price($amount)."\n"; + print ''.price($amount)."\n"; print "\n"; // VAT really received @@ -1375,7 +1375,7 @@ if ($modecompta == 'BOOKKEEPING') { if ($modecompta == 'CREANCES-DETTES') { print ''."\n"; } - print ''.price($amount)."\n"; + print ''.price($amount)."\n"; print "\n"; } } diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 8ef75bf5846..67bc2d2e61f 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -500,18 +500,18 @@ if ($modecompta == 'CREANCES-DETTES') { } print ''; - print ''.price($totCat['NP']).''; - print ''.price($totCat['N']).''; + print ''.price($totCat['NP']).''; + print ''.price($totCat['N']).''; // Each month foreach ($totCat['M'] as $k => $v) { if (($k + 1) >= $date_startmonth) { - print ''.price($v).''; + print ''.price($v).''; } } foreach ($totCat['M'] as $k => $v) { if (($k + 1) < $date_startmonth) { - print ''.price($v).''; + print ''.price($v).''; } } @@ -531,20 +531,20 @@ if ($modecompta == 'CREANCES-DETTES') { print ' - '; print $cpt['account_label']; print ''; - print ''.price($resultNP).''; - print ''.price($resultN).''; + print ''.price($resultNP).''; + print ''.price($resultN).''; // Make one call for each month foreach ($months as $k => $v) { if (($k + 1) >= $date_startmonth) { $resultM = $totPerAccount[$cpt['account_number']]['M'][$k]; - print ''.price($resultM).''; + print ''.price($resultM).'/td>'; } } foreach ($months as $k => $v) { if (($k + 1) < $date_startmonth) { $resultM = $totPerAccount[$cpt['account_number']]['M'][$k]; - print ''.price($resultM).''; + print ''.price($resultM).''; } } print "\n"; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index c26c62fb7ed..b8562829066 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -677,7 +677,7 @@ if ($id > 0) { } print ''; } - print ''.price($objp->amount)."\n"; + print ''.price($objp->amount)."\n"; print ""; $totalpaye += $objp->amount; $i++; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 21f599f42dc..99d8efd3665 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -262,7 +262,7 @@ while ($i < min($num, $limit)) { // Type print ''.$obj->label.''; // Expected to pay - print ''.price($obj->total).''; + print ''.price($obj->total).''; // Ref payment $payment_sc_static->id = $obj->pid; $payment_sc_static->ref = $obj->pid; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index fdb1e3336df..2a116c6376b 100755 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -675,7 +675,7 @@ if ($id) { } print ''; } - print ''.price($objp->amount)."\n"; + print ''.price($objp->amount)."\n"; print ""; $totalpaye += $objp->amount; $i++; diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 5b990258672..7860f7e3c02 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -558,8 +558,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ' '; print ' '; } - print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; - print ''.price(price2num($subtot_coll_vat, 'MT')).''; + print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; + print ''.price(price2num($subtot_coll_vat, 'MT')).''; print ''; } } @@ -748,8 +748,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ' '; print ' '; } - print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; - print ''.price(price2num($subtot_paye_vat, 'MT')).''; + print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; + print ''.price(price2num($subtot_paye_vat, 'MT')).''; print ''; } } diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 4eec7ca85a1..2ec4ef5bbd5 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -204,7 +204,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $date = $obj->datev; print ''.dol_print_date($date, 'day').''; // Expected to pay - print ''.price($obj->total).''; + print ''.price($obj->total).''; // Paid print ''; if ($obj->totalpaye) { diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index d3871968ed5..acf0bec8899 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -595,8 +595,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ' '; print ' '; } - print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; - print ''.price(price2num($subtot_coll_vat, 'MT')).''; + print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; + print ''.price(price2num($subtot_coll_vat, 'MT')).''; print ''; } @@ -831,8 +831,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ' '; print ' '; } - print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; - print ''.price(price2num($subtot_paye_vat, 'MT')).''; + print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; + print ''.price(price2num($subtot_paye_vat, 'MT')).''; print ''; } @@ -844,8 +844,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ' '; print ' '; } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; print ''; } diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 27cbf5a3a70..60215abb847 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -488,24 +488,24 @@ $moreforfilter = ''; if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmpttile = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmpttile, 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view other users if ($user->rights->user->user->lire) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $tmpttile = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmpttile, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view categories of products if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $tmpttile = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmpttile, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
    '; } diff --git a/htdocs/core/class/html.formcategory.class.php b/htdocs/core/class/html.formcategory.class.php index 320a1cd2a49..518a8f93290 100644 --- a/htdocs/core/class/html.formcategory.class.php +++ b/htdocs/core/class/html.formcategory.class.php @@ -49,11 +49,13 @@ class FormCategory extends Form $categoryArray = $this->select_all_categories($type, "", "", 64, 0, 1); $categoryArray[-2] = "- ".$langs->trans('NotCategorized')." -"; + $tmptitle = $langs->trans("Category"); + $filter = ''; $filter .= '
    '; - $filter .= img_picto($langs->trans("Categories"), 'category', 'class="pictofixedwidth"'); + $filter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); //$filter .= $langs->trans('Categories').": "; - $filter .= Form::multiselectarray($htmlName, $categoryArray, $preSelected, 0, 0, "minwidth300"); + $filter .= Form::multiselectarray($htmlName, $categoryArray, $preSelected, 0, 0, "minwidth300", 0, 0, '', '', $tmptitle); $filter .= "
    "; return $filter; diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 9a2d1402e17..6e06071bde7 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -292,7 +292,7 @@ if ($resql) { } print "\n"; } - print ''.price($objp->amount).''; + print ''.price($objp->amount).''; print ''.$donationstatic->LibStatut($objp->status, 5).''; print ''; print ""; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 09834f5c2af..2417563c176 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -970,24 +970,24 @@ if ($resql) { if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view other users if ($user->rights->user->user->lire) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $tmptitle = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
    '; } $parameters = array(); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 11b6f5bf1fe..45a461564b5 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -82,6 +82,8 @@ PaymentsAlreadyDone=Payments already done PaymentsBackAlreadyDone=Refunds already done PaymentRule=Payment rule PaymentMode=Payment Type +DefaultPaymentMode=Default Payment Type +DefaultBankAccount=Default Bank Account PaymentTypeDC=Debit/Credit Card PaymentTypePP=PayPal IdPaymentMode=Payment Type (id) diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index 9040d140149..fa1de74b0cc 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -252,7 +252,7 @@ if ($resql) { print ''.dol_trunc($obj->label, 42).''; // Capital - print ''.price($obj->capital).''; + print ''.price($obj->capital).''; // Date start print ''.dol_print_date($db->jdate($obj->datestart), 'day').''; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 9042ed16dac..a27393c8bb2 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -197,7 +197,7 @@ $sql .= $db->order($sortfield, $sortorder); print '
    '; -print img_info('').' '.$langs->trans("MarginPerSaleRepresentativeWarning").'
    '; +print ''.$langs->trans("MarginPerSaleRepresentativeWarning").'
    '; $param = ''; if (!empty($agentid)) { @@ -326,9 +326,9 @@ if ($result) { print ''; print "".$group_array['htmlname']."\n"; - print ''.price(price2num($pv, 'MT')).''; - print ''.price(price2num($pa, 'MT')).''; - print ''.price(price2num($marge, 'MT')).''; + print ''.price(price2num($pv, 'MT')).''; + print ''.price(price2num($pa, 'MT')).''; + print ''.price(price2num($marge, 'MT')).''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''; } diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 43ff6ef6b9f..d12c827cc3e 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -209,10 +209,10 @@ $massactionbutton = ''; $invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED); $sql = "SELECT"; -$sql .= " f.ref, f.rowid as invoiceid, d.rowid as invoicedetid, d.buy_price_ht, d.total_ht, d.subprice, d.label, d.description , d.qty"; -$sql .= " ,d.fk_product"; +$sql .= " f.ref, f.rowid as invoiceid,"; +$sql .= " d.rowid as invoicedetid, d.product_type, d.buy_price_ht, d.total_ht, d.subprice, d.label, d.description, d.qty, d.fk_product"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f "; -$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as d ON d.fk_facture = f.rowid"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as d ON d.fk_facture = f.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql .= " WHERE f.fk_statut NOT IN (".$db->sanitize(implode(', ', $invoice_status_except_list)).")"; $sql .= " AND f.entity IN (".getEntity('invoice').") "; @@ -279,12 +279,12 @@ if ($result) { print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "", "", $param, 'width=20%', $sortfield, $sortorder); - print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "d.subprice", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "d.subprice", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], "d.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); print "\n"; $i = 0; @@ -309,6 +309,12 @@ if ($result) { print $productstatic->getNomUrl(1); } } else { + if ($objp->product_type == $productstatic::TYPE_PRODUCT) { + print img_picto('', 'product'); + } + if ($objp->product_type == $productstatic::TYPE_SERVICE) { + print img_picto('', 'service'); + } print $objp->label; print ' '; print $objp->description; @@ -324,7 +330,7 @@ if ($result) { print $objp->qty; print ''; print ''; - print price($objp->total_ht); + print ''.price($objp->total_ht).''; print ''; print ''; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index e24d318bafc..66e5dc5ffbf 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -344,9 +344,9 @@ if ($result) { print ''.$companystatic->getNomUrl(1, 'margin').''; } - print ''.price(price2num($pv, 'MT')).''; - print ''.price(price2num($pa, 'MT')).''; - print ''.price(price2num($marge, 'MT')).''; + print ''.price(price2num($pv, 'MT')).''; + print ''.price(price2num($pa, 'MT')).''; + print ''.price(price2num($marge, 'MT')).''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''; } diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index a101848bfa1..2914d554fad 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -310,9 +310,9 @@ if ($result) { //print "".$product_static->getNomUrl(1)."\n"; } print ''.$qty.''; - print ''.price(price2num($pv, 'MT')).''; - print ''.price(price2num($pa, 'MT')).''; - print ''.price(price2num($marge, 'MT')).''; + print ''.price(price2num($pv, 'MT')).''; + print ''.price(price2num($pa, 'MT')).''; + print ''.price(price2num($marge, 'MT')).''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''; } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 976e29b55bf..6ab17b6feee 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -678,32 +678,32 @@ if ($search_all) { $moreforfilter = ''; -// Filter on categories -if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { - $formcategory = new FormCategory($db); - $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array); -} - // If the user can view user other than himself $moreforfilter .= '
    '; -$moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').': '; +$tmptitle = $langs->trans('ProjectsWithThisUserAsContact'); //$includeonly = 'hierarchyme'; $includeonly = ''; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; // If the user can view thirdparties other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250'); $moreforfilter .= '
    '; } +// Filter on categories +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + $formcategory = new FormCategory($db); + $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array); +} + if (!empty($moreforfilter)) { print '
    '; print $moreforfilter; @@ -1243,7 +1243,7 @@ while ($i < min($num, $limit)) { $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration'; } } - // PriceOfBooth + // Price of booth if (!empty($arrayfields['p.price_booth']['checked'])) { print ''; if ($obj->price_booth != '') { @@ -1266,7 +1266,7 @@ while ($i < min($num, $limit)) { print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['p.datec']['checked'])) { - print ''; + print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; if (!$i) { @@ -1275,7 +1275,7 @@ while ($i < min($num, $limit)) { } // Date modification if (!empty($arrayfields['p.tms']['checked'])) { - print ''; + print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; if (!$i) { diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index cb89a210e1e..7156d94ef21 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -588,29 +588,29 @@ $morehtmlfilter = ''; if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { 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, 'maxwidth300'); + $tmptitle = $langs->trans('ProjectCategories'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('project', $search_categ, 'search_categ', 0, $tmptitle, 'maxwidth300'); $moreforfilter .= '
    '; } // If the user can view users $moreforfilter .= '
    '; -$moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').' '; +$tmptitle = $langs->trans('ProjectsWithThisUserAsContact'); $includeonly = ''; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; // If the user can view users $moreforfilter .= '
    '; -$moreforfilter .= $langs->trans('TasksWithThisUserAsContact').': '; +$tmptitle = $langs->trans('TasksWithThisUserAsContact'); $includeonly = ''; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= $form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_task_user, 'search_task_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; if (!empty($moreforfilter)) { @@ -658,7 +658,7 @@ if (!empty($arrayfields['t.dateo']['checked'])) { print ''; } print ''; - $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5); + print $formother->selectyear($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'valignmiddle width75', 1); print ''; } // End date @@ -668,7 +668,7 @@ if (!empty($arrayfields['t.datee']['checked'])) { print ''; } print ''; - $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5); + print $formother->selectyear($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'valignmiddle width75', 1); print ''; } if (!empty($arrayfields['p.ref']['checked'])) { diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index b192fa14011..e6c1ef9b97c 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -602,7 +602,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; // Amount - print ''.price($obj->amount).''; + print ''.price($obj->amount).''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index f60f20f7f7a..71540aa2f11 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -560,24 +560,24 @@ if ($resql) { if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view products if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $tmptitle = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
    '; } $parameters = array(); From 6bc56b7671f54593adcd95651695c2c073b32daa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Mar 2021 13:41:28 +0200 Subject: [PATCH 231/618] Look and feel v14 --- htdocs/compta/bank/bankentries_list.php | 13 +- .../compta/cashcontrol/cashcontrol_list.php | 172 ++++++++++++------ .../cashcontrol/class/cashcontrol.class.php | 34 +++- htdocs/compta/paymentbybanktransfer/index.php | 4 +- htdocs/compta/prelevement/index.php | 4 +- htdocs/fichinter/card-rec.php | 32 ++-- htdocs/langs/en_US/bills.lang | 1 + htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 9 files changed, 169 insertions(+), 95 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index fc017a9707b..965e0f6c94b 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -211,7 +211,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_thirdparty_user = ''; $search_num_releve = ''; $search_conciliated = ''; - $thirdparty = ''; $search_account = ""; if ($id > 0 || !empty($ref)) { @@ -992,9 +991,9 @@ if ($resql) { // Bank line $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('RubriquesTransactions').' : '; + $tmptitle = $langs->trans('RubriquesTransactions'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_bid', $cate_arbo, $search_bid, 1, 0, 0, '', 0, 0, 0, '', '', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_bid', $cate_arbo, $search_bid, $tmptitle, 0, 0, '', 0, 0, 0, '', '', 1); $moreforfilter .= '
    '; } } @@ -1561,12 +1560,12 @@ if ($resql) { // Debit if (!empty($arrayfields['b.debit']['checked'])) { - print ''; + print ''; if ($objp->amount < 0) { print price($objp->amount * -1); $totalarray['totaldeb'] += $objp->amount; } - print "\n"; + print "\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1577,12 +1576,12 @@ if ($resql) { // Credit if (!empty($arrayfields['b.credit']['checked'])) { - print ''; + print ''; if ($objp->amount > 0) { print price($objp->amount); $totalarray['totalcred'] += $objp->amount; } - print "\n"; + print "\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 3b97b967208..79ac1e1b708 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -31,14 +31,17 @@ //if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler //if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; @@ -66,7 +69,7 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; @@ -83,11 +86,13 @@ $hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); +//$extrafields->fetch_name_optionals_label($object->table_element_line); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { + reset($object->fields); // Reset is required to avoid key() to return null. $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. } if (!$sortorder) { @@ -95,12 +100,16 @@ if (!$sortorder) { } // Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); +$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); $search = array(); foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { + if (GETPOST('search_'.$key, 'alpha') !== '') { $search[$key] = GETPOST('search_'.$key, 'alpha'); } + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); + $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); + } } // List of fields to search into when doing a "search in all" @@ -161,6 +170,10 @@ if (empty($reshook)) { 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 foreach ($object->fields as $key => $val) { $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } } $toselect = ''; $search_array_options = array(); @@ -198,9 +211,7 @@ $title = $langs->trans('CashControl'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) { - $sql .= 't.'.$key.', '; -} +$sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -210,24 +221,48 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -$sql = preg_replace('/, $/', '', $sql); +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; if ($object->ismultientitymanaged == 1) { $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; } else { $sql .= " WHERE 1 = 1"; } foreach ($search as $key => $val) { - if ($key == 'status' && $search[$key] == -1) { - continue; - } - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + if (array_key_exists($key, $object->fields)) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0)) { + if ($search[$key] == '-1' || $search[$key] === '0') { + $search[$key] = ''; + } + $mode_search = 2; + } + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } + } else { + if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { + $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); + if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { + if (preg_match('/_dtstart$/', $key)) { + $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'"; + } + if (preg_match('/_dtend$/', $key)) { + $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + } + } + } } } if ($search_all) { @@ -241,20 +276,20 @@ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $objec $sql .= $hookmanager->resPrint; /* If a group by is required - $sql.= " GROUP BY " - foreach($object->fields as $key => $val) - { - $sql.='t.'.$key.', '; - } - // Add fields from extrafields - if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); - // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; - $sql=preg_replace('/, $/','', $sql); - */ +$sql.= " GROUP BY "; +foreach($object->fields as $key => $val) { + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +} +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/,\s*$/','', $sql); +*/ $sql .= $db->order($sortfield, $sortorder); @@ -269,10 +304,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); if (!$resql) { @@ -284,10 +321,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; - header("Location: ".dol_buildpath('/compta/cashcontrol/cashcontrol_card.php', 1).'?id='.$id); + header("Location: ".DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$id); exit; } @@ -295,7 +332,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -llxHeader('', $title, $help_url); +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); // Example : Adding jquery code print ''."\n"; + $tplcontent .= ''."\n"; // Add headers $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; From 5e9ce734a7c7926b1783a89af8ed50af000ee4cc Mon Sep 17 00:00:00 2001 From: Youvious Date: Sat, 3 Apr 2021 15:14:33 +0200 Subject: [PATCH 432/618] Clean llx_accounting_account_be.sql of all 'PRODUCT' and 'SERVICE' (pcg_subtype) --- .../mysql/data/llx_accounting_account_be.sql | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/install/mysql/data/llx_accounting_account_be.sql b/htdocs/install/mysql/data/llx_accounting_account_be.sql index b1e3dadff90..e99fa1e54fe 100644 --- a/htdocs/install/mysql/data/llx_accounting_account_be.sql +++ b/htdocs/install/mysql/data/llx_accounting_account_be.sql @@ -655,11 +655,11 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1062, 'PCMN-BASE', 'FINAN', '578', '1060', 'Caisses - timbres ( 0 - fiscaux ; 1 - postaux)', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1063, 'PCMN-BASE', 'FINAN', '58', '1355', 'Virements internes', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1064, 'PCMN-BASE', 'EXPENSE', '60', '1356', 'Approvisionnements et marchandises', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1065, 'PCMN-BASE', 'EXPENSE', 'PRODUCT', '600', '1064', 'Achats de matières premières', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1066, 'PCMN-BASE', 'EXPENSE', 'PRODUCT', '601', '1064', 'Achats de fournitures', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1067, 'PCMN-BASE', 'EXPENSE', 'SERVICE', '602', '1064', 'Achats de services, travaux et études', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1065, 'PCMN-BASE', 'EXPENSE', '600', '1064', 'Achats de matières premières', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1066, 'PCMN-BASE', 'EXPENSE', '601', '1064', 'Achats de fournitures', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1067, 'PCMN-BASE', 'EXPENSE', '602', '1064', 'Achats de services, travaux et études', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1068, 'PCMN-BASE', 'EXPENSE', '603', '1064', 'Sous-traitances générales', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1069, 'PCMN-BASE', 'EXPENSE', 'PRODUCT', '604', '1064', 'Achats de marchandises', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1069, 'PCMN-BASE', 'EXPENSE', '604', '1064', 'Achats de marchandises', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1070, 'PCMN-BASE', 'EXPENSE', '605', '1064', 'Achats d''immeubles destinés à la revente', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1071, 'PCMN-BASE', 'EXPENSE', '608', '1064', 'Remises , ristournes et rabais obtenus sur achats', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1072, 'PCMN-BASE', 'EXPENSE', '609', '1064', 'Variations de stocks', 1); @@ -849,24 +849,24 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1256, 'PCMN-BASE', 'EXPENSE', '695', '1250', 'Administrateurs ou gérants', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1257, 'PCMN-BASE', 'EXPENSE', '696', '1250', 'Autres allocataires', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1258, 'PCMN-BASE', 'INCOME', '70', '1357', 'Chiffre d''affaires', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1260, 'PCMN-BASE', 'INCOME', 'PRODUCT', '700', '1258', 'Ventes de marchandises', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1261, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7000', '1260', 'Ventes en Belgique', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1262, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7001', '1260', 'Ventes dans les pays membres de la C.E.E.', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1263, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7002', '1260', 'Ventes à l''exportation', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1264, 'PCMN-BASE', 'INCOME', 'PRODUCT', '701', '1258', 'Ventes de produits finis', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1265, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7010', '1264', 'Ventes en Belgique', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1266, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7011', '1264', 'Ventes dans les pays membres de la C.E.E.', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1267, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7012', '1264', 'Ventes à l''exportation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1260, 'PCMN-BASE', 'INCOME', '700', '1258', 'Ventes de marchandises', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1261, 'PCMN-BASE', 'INCOME', '7000', '1260', 'Ventes en Belgique', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1262, 'PCMN-BASE', 'INCOME', '7001', '1260', 'Ventes dans les pays membres de la C.E.E.', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1263, 'PCMN-BASE', 'INCOME', '7002', '1260', 'Ventes à l''exportation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1264, 'PCMN-BASE', 'INCOME', '701', '1258', 'Ventes de produits finis', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1265, 'PCMN-BASE', 'INCOME', '7010', '1264', 'Ventes en Belgique', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1266, 'PCMN-BASE', 'INCOME', '7011', '1264', 'Ventes dans les pays membres de la C.E.E.', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1267, 'PCMN-BASE', 'INCOME', '7012', '1264', 'Ventes à l''exportation', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1268, 'PCMN-BASE', 'INCOME', '702', '1258', 'Ventes de déchets et rebuts', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1269, 'PCMN-BASE', 'INCOME', '7020', '1268', 'Ventes en Belgique', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1270, 'PCMN-BASE', 'INCOME', '7021', '1268', 'Ventes dans les pays membres de la C.E.E.', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1271, 'PCMN-BASE', 'INCOME', '7022', '1268', 'Ventes à l''exportation', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1272, 'PCMN-BASE', 'INCOME', '703', '1258', 'Ventes d''emballages récupérables', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1273, 'PCMN-BASE', 'INCOME', '704', '1258', 'Facturations des travaux en cours (associations momentanées)', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1274, 'PCMN-BASE', 'INCOME', 'SERVICE', '705', '1258', 'Prestations de services', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1275, 'PCMN-BASE', 'INCOME', 'SERVICE', '7050', '1274', 'Prestations de services en Belgique', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1276, 'PCMN-BASE', 'INCOME', 'SERVICE', '7051', '1274', 'Prestations de services dans les pays membres de la C.E.E.', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1277, 'PCMN-BASE', 'INCOME', 'SERVICE', '7052', '1274', 'Prestations de services en vue de l''exportation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1274, 'PCMN-BASE', 'INCOME', '705', '1258', 'Prestations de services', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1275, 'PCMN-BASE', 'INCOME', '7050', '1274', 'Prestations de services en Belgique', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1276, 'PCMN-BASE', 'INCOME', '7051', '1274', 'Prestations de services dans les pays membres de la C.E.E.', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1277, 'PCMN-BASE', 'INCOME', '7052', '1274', 'Prestations de services en vue de l''exportation', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1278, 'PCMN-BASE', 'INCOME', '706', '1258', 'Pénalités et dédits obtenus par l''entreprise', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1279, 'PCMN-BASE', 'INCOME', '708', '1258', 'Remises, ristournes et rabais accordés', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1280, 'PCMN-BASE', 'INCOME', '7080', '1279', 'Sur ventes de marchandises', 1); From e30f7fb6e602118c470afece2e969af8865ef5a2 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 3 Apr 2021 16:45:53 +0200 Subject: [PATCH 433/618] Create index.html --- htdocs/modulebuilder/admin/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/modulebuilder/admin/index.html diff --git a/htdocs/modulebuilder/admin/index.html b/htdocs/modulebuilder/admin/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/admin/index.html @@ -0,0 +1 @@ + From fa1e46cc6a81253bf43408ed3fd3ea076ec5bfba Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 3 Apr 2021 16:48:03 +0200 Subject: [PATCH 434/618] Create index.html --- htdocs/modulebuilder/template/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/modulebuilder/template/index.html diff --git a/htdocs/modulebuilder/template/index.html b/htdocs/modulebuilder/template/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/index.html @@ -0,0 +1 @@ + From bf59287770e11e2c16f607361295f8a966d5890e Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 3 Apr 2021 17:19:16 +0200 Subject: [PATCH 435/618] Update llx_10_c_regions.sql --- .../install/mysql/data/llx_10_c_regions.sql | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 09981e7d339..f1dc9b05bf6 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -49,14 +49,19 @@ -- CONTENT ------------------------------------------------------------------- -- --- Algeria +-- Algeria -> for Departmements +-- Andorra -> for Departmements +-- Angola -> for Departmements -- Argentina --- Australia --- Austria --- Barbados +-- Australia -> for Departmements +-- Austria -> for Departmements +-- Barbados -> for Departmements -- Belgium -- Bolivia --- Brazil +-- Brazil -> for Departmements +-- Canada -> for Departmements +-- Colombie -> for Departmements + -- TEMPLATE ---------------------------------------------------------------------------------------- @@ -67,6 +72,14 @@ insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 0 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 13, 1301, '', 0, 'Algerie'); +-- Andorra Regions (id country=18) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 34, 34000, 'AD', NULL, 'Andorra'); + + +-- Angola Regions (id country=35) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 35, 35001, 'AO', NULL, 'Angola'); + + -- Argentina Regions (id country=23) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2301, '', 0, 'Norte'); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2302, '', 0, 'Litoral'); @@ -364,8 +377,6 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) va -- Regions United Arab Emirates (rowid country=227) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 227, 22701, '', 0, 'United Arab Emirates', 1); --- Regions Andorra (rowid country=18) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (34, 34000, 'AD', NULL, 'Andorra'); -- Regions Hungary (rowid country=18) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (18, 183100, 'HU31', NULL, 'Northern Hungary'); @@ -420,8 +431,6 @@ insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (9, 932 insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (9, 933, '港',0,'香港特别行政区'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (9, 934, '澳',0,'澳门特别行政区'); --- Regions Angola (rowid country=35) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (35, 35001, 'AO', NULL, 'Angola'); -- Regions Taiwan (rowid country=213) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (213, 21301, 'TW', NULL, 'Taiwan'); From 44b8ea2b5f1a0e73ea9c84e55a20879d8eed5445 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 3 Apr 2021 17:38:31 +0200 Subject: [PATCH 436/618] Update llx_20_c_departements.sql Colombia Departamentos --- .../mysql/data/llx_20_c_departements.sql | 72 ++++++++++--------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index d41f2a7454a..bd5d4c15977 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -45,6 +45,7 @@ -- Belgium -- Brazil -- Canada +-- Colombia -- France -- Germany @@ -258,6 +259,42 @@ insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401,'NL','',1,'','Newfoundland and Labrador'); +-- Colombia Departamentos (id country=70) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'ANT', '', 0, 'ANT', 'Antioquia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'BOL', '', 0, 'BOL', 'Bolívar'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'BOY', '', 0, 'BOY', 'Boyacá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAL', '', 0, 'CAL', 'Caldas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAU', '', 0, 'CAU', 'Cauca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CUN', '', 0, 'CUN', 'Cundinamarca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'HUI', '', 0, 'HUI', 'Huila'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'LAG', '', 0, 'LAG', 'La Guajira'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'MET', '', 0, 'MET', 'Meta'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'NAR', '', 0, 'NAR', 'Nariño'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'NDS', '', 0, 'NDS', 'Norte de Santander'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'SAN', '', 0, 'SAN', 'Santander'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'SUC', '', 0, 'SUC', 'Sucre'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'TOL', '', 0, 'TOL', 'Tolima'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'VAC', '', 0, 'VAC', 'Valle del Cauca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'RIS', '', 0, 'RIS', 'Risalda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'ATL', '', 0, 'ATL', 'Atlántico'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'COR', '', 0, 'COR', 'Córdoba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'SAP', '', 0, 'SAP', 'San Andrés, Providencia y Santa Catalina'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'ARA', '', 0, 'ARA', 'Arauca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAS', '', 0, 'CAS', 'Casanare'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'AMA', '', 0, 'AMA', 'Amazonas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAQ', '', 0, 'CAQ', 'Caquetá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CHO', '', 0, 'CHO', 'Chocó'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'GUA', '', 0, 'GUA', 'Guainía'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'GUV', '', 0, 'GUV', 'Guaviare'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'PUT', '', 0, 'PUT', 'Putumayo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'QUI', '', 0, 'QUI', 'Quindío'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'VAU', '', 0, 'VAU', 'Vaupés'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'BOG', '', 0, 'BOG', 'Bogotá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'VID', '', 0, 'VID', 'Vichada'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CES', '', 0, 'CES', 'Cesar'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'MAG', '', 0, 'MAG', 'Magdalena'); + + -- France Departements (id country=1) insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 1,'971','97105',3,'GUADELOUPE','Guadeloupe'); insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 2,'972','97209',3,'MARTINIQUE','Martinique'); @@ -1242,41 +1279,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ZAC', 15401, '', 0, 'ZAC', 'Zacatecas', 1); --- Provinces Colombia (id country=70) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ANT', 7001, '', 0, 'ANT', 'Antioquia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BOL', 7001, '', 0, 'BOL', 'Bolívar', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BOY', 7001, '', 0, 'BOY', 'Boyacá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAL', 7001, '', 0, 'CAL', 'Caldas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAU', 7001, '', 0, 'CAU', 'Cauca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CUN', 7001, '', 0, 'CUN', 'Cundinamarca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('HUI', 7001, '', 0, 'HUI', 'Huila', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LAG', 7001, '', 0, 'LAG', 'La Guajira', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MET', 7001, '', 0, 'MET', 'Meta', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('NAR', 7001, '', 0, 'NAR', 'Nariño', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('NDS', 7001, '', 0, 'NDS', 'Norte de Santander', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SAN', 7001, '', 0, 'SAN', 'Santander', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SUC', 7001, '', 0, 'SUC', 'Sucre', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TOL', 7001, '', 0, 'TOL', 'Tolima', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VAC', 7001, '', 0, 'VAC', 'Valle del Cauca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RIS', 7001, '', 0, 'RIS', 'Risalda', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ATL', 7001, '', 0, 'ATL', 'Atlántico', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('COR', 7001, '', 0, 'COR', 'Córdoba', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SAP', 7001, '', 0, 'SAP', 'San Andrés, Providencia y Santa Catalina', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ARA', 7001, '', 0, 'ARA', 'Arauca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAS', 7001, '', 0, 'CAS', 'Casanare', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AMA', 7001, '', 0, 'AMA', 'Amazonas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAQ', 7001, '', 0, 'CAQ', 'Caquetá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CHO', 7001, '', 0, 'CHO', 'Chocó', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GUA', 7001, '', 0, 'GUA', 'Guainía', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GUV', 7001, '', 0, 'GUV', 'Guaviare', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PUT', 7001, '', 0, 'PUT', 'Putumayo', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('QUI', 7001, '', 0, 'QUI', 'Quindío', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VAU', 7001, '', 0, 'VAU', 'Vaupés', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BOG', 7001, '', 0, 'BOG', 'Bogotá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VID', 7001, '', 0, 'VID', 'Vichada', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CES', 7001, '', 0, 'CES', 'Cesar', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MAG', 7001, '', 0, 'MAG', 'Magdalena', 1); - -- Provinces Honduras (id country=114) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AT', 11401, '', 0, 'AT', 'Atlántida', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CH', 11401, '', 0, 'CH', 'Choluteca', 1); From d72c0a1c3b3dd8ca8e5092f813a303749ee22038 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 3 Apr 2021 17:56:16 +0200 Subject: [PATCH 437/618] Update .gitattributes *.conf text eol=lf *.jpeg binary --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index 4b0ed3d14b5..d1002263778 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,6 +18,7 @@ *.pp text eol=lf *.sh text eol=lf *.yaml text eol=lf +*.conf text eol=lf .bash_aliases text eol=lf @@ -26,6 +27,7 @@ *.ico binary *.png binary *.jpg binary +*.jpeg binary *.odt binary *.odf binary *.frm binary From 1a70aebba6bc19815552600ada0e2a2048948558 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Apr 2021 01:12:25 +0200 Subject: [PATCH 438/618] NEW Can set a target image in dolcropresize function. --- htdocs/core/lib/files.lib.php | 5 +-- htdocs/core/lib/images.lib.php | 65 +++++++++++++++++++--------------- test/phpunit/ImagesLibTest.php | 16 +++++++++ 3 files changed, 56 insertions(+), 30 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 8c73ca6fd1c..431cdffccf4 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1840,14 +1840,15 @@ function deleteFilesIntoDatabaseIndex($dir, $file, $mode = 'uploaded') /** - * Convert an image file into another format. - * This need Imagick php extension. + * Convert an image file or a PDF into another image format. + * This need Imagick php extension. You can use dol_imageResizeOrCrop() for a function that need GD. * * @param string $fileinput Input file name * @param string $ext Format of target file (It is also extension added to file if fileoutput is not provided). * @param string $fileoutput Output filename * @param string $page Page number if we convert a PDF into png * @return int <0 if KO, 0=Nothing done, >0 if OK + * @see dol_imageResizeOrCrop() */ function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '', $page = '') { diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 7041eabfc5e..4803b5e0770 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -97,7 +97,7 @@ function image_format_supported($file, $acceptsvg = 0) /** - * Return size of image file on disk (Supported extensions are gif, jpg, png and bmp) + * Return size of image file on disk (Supported extensions are gif, jpg, png, bmp and webp) * * @param string $file Full path name of file * @param bool $url Image with url (true or false) @@ -127,17 +127,19 @@ function dol_getImageSize($file, $url = false) /** - * Resize or crop an image file (Supported extensions are gif, jpg, png and bmp) + * Resize or crop an image file (Supported extensions are gif, jpg, png, bmp and webp) * - * @param string $file Path of file to resize/crop - * @param int $mode 0=Resize, 1=Crop - * @param int $newWidth Largeur maximum que dois faire l'image destination (0=keep ratio) - * @param int $newHeight Hauteur maximum que dois faire l'image destination (0=keep ratio) - * @param int $src_x Position of croping image in source image (not use if mode=0) - * @param int $src_y Position of croping image in source image (not use if mode=0) - * @return string File name if OK, error message if KO + * @param string $file Path of source file to resize/crop + * @param int $mode 0=Resize, 1=Crop + * @param int $newWidth Largeur maximum que dois faire l'image destination (0=keep ratio) + * @param int $newHeight Hauteur maximum que dois faire l'image destination (0=keep ratio) + * @param int $src_x Position of croping image in source image (not use if mode=0) + * @param int $src_y Position of croping image in source image (not use if mode=0) + * @param string $filetowrite Path of file to write (overwrite source file if not provided) + * @return string File name if OK, error message if KO + * @see dol_convert_file() */ -function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0) +function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0, $filetowrite = '') { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -159,8 +161,8 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, return 'This filename '.$file.' does not seem to be an image filename.'; } elseif (!is_numeric($newWidth) && !is_numeric($newHeight)) { return 'Wrong value for parameter newWidth or newHeight'; - } elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) { - return 'At least newHeight or newWidth must be defined for resizing'; + } elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0 && (empty($filetowrite) || $filetowrite == $file)) { + return 'At least newHeight or newWidth must be defined for resizing, or a target filename must be set to convert'; } elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) { return 'Both newHeight or newWidth must be defined for croping'; } @@ -172,6 +174,11 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $imgHeight = $infoImg[1]; // Hauteur de l'image if ($mode == 0) { // If resize, we check parameters + if (!empty($filetowrite) && $filetowrite != $file && $newWidth <= 0 && $newHeight <= 0) { + $newWidth = $imgWidth; + $newHeight = $imgHeight; + } + if ($newWidth <= 0) { $newWidth = intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio } @@ -280,34 +287,36 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode == 0 ? $imgWidth : $newWidth), ($mode == 0 ? $imgHeight : $newHeight)); // Insere l'image de base redimensionnee - $imgThumbName = $file; + $imgTargetName = ($filetowrite ? $filetowrite : $file); // Check if permission are ok - //$fp = fopen($imgThumbName, "w"); + //$fp = fopen($imgTargetName, "w"); //fclose($fp); - // Create image on disk - switch ($infoImg[2]) { - case 1: // Gif - imagegif($imgThumb, $imgThumbName); + $newExt = strtolower(pathinfo($imgTargetName, PATHINFO_EXTENSION)); + + // Create image on disk (overwrite file if exists) + switch ($newExt) { + case 'gif': // Gif + imagegif($imgThumb, $imgTargetName); break; - case 2: // Jpg - imagejpeg($imgThumb, $imgThumbName, $newquality); + case 'jpg': // Jpg + imagejpeg($imgThumb, $imgTargetName, $newquality); break; - case 3: // Png - imagepng($imgThumb, $imgThumbName, $newquality); + case 'png': // Png + imagepng($imgThumb, $imgTargetName, $newquality); break; - case 4: // Bmp - imagewbmp($imgThumb, $imgThumbName); + case 'bmp': // Bmp + imagewbmp($imgThumb, $imgTargetName); break; - case 18: // Webp - imagewebp($imgThumb, $imgThumbName, $newquality); + case 'webp': // Webp + imagewebp($imgThumb, $imgTargetName, $newquality); break; } // Set permissions on file if (!empty($conf->global->MAIN_UMASK)) { - @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); + @chmod($imgTargetName, octdec($conf->global->MAIN_UMASK)); } // Free memory. This does not delete image. @@ -316,7 +325,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, clearstatcache(); // File was replaced by a modified one, so we clear file caches. - return $imgThumbName; + return $imgTargetName; } diff --git a/test/phpunit/ImagesLibTest.php b/test/phpunit/ImagesLibTest.php index d50d90b9069..5d956fcf3c7 100644 --- a/test/phpunit/ImagesLibTest.php +++ b/test/phpunit/ImagesLibTest.php @@ -152,4 +152,20 @@ class ImagesLibTest extends PHPUnit\Framework\TestCase return 1; } + + /** + * testDolImageResizeOrCrop + * + * @return int + */ + public function testDolImageResizeOrCrop() + { + global $conf; + + $file=dirname(__FILE__).'/img250x20.png'; + $filetarget=$conf->admin->dir_temp.'/img250x20.webp'; + $result = dol_imageResizeOrCrop($file, 0, 0, 0, 0, 0, $filetarget); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($filetarget, $result, 'Failed to convert into webp'); + } } From 025304ad6d1a089547b5a5ba3b49461726ad662d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 4 Apr 2021 07:12:01 +0200 Subject: [PATCH 439/618] Accountancy - Add a constant to enable fk_docdet register --- htdocs/accountancy/class/bookkeeping.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 7286e954d0e..a2cbf12da3d 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -295,7 +295,7 @@ class BookKeeping extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE doc_type = '".$this->db->escape($this->doc_type)."'"; $sql .= " AND fk_doc = ".$this->fk_doc; - //$sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 if record is for several lines + if (!empty($conf->global->ACCOUNTANCY_ENABLE_FKDOCDET)) $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 if record is for several lines $sql .= " AND numero_compte = '".$this->db->escape($this->numero_compte)."'"; $sql .= " AND label_operation = '".$this->db->escape($this->label_operation)."'"; $sql .= " AND entity IN (".getEntity('accountancy').")"; From 9e8ed661b3205974722748a23e9629947be55b34 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 4 Apr 2021 08:06:59 +0200 Subject: [PATCH 440/618] FIX: Accountancy - Warning on the pages of the preparatory statements of accounting entries --- htdocs/accountancy/journal/bankjournal.php | 7 +++++-- htdocs/accountancy/journal/expensereportsjournal.php | 7 +++++-- htdocs/accountancy/journal/purchasesjournal.php | 8 +++++--- htdocs/accountancy/journal/sellsjournal.php | 8 +++++--- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 9878f67890c..27b37c74932 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -997,8 +997,11 @@ if (empty($action) || $action == 'view') { if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1' || empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { - print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); - print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); + print $desc; + print '
    '; } diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 2f7569ab152..2916d4d1fca 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -506,8 +506,11 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { - print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); - print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); + print $desc; + print '
    '; } print '
    '; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index f6fa5c4b76a..bf950182798 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -735,9 +735,11 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { - print '
    '; - print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); - print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); + print $desc; + print '
    '; } print '
    '; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index e5f52cbc2ea..1904631775d 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -688,9 +688,11 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { - print '
    '; - print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); - print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); + print $desc; + print '
    '; } print '
    '; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { From c254d7dded58f3b3506700b2fffd2c631aecca3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Apr 2021 13:42:58 +0200 Subject: [PATCH 441/618] css --- htdocs/contrat/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 5c0ad2747ba..9e342b9b8d3 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1530,7 +1530,7 @@ if ($action == 'create') { print ''; if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0)) { print ''; - print ''; + print ''; print img_picto($langs->trans("MoveToAnotherContract"), 'uparrow'); print ''; } From 3c637fa1adce5858efba3ecdcd8d2224079488be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Apr 2021 15:11:51 +0200 Subject: [PATCH 442/618] Install php-gd --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 733e997bdf3..07895934136 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,8 @@ addons: - libapache2-mod-fastcgi # We need pgloader for import mysql database into pgsql - pgloader + # We need pgloader for import mysql database into pgsql + - php-gd env: global: From 1b62ab73d781bfa801a9251188649a2e63ae487c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Apr 2021 15:42:37 +0200 Subject: [PATCH 443/618] Test --- test/phpunit/ImagesLibTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/phpunit/ImagesLibTest.php b/test/phpunit/ImagesLibTest.php index 5d956fcf3c7..4835a8afd76 100644 --- a/test/phpunit/ImagesLibTest.php +++ b/test/phpunit/ImagesLibTest.php @@ -163,9 +163,9 @@ class ImagesLibTest extends PHPUnit\Framework\TestCase global $conf; $file=dirname(__FILE__).'/img250x20.png'; - $filetarget=$conf->admin->dir_temp.'/img250x20.webp'; + $filetarget=$conf->admin->dir_temp.'/img250x20.jpg'; $result = dol_imageResizeOrCrop($file, 0, 0, 0, 0, 0, $filetarget); print __METHOD__." result=".$result."\n"; - $this->assertEquals($filetarget, $result, 'Failed to convert into webp'); + $this->assertEquals($filetarget, $result, 'Failed to convert into '.$filetarget); } } From 000510a562baeb66f11743896d97ae06571565c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Apr 2021 15:46:31 +0200 Subject: [PATCH 444/618] clean travis --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 07895934136..733e997bdf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,8 +30,6 @@ addons: - libapache2-mod-fastcgi # We need pgloader for import mysql database into pgsql - pgloader - # We need pgloader for import mysql database into pgsql - - php-gd env: global: From a50ca93a3e878e94ad70656b916cfd42e547fdc6 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 4 Apr 2021 08:06:59 +0200 Subject: [PATCH 445/618] FIX: Accountancy - Warning on the pages of the preparatory statements of accounting entries --- htdocs/accountancy/journal/bankjournal.php | 7 +++++-- htdocs/accountancy/journal/expensereportsjournal.php | 7 +++++-- htdocs/accountancy/journal/purchasesjournal.php | 8 +++++--- htdocs/accountancy/journal/sellsjournal.php | 8 +++++--- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index c47255647cb..d8368bba182 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -985,8 +985,11 @@ if (empty($action) || $action == 'view') { if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1' || empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { - print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); - print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); + print $desc; + print '
    '; } diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 70ec097cd27..5a334e0e741 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -498,8 +498,11 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { - print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); - print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); + print $desc; + print '
    '; } print '
    '; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 611dde36af5..d064aae33af 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -728,9 +728,11 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { - print '
    '; - print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); - print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); + print $desc; + print '
    '; } print '
    '; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print ''; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 62d2238a116..2a13b0153c6 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -667,9 +667,11 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { - print '
    '; - print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); - print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print '
    '.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); + print $desc; + print '
    '; } print '
    '; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print ''; From 6fc19c626d161e6d35f35a9aaf6fe0049f4d271a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Apr 2021 17:05:01 +0200 Subject: [PATCH 446/618] Try fix for #17094 --- htdocs/comm/mailing/card.php | 10 +++++----- htdocs/core/lib/files.lib.php | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 00c5c946326..4958811ef4d 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -524,15 +524,15 @@ if (empty($reshook)) { } /* - * Add file in email form + * Action of adding a file in email form */ - if (!empty($_POST['addfile'])) { + if (GETPOST('addfile')) { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Set tmp user directory - dol_add_file_process($upload_dir, 0, 0); + dol_add_file_process($upload_dir, 0, 0, 'addedfile', '', null, '', 0); $action = "edit"; } @@ -543,7 +543,7 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing + dol_remove_file_process(GETPOST('removedfile'), 0, 0); // We really delete file linked to mailing $action = "edit"; } @@ -1216,7 +1216,7 @@ if ($action == 'create') { $out .= '
    '; } } else { - $out .= $langs->trans("NoAttachedFiles").'
    '; + $out .= ''.$langs->trans("NoAttachedFiles").'
    '; } // Add link to add file $out .= ''; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 431cdffccf4..782b0ec4694 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1544,7 +1544,9 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess if (!empty($_FILES[$varfiles])) { // For view $_FILES[$varfiles]['error'] dol_syslog('dol_add_file_process upload_dir='.$upload_dir.' allowoverwrite='.$allowoverwrite.' donotupdatesession='.$donotupdatesession.' savingdocmask='.$savingdocmask, LOG_DEBUG); - if (dol_mkdir($upload_dir) >= 0) { + $result = dol_mkdir($upload_dir); + // var_dump($result);exit; + if ($result >= 0) { $TFile = $_FILES[$varfiles]; if (!is_array($TFile['name'])) { foreach ($TFile as $key => &$val) { @@ -1647,6 +1649,8 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess $res = 1; setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs'); } + } else { + setEventMessages($langs->trans("ErrorFailedToCreateDir", $upload_dir), null, 'errors'); } } elseif ($link) { require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; From fd82776f672037a03c6feb65132a3e9ce080a80a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Apr 2021 18:00:07 +0200 Subject: [PATCH 447/618] Fix --- htdocs/user/perms.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 48b44d2fc57..81d687cd13c 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -288,7 +288,7 @@ if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->ad } print ''.$langs->trans("Permissions").''; if ($user->admin) { - print ''.$langs->trans("ID").''; + print ''; } print ''."\n"; @@ -438,7 +438,11 @@ if ($result) { // Permission id if ($user->admin) { - print ''.$obj->id.''; + print ''; + $htmltext = $langs->trans("ID").': '.$obj->id; + print $form->textwithpicto('', $htmltext); + //print ''.$obj->id.''; + print ''; } print ''."\n"; From e048d734871770c61e308da94798d58e8e077666 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Apr 2021 11:18:24 +0200 Subject: [PATCH 448/618] Show text of permission in tooltip --- htdocs/user/perms.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 81d687cd13c..a3d536cee49 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -440,6 +440,7 @@ if ($result) { if ($user->admin) { print ''; $htmltext = $langs->trans("ID").': '.$obj->id; + $htmltext .= '
    '.$langs->trans("Permission").': user->rights->'.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : ''); print $form->textwithpicto('', $htmltext); //print ''.$obj->id.''; print ''; From bd88806982c9ef6eadb23a9c6ce46a5bc0c5af56 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 5 Apr 2021 12:07:51 +0200 Subject: [PATCH 449/618] Fix order status label in comm index page --- htdocs/comm/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index af5b4ac41a5..82081f6f661 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -839,7 +839,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); - $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; + $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.fk_statut, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; $sql .= ", s.code_client"; $sql .= ", s.entity"; $sql .= ", s.email"; @@ -877,6 +877,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $orderstatic->id = $obj->commandeid; $orderstatic->ref = $obj->ref; + $orderstatic->statut = $obj->fk_statut; $orderstatic->ref_client = $obj->ref_client; $orderstatic->total_ht = $obj->total_ht; $orderstatic->total_tva = $obj->total_tva; From 7cba3f8a0a6ab91dd06ebc3babd72adbf67d2083 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Apr 2021 12:41:39 +0200 Subject: [PATCH 450/618] css --- htdocs/website/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 3e4c56cd240..26ca6df9bf8 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -895,6 +895,7 @@ if ($action == 'addcontainer' && $usercanedit) { getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl['content'], $action, 1, $grabimages, $grabimagesinto); + // We try to convert the CSS we got by adding a prefix .bodywebsite with lessc to avoid conflicit with CSS of Dolibarr. include_once DOL_DOCUMENT_ROOT.'/core/class/lessc.class.php'; $lesscobj = new Lessc(); try { From f03190e23b6e1c97614cb44484377edb7627b9b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Apr 2021 12:57:43 +0200 Subject: [PATCH 451/618] Fix permissions in module workstation --- htdocs/workstation/workstation_agenda.php | 8 +++----- htdocs/workstation/workstation_card.php | 13 +++---------- htdocs/workstation/workstation_document.php | 7 ++----- htdocs/workstation/workstation_list.php | 13 +------------ htdocs/workstation/workstation_note.php | 2 ++ 5 files changed, 11 insertions(+), 32 deletions(-) diff --git a/htdocs/workstation/workstation_agenda.php b/htdocs/workstation/workstation_agenda.php index 8096aa3d771..324e640702b 100755 --- a/htdocs/workstation/workstation_agenda.php +++ b/htdocs/workstation/workstation_agenda.php @@ -82,13 +82,11 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->workstation->multidir_output[$object->entity]."/".$object->id; } -// Security check - Protection if external user -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$result = restrictedArea($user, 'workstation', $object->id); - $permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php +// Security check +restrictedArea($user, $object->element, $object->id); + /* * Actions diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index b64f15e1f76..5d0d92c7cb0 100755 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -82,15 +82,8 @@ $permissionnote = $user->rights->workstation->workstation->write; // Used by the $permissiondellink = $user->rights->workstation->workstation->write; // Used by the include of actions_dellink.inc.php $upload_dir = $conf->workstation->multidir_output[isset($object->entity) ? $object->entity : 1]; -// Security check - Protection if external user -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); -//$result = restrictedArea($user, 'workstation', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); - -if (!$permissiontoread) { - accessforbidden(); -} +// Security check +restrictedArea($user, $object->element, $object->id); /* @@ -343,7 +336,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
    '; /* diff --git a/htdocs/workstation/workstation_document.php b/htdocs/workstation/workstation_document.php index 2c1a9906c8e..324546a9647 100755 --- a/htdocs/workstation/workstation_document.php +++ b/htdocs/workstation/workstation_document.php @@ -74,13 +74,10 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->workstation->multidir_output[$object->entity ? $object->entity : $conf->entity]."/workstation/".get_exdir(0, 0, 0, 1, $object); } -// Security check - Protection if external user -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$result = restrictedArea($user, 'workstation', $object->id); - $permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php +// Security check +restrictedArea($user, $object->element, $object->id); /* diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 59dbfc658d3..2d8b371cd52 100755 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -146,18 +146,7 @@ $permissiontoadd = $user->rights->workstation->workstation->write; $permissiontodelete = $user->rights->workstation->workstation->delete; // Security check -if (empty($conf->workstation->enabled)) { - accessforbidden('Module not enabled'); -} -$socid = 0; -if ($user->socid > 0) { - // Protection if external user - //$socid = $user->socid; - accessforbidden(); -} -//$result = restrictedArea($user, 'workstation', $id, ''); -//if (!$permissiontoread) accessforbidden(); - +restrictedArea($user, $object->element, 0); /* diff --git a/htdocs/workstation/workstation_note.php b/htdocs/workstation/workstation_note.php index f2fa055102a..ddafd1136fe 100755 --- a/htdocs/workstation/workstation_note.php +++ b/htdocs/workstation/workstation_note.php @@ -60,6 +60,8 @@ if ($id > 0 || !empty($ref)) { $permissionnote = $user->rights->workstation->workstation->write; // Used by the include of actions_setnotes.inc.php $permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php +// Security check +restrictedArea($user, $object->element, $object->id); /* From 93341b15144cf6cac87e2efea51881af6483f241 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 5 Apr 2021 13:51:21 +0200 Subject: [PATCH 452/618] FIX uniformization of external link --- htdocs/recruitment/recruitmentjobposition_card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index 45e6ddab01f..58ee9260617 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -552,11 +552,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Load translation files required by the page $langs->loadLangs(array('recruitment')); - $out = img_picto('', 'globe').' '.$langs->trans("PublicUrl").'
    '; + $out = img_picto('', 'globe').' '.$langs->trans("PublicUrl").'
    '; $url = getPublicJobPositionUrl(0, $object->ref); - $out .= ''; - $out .= ''.img_picto('', 'globe').''; + $out .= ''; $out .= ajax_autoselect("recruitmentjobpositionurl", 0); print $out; From 1b3b2ca0235cda5086c53c969a0cf2dad9d67109 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 5 Apr 2021 13:52:09 +0200 Subject: [PATCH 453/618] Update payments.lib.php --- htdocs/core/lib/payments.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 84a72edcc1e..f9022726511 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -173,7 +173,8 @@ function showOnlinePaymentUrl($type, $ref) $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
    '; $url = getOnlinePaymentUrl(0, $type, $ref); - $out .= ''; + $out .= ''; $out .= ajax_autoselect("onlinepaymenturl", 0); return $out; } From 6c521073ea9215fb7baddca5e48345b20b1ab5a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Apr 2021 13:52:19 +0200 Subject: [PATCH 454/618] Fix perm id and sort of modules by id. --- htdocs/admin/system/modules.php | 71 ++++++++---------- htdocs/core/modules/modBlockedLog.class.php | 2 +- htdocs/core/modules/modBom.class.php | 2 +- htdocs/core/modules/modDebugBar.class.php | 2 +- .../modules/modEventOrganization.class.php | 3 +- htdocs/core/modules/modLoan.class.php | 2 +- htdocs/core/modules/modMailing.class.php | 2 +- htdocs/core/modules/modMrp.class.php | 2 +- htdocs/core/modules/modNotification.class.php | 2 +- .../core/modules/modReceiptPrinter.class.php | 2 +- htdocs/core/modules/modWorkstation.class.php | 5 +- htdocs/core/modules/modZapier.class.php | 2 +- htdocs/theme/eldy/img/object_zapier.png | Bin 459 -> 3516 bytes htdocs/user/class/user.class.php | 5 +- htdocs/user/perms.php | 4 +- 15 files changed, 50 insertions(+), 56 deletions(-) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index f9b8bdb65c8..51f3b4577cf 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -228,26 +228,26 @@ print ''; if ($arrayfields['name']['checked']) { print ''; - print ''; + print ''; print ''; } if ($arrayfields['version']['checked']) { print ''; - print ''; + print ''; print ''; } if ($arrayfields['id']['checked']) { print ''; - print ''; - print ''; -} -if ($arrayfields['module_position']['checked']) { - print ''; + print ''; print ''; } if ($arrayfields['permission']['checked']) { print ''; - print ''; + print ''; + print ''; +} +if ($arrayfields['module_position']['checked']) { + print ''; print ''; } @@ -267,14 +267,14 @@ if ($arrayfields['version']['checked']) { print_liste_field_titre($arrayfields['version']['label'], $_SERVER["PHP_SELF"], "version", "", "", "", $sortfield, $sortorder); } if ($arrayfields['id']['checked']) { - print_liste_field_titre($arrayfields['id']['label'], $_SERVER["PHP_SELF"], "id", "", "", "", $sortfield, $sortorder); -} -if ($arrayfields['module_position']['checked']) { - print_liste_field_titre($arrayfields['module_position']['label'], $_SERVER["PHP_SELF"], "module_position", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($arrayfields['id']['label'], $_SERVER["PHP_SELF"], "id", "", "", "", $sortfield, $sortorder, 'nowraponall '); } if ($arrayfields['permission']['checked']) { print_liste_field_titre($arrayfields['permission']['label'], $_SERVER["PHP_SELF"], "permission", "", "", "", $sortfield, $sortorder); } +if ($arrayfields['module_position']['checked']) { + print_liste_field_titre($arrayfields['module_position']['label'], $_SERVER["PHP_SELF"], "module_position", "", "", "", $sortfield, $sortorder); +} // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -289,37 +289,30 @@ if ($sortfield == "name" && $sortorder == "asc") { usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($a->name, $b->name); }); -} -if ($sortfield == "name" && $sortorder == "desc") { +} elseif ($sortfield == "name" && $sortorder == "desc") { usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($b->name, $a->name); }); -} -if ($sortfield == "version" && $sortorder == "asc") { +} elseif ($sortfield == "version" && $sortorder == "asc") { usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($a->version, $b->version); }); -} -if ($sortfield == "version" && $sortorder == "desc") { +} elseif ($sortfield == "version" && $sortorder == "desc") { usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($b->version, $a->version); }); -} -if ($sortfield == "id" && $sortorder == "asc") { +} elseif ($sortfield == "id" && $sortorder == "asc") { usort($moduleList, "compareIdAsc"); -} -if ($sortfield == "id" && $sortorder == "desc") { +} elseif ($sortfield == "id" && $sortorder == "desc") { usort($moduleList, "compareIdDesc"); -} -if ($sortfield == "permission" && $sortorder == "asc") { +} elseif ($sortfield == "permission" && $sortorder == "asc") { usort($moduleList, "comparePermissionIdsAsc"); -} -if ($sortfield == "permission" && $sortorder == "desc") { +} elseif ($sortfield == "permission" && $sortorder == "desc") { usort($moduleList, "comparePermissionIdsDesc"); +} else { + $moduleList = dol_sort_array($moduleList, 'module_position'); } -$moduleList = dol_sort_array($moduleList, 'module_position'); - foreach ($moduleList as $module) { print ''; @@ -338,10 +331,6 @@ foreach ($moduleList as $module) { print ''.$module->id.''; } - if ($arrayfields['module_position']['checked']) { - print ''.$module->module_position.''; - } - if ($arrayfields['permission']['checked']) { $idperms = ''; @@ -357,7 +346,11 @@ foreach ($moduleList as $module) { } } - print ''.($idperms ? $idperms : " ").''; + print ''.($idperms ? $idperms : " ").''; + } + + if ($arrayfields['module_position']['checked']) { + print ''.$module->module_position.''; } print ''; @@ -394,11 +387,11 @@ $db->close(); */ function compareIdAsc(stdClass $a, stdClass $b) { - if ($a->id == $b->id) { + if ((int) $a->id == (int) $b->id) { return 0; } - return $a->id > $b->id ? -1 : 1; + return ((int) $a->id < (int) $b->id) ? -1 : 1; } /** @@ -410,11 +403,11 @@ function compareIdAsc(stdClass $a, stdClass $b) */ function compareIdDesc(stdClass $a, stdClass $b) { - if ($a->id == $b->id) { + if ((int) $a->id == (int) $b->id) { return 0; } - return $b->id > $a->id ? -1 : 1; + return ((int) $b->id < (int) $a->id) ? -1 : 1; } /** @@ -441,7 +434,7 @@ function comparePermissionIdsAsc(stdClass $a, stdClass $b) return 0; } - return $a->permission[0] > $b->permission[0] ? -1 : 1; + return $a->permission[0] < $b->permission[0] ? -1 : 1; } /** @@ -468,5 +461,5 @@ function comparePermissionIdsDesc(stdClass $a, stdClass $b) return 0; } - return $a->permission[0] > $b->permission[0] ? 1 : -1; + return $b->permission[0] < $a->permission[0] ? -1 : 1; } diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 16f95a5e926..9a90fa945bb 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -113,7 +113,7 @@ class modBlockedLog extends DolibarrModules // ----------------- $this->rights = array(); // Permission array used by this module - $r = 0; + $r = 1; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Read archived events and fingerprints'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 67a480dcc08..6b69c6b7af0 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -205,7 +205,7 @@ class modBom extends DolibarrModules // Permissions provided by this module $this->rights = array(); // Permission array used by this module - $r = 0; + $r = 1; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Read bom of Bom'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) diff --git a/htdocs/core/modules/modDebugBar.class.php b/htdocs/core/modules/modDebugBar.class.php index 1b591f02da1..ae2bdcfffc8 100644 --- a/htdocs/core/modules/modDebugBar.class.php +++ b/htdocs/core/modules/modDebugBar.class.php @@ -79,7 +79,7 @@ class modDebugBar extends DolibarrModules // Permissions $this->rights = array(); - $this->rights[1][0] = 430; // id de la permission + $this->rights[1][0] = 431; // id de la permission $this->rights[1][1] = 'Use Debug Bar'; // libelle de la permission $this->rights[1][2] = 'u'; // type de la permission (deprecie a ce jour) $this->rights[1][3] = 1; // La permission est-elle une permission par defaut diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php index 9ee0cb1b74f..3a81102f4bd 100644 --- a/htdocs/core/modules/modEventOrganization.class.php +++ b/htdocs/core/modules/modEventOrganization.class.php @@ -224,7 +224,8 @@ class modEventOrganization extends DolibarrModules // Permissions provided by this module $this->rights = array(); - $r = 0; + $r = 1; + // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index 30aa547cb3a..b061e1b73a6 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -97,7 +97,7 @@ class modLoan extends DolibarrModules $r = 0; $r++; - $this->rights[$r][0] = 520; + $this->rights[$r][0] = 521; $this->rights[$r][1] = 'Read loans'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index 9d590631fe4..ad14724d154 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -48,7 +48,7 @@ class modMailing extends DolibarrModules // It is used to group modules by family in module setup page $this->family = "interface"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '22'; + $this->module_position = '23'; // 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)); diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php index 0a4a7592a20..eb3baae78cd 100644 --- a/htdocs/core/modules/modMrp.class.php +++ b/htdocs/core/modules/modMrp.class.php @@ -236,7 +236,7 @@ class modMrp extends DolibarrModules // Permissions provided by this module $this->rights = array(); - $r = 0; + $r = 1; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index e124b8304f3..072e0607b60 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -45,7 +45,7 @@ class modNotification extends DolibarrModules // It is used to group modules in module setup page $this->family = "interface"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '01'; + $this->module_position = '22'; // 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 = "EMail notifications (push) on business Dolibarr events"; diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 4fe437700e4..ee87f4c57ba 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -95,7 +95,7 @@ class modReceiptPrinter extends DolibarrModules // $this->rights[$r][5] Niveau 2 pour nommer permission dans code $r++; - $this->rights[$r][0] = 67000; + $this->rights[$r][0] = 67001; $this->rights[$r][1] = 'ReceiptPrinter'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; diff --git a/htdocs/core/modules/modWorkstation.class.php b/htdocs/core/modules/modWorkstation.class.php index 02f5e059297..84234a9f6a3 100755 --- a/htdocs/core/modules/modWorkstation.class.php +++ b/htdocs/core/modules/modWorkstation.class.php @@ -45,7 +45,7 @@ class modWorkstation extends DolibarrModules // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module + $this->numero = 690; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'workstation'; // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' @@ -239,7 +239,7 @@ class modWorkstation extends DolibarrModules // Permissions provided by this module $this->rights = array(); - $r = 0; + $r = 1; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) @@ -330,6 +330,7 @@ class modWorkstation extends DolibarrModules // This is a Left menu entry 'type'=>'left', 'titre'=>$langs->trans('Workstations'), + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'mainmenu'=>'mrp', 'leftmenu'=>'workstation_workstation', 'url'=>'', diff --git a/htdocs/core/modules/modZapier.class.php b/htdocs/core/modules/modZapier.class.php index 5685a30c701..430622465ca 100644 --- a/htdocs/core/modules/modZapier.class.php +++ b/htdocs/core/modules/modZapier.class.php @@ -242,7 +242,7 @@ class modZapier extends DolibarrModules // Permission array used by this module $this->rights = array(); - $r = 0; + $r = 1; // Permission id (must not be already used) $this->rights[$r][0] = $this->numero + $r; // Permission label diff --git a/htdocs/theme/eldy/img/object_zapier.png b/htdocs/theme/eldy/img/object_zapier.png index b1337750b6732d01fcc1b04daab1612b71e20c85..b244cb1d5d675f0ae90fbe86e9b637842c15b961 100644 GIT binary patch delta 3352 zcmV+z4d?R91H2oMBYz4DdQ@0+Qek%>aB^>EX>4U6ba`-PAZ2)IW&i+q+U1yQmfX4x zg#U9DS%UZgK`w{SbFzahKOZP{d&c&}zSsGcjNC1?T1|qeLZN84{`Jr8{=r`iS8z$R z4AFuOX?g*m2d~BT4c^97ZF>)PacIQ@k1|uP#miIbe*T)2XO7iQjOK??C)xfr z3=c9$isxsULwO0;dXCCbu67L|pVzo-%HgXIpt7A$e){IOU*|mhAjA|_P|hI?fU$aQHDMTX_RdoP;`f7_oCLp)2mb2=f1oM|%1Lu!f$i$|5MBH?ZpDLhGd zmymZlp8-e_a|^-v2m)93QGE87hM?Y)#{xi&$U{t_gMb$alORK)LW0v!g3Zlu)SqXA zgdFTP+J6KP5_43rsj&f8N&O;{-07jmp1SnhwU=Id8_;K@AtMhRWz^AT zm~kQ#Gf$mm*4dVK3#C|T$;wMtS#`Ay*LK`#%YV*WciDBfH);>6KOBDnHUFR%4pR1< zzER_@Q+*BLO-{rx1F?`ih^rw0p@U&|6`xWtcZFfAWs`!{yq zkozs%oRr_fE&K{OXVCpOkaIxyBW^!IZCalj2eG>fEvHwc`go>=;&@#bZ-09JKOCr! zoPYb(`lxl~I{MC$(%IG(bOwpbucdu2P@!j(pl)7@vl+We?+Il|EAQ^XY8yybt0T@) z^PWIzBc+}5nXk_rR~~2TX13M`_m-hWpLSy$buw<5XDob4S7wmzX?x>vXQ*khci zTq`r=HJE`GxW&r~Q`U?!X2~OMie%N?{iItD5-rgJ>%>NpP(|a(l3Oi~{kL%6KDQ+! z(UfNqM{&-vt;d#Yx4EMN2QxL6NM2&J6bu0*&eI@B-9QMK)hGM_3YTH@9SyMGC! zsI!(ObIVwaL2^3@TGVY6R@FQ)G%vbXX^p)iXrb`Mg*2cA(b;KNUnz0mT0GlSDiWnB z;jV~vPFoK-XZENN6S*9jRBB0dHbW+>N7x#(GKTSM@32PitKFCr4~d>_8%aw?_?qdE zhL*K~$so{nCu_T0+va!lN}YYO8h-(ut#F%^HGu4stg(7ixmpfcWG1ca&_>K4+u6M? zzCNG&@#x@%)Wt8&Cy;Q8eal@1H=;Bf>!vMMGHKo zI+Uh^BB>3N$c7EWET=f?dze*|+qBR>6v()AHdh*<7~MU*Y(v(ymodxG*dbch=9nji zbFCvM{m4n`-COZM+Nr)dL4SIrrd|{DqV={W8S3aT3enB>h* z)Vb;8j;9DrOA!SJ@<;41KcZ004Af0o2IOA2l9)+M-7sPf5RPV1&Zx4mL?>7b&QPdZ(NF9P za>szf(K3G;eP&&@V1Fcq5CR`CWN0913ESdCt63EFIZU`VGScoKNvGdzpS}{6TS92e zvSJquRjwEDrYC+Eh=Be>C$3HD%sc>H=V_aIV$*3&36}eHe^JhD$h0wUNM+BVbtjC} zuPLVW>?!(0Y(}OHa@`e$H!Jt#Ug{WN`O5wLn0xmv`2=n`KYt+BC-<~T(iiDMyVp_K zVb;SPOOu>36I3h6)g6|xTP2npDVffw@kAad+?C!pZ%E?o)^RNTXm44N&l_)QP7eJd zTQIC5jRR%lBg?CE@ARk*ZTf?M`Qq$8-RKdzA`h7M9X(bZq-b0fHH@{8JEbU5lSxr> zJ(qPrR*7u7Nq^H?becq6Dh->uq@znT`J|)zg?i%qX9!>pkc(00_CqPQSvSb8%deD7 z{J{Wti|*kg@OFMPW}rF}CInqZXz^;c=N$(!=04udTEaSl?YkwLh-r_4Hei0N+t}V= zvA40J?Hdx9nJ^ZptwSkHhN2&QG6#-cRoYl>BDL&1X@71bu$a+qO0z}!RRjHLrxh|l za;0>Xk_O$(ZQRMmB)~Gl%jUbbm2x)o0-`4HPCw=OAh;sAWtoIy#U(smFoq^r2qk`p zrrvwD(Yhx)sNFv<3VvszydWkkRo(nObIb!c+dtgth7{ikaTtS zO4dT*0e^I?C!d>nkZ``hiVRkPX51|mD=|z48x@rpz4v%^JS2Wtj~}M0XhCbYb-WDr z?}G(kg+1YqW~K^f7=(=aQ}0V|`ZxRU!{2VK+taVj_}`{HABV?1qEo>ydsIhC&FmSNnl`pqkm7g%%agUqS>S-Naw;S^6NH_M~myR zW~>MY8nnpc-VKt$P(Z;@~K0hVtwIIOs*!Y5J9!_-&g*I`_JJ>CU z$BK~*TXSPOHTp-BaLs#tD<&|oowXDud^Sk8_w?8`*%)@lyUnL5AGQz3`hjd7$gVH# z=YQw3`+3J$Sd=v)%cGtnP6q|zKs?r^p29F8S7V>z3x?I2>%P0p*mR<6>-!m6rn2R|084ld5RI=Bjg;0K7Cn}3s{ zijGx_(b9vrW+RVI`Pz|rE}gVjTkx9=HM~KB@8_R9XN`^{2Nq-zwRE_e5tjh}LEzWAW%9{7&FAV3k4ex=P*v2Zz9Lk+Ro3-rdpO+rMX;{rv!DCUT-x z{UY)J005{^OjJbx005CGrGMW7h7$k)00DGTPE!Ct=GbNc0004EOGiWihy@);00009 za7bBm000XU000XU0RWnu7ytkO2XskIMF-^s1q&nyyJhee0002xNkl5EU2PSpsMT{Qp1mUXe)J>Vt32OFNyDwzo^C^MBHGU4Q!ubb;=ttk(v5 za^5%0H((llF&`L!)c_V?3`AlGz^nn2xrw384~ zoFs9CP+dey(`I>|QALw}$}d;odQlUchxJj1D&j_iMRQpNnVU$IoHy59pp@6B+7G7s i<;gvDkD~h@{0000B1|=wExpE~4D&?fF*6I~6sMKrKxNp>;*>Zwb6KaiE z(Cz?rC#VCRwu%>Bpx1|f59o@IGXRF8(GVD@RK`rEv)OdQIHBf~e-_K(O2%rqeq6|2 z$LnGc>}L! zhW~1yeNziv{MGr@S1I&ZU;w6fnkHbV7?yY^kit?4{$`4tqD)ClatL6iperror, $edituser->errors, 'errors'); } - // If we are changing our own permissions, we reload + // If we are changing our own permissions, we reload permissions and menu if ($object->id == $user->id) { $user->clearrights(); $user->getrights(); @@ -124,7 +124,7 @@ if (empty($reshook)) { setEventMessages($edituser->error, $edituser->errors, 'errors'); } - // If we are changing our own permissions, we reload + // If we are changing our own permissions, we reload permissions and menu if ($object->id == $user->id) { $user->clearrights(); $user->getrights(); From 685c880e6cd36568f47d16eca15fc413d2c67a85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Apr 2021 14:56:47 +0200 Subject: [PATCH 455/618] Debug module workstation --- htdocs/core/lib/functions.lib.php | 10 +- htdocs/core/modules/modWorkstation.class.php | 4 +- htdocs/install/upgrade2.php | 2 + .../workstation/class/workstation.class.php | 4 +- htdocs/workstation/workstation_agenda.php | 2 +- htdocs/workstation/workstation_card.php | 6 +- htdocs/workstation/workstation_document.php | 2 +- htdocs/workstation/workstation_list.php | 91 +++++++++++-------- htdocs/workstation/workstation_note.php | 2 +- 9 files changed, 71 insertions(+), 52 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d22aa0d40e2..3cca19ba0ff 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3525,7 +3525,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'object_recruitmentjobposition', 'object_recruitmentcandidature', 'object_salary', 'object_shipment', 'object_share-alt', 'object_supplier_invoice', 'object_supplier_invoicea', 'object_supplier_invoiced', 'object_supplier_order', 'object_supplier_proposal', 'object_service', 'object_stock', 'object_technic', 'object_ticket', 'object_trip', 'object_user', 'object_group', 'object_member', - 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', 'object_movement', + 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', 'object_movement', 'object_workstation', 'off', 'on', 'order', 'paiment', 'play', 'pdf', 'phone', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'stock', 'resize', 'service', 'stats', 'trip', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', @@ -3537,7 +3537,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'recruitmentcandidature', 'recruitmentjobposition', 'resource', 'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', - 'user-cog', 'website', + 'user-cog', 'website', 'workstation', 'conferenceorbooth', 'eventorganization' ))) { $pictowithouttext = str_replace('object_', '', $pictowithouttext); @@ -3585,7 +3585,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'title_agenda'=>'calendar-alt', 'uparrow'=>'share', 'vcard'=>'address-card', 'jabber'=>'comment-o', - 'website'=>'globe-americas', + 'website'=>'globe-americas', 'workstation'=>'pallet', 'conferenceorbooth'=>'chalkboard-teacher', 'eventorganization'=>'project-diagram' ); if ($pictowithouttext == 'off') { @@ -3619,7 +3619,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (in_array($pictowithouttext, array('dollyrevert', 'member', 'members', 'contract', 'group', 'resource', 'shipment'))) { $morecss = 'em092'; } - if (in_array($pictowithouttext, array('conferenceorbooth', 'collab', 'eventorganization', 'holiday', 'project'))) { + if (in_array($pictowithouttext, array('conferenceorbooth', 'collab', 'eventorganization', 'holiday', 'project', 'workstation'))) { $morecss = 'em088'; } if (in_array($pictowithouttext, array('intervention', 'info', 'payment', 'loan', 'stock', 'technic'))) { @@ -3676,7 +3676,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'other'=>'#ddd', 'playdisabled'=>'#ccc', 'printer'=>'#444', 'projectpub'=>'#986c6a', 'resize'=>'#444', 'rss'=>'#cba', 'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'timespent'=>'#555', 'uparrow'=>'#555', 'user-cog'=>'#999', 'country'=>'#aaa', 'globe-americas'=>'#aaa', - 'website'=>'#304' + 'website'=>'#304', 'workstation'=>'#a69944' ); if (isset($arrayconvpictotocolor[$pictowithouttext])) { $facolor = $arrayconvpictotocolor[$pictowithouttext]; diff --git a/htdocs/core/modules/modWorkstation.class.php b/htdocs/core/modules/modWorkstation.class.php index 84234a9f6a3..b0fae39bb52 100755 --- a/htdocs/core/modules/modWorkstation.class.php +++ b/htdocs/core/modules/modWorkstation.class.php @@ -50,7 +50,7 @@ class modWorkstation extends DolibarrModules $this->rights_class = 'workstation'; // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' // It is used to group modules by family in module setup page - $this->family = "other"; + $this->family = "products"; // Module position in the family on 2 digits ('01', '10', '20', ...) $this->module_position = '90'; // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) @@ -71,7 +71,7 @@ class modWorkstation extends DolibarrModules // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'mrp'; + $this->picto = 'workstation'; // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( // Set this to 1 if module has its own trigger directory (core/triggers) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 32959af80cc..0db923b138f 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -456,6 +456,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $listofmodule = array( 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', 'MAIN_MODULE_AGENDA'=>'newboxdefonly', + 'MAIN_MODULE_BOM'=>'menuonly', 'MAIN_MODULE_BANQUE'=>'menuonly', 'MAIN_MODULE_BARCODE'=>'newboxdefonly', 'MAIN_MODULE_CRON'=>'newboxdefonly', @@ -470,6 +471,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', 'MAIN_MODULE_MARGIN'=>'menuonly', + 'MAIN_MODULE_MRP'=>'menuonly', 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', 'MAIN_MODULE_PRINTING'=>'newboxdefonly', diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index 07edb353aa4..b4364a2cc82 100755 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -61,7 +61,7 @@ class Workstation extends CommonObject /** * @var string String with name of icon for workstation. Must be the part after the 'object_' into object_workstation.png */ - public $picto = 'mrp'; + public $picto = 'workstation'; const STATUS_DISABLED = 0; @@ -100,7 +100,7 @@ class Workstation extends CommonObject */ public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'varchar(128)', 'picto'=>'mrp', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'noteditable'=>'0', 'default'=>'', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'noteditable'=>'0', 'default'=>'', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'showoncombobox'=>'1',), 'type' => array('type'=>'select', 'label'=>'Type', 'enabled'=>'1', 'position'=>32, 'default'=>1, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('HUMAN'=>'Human', 'MACHINE'=>'Machine', 'BOTH'=>'HumanMachine'),), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), diff --git a/htdocs/workstation/workstation_agenda.php b/htdocs/workstation/workstation_agenda.php index 324e640702b..420bf8b9051 100755 --- a/htdocs/workstation/workstation_agenda.php +++ b/htdocs/workstation/workstation_agenda.php @@ -85,7 +85,7 @@ if ($id > 0 || !empty($ref)) { $permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php // Security check -restrictedArea($user, $object->element, $object->id); +restrictedArea($user, $object->element, $object->id, '', 'workstation'); /* diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index 5d0d92c7cb0..8f351523ecb 100755 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -83,7 +83,7 @@ $permissiondellink = $user->rights->workstation->workstation->write; // Used by $upload_dir = $conf->workstation->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check -restrictedArea($user, $object->element, $object->id); +restrictedArea($user, $object->element, $object->id, '', 'workstation'); /* @@ -212,7 +212,7 @@ if ($action == 'create') { print ''; print ''; print img_picto('', 'group'); - print $form->select_dolgroups($groups, 'groups', 1, '', 0, '', '', $object->entity, true); + print $form->select_dolgroups($groups, 'groups', 1, '', 0, '', '', $object->entity, true, 'minwidth200'); print ''; print ''; @@ -220,7 +220,7 @@ if ($action == 'create') { print ''; print ''; print img_picto('', 'resource'); - print $formresource->select_resource_list($resources, 'resources', '', '', 0, '', '', $object->entity, true, 0, '', true); + print $formresource->select_resource_list($resources, 'resources', '', '', 0, '', '', $object->entity, true, 0, 'minwidth200', true); print ''; // Other attributes diff --git a/htdocs/workstation/workstation_document.php b/htdocs/workstation/workstation_document.php index 324546a9647..2deb06579b8 100755 --- a/htdocs/workstation/workstation_document.php +++ b/htdocs/workstation/workstation_document.php @@ -77,7 +77,7 @@ if ($id > 0 || !empty($ref)) { $permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php // Security check -restrictedArea($user, $object->element, $object->id); +restrictedArea($user, $object->element, $object->id, '', 'workstation'); /* diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 2d8b371cd52..40265496dbf 100755 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -28,9 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; - -// load workstation libraries -require_once __DIR__.'/class/workstation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; // Load translation files required by the page $langs->loadLangs(array("workstation", "other")); @@ -87,8 +85,9 @@ foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha') !== '') { $search[$key] = GETPOST('search_'.$key, 'alpha'); } - if (in_array($key, array('type', 'status')) && GETPOST('search_'.$key, 'alpha') == -1) { - $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); + $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); } } @@ -108,7 +107,7 @@ $arrayfields = array(); foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { - $visible = dol_eval($val['visible'], 1); + $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( 'label'=>$val['label'], 'checked'=>(($visible < 0) ? 0 : 1), @@ -146,7 +145,7 @@ $permissiontoadd = $user->rights->workstation->workstation->write; $permissiontodelete = $user->rights->workstation->workstation->delete; // Security check -restrictedArea($user, $object->element, 0); +restrictedArea($user, $object->element, 0, '', 'workstation'); /* @@ -154,7 +153,8 @@ restrictedArea($user, $object->element, 0); */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -174,6 +174,10 @@ if (empty($reshook)) { 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 foreach ($object->fields as $key => $val) { $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } } $groups=$resources=array(); $toselect = ''; @@ -203,19 +207,15 @@ $formresource = new FormResource($db); $now = dol_now(); $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Workstations")); - -//$help_url="EN:Module_Workstation|FR:Module_Workstation_FR|ES:Módulo_Workstation"; $help_url = 'EN:Module_Workstation'; - -llxHeader('', $title, $help_url); +$morejs = array(); +$morecss = array(); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) { - $sql .= 't.'.$key.', '; -} +$sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -247,18 +247,32 @@ if ($object->ismultientitymanaged == 1) { $sql .= " WHERE 1 = 1"; } foreach ($search as $key => $val) { - if ($key == 'status' && $search[$key] == -1) { - continue; - } - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') { - $search[$key] = ''; + if (array_key_exists($key, $object->fields)) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0)) { + if ($search[$key] == '-1' || $search[$key] === '0') { + $search[$key] = ''; + } + $mode_search = 2; + } + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } + } else { + if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { + $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); + if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { + if (preg_match('/_dtstart$/', $key)) { + $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'"; + } + if (preg_match('/_dtend$/', $key)) { + $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + } + } } - $mode_search = 2; - } - if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } } if ($search_all) { @@ -283,10 +297,8 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -/* If a group by is required $sql.= " GROUP BY "; -foreach($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $sql.='t.'.$key.', '; } // Add fields from extrafields @@ -295,11 +307,9 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { } // Add where from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/','', $sql); -*/ -$sql.= ' GROUP BY t.rowid'; +$sql=preg_replace('/,\s*$/', '', $sql); $sql .= $db->order($sortfield, $sortorder); // Count total nb of records @@ -341,7 +351,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -llxHeader('', $title, $help_url); +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); // Example : Adding jquery code print ''; + jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() { + setRadioForTypeOfInvoice(); + }); + function setRadioForTypeOfInvoice() { + console.log("Change radio"); + if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) { + jQuery(".checkforselect").prop("disabled", true); + jQuery(".checkforselect").prop("checked", false); + } else { + jQuery(".checkforselect").prop("disabled", false); + jQuery(".checkforselect").prop("checked", true); + } + }; + }); + '; - $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); - print '
    '; + $tmp = $tmp.''; + $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); + print ''; + print ''; if (($origin == 'propal') || ($origin == 'commande')) { - print ''; + print ''; - print '
    '; print $desc; print ''; - $arraylist = array('amount' => $langs->transnoentitiesnoconv('FixAmount', $langs->transnoentitiesnoconv('Deposit')), 'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit'))); - print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1); + print ''; + $arraylist = array( + 'amount' => $langs->transnoentitiesnoconv('FixAmount', $langs->transnoentitiesnoconv('Deposit')), + 'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit')), + 'variablealllines' => $langs->transnoentitiesnoconv('VarAmountAllLines') + ); + print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit', 'aZ09'), 0, 0, 0, '', 1); + print ''; + print ''.$langs->trans("AmountOrPercent").''; print '' . $langs->trans('Value') . ':'; } - print '
    '; + print '
    '; print '
    '; } } - */ /* Not yet supported for supplier if ($societe->id > 0) @@ -2340,10 +2533,68 @@ if ($action == 'create') { } // Confirmation set paid - if ($action == 'paid') { + if ($action == 'paid' && $resteapayer <= 0) { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', 0, 1); } + if ($action == 'paid' && $resteapayer > 0) { + $close = array(); + // Code + $i = 0; + $close[$i]['code'] = 'discount_vat'; // escompte + $i++; + $close[$i]['code'] = 'badsupplier'; + $i++; + $close[$i]['code'] = 'other'; + $i++; + // Help + $i = 0; + $close[$i]['label'] = $langs->trans("HelpEscompte").'

    '.$langs->trans("ConfirmClassifyPaidPartiallyReasonDiscountVatDesc"); + $i++; + $close[$i]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadSupplierDesc"); + $i++; + $close[$i]['label'] = $langs->trans("Other"); + $i++; + // Text + $i = 0; + $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1); + $i++; + $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1); + $i++; + $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("Other"), $close[$i]['label'], 1); + $i++; + // arrayreasons[code]=reason + foreach ($close as $key => $val) { + $arrayreasons[$close[$key]['code']] = $close[$key]['reason']; + } + + // Create a form table + $formquestion = array('text' => $langs->trans("ConfirmClassifyPaidPartiallyQuestion"), array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'morecss' => 'minwidth300')); + // Incomplete payment. We ask if the reason is discount or other + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidPartially', $object->ref), 'confirm_paid_partially', $formquestion, "yes", 1, 310); + } + + // Confirmation of the abandoned classification + if ($action == 'canceled') { + // Code + $close[1]['code'] = 'badsupplier'; + $close[2]['code'] = 'abandon'; + // Help + $close[1]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadSupplierDesc"); + $close[2]['label'] = $langs->trans("ConfirmClassifyAbandonReasonOtherDesc"); + // Text + $close[1]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadSupplier", $object->ref), $close[1]['label'], 1); + $close[2]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyAbandonReasonOther"), $close[2]['label'], 1); + // arrayreasons + $arrayreasons[$close[1]['code']] = $close[1]['reason']; + $arrayreasons[$close[2]['code']] = $close[2]['reason']; + + // Create a form table + $formquestion = array('text' => $langs->trans("ConfirmCancelBillQuestion"), array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'morecss' => 'minwidth300')); + + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('CancelBill'), $langs->trans('ConfirmCancelBill', $object->ref), 'confirm_canceled', $formquestion, "yes", 1, 250); + } + // Confirmation de la suppression de la facture fournisseur if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1); @@ -3109,9 +3360,9 @@ if ($action == 'create') { $ventilExportCompta = $object->getVentilExportCompta(); // Should be 0 since the sum of payments are zero. But we keep the protection. if ($ventilExportCompta == 0) { - print ''; + print ''.$langs->trans('Modify').''; } else { - print '
    '.$langs->trans('Modify').'
    '; + print ''.$langs->trans('Modify').''; } } @@ -3120,15 +3371,29 @@ if ($action == 'create') { // Reopen a standard paid invoice if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT - || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id))) + || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id)) + || ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discount->id))) && ($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED)) { // A paid invoice (partially or completely) if (!$facidnext && $object->close_code != 'replaced' && $usercancreate) { // Not replaced by another invoice - print ''; + print ''.$langs->trans('ReOpen').''; } else { if ($usercancreate) { - print '
    '.$langs->trans('ReOpen').'
    '; + print ''.$langs->trans('ReOpen').''; } elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { - print '
    '.$langs->trans('ReOpen').'
    '; + print ''.$langs->trans('ReOpen').''; + } + } + } + + // Validate + if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_DRAFT) { + if (count($object->lines)) { + if ($usercanvalidate) { + print ''.$langs->trans('Validate').''; + } else { + print ''.$langs->trans('Validate').''; } } } @@ -3137,24 +3402,16 @@ if ($action == 'create') { if (empty($user->socid)) { if (($object->statut == FactureFournisseur::STATUS_VALIDATED || $object->statut == FactureFournisseur::STATUS_CLOSED)) { if ($usercansend) { - print ''; + print ''.$langs->trans('SendMail').''; } else { - print '
    '.$langs->trans('SendMail').'
    '; + print ''.$langs->trans('SendMail').''; } } } - // Make payments - if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { - print ''; // must use facid because id is for payment id not invoice - } - - // Classify paid - if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { - print ''; - - //print ''.$langs->trans('ClassifyPaid').''; + // Create payment + if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0) { + print ''.$langs->trans('DoPayment').''; // must use facid because id is for payment id not invoice } // Reverse back money or convert to reduction @@ -3162,37 +3419,43 @@ if ($action == 'create') { // For credit note only if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0) { if ($resteapayer == 0) { - print '
    '.$langs->trans('DoPaymentBack').'
    '; + print ''.$langs->trans('DoPaymentBack').''; } else { - print ''; + print ''.$langs->trans('DoPaymentBack').''; } } // For standard invoice with excess paid if ($object->type == FactureFournisseur::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id)) { - print ''; + print ''.$langs->trans('ConvertExcessPaidToReduc').''; } // For credit note if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate && (!empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) ) { - print ''; + print ''.$langs->trans('ConvertToReduc').''; } // For deposit invoice - if ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 1 && $resteapayer == 0 && $usercancreate && empty($discount->id)) { - print ''; + if ($object->type == FactureFournisseur::TYPE_DEPOSIT && $usercancreate && $object->statut > 0 && empty($discount->id)) { + print ''.$langs->trans('ConvertToReduc').''; } } - // Validate - if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_DRAFT) { - if (count($object->lines)) { - if ($usercanvalidate) { - print ''; - } else { - print ''; + // Classify paid + if (($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && (($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $resteapayer >= 0))) + || ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && empty($discount->id)) + ) { + print ''.$langs->trans('ClassifyPaid').''; + } + + // Classify 'closed not completely paid' (possible if validated and not yet filed paid) + if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0) { + if ($totalpaye > 0 || $totalcreditnotes > 0) { + // If one payment or one credit note was linked to this invoice + print ''.$langs->trans('ClassifyPaidPartially').''; + } else { + if (empty($conf->global->INVOICE_CAN_NEVER_BE_CANCELED)) { + print ''.$langs->trans('ClassifyCanceled').''; } } } @@ -3203,34 +3466,34 @@ if ($action == 'create') { print ''; }*/ - // Clone - if ($action != 'edit' && $usercancreate) { - print ''; - } - // Create a credit note if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_DEPOSIT) && $object->statut > 0 && $usercancreate) { if (!$objectidnext) { - print ''; + print ''.$langs->trans("CreateCreditNote").''; } } + // Clone + if ($action != 'edit' && $usercancreate) { + print 'socid.'">'.$langs->trans('ToClone').''; + } + // Delete $isErasable = $object->is_erasable(); if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($usercancreate && $isErasable == 1))) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) //var_dump($isErasable); if ($isErasable == -4) { - print ''; + print ''.$langs->trans('Delete').''; } elseif ($isErasable == -3) { // Should never happen with supplier invoice - print ''; + print ''.$langs->trans('Delete').''; } elseif ($isErasable == -2) { // Should never happen with supplier invoice - print ''; + print ''.$langs->trans('Delete').''; } elseif ($isErasable == -1) { - print ''; + print ''.$langs->trans('Delete').''; } elseif ($isErasable <= 0) { // Any other cases - print ''; + print ''.$langs->trans('Delete').''; } else { - print ''; + print ''.$langs->trans('Delete').''; } } print '
    '; diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 1988fd5c294..d4cb021cf75 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -365,3 +365,6 @@ ALTER TABLE llx_product ADD COLUMN batch_mask VARCHAR(32) NULL; insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (210, 'conferenceorbooth', 'internal', 'MANAGER', 'Conference or Booth manager', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (211, 'conferenceorbooth', 'external', 'SPEAKER', 'Conference Speaker', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (212, 'conferenceorbooth', 'external', 'RESPONSIBLE', 'Booth responsible', 1); + +ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL after date_valid; +ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid; diff --git a/htdocs/install/mysql/tables/llx_facture_fourn.sql b/htdocs/install/mysql/tables/llx_facture_fourn.sql index ef7e980b8aa..e5e78f87028 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn.sql @@ -1,8 +1,9 @@ -- =========================================================================== --- Copyright (C) 2001-2003 Rodolphe Quiedeville --- Copyright (C) 2007-2017 Laurent Destailleur --- Copyright (C) 2007-2012 Regis Houssin --- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2001-2003 Rodolphe Quiedeville +-- Copyright (C) 2007-2017 Laurent Destailleur +-- Copyright (C) 2007-2012 Regis Houssin +-- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2021 Alexandre Spangaro -- -- 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 @@ -32,10 +33,11 @@ create table llx_facture_fourn fk_soc integer NOT NULL, datec datetime, -- date de creation de la facture - datef date, -- date de la facture + datef date, -- date invoice date_pointoftax date DEFAULT NULL, -- date point of tax (for GB) date_valid date, -- date validation tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- last modification date + date_closing datetime, -- date closing libelle varchar(255), paye smallint DEFAULT 0 NOT NULL, amount double(24,8) DEFAULT 0 NOT NULL, @@ -57,14 +59,15 @@ create table llx_facture_fourn fk_user_author integer, -- user making creation fk_user_modif integer, -- user making last change fk_user_valid integer, -- user validating + fk_user_closing integer, -- user closing fk_facture_source integer, -- facture origine si facture avoir fk_projet integer, -- projet auquel est associee la facture fk_account integer, -- bank account - fk_cond_reglement integer, -- condition de reglement (30 jours, fin de mois ...) - fk_mode_reglement integer, -- mode de reglement (CHQ, VIR, ...) - date_lim_reglement date, -- date limite de reglement + fk_cond_reglement integer, -- condition de reglement (30 jours, fin de mois ...) + fk_mode_reglement integer, -- mode de reglement (CHQ, VIR, ...) + date_lim_reglement date, -- date limite de reglement note_private text, note_public text, From 30d26c1e28fed821f424b57fd52fab77e045e952 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 6 Apr 2021 07:20:07 +0000 Subject: [PATCH 476/618] Fixing style errors. --- htdocs/fourn/facture/card.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 5e13d8bb917..45d31b7aa0e 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1964,11 +1964,9 @@ if ($action == 'create') { print $desc; print '
    '; - if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) - { + if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) { // Deposit - Down payment - if (empty($conf->global->INVOICE_DISABLE_DEPOSIT)) - { + if (empty($conf->global->INVOICE_DISABLE_DEPOSIT)) { print '
    '; $tmp=' '; print ''; + print ''.$langs->trans('AutofillWithExpected').''; + } print '
    '; print '
    '; print ''; @@ -603,13 +617,13 @@ if ($object->id > 0) { print ''; } - print ''; + print ''; print $obj->qty_stock; print ''; print ''; if ($object->status == $object::STATUS_VALIDATED) { $qty_view = GETPOST("id_".$obj->rowid) ? GETPOST("id_".$obj->rowid) : $obj->qty_view; - print ''; + print ''; print ''; print ''; print ''.img_delete().''; From 843882c7c799dbe62216fcce89615a1f93b73fae Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 7 Apr 2021 12:46:51 +0200 Subject: [PATCH 526/618] update stock.lang --- htdocs/langs/en_US/stocks.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 4d1713266f6..b3f01b00cf7 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -254,4 +254,4 @@ ReOpen=Reopen ConfirmFinish=Do you confirm the closing of the inventory ? This will generate all stock movements to update your stock. ObjectNotFound=%s not found MakeMovementsAndClose=Generate movements and close -AutofillWithExpected=Auto-fill with real quantity expected quantity \ No newline at end of file +AutofillWithExpected=Auto-fill expected quantity with real quantity \ No newline at end of file From efb88936fd6ff74cb3942e08795602fc7d0b9c29 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 12:49:52 +0200 Subject: [PATCH 527/618] Update llx_10_c_regions.sql Greece --- .../install/mysql/data/llx_10_c_regions.sql | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 7d370bf0bd0..40e9aca2407 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -63,6 +63,7 @@ -- Colombie -> for Departmements -- France -- Germany -> for Departmements +-- Greece @@ -159,19 +160,19 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 5 -- Greece Regions (id_country=102) -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10201, 102, NULL, NULL, 'Αττική', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10202, 102, NULL, NULL, 'Στερεά Ελλάδα', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10203, 102, NULL, NULL, 'Κεντρική Μακεδονία', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10204, 102, NULL, NULL, 'Κρήτη', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10205, 102, NULL, NULL, 'Ανατολική Μακεδονία και Θράκη', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10206, 102, NULL, NULL, 'Ήπειρος', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10207, 102, NULL, NULL, 'Ιόνια νησιά', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10208, 102, NULL, NULL, 'Βόρειο Αιγαίο', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10209, 102, NULL, NULL, 'Πελοπόννησος', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10210, 102, NULL, NULL, 'Νότιο Αιγαίο', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10211, 102, NULL, NULL, 'Δυτική Ελλάδα', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10212, 102, NULL, NULL, 'Θεσσαλία', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10213, 102, NULL, NULL, 'Δυτική Μακεδονία', 1); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10201, NULL, NULL, 'Αττική'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10202, NULL, NULL, 'Στερεά Ελλάδα'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10203, NULL, NULL, 'Κεντρική Μακεδονία'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10204, NULL, NULL, 'Κρήτη'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10205, NULL, NULL, 'Ανατολική Μακεδονία και Θράκη'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10206, NULL, NULL, 'Ήπειρος'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10207, NULL, NULL, 'Ιόνια νησιά'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10208, NULL, NULL, 'Βόρειο Αιγαίο'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10209, NULL, NULL, 'Πελοπόννησος'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10210, NULL, NULL, 'Νότιο Αιγαίο'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10211, NULL, NULL, 'Δυτική Ελλάδα'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10212, NULL, NULL, 'Θεσσαλία'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10213, NULL, NULL, 'Δυτική Μακεδονία'); -- Regions Italy (id country=3) @@ -196,6 +197,7 @@ insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 31 insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 319, NULL, 1, 'Valle d Aosta'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 320, NULL, 1, 'Veneto'); + -- Regions Spain (id country=4) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 401, '', 0, 'Andalucia', 1); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 402, '', 0, 'Aragón', 1); From 7be9a98ef03e770f912f5d00392ed675740333ed Mon Sep 17 00:00:00 2001 From: Florent Peyraud Date: Wed, 7 Apr 2021 13:51:08 +0200 Subject: [PATCH 528/618] Add bill tax code article for non profit organization VAT --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 6 +++++- htdocs/langs/fr_FR/bills.lang | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 1d3211407c5..1203943ab91 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1025,7 +1025,11 @@ class pdf_crabe extends ModelePDFFactures if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); + if ($mysoc->forme_juridique_code == 92) { + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoiceAsso"), 0, 'L', 0); + } else { + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); + } $posy = $pdf->GetY() + 4; } diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index b5588c21df3..342924e1680 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -464,6 +464,7 @@ PaymentByChequeOrderedToShort=Règlement TTC par chèque à l'ordre de SendTo=envoyé à PaymentByTransferOnThisBankAccount=Règlement par virement sur le compte bancaire suivant VATIsNotUsedForInvoice=* TVA non applicable art-293B du CGI +VATIsNotUsedForInvoiceAsso=* TVA non applicable art-261-7 du CGI LawApplicationPart1=Par application de la loi 80.335 du 12/05/80 LawApplicationPart2=les marchandises demeurent la propriété du LawApplicationPart3=vendeur jusqu'à complet encaissement de From c06cc6d75aaa1cd449e64ea24199167435cae1d0 Mon Sep 17 00:00:00 2001 From: kamel Date: Wed, 7 Apr 2021 17:28:13 +0200 Subject: [PATCH 529/618] NEW : Add new permok for edit extrafields on contact card --- htdocs/core/tpl/extrafields_view.tpl.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 9f77eaca415..d1613cee7e9 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -182,6 +182,9 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] if ($object->element == 'mo') { $permok = $user->rights->mrp->write; } + if ($object->element == 'contact') { + $permok = $user->rights->societe->contact->creer; + } $isdraft = ((isset($object->statut) && $object->statut == 0) || (isset($object->status) && $object->status == 0)); if (($isdraft || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$tmpkeyextra])) From 87d4e6e2c5209d380c386a1d32be2e8810726286 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Apr 2021 19:07:22 +0200 Subject: [PATCH 530/618] Add option API_DISABLE_LOGIN_API --- htdocs/api/class/api_login.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index b9666269cc1..5209cc51157 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -58,7 +58,11 @@ class Login { global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; - // TODO Remove the API login. The token must be generated from backoffice only. + // Is the login API disabled ? The token must be generated from backoffice only. + if (! empty($conf->global->API_DISABLE_LOGIN_API)) { + dol_syslog("Warning: A try to use the login API has been done while the login API is disabled. You must generate or get the token from the backoffice.", LOG_WARNING); + throw new RestException(403, "Error, the login API has been disabled for security purpose. You must generate or get the token from the backoffice."); + } // Authentication mode if (empty($dolibarr_main_authentication)) { @@ -87,7 +91,7 @@ class Login } include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $login = checkLoginPassEntity($login, $password, $entity, $authmode, 'api'); + $login = checkLoginPassEntity($login, $password, $entity, $authmode, 'api'); // Check credentials. if (empty($login)) { throw new RestException(403, 'Access denied'); } From 2d6eb2809ca7076a17f88c203fde701fe13a00b3 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 19:08:41 +0200 Subject: [PATCH 531/618] Create index.html --- htdocs/mrp/ajax/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/mrp/ajax/index.html diff --git a/htdocs/mrp/ajax/index.html b/htdocs/mrp/ajax/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/mrp/ajax/index.html @@ -0,0 +1 @@ + From 49a6654b58c5ee2d6610f5825169563b7dd5e752 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 19:09:16 +0200 Subject: [PATCH 532/618] Create index.html --- htdocs/mrp/class/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/mrp/class/index.html diff --git a/htdocs/mrp/class/index.html b/htdocs/mrp/class/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/mrp/class/index.html @@ -0,0 +1 @@ + From 2d6bbf1e87dea94d118edb731c39ca7befa48d64 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 19:10:13 +0200 Subject: [PATCH 533/618] Create index.html --- htdocs/mrp/js/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/mrp/js/index.html diff --git a/htdocs/mrp/js/index.html b/htdocs/mrp/js/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/mrp/js/index.html @@ -0,0 +1 @@ + From 2fd18ca836d9681e73d2ae2ae897ed0162ca95cf Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 19:12:04 +0200 Subject: [PATCH 534/618] Create index.html --- htdocs/mrp/tpl/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/mrp/tpl/index.html diff --git a/htdocs/mrp/tpl/index.html b/htdocs/mrp/tpl/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/mrp/tpl/index.html @@ -0,0 +1 @@ + From 3315bf6c00d51422c439db9118c646aa24e29203 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Apr 2021 19:16:07 +0200 Subject: [PATCH 535/618] Add samples to show how to setup fail2ban --- .../web-dolibarr-rulesbruteforce.conf | 20 +++++++++++++ .../web-dolibarr-rulespassforgotten.conf | 20 +++++++++++++ dev/setup/fail2ban/jail.local | 28 +++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 dev/setup/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf create mode 100644 dev/setup/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf create mode 100644 dev/setup/fail2ban/jail.local diff --git a/dev/setup/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf b/dev/setup/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf new file mode 100644 index 00000000000..d5922909ba9 --- /dev/null +++ b/dev/setup/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf @@ -0,0 +1,20 @@ +# Fail2Ban configuration file +# +# Regexp to catch known spambots and software alike. Please verify +# that it is your intent to block IPs which were driven by +# above mentioned bots. + + +[Definition] + +# To test, you can inject this example into log +# echo `date +'%Y-%m-%d %H:%M:%S'`" INFO 1.2.3.4 functions_dolibarr::check_user_password_abcd Authentication KO" >> /mypath/documents/dolibarr.log +# +# then +# fail2ban-client status web-dol-bruteforce +# +# To test rule file on a existing log file +# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf + +failregex = ^ [A-Z\s]+ \s+functions_dolibarr::check_user_password_.* Authentication KO +ignoreregex = diff --git a/dev/setup/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf b/dev/setup/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf new file mode 100644 index 00000000000..edc2ca68092 --- /dev/null +++ b/dev/setup/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf @@ -0,0 +1,20 @@ +# Fail2Ban configuration file +# +# Regexp to catch known spambots and software alike. Please verify +# that it is your intent to block IPs which were driven by +# above mentioned bots. + + +[Definition] + +# To test, you can inject this example into log +# echo `date +'%Y-%m-%d %H:%M:%S'`" INFO 1.2.3.4 --- Access to GET /passwordforgotten.php - action=buildnewpassword, massaction=" >> /mypath/documents/dolibarr.log +# +# then +# fail2ban-client status web-dol-passforgotten +# +# To test rule file on a existing log file +# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf + +failregex = ^ [A-Z\s]+ \s+--- Access to .*/passwordforgotten.php - action=buildnewpassword +ignoreregex = diff --git a/dev/setup/fail2ban/jail.local b/dev/setup/fail2ban/jail.local new file mode 100644 index 00000000000..bd506e20812 --- /dev/null +++ b/dev/setup/fail2ban/jail.local @@ -0,0 +1,28 @@ +# +# Examle of rule you can add to fail2ban to restrict bruteforce attacks. +# + +[web-dol-passforgotten] + +; rule against call of passwordforgottenpage +enabled = true +port = http,https +filter = web-dolibarr-rulespassforgotten +logpath = >> /mypath/documents/documents/dolibarr.log +action = %(action_mw)s +bantime = 4320000 ; 50 days +findtime = 86400 ; 1 day +maxretry = 10 + +[web-dol-bruteforce] + +; rule against bruteforce hacking (login + api) +enabled = true +port = http,https +filter = web-dolibarr-rulesbruteforce +logpath = >> /mypath/documents/documents/dolibarr.log +action = %(action_mw)s +bantime = 86400 ; 1 day +findtime = 3600 ; 1 hour +maxretry = 10 + From a144ae147f8e7e6c50edb5073930cef129766bb3 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 19:36:13 +0200 Subject: [PATCH 536/618] Create index.html --- htdocs/fourn/js/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/fourn/js/index.html diff --git a/htdocs/fourn/js/index.html b/htdocs/fourn/js/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/fourn/js/index.html @@ -0,0 +1 @@ + From 1e1b963ca74785f3b07d83f89b978d34fcbd7f2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Apr 2021 19:38:54 +0200 Subject: [PATCH 537/618] Restriction on name of files --- htdocs/admin/system/filecheck.php | 16 +++++++++++----- htdocs/core/boxes/box_external_rss.php | 1 + htdocs/core/modules/modExternalRss.class.php | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index cb7c9667757..e6e95872c91 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -78,10 +78,10 @@ print '
    '; $file_list = array('missing' => array(), 'updated' => array()); // Local file to compare to -$xmlshortfile = GETPOST('xmlshortfile', 'alpha') ?GETPOST('xmlshortfile', 'alpha') : '/install/filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX) ? '' : $conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml'.(empty($conf->global->MAIN_FILECHECK_LOCAL_EXT) ? '' : $conf->global->MAIN_FILECHECK_LOCAL_EXT); -$xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; +$xmlshortfile = dol_sanitizeFileName(GETPOST('xmlshortfile', 'alpha') ? GETPOST('xmlshortfile', 'alpha') : 'filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX) ? '' : $conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml'.(empty($conf->global->MAIN_FILECHECK_LOCAL_EXT) ? '' : $conf->global->MAIN_FILECHECK_LOCAL_EXT)); +$xmlfile = DOL_DOCUMENT_ROOT.'/install/'.$xmlshortfile; // Remote file to compare to -$xmlremote = GETPOST('xmlremote'); +$xmlremote = GETPOST('xmlremote', 'alphanohtml'); if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) { $xmlremote = $conf->global->MAIN_FILECHECK_URL; } @@ -92,7 +92,13 @@ if (empty($xmlremote) && !empty($conf->global->$param)) { if (empty($xmlremote)) { $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; } - +if ($xmlremote && !preg_match('/^https?:\/\//', $xmlremote)) { +} +if ($xmlremote && !preg_match('/^https?:\/\//', $xmlremote)) { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorURLMustStartWithHttp", $xmlremote), '', 'errors'); + $error++; +} // Test if remote test is ok $enableremotecheck = true; @@ -147,7 +153,7 @@ if (GETPOST('target') == 'local') { } $xml = simplexml_load_file($xmlfile); } else { - print $langs->trans('XmlNotFound').': '.$xmlfile; + print '
    '.$langs->trans('XmlNotFound').': '.$xmlfile.''; $error++; } } diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index d85f0a3f44b..7bf8a69ed03 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -77,6 +77,7 @@ class box_external_rss extends ModeleBoxes $this->max = $max; // On recupere numero de param de la boite + $reg = array(); preg_match('/^([0-9]+) /', $this->paramdef, $reg); $site = $reg[1]; diff --git a/htdocs/core/modules/modExternalRss.class.php b/htdocs/core/modules/modExternalRss.class.php index 6ca023a65a8..d7710687ca6 100644 --- a/htdocs/core/modules/modExternalRss.class.php +++ b/htdocs/core/modules/modExternalRss.class.php @@ -100,6 +100,7 @@ class modExternalRss extends DolibarrModules $result = $this->db->query($sql); if ($result) { while ($obj = $this->db->fetch_object($result)) { + $reg = array(); if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i', $obj->name, $reg)) { // Definie la boite si on a trouvee une ancienne configuration //$this->boxes[$reg[1]][0] = "(ExternalRSSInformations)"; From 6fce28e7d0dc4c980a1b60d78a2554e9a4dee211 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 19:39:29 +0200 Subject: [PATCH 538/618] Create index.html --- htdocs/modulebuilder/template/admin/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/modulebuilder/template/admin/index.html diff --git a/htdocs/modulebuilder/template/admin/index.html b/htdocs/modulebuilder/template/admin/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/admin/index.html @@ -0,0 +1 @@ + From c910fb7594825a7d8d5195a6907b6a44fd7686dc Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 19:40:46 +0200 Subject: [PATCH 539/618] Create index.html --- htdocs/modulebuilder/template/class/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/modulebuilder/template/class/index.html diff --git a/htdocs/modulebuilder/template/class/index.html b/htdocs/modulebuilder/template/class/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/class/index.html @@ -0,0 +1 @@ + From c9c7a5574895af25dd3bab03048c8af1b0204680 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 19:42:11 +0200 Subject: [PATCH 540/618] Create index.html --- htdocs/modulebuilder/template/js/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/modulebuilder/template/js/index.html diff --git a/htdocs/modulebuilder/template/js/index.html b/htdocs/modulebuilder/template/js/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/js/index.html @@ -0,0 +1 @@ + From 6d8bbaeeaedab5b9eadaae382e7530d8c341d24e Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 19:42:47 +0200 Subject: [PATCH 541/618] Create index.html --- htdocs/modulebuilder/template/lib/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/modulebuilder/template/lib/index.html diff --git a/htdocs/modulebuilder/template/lib/index.html b/htdocs/modulebuilder/template/lib/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/lib/index.html @@ -0,0 +1 @@ + From 2f349146ed5e46d027640b512f0d3044c805c9a5 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 19:44:39 +0200 Subject: [PATCH 542/618] Create index.html --- htdocs/modulebuilder/template/sql/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/modulebuilder/template/sql/index.html diff --git a/htdocs/modulebuilder/template/sql/index.html b/htdocs/modulebuilder/template/sql/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/sql/index.html @@ -0,0 +1 @@ + From e5764fa304abd31c21525d74fb1efcfa5516d837 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 20:21:45 +0200 Subject: [PATCH 543/618] Update .gitattributes *.json text eol=lf *.yml text eol=lf --- .gitattributes | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitattributes b/.gitattributes index d1002263778..de9ce3303a9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,12 +11,14 @@ *.htm text eol=lf *.html text eol=lf *.js text eol=lf +*.json text eol=lf *.css text eol=lf *.lang text eol=lf *.txt text eol=lf *.md text eol=lf *.pp text eol=lf *.sh text eol=lf +*.yml text eol=lf *.yaml text eol=lf *.conf text eol=lf @@ -24,15 +26,16 @@ # Denote all files that are truly binary and should not be modified. *.bmp binary -*.ico binary -*.png binary -*.jpg binary -*.jpeg binary -*.odt binary -*.odf binary *.frm binary +*.ico binary +*.jpeg binary +*.jpg binary *.MYD binary *.MYI binary +*.odf binary +*.odt binary +*.png binary + # Export ignores to generate clean production tarballs /build export-ignore From baf8c47ceb3dd3d2d965bc29d59060a0b952d1cf Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 7 Apr 2021 20:48:49 +0200 Subject: [PATCH 544/618] Create index.html --- htdocs/projet/ajax/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/projet/ajax/index.html diff --git a/htdocs/projet/ajax/index.html b/htdocs/projet/ajax/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/projet/ajax/index.html @@ -0,0 +1 @@ + From 6c4f5b851d68c5ab726f6c5e3e9299d2b8d3af60 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Apr 2021 23:31:16 +0200 Subject: [PATCH 545/618] Use all param of getURLContent --- htdocs/admin/system/filecheck.php | 2 +- htdocs/core/lib/geturl.lib.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index e6e95872c91..ab42039b98a 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -158,7 +158,7 @@ if (GETPOST('target') == 'local') { } } if (GETPOST('target') == 'remote') { - $xmlarray = getURLContent($xmlremote); + $xmlarray = getURLContent($xmlremote, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') { diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index d624e2e0ace..435f02f1da0 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -190,6 +190,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $info = curl_getinfo($ch); // Reading of request must be done after sending request $http_code = $info['http_code']; + if ($followlocation && ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307)) { $newUrl = $info['redirect_url']; $maxRedirection--; From 59c8e70fd27ea37af226ef57c15ed15f53629c5a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Apr 2021 23:43:10 +0200 Subject: [PATCH 546/618] Fix #yogosha4510 --- htdocs/admin/modules.php | 2 +- htdocs/admin/system/filecheck.php | 2 -- htdocs/api/class/api_setup.class.php | 10 +++++++--- htdocs/core/class/openid.class.php | 4 ++-- htdocs/core/lib/website.lib.php | 4 ++-- .../class/price_global_variable_updater.class.php | 2 +- htdocs/website/index.php | 6 +++--- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 9b9fcdea1fd..fbe1ae98619 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -897,7 +897,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { if (!empty($conf->global->CHECKLASTVERSION_EXTERNALMODULE)) { // This is a bad practice to activate a synch external access during building of a page. 1 external module can hang the application. require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; if (!empty($objMod->url_last_version)) { - $newversion = getURLContent($objMod->url_last_version); + $newversion = getURLContent($objMod->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only if (isset($newversion['content'])) { if (version_compare($newversion['content'], $versiontrans) > 0) { print " ".$newversion['content'].""; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index ab42039b98a..3869c37ce7d 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -92,8 +92,6 @@ if (empty($xmlremote) && !empty($conf->global->$param)) { if (empty($xmlremote)) { $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; } -if ($xmlremote && !preg_match('/^https?:\/\//', $xmlremote)) { -} if ($xmlremote && !preg_match('/^https?:\/\//', $xmlremote)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorURLMustStartWithHttp", $xmlremote), '', 'errors'); diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 064fb6ad359..0029d0fd110 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1647,8 +1647,8 @@ class Setup extends DolibarrApi $file_list = array('missing' => array(), 'updated' => array()); // Local file to compare to - $xmlshortfile = GETPOST('xmlshortfile') ?GETPOST('xmlshortfile') : '/install/filelist-'.DOL_VERSION.'.xml'; - $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; + $xmlshortfile = dol_sanitizeFileName(GETPOST('xmlshortfile', 'alpha') ? GETPOST('xmlshortfile', 'alpha') : 'filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX) ? '' : $conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml'.(empty($conf->global->MAIN_FILECHECK_LOCAL_EXT) ? '' : $conf->global->MAIN_FILECHECK_LOCAL_EXT)); + $xmlfile = DOL_DOCUMENT_ROOT.'/install/'.$xmlshortfile; // Remote file to compare to $xmlremote = ($target == 'default' ? '' : $target); if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) { @@ -1661,6 +1661,10 @@ class Setup extends DolibarrApi if (empty($xmlremote)) { $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; } + if ($xmlremote && !preg_match('/^https?:\/\//', $xmlremote)) { + $langs->load("errors"); + throw new RestException(500, $langs->trans("ErrorURLMustStartWithHttp", $xmlremote)); + } if ($target == 'local') { if (dol_is_file($xmlfile)) { @@ -1669,7 +1673,7 @@ class Setup extends DolibarrApi throw new RestException(500, $langs->trans('XmlNotFound').': '.$xmlfile); } } else { - $xmlarray = getURLContent($xmlremote); + $xmlarray = getURLContent($xmlremote, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') { diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index 5156e7b767a..abb006969db 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -405,7 +405,7 @@ class SimpleOpenID $url = $conf->global->MAIN_AUTHENTICATION_OPENID_URL; } - $response = getURLContent($url); + $response = getURLContent($url, 'GET', '', 1, array(), array('http', 'https')); list($servers, $delegates) = $this->HTML2OpenIDServer($response); if (count($servers) == 0) { @@ -525,7 +525,7 @@ class SimpleOpenID dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS get XRDS'); $addheaders = array('Accept: application/xrds+xml'); - $response = getURLContent($url, 'GET', '', 1, $addheaders); + $response = getURLContent($url, 'GET', '', 1, $addheaders, array('http', 'https'), 0); /* response should like this: diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index bf3b9f3dd07..4fa0f053236 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -1023,7 +1023,7 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify if (empty($alreadygrabbed[$urltograbbis])) { if ($grabimages) { - $tmpgeturl = getURLContent($urltograbbis); + $tmpgeturl = getURLContent($urltograbbis, 'GET', '', 1, array(), array('http', 'https'), 0); if ($tmpgeturl['curl_error_no']) { $error++; setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); @@ -1094,7 +1094,7 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify if (empty($alreadygrabbed[$urltograbbis])) { if ($grabimages) { - $tmpgeturl = getURLContent($urltograbbis); + $tmpgeturl = getURLContent($urltograbbis, 'GET', '', 1, array(), array('http', 'https'), 0); if ($tmpgeturl['curl_error_no']) { $error++; setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index 96e77d661ab..172c004a2d7 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -487,7 +487,7 @@ class PriceGlobalVariableUpdater if ($this->type == 0) { // Call JSON request include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - $tmpresult = getURLContent($url); + $tmpresult = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 0); $code = $tmpresult['http_code']; $result = $tmpresult['content']; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 26ca6df9bf8..86c50a22247 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -680,7 +680,7 @@ if ($action == 'addcontainer' && $usercanedit) { } if (!$error) { - $tmp = getURLContent($urltograb); + $tmp = getURLContent($urltograb, 'GET', '', 1, array(), array('http', 'https'), 0); if ($tmp['curl_error_no']) { $error++; setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors'); @@ -795,7 +795,7 @@ if ($action == 'addcontainer' && $usercanedit) { } /* - $tmpgeturl = getURLContent($urltograbbis); + $tmpgeturl = getURLContent($urltograbbis, 'GET', '', 1, array(), array('http', 'https'), 0); if ($tmpgeturl['curl_error_no']) { $error++; @@ -860,7 +860,7 @@ if ($action == 'addcontainer' && $usercanedit) { continue; } - $tmpgeturl = getURLContent($urltograbbis); + $tmpgeturl = getURLContent($urltograbbis, 'GET', '', 1, array(), array('http', 'https'), 0); if ($tmpgeturl['curl_error_no']) { $errorforsubresource++; setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); From 626f252ed8652a7de2e29103d4f18386f1a29b46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 00:33:25 +0200 Subject: [PATCH 547/618] FIX #yogosha5828 --- htdocs/core/lib/security.lib.php | 2 +- htdocs/user/class/api_users.class.php | 135 +++++++++++++++++++------- 2 files changed, 99 insertions(+), 38 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index b6b71f6d8a6..1b6aa0aa544 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -534,7 +534,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f /** * Check access by user to object. - * This function is also called by restrictedArea + * This function is also called by restrictedArea that check before if module is enabled and permissions of user compared to $action. * * @param User $user User to check * @param array $featuresarray Features/modules to check. Example: ('user','service','member','project','task',...) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 803b517a354..0923cf1e7bd 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -30,7 +30,6 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; class Users extends DolibarrApi { /** - * * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( @@ -71,12 +70,12 @@ class Users extends DolibarrApi { global $db, $conf; - $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->user->user->lire) { throw new RestException(401, "You are not allowed to read list of users"); } + $obj_ret = array(); + // case of external user, $societe param is ignored and replaced by user's socid //$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe; @@ -150,9 +149,10 @@ class Users extends DolibarrApi */ public function get($id, $includepermissions = 0) { - //if (!DolibarrApiAccess::$user->rights->user->user->lire) { - //throw new RestException(401); - //} + if (empty(DolibarrApiAccess::$user->rights->user->user->lire)) { + throw new RestException(401, 'Not allowed'); + } + if ($id == 0) { $result = $this->useraccount->initAsSpecimen(); } else { @@ -187,9 +187,9 @@ class Users extends DolibarrApi */ public function getByLogin($login, $includepermissions = 0) { - //if (!DolibarrApiAccess::$user->rights->user->user->lire) { - //throw new RestException(401); - //} + if (empty(DolibarrApiAccess::$user->rights->user->user->lire)) { + throw new RestException(401, 'Not allowed'); + } $result = $this->useraccount->fetch('', $login); if (!$result) { @@ -221,9 +221,9 @@ class Users extends DolibarrApi */ public function getByEmail($email, $includepermissions = 0) { - //if (!DolibarrApiAccess::$user->rights->user->user->lire) { - //throw new RestException(401); - //} + if (empty(DolibarrApiAccess::$user->rights->user->user->lire)) { + throw new RestException(401, 'Not allowed'); + } $result = $this->useraccount->fetch('', '', '', 0, -1, $email); if (!$result) { @@ -242,18 +242,22 @@ class Users extends DolibarrApi } /** - * Get properties of user connected + * Get more properties of a user * * @url GET /info * - * @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 + * @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 401 Insufficient rights * @throws RestException 404 User or group not found */ public function getInfo($includepermissions = 0) { + if (empty(DolibarrApiAccess::$user->rights->user->user->lire)) { + throw new RestException(401, 'Not allowed'); + } + $apiUser = DolibarrApiAccess::$user; $result = $this->useraccount->fetch($apiUser->id); @@ -285,13 +289,16 @@ class Users extends DolibarrApi * * @param array $request_data New user data * @return int + * + * @throws RestException 401 Not allowed */ public function post($request_data = null) { - // check user authorization - //if(! DolibarrApiAccess::$user->rights->user->creer) { - // throw new RestException(401, "User creation not allowed"); - //} + // Check user authorization + if (empty(DolibarrApiAccess::$user->rights->user->creer)) { + throw new RestException(401, "User creation not allowed"); + } + // check mandatory fields /*if (!isset($request_data["login"])) throw new RestException(400, "login field missing"); @@ -299,9 +306,23 @@ class Users extends DolibarrApi throw new RestException(400, "password field missing"); if (!isset($request_data["lastname"])) throw new RestException(400, "lastname field missing");*/ + //assign field values foreach ($request_data as $field => $value) { - $this->useraccount->$field = $value; + if (in_array($field, array('pass_crypted', 'pass_indatabase', 'pass_indatabase_crypted', 'pass_temp', 'api_key'))) { + // This properties can't be set/modified with API + throw new RestException(401, 'The property '.$field." can't be set/modified using the APIs"); + continue; + } + /*if ($field == 'pass') { + if (empty(DolibarrApiAccess::$user->rights->user->user->password)) { + throw new RestException(401, 'You are not allowed to modify/set password of other users'); + continue; + } + } + */ + + $this->useraccount->$field = $value; } if ($this->useraccount->create(DolibarrApiAccess::$user) < 0) { @@ -312,7 +333,7 @@ class Users extends DolibarrApi /** - * Update account + * Update user account * * @param int $id Id of account to update * @param array $request_data Datas @@ -324,9 +345,10 @@ class Users extends DolibarrApi */ public function put($id, $request_data = null) { - //if (!DolibarrApiAccess::$user->rights->user->user->creer) { - //throw new RestException(401); - //} + // Check user authorization + if (empty(DolibarrApiAccess::$user->rights->user->creer)) { + throw new RestException(401, "User update not allowed"); + } $result = $this->useraccount->fetch($id); if (!$result) { @@ -341,6 +363,30 @@ class Users extends DolibarrApi if ($field == 'id') { continue; } + if (in_array($field, array('pass_crypted', 'pass_indatabase', 'pass_indatabase_crypted', 'pass_temp', 'api_key'))) { + // This properties can't be set/modified with API + throw new RestException(401, 'The property '.$field." can't be set/modified using the APIs"); + continue; + } + if ($field == 'pass') { + if ($this->useraccount->id != DolibarrApiAccess::$user->id && empty(DolibarrApiAccess::$user->rights->user->user->password)) { + throw new RestException(401, 'You are not allowed to modify password of other users'); + continue; + } + if ($this->useraccount->id == DolibarrApiAccess::$user->id && empty(DolibarrApiAccess::$user->rights->user->self->password)) { + throw new RestException(401, 'You are not allowed to modify your own password'); + continue; + } + } + if (DolibarrApiAccess::$user->admin) { // If user for API is admin + if ($field == 'admin' && $value != $this->useraccount->admin && empty($value)) { + throw new RestException(401, 'Reseting the admin status of a user is not possible using the API'); + } + } else { + if ($field == 'admin' && $value != $this->useraccount->admin) { + throw new RestException(401, 'Only an admin user can modify the admin status of another user'); + } + } // The status must be updated using setstatus() because it // is not handled by the update() method. if ($field == 'statut') { @@ -376,12 +422,12 @@ class Users extends DolibarrApi */ public function getGroups($id) { - $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->user->user->lire) { throw new RestException(403); } + $obj_ret = array(); + $user = new User($this->db); $result = $user->fetch($id); if (!$result) { @@ -406,16 +452,20 @@ class Users extends DolibarrApi * @param int $entity Entity ID (valid only for superadmin in multicompany transverse mode) * @return int 1 if success * + * @throws RestException 401 Not allowed + * @throws RestException 404 User not found + * @throws RestException 500 Error + * * @url GET {id}/setGroup/{group} */ public function setGroup($id, $group, $entity = 1) { - global $conf; - //if (!DolibarrApiAccess::$user->rights->user->user->supprimer) { - //throw new RestException(401); - //} + if (empty(DolibarrApiAccess::$user->rights->user->user->creer)) { + throw new RestException(401); + } + $result = $this->useraccount->fetch($id); if (!$result) { throw new RestException(404, 'User not found'); @@ -455,6 +505,9 @@ class Users extends DolibarrApi * @param string $group_ids Groups ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of User objects + * + * @throws RestException 404 User not found + * @throws RestException 503 Error */ public function listGroups($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $group_ids = 0, $sqlfilters = '') { @@ -462,8 +515,9 @@ class Users extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->user->group_advance->read) { - throw new RestException(401, "You are not allowed to read list of groups"); + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty(DolibarrApiAccess::$user->rights->user->user->lire)) || + !empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty(DolibarrApiAccess::$user->rights->user->group_advance->read)) { + throw new RestException(401, "You are not allowed to read groups"); } // case of external user, $societe param is ignored and replaced by user's socid @@ -527,12 +581,16 @@ class Users extends DolibarrApi * @param int $group ID of group * @param int $load_members Load members list or not {@min 0} {@max 1} * @return array Array of User objects + * + * @throws RestException 401 Not allowed + * @throws RestException 404 User not found */ public function infoGroups($group, $load_members = 0) { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->user->group_advance->read) { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty(DolibarrApiAccess::$user->rights->user->user->lire)) || + !empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty(DolibarrApiAccess::$user->rights->user->group_advance->read)) { throw new RestException(401, "You are not allowed to read groups"); } @@ -547,16 +605,19 @@ class Users extends DolibarrApi } /** - * Delete account + * Delete account/user * * @param int $id Account ID * @return array + * + * @throws RestException 401 Not allowed + * @throws RestException 404 User not found */ public function delete($id) { - //if (!DolibarrApiAccess::$user->rights->user->user->supprimer) { - //throw new RestException(401); - //} + if (empty(DolibarrApiAccess::$user->rights->user->user->supprimer)) { + throw new RestException(401, 'Not allowed'); + } $result = $this->useraccount->fetch($id); if (!$result) { throw new RestException(404, 'User not found'); From 489cff46a37b04784d8e884af7fc2ad623bee17d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 00:33:25 +0200 Subject: [PATCH 548/618] FIX #yogosha5828 --- htdocs/core/lib/security.lib.php | 2 +- htdocs/user/class/api_users.class.php | 138 +++++++++++++++++++------- 2 files changed, 102 insertions(+), 38 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index b6b71f6d8a6..1b6aa0aa544 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -534,7 +534,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f /** * Check access by user to object. - * This function is also called by restrictedArea + * This function is also called by restrictedArea that check before if module is enabled and permissions of user compared to $action. * * @param User $user User to check * @param array $featuresarray Features/modules to check. Example: ('user','service','member','project','task',...) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 803b517a354..871e04450b3 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -30,7 +30,6 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; class Users extends DolibarrApi { /** - * * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( @@ -71,12 +70,12 @@ class Users extends DolibarrApi { global $db, $conf; - $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->user->user->lire) { throw new RestException(401, "You are not allowed to read list of users"); } + $obj_ret = array(); + // case of external user, $societe param is ignored and replaced by user's socid //$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe; @@ -150,9 +149,10 @@ class Users extends DolibarrApi */ public function get($id, $includepermissions = 0) { - //if (!DolibarrApiAccess::$user->rights->user->user->lire) { - //throw new RestException(401); - //} + if (empty(DolibarrApiAccess::$user->rights->user->user->lire)) { + throw new RestException(401, 'Not allowed'); + } + if ($id == 0) { $result = $this->useraccount->initAsSpecimen(); } else { @@ -187,9 +187,9 @@ class Users extends DolibarrApi */ public function getByLogin($login, $includepermissions = 0) { - //if (!DolibarrApiAccess::$user->rights->user->user->lire) { - //throw new RestException(401); - //} + if (empty(DolibarrApiAccess::$user->rights->user->user->lire)) { + throw new RestException(401, 'Not allowed'); + } $result = $this->useraccount->fetch('', $login); if (!$result) { @@ -221,9 +221,9 @@ class Users extends DolibarrApi */ public function getByEmail($email, $includepermissions = 0) { - //if (!DolibarrApiAccess::$user->rights->user->user->lire) { - //throw new RestException(401); - //} + if (empty(DolibarrApiAccess::$user->rights->user->user->lire)) { + throw new RestException(401, 'Not allowed'); + } $result = $this->useraccount->fetch('', '', '', 0, -1, $email); if (!$result) { @@ -242,18 +242,22 @@ class Users extends DolibarrApi } /** - * Get properties of user connected + * Get more properties of a user * * @url GET /info * - * @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 + * @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 401 Insufficient rights * @throws RestException 404 User or group not found */ public function getInfo($includepermissions = 0) { + if (empty(DolibarrApiAccess::$user->rights->user->user->lire)) { + throw new RestException(401, 'Not allowed'); + } + $apiUser = DolibarrApiAccess::$user; $result = $this->useraccount->fetch($apiUser->id); @@ -285,13 +289,16 @@ class Users extends DolibarrApi * * @param array $request_data New user data * @return int + * + * @throws RestException 401 Not allowed */ public function post($request_data = null) { - // check user authorization - //if(! DolibarrApiAccess::$user->rights->user->creer) { - // throw new RestException(401, "User creation not allowed"); - //} + // Check user authorization + if (empty(DolibarrApiAccess::$user->rights->user->creer)) { + throw new RestException(401, "User creation not allowed"); + } + // check mandatory fields /*if (!isset($request_data["login"])) throw new RestException(400, "login field missing"); @@ -299,9 +306,23 @@ class Users extends DolibarrApi throw new RestException(400, "password field missing"); if (!isset($request_data["lastname"])) throw new RestException(400, "lastname field missing");*/ + //assign field values foreach ($request_data as $field => $value) { - $this->useraccount->$field = $value; + if (in_array($field, array('pass_crypted', 'pass_indatabase', 'pass_indatabase_crypted', 'pass_temp', 'api_key'))) { + // This properties can't be set/modified with API + throw new RestException(401, 'The property '.$field." can't be set/modified using the APIs"); + continue; + } + /*if ($field == 'pass') { + if (empty(DolibarrApiAccess::$user->rights->user->user->password)) { + throw new RestException(401, 'You are not allowed to modify/set password of other users'); + continue; + } + } + */ + + $this->useraccount->$field = $value; } if ($this->useraccount->create(DolibarrApiAccess::$user) < 0) { @@ -312,7 +333,7 @@ class Users extends DolibarrApi /** - * Update account + * Update user account * * @param int $id Id of account to update * @param array $request_data Datas @@ -324,9 +345,10 @@ class Users extends DolibarrApi */ public function put($id, $request_data = null) { - //if (!DolibarrApiAccess::$user->rights->user->user->creer) { - //throw new RestException(401); - //} + // Check user authorization + if (empty(DolibarrApiAccess::$user->rights->user->creer)) { + throw new RestException(401, "User update not allowed"); + } $result = $this->useraccount->fetch($id); if (!$result) { @@ -341,6 +363,33 @@ class Users extends DolibarrApi if ($field == 'id') { continue; } + if (in_array($field, array('pass_crypted', 'pass_indatabase', 'pass_indatabase_crypted', 'pass_temp', 'api_key'))) { + // This properties can't be set/modified with API + throw new RestException(401, 'The property '.$field." can't be set/modified using the APIs"); + continue; + } + if ($field == 'pass') { + if ($this->useraccount->id != DolibarrApiAccess::$user->id && empty(DolibarrApiAccess::$user->rights->user->user->password)) { + throw new RestException(401, 'You are not allowed to modify password of other users'); + continue; + } + if ($this->useraccount->id == DolibarrApiAccess::$user->id && empty(DolibarrApiAccess::$user->rights->user->self->password)) { + throw new RestException(401, 'You are not allowed to modify your own password'); + continue; + } + } + if (DolibarrApiAccess::$user->admin) { // If user for API is admin + if ($field == 'admin' && $value != $this->useraccount->admin && empty($value)) { + throw new RestException(401, 'Reseting the admin status of a user is not possible using the API'); + } + } else { + if ($field == 'admin' && $value != $this->useraccount->admin) { + throw new RestException(401, 'Only an admin user can modify the admin status of another user'); + } + } + if ($field == 'entity' && $value != $this->useraccount->entity) { + throw new RestException(401, 'Changing entity of a user using the APIs is not possible'); + } // The status must be updated using setstatus() because it // is not handled by the update() method. if ($field == 'statut') { @@ -376,12 +425,12 @@ class Users extends DolibarrApi */ public function getGroups($id) { - $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->user->user->lire) { throw new RestException(403); } + $obj_ret = array(); + $user = new User($this->db); $result = $user->fetch($id); if (!$result) { @@ -406,16 +455,20 @@ class Users extends DolibarrApi * @param int $entity Entity ID (valid only for superadmin in multicompany transverse mode) * @return int 1 if success * + * @throws RestException 401 Not allowed + * @throws RestException 404 User not found + * @throws RestException 500 Error + * * @url GET {id}/setGroup/{group} */ public function setGroup($id, $group, $entity = 1) { - global $conf; - //if (!DolibarrApiAccess::$user->rights->user->user->supprimer) { - //throw new RestException(401); - //} + if (empty(DolibarrApiAccess::$user->rights->user->user->creer)) { + throw new RestException(401); + } + $result = $this->useraccount->fetch($id); if (!$result) { throw new RestException(404, 'User not found'); @@ -455,6 +508,9 @@ class Users extends DolibarrApi * @param string $group_ids Groups ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of User objects + * + * @throws RestException 404 User not found + * @throws RestException 503 Error */ public function listGroups($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $group_ids = 0, $sqlfilters = '') { @@ -462,8 +518,9 @@ class Users extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->user->group_advance->read) { - throw new RestException(401, "You are not allowed to read list of groups"); + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty(DolibarrApiAccess::$user->rights->user->user->lire)) || + !empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty(DolibarrApiAccess::$user->rights->user->group_advance->read)) { + throw new RestException(401, "You are not allowed to read groups"); } // case of external user, $societe param is ignored and replaced by user's socid @@ -527,12 +584,16 @@ class Users extends DolibarrApi * @param int $group ID of group * @param int $load_members Load members list or not {@min 0} {@max 1} * @return array Array of User objects + * + * @throws RestException 401 Not allowed + * @throws RestException 404 User not found */ public function infoGroups($group, $load_members = 0) { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->user->group_advance->read) { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty(DolibarrApiAccess::$user->rights->user->user->lire)) || + !empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty(DolibarrApiAccess::$user->rights->user->group_advance->read)) { throw new RestException(401, "You are not allowed to read groups"); } @@ -547,16 +608,19 @@ class Users extends DolibarrApi } /** - * Delete account + * Delete account/user * * @param int $id Account ID * @return array + * + * @throws RestException 401 Not allowed + * @throws RestException 404 User not found */ public function delete($id) { - //if (!DolibarrApiAccess::$user->rights->user->user->supprimer) { - //throw new RestException(401); - //} + if (empty(DolibarrApiAccess::$user->rights->user->user->supprimer)) { + throw new RestException(401, 'Not allowed'); + } $result = $this->useraccount->fetch($id); if (!$result) { throw new RestException(404, 'User not found'); From 3f119c8004732314810d743baed2f2a15150f8dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 01:43:38 +0200 Subject: [PATCH 549/618] Fix eol --- htdocs/accountancy/class/bookkeeping.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index e7c5d106ddf..6220904dbe8 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -200,7 +200,7 @@ class BookKeeping extends CommonObject $error = 0; - // Clean parameters + // Clean parameters if (isset($this->doc_type)) { $this->doc_type = trim($this->doc_type); } @@ -296,7 +296,7 @@ class BookKeeping extends CommonObject $sql .= " WHERE doc_type = '".$this->db->escape($this->doc_type)."'"; $sql .= " AND fk_doc = ".$this->fk_doc; if (!empty($conf->global->ACCOUNTANCY_ENABLE_FKDOCDET)) { - // DO NOT USE THIS IN PRPDUCTION. This will generate a lot of trouble into reports and will corrupt database (by generating duplicate entries. + // DO NOT USE THIS IN PRPDUCTION. This will generate a lot of trouble into reports and will corrupt database (by generating duplicate entries. $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 if record is for several lines } $sql .= " AND numero_compte = '".$this->db->escape($this->numero_compte)."'"; From aef164a7eebe626842e00e882aa83e38cd126b2b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 02:05:36 +0200 Subject: [PATCH 550/618] Fix bad permission --- htdocs/user/class/api_users.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 871e04450b3..e29506db93b 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -295,8 +295,8 @@ class Users extends DolibarrApi public function post($request_data = null) { // Check user authorization - if (empty(DolibarrApiAccess::$user->rights->user->creer)) { - throw new RestException(401, "User creation not allowed"); + if (empty(DolibarrApiAccess::$user->rights->user->user->creer)) { + throw new RestException(401, "User creation not allowed for login ".DolibarrApiAccess::$user->login); } // check mandatory fields From 1ec6317b804a36a20e2ee34876d56b1bdba48932 Mon Sep 17 00:00:00 2001 From: kamel Date: Thu, 8 Apr 2021 10:33:27 +0200 Subject: [PATCH 551/618] FIX : Fix warning (function errorHandler() is not defined in this class so let the class handle the errors) --- htdocs/core/class/smtps.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index ef26dc4ac65..ba8d4349a38 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -392,7 +392,6 @@ class SMTPs } else { if (function_exists('stream_socket_client') && !empty($this->_options)) { $socket_context = stream_context_create($this->_options); // An array of options for stream_context_create() - set_error_handler([$this, 'errorHandler']); $this->socket = @stream_socket_client( preg_replace('@tls://@i', '', $this->getHost()).// Host to 'hit', IP or domain ':'.$this->getPort(), // which Port number to use From 11700f2162135b178b0587131957f7e2a4d3d9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Thu, 8 Apr 2021 13:52:29 +0200 Subject: [PATCH 552/618] Fix Ticket-Module public interface: uppercase/lowercaser in e-mail should be ignored #17186 --- htdocs/public/ticket/list.php | 12 ++++++------ htdocs/public/ticket/view.php | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 0f9542c986a..18bc0e83468 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -51,7 +51,7 @@ $langs->loadLangs(array("companies", "other", "ticket")); // Get parameters $track_id = GETPOST('track_id', 'alpha'); $action = GETPOST('action', 'aZ09'); -$email = GETPOST('email', 'alpha'); +$email = strtolower (GETPOST('email', 'alpha')); if (GETPOST('btn_view_ticket_list')) { unset($_SESSION['track_id_customer']); @@ -61,7 +61,7 @@ if (isset($_SESSION['track_id_customer'])) { $track_id = $_SESSION['track_id_customer']; } if (isset($_SESSION['email_customer'])) { - $email = $_SESSION['email_customer']; + $email = strtolower ($_SESSION['email_customer']); } $object = new Ticket($db); @@ -101,7 +101,7 @@ if ($action == "view_ticketlist") { // vérifie si l'adresse email est bien dans les contacts du ticket $contacts = $object->liste_contact(-1, 'external'); foreach ($contacts as $contact) { - if ($contact['email'] == $email) { + if (strtolower($contact['email']) == $email) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; $_SESSION['track_id_customer'] = $track_id; @@ -112,7 +112,7 @@ if ($action == "view_ticketlist") { } if ($object->fk_soc > 0) { $object->fetch_thirdparty(); - if ($email == $object->thirdparty->email) { + if ($email == strtolower($object->thirdparty->email)) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; $_SESSION['track_id_customer'] = $track_id; @@ -121,14 +121,14 @@ if ($action == "view_ticketlist") { if ($object->fk_user_create > 0) { $tmpuser = new User($db); $tmpuser->fetch($object->fk_user_create); - if ($email == $tmpuser->email) { + if ($email == strtolower($tmpuser->email)) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; $_SESSION['track_id_customer'] = $track_id; } } - $emailorigin = CMailFile::getValidAddress($object->origin_email, 2); + $emailorigin = strtolower(CMailFile::getValidAddress($object->origin_email, 2)); if ($email == $emailorigin) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index 02c7c9e51d8..cde872c56db 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -53,13 +53,13 @@ $langs->loadLangs(array("companies", "other", "ticket")); $track_id = GETPOST('track_id', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $action = GETPOST('action', 'aZ09'); -$email = GETPOST('email', 'alpha'); +$email = strtolower(GETPOST('email', 'alpha')); if (GETPOST('btn_view_ticket')) { unset($_SESSION['email_customer']); } if (isset($_SESSION['email_customer'])) { - $email = $_SESSION['email_customer']; + $email = strtolower($_SESSION['email_customer']); } $object = new ActionsTicket($db); @@ -103,7 +103,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a $ret = $object->fetch('', '', $track_id); if ($ret && $object->dao->id > 0) { // Check if emails provided is the one of author - $emailofticket = CMailFile::getValidAddress($object->dao->origin_email, 2); + $emailofticket = strtolower(CMailFile::getValidAddress($object->dao->origin_email, 2)); if ($emailofticket == $email) { $display_ticket = true; @@ -113,7 +113,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a else { $contacts = $object->dao->liste_contact(-1, 'external'); foreach ($contacts as $contact) { - if ($contact['email'] == $email) { + if (strtolower($contact['email']) == $email) { $display_ticket = true; $_SESSION['email_customer'] = $email; break; @@ -135,7 +135,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a { $tmpuser = new User($db); $tmpuser->fetch($object->dao->fk_user_create); - if ($email == $tmpuser->email) { + if ($email == strtolower($tmpuser->email)) { $display_ticket = true; $_SESSION['email_customer'] = $email; } @@ -145,7 +145,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a { $tmpuser = new User($db); $tmpuser->fetch($object->dao->fk_user_assign); - if ($email == $tmpuser->email) { + if ($email == strtolower($tmpuser->email)) { $display_ticket = true; $_SESSION['email_customer'] = $email; } From 0b1e3ce7e484f8c15ef77793d508b6b908443cf2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 8 Apr 2021 12:15:35 +0000 Subject: [PATCH 553/618] Fixing style errors. --- htdocs/public/ticket/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 18bc0e83468..4c426869239 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -51,7 +51,7 @@ $langs->loadLangs(array("companies", "other", "ticket")); // Get parameters $track_id = GETPOST('track_id', 'alpha'); $action = GETPOST('action', 'aZ09'); -$email = strtolower (GETPOST('email', 'alpha')); +$email = strtolower(GETPOST('email', 'alpha')); if (GETPOST('btn_view_ticket_list')) { unset($_SESSION['track_id_customer']); @@ -61,7 +61,7 @@ if (isset($_SESSION['track_id_customer'])) { $track_id = $_SESSION['track_id_customer']; } if (isset($_SESSION['email_customer'])) { - $email = strtolower ($_SESSION['email_customer']); + $email = strtolower($_SESSION['email_customer']); } $object = new Ticket($db); From f8b5bee9eb0ea24156fb79272b8dde2374651366 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 14:20:59 +0200 Subject: [PATCH 554/618] Add function getListOfPossibleImageExt --- htdocs/core/lib/images.lib.php | 24 ++++++++++++++++++------ htdocs/website/index.php | 8 +++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 4803b5e0770..36e8cef6bfe 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -30,6 +30,23 @@ $maxheightmini = 72; // 16/9eme $quality = 80; +/** + * Return if a filename is file name of a supported image format + * + * @param int $acceptsvg 0=Default (depends on setup), 1=Always accept SVG as image files + * @return string Return list fo image format + */ +function getListOfPossibleImageExt($acceptsvg = 0) +{ + global $conf; + + $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php + if ($acceptsvg || !empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) { + $regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript + } + + return $regeximgext; +} /** * Return if a filename is file name of a supported image format @@ -40,12 +57,7 @@ $quality = 80; */ function image_format_supported($file, $acceptsvg = 0) { - global $conf; - - $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php - if ($acceptsvg || !empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) { - $regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript - } + $regeximgext = getListOfPossibleImageExt(); // Case filename is not a format image $reg = array(); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index fd24f202a1c..405369ce26f 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2230,10 +2230,16 @@ if ($action == 'generatesitemaps' && $usercanedit) { } $action = 'preview'; } + $imagefolder = $conf->website->dir_output.'/'.$websitekey.'/medias/image/'.$websitekey.'/'; + if ($action == 'convertimgwebp' && $usercanedit) { include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $filelist = dol_dir_list($imagefolder, "all", 1); + + $regeximgext = getListOfPossibleImageExt(); + + $filelist = dol_dir_list($imagefolder, "all", 1, $regeximgext); + foreach ($filelist as $filename) { $filepath = $filename['fullname']; if (!(substr_compare($filepath, 'webp', -strlen('webp')) === 0)) { From 539c29b05feaafa25c585d85d170755e60276a64 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Thu, 8 Apr 2021 14:38:43 +0200 Subject: [PATCH 555/618] Update llx_10_c_regions.sql Chile --- .../install/mysql/data/llx_10_c_regions.sql | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 40e9aca2407..2feb15e8436 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -60,6 +60,7 @@ -- Bolivia -- Brazil -> for Departmements -- Canada -> for Departmements +-- Chile -- Colombie -> for Departmements -- France -- Germany -> for Departmements @@ -129,6 +130,24 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 5 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 14, 1401, '', 0, 'Canada'); +-- Chile Regions (id country=67) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6701, NULL, NULL, 'Tarapacá'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6702, NULL, NULL, 'Antofagasta'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6703, NULL, NULL, 'Atacama'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6704, NULL, NULL, 'Coquimbo'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6705, NULL, NULL, 'Valparaíso'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6706, NULL, NULL, 'General Bernardo O Higgins'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6707, NULL, NULL, 'Maule'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6708, NULL, NULL, 'Biobío'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6709, NULL, NULL, 'Raucanía'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6710, NULL, NULL, 'Los Lagos'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6711, NULL, NULL, 'Aysén General Carlos Ibáñez del Campo'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6712, NULL, NULL, 'Magallanes y Antártica Chilena'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6713, NULL, NULL, 'Metropolitana de Santiago'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6714, NULL, NULL, 'Los Ríos'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6715, NULL, NULL, 'Arica y Parinacota'); + + -- Colombie Regions (id country=70) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 70, 7001, '', 0, 'Colombie'); @@ -264,23 +283,6 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) va INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 17, 1701, '', 0,'Provincies van Nederland ', 1); --- Regions Chile (id country=67) -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6701, 67, NULL, NULL, 'Tarapacá', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6702, 67, NULL, NULL, 'Antofagasta', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6703, 67, NULL, NULL, 'Atacama', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6704, 67, NULL, NULL, 'Coquimbo', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6705, 67, NULL, NULL, 'Valparaíso', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6706, 67, NULL, NULL, 'General Bernardo O Higgins', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6707, 67, NULL, NULL, 'Maule', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6708, 67, NULL, NULL, 'Biobío', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6709, 67, NULL, NULL, 'Raucanía', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6710, 67, NULL, NULL, 'Los Lagos', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6711, 67, NULL, NULL, 'Aysén General Carlos Ibáñez del Campo', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6712, 67, NULL, NULL, 'Magallanes y Antártica Chilena', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6713, 67, NULL, NULL, 'Metropolitana de Santiago', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6714, 67, NULL, NULL, 'Los Ríos', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6715, 67, NULL, NULL, 'Arica y Parinacota', 1); - -- Regions San Salvador (id country=86) INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 8601, 86, NULL, NULL, 'Central', 1); INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 8602, 86, NULL, NULL, 'Oriental', 1); From f609d03accae5be563973f1a6df3df1b95acea84 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Thu, 8 Apr 2021 15:24:59 +0200 Subject: [PATCH 556/618] Update llx_20_c_departements.sql Chile --- .../mysql/data/llx_20_c_departements.sql | 114 +++++++++--------- 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index e4256374c13..9675fa126c8 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -45,6 +45,7 @@ -- Belgium -- Brazil -- Canada +-- Chile -- Colombia -- France -- Germany @@ -263,6 +264,63 @@ insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401, 'NL','',1,'','Newfoundland and Labrador'); +-- Chile Provinces (id country=67) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6701, '011', '', 0, '011', 'Iquique'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6701, '014', '', 0, '014', 'Tamarugal'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6702, '021', '', 0, '021', 'Antofagasa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6702, '022', '', 0, '022', 'El Loa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6702, '023', '', 0, '023', 'Tocopilla'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6703, '031', '', 0, '031', 'Copiapó'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6703, '032', '', 0, '032', 'Chañaral'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6703, '033', '', 0, '033', 'Huasco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6704, '041', '', 0, '041', 'Elqui'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6704, '042', '', 0, '042', 'Choapa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6704, '043', '', 0, '043', 'Limarí'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '051', '', 0, '051', 'Valparaíso'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '052', '', 0, '052', 'Isla de Pascua'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '053', '', 0, '053', 'Los Andes'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '054', '', 0, '054', 'Petorca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '055', '', 0, '055', 'Quillota'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '056', '', 0, '056', 'San Antonio'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '057', '', 0, '057', 'San Felipe de Aconcagua'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '058', '', 0, '058', 'Marga Marga'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6706, '061', '', 0, '061', 'Cachapoal'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6706, '062', '', 0, '062', 'Cardenal Caro'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6706, '063', '', 0, '063', 'Colchagua'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6707, '071', '', 0, '071', 'Talca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6707, '072', '', 0, '072', 'Cauquenes'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6707, '073', '', 0, '073', 'Curicó'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6707, '074', '', 0, '074', 'Linares'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6708, '081', '', 0, '081', 'Concepción'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6708, '082', '', 0, '082', 'Arauco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6708, '083', '', 0, '083', 'Biobío'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6708, '084', '', 0, '084', 'Ñuble'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6709, '091', '', 0, '091', 'Cautín'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6709, '092', '', 0, '092', 'Malleco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6710, '101', '', 0, '101', 'Llanquihue'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6710, '102', '', 0, '102', 'Chiloé'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6710, '103', '', 0, '103', 'Osorno'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6710, '104', '', 0, '104', 'Palena'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6711, '111', '', 0, '111', 'Coihaique'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6711, '112', '', 0, '112', 'Aisén'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6711, '113', '', 0, '113', 'Capitán Prat'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6711, '114', '', 0, '114', 'General Carrera'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6712, '121', '', 0, '121', 'Magallanes'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6712, '122', '', 0, '122', 'Antártica Chilena'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6712, '123', '', 0, '123', 'Tierra del Fuego'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6712, '124', '', 0, '124', 'Última Esperanza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '131', '', 0, '131', 'Santiago'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '132', '', 0, '132', 'Cordillera'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '133', '', 0, '133', 'Chacabuco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '134', '', 0, '134', 'Maipo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '135', '', 0, '135', 'Melipilla'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '136', '', 0, '136', 'Talagante'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6714, '141', '', 0, '141', 'Valdivia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6714, '142', '', 0, '142', 'Ranco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6715, '151', '', 0, '151', 'Arica'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6715, '152', '', 0, '152', 'Parinacota'); + + -- Colombia Departamentos (id country=70) INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'ANT', '', 0, 'ANT', 'Antioquia'); INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'BOL', '', 0, 'BOL', 'Bolívar'); @@ -1160,62 +1218,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CU', 8601, '', 0, '', 'Cuscatlan', 1); --- Provinces Chile (id country=67) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('151', 6715, '', 0, '151', 'Arica', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('152', 6715, '', 0, '152', 'Parinacota', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('011', 6701, '', 0, '011', 'Iquique', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('014', 6701, '', 0, '014', 'Tamarugal', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('021', 6702, '', 0, '021', 'Antofagasa', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('022', 6702, '', 0, '022', 'El Loa', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('023', 6702, '', 0, '023', 'Tocopilla', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('031', 6703, '', 0, '031', 'Copiapó', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('032', 6703, '', 0, '032', 'Chañaral', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('033', 6703, '', 0, '033', 'Huasco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('041', 6704, '', 0, '041', 'Elqui', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('042', 6704, '', 0, '042', 'Choapa', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('043', 6704, '', 0, '043', 'Limarí', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('051', 6705, '', 0, '051', 'Valparaíso', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('052', 6705, '', 0, '052', 'Isla de Pascua', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('053', 6705, '', 0, '053', 'Los Andes', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('054', 6705, '', 0, '054', 'Petorca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('055', 6705, '', 0, '055', 'Quillota', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('056', 6705, '', 0, '056', 'San Antonio', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('057', 6705, '', 0, '057', 'San Felipe de Aconcagua', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('058', 6705, '', 0, '058', 'Marga Marga', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('061', 6706, '', 0, '061', 'Cachapoal', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('062', 6706, '', 0, '062', 'Cardenal Caro', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('063', 6706, '', 0, '063', 'Colchagua', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('071', 6707, '', 0, '071', 'Talca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('072', 6707, '', 0, '072', 'Cauquenes', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('073', 6707, '', 0, '073', 'Curicó', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('074', 6707, '', 0, '074', 'Linares', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('081', 6708, '', 0, '081', 'Concepción', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('082', 6708, '', 0, '082', 'Arauco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('083', 6708, '', 0, '083', 'Biobío', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('084', 6708, '', 0, '084', 'Ñuble', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('091', 6709, '', 0, '091', 'Cautín', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('092', 6709, '', 0, '092', 'Malleco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('141', 6714, '', 0, '141', 'Valdivia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('142', 6714, '', 0, '142', 'Ranco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('101', 6710, '', 0, '101', 'Llanquihue', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('102', 6710, '', 0, '102', 'Chiloé', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('103', 6710, '', 0, '103', 'Osorno', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('104', 6710, '', 0, '104', 'Palena', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('111', 6711, '', 0, '111', 'Coihaique', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('112', 6711, '', 0, '112', 'Aisén', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('113', 6711, '', 0, '113', 'Capitán Prat', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('114', 6711, '', 0, '114', 'General Carrera', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('121', 6712, '', 0, '121', 'Magallanes', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('122', 6712, '', 0, '122', 'Antártica Chilena', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('123', 6712, '', 0, '123', 'Tierra del Fuego', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('124', 6712, '', 0, '124', 'Última Esperanza', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('131', 6713, '', 0, '131', 'Santiago', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('132', 6713, '', 0, '132', 'Cordillera', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('133', 6713, '', 0, '133', 'Chacabuco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('134', 6713, '', 0, '134', 'Maipo', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('135', 6713, '', 0, '135', 'Melipilla', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('136', 6713, '', 0, '136', 'Talagante', 1); - -- Provinces India (id country=117) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AN', 11701, NULL, 0, 'AN', 'Andaman & Nicobar', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AP', 11701, NULL, 0, 'AP', 'Andhra Pradesh', 1); From 482b4e808b68f89ebc7755db464f18c6694ef114 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 8 Apr 2021 16:21:50 +0200 Subject: [PATCH 557/618] chnages with eldy's advices --- htdocs/product/inventory/inventory.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 764c1bd78c9..0bdd203caf0 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -468,17 +468,17 @@ if ($object->id > 0) { } if ($permissiontoadd && $conf->use_javascript_ajax) { print ' '; + print ''; print ''; - print ''.$langs->trans('AutofillWithExpected').''; } print '
    '; print '
    '; @@ -623,7 +623,7 @@ if ($object->id > 0) { print ''; if ($object->status == $object::STATUS_VALIDATED) { $qty_view = GETPOST("id_".$obj->rowid) ? GETPOST("id_".$obj->rowid) : $obj->qty_view; - print ''; + print ''; print ''; print ''; print ''.img_delete().''; From 4f413ca9839e77593c2f4cdd9573a69d8980019a Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 8 Apr 2021 16:46:52 +0200 Subject: [PATCH 558/618] add fk_project to warehouse table --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_entrepot.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index d186dc218ee..f2ae6c7d173 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -372,3 +372,5 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL after date_valid; ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid; + +ALTER TABLE llx_entrepot ADD COLUMN fk_project INTEGER DEFAULT NULL AFTER entity; -- project associated to warehouse if any diff --git a/htdocs/install/mysql/tables/llx_entrepot.sql b/htdocs/install/mysql/tables/llx_entrepot.sql index 2a390f008e2..be49978f6b7 100644 --- a/htdocs/install/mysql/tables/llx_entrepot.sql +++ b/htdocs/install/mysql/tables/llx_entrepot.sql @@ -25,6 +25,7 @@ create table llx_entrepot datec datetime, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_project integer DEFAULT NULL, -- project associated to warehouse if any description text, lieu varchar(64), -- resume lieu situation address varchar(255), From d098bf412d5f99480b335ba737ac1c7856486bc9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 17:35:52 +0200 Subject: [PATCH 559/618] Move directory to match the one of composer package for phpspreadsheet --- htdocs/core/modules/export/export_excel2007.modules.php | 2 +- htdocs/core/modules/import/import_xlsx.modules.php | 6 +++--- htdocs/filefunc.inc.php | 2 +- .../src}/PhpSpreadsheet/Calculation/Calculation.php | 0 .../src}/PhpSpreadsheet/Calculation/Category.php | 0 .../src}/PhpSpreadsheet/Calculation/Database.php | 0 .../src}/PhpSpreadsheet/Calculation/DateTime.php | 0 .../Calculation/Engine/CyclicReferenceStack.php | 0 .../src}/PhpSpreadsheet/Calculation/Engine/Logger.php | 0 .../src}/PhpSpreadsheet/Calculation/Engineering.php | 0 .../src}/PhpSpreadsheet/Calculation/Exception.php | 0 .../src}/PhpSpreadsheet/Calculation/ExceptionHandler.php | 0 .../src}/PhpSpreadsheet/Calculation/Financial.php | 0 .../src}/PhpSpreadsheet/Calculation/FormulaParser.php | 0 .../src}/PhpSpreadsheet/Calculation/FormulaToken.php | 0 .../src}/PhpSpreadsheet/Calculation/Functions.php | 0 .../src}/PhpSpreadsheet/Calculation/Logical.php | 0 .../src}/PhpSpreadsheet/Calculation/LookupRef.php | 0 .../src}/PhpSpreadsheet/Calculation/MathTrig.php | 0 .../src}/PhpSpreadsheet/Calculation/Statistical.php | 0 .../src}/PhpSpreadsheet/Calculation/TextData.php | 0 .../src}/PhpSpreadsheet/Calculation/Token/Stack.php | 0 .../src}/PhpSpreadsheet/Calculation/functionlist.txt | 0 .../src}/PhpSpreadsheet/Calculation/locale/bg/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/bg/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/cs/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/cs/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/da/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/da/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/de/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/de/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/en/uk/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/es/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/es/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/fi/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/fi/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/fr/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/fr/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/hu/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/hu/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/it/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/it/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/nl/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/nl/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/no/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/no/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/pl/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/pl/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/pt/br/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/pt/br/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/pt/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/pt/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/ru/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/ru/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/sv/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/sv/functions | 0 .../src}/PhpSpreadsheet/Calculation/locale/tr/config | 0 .../src}/PhpSpreadsheet/Calculation/locale/tr/functions | 0 .../src}/PhpSpreadsheet/Cell/AdvancedValueBinder.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Cell/Cell.php | 0 .../src}/PhpSpreadsheet/Cell/Coordinate.php | 0 .../src}/PhpSpreadsheet/Cell/DataType.php | 0 .../src}/PhpSpreadsheet/Cell/DataValidation.php | 0 .../src}/PhpSpreadsheet/Cell/DataValidator.php | 0 .../src}/PhpSpreadsheet/Cell/DefaultValueBinder.php | 0 .../src}/PhpSpreadsheet/Cell/Hyperlink.php | 0 .../src}/PhpSpreadsheet/Cell/IValueBinder.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Axis.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Chart.php | 0 .../src}/PhpSpreadsheet/Chart/DataSeries.php | 0 .../src}/PhpSpreadsheet/Chart/DataSeriesValues.php | 0 .../src}/PhpSpreadsheet/Chart/Exception.php | 0 .../src}/PhpSpreadsheet/Chart/GridLines.php | 0 .../src}/PhpSpreadsheet/Chart/Layout.php | 0 .../src}/PhpSpreadsheet/Chart/Legend.php | 0 .../src}/PhpSpreadsheet/Chart/PlotArea.php | 0 .../src}/PhpSpreadsheet/Chart/Properties.php | 0 .../src}/PhpSpreadsheet/Chart/Renderer/IRenderer.php | 0 .../src}/PhpSpreadsheet/Chart/Renderer/JpGraph.php | 0 .../Chart/Renderer/PHP Charting Libraries.txt | 0 .../src}/PhpSpreadsheet/Chart/Renderer/Polyfill.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Title.php | 0 .../src}/PhpSpreadsheet/Collection/Cells.php | 0 .../src}/PhpSpreadsheet/Collection/CellsFactory.php | 0 .../src}/PhpSpreadsheet/Collection/Memory.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Comment.php | 0 .../src}/PhpSpreadsheet/Document/Properties.php | 0 .../src}/PhpSpreadsheet/Document/Security.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Exception.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/HashTable.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Helper/Html.php | 0 .../src}/PhpSpreadsheet/Helper/Migrator.php | 0 .../src}/PhpSpreadsheet/Helper/Sample.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/IComparable.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/IOFactory.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/NamedRange.php | 0 .../src}/PhpSpreadsheet/Reader/BaseReader.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Csv.php | 0 .../src}/PhpSpreadsheet/Reader/DefaultReadFilter.php | 0 .../src}/PhpSpreadsheet/Reader/Exception.php | 0 .../src}/PhpSpreadsheet/Reader/Gnumeric.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Html.php | 0 .../src}/PhpSpreadsheet/Reader/IReadFilter.php | 0 .../src}/PhpSpreadsheet/Reader/IReader.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Ods.php | 0 .../src}/PhpSpreadsheet/Reader/Security/XmlScanner.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Slk.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls.php | 0 .../src}/PhpSpreadsheet/Reader/Xls/Color.php | 0 .../src}/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php | 0 .../src}/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php | 0 .../src}/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php | 0 .../src}/PhpSpreadsheet/Reader/Xls/ErrorCode.php | 0 .../src}/PhpSpreadsheet/Reader/Xls/Escher.php | 0 .../src}/PhpSpreadsheet/Reader/Xls/MD5.php | 0 .../src}/PhpSpreadsheet/Reader/Xls/RC4.php | 0 .../src}/PhpSpreadsheet/Reader/Xls/Style/Border.php | 0 .../src}/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xlsx.php | 0 .../src}/PhpSpreadsheet/Reader/Xlsx/Chart.php | 0 .../src}/PhpSpreadsheet/Reader/Xlsx/Theme.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xml.php | 0 .../src}/PhpSpreadsheet/ReferenceHelper.php | 0 .../src}/PhpSpreadsheet/RichText/ITextElement.php | 0 .../src}/PhpSpreadsheet/RichText/RichText.php | 0 .../src}/PhpSpreadsheet/RichText/Run.php | 0 .../src}/PhpSpreadsheet/RichText/TextElement.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Settings.php | 0 .../src}/PhpSpreadsheet/Shared/CodePage.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Date.php | 0 .../src}/PhpSpreadsheet/Shared/Drawing.php | 0 .../src}/PhpSpreadsheet/Shared/Escher.php | 0 .../src}/PhpSpreadsheet/Shared/Escher/DgContainer.php | 0 .../Shared/Escher/DgContainer/SpgrContainer.php | 0 .../Shared/Escher/DgContainer/SpgrContainer/SpContainer.php | 0 .../src}/PhpSpreadsheet/Shared/Escher/DggContainer.php | 0 .../Shared/Escher/DggContainer/BstoreContainer.php | 0 .../Shared/Escher/DggContainer/BstoreContainer/BSE.php | 0 .../Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/File.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Font.php | 0 .../src}/PhpSpreadsheet/Shared/JAMA/CHANGELOG.TXT | 0 .../PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php | 0 .../PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php | 0 .../src}/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php | 0 .../src}/PhpSpreadsheet/Shared/JAMA/Matrix.php | 0 .../src}/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php | 0 .../Shared/JAMA/SingularValueDecomposition.php | 0 .../src}/PhpSpreadsheet/Shared/JAMA/utils/Maths.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/OLE.php | 0 .../src}/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php | 0 .../src}/PhpSpreadsheet/Shared/OLE/PPS.php | 0 .../src}/PhpSpreadsheet/Shared/OLE/PPS/File.php | 0 .../src}/PhpSpreadsheet/Shared/OLE/PPS/Root.php | 0 .../src}/PhpSpreadsheet/Shared/OLERead.php | 0 .../src}/PhpSpreadsheet/Shared/PasswordHasher.php | 0 .../src}/PhpSpreadsheet/Shared/StringHelper.php | 0 .../src}/PhpSpreadsheet/Shared/TimeZone.php | 0 .../src}/PhpSpreadsheet/Shared/Trend/BestFit.php | 0 .../src}/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php | 0 .../src}/PhpSpreadsheet/Shared/Trend/LinearBestFit.php | 0 .../src}/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php | 0 .../src}/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php | 0 .../src}/PhpSpreadsheet/Shared/Trend/PowerBestFit.php | 0 .../src}/PhpSpreadsheet/Shared/Trend/Trend.php | 0 .../src}/PhpSpreadsheet/Shared/XMLWriter.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Xls.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Spreadsheet.php | 0 .../src}/PhpSpreadsheet/Style/Alignment.php | 0 .../src}/PhpSpreadsheet/Style/Border.php | 0 .../src}/PhpSpreadsheet/Style/Borders.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Color.php | 0 .../src}/PhpSpreadsheet/Style/Conditional.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Fill.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Font.php | 0 .../src}/PhpSpreadsheet/Style/NumberFormat.php | 0 .../src}/PhpSpreadsheet/Style/Protection.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Style.php | 0 .../src}/PhpSpreadsheet/Style/Supervisor.php | 0 .../src}/PhpSpreadsheet/Worksheet/AutoFilter.php | 0 .../src}/PhpSpreadsheet/Worksheet/AutoFilter/Column.php | 0 .../PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php | 0 .../src}/PhpSpreadsheet/Worksheet/BaseDrawing.php | 0 .../src}/PhpSpreadsheet/Worksheet/CellIterator.php | 0 .../src}/PhpSpreadsheet/Worksheet/Column.php | 0 .../src}/PhpSpreadsheet/Worksheet/ColumnCellIterator.php | 0 .../src}/PhpSpreadsheet/Worksheet/ColumnDimension.php | 0 .../src}/PhpSpreadsheet/Worksheet/ColumnIterator.php | 0 .../src}/PhpSpreadsheet/Worksheet/Dimension.php | 0 .../src}/PhpSpreadsheet/Worksheet/Drawing.php | 0 .../src}/PhpSpreadsheet/Worksheet/Drawing/Shadow.php | 0 .../src}/PhpSpreadsheet/Worksheet/HeaderFooter.php | 0 .../src}/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php | 0 .../src}/PhpSpreadsheet/Worksheet/Iterator.php | 0 .../src}/PhpSpreadsheet/Worksheet/MemoryDrawing.php | 0 .../src}/PhpSpreadsheet/Worksheet/PageMargins.php | 0 .../src}/PhpSpreadsheet/Worksheet/PageSetup.php | 0 .../src}/PhpSpreadsheet/Worksheet/Protection.php | 0 .../src}/PhpSpreadsheet/Worksheet/Row.php | 0 .../src}/PhpSpreadsheet/Worksheet/RowCellIterator.php | 0 .../src}/PhpSpreadsheet/Worksheet/RowDimension.php | 0 .../src}/PhpSpreadsheet/Worksheet/RowIterator.php | 0 .../src}/PhpSpreadsheet/Worksheet/SheetView.php | 0 .../src}/PhpSpreadsheet/Worksheet/Worksheet.php | 0 .../src}/PhpSpreadsheet/Writer/BaseWriter.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Csv.php | 0 .../src}/PhpSpreadsheet/Writer/Exception.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Html.php | 0 .../src}/PhpSpreadsheet/Writer/IWriter.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Ods.php | 0 .../src}/PhpSpreadsheet/Writer/Ods/Cell/Comment.php | 0 .../src}/PhpSpreadsheet/Writer/Ods/Content.php | 0 .../src}/PhpSpreadsheet/Writer/Ods/Meta.php | 0 .../src}/PhpSpreadsheet/Writer/Ods/MetaInf.php | 0 .../src}/PhpSpreadsheet/Writer/Ods/Mimetype.php | 0 .../src}/PhpSpreadsheet/Writer/Ods/Settings.php | 0 .../src}/PhpSpreadsheet/Writer/Ods/Styles.php | 0 .../src}/PhpSpreadsheet/Writer/Ods/Thumbnails.php | 0 .../src}/PhpSpreadsheet/Writer/Ods/WriterPart.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Pdf.php | 0 .../src}/PhpSpreadsheet/Writer/Pdf/Dompdf.php | 0 .../src}/PhpSpreadsheet/Writer/Pdf/Mpdf.php | 0 .../src}/PhpSpreadsheet/Writer/Pdf/Tcpdf.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xls.php | 0 .../src}/PhpSpreadsheet/Writer/Xls/BIFFwriter.php | 0 .../src}/PhpSpreadsheet/Writer/Xls/Escher.php | 0 .../src}/PhpSpreadsheet/Writer/Xls/Font.php | 0 .../src}/PhpSpreadsheet/Writer/Xls/Parser.php | 0 .../src}/PhpSpreadsheet/Writer/Xls/Workbook.php | 0 .../src}/PhpSpreadsheet/Writer/Xls/Worksheet.php | 0 .../src}/PhpSpreadsheet/Writer/Xls/Xf.php | 0 .../{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/Chart.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/Comments.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/DocProps.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/Drawing.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/Rels.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/StringTable.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/Style.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/Theme.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/Workbook.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 0 .../src}/PhpSpreadsheet/Writer/Xlsx/WriterPart.php | 0 htdocs/install/upgrade2.php | 5 +++++ 247 files changed, 10 insertions(+), 5 deletions(-) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Calculation.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Category.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Database.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/DateTime.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Engine/Logger.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Engineering.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Exception.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/ExceptionHandler.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Financial.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/FormulaParser.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/FormulaToken.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Functions.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Logical.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/LookupRef.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/MathTrig.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Statistical.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/TextData.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/Token/Stack.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/functionlist.txt (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/bg/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/bg/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/cs/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/cs/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/da/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/da/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/de/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/de/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/en/uk/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/es/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/es/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/fi/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/fi/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/fr/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/fr/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/hu/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/hu/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/it/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/it/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/nl/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/nl/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/no/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/no/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/pl/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/pl/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/pt/br/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/pt/br/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/pt/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/pt/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/ru/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/ru/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/sv/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/sv/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/tr/config (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Calculation/locale/tr/functions (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Cell/AdvancedValueBinder.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Cell/Cell.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Cell/Coordinate.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Cell/DataType.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Cell/DataValidation.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Cell/DataValidator.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Cell/DefaultValueBinder.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Cell/Hyperlink.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Cell/IValueBinder.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Axis.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Chart.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/DataSeries.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/DataSeriesValues.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Exception.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/GridLines.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Layout.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Legend.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/PlotArea.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Properties.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Renderer/IRenderer.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Renderer/JpGraph.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Renderer/Polyfill.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Chart/Title.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Collection/Cells.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Collection/CellsFactory.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Collection/Memory.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Comment.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Document/Properties.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Document/Security.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Exception.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/HashTable.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Helper/Html.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Helper/Migrator.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Helper/Sample.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/IComparable.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/IOFactory.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/NamedRange.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/BaseReader.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Csv.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/DefaultReadFilter.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Exception.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Gnumeric.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Html.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/IReadFilter.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/IReader.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Ods.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Security/XmlScanner.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Slk.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls/Color.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls/ErrorCode.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls/Escher.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls/MD5.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls/RC4.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls/Style/Border.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xlsx.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xlsx/Chart.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xlsx/Theme.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Reader/Xml.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/ReferenceHelper.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/RichText/ITextElement.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/RichText/RichText.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/RichText/Run.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/RichText/TextElement.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Settings.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/CodePage.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Date.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Drawing.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Escher.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Escher/DgContainer.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Escher/DggContainer.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/File.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Font.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/JAMA/CHANGELOG.TXT (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/JAMA/Matrix.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/JAMA/utils/Maths.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/OLE.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/OLE/PPS.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/OLE/PPS/File.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/OLE/PPS/Root.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/OLERead.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/PasswordHasher.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/StringHelper.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/TimeZone.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Trend/BestFit.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Trend/LinearBestFit.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Trend/PowerBestFit.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Trend/Trend.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/XMLWriter.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Shared/Xls.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Spreadsheet.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Alignment.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Border.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Borders.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Color.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Conditional.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Fill.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Font.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Style/NumberFormat.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Protection.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Style.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Style/Supervisor.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/AutoFilter.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/AutoFilter/Column.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/BaseDrawing.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/CellIterator.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/Column.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/ColumnCellIterator.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/ColumnDimension.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/ColumnIterator.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/Dimension.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/Drawing.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/Drawing/Shadow.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/HeaderFooter.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/Iterator.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/MemoryDrawing.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/PageMargins.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/PageSetup.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/Protection.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/Row.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/RowCellIterator.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/RowDimension.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/RowIterator.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/SheetView.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Worksheet/Worksheet.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/BaseWriter.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Csv.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Exception.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Html.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/IWriter.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Ods.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Ods/Cell/Comment.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Ods/Content.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Ods/Meta.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Ods/MetaInf.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Ods/Mimetype.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Ods/Settings.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Ods/Styles.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Ods/Thumbnails.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Ods/WriterPart.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Pdf.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Pdf/Dompdf.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Pdf/Mpdf.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Pdf/Tcpdf.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xls.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xls/BIFFwriter.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xls/Escher.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xls/Font.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xls/Parser.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xls/Workbook.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xls/Worksheet.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xls/Xf.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/Chart.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/Comments.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/DocProps.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/Drawing.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/Rels.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/StringTable.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/Style.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/Theme.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/Workbook.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/Worksheet.php (100%) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/PhpSpreadsheet/Writer/Xlsx/WriterPart.php (100%) diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index ed85493f04f..370fc49df7e 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -193,7 +193,7 @@ class ExportExcel2007 extends ModeleExports $outputlangs->load("exports"); - require_once DOL_DOCUMENT_ROOT.'/includes/phpoffice/autoloader.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/phpoffice/phpspreadsheet/src/autoloader.php'; require_once DOL_DOCUMENT_ROOT.'/includes/Psr/autoloader.php'; require_once PHPEXCELNEW_PATH.'Spreadsheet.php'; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index bc146c5ece7..d90a52755e3 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -112,9 +112,9 @@ class ImportXlsx extends ModeleImports $this->picto = 'mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) $this->version = '1.0'; // Driver version // If driver use an external library, put its name here - require_once DOL_DOCUMENT_ROOT . '/includes/phpoffice/autoloader.php'; - require_once DOL_DOCUMENT_ROOT . '/includes/Psr/autoloader.php'; - require_once PHPEXCELNEW_PATH . 'Spreadsheet.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/phpoffice/phpspreadsheet/src/autoloader.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/Psr/autoloader.php'; + require_once PHPEXCELNEW_PATH.'Spreadsheet.php'; $this->workbook = new Spreadsheet(); //if ($this->id == 'excel2007new') diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index aff0ebad349..e479b1430a1 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -298,7 +298,7 @@ if (!defined('NUSOAP_PATH')) { define('NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ? '' : $dolibarr_lib_NUSOAP_PATH.'/')); } if (!defined('PHPEXCELNEW_PATH')) { - define('PHPEXCELNEW_PATH', (!isset($dolibarr_lib_PHPEXCELNEW_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/phpoffice/PhpSpreadsheet/' : (empty($dolibarr_lib_PHPEXCELNEW_PATH) ? '' : $dolibarr_lib_PHPEXCELNEW_PATH.'/')); + define('PHPEXCELNEW_PATH', (!isset($dolibarr_lib_PHPEXCELNEW_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/' : (empty($dolibarr_lib_PHPEXCELNEW_PATH) ? '' : $dolibarr_lib_PHPEXCELNEW_PATH.'/')); } if (!defined('ODTPHP_PATH')) { define('ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ? '' : $dolibarr_lib_ODTPHP_PATH.'/')); diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Calculation.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Calculation.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Category.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Category.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Category.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Category.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Database.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Database.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/DateTime.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTime.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/DateTime.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTime.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engine/Logger.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/Logger.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engine/Logger.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/Logger.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engineering.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engineering.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Exception.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Exception.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Exception.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Exception.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/ExceptionHandler.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/ExceptionHandler.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/ExceptionHandler.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/ExceptionHandler.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Financial.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Financial.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/FormulaParser.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/FormulaParser.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/FormulaParser.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/FormulaParser.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/FormulaToken.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/FormulaToken.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/FormulaToken.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/FormulaToken.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Functions.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Functions.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Functions.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Functions.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Logical.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Logical.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/LookupRef.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/LookupRef.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/MathTrig.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/MathTrig.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Statistical.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Statistical.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/TextData.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/TextData.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Token/Stack.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Token/Stack.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Token/Stack.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Token/Stack.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/functionlist.txt b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/functionlist.txt similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/functionlist.txt rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/functionlist.txt diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/bg/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/bg/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/bg/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/bg/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/bg/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/bg/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/bg/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/bg/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/cs/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/cs/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/cs/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/cs/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/cs/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/cs/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/cs/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/cs/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/da/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/da/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/da/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/da/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/da/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/da/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/da/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/da/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/de/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/de/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/de/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/de/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/de/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/de/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/de/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/de/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/en/uk/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/en/uk/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/en/uk/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/en/uk/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/es/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/es/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/es/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/es/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/es/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/es/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/es/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/es/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fi/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fi/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fi/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fi/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fi/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fi/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fi/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fi/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fr/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fr/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fr/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fr/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fr/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fr/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fr/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fr/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/hu/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/hu/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/hu/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/hu/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/hu/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/hu/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/hu/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/hu/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/it/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/it/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/it/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/it/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/it/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/it/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/it/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/it/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/nl/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nl/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/nl/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nl/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/nl/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nl/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/nl/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nl/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/no/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/no/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/no/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/no/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/no/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/no/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/no/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/no/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pl/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pl/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pl/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pl/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pl/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pl/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pl/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pl/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/br/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/br/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/br/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/br/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/br/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/br/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/br/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/br/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/ru/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/ru/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/ru/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/ru/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/ru/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/ru/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/ru/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/ru/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/sv/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/sv/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/sv/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/sv/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/sv/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/sv/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/sv/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/sv/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/tr/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/tr/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/tr/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/tr/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/tr/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/tr/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/tr/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/tr/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/AdvancedValueBinder.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/AdvancedValueBinder.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Cell.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Cell.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Coordinate.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Coordinate.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataType.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataType.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataType.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataType.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataValidation.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidation.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataValidation.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidation.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataValidator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataValidator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DefaultValueBinder.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DefaultValueBinder.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Hyperlink.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Hyperlink.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Hyperlink.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Hyperlink.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/IValueBinder.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IValueBinder.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/IValueBinder.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IValueBinder.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Axis.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Axis.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Chart.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Chart.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Chart.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Chart.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/DataSeries.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeries.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/DataSeries.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeries.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/DataSeriesValues.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeriesValues.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/DataSeriesValues.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeriesValues.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Exception.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Exception.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Exception.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Exception.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/GridLines.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/GridLines.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Layout.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Layout.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Legend.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Legend.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Legend.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Legend.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/PlotArea.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/PlotArea.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/PlotArea.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/PlotArea.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Properties.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Properties.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Properties.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Properties.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/IRenderer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/IRenderer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/JpGraph.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/JpGraph.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/Polyfill.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/Polyfill.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/Polyfill.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/Polyfill.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Title.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Title.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Title.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Title.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Collection/Cells.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Collection/Cells.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Collection/CellsFactory.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/CellsFactory.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Collection/CellsFactory.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/CellsFactory.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Collection/Memory.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Memory.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Collection/Memory.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Memory.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Comment.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Comment.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Comment.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Comment.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Document/Properties.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Properties.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Document/Properties.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Properties.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Document/Security.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Security.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Document/Security.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Security.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Exception.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Exception.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Exception.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Exception.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/HashTable.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/HashTable.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/HashTable.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/HashTable.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Html.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Html.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Html.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Html.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Migrator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Migrator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Migrator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Migrator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Sample.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Sample.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Sample.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Sample.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/IComparable.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IComparable.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/IComparable.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IComparable.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/IOFactory.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/IOFactory.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/NamedRange.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/NamedRange.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/NamedRange.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/NamedRange.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/BaseReader.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/BaseReader.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Csv.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Csv.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/DefaultReadFilter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/DefaultReadFilter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/DefaultReadFilter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/DefaultReadFilter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Exception.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Exception.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Exception.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Exception.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Gnumeric.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Gnumeric.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Html.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Html.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Html.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Html.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/IReadFilter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReadFilter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/IReadFilter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReadFilter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/IReader.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReader.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/IReader.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReader.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Ods.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Ods.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Security/XmlScanner.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Security/XmlScanner.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Slk.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Slk.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Slk.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Slk.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/ErrorCode.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/ErrorCode.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Escher.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Escher.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Escher.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Escher.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/MD5.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/MD5.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/MD5.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/MD5.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/RC4.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/RC4.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/RC4.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/RC4.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Style/Border.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/Border.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Style/Border.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/Border.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xlsx.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xlsx.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xlsx/Chart.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Chart.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xlsx/Chart.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Chart.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xlsx/Theme.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Theme.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xlsx/Theme.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Theme.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xml.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xml.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/ReferenceHelper.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/ReferenceHelper.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/ReferenceHelper.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/ReferenceHelper.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/RichText/ITextElement.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/ITextElement.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/RichText/ITextElement.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/ITextElement.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/RichText/RichText.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/RichText.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/RichText/RichText.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/RichText.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/RichText/Run.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/Run.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/RichText/Run.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/Run.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/RichText/TextElement.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/TextElement.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/RichText/TextElement.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/TextElement.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Settings.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Settings.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Settings.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Settings.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/CodePage.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/CodePage.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/CodePage.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/CodePage.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Date.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Date.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Date.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Date.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Drawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Drawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Drawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Drawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/File.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/File.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Font.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Font.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Font.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Font.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/CHANGELOG.TXT b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/CHANGELOG.TXT similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/CHANGELOG.TXT rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/CHANGELOG.TXT diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/Matrix.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/Matrix.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/Matrix.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/Matrix.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/utils/Maths.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/utils/Maths.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/utils/Maths.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/utils/Maths.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS/File.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS/File.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS/File.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS/File.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS/Root.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLERead.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLERead.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLERead.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLERead.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/PasswordHasher.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/PasswordHasher.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/PasswordHasher.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/PasswordHasher.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/StringHelper.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/StringHelper.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/StringHelper.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/StringHelper.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/TimeZone.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/TimeZone.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/TimeZone.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/TimeZone.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/BestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/BestFit.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/BestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/BestFit.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/LinearBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/LinearBestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/PowerBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/PowerBestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/Trend.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/Trend.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/Trend.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/Trend.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/XMLWriter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/XMLWriter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/XMLWriter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/XMLWriter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Xls.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Xls.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Xls.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Xls.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Spreadsheet.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Spreadsheet.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Alignment.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Alignment.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Alignment.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Alignment.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Border.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Border.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Border.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Border.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Borders.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Borders.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Borders.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Borders.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Color.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Color.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Color.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Color.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Conditional.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Conditional.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Conditional.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Conditional.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Fill.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Fill.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Fill.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Fill.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Font.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Font.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Font.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Font.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/NumberFormat.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/NumberFormat.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Protection.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Protection.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Protection.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Protection.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Style.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Style.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Style.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Style.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Supervisor.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Supervisor.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Supervisor.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Supervisor.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter/Column.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/BaseDrawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/BaseDrawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/BaseDrawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/BaseDrawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/CellIterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/CellIterator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/CellIterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/CellIterator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Column.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Column.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Column.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Column.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnCellIterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnCellIterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnDimension.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnDimension.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnDimension.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnDimension.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnIterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnIterator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnIterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnIterator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Dimension.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Dimension.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Drawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Drawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Drawing/Shadow.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Drawing/Shadow.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/HeaderFooter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/HeaderFooter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Iterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Iterator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Iterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Iterator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/MemoryDrawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/MemoryDrawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/PageMargins.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageMargins.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/PageMargins.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageMargins.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/PageSetup.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageSetup.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/PageSetup.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageSetup.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Protection.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Protection.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Protection.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Protection.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Row.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Row.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Row.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Row.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowCellIterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowCellIterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowDimension.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowDimension.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowDimension.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowDimension.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowIterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowIterator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowIterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowIterator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/SheetView.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/SheetView.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/SheetView.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/SheetView.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Worksheet.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Worksheet.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/BaseWriter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/BaseWriter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Csv.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Csv.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Csv.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Csv.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Exception.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Exception.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Exception.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Exception.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Html.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Html.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Html.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Html.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/IWriter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/IWriter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/IWriter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/IWriter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Cell/Comment.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Cell/Comment.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Content.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Content.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Content.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Content.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Meta.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Meta.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Meta.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Meta.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/MetaInf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/MetaInf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/MetaInf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/MetaInf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Mimetype.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Mimetype.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Mimetype.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Mimetype.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Settings.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Settings.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Settings.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Settings.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Styles.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Styles.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Styles.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Styles.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Thumbnails.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Thumbnails.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/WriterPart.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/WriterPart.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/WriterPart.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/WriterPart.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Dompdf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Dompdf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Mpdf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Tcpdf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Tcpdf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/BIFFwriter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/BIFFwriter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Escher.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Escher.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Escher.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Escher.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Font.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Font.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Font.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Font.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Parser.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Parser.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Workbook.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Workbook.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Workbook.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Workbook.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Worksheet.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Worksheet.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Xf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Xf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Xf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Xf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Chart.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Chart.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Chart.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Chart.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Comments.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Comments.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Comments.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Comments.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/DocProps.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/DocProps.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Drawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Drawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Rels.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Rels.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Rels.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Rels.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/StringTable.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Style.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Style.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Style.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Style.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Theme.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Theme.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Theme.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Theme.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Workbook.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Worksheet.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/WriterPart.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/WriterPart.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 0db923b138f..23fa3d95a3c 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4098,6 +4098,11 @@ function migrate_delete_old_dir($db, $langs, $conf) DOL_DOCUMENT_ROOT.'/core/modules/facture/mercure', ); + // On linux, we can also removed old directory with a different case than new directory. + if (!empty($_SERVER["WINDIR"])) { + $filetodeletearray[] = DOL_DOCUMENT_ROOT.'/includes/phpoffice/PhpSpreadsheet'; + } + foreach ($filetodeletearray as $filetodelete) { //print ''.$filetodelete."
    \n"; if (file_exists($filetodelete)) { From 04536f9ec8bd641f8e97f8550f1b401fe693c7bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 17:49:13 +0200 Subject: [PATCH 560/618] Fix import --- htdocs/imports/import.php | 25 +++++++++++-------- .../{ => phpspreadsheet/src}/autoloader.php | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) rename htdocs/includes/phpoffice/{ => phpspreadsheet/src}/autoloader.php (81%) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index f484e3b0901..0783e6352a4 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -492,12 +492,16 @@ if ($step == 2 && $datatoimport) { print ''; print ''; + print '
    '; + print ''; $s = $langs->trans("ChooseFormatOfFileToImport", '{s1}'); $s = str_replace('{s1}', img_picto('', 'next'), $s); print $s; print '

    '; + print '
    '; + print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; @@ -513,7 +517,9 @@ if ($step == 2 && $datatoimport) { print ''; $text = $objmodelimport->getDriverDescForKey($key); print ''; - print ''; + print ''; // Action button print '
    '.img_picto_common($key, $objmodelimport->getPictoForKey($key)).''.$form->textwithpicto($objmodelimport->getDriverLabelForKey($key), $text).''.$langs->trans("DownloadEmptyExample").''; + print img_picto('', 'download', 'class="paddingright opacitymedium"').''.$langs->trans("DownloadEmptyExample").''; + print ''; print ''.img_picto($langs->trans("SelectFormat"), 'next', 'class="fa-15x"').''; @@ -587,7 +593,7 @@ if ($step == 3 && $datatoimport) { print '
    '; print '
    '; - print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', ''); + print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', 'file-export'); print '
    '; print '
    '; @@ -598,8 +604,8 @@ if ($step == 3 && $datatoimport) { print ''; $text = $objmodelimport->getDriverDescForKey($format); print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text); - print ''.$langs->trans("DownloadEmptyExample").''; - + print ''; + print img_picto('', 'download', 'class="paddingright opacitymedium"').''.$langs->trans("DownloadEmptyExample").''; print ''; print ''; @@ -890,7 +896,7 @@ if ($step == 4 && $datatoimport) { print ''; print '
    '; - print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', ''); + print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', 'file-export'); print '
    '; print '
    '; @@ -1374,7 +1380,7 @@ if ($step == 5 && $datatoimport) { print ''; print '
    '; - print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', ''); + print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', 'file-export'); print '
    '; print '
    '; @@ -1468,7 +1474,7 @@ if ($step == 5 && $datatoimport) { print '
    '; - print load_fiche_titre($langs->trans("InformationOnTargetTables"), '', ''); + print load_fiche_titre($langs->trans("InformationOnTargetTables"), '', 'file-import'); print '
    '; print '
    '; @@ -1812,7 +1818,7 @@ if ($step == 6 && $datatoimport) { print ''; print '
    '; - print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', ''); + print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', 'file-export'); print '
    '; print '
    '; @@ -1875,8 +1881,7 @@ if ($step == 6 && $datatoimport) { print ''.$langs->trans("InformationOnTargetTables").''; print '
    '; print '
    '; - print ''; - //print ''; + print '
    '.$langs->trans("InformationOnTargetTables").'
    '; // Tables imported print '\n"; + +// Amount by member type +$adht = new AdherentType($db); +$amountbytype = empty($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE) ? -1 : json_decode($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE, true); +print '\n"; + // Insert subscription into bank account print ''; $arraychoices = array('0'=>$langs->trans("None")); diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index d4f2df25c0c..8b32e79526d 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -177,7 +177,7 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { print $langs->trans("ForceMemberType"); print '\n"; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 79fef823883..f7a87e9bf0c 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1490,9 +1490,11 @@ class Adherent extends CommonObject * @param string $emetteur_nom Name of cheque writer * @param string $emetteur_banque Name of bank of cheque * @param int $datesubend Date end subscription + * @param int fk_type Member type id + * * @return int rowid of record added, <0 if KO */ - public function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0) + public function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0, $fk_type = NULL) { global $conf, $langs, $user; @@ -1523,6 +1525,7 @@ class Adherent extends CommonObject $subscription->amount = $amount; $subscription->note = $label; // deprecated $subscription->note_public = $label; + $subscription->fk_type = $fk_type; $rowid = $subscription->create($user); if ($rowid > 0) { diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 31d0790b331..7f36f759bb1 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -169,6 +169,7 @@ DocForLabels=Generate address sheets SubscriptionPayment=Subscription payment LastSubscriptionDate=Date of latest subscription payment LastSubscriptionAmount=Amount of latest subscription +LastMemberType=Last Member type MembersStatisticsByCountries=Members statistics by country MembersStatisticsByState=Members statistics by state/province MembersStatisticsByTown=Members statistics by town diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index ea52dc21d7a..a541c347adb 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -162,6 +162,7 @@ DocForLabels=Génération d'étiquettes d'adresses SubscriptionPayment=Paiement cotisation LastSubscriptionDate=Date de dernière adhésion LastSubscriptionAmount=Montant dernière adhésion +LastMemberType=Ancien type de membre MembersStatisticsByCountries=Statistiques des membres par pays MembersStatisticsByState=Statistiques des membres par département/province/canton MembersStatisticsByTown=Statistiques des membres par ville diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 486223b0293..d55a8add8ea 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1437,6 +1437,39 @@ if ($source == 'membersubscription') { $_GET['newamount'] = $member->last_subscription_amount; } } + + if ($member->type) { + // Last member type + print '"."\n"; + } + + if (!empty($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE)) { + // Amount by member type + $amountbytype = json_decode($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE, true); + // Set the member type + $member->typeid = (int)(GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $member->typeid); + // If we change the type of membership, we set also label of new type + $member->type = dol_getIdFromCode($db, $member->typeid, 'adherent_type', 'rowid', 'libelle'); + // Set amount for the subscription + $amount = $amountbytype[$member->typeid] ? $amountbytype[$member->typeid] : $member->last_subscription_amount; + // list member type + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + $adht = new AdherentType($db); + if( !$action){ + $form = new Form($db); // so wecan call method selectarray + print '"."\n"; + } elseif ($action == dopayment) { + print '"."\n"; + } + } // Amount print '\n"; $adht = new AdherentType($db); $amountbytype = empty($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE) ? -1 : json_decode($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE, true); print '\n"; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index f7a87e9bf0c..40394a36062 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1494,7 +1494,7 @@ class Adherent extends CommonObject * * @return int rowid of record added, <0 if KO */ - public function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0, $fk_type = NULL) + public function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0, $fk_type = null) { global $conf, $langs, $user; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index d55a8add8ea..f665556d3d2 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1437,38 +1437,38 @@ if ($source == 'membersubscription') { $_GET['newamount'] = $member->last_subscription_amount; } } - + if ($member->type) { - // Last member type - print '"."\n"; + // Last member type + print '"."\n"; } - + if (!empty($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE)) { - // Amount by member type - $amountbytype = json_decode($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE, true); - // Set the member type - $member->typeid = (int)(GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $member->typeid); - // If we change the type of membership, we set also label of new type - $member->type = dol_getIdFromCode($db, $member->typeid, 'adherent_type', 'rowid', 'libelle'); - // Set amount for the subscription - $amount = $amountbytype[$member->typeid] ? $amountbytype[$member->typeid] : $member->last_subscription_amount; - // list member type - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; - $adht = new AdherentType($db); - if( !$action){ - $form = new Form($db); // so wecan call method selectarray - print '"."\n"; - } elseif ($action == dopayment) { - print '"."\n"; - } + // Amount by member type + $amountbytype = json_decode($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE, true); + // Set the member type + $member->typeid = (int) (GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $member->typeid); + // If we change the type of membership, we set also label of new type + $member->type = dol_getIdFromCode($db, $member->typeid, 'adherent_type', 'rowid', 'libelle'); + // Set amount for the subscription + $amount = $amountbytype[$member->typeid] ? $amountbytype[$member->typeid] : $member->last_subscription_amount; + // list member type + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + $adht = new AdherentType($db); + if ( !$action) { + $form = new Form($db); // so wecan call method selectarray + print '"."\n"; + } elseif ($action == dopayment) { + print '"."\n"; + } } // Amount diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index bf957d4cf6b..399d1c2575a 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -340,7 +340,7 @@ if ($ispaymentok) { $user->rights->facture = new stdClass(); } if (empty($user->rights->adherent)) { - $user->rights->adherent = new stdClass(); + $user->rights->adherent = new stdClass(); $user->rights->adherent->cotisation = new stdClass(); } $user->rights->societe->creer = 1; From 62485655512fb0dde76cc21da7964828bca6f3b8 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 9 Apr 2021 02:32:40 +0200 Subject: [PATCH 570/618] fix code style --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/public/payment/newpayment.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index f7a87e9bf0c..6f6f82c5fd1 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1490,7 +1490,7 @@ class Adherent extends CommonObject * @param string $emetteur_nom Name of cheque writer * @param string $emetteur_banque Name of bank of cheque * @param int $datesubend Date end subscription - * @param int fk_type Member type id + * @param int $fk_type Member type id * * @return int rowid of record added, <0 if KO */ diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index d55a8add8ea..8217e36d0d1 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1442,7 +1442,7 @@ if ($source == 'membersubscription') { // Last member type print '"."\n"; + print "\n"; } if (!empty($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE)) { @@ -1462,12 +1462,12 @@ if ($source == 'membersubscription') { print '"."\n"; + print "\n"; } elseif ($action == dopayment) { print '"."\n"; + print "\n"; } } From 51d327e99c6a6811e52e79d33b39f63e9ab6d9c6 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 9 Apr 2021 02:36:57 +0200 Subject: [PATCH 571/618] Revert "fix code style" This reverts commit 62485655512fb0dde76cc21da7964828bca6f3b8. --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/public/payment/newpayment.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 6f6f82c5fd1..f7a87e9bf0c 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1490,7 +1490,7 @@ class Adherent extends CommonObject * @param string $emetteur_nom Name of cheque writer * @param string $emetteur_banque Name of bank of cheque * @param int $datesubend Date end subscription - * @param int $fk_type Member type id + * @param int fk_type Member type id * * @return int rowid of record added, <0 if KO */ diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 8217e36d0d1..d55a8add8ea 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1442,7 +1442,7 @@ if ($source == 'membersubscription') { // Last member type print '\n"; + print ""."\n"; } if (!empty($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE)) { @@ -1462,12 +1462,12 @@ if ($source == 'membersubscription') { print '\n"; + print ""."\n"; } elseif ($action == dopayment) { print '\n"; + print ""."\n"; } } From 9ee80be23fbc8b33cdf26b9bc36cdf75d5d08a65 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 9 Apr 2021 02:40:21 +0200 Subject: [PATCH 572/618] fix code style errors --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/public/payment/newpayment.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 40394a36062..01b7d7db644 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1490,7 +1490,7 @@ class Adherent extends CommonObject * @param string $emetteur_nom Name of cheque writer * @param string $emetteur_banque Name of bank of cheque * @param int $datesubend Date end subscription - * @param int fk_type Member type id + * @param int $fk_type Member type id * * @return int rowid of record added, <0 if KO */ diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index f665556d3d2..b473fe4f38a 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1442,7 +1442,7 @@ if ($source == 'membersubscription') { // Last member type print '"."\n"; + print "\n"; } if (!empty($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE)) { @@ -1462,12 +1462,12 @@ if ($source == 'membersubscription') { print '"."\n"; + print "\n"; } elseif ($action == dopayment) { print '"."\n"; + print "\n"; } } From 071b50debfbe263175a16c326243a24e04fc2bf6 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 9 Apr 2021 02:51:05 +0200 Subject: [PATCH 573/618] Copyright --- htdocs/adherents/admin/member.php | 3 ++- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/public/payment/newpayment.php | 1 + htdocs/public/payment/paymentok.php | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 98da5281088..29c0170982b 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -8,7 +8,8 @@ * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2012 J. Fernando Lagrange * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2020-2021 Frédéric France + * Copyright (C) 2020-2021 Frédéric France + * Copyright (C) 2021 Waël Almoman * * 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 diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 01b7d7db644..aff47d40dc3 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -13,7 +13,7 @@ * Copyright (C) 2018-2019 Thibault FOUCART * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Josep Lluís Amador - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2021 Waël Almoman * * 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 diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index b473fe4f38a..8931ce1ceed 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -4,6 +4,7 @@ * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2018 Juanjo Menent * Copyright (C) 2018-2019 Thibault FOUCART + * Copyright (C) 2021 Waël Almoman * * 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 diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 399d1c2575a..1942635001f 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2002 Rodolphe Quiedeville * Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 555a968f934bfafd73a43e5c99ff39c5231a5273 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 9 Apr 2021 02:54:11 +0200 Subject: [PATCH 574/618] Fix html style error --- htdocs/adherents/admin/member.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 29c0170982b..03f161e6926 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -228,7 +228,7 @@ print '< foreach ($adht->liste_array(1) as $typeid => $type) { print $type .' : '; print ''; - print '
    '; + print '
    '; } print "\n"; From 555580710452d175b08602f0e2759168200574ba Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 9 Apr 2021 08:51:09 +0200 Subject: [PATCH 575/618] fix: right definition id in modulebuilder --- .../template/core/modules/modMyModule.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 2f08786e503..18bdfa54158 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -264,17 +264,17 @@ class modMyModule extends DolibarrModules $r = 0; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ - $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero . sprintf("%02d", $r); // Permission id (must not be already used) $this->rights[$r][1] = 'Read objects of MyModule'; // Permission label $this->rights[$r][4] = 'myobject'; $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->read) $r++; - $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero . sprintf("%02d", $r); // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label $this->rights[$r][4] = 'myobject'; $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->write) $r++; - $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero . sprintf("%02d", $r); // Permission id (must not be already used) $this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label $this->rights[$r][4] = 'myobject'; $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->delete) From 3153966b2438c1faddfcaf00e38150af2f1e24f5 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 9 Apr 2021 09:19:52 +0200 Subject: [PATCH 576/618] New edit object in module builder --- htdocs/modulebuilder/index.php | 204 ++++++++++++++++++++++----------- 1 file changed, 137 insertions(+), 67 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 682fa4bc330..8fa37b17588 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1212,6 +1212,10 @@ if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && } } +if ($dirins && $action == 'saveeditproperty' && !empty($module) && !empty($tabobj) && empty($cancel)) { + print 'test'; +} + if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) { $error = 0; @@ -2694,75 +2698,141 @@ if ($module == 'initmodule') { print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + /*print '';*/ + print ''; + print ''; } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - /*print '';*/ - print ''; - print ''; - print ''; } } else { From 056143450bba835e990aa66404e9ae0a4072d365 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 9 Apr 2021 10:58:33 +0200 Subject: [PATCH 577/618] NEW: add config type securekey module builder --- htdocs/admin/eventorganization.php | 37 +++++++++++++++---- htdocs/modulebuilder/template/admin/setup.php | 21 +++++++++++ 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index e142acedf8f..3bc58638455 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -60,6 +60,7 @@ $arrayofparameters = array( 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), + 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1), ); $error = 0; @@ -74,6 +75,7 @@ if ((float) DOL_VERSION >= 6) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; } + if ($action == 'updateMask') { $maskconstorder = GETPOST('maskconstorder', 'alpha'); $maskorder = GETPOST('maskorder', 'alpha'); @@ -196,7 +198,6 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, 'even // Setup page goes here echo ''.$langs->trans("EventOrganizationSetupPage").'

    '; - if ($action == 'edit') { print ''; print ''; @@ -206,12 +207,12 @@ if ($action == 'edit') { print '
    '; foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { - $setupnotempty++; - print ''; - print ''; } else { print ''; print ''; } From 17b446e8f73df9e2111740b9d3b8579593002b20 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 12:27:10 +0200 Subject: [PATCH 589/618] Update adherent.class.php --- htdocs/adherents/class/adherent.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index aff47d40dc3..0299b32663c 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1491,7 +1491,6 @@ class Adherent extends CommonObject * @param string $emetteur_banque Name of bank of cheque * @param int $datesubend Date end subscription * @param int $fk_type Member type id - * * @return int rowid of record added, <0 if KO */ public function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0, $fk_type = null) From 95d3dabdf693f406364f8b38b6d4a9eb1d72334b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 12:48:06 +0200 Subject: [PATCH 590/618] Update website2.lib.php --- htdocs/core/lib/website2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index e922087d0a9..cb96ed9ca43 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -104,7 +104,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) } // Save also alias into all language subdirectories if it is a main language elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(',', $object->otherlang))) { - if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR)) { + if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR) && !empty($object->otherlang)) { $dirname = dirname($filealias); $filename = basename($filealias); foreach (explode(',', $object->otherlang) as $sublang) { From a50b0e744192e7624fd1fdb36a173b550b9a31fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 13:15:27 +0200 Subject: [PATCH 591/618] Debug inventory module --- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/expedition/card.php | 3 ++- htdocs/expedition/shipment.php | 12 +++--------- htdocs/langs/en_US/stocks.lang | 2 +- htdocs/product/inventory/inventory.php | 16 +++++++++------- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3305bdc6e74..6a98976e261 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3511,7 +3511,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'bank_account', 'barcode', 'bank', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'building', 'cash-register', 'category', 'chart', 'check', 'clock', 'close_title', 'cog', 'collab', 'company', 'contact', 'country', 'contract', 'cron', 'cubes', 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'edit', 'ellipsis-h', 'email', 'eraser', 'establishment', 'external-link-alt', 'external-link-square-alt', - 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', + 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', 'help', 'holiday', 'info', 'intervention', 'inventory', 'intracommreport', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', @@ -3558,7 +3558,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ } $arrayconvpictotofa = array( - 'account'=>'university', 'accountline'=>'receipt', 'accountancy'=>'search-dollar', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book', 'asset'=>'money-check-alt', + 'account'=>'university', 'accountline'=>'receipt', 'accountancy'=>'search-dollar', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book', 'asset'=>'money-check-alt', 'autofill'=>'fill', 'bank_account'=>'university', 'bill'=>'file-invoice-dollar', 'billa'=>'file-excel', 'billr'=>'file-invoice-dollar', 'supplier_invoicea'=>'file-excel', 'billd'=>'file-medical', 'supplier_invoiced'=>'file-medical', 'bom'=>'shapes', 'chart'=>'chart-line', 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'collab'=>'people-arrows', 'conversation'=>'comments', 'country'=>'globe-americas', 'cron'=>'business-time', diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index c543ef40880..675372273f0 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -130,6 +130,7 @@ $date_delivery = dol_mktime(GETPOST('date_deliveryhour', 'int'), GETPOST('date_d if ($user->socid) { $socid = $user->socid; } + $result = restrictedArea($user, 'expedition', $object->id, ''); @@ -1035,7 +1036,7 @@ if ($action == 'create') { print ''; print ''; } - // Time spent by everybody - print '\n"; + if (!empty($arrayfields['timeconsumed']['checked'])) { + // Time spent by everybody + print '\n"; - // Time spent by user - print '\n"; } - print "\n"; $disabledproject = 1; $disabledtask = 1; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index fc5ea53e98a..de4e32143fa 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -61,10 +61,6 @@ $socid = 0; $result = restrictedArea($user, 'projet', $projectid); $now = dol_now(); -$nowtmp = dol_getdate($now); -$nowday = $nowtmp['mday']; -$nowmonth = $nowtmp['mon']; -$nowyear = $nowtmp['year']; $year = GETPOST('reyear', 'int') ?GETPOST('reyear', 'int') : (GETPOST("year", "int") ?GETPOST("year", "int") : (GETPOST("addtimeyear", "int") ?GETPOST("addtimeyear", "int") : date("Y"))); $month = GETPOST('remonth', 'int') ?GETPOST('remonth', 'int') : (GETPOST("month", "int") ?GETPOST("month", "int") : (GETPOST("addtimemonth", "int") ?GETPOST("addtimemonth", "int") : date("m"))); @@ -73,7 +69,7 @@ $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = (int) $day; -$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'); @@ -153,7 +149,7 @@ if ($reshook < 0) { // 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_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -422,9 +418,7 @@ $nav = '".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "day")." \n"; $nav .= ''.img_next($langs->trans("Next"))."\n"; -//$nav .= "   (".$langs->trans("Today").")"; $nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' '; -//$nav .= ' '; $nav .= ' '; $picto = 'clock'; diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 5fd76694c34..31067d2e312 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -57,10 +57,6 @@ $socid = 0; $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")); @@ -68,7 +64,7 @@ $day = GETPOST('reday') ?GETPOST('reday', 'int') : (GETPOST("day") ?GETPOST("day $day = (int) $day; $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'); @@ -119,7 +115,7 @@ if ($reshook < 0) { // 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_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -349,9 +345,7 @@ $param .= ($search_task_label ? '&search_task_label='.$search_task_label : ''); $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->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' '; -//$nav.=' '; $nav .= ' '; $picto = 'clock'; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 4201fca41b6..301d9c3da7c 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -61,10 +61,6 @@ $socid = 0; $result = restrictedArea($user, 'projet', $projectid); $now = dol_now(); -$nowtmp = dol_getdate($now); -$nowday = $nowtmp['mday']; -$nowmonth = $nowtmp['mon']; -$nowyear = $nowtmp['year']; $year = GETPOST('reyear', 'int') ?GETPOST('reyear', 'int') : (GETPOST("year", 'int') ?GETPOST("year", "int") : date("Y")); $month = GETPOST('remonth', 'int') ?GETPOST('remonth', 'int') : (GETPOST("month", 'int') ?GETPOST("month", "int") : date("m")); @@ -73,7 +69,7 @@ $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = (int) $day; -$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'); @@ -129,8 +125,9 @@ $arrayfields = array(); 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115), );*/ -$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); -$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>5); +$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>10); +$arrayfields['timeconsumed'] = array('label'=>'TimeConsumed', 'checked'=>1, 'enabled'=>1, 'position'=>15); /*foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field @@ -165,7 +162,7 @@ if ($reshook < 0) { // 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_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -441,9 +438,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $nav = ''.img_previous($langs->trans("Previous"))."\n"; $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; $nav .= ''.img_next($langs->trans("Next"))."\n"; -//$nav .= "   (".$langs->trans("Today").")"; $nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' '; -//$nav .= ' '; $nav .= ' '; $picto = 'clock'; @@ -618,14 +613,16 @@ $search_options_pattern = 'search_task_options_'; $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; -print ''; if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''; -} -if (!empty($arrayfields['t.progress']['checked'])) { print ''; } -print ''; +if (!empty($arrayfields['t.progress']['checked'])) { + print ''; +} +if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; +} for ($idw = 0; $idw < 7; $idw++) { print ''; } @@ -654,17 +651,15 @@ if (!empty($arrayfields['t.planned_workload']['checked'])) { if (!empty($arrayfields['t.progress']['checked'])) { print ''; } -/*print ''; - if ($usertoprocess->id == $user->id) print ''; - else print '';*/ -print ''; -print ''; - +if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; +} for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); @@ -693,7 +688,7 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print "\n"; -$colspan = 3 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); +$colspan = 1 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); if ($conf->use_javascript_ajax) { print ''; @@ -701,7 +696,10 @@ if ($conf->use_javascript_ajax) { print $langs->trans("Total"); print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print ''; - + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. @@ -780,6 +778,10 @@ if (count($tasksarray) > 0) { print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. @@ -801,11 +803,15 @@ if (count($tasksarray) > 0) { } if ($conf->use_javascript_ajax) { - print ' - '; + print ''; + print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; @@ -826,8 +832,8 @@ if (count($tasksarray) > 0) { print ''; } - print ' - '; + print ''; + print ''; } } else { print ''; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index e807ae62234..7e0b857eb6d 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2284,8 +2284,8 @@ li.tmenu, li.tmenusel { li.tmenu:hover { opacity: .50; /* show only a slight shadow */ } -li.tmenusel { - text-decoration: underline; +li.tmenusel a.tmenusel { + text-decoration: underline !important; } .tmenuend .tmenuleft { width: 0px; } .tmenuend { display: none; } From cb08151473ef6f34e724e40a150e26f0e5d5aa9e Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 10 Apr 2021 13:47:35 +0200 Subject: [PATCH 614/618] Update llx_20_c_departements.sql Romania --- .../mysql/data/llx_20_c_departements.sql | 92 ++++++++++--------- 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 445a970b3f9..b48831bbd39 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -53,6 +53,8 @@ -- (Italy) -- Luxembourg -- Netherlands +-- (Moroco) +-- Romania @@ -731,6 +733,52 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA19A', 1214, '', 0, '', 'Province de Tan-Tan', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA19B', 1214, '', 0, '', 'Province de Tan-Tan', 1); + +-- Romania Provinces (id country=188) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'AB', '', 0, '', 'Alba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'AR', '', 0, '', 'Arad'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'AG', '', 0, '', 'Argeș'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BC', '', 0, '', 'Bacău'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BH', '', 0, '', 'Bihor'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BN', '', 0, '', 'Bistrița-Năsăud'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BT', '', 0, '', 'Botoșani'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BV', '', 0, '', 'Brașov'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BR', '', 0, '', 'Brăila'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BU', '', 0, '', 'Bucuresti'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BZ', '', 0, '', 'Buzău'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'CL', '', 0, '', 'Călărași'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'CS', '', 0, '', 'Caraș-Severin'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'CJ', '', 0, '', 'Cluj'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'CT', '', 0, '', 'Constanța'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'CV', '', 0, '', 'Covasna'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'DB', '', 0, '', 'Dâmbovița'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'DJ', '', 0, '', 'Dolj'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'GL', '', 0, '', 'Galați'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'GR', '', 0, '', 'Giurgiu'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'GJ', '', 0, '', 'Gorj'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'HR', '', 0, '', 'Harghita'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'HD', '', 0, '', 'Hunedoara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'IL', '', 0, '', 'Ialomița'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'IS', '', 0, '', 'Iași'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'IF', '', 0, '', 'Ilfov'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'MM', '', 0, '', 'Maramureș'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'MH', '', 0, '', 'Mehedinți'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'MS', '', 0, '', 'Mureș'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'NT', '', 0, '', 'Neamț'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'OT', '', 0, '', 'Olt'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'PH', '', 0, '', 'Prahova'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'SM', '', 0, '', 'Satu Mare'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'SJ', '', 0, '', 'Sălaj'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'SB', '', 0, '', 'Sibiu'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'SV', '', 0, '', 'Suceava'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'TR', '', 0, '', 'Teleorman'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'TM', '', 0, '', 'Timiș'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'TL', '', 0, '', 'Tulcea'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'VS', '', 0, '', 'Vaslui'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'VL', '', 0, '', 'Vâlcea'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'VN', '', 0, '', 'Vrancea'); + + -- Provinces Tunisia (id country=10) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('TN01', 1001, '', 0, '', 'Ariana', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('TN02', 1001, '', 0, '', 'Béja', 1); @@ -1328,50 +1376,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ZAC', 15401, '', 0, 'ZAC', 'Zacatecas', 1); --- Provinces Romania (id country=188) -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AB', 18801, '', 0, '', 'Alba', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AR', 18801, '', 0, '', 'Arad', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AG', 18801, '', 0, '', 'Argeș', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BC', 18801, '', 0, '', 'Bacău', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BH', 18801, '', 0, '', 'Bihor', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BN', 18801, '', 0, '', 'Bistrița-Năsăud', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BT', 18801, '', 0, '', 'Botoșani', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BV', 18801, '', 0, '', 'Brașov', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BR', 18801, '', 0, '', 'Brăila', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BZ', 18801, '', 0, '', 'Buzău', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CL', 18801, '', 0, '', 'Călărași', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CS', 18801, '', 0, '', 'Caraș-Severin', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CJ', 18801, '', 0, '', 'Cluj', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CT', 18801, '', 0, '', 'Constanța', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CV', 18801, '', 0, '', 'Covasna', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('DB', 18801, '', 0, '', 'Dâmbovița', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('DJ', 18801, '', 0, '', 'Dolj', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GL', 18801, '', 0, '', 'Galați', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GR', 18801, '', 0, '', 'Giurgiu', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GJ', 18801, '', 0, '', 'Gorj', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('HR', 18801, '', 0, '', 'Harghita', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('HD', 18801, '', 0, '', 'Hunedoara', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('IL', 18801, '', 0, '', 'Ialomița', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('IS', 18801, '', 0, '', 'Iași', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('IF', 18801, '', 0, '', 'Ilfov', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MM', 18801, '', 0, '', 'Maramureș', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MH', 18801, '', 0, '', 'Mehedinți', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MS', 18801, '', 0, '', 'Mureș', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('NT', 18801, '', 0, '', 'Neamț', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('OT', 18801, '', 0, '', 'Olt', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PH', 18801, '', 0, '', 'Prahova', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SM', 18801, '', 0, '', 'Satu Mare', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SJ', 18801, '', 0, '', 'Sălaj', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SB', 18801, '', 0, '', 'Sibiu', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SV', 18801, '', 0, '', 'Suceava', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TR', 18801, '', 0, '', 'Teleorman', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TM', 18801, '', 0, '', 'Timiș', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TL', 18801, '', 0, '', 'Tulcea', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VS', 18801, '', 0, '', 'Vaslui', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VL', 18801, '', 0, '', 'Vâlcea', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VN', 18801, '', 0, '', 'Vrancea', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BU', 18801, '', 0, '', 'Bucuresti', 1); - -- Provinces Venezuela (id country=232) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VE-L', 23201, '', 0, 'VE-L', 'Mérida', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VE-T', 23201, '', 0, 'VE-T', 'Trujillo', 1); From cb57546d99129f7315454bc35491705e12491b52 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Apr 2021 13:29:24 +0200 Subject: [PATCH 615/618] NEW Can hide columns "time consumed" on timesheet per week. --- htdocs/core/lib/project.lib.php | 80 ++++++++++++++------------- htdocs/projet/activity/perday.php | 63 ++++++++++++---------- htdocs/projet/activity/permonth.php | 10 +--- htdocs/projet/activity/perweek.php | 84 ++++++++++++++++------------- htdocs/theme/md/style.css.php | 4 +- 5 files changed, 128 insertions(+), 113 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index abdb098eb7d..a440940d76d 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1512,27 +1512,29 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print ''; } - // Time spent by everybody - print '\n"; + if (!empty($arrayfields['timeconsumed']['checked'])) { + // Time spent by everybody + print '\n"; - // Time spent by user - print '\n"; } - print "\n"; $disabledproject = 1; $disabledtask = 1; @@ -1903,27 +1905,29 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ print ''; } - // Time spent by everybody - print '\n"; + if (!empty($arrayfields['timeconsumed']['checked'])) { + // Time spent by everybody + print '\n"; - // Time spent by user - print '\n"; } - print "\n"; $disabledproject = 1; $disabledtask = 1; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index fc5ea53e98a..44ed79c2520 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -61,10 +61,6 @@ $socid = 0; $result = restrictedArea($user, 'projet', $projectid); $now = dol_now(); -$nowtmp = dol_getdate($now); -$nowday = $nowtmp['mday']; -$nowmonth = $nowtmp['mon']; -$nowyear = $nowtmp['year']; $year = GETPOST('reyear', 'int') ?GETPOST('reyear', 'int') : (GETPOST("year", "int") ?GETPOST("year", "int") : (GETPOST("addtimeyear", "int") ?GETPOST("addtimeyear", "int") : date("Y"))); $month = GETPOST('remonth', 'int') ?GETPOST('remonth', 'int') : (GETPOST("month", "int") ?GETPOST("month", "int") : (GETPOST("addtimemonth", "int") ?GETPOST("addtimemonth", "int") : date("m"))); @@ -73,7 +69,7 @@ $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = (int) $day; -$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'); @@ -117,6 +113,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); $arrayfields = array(); $arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); $arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['timeconsumed'] = array('label'=>'TimeConsumed', 'checked'=>1, 'enabled'=>1, 'position'=>15); /*$arrayfields=array( // Project 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), @@ -153,7 +150,7 @@ if ($reshook < 0) { // 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_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -403,12 +400,13 @@ llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js')); $param = ''; $param .= ($mode ? '&mode='.urlencode($mode) : ''); $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : ''); -$param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); +$param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : ''); $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : ''); $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); -/*$search_array_options=$search_array_options_project; +/* +$search_array_options = $search_array_options_project; $search_options_pattern='search_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ @@ -422,9 +420,7 @@ $nav = '".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "day")." \n"; $nav .= ''.img_next($langs->trans("Next"))."\n"; -//$nav .= "   (".$langs->trans("Today").")"; $nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' '; -//$nav .= ' '; $nav .= ' '; $picto = 'clock'; @@ -561,14 +557,16 @@ $search_options_pattern = 'search_task_options_'; $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; -print ''; if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''; -} -if (!empty($arrayfields['t.progress']['checked'])) { print ''; } -print ''; +if (!empty($arrayfields['t.progress']['checked'])) { + print ''; +} +if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; +} print ''; print ''; print ''; @@ -592,21 +590,20 @@ $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['t.progress']['checked'])) { print ''; } -/*print ''; -if ($usertoprocess->id == $user->id) print ''; -else print '';*/ -print ''; -print ''; +if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; +} print '\n"; -$colspan = 4 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); +$colspan = 2 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); if ($conf->use_javascript_ajax) { print ''; print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } print ''; @@ -723,6 +724,10 @@ if (count($tasksarray) > 0) { print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } print ''; print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } print ''; diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 5fd76694c34..31067d2e312 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -57,10 +57,6 @@ $socid = 0; $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")); @@ -68,7 +64,7 @@ $day = GETPOST('reday') ?GETPOST('reday', 'int') : (GETPOST("day") ?GETPOST("day $day = (int) $day; $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'); @@ -119,7 +115,7 @@ if ($reshook < 0) { // 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_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -349,9 +345,7 @@ $param .= ($search_task_label ? '&search_task_label='.$search_task_label : ''); $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->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' '; -//$nav.=' '; $nav .= ' '; $picto = 'clock'; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 4201fca41b6..fdf6e492361 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -61,10 +61,6 @@ $socid = 0; $result = restrictedArea($user, 'projet', $projectid); $now = dol_now(); -$nowtmp = dol_getdate($now); -$nowday = $nowtmp['mday']; -$nowmonth = $nowtmp['mon']; -$nowyear = $nowtmp['year']; $year = GETPOST('reyear', 'int') ?GETPOST('reyear', 'int') : (GETPOST("year", 'int') ?GETPOST("year", "int") : date("Y")); $month = GETPOST('remonth', 'int') ?GETPOST('remonth', 'int') : (GETPOST("month", 'int') ?GETPOST("month", "int") : date("m")); @@ -73,7 +69,7 @@ $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = (int) $day; -$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'); @@ -129,8 +125,9 @@ $arrayfields = array(); 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115), );*/ -$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); -$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>5); +$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>10); +$arrayfields['timeconsumed'] = array('label'=>'TimeConsumed', 'checked'=>1, 'enabled'=>1, 'position'=>15); /*foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field @@ -165,7 +162,7 @@ if ($reshook < 0) { // 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_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -184,8 +181,10 @@ if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') | } if (GETPOST('submitdateselect')) { - $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - + if (GETPOST('remonth', 'int') && GETPOST('reday', 'int') && GETPOST('reyear', 'int')) { + $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + } + $action = ''; } @@ -441,9 +440,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $nav = ''.img_previous($langs->trans("Previous"))."\n"; $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; $nav .= ''.img_next($langs->trans("Next"))."\n"; -//$nav .= "   (".$langs->trans("Today").")"; $nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' '; -//$nav .= ' '; $nav .= ' '; $picto = 'clock'; @@ -618,14 +615,16 @@ $search_options_pattern = 'search_task_options_'; $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; -print ''; if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''; -} -if (!empty($arrayfields['t.progress']['checked'])) { print ''; } -print ''; +if (!empty($arrayfields['t.progress']['checked'])) { + print ''; +} +if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; +} for ($idw = 0; $idw < 7; $idw++) { print ''; } @@ -649,22 +648,20 @@ $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['t.progress']['checked'])) { print ''; } -/*print ''; - if ($usertoprocess->id == $user->id) print ''; - else print '';*/ -print ''; -print ''; - +if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; +} for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); @@ -693,7 +690,7 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print "\n"; -$colspan = 3 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); +$colspan = 1 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); if ($conf->use_javascript_ajax) { print ''; @@ -701,7 +698,10 @@ if ($conf->use_javascript_ajax) { print $langs->trans("Total"); print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print ''; - + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. @@ -780,6 +780,10 @@ if (count($tasksarray) > 0) { print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. @@ -801,11 +805,15 @@ if (count($tasksarray) > 0) { } if ($conf->use_javascript_ajax) { - print ' - '; + print ''; + print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; @@ -826,8 +834,8 @@ if (count($tasksarray) > 0) { print ''; } - print ' - '; + print ''; + print ''; } } else { print ''; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index e807ae62234..7e0b857eb6d 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2284,8 +2284,8 @@ li.tmenu, li.tmenusel { li.tmenu:hover { opacity: .50; /* show only a slight shadow */ } -li.tmenusel { - text-decoration: underline; +li.tmenusel a.tmenusel { + text-decoration: underline !important; } .tmenuend .tmenuleft { width: 0px; } .tmenuend { display: none; } From 35a64e08bf69ed081a24f7307486f475e10be10e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Apr 2021 14:12:51 +0200 Subject: [PATCH 616/618] Fix link --- 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 a440940d76d..3c5e9c71dad 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2473,7 +2473,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $i = 0; print ''; - print_liste_field_titre($title.''.$num.'', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($title.''.$num.'', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { if (!in_array('prospectionstatus', $hiddenfields)) { From 0bc93d437ec2e4d65ba81482285a9832570d079d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Apr 2021 14:21:03 +0200 Subject: [PATCH 617/618] css --- htdocs/projet/activity/perday.php | 6 +++--- htdocs/projet/activity/permonth.php | 6 +++--- htdocs/projet/activity/perweek.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 44ed79c2520..5b238d96b92 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -500,18 +500,18 @@ $includeonly = 'hierarchyme'; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$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 marginleftonly'); +$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user', 'class="paddingright"').$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 .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project', 'class="paddingright"').''; $moreforfilter .= '
    '; $moreforfilter .= '
    '; $moreforfilter .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company', 'class="paddingright"').''; $moreforfilter .= '
    '; } diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 31067d2e312..43cdfa863f5 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -422,18 +422,18 @@ $includeonly = 'hierachyme'; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$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 .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user', 'class="paddingright"').$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 .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project', 'class="paddingright"').''; $moreforfilter .= '
    '; $moreforfilter .= '
    '; $moreforfilter .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company', 'class="paddingright"').''; $moreforfilter .= '
    '; } diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index cb331f7d262..c413b5e0533 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -556,18 +556,18 @@ $includeonly = 'hierarchyme'; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$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 .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user', 'class="paddingright"').$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 .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project', 'class="paddingright"').''; $moreforfilter .= '
    '; $moreforfilter .= '
    '; $moreforfilter .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company', 'class="paddingright"').''; $moreforfilter .= '
    '; } From be800e07f2efabb617b5d812257f641794523dd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Apr 2021 15:27:44 +0200 Subject: [PATCH 618/618] Use urlencode even on security key --- htdocs/core/lib/payments.lib.php | 14 +++++++------- htdocs/public/payment/newpayment.php | 4 ++-- .../lib/recruitment_recruitmentjobposition.lib.php | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index f9022726511..166814525cf 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -211,9 +211,9 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out = $urltouse.'/public/payment/newpayment.php?amount='.($mode ? '' : '').$amount.($mode ? '' : '').'&tag='.($mode ? '' : '').$freetag.($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { - $out .= '&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $out .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2)); } } //if ($mode) $out.='&noidempotency=1'; @@ -228,7 +228,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out .= ($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { @@ -251,7 +251,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out .= ($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { @@ -274,7 +274,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out .= ($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { @@ -297,7 +297,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out .= ($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { @@ -321,7 +321,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out .= ($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 8931ce1ceed..9a88a1b49ac 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1459,10 +1459,10 @@ if ($source == 'membersubscription') { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; $adht = new AdherentType($db); if ( !$action) { - $form = new Form($db); // so wecan call method selectarray + $form = new Form($db); // so we can call method selectarray print '
    \n"; } elseif ($action == dopayment) { print '
    '; diff --git a/htdocs/includes/phpoffice/autoloader.php b/htdocs/includes/phpoffice/phpspreadsheet/src/autoloader.php similarity index 81% rename from htdocs/includes/phpoffice/autoloader.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/autoloader.php index 71e94e9b738..809725dfb6f 100644 --- a/htdocs/includes/phpoffice/autoloader.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/autoloader.php @@ -5,6 +5,6 @@ spl_autoload_register(function ($class_name) { if (1 === $preg_match) { $class_name = preg_replace('/\\\/', '/', $class_name); $class_name = preg_replace('/^PhpOffice\\/PhpSpreadsheet\\//', '', $class_name); - require_once(__DIR__ . '/PhpSpreadsheet/' . $class_name . '.php'); + require_once __DIR__ . '/PhpSpreadsheet/' . $class_name . '.php'; } }); From 76c3229c97c3a25e39a353d20dbac414b3997011 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 18:32:02 +0200 Subject: [PATCH 561/618] Update to phpspreadsheet 1.8.2 --- COPYRIGHT | 2 +- composer.lock | 57 ++ .../Calculation/Calculation.php | 25 +- .../PhpSpreadsheet/Calculation/Logical.php | 54 ++ .../PhpSpreadsheet/Calculation/LookupRef.php | 34 +- .../PhpSpreadsheet/Calculation/MathTrig.php | 5 +- .../Calculation/functionlist.txt | 1 + .../Cell/AdvancedValueBinder.php | 2 + .../src/PhpSpreadsheet/Cell/Cell.php | 2 +- .../src/PhpSpreadsheet/Cell/Coordinate.php | 4 +- .../Cell/DefaultValueBinder.php | 2 + .../PhpSpreadsheet/Cell/StringValueBinder.php | 31 + .../src/PhpSpreadsheet/Chart/Axis.php | 4 +- .../src/PhpSpreadsheet/Chart/GridLines.php | 4 +- .../src/PhpSpreadsheet/Chart/Layout.php | 16 +- .../src/PhpSpreadsheet/Collection/Cells.php | 6 +- .../PhpSpreadsheet/Document/Properties.php | 2 +- .../src/PhpSpreadsheet/Reader/BaseReader.php | 91 +- .../src/PhpSpreadsheet/Reader/Csv.php | 26 +- .../src/PhpSpreadsheet/Reader/Gnumeric.php | 2 +- .../src/PhpSpreadsheet/Reader/Html.php | 330 ++++++- .../src/PhpSpreadsheet/Reader/IReader.php | 106 +++ .../src/PhpSpreadsheet/Reader/Ods.php | 116 +-- .../PhpSpreadsheet/Reader/Ods/Properties.php | 136 +++ .../Reader/Security/XmlScanner.php | 91 +- .../src/PhpSpreadsheet/Reader/Slk.php | 2 +- .../src/PhpSpreadsheet/Reader/Xls.php | 2 +- .../src/PhpSpreadsheet/Reader/Xlsx.php | 803 +++--------------- .../PhpSpreadsheet/Reader/Xlsx/AutoFilter.php | 144 ++++ .../Reader/Xlsx/BaseParserClass.php | 19 + .../Reader/Xlsx/ColumnAndRowAttributes.php | 204 +++++ .../Reader/Xlsx/ConditionalStyles.php | 92 ++ .../Reader/Xlsx/DataValidations.php | 50 ++ .../PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php | 58 ++ .../PhpSpreadsheet/Reader/Xlsx/PageSetup.php | 150 ++++ .../PhpSpreadsheet/Reader/Xlsx/Properties.php | 91 ++ .../Reader/Xlsx/SheetViewOptions.php | 124 +++ .../PhpSpreadsheet/Reader/Xlsx/SheetViews.php | 127 +++ .../src/PhpSpreadsheet/Reader/Xlsx/Styles.php | 265 ++++++ .../src/PhpSpreadsheet/Reader/Xml.php | 2 +- .../src/PhpSpreadsheet/ReferenceHelper.php | 26 +- .../src/PhpSpreadsheet/Settings.php | 42 + .../src/PhpSpreadsheet/Shared/Date.php | 25 +- .../src/PhpSpreadsheet/Shared/OLE.php | 36 +- .../Shared/Trend/ExponentialBestFit.php | 4 +- .../Shared/Trend/LinearBestFit.php | 4 +- .../Shared/Trend/LogarithmicBestFit.php | 4 +- .../Shared/Trend/PolynomialBestFit.php | 4 +- .../Shared/Trend/PowerBestFit.php | 4 +- .../src/PhpSpreadsheet/Spreadsheet.php | 2 +- .../src/PhpSpreadsheet/Style/NumberFormat.php | 20 +- .../PhpSpreadsheet/Worksheet/Dimension.php | 4 +- .../Worksheet/RowCellIterator.php | 10 + .../PhpSpreadsheet/Worksheet/Worksheet.php | 4 +- .../src/PhpSpreadsheet/Writer/BaseWriter.php | 55 -- .../src/PhpSpreadsheet/Writer/IWriter.php | 69 ++ .../src/PhpSpreadsheet/Writer/Xls/Parser.php | 33 +- .../PhpSpreadsheet/Writer/Xls/Workbook.php | 10 +- .../src/PhpSpreadsheet/Writer/Xlsx.php | 15 +- .../PhpSpreadsheet/Writer/Xlsx/Workbook.php | 4 +- .../PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 26 +- 61 files changed, 2557 insertions(+), 1126 deletions(-) create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/StringValueBinder.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/Properties.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/BaseParserClass.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Properties.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php create mode 100644 htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Styles.php diff --git a/COPYRIGHT b/COPYRIGHT index 21e37f39f1d..b133b05b2cf 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -23,7 +23,7 @@ PEAR Mail_MIME 1.8.9 BSD Yes ParseDown 1.6 MIT License Yes Markdown parser PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers -PHPSpreadSheet ? LGPL-2.1+ Yes Read/Write XLS files, read ODS files +PHPSpreadSheet 1.8.2 LGPL-2.1+ Yes Read/Write XLS files, read ODS files php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests diff --git a/composer.lock b/composer.lock index c588bc7783f..3e867f8f186 100644 --- a/composer.lock +++ b/composer.lock @@ -328,6 +328,63 @@ }, "time": "2020-03-23T09:12:05+00:00" }, + { + "name": "phpoffice/phpexcel", + "version": "1.8.2", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PHPExcel.git", + "reference": "1441011fb7ecdd8cc689878f54f8b58a6805f870" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/1441011fb7ecdd8cc689878f54f8b58a6805f870", + "reference": "1441011fb7ecdd8cc689878f54f8b58a6805f870", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "php": "^5.2|^7.0" + }, + "require-dev": { + "squizlabs/php_codesniffer": "2.*" + }, + "type": "library", + "autoload": { + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "http://blog.maartenballiauw.be" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Franck Lefevre", + "homepage": "http://rootslabs.net" + }, + { + "name": "Mark Baker", + "homepage": "http://markbakeruk.net" + } + ], + "description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PHPExcel", + "keywords": [ + "OpenXML", + "excel", + "xlsx" + ], + "abandoned": "phpoffice/phpspreadsheet", + "time": "2018-11-22T23:07:24+00:00" + }, { "name": "restler/framework", "version": "3.0.0-RC6", diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php index 4f9ef639883..ae06d654dce 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php @@ -117,7 +117,7 @@ class Calculation /** * An array of the nested cell references accessed by the calculation engine, used for the debug log. * - * @var array of string + * @var CyclicReferenceStack */ private $cyclicReferenceStack; @@ -1945,6 +1945,11 @@ class Calculation 'functionCall' => [MathTrig::class, 'SUMXMY2'], 'argumentCount' => '2', ], + 'SWITCH' => [ + 'category' => Category::CATEGORY_LOGICAL, + 'functionCall' => [Logical::class, 'statementSwitch'], + 'argumentCount' => '3+', + ], 'SYD' => [ 'category' => Category::CATEGORY_FINANCIAL, 'functionCall' => [Financial::class, 'SYD'], @@ -2207,8 +2212,8 @@ class Calculation private static function loadLocales() { $localeFileDirectory = __DIR__ . '/locale/'; - foreach (glob($localeFileDirectory . '/*', GLOB_ONLYDIR) as $filename) { - $filename = substr($filename, strlen($localeFileDirectory) + 1); + foreach (glob($localeFileDirectory . '*', GLOB_ONLYDIR) as $filename) { + $filename = substr($filename, strlen($localeFileDirectory)); if ($filename != 'en') { self::$validLocaleLanguages[] = $filename; } @@ -2413,7 +2418,6 @@ class Calculation if (strpos($locale, '_') !== false) { list($language) = explode('_', $locale); } - if (count(self::$validLocaleLanguages) == 1) { self::loadLocales(); } @@ -2704,7 +2708,7 @@ class Calculation * @param Cell $pCell Cell to calculate * @param bool $resetLog Flag indicating whether the debug log should be reset or not * - * @throws Exception + * @throws \PhpOffice\PhpSpreadsheet\Exception * * @return mixed */ @@ -2808,7 +2812,7 @@ class Calculation * @param string $cellID Address of the cell to calculate * @param Cell $pCell Cell to calculate * - * @throws Exception + * @throws \PhpOffice\PhpSpreadsheet\Exception * * @return mixed */ @@ -2892,6 +2896,15 @@ class Calculation { $cellValue = null; + // Quote-Prefixed cell values cannot be formulae, but are treated as strings + if ($pCell !== null && $pCell->getStyle()->getQuotePrefix() === true) { + return self::wrapResult((string) $formula); + } + + if (preg_match('/^=\s*cmd\s*\|/miu', $formula) !== 0) { + return self::wrapResult($formula); + } + // Basic validation that this is indeed a formula // We simply return the cell value if not $formula = trim($formula); diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical.php index c36e3fca74f..3e6c5e74177 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical.php @@ -273,6 +273,60 @@ class Logical return ($condition) ? $returnIfTrue : $returnIfFalse; } + /** + * STATEMENT_SWITCH. + * + * Returns corresponding with first match (any data type such as a string, numeric, date, etc). + * + * Excel Function: + * =SWITCH (expression, value1, result1, value2, result2, ... value_n, result_n [, default]) + * + * Expression + * The expression to compare to a list of values. + * value1, value2, ... value_n + * A list of values that are compared to expression. The SWITCH function is looking for the first value that matches the expression. + * result1, result2, ... result_n + * A list of results. The SWITCH function returns the corresponding result when a value matches expression. + * default + * Optional. It is the default to return if expression does not match any of the values (value1, value2, ... value_n). + * + * @category Logical Functions + * + * @param mixed $arguments Statement arguments + * + * @return mixed The value of matched expression + */ + public static function statementSwitch(...$arguments) + { + $result = Functions::VALUE(); + + if (count($arguments) > 0) { + $targetValue = Functions::flattenSingleValue($arguments[0]); + $argc = count($arguments) - 1; + $switchCount = floor($argc / 2); + $switchSatisfied = false; + $hasDefaultClause = $argc % 2 !== 0; + $defaultClause = $argc % 2 === 0 ? null : $arguments[count($arguments) - 1]; + + if ($switchCount) { + for ($index = 0; $index < $switchCount; ++$index) { + if ($targetValue == $arguments[$index * 2 + 1]) { + $result = $arguments[$index * 2 + 2]; + $switchSatisfied = true; + + break; + } + } + } + + if (!$switchSatisfied) { + $result = $hasDefaultClause ? $defaultClause : Functions::NA(); + } + } + + return $result; + } + /** * IFERROR. * diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php index 2a3c5582108..e6b0f3203f8 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class LookupRef @@ -473,8 +474,9 @@ class LookupRef $lookupValue = Functions::flattenSingleValue($lookupValue); $matchType = ($matchType === null) ? 1 : (int) Functions::flattenSingleValue($matchType); + $initialLookupValue = $lookupValue; // MATCH is not case sensitive - $lookupValue = strtolower($lookupValue); + $lookupValue = StringHelper::strToLower($lookupValue); // Lookup_value type has to be number, text, or logical values if ((!is_numeric($lookupValue)) && (!is_string($lookupValue)) && (!is_bool($lookupValue))) { @@ -502,7 +504,7 @@ class LookupRef } // Convert strings to lowercase for case-insensitive testing if (is_string($lookupArrayValue)) { - $lookupArray[$i] = strtolower($lookupArrayValue); + $lookupArray[$i] = StringHelper::strToLower($lookupArrayValue); } if (($lookupArrayValue === null) && (($matchType == 1) || ($matchType == -1))) { $lookupArray = array_slice($lookupArray, 0, $i - 1); @@ -522,9 +524,13 @@ class LookupRef if ($matchType == 0 || $matchType == 1) { foreach ($lookupArray as $i => $lookupArrayValue) { - if (($matchType == 0) && ($lookupArrayValue == $lookupValue)) { + $onlyNumeric = is_numeric($lookupArrayValue) && is_numeric($lookupValue); + $onlyNumericExactMatch = $onlyNumeric && $lookupArrayValue == $lookupValue; + $nonOnlyNumericExactMatch = !$onlyNumeric && $lookupArrayValue === $lookupValue; + $exactMatch = $onlyNumericExactMatch || $nonOnlyNumericExactMatch; + if (($matchType == 0) && $exactMatch) { // exact match - return ++$i; + return $i + 1; } elseif (($matchType == 1) && ($lookupArrayValue <= $lookupValue)) { $i = array_search($i, $keySet); @@ -661,7 +667,9 @@ class LookupRef { reset($a); $firstColumn = key($a); - if (($aLower = strtolower($a[$firstColumn])) == ($bLower = strtolower($b[$firstColumn]))) { + $aLower = StringHelper::strToLower($a[$firstColumn]); + $bLower = StringHelper::strToLower($b[$firstColumn]); + if ($aLower == $bLower) { return 0; } @@ -707,11 +715,14 @@ class LookupRef uasort($lookup_array, ['self', 'vlookupSort']); } + $lookupLower = StringHelper::strToLower($lookup_value); $rowNumber = $rowValue = false; foreach ($lookup_array as $rowKey => $rowData) { + $firstLower = StringHelper::strToLower($rowData[$firstColumn]); + // break if we have passed possible keys if ((is_numeric($lookup_value) && is_numeric($rowData[$firstColumn]) && ($rowData[$firstColumn] > $lookup_value)) || - (!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && (strtolower($rowData[$firstColumn]) > strtolower($lookup_value)))) { + (!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && ($firstLower > $lookupLower))) { break; } // remember the last key, but only if datatypes match @@ -719,17 +730,15 @@ class LookupRef (!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]))) { if ($not_exact_match) { $rowNumber = $rowKey; - $rowValue = $rowData[$firstColumn]; continue; - } elseif ((strtolower($rowData[$firstColumn]) == strtolower($lookup_value)) + } elseif (($firstLower == $lookupLower) // Spreadsheets software returns first exact match, // we have sorted and we might have broken key orders // we want the first one (by its initial index) && (($rowNumber == false) || ($rowKey < $rowNumber)) ) { $rowNumber = $rowKey; - $rowValue = $rowData[$firstColumn]; } } } @@ -782,8 +791,11 @@ class LookupRef // break if we have passed possible keys $bothNumeric = is_numeric($lookup_value) && is_numeric($rowData); $bothNotNumeric = !is_numeric($lookup_value) && !is_numeric($rowData); + $lookupLower = StringHelper::strToLower($lookup_value); + $rowDataLower = StringHelper::strToLower($rowData); + if (($bothNumeric && $rowData > $lookup_value) || - ($bothNotNumeric && strtolower($rowData) > strtolower($lookup_value))) { + ($bothNotNumeric && $rowDataLower > $lookupLower)) { break; } @@ -793,7 +805,7 @@ class LookupRef $rowNumber = $rowKey; continue; - } elseif (strtolower($rowData) === strtolower($lookup_value) + } elseif ($rowDataLower === $lookupLower && ($rowNumber === null || $rowKey < $rowNumber) ) { $rowNumber = $rowKey; diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig.php index 9170196bae5..a06f3a384c9 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -1224,11 +1224,12 @@ class MathTrig } $testCondition = '=' . $arg . $condition; + $sumValue = array_key_exists($key, $sumArgs) ? $sumArgs[$key] : 0; - if (is_numeric($sumArgs[$key]) && + if (is_numeric($sumValue) && Calculation::getInstance()->_calculateFormulaValue($testCondition)) { // Is it a value within our criteria and only numeric can be added to the result - $returnValue += $sumArgs[$key]; + $returnValue += $sumValue; } } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/functionlist.txt b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/functionlist.txt index ee87c17f63c..4a5cd265ba8 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/functionlist.txt +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/functionlist.txt @@ -337,6 +337,7 @@ SUMSQ SUMX2MY2 SUMX2PY2 SUMXMY2 +SWITCH SYD T TAN diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php index efb8e5ef368..4052c23cb97 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php @@ -16,6 +16,8 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell * + * @throws \PhpOffice\PhpSpreadsheet\Exception + * * @return bool */ public function bindValue(Cell $cell, $value = null) diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php index 416b4a9909b..813eee4a091 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php @@ -523,7 +523,7 @@ class Cell /** * If this cell is in a merge range, then return the range. * - * @return string + * @return false|string */ public function getMergeRange() { diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php index 12e3b689727..5e20ec6d9dc 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php @@ -157,14 +157,12 @@ abstract class Coordinate } // Build range - $imploded = []; $counter = count($pRange); for ($i = 0; $i < $counter; ++$i) { $pRange[$i] = implode(':', $pRange[$i]); } - $imploded = implode(',', $pRange); - return $imploded; + return implode(',', $pRange); } /** diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php index 7cbb6cca27f..0e6433a4ec8 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php @@ -14,6 +14,8 @@ class DefaultValueBinder implements IValueBinder * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell * + * @throws \PhpOffice\PhpSpreadsheet\Exception + * * @return bool */ public function bindValue(Cell $cell, $value) diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/StringValueBinder.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/StringValueBinder.php new file mode 100644 index 00000000000..0552677f295 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/StringValueBinder.php @@ -0,0 +1,31 @@ +setValueExplicit((string) $value, DataType::TYPE_STRING); + + // Done! + return true; + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php index 52f70431453..3d1dd22262d 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php @@ -365,10 +365,10 @@ class Axis extends Properties } /** - * Set Shadow Properties from Maped Values. + * Set Shadow Properties from Mapped Values. * * @param array $properties_map - * @param * $reference + * @param mixed &$reference * * @return Axis */ diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php index 6e9e39dcf50..8cc83e5540c 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php @@ -319,7 +319,7 @@ class GridLines extends Properties * Set Shadow Properties Values. * * @param array $properties_map - * @param * $reference + * @param mixed &$reference * * @return GridLines */ @@ -439,7 +439,7 @@ class GridLines extends Properties { if ($size !== null) { $this->activateObject(); - $softEdges['size'] = (string) $this->getExcelPointsWidth($size); + $this->softEdges['size'] = (string) $this->getExcelPointsWidth($size); } } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php index fb5a53a063e..a8a96d2f1cb 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php @@ -175,13 +175,13 @@ class Layout /** * Set X-Mode. * - * @param X-Mode $value + * @param string $value * * @return Layout */ public function setXMode($value) { - $this->xMode = $value; + $this->xMode = (string) $value; return $this; } @@ -199,13 +199,13 @@ class Layout /** * Set Y-Mode. * - * @param Y-Mode $value + * @param string $value * * @return Layout */ public function setYMode($value) { - $this->yMode = $value; + $this->yMode = (string) $value; return $this; } @@ -223,13 +223,13 @@ class Layout /** * Set X-Position. * - * @param X-Position $value + * @param float $value * * @return Layout */ public function setXPosition($value) { - $this->xPos = $value; + $this->xPos = (float) $value; return $this; } @@ -247,13 +247,13 @@ class Layout /** * Set Y-Position. * - * @param Y-Position $value + * @param float $value * * @return Layout */ public function setYPosition($value) { - $this->yPos = $value; + $this->yPos = (float) $value; return $this; } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php index 80a43220988..84c3d3009ca 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php @@ -241,7 +241,7 @@ class Cells */ public function getHighestColumn($row = null) { - if ($row == null) { + if ($row === null) { $colRow = $this->getHighestRowAndColumn(); return $colRow['column']; @@ -259,7 +259,7 @@ class Cells $columnList[] = Coordinate::columnIndexFromString($c); } - return Coordinate::stringFromColumnIndex(max($columnList) + 1); + return Coordinate::stringFromColumnIndex(max($columnList)); } /** @@ -272,7 +272,7 @@ class Cells */ public function getHighestRow($column = null) { - if ($column == null) { + if ($column === null) { $colRow = $this->getHighestRowAndColumn(); return $colRow['row']; diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Properties.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Properties.php index bbac96d92a8..1a432db0497 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Properties.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Properties.php @@ -418,7 +418,7 @@ class Properties * * @param string $propertyName * - * @return string + * @return mixed */ public function getCustomPropertyValue($propertyName) { diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php index c191c3f8d8e..f7af1557fff 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php @@ -55,27 +55,16 @@ abstract class BaseReader implements IReader */ protected $securityScanner; - /** - * Read data only? - * If this is true, then the Reader will only read data values for cells, it will not read any formatting information. - * If false (the default) it will read data and formatting. - * - * @return bool - */ + public function __construct() + { + $this->readFilter = new DefaultReadFilter(); + } + public function getReadDataOnly() { return $this->readDataOnly; } - /** - * Set read data only - * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. - * Set to false (the default) to advise the Reader to read both data and formatting for cells. - * - * @param bool $pValue - * - * @return IReader - */ public function setReadDataOnly($pValue) { $this->readDataOnly = (bool) $pValue; @@ -83,27 +72,11 @@ abstract class BaseReader implements IReader return $this; } - /** - * Read empty cells? - * If this is true (the default), then the Reader will read data values for all cells, irrespective of value. - * If false it will not read data for cells containing a null value or an empty string. - * - * @return bool - */ public function getReadEmptyCells() { return $this->readEmptyCells; } - /** - * Set read empty cells - * Set to true (the default) to advise the Reader read data values for all cells, irrespective of value. - * Set to false to advise the Reader to ignore cells containing a null value or an empty string. - * - * @param bool $pValue - * - * @return IReader - */ public function setReadEmptyCells($pValue) { $this->readEmptyCells = (bool) $pValue; @@ -111,29 +84,11 @@ abstract class BaseReader implements IReader return $this; } - /** - * Read charts in workbook? - * If this is true, then the Reader will include any charts that exist in the workbook. - * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. - * If false (the default) it will ignore any charts defined in the workbook file. - * - * @return bool - */ public function getIncludeCharts() { return $this->includeCharts; } - /** - * Set read charts in workbook - * Set to true, to advise the Reader to include any charts that exist in the workbook. - * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. - * Set to false (the default) to discard charts. - * - * @param bool $pValue - * - * @return IReader - */ public function setIncludeCharts($pValue) { $this->includeCharts = (bool) $pValue; @@ -141,27 +96,11 @@ abstract class BaseReader implements IReader return $this; } - /** - * Get which sheets to load - * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null - * indicating that all worksheets in the workbook should be loaded. - * - * @return mixed - */ public function getLoadSheetsOnly() { return $this->loadSheetsOnly; } - /** - * Set which sheets to load. - * - * @param mixed $value - * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. - * If NULL, then it tells the Reader to read all worksheets in the workbook - * - * @return IReader - */ public function setLoadSheetsOnly($value) { if ($value === null) { @@ -173,12 +112,6 @@ abstract class BaseReader implements IReader return $this; } - /** - * Set all sheets to load - * Tells the Reader to load all worksheets from the workbook. - * - * @return IReader - */ public function setLoadAllSheets() { $this->loadSheetsOnly = null; @@ -186,23 +119,11 @@ abstract class BaseReader implements IReader return $this; } - /** - * Read filter. - * - * @return IReadFilter - */ public function getReadFilter() { return $this->readFilter; } - /** - * Set read filter. - * - * @param IReadFilter $pValue - * - * @return IReader - */ public function setReadFilter(IReadFilter $pValue) { $this->readFilter = $pValue; @@ -210,7 +131,7 @@ abstract class BaseReader implements IReader return $this; } - public function getSecuritySCanner() + public function getSecurityScanner() { if (property_exists($this, 'securityScanner')) { return $this->securityScanner; diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php index 25f244c1181..81ca1a8cf3e 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php @@ -62,7 +62,7 @@ class Csv extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); } /** @@ -143,7 +143,7 @@ class Csv extends BaseReader return; } - return $this->skipBOM(); + $this->skipBOM(); } /** @@ -155,7 +155,7 @@ class Csv extends BaseReader return; } - $potentialDelimiters = [',', ';', "\t", '|', ':', ' ']; + $potentialDelimiters = [',', ';', "\t", '|', ':', ' ', '~']; $counts = []; foreach ($potentialDelimiters as $delimiter) { $counts[$delimiter] = []; @@ -184,8 +184,9 @@ class Csv extends BaseReader // If number of lines is 0, nothing to infer : fall back to the default if ($numberLines === 0) { $this->delimiter = reset($potentialDelimiters); + $this->skipBOM(); - return $this->skipBOM(); + return; } // Calculate the mean square deviations for each delimiter (ignoring delimiters that haven't been found consistently) @@ -230,7 +231,7 @@ class Csv extends BaseReader $this->delimiter = reset($potentialDelimiters); } - return $this->skipBOM(); + $this->skipBOM(); } /** @@ -254,15 +255,13 @@ class Csv extends BaseReader $line = $line . $newLine; // Drop everything that is enclosed to avoid counting false positives in enclosures - $enclosure = preg_quote($this->enclosure, '/'); - $line = preg_replace('/(' . $enclosure . '.*' . $enclosure . ')/U', '', $line); + $enclosure = '(?escapeCharacter, '/') . ')' + . preg_quote($this->enclosure, '/'); + $line = preg_replace('/(' . $enclosure . '.*' . $enclosure . ')/Us', '', $line); // See if we have any enclosures left in the line - $matches = []; - preg_match('/(' . $enclosure . ')/', $line, $matches); - - // if we still have an enclosure then we need to read the next line aswell - if (count($matches) > 0) { + // if we still have an enclosure then we need to read the next line as well + if (preg_match('/(' . $enclosure . ')/', $line) > 0) { $line = $this->getNextLine($line); } @@ -547,7 +546,8 @@ class Csv extends BaseReader fclose($this->fileHandle); // Trust file extension if any - if (strtolower(pathinfo($pFilename, PATHINFO_EXTENSION)) === 'csv') { + $extension = strtolower(pathinfo($pFilename, PATHINFO_EXTENSION)); + if (in_array($extension, ['csv', 'tsv'])) { return true; } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric.php index 16f1925a738..7445ef1bf25 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -36,7 +36,7 @@ class Gnumeric extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); $this->referenceHelper = ReferenceHelper::getInstance(); $this->securityScanner = XmlScanner::getInstance($this); } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Html.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Html.php index d9f25a3166d..2e823f03bb5 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Html.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Html.php @@ -12,6 +12,9 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Color; use PhpOffice\PhpSpreadsheet\Style\Fill; +use PhpOffice\PhpSpreadsheet\Style\Font; +use PhpOffice\PhpSpreadsheet\Style\Style; +use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; /** PhpSpreadsheet root directory */ @@ -96,6 +99,26 @@ class Html extends BaseReader ], ], ], // Bottom border + 'strong' => [ + 'font' => [ + 'bold' => true, + ], + ], // Bold + 'b' => [ + 'font' => [ + 'bold' => true, + ], + ], // Bold + 'i' => [ + 'font' => [ + 'italic' => true, + ], + ], // Italic + 'em' => [ + 'font' => [ + 'italic' => true, + ], + ], // Italic ]; protected $rowspan = []; @@ -105,7 +128,7 @@ class Html extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); $this->securityScanner = XmlScanner::getInstance($this); } @@ -295,11 +318,9 @@ class Html extends BaseReader switch ($child->nodeName) { case 'meta': foreach ($attributeArray as $attributeName => $attributeValue) { - switch ($attributeName) { - case 'content': - // TODO - // Extract character set, so we can convert to UTF-8 if required - break; + // Extract character set, so we can convert to UTF-8 if required + if ($attributeName === 'charset') { + $this->setInputEncoding($attributeValue); } } $this->processDomElement($child, $sheet, $row, $column, $cellContent); @@ -334,6 +355,10 @@ class Html extends BaseReader $cellContent .= ' '; } + if (isset($this->formats[$child->nodeName])) { + $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); + } + break; case 'hr': $this->flushCell($sheet, $column, $row, $cellContent); @@ -423,6 +448,10 @@ class Html extends BaseReader $column = 'A'; } + break; + case 'img': + $this->insertImage($sheet, $column, $row, $attributeArray); + break; case 'table': $this->flushCell($sheet, $column, $row, $cellContent); @@ -448,6 +477,11 @@ class Html extends BaseReader $column = $this->getTableStartColumn(); $cellContent = ''; $this->processDomElement($child, $sheet, $row, $column, $cellContent); + + if (isset($attributeArray['height'])) { + $sheet->getRowDimension($row)->setRowHeight($attributeArray['height']); + } + ++$row; break; @@ -501,6 +535,27 @@ class Html extends BaseReader ] ); } + + if (isset($attributeArray['width'])) { + $sheet->getColumnDimension($column)->setWidth($attributeArray['width']); + } + + if (isset($attributeArray['height'])) { + $sheet->getRowDimension($row)->setRowHeight($attributeArray['height']); + } + + if (isset($attributeArray['align'])) { + $sheet->getStyle($column . $row)->getAlignment()->setHorizontal($attributeArray['align']); + } + + if (isset($attributeArray['valign'])) { + $sheet->getStyle($column . $row)->getAlignment()->setVertical($attributeArray['valign']); + } + + if (isset($attributeArray['data-format'])) { + $sheet->getStyle($column . $row)->getNumberFormat()->setFormatCode($attributeArray['data-format']); + } + ++$column; break; @@ -608,36 +663,271 @@ class Html extends BaseReader return; } - $supported_styles = ['background-color', 'color']; + $cellStyle = $sheet->getStyle($column . $row); // add color styles (background & text) from dom element,currently support : td & th, using ONLY inline css style with RGB color $styles = explode(';', $attributeArray['style']); foreach ($styles as $st) { $value = explode(':', $st); + $styleName = isset($value[0]) ? trim($value[0]) : null; + $styleValue = isset($value[1]) ? trim($value[1]) : null; - if (empty(trim($value[0])) || !in_array(trim($value[0]), $supported_styles)) { + if (!$styleName) { continue; } - //check if has #, so we can get clean hex - if (substr(trim($value[1]), 0, 1) == '#') { - $style_color = substr(trim($value[1]), 1); - } - - if (empty($style_color)) { - continue; - } - - switch (trim($value[0])) { + switch ($styleName) { + case 'background': case 'background-color': - $sheet->getStyle($column . $row)->applyFromArray(['fill' => ['fillType' => Fill::FILL_SOLID, 'color' => ['rgb' => "{$style_color}"]]]); + $styleColor = $this->getStyleColor($styleValue); + + if (!$styleColor) { + continue 2; + } + + $cellStyle->applyFromArray(['fill' => ['fillType' => Fill::FILL_SOLID, 'color' => ['rgb' => $styleColor]]]); break; case 'color': - $sheet->getStyle($column . $row)->applyFromArray(['font' => ['color' => ['rgb' => "{$style_color}"]]]); + $styleColor = $this->getStyleColor($styleValue); + + if (!$styleColor) { + continue 2; + } + + $cellStyle->applyFromArray(['font' => ['color' => ['rgb' => $styleColor]]]); + + break; + + case 'border': + $this->setBorderStyle($cellStyle, $styleValue, 'allBorders'); + + break; + + case 'border-top': + $this->setBorderStyle($cellStyle, $styleValue, 'top'); + + break; + + case 'border-bottom': + $this->setBorderStyle($cellStyle, $styleValue, 'bottom'); + + break; + + case 'border-left': + $this->setBorderStyle($cellStyle, $styleValue, 'left'); + + break; + + case 'border-right': + $this->setBorderStyle($cellStyle, $styleValue, 'right'); + + break; + + case 'font-size': + $cellStyle->getFont()->setSize( + (float) $styleValue + ); + + break; + + case 'font-weight': + if ($styleValue === 'bold' || $styleValue >= 500) { + $cellStyle->getFont()->setBold(true); + } + + break; + + case 'font-style': + if ($styleValue === 'italic') { + $cellStyle->getFont()->setItalic(true); + } + + break; + + case 'font-family': + $cellStyle->getFont()->setName(str_replace('\'', '', $styleValue)); + + break; + + case 'text-decoration': + switch ($styleValue) { + case 'underline': + $cellStyle->getFont()->setUnderline(Font::UNDERLINE_SINGLE); + + break; + case 'line-through': + $cellStyle->getFont()->setStrikethrough(true); + + break; + } + + break; + + case 'text-align': + $cellStyle->getAlignment()->setHorizontal($styleValue); + + break; + + case 'vertical-align': + $cellStyle->getAlignment()->setVertical($styleValue); + + break; + + case 'width': + $sheet->getColumnDimension($column)->setWidth( + str_replace('px', '', $styleValue) + ); + + break; + + case 'height': + $sheet->getRowDimension($row)->setRowHeight( + str_replace('px', '', $styleValue) + ); + + break; + + case 'word-wrap': + $cellStyle->getAlignment()->setWrapText( + $styleValue === 'break-word' + ); + + break; + + case 'text-indent': + $cellStyle->getAlignment()->setIndent( + (int) str_replace(['px'], '', $styleValue) + ); break; } } } + + /** + * Check if has #, so we can get clean hex. + * + * @param $value + * + * @return null|string + */ + public function getStyleColor($value) + { + if (strpos($value, '#') === 0) { + return substr($value, 1); + } + + return null; + } + + /** + * @param Worksheet $sheet + * @param string $column + * @param int $row + * @param array $attributes + * + * @throws \PhpOffice\PhpSpreadsheet\Exception + */ + private function insertImage(Worksheet $sheet, $column, $row, array $attributes) + { + if (!isset($attributes['src'])) { + return; + } + + $src = urldecode($attributes['src']); + $width = isset($attributes['width']) ? (float) $attributes['width'] : null; + $height = isset($attributes['height']) ? (float) $attributes['height'] : null; + $name = isset($attributes['alt']) ? (float) $attributes['alt'] : null; + + $drawing = new Drawing(); + $drawing->setPath($src); + $drawing->setWorksheet($sheet); + $drawing->setCoordinates($column . $row); + $drawing->setOffsetX(0); + $drawing->setOffsetY(10); + $drawing->setResizeProportional(true); + + if ($name) { + $drawing->setName($name); + } + + if ($width) { + $drawing->setWidth((int) $width); + } + + if ($height) { + $drawing->setHeight((int) $height); + } + + $sheet->getColumnDimension($column)->setWidth( + $drawing->getWidth() / 6 + ); + + $sheet->getRowDimension($row)->setRowHeight( + $drawing->getHeight() * 0.9 + ); + } + + /** + * Map html border style to PhpSpreadsheet border style. + * + * @param string $style + * + * @return null|string + */ + public function getBorderStyle($style) + { + switch ($style) { + case 'solid': + return Border::BORDER_THIN; + case 'dashed': + return Border::BORDER_DASHED; + case 'dotted': + return Border::BORDER_DOTTED; + case 'medium': + return Border::BORDER_MEDIUM; + case 'thick': + return Border::BORDER_THICK; + case 'none': + return Border::BORDER_NONE; + case 'dash-dot': + return Border::BORDER_DASHDOT; + case 'dash-dot-dot': + return Border::BORDER_DASHDOTDOT; + case 'double': + return Border::BORDER_DOUBLE; + case 'hair': + return Border::BORDER_HAIR; + case 'medium-dash-dot': + return Border::BORDER_MEDIUMDASHDOT; + case 'medium-dash-dot-dot': + return Border::BORDER_MEDIUMDASHDOTDOT; + case 'medium-dashed': + return Border::BORDER_MEDIUMDASHED; + case 'slant-dash-dot': + return Border::BORDER_SLANTDASHDOT; + } + + return null; + } + + /** + * @param Style $cellStyle + * @param string $styleValue + * @param string $type + */ + private function setBorderStyle(Style $cellStyle, $styleValue, $type) + { + list(, $borderStyle, $color) = explode(' ', $styleValue); + + $cellStyle->applyFromArray([ + 'borders' => [ + $type => [ + 'borderStyle' => $this->getBorderStyle($borderStyle), + 'color' => ['rgb' => $this->getStyleColor($color)], + ], + ], + ]); + } } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReader.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReader.php index e35c4ee6255..70a7a200d78 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReader.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReader.php @@ -18,6 +18,112 @@ interface IReader */ public function canRead($pFilename); + /** + * Read data only? + * If this is true, then the Reader will only read data values for cells, it will not read any formatting information. + * If false (the default) it will read data and formatting. + * + * @return bool + */ + public function getReadDataOnly(); + + /** + * Set read data only + * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. + * Set to false (the default) to advise the Reader to read both data and formatting for cells. + * + * @param bool $pValue + * + * @return IReader + */ + public function setReadDataOnly($pValue); + + /** + * Read empty cells? + * If this is true (the default), then the Reader will read data values for all cells, irrespective of value. + * If false it will not read data for cells containing a null value or an empty string. + * + * @return bool + */ + public function getReadEmptyCells(); + + /** + * Set read empty cells + * Set to true (the default) to advise the Reader read data values for all cells, irrespective of value. + * Set to false to advise the Reader to ignore cells containing a null value or an empty string. + * + * @param bool $pValue + * + * @return IReader + */ + public function setReadEmptyCells($pValue); + + /** + * Read charts in workbook? + * If this is true, then the Reader will include any charts that exist in the workbook. + * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. + * If false (the default) it will ignore any charts defined in the workbook file. + * + * @return bool + */ + public function getIncludeCharts(); + + /** + * Set read charts in workbook + * Set to true, to advise the Reader to include any charts that exist in the workbook. + * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. + * Set to false (the default) to discard charts. + * + * @param bool $pValue + * + * @return IReader + */ + public function setIncludeCharts($pValue); + + /** + * Get which sheets to load + * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null + * indicating that all worksheets in the workbook should be loaded. + * + * @return mixed + */ + public function getLoadSheetsOnly(); + + /** + * Set which sheets to load. + * + * @param mixed $value + * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. + * If NULL, then it tells the Reader to read all worksheets in the workbook + * + * @return IReader + */ + public function setLoadSheetsOnly($value); + + /** + * Set all sheets to load + * Tells the Reader to load all worksheets from the workbook. + * + * @return IReader + */ + public function setLoadAllSheets(); + + /** + * Read filter. + * + * @return IReadFilter + */ + public function getReadFilter(); + + /** + * Set read filter. + * + * @param IReadFilter $pValue + * + * @return IReader + */ + public function setReadFilter(IReadFilter $pValue); + /** * Loads PhpSpreadsheet from file. * diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods.php index 0941f035dff..51462c2003e 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods.php @@ -7,7 +7,7 @@ use DateTimeZone; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\DataType; -use PhpOffice\PhpSpreadsheet\Document\Properties; +use PhpOffice\PhpSpreadsheet\Reader\Ods\Properties as DocumentProperties; use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner; use PhpOffice\PhpSpreadsheet\RichText\RichText; use PhpOffice\PhpSpreadsheet\Settings; @@ -25,7 +25,7 @@ class Ods extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); $this->securityScanner = XmlScanner::getInstance($this); } @@ -52,7 +52,7 @@ class Ods extends BaseReader $stat = $zip->statName('mimetype'); if ($stat && ($stat['size'] <= 255)) { $mimeType = $zip->getFromName($stat['name']); - } elseif ($stat = $zip->statName('META-INF/manifest.xml')) { + } elseif ($zip->statName('META-INF/manifest.xml')) { $xml = simplexml_load_string( $this->securityScanner->scan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', @@ -265,7 +265,7 @@ class Ods extends BaseReader $zip = new ZipArchive(); if (!$zip->open($pFilename)) { - throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.'); + throw new Exception("Could not open {$pFilename} for reading! Error opening file."); } // Meta @@ -275,97 +275,13 @@ class Ods extends BaseReader 'SimpleXMLElement', Settings::getLibXmlLoaderOptions() ); + if ($xml === false) { + throw new Exception('Unable to read data from {$pFilename}'); + } + $namespacesMeta = $xml->getNamespaces(true); - $docProps = $spreadsheet->getProperties(); - $officeProperty = $xml->children($namespacesMeta['office']); - foreach ($officeProperty as $officePropertyData) { - $officePropertyDC = []; - if (isset($namespacesMeta['dc'])) { - $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); - } - foreach ($officePropertyDC as $propertyName => $propertyValue) { - $propertyValue = (string) $propertyValue; - switch ($propertyName) { - case 'title': - $docProps->setTitle($propertyValue); - - break; - case 'subject': - $docProps->setSubject($propertyValue); - - break; - case 'creator': - $docProps->setCreator($propertyValue); - $docProps->setLastModifiedBy($propertyValue); - - break; - case 'date': - $creationDate = strtotime($propertyValue); - $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); - - break; - case 'description': - $docProps->setDescription($propertyValue); - - break; - } - } - $officePropertyMeta = []; - if (isset($namespacesMeta['dc'])) { - $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); - } - foreach ($officePropertyMeta as $propertyName => $propertyValue) { - $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); - $propertyValue = (string) $propertyValue; - switch ($propertyName) { - case 'initial-creator': - $docProps->setCreator($propertyValue); - - break; - case 'keyword': - $docProps->setKeywords($propertyValue); - - break; - case 'creation-date': - $creationDate = strtotime($propertyValue); - $docProps->setCreated($creationDate); - - break; - case 'user-defined': - $propertyValueType = Properties::PROPERTY_TYPE_STRING; - foreach ($propertyValueAttributes as $key => $value) { - if ($key == 'name') { - $propertyValueName = (string) $value; - } elseif ($key == 'value-type') { - switch ($value) { - case 'date': - $propertyValue = Properties::convertProperty($propertyValue, 'date'); - $propertyValueType = Properties::PROPERTY_TYPE_DATE; - - break; - case 'boolean': - $propertyValue = Properties::convertProperty($propertyValue, 'bool'); - $propertyValueType = Properties::PROPERTY_TYPE_BOOLEAN; - - break; - case 'float': - $propertyValue = Properties::convertProperty($propertyValue, 'r4'); - $propertyValueType = Properties::PROPERTY_TYPE_FLOAT; - - break; - default: - $propertyValueType = Properties::PROPERTY_TYPE_STRING; - } - } - } - $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType); - - break; - } - } - } + (new DocumentProperties($spreadsheet))->load($xml, $namespacesMeta); // Content @@ -513,7 +429,7 @@ class Ods extends BaseReader foreach ($paragraphs as $pData) { $dataArray[] = $this->scanElementForText($pData); } - $allCellDataText = implode($dataArray, "\n"); + $allCellDataText = implode("\n", $dataArray); $type = $cellData->getAttributeNS($officeNs, 'value-type'); @@ -580,12 +496,12 @@ class Ods extends BaseReader ); $dataValue = Date::formattedPHPToExcel( - $year, - $month, - $day, - $hour, - $minute, - $second + (int) $year, + (int) $month, + (int) $day, + (int) $hour, + (int) $minute, + (int) $second ); if ($dataValue != floor($dataValue)) { diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/Properties.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/Properties.php new file mode 100644 index 00000000000..8b6122c56e7 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/Properties.php @@ -0,0 +1,136 @@ +spreadsheet = $spreadsheet; + } + + public function load(\SimpleXMLElement $xml, $namespacesMeta) + { + $docProps = $this->spreadsheet->getProperties(); + $officeProperty = $xml->children($namespacesMeta['office']); + foreach ($officeProperty as $officePropertyData) { + /** @var \SimpleXMLElement $officePropertyData */ + $officePropertiesDC = (object) []; + if (isset($namespacesMeta['dc'])) { + $officePropertiesDC = $officePropertyData->children($namespacesMeta['dc']); + } + $this->setCoreProperties($docProps, $officePropertiesDC); + + $officePropertyMeta = (object) []; + if (isset($namespacesMeta['dc'])) { + $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); + } + foreach ($officePropertyMeta as $propertyName => $propertyValue) { + $this->setMetaProperties($namespacesMeta, $propertyValue, $propertyName, $docProps); + } + } + } + + private function setCoreProperties(DocumentProperties $docProps, \SimpleXMLElement $officePropertyDC) + { + foreach ($officePropertyDC as $propertyName => $propertyValue) { + $propertyValue = (string) $propertyValue; + switch ($propertyName) { + case 'title': + $docProps->setTitle($propertyValue); + + break; + case 'subject': + $docProps->setSubject($propertyValue); + + break; + case 'creator': + $docProps->setCreator($propertyValue); + $docProps->setLastModifiedBy($propertyValue); + + break; + case 'creation-date': + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + $docProps->setModified($creationDate); + + break; + case 'keyword': + $docProps->setKeywords($propertyValue); + + break; + case 'description': + $docProps->setDescription($propertyValue); + + break; + } + } + } + + private function setMetaProperties( + $namespacesMeta, + \SimpleXMLElement $propertyValue, + $propertyName, + DocumentProperties $docProps + ) { + $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); + $propertyValue = (string) $propertyValue; + switch ($propertyName) { + case 'initial-creator': + $docProps->setCreator($propertyValue); + + break; + case 'keyword': + $docProps->setKeywords($propertyValue); + + break; + case 'creation-date': + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + + break; + case 'user-defined': + $this->setUserDefinedProperty($propertyValueAttributes, $propertyValue, $docProps); + + break; + } + } + + private function setUserDefinedProperty($propertyValueAttributes, $propertyValue, DocumentProperties $docProps) + { + $propertyValueName = ''; + $propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING; + foreach ($propertyValueAttributes as $key => $value) { + if ($key == 'name') { + $propertyValueName = (string) $value; + } elseif ($key == 'value-type') { + switch ($value) { + case 'date': + $propertyValue = DocumentProperties::convertProperty($propertyValue, 'date'); + $propertyValueType = DocumentProperties::PROPERTY_TYPE_DATE; + + break; + case 'boolean': + $propertyValue = DocumentProperties::convertProperty($propertyValue, 'bool'); + $propertyValueType = DocumentProperties::PROPERTY_TYPE_BOOLEAN; + + break; + case 'float': + $propertyValue = DocumentProperties::convertProperty($propertyValue, 'r4'); + $propertyValueType = DocumentProperties::PROPERTY_TYPE_FLOAT; + + break; + default: + $propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING; + } + } + } + + $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType); + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php index b5f7ac60fdc..732f0bf612c 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php @@ -3,16 +3,10 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Security; use PhpOffice\PhpSpreadsheet\Reader; +use PhpOffice\PhpSpreadsheet\Settings; class XmlScanner { - /** - * Identifies whether the thread-safe libxmlDisableEntityLoader() function is available. - * - * @var bool - */ - private $libxmlDisableEntityLoader = false; - /** * String used to identify risky xml elements. * @@ -22,10 +16,16 @@ class XmlScanner private $callback; - private function __construct($pattern = 'pattern = $pattern; - $this->libxmlDisableEntityLoader = $this->identifyLibxmlDisableEntityLoaderAvailability(); + + $this->disableEntityLoaderCheck(); + + // A fatal error will bypass the destructor, so we register a shutdown here + register_shutdown_function([__CLASS__, 'shutdown']); } public static function getInstance(Reader\IReader $reader) @@ -43,7 +43,7 @@ class XmlScanner } } - private function identifyLibxmlDisableEntityLoaderAvailability() + public static function threadSafeLibxmlDisableEntityLoaderAvailability() { if (PHP_MAJOR_VERSION == 7) { switch (PHP_MINOR_VERSION) { @@ -61,11 +61,54 @@ class XmlScanner return false; } + private function disableEntityLoaderCheck() + { + if (Settings::getLibXmlDisableEntityLoader()) { + $libxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true); + + if (self::$libxmlDisableEntityLoaderValue === null) { + self::$libxmlDisableEntityLoaderValue = $libxmlDisableEntityLoaderValue; + } + } + } + + public static function shutdown() + { + if (self::$libxmlDisableEntityLoaderValue !== null) { + libxml_disable_entity_loader(self::$libxmlDisableEntityLoaderValue); + self::$libxmlDisableEntityLoaderValue = null; + } + } + + public function __destruct() + { + self::shutdown(); + } + public function setAdditionalCallback(callable $callback) { $this->callback = $callback; } + private function toUtf8($xml) + { + $pattern = '/encoding="(.*?)"/'; + $result = preg_match($pattern, $xml, $matches); + $charset = strtoupper($result ? $matches[1] : 'UTF-8'); + + if ($charset !== 'UTF-8') { + $xml = mb_convert_encoding($xml, 'UTF-8', $charset); + + $result = preg_match($pattern, $xml, $matches); + $charset = strtoupper($result ? $matches[1] : 'UTF-8'); + if ($charset !== 'UTF-8') { + throw new Reader\Exception('Suspicious Double-encoded XML, spreadsheet file load() aborted to prevent XXE/XEE attacks'); + } + } + + return $xml; + } + /** * Scan the XML for use of libxmlDisableEntityLoader) { - $previousLibxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true); - } + $this->disableEntityLoaderCheck(); - $pattern = '/encoding="(.*?)"/'; - $result = preg_match($pattern, $xml, $matches); - $charset = $result ? $matches[1] : 'UTF-8'; - - if ($charset !== 'UTF-8') { - $xml = mb_convert_encoding($xml, 'UTF-8', $charset); - } + $xml = $this->toUtf8($xml); // Don't rely purely on libxml_disable_entity_loader() $pattern = '/\\0?' . implode('\\0?', str_split($this->pattern)) . '\\0?/'; - try { - if (preg_match($pattern, $xml)) { - throw new Reader\Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks'); - } + if (preg_match($pattern, $xml)) { + throw new Reader\Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks'); + } - if ($this->callback !== null && is_callable($this->callback)) { - $xml = call_user_func($this->callback, $xml); - } - } finally { - if (isset($previousLibxmlDisableEntityLoaderValue)) { - libxml_disable_entity_loader($previousLibxmlDisableEntityLoaderValue); - } + if ($this->callback !== null && is_callable($this->callback)) { + $xml = call_user_func($this->callback, $xml); } return $xml; diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Slk.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Slk.php index 61e52334b5c..c1013c2eb22 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Slk.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Slk.php @@ -43,7 +43,7 @@ class Slk extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); } /** diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php index 514adae2743..bd2c9c1db5b 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php @@ -412,7 +412,7 @@ class Xls extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); } /** diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php index 335f5d7e99c..5372fef9c13 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php @@ -4,10 +4,19 @@ namespace PhpOffice\PhpSpreadsheet\Reader; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\Hyperlink; -use PhpOffice\PhpSpreadsheet\Document\Properties; use PhpOffice\PhpSpreadsheet\NamedRange; use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\AutoFilter; use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Chart; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\ColumnAndRowAttributes; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\ConditionalStyles; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\DataValidations; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Hyperlinks; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\PageSetup; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Properties as PropertyReader; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\SheetViewOptions; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\SheetViews; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles; use PhpOffice\PhpSpreadsheet\ReferenceHelper; use PhpOffice\PhpSpreadsheet\RichText\RichText; use PhpOffice\PhpSpreadsheet\Settings; @@ -20,11 +29,9 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Borders; use PhpOffice\PhpSpreadsheet\Style\Color; -use PhpOffice\PhpSpreadsheet\Style\Conditional; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\Protection; use PhpOffice\PhpSpreadsheet\Style\Style; -use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column; use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use SimpleXMLElement; @@ -52,7 +59,7 @@ class Xlsx extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); $this->referenceHelper = ReferenceHelper::getInstance(); $this->securityScanner = XmlScanner::getInstance($this); } @@ -323,60 +330,6 @@ class Xlsx extends BaseReader return $contents; } - /** - * Set Worksheet column attributes by attributes array passed. - * - * @param Worksheet $docSheet - * @param string $column A, B, ... DX, ... - * @param array $columnAttributes array of attributes (indexes are attribute name, values are value) - * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'width', ... ? - */ - private function setColumnAttributes(Worksheet $docSheet, $column, array $columnAttributes) - { - if (isset($columnAttributes['xfIndex'])) { - $docSheet->getColumnDimension($column)->setXfIndex($columnAttributes['xfIndex']); - } - if (isset($columnAttributes['visible'])) { - $docSheet->getColumnDimension($column)->setVisible($columnAttributes['visible']); - } - if (isset($columnAttributes['collapsed'])) { - $docSheet->getColumnDimension($column)->setCollapsed($columnAttributes['collapsed']); - } - if (isset($columnAttributes['outlineLevel'])) { - $docSheet->getColumnDimension($column)->setOutlineLevel($columnAttributes['outlineLevel']); - } - if (isset($columnAttributes['width'])) { - $docSheet->getColumnDimension($column)->setWidth($columnAttributes['width']); - } - } - - /** - * Set Worksheet row attributes by attributes array passed. - * - * @param Worksheet $docSheet - * @param int $row 1, 2, 3, ... 99, ... - * @param array $rowAttributes array of attributes (indexes are attribute name, values are value) - * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'rowHeight', ... ? - */ - private function setRowAttributes(Worksheet $docSheet, $row, array $rowAttributes) - { - if (isset($rowAttributes['xfIndex'])) { - $docSheet->getRowDimension($row)->setXfIndex($rowAttributes['xfIndex']); - } - if (isset($rowAttributes['visible'])) { - $docSheet->getRowDimension($row)->setVisible($rowAttributes['visible']); - } - if (isset($rowAttributes['collapsed'])) { - $docSheet->getRowDimension($row)->setCollapsed($rowAttributes['collapsed']); - } - if (isset($rowAttributes['outlineLevel'])) { - $docSheet->getRowDimension($row)->setOutlineLevel($rowAttributes['outlineLevel']); - } - if (isset($rowAttributes['rowHeight'])) { - $docSheet->getRowDimension($row)->setRowHeight($rowAttributes['rowHeight']); - } - } - /** * Loads Spreadsheet from file. * @@ -456,70 +409,20 @@ class Xlsx extends BaseReader 'SimpleXMLElement', Settings::getLibXmlLoaderOptions() ); + + $propertyReader = new PropertyReader($this->securityScanner, $excel->getProperties()); foreach ($rels->Relationship as $rel) { switch ($rel['Type']) { case 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties': - $xmlCore = simplexml_load_string( - $this->securityScanner->scan($this->getFromZipArchive($zip, "{$rel['Target']}")), - 'SimpleXMLElement', - Settings::getLibXmlLoaderOptions() - ); - if (is_object($xmlCore)) { - $xmlCore->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/'); - $xmlCore->registerXPathNamespace('dcterms', 'http://purl.org/dc/terms/'); - $xmlCore->registerXPathNamespace('cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); - $docProps = $excel->getProperties(); - $docProps->setCreator((string) self::getArrayItem($xmlCore->xpath('dc:creator'))); - $docProps->setLastModifiedBy((string) self::getArrayItem($xmlCore->xpath('cp:lastModifiedBy'))); - $docProps->setCreated(strtotime(self::getArrayItem($xmlCore->xpath('dcterms:created')))); //! respect xsi:type - $docProps->setModified(strtotime(self::getArrayItem($xmlCore->xpath('dcterms:modified')))); //! respect xsi:type - $docProps->setTitle((string) self::getArrayItem($xmlCore->xpath('dc:title'))); - $docProps->setDescription((string) self::getArrayItem($xmlCore->xpath('dc:description'))); - $docProps->setSubject((string) self::getArrayItem($xmlCore->xpath('dc:subject'))); - $docProps->setKeywords((string) self::getArrayItem($xmlCore->xpath('cp:keywords'))); - $docProps->setCategory((string) self::getArrayItem($xmlCore->xpath('cp:category'))); - } + $propertyReader->readCoreProperties($this->getFromZipArchive($zip, "{$rel['Target']}")); break; case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties': - $xmlCore = simplexml_load_string( - $this->securityScanner->scan($this->getFromZipArchive($zip, "{$rel['Target']}")), - 'SimpleXMLElement', - Settings::getLibXmlLoaderOptions() - ); - if (is_object($xmlCore)) { - $docProps = $excel->getProperties(); - if (isset($xmlCore->Company)) { - $docProps->setCompany((string) $xmlCore->Company); - } - if (isset($xmlCore->Manager)) { - $docProps->setManager((string) $xmlCore->Manager); - } - } + $propertyReader->readExtendedProperties($this->getFromZipArchive($zip, "{$rel['Target']}")); break; case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties': - $xmlCore = simplexml_load_string( - $this->securityScanner->scan($this->getFromZipArchive($zip, "{$rel['Target']}")), - 'SimpleXMLElement', - Settings::getLibXmlLoaderOptions() - ); - if (is_object($xmlCore)) { - $docProps = $excel->getProperties(); - /** @var SimpleXMLElement $xmlProperty */ - foreach ($xmlCore as $xmlProperty) { - $cellDataOfficeAttributes = $xmlProperty->attributes(); - if (isset($cellDataOfficeAttributes['name'])) { - $propertyName = (string) $cellDataOfficeAttributes['name']; - $cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); - $attributeType = $cellDataOfficeChildren->getName(); - $attributeValue = (string) $cellDataOfficeChildren->{$attributeType}; - $attributeValue = Properties::convertProperty($attributeValue, $attributeType); - $attributeType = Properties::convertPropertyType($attributeType); - $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType); - } - } - } + $propertyReader->readCustomProperties($this->getFromZipArchive($zip, "{$rel['Target']}")); break; //Ribbon @@ -586,8 +489,7 @@ class Xlsx extends BaseReader } } } - $styles = []; - $cellStyles = []; + $xpath = self::getArrayItem($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main" $xmlStyles = simplexml_load_string( @@ -595,6 +497,9 @@ class Xlsx extends BaseReader 'SimpleXMLElement', Settings::getLibXmlLoaderOptions() ); + + $styles = []; + $cellStyles = []; $numFmts = null; if ($xmlStyles && $xmlStyles->numFmts[0]) { $numFmts = $xmlStyles->numFmts[0]; @@ -674,31 +579,10 @@ class Xlsx extends BaseReader } } - $dxfs = []; - if (!$this->readDataOnly && $xmlStyles) { - // Conditional Styles - if ($xmlStyles->dxfs) { - foreach ($xmlStyles->dxfs->dxf as $dxf) { - $style = new Style(false, true); - self::readStyle($style, $dxf); - $dxfs[] = $style; - } - } - // Cell Styles - if ($xmlStyles->cellStyles) { - foreach ($xmlStyles->cellStyles->cellStyle as $cellStyle) { - if ((int) ($cellStyle['builtinId']) == 0) { - if (isset($cellStyles[(int) ($cellStyle['xfId'])])) { - // Set default style - $style = new Style(); - self::readStyle($style, $cellStyles[(int) ($cellStyle['xfId'])]); - - // normal style, currently not using it for anything - } - } - } - } - } + $styleReader = new Styles($xmlStyles); + $styleReader->setStyleBaseData(self::$theme, $styles, $cellStyles); + $dxfs = $styleReader->dxfs($this->readDataOnly); + $styles = $styleReader->styles(); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main" $xmlWorkbook = simplexml_load_string( @@ -765,134 +649,19 @@ class Xlsx extends BaseReader $docSheet->setSheetState((string) $eleSheet['state']); } - if (isset($xmlSheet->sheetViews, $xmlSheet->sheetViews->sheetView)) { - if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) { - $zoomScale = (int) ($xmlSheet->sheetViews->sheetView['zoomScale']); - if ($zoomScale <= 0) { - // setZoomScale will throw an Exception if the scale is less than or equals 0 - // that is OK when manually creating documents, but we should be able to read all documents - $zoomScale = 100; - } - - $docSheet->getSheetView()->setZoomScale($zoomScale); - } - if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) { - $zoomScaleNormal = (int) ($xmlSheet->sheetViews->sheetView['zoomScaleNormal']); - if ($zoomScaleNormal <= 0) { - // setZoomScaleNormal will throw an Exception if the scale is less than or equals 0 - // that is OK when manually creating documents, but we should be able to read all documents - $zoomScaleNormal = 100; - } - - $docSheet->getSheetView()->setZoomScaleNormal($zoomScaleNormal); - } - if (isset($xmlSheet->sheetViews->sheetView['view'])) { - $docSheet->getSheetView()->setView((string) $xmlSheet->sheetViews->sheetView['view']); - } - if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) { - $docSheet->setShowGridLines(self::boolean((string) $xmlSheet->sheetViews->sheetView['showGridLines'])); - } - if (isset($xmlSheet->sheetViews->sheetView['showRowColHeaders'])) { - $docSheet->setShowRowColHeaders(self::boolean((string) $xmlSheet->sheetViews->sheetView['showRowColHeaders'])); - } - if (isset($xmlSheet->sheetViews->sheetView['rightToLeft'])) { - $docSheet->setRightToLeft(self::boolean((string) $xmlSheet->sheetViews->sheetView['rightToLeft'])); - } - if (isset($xmlSheet->sheetViews->sheetView->pane)) { - $xSplit = 0; - $ySplit = 0; - $topLeftCell = null; - - if (isset($xmlSheet->sheetViews->sheetView->pane['xSplit'])) { - $xSplit = (int) ($xmlSheet->sheetViews->sheetView->pane['xSplit']); - } - - if (isset($xmlSheet->sheetViews->sheetView->pane['ySplit'])) { - $ySplit = (int) ($xmlSheet->sheetViews->sheetView->pane['ySplit']); - } - - if (isset($xmlSheet->sheetViews->sheetView->pane['topLeftCell'])) { - $topLeftCell = (string) $xmlSheet->sheetViews->sheetView->pane['topLeftCell']; - } - - $docSheet->freezePane(Coordinate::stringFromColumnIndex($xSplit + 1) . ($ySplit + 1), $topLeftCell); + if ($xmlSheet) { + if (isset($xmlSheet->sheetViews, $xmlSheet->sheetViews->sheetView)) { + $sheetViews = new SheetViews($xmlSheet->sheetViews->sheetView, $docSheet); + $sheetViews->load(); } - if (isset($xmlSheet->sheetViews->sheetView->selection)) { - if (isset($xmlSheet->sheetViews->sheetView->selection['sqref'])) { - $sqref = (string) $xmlSheet->sheetViews->sheetView->selection['sqref']; - $sqref = explode(' ', $sqref); - $sqref = $sqref[0]; - $docSheet->setSelectedCells($sqref); - } - } + $sheetViewOptions = new SheetViewOptions($docSheet, $xmlSheet); + $sheetViewOptions->load($this->getReadDataOnly()); + + (new ColumnAndRowAttributes($docSheet, $xmlSheet)) + ->load($this->getReadFilter(), $this->getReadDataOnly()); } - if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr->tabColor)) { - if (isset($xmlSheet->sheetPr->tabColor['rgb'])) { - $docSheet->getTabColor()->setARGB((string) $xmlSheet->sheetPr->tabColor['rgb']); - } - } - if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr['codeName'])) { - $docSheet->setCodeName((string) $xmlSheet->sheetPr['codeName'], false); - } - if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr->outlinePr)) { - if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && - !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) { - $docSheet->setShowSummaryRight(false); - } else { - $docSheet->setShowSummaryRight(true); - } - - if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && - !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryBelow'])) { - $docSheet->setShowSummaryBelow(false); - } else { - $docSheet->setShowSummaryBelow(true); - } - } - - if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr->pageSetUpPr)) { - if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && - !self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) { - $docSheet->getPageSetup()->setFitToPage(false); - } else { - $docSheet->getPageSetup()->setFitToPage(true); - } - } - - if (isset($xmlSheet->sheetFormatPr)) { - if (isset($xmlSheet->sheetFormatPr['customHeight']) && - self::boolean((string) $xmlSheet->sheetFormatPr['customHeight']) && - isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) { - $docSheet->getDefaultRowDimension()->setRowHeight((float) $xmlSheet->sheetFormatPr['defaultRowHeight']); - } - if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) { - $docSheet->getDefaultColumnDimension()->setWidth((float) $xmlSheet->sheetFormatPr['defaultColWidth']); - } - if (isset($xmlSheet->sheetFormatPr['zeroHeight']) && - ((string) $xmlSheet->sheetFormatPr['zeroHeight'] == '1')) { - $docSheet->getDefaultRowDimension()->setZeroHeight(true); - } - } - - if (isset($xmlSheet->printOptions) && !$this->readDataOnly) { - if (self::boolean((string) $xmlSheet->printOptions['gridLinesSet'])) { - $docSheet->setShowGridlines(true); - } - if (self::boolean((string) $xmlSheet->printOptions['gridLines'])) { - $docSheet->setPrintGridlines(true); - } - if (self::boolean((string) $xmlSheet->printOptions['horizontalCentered'])) { - $docSheet->getPageSetup()->setHorizontalCentered(true); - } - if (self::boolean((string) $xmlSheet->printOptions['verticalCentered'])) { - $docSheet->getPageSetup()->setVerticalCentered(true); - } - } - - $this->readColumnsAndRowsAttributes($xmlSheet, $docSheet); - if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) { $cIndex = 1; // Cell Start from 1 foreach ($xmlSheet->sheetData->row as $row) { @@ -972,38 +741,39 @@ class Xlsx extends BaseReader break; } - // Check for numeric values - if (is_numeric($value) && $cellDataType != 's') { - if ($value == (int) $value) { - $value = (int) $value; - } elseif ($value == (float) $value) { - $value = (float) $value; - } elseif ($value == (float) $value) { - $value = (float) $value; + // read empty cells or the cells are not empty + if ($this->readEmptyCells || ($value !== null && $value !== '')) { + // Check for numeric values + if (is_numeric($value) && $cellDataType != 's') { + if ($value == (int) $value) { + $value = (int) $value; + } elseif ($value == (float) $value) { + $value = (float) $value; + } } - } - // Rich text? - if ($value instanceof RichText && $this->readDataOnly) { - $value = $value->getPlainText(); - } + // Rich text? + if ($value instanceof RichText && $this->readDataOnly) { + $value = $value->getPlainText(); + } - $cell = $docSheet->getCell($r); - // Assign value - if ($cellDataType != '') { - $cell->setValueExplicit($value, $cellDataType); - } else { - $cell->setValue($value); - } - if ($calculatedValue !== null) { - $cell->setCalculatedValue($calculatedValue); - } + $cell = $docSheet->getCell($r); + // Assign value + if ($cellDataType != '') { + $cell->setValueExplicit($value, $cellDataType); + } else { + $cell->setValue($value); + } + if ($calculatedValue !== null) { + $cell->setCalculatedValue($calculatedValue); + } - // Style information? - if ($c['s'] && !$this->readDataOnly) { - // no style index means 0, it seems - $cell->setXfIndex(isset($styles[(int) ($c['s'])]) ? - (int) ($c['s']) : 0); + // Style information? + if ($c['s'] && !$this->readDataOnly) { + // no style index means 0, it seems + $cell->setXfIndex(isset($styles[(int) ($c['s'])]) ? + (int) ($c['s']) : 0); + } } $rowIndex += 1; } @@ -1011,49 +781,8 @@ class Xlsx extends BaseReader } } - $conditionals = []; if (!$this->readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) { - foreach ($xmlSheet->conditionalFormatting as $conditional) { - foreach ($conditional->cfRule as $cfRule) { - if (((string) $cfRule['type'] == Conditional::CONDITION_NONE || (string) $cfRule['type'] == Conditional::CONDITION_CELLIS || (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSTEXT || (string) $cfRule['type'] == Conditional::CONDITION_EXPRESSION) && isset($dxfs[(int) ($cfRule['dxfId'])])) { - $conditionals[(string) $conditional['sqref']][(int) ($cfRule['priority'])] = $cfRule; - } - } - } - - foreach ($conditionals as $ref => $cfRules) { - ksort($cfRules); - $conditionalStyles = []; - foreach ($cfRules as $cfRule) { - $objConditional = new Conditional(); - $objConditional->setConditionType((string) $cfRule['type']); - $objConditional->setOperatorType((string) $cfRule['operator']); - - if ((string) $cfRule['text'] != '') { - $objConditional->setText((string) $cfRule['text']); - } - - if (isset($cfRule['stopIfTrue']) && (int) $cfRule['stopIfTrue'] === 1) { - $objConditional->setStopIfTrue(true); - } - - if (count($cfRule->formula) > 1) { - foreach ($cfRule->formula as $formula) { - $objConditional->addCondition((string) $formula); - } - } else { - $objConditional->addCondition((string) $cfRule->formula); - } - $objConditional->setStyle(clone $dxfs[(int) ($cfRule['dxfId'])]); - $conditionalStyles[] = $objConditional; - } - - // Extract all cell references in $ref - $cellBlocks = explode(' ', str_replace('$', '', strtoupper($ref))); - foreach ($cellBlocks as $cellBlock) { - $docSheet->getStyle($cellBlock)->setConditionalStyles($conditionalStyles); - } - } + (new ConditionalStyles($docSheet, $xmlSheet, $dxfs))->load(); } $aKeys = ['sheet', 'objects', 'scenarios', 'formatCells', 'formatColumns', 'formatRows', 'insertColumns', 'insertRows', 'insertHyperlinks', 'deleteColumns', 'deleteRows', 'selectLockedCells', 'sort', 'autoFilter', 'pivotTables', 'selectUnlockedCells']; @@ -1074,103 +803,7 @@ class Xlsx extends BaseReader } if ($xmlSheet && $xmlSheet->autoFilter && !$this->readDataOnly) { - $autoFilterRange = (string) $xmlSheet->autoFilter['ref']; - if (strpos($autoFilterRange, ':') !== false) { - $autoFilter = $docSheet->getAutoFilter(); - $autoFilter->setRange($autoFilterRange); - - foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) { - $column = $autoFilter->getColumnByOffset((int) $filterColumn['colId']); - // Check for standard filters - if ($filterColumn->filters) { - $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER); - $filters = $filterColumn->filters; - if ((isset($filters['blank'])) && ($filters['blank'] == 1)) { - // Operator is undefined, but always treated as EQUAL - $column->createRule()->setRule(null, '')->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_FILTER); - } - // Standard filters are always an OR join, so no join rule needs to be set - // Entries can be either filter elements - foreach ($filters->filter as $filterRule) { - // Operator is undefined, but always treated as EQUAL - $column->createRule()->setRule(null, (string) $filterRule['val'])->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_FILTER); - } - // Or Date Group elements - foreach ($filters->dateGroupItem as $dateGroupItem) { - // Operator is undefined, but always treated as EQUAL - $column->createRule()->setRule( - null, - [ - 'year' => (string) $dateGroupItem['year'], - 'month' => (string) $dateGroupItem['month'], - 'day' => (string) $dateGroupItem['day'], - 'hour' => (string) $dateGroupItem['hour'], - 'minute' => (string) $dateGroupItem['minute'], - 'second' => (string) $dateGroupItem['second'], - ], - (string) $dateGroupItem['dateTimeGrouping'] - ) - ->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP); - } - } - // Check for custom filters - if ($filterColumn->customFilters) { - $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER); - $customFilters = $filterColumn->customFilters; - // Custom filters can an AND or an OR join; - // and there should only ever be one or two entries - if ((isset($customFilters['and'])) && ($customFilters['and'] == 1)) { - $column->setJoin(Column::AUTOFILTER_COLUMN_JOIN_AND); - } - foreach ($customFilters->customFilter as $filterRule) { - $column->createRule()->setRule( - (string) $filterRule['operator'], - (string) $filterRule['val'] - ) - ->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); - } - } - // Check for dynamic filters - if ($filterColumn->dynamicFilter) { - $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); - // We should only ever have one dynamic filter - foreach ($filterColumn->dynamicFilter as $filterRule) { - // Operator is undefined, but always treated as EQUAL - $column->createRule()->setRule( - null, - (string) $filterRule['val'], - (string) $filterRule['type'] - ) - ->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); - if (isset($filterRule['val'])) { - $column->setAttribute('val', (string) $filterRule['val']); - } - if (isset($filterRule['maxVal'])) { - $column->setAttribute('maxVal', (string) $filterRule['maxVal']); - } - } - } - // Check for dynamic filters - if ($filterColumn->top10) { - $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER); - // We should only ever have one top10 filter - foreach ($filterColumn->top10 as $filterRule) { - $column->createRule()->setRule( - (((isset($filterRule['percent'])) && ($filterRule['percent'] == 1)) - ? Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT - : Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE - ), - (string) $filterRule['val'], - (((isset($filterRule['top'])) && ($filterRule['top'] == 1)) - ? Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP - : Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM - ) - ) - ->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_TOPTENFILTER); - } - } - } - } + (new AutoFilter($docSheet, $xmlSheet))->load(); } if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->readDataOnly) { @@ -1182,124 +815,12 @@ class Xlsx extends BaseReader } } - if ($xmlSheet && $xmlSheet->pageMargins && !$this->readDataOnly) { - $docPageMargins = $docSheet->getPageMargins(); - $docPageMargins->setLeft((float) ($xmlSheet->pageMargins['left'])); - $docPageMargins->setRight((float) ($xmlSheet->pageMargins['right'])); - $docPageMargins->setTop((float) ($xmlSheet->pageMargins['top'])); - $docPageMargins->setBottom((float) ($xmlSheet->pageMargins['bottom'])); - $docPageMargins->setHeader((float) ($xmlSheet->pageMargins['header'])); - $docPageMargins->setFooter((float) ($xmlSheet->pageMargins['footer'])); - } - - if ($xmlSheet && $xmlSheet->pageSetup && !$this->readDataOnly) { - $docPageSetup = $docSheet->getPageSetup(); - - if (isset($xmlSheet->pageSetup['orientation'])) { - $docPageSetup->setOrientation((string) $xmlSheet->pageSetup['orientation']); - } - if (isset($xmlSheet->pageSetup['paperSize'])) { - $docPageSetup->setPaperSize((int) ($xmlSheet->pageSetup['paperSize'])); - } - if (isset($xmlSheet->pageSetup['scale'])) { - $docPageSetup->setScale((int) ($xmlSheet->pageSetup['scale']), false); - } - if (isset($xmlSheet->pageSetup['fitToHeight']) && (int) ($xmlSheet->pageSetup['fitToHeight']) >= 0) { - $docPageSetup->setFitToHeight((int) ($xmlSheet->pageSetup['fitToHeight']), false); - } - if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) { - $docPageSetup->setFitToWidth((int) ($xmlSheet->pageSetup['fitToWidth']), false); - } - if (isset($xmlSheet->pageSetup['firstPageNumber'], $xmlSheet->pageSetup['useFirstPageNumber']) && - self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) { - $docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber'])); - } - - $relAttributes = $xmlSheet->pageSetup->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - if (isset($relAttributes['id'])) { - $unparsedLoadedData['sheets'][$docSheet->getCodeName()]['pageSetupRelId'] = (string) $relAttributes['id']; - } - } - - if ($xmlSheet && $xmlSheet->headerFooter && !$this->readDataOnly) { - $docHeaderFooter = $docSheet->getHeaderFooter(); - - if (isset($xmlSheet->headerFooter['differentOddEven']) && - self::boolean((string) $xmlSheet->headerFooter['differentOddEven'])) { - $docHeaderFooter->setDifferentOddEven(true); - } else { - $docHeaderFooter->setDifferentOddEven(false); - } - if (isset($xmlSheet->headerFooter['differentFirst']) && - self::boolean((string) $xmlSheet->headerFooter['differentFirst'])) { - $docHeaderFooter->setDifferentFirst(true); - } else { - $docHeaderFooter->setDifferentFirst(false); - } - if (isset($xmlSheet->headerFooter['scaleWithDoc']) && - !self::boolean((string) $xmlSheet->headerFooter['scaleWithDoc'])) { - $docHeaderFooter->setScaleWithDocument(false); - } else { - $docHeaderFooter->setScaleWithDocument(true); - } - if (isset($xmlSheet->headerFooter['alignWithMargins']) && - !self::boolean((string) $xmlSheet->headerFooter['alignWithMargins'])) { - $docHeaderFooter->setAlignWithMargins(false); - } else { - $docHeaderFooter->setAlignWithMargins(true); - } - - $docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader); - $docHeaderFooter->setOddFooter((string) $xmlSheet->headerFooter->oddFooter); - $docHeaderFooter->setEvenHeader((string) $xmlSheet->headerFooter->evenHeader); - $docHeaderFooter->setEvenFooter((string) $xmlSheet->headerFooter->evenFooter); - $docHeaderFooter->setFirstHeader((string) $xmlSheet->headerFooter->firstHeader); - $docHeaderFooter->setFirstFooter((string) $xmlSheet->headerFooter->firstFooter); - } - - if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->readDataOnly) { - foreach ($xmlSheet->rowBreaks->brk as $brk) { - if ($brk['man']) { - $docSheet->setBreak("A$brk[id]", Worksheet::BREAK_ROW); - } - } - } - if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->readDataOnly) { - foreach ($xmlSheet->colBreaks->brk as $brk) { - if ($brk['man']) { - $docSheet->setBreak(Coordinate::stringFromColumnIndex((string) $brk['id'] + 1) . '1', Worksheet::BREAK_COLUMN); - } - } + if ($xmlSheet && !$this->readDataOnly) { + $unparsedLoadedData = (new PageSetup($docSheet, $xmlSheet))->load($unparsedLoadedData); } if ($xmlSheet && $xmlSheet->dataValidations && !$this->readDataOnly) { - foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) { - // Uppercase coordinate - $range = strtoupper($dataValidation['sqref']); - $rangeSet = explode(' ', $range); - foreach ($rangeSet as $range) { - $stRange = $docSheet->shrinkRangeToFit($range); - - // Extract all cell references in $range - foreach (Coordinate::extractAllCellReferencesInRange($stRange) as $reference) { - // Create validation - $docValidation = $docSheet->getCell($reference)->getDataValidation(); - $docValidation->setType((string) $dataValidation['type']); - $docValidation->setErrorStyle((string) $dataValidation['errorStyle']); - $docValidation->setOperator((string) $dataValidation['operator']); - $docValidation->setAllowBlank($dataValidation['allowBlank'] != 0); - $docValidation->setShowDropDown($dataValidation['showDropDown'] == 0); - $docValidation->setShowInputMessage($dataValidation['showInputMessage'] != 0); - $docValidation->setShowErrorMessage($dataValidation['showErrorMessage'] != 0); - $docValidation->setErrorTitle((string) $dataValidation['errorTitle']); - $docValidation->setError((string) $dataValidation['error']); - $docValidation->setPromptTitle((string) $dataValidation['promptTitle']); - $docValidation->setPrompt((string) $dataValidation['prompt']); - $docValidation->setFormula1((string) $dataValidation->formula1); - $docValidation->setFormula2((string) $dataValidation->formula2); - } - } - } + (new DataValidations($docSheet, $xmlSheet))->load(); } // unparsed sheet AlternateContent @@ -1313,50 +834,25 @@ class Xlsx extends BaseReader } // Add hyperlinks - $hyperlinks = []; if (!$this->readDataOnly) { + $hyperlinkReader = new Hyperlinks($docSheet); // Locate hyperlink relations - if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) { + $relationsFileName = dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels'; + if ($zip->locateName($relationsFileName)) { //~ http://schemas.openxmlformats.org/package/2006/relationships" $relsWorksheet = simplexml_load_string( $this->securityScanner->scan( - $this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels') + $this->getFromZipArchive($zip, $relationsFileName) ), 'SimpleXMLElement', Settings::getLibXmlLoaderOptions() ); - foreach ($relsWorksheet->Relationship as $ele) { - if ($ele['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink') { - $hyperlinks[(string) $ele['Id']] = (string) $ele['Target']; - } - } + $hyperlinkReader->readHyperlinks($relsWorksheet); } // Loop through hyperlinks if ($xmlSheet && $xmlSheet->hyperlinks) { - /** @var SimpleXMLElement $hyperlink */ - foreach ($xmlSheet->hyperlinks->hyperlink as $hyperlink) { - // Link url - $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - - foreach (Coordinate::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { - $cell = $docSheet->getCell($cellReference); - if (isset($linkRel['id'])) { - $hyperlinkUrl = $hyperlinks[(string) $linkRel['id']]; - if (isset($hyperlink['location'])) { - $hyperlinkUrl .= '#' . (string) $hyperlink['location']; - } - $cell->getHyperlink()->setUrl($hyperlinkUrl); - } elseif (isset($hyperlink['location'])) { - $cell->getHyperlink()->setUrl('sheet://' . (string) $hyperlink['location']); - } - - // Tooltip - if (isset($hyperlink['tooltip'])) { - $cell->getHyperlink()->setTooltip((string) $hyperlink['tooltip']); - } - } - } + $hyperlinkReader->setHyperlinks($xmlSheet->hyperlinks); } } @@ -1418,12 +914,18 @@ class Xlsx extends BaseReader foreach ($vmlComments as $relName => $relPath) { // Load VML comments file $relPath = File::realpath(dirname("$dir/$fileWorksheet") . '/' . $relPath); - $vmlCommentsFile = simplexml_load_string( - $this->securityScanner->scan($this->getFromZipArchive($zip, $relPath)), - 'SimpleXMLElement', - Settings::getLibXmlLoaderOptions() - ); - $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); + + try { + $vmlCommentsFile = simplexml_load_string( + $this->securityScanner->scan($this->getFromZipArchive($zip, $relPath)), + 'SimpleXMLElement', + Settings::getLibXmlLoaderOptions() + ); + $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); + } catch (\Throwable $ex) { + //Ignore unparsable vmlDrawings. Later they will be moved from $unparsedVmlDrawings to $unparsedLoadedData + continue; + } $shapes = $vmlCommentsFile->xpath('//v:shape'); foreach ($shapes as $shape) { @@ -1597,8 +1099,10 @@ class Xlsx extends BaseReader } } if ($xmlSheet->drawing && !$this->readDataOnly) { + $unparsedDrawings = []; foreach ($xmlSheet->drawing as $drawing) { - $fileDrawing = $drawings[(string) self::getArrayItem($drawing->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id')]; + $drawingRelId = (string) self::getArrayItem($drawing->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id'); + $fileDrawing = $drawings[$drawingRelId]; //~ http://schemas.openxmlformats.org/package/2006/relationships" $relsDrawing = simplexml_load_string( $this->securityScanner->scan( @@ -1630,10 +1134,11 @@ class Xlsx extends BaseReader $this->securityScanner->scan($this->getFromZipArchive($zip, $fileDrawing)), 'SimpleXMLElement', Settings::getLibXmlLoaderOptions() - )->children('http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing'); + ); + $xmlDrawingChildren = $xmlDrawing->children('http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing'); - if ($xmlDrawing->oneCellAnchor) { - foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) { + if ($xmlDrawingChildren->oneCellAnchor) { + foreach ($xmlDrawingChildren->oneCellAnchor as $oneCellAnchor) { if ($oneCellAnchor->pic->blipFill) { /** @var SimpleXMLElement $blip */ $blip = $oneCellAnchor->pic->blipFill->children('http://schemas.openxmlformats.org/drawingml/2006/main')->blip; @@ -1667,12 +1172,13 @@ class Xlsx extends BaseReader if ($outerShdw) { $shadow = $objDrawing->getShadow(); $shadow->setVisible(true); - $shadow->setBlurRadius(Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), 'blurRad'))); - $shadow->setDistance(Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), 'dist'))); + $shadow->setBlurRadius(Drawing::EMUToPixels(self::getArrayItem($outerShdw->attributes(), 'blurRad'))); + $shadow->setDistance(Drawing::EMUToPixels(self::getArrayItem($outerShdw->attributes(), 'dist'))); $shadow->setDirection(Drawing::angleToDegrees(self::getArrayItem($outerShdw->attributes(), 'dir'))); $shadow->setAlignment((string) self::getArrayItem($outerShdw->attributes(), 'algn')); - $shadow->getColor()->setRGB(self::getArrayItem($outerShdw->srgbClr->attributes(), 'val')); - $shadow->setAlpha(self::getArrayItem($outerShdw->srgbClr->alpha->attributes(), 'val') / 1000); + $clr = isset($outerShdw->srgbClr) ? $outerShdw->srgbClr : $outerShdw->prstClr; + $shadow->getColor()->setRGB(self::getArrayItem($clr->attributes(), 'val')); + $shadow->setAlpha(self::getArrayItem($clr->alpha->attributes(), 'val') / 1000); } $this->readHyperLinkDrawing($objDrawing, $oneCellAnchor, $hyperlinks); @@ -1688,8 +1194,8 @@ class Xlsx extends BaseReader } } } - if ($xmlDrawing->twoCellAnchor) { - foreach ($xmlDrawing->twoCellAnchor as $twoCellAnchor) { + if ($xmlDrawingChildren->twoCellAnchor) { + foreach ($xmlDrawingChildren->twoCellAnchor as $twoCellAnchor) { if ($twoCellAnchor->pic->blipFill) { $blip = $twoCellAnchor->pic->blipFill->children('http://schemas.openxmlformats.org/drawingml/2006/main')->blip; $xfrm = $twoCellAnchor->pic->spPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->xfrm; @@ -1719,12 +1225,13 @@ class Xlsx extends BaseReader if ($outerShdw) { $shadow = $objDrawing->getShadow(); $shadow->setVisible(true); - $shadow->setBlurRadius(Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), 'blurRad'))); - $shadow->setDistance(Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), 'dist'))); + $shadow->setBlurRadius(Drawing::EMUToPixels(self::getArrayItem($outerShdw->attributes(), 'blurRad'))); + $shadow->setDistance(Drawing::EMUToPixels(self::getArrayItem($outerShdw->attributes(), 'dist'))); $shadow->setDirection(Drawing::angleToDegrees(self::getArrayItem($outerShdw->attributes(), 'dir'))); $shadow->setAlignment((string) self::getArrayItem($outerShdw->attributes(), 'algn')); - $shadow->getColor()->setRGB(self::getArrayItem($outerShdw->srgbClr->attributes(), 'val')); - $shadow->setAlpha(self::getArrayItem($outerShdw->srgbClr->alpha->attributes(), 'val') / 1000); + $clr = isset($outerShdw->srgbClr) ? $outerShdw->srgbClr : $outerShdw->prstClr; + $shadow->getColor()->setRGB(self::getArrayItem($clr->attributes(), 'val')); + $shadow->setAlpha(self::getArrayItem($clr->alpha->attributes(), 'val') / 1000); } $this->readHyperLinkDrawing($objDrawing, $twoCellAnchor, $hyperlinks); @@ -1754,13 +1261,21 @@ class Xlsx extends BaseReader } } } + if ($relsDrawing === false && $xmlDrawing->count() == 0) { + // Save Drawing without rels and children as unparsed + $unparsedDrawings[$drawingRelId] = $xmlDrawing->asXML(); + } } // store original rId of drawing files $unparsedLoadedData['sheets'][$docSheet->getCodeName()]['drawingOriginalIds'] = []; foreach ($relsWorksheet->Relationship as $ele) { if ($ele['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing') { - $unparsedLoadedData['sheets'][$docSheet->getCodeName()]['drawingOriginalIds'][(string) $ele['Target']] = (string) $ele['Id']; + $drawingRelId = (string) $ele['Id']; + $unparsedLoadedData['sheets'][$docSheet->getCodeName()]['drawingOriginalIds'][(string) $ele['Target']] = $drawingRelId; + if (isset($unparsedDrawings[$drawingRelId])) { + $unparsedLoadedData['sheets'][$docSheet->getCodeName()]['Drawings'][$drawingRelId] = $unparsedDrawings[$drawingRelId]; + } } } @@ -1905,7 +1420,7 @@ class Xlsx extends BaseReader if (strpos((string) $definedName, '!') !== false) { // Extract sheet name $extractedSheetName = Worksheet::extractSheetTitle((string) $definedName, true); - $extractedSheetName = $extractedSheetName[0]; + $extractedSheetName = trim($extractedSheetName[0], "'"); // Locate sheet $locatedSheet = $excel->getSheetByName($extractedSheetName); @@ -2511,94 +2026,4 @@ class Xlsx extends BaseReader return (bool) $xsdBoolean; } - - /** - * Read columns and rows attributes from XML and set them on the worksheet. - * - * @param SimpleXMLElement $xmlSheet - * @param Worksheet $docSheet - */ - private function readColumnsAndRowsAttributes(SimpleXMLElement $xmlSheet, Worksheet $docSheet) - { - $columnsAttributes = []; - $rowsAttributes = []; - if (isset($xmlSheet->cols) && !$this->readDataOnly) { - foreach ($xmlSheet->cols->col as $col) { - for ($i = (int) ($col['min']); $i <= (int) ($col['max']); ++$i) { - if ($col['style'] && !$this->readDataOnly) { - $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['xfIndex'] = (int) $col['style']; - } - if (self::boolean($col['hidden'])) { - $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['visible'] = false; - } - if (self::boolean($col['collapsed'])) { - $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['collapsed'] = true; - } - if ($col['outlineLevel'] > 0) { - $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['outlineLevel'] = (int) $col['outlineLevel']; - } - $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['width'] = (float) $col['width']; - - if ((int) ($col['max']) == 16384) { - break; - } - } - } - } - - if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) { - foreach ($xmlSheet->sheetData->row as $row) { - if ($row['ht'] && !$this->readDataOnly) { - $rowsAttributes[(int) $row['r']]['rowHeight'] = (float) $row['ht']; - } - if (self::boolean($row['hidden']) && !$this->readDataOnly) { - $rowsAttributes[(int) $row['r']]['visible'] = false; - } - if (self::boolean($row['collapsed'])) { - $rowsAttributes[(int) $row['r']]['collapsed'] = true; - } - if ($row['outlineLevel'] > 0) { - $rowsAttributes[(int) $row['r']]['outlineLevel'] = (int) $row['outlineLevel']; - } - if ($row['s'] && !$this->readDataOnly) { - $rowsAttributes[(int) $row['r']]['xfIndex'] = (int) $row['s']; - } - } - } - - $readFilter = (\get_class($this->getReadFilter()) !== DefaultReadFilter::class ? $this->getReadFilter() : null); - - // set columns/rows attributes - $columnsAttributesSet = []; - $rowsAttributesSet = []; - foreach ($columnsAttributes as $coordColumn => $columnAttributes) { - if ($readFilter !== null) { - foreach ($rowsAttributes as $coordRow => $rowAttributes) { - if (!$readFilter->readCell($coordColumn, $coordRow, $docSheet->getTitle())) { - continue 2; - } - } - } - - if (!isset($columnsAttributesSet[$coordColumn])) { - $this->setColumnAttributes($docSheet, $coordColumn, $columnAttributes); - $columnsAttributesSet[$coordColumn] = true; - } - } - - foreach ($rowsAttributes as $coordRow => $rowAttributes) { - if ($readFilter !== null) { - foreach ($columnsAttributes as $coordColumn => $columnAttributes) { - if (!$readFilter->readCell($coordColumn, $coordRow, $docSheet->getTitle())) { - continue 2; - } - } - } - - if (!isset($rowsAttributesSet[$coordRow])) { - $this->setRowAttributes($docSheet, $coordRow, $rowAttributes); - $rowsAttributesSet[$coordRow] = true; - } - } - } } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php new file mode 100644 index 00000000000..6929758dfe9 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php @@ -0,0 +1,144 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + } + + public function load() + { + $autoFilterRange = (string) $this->worksheetXml->autoFilter['ref']; + if (strpos($autoFilterRange, ':') !== false) { + $this->readAutoFilter($autoFilterRange, $this->worksheetXml); + } + } + + private function readAutoFilter($autoFilterRange, $xmlSheet) + { + $autoFilter = $this->worksheet->getAutoFilter(); + $autoFilter->setRange($autoFilterRange); + + foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) { + $column = $autoFilter->getColumnByOffset((int) $filterColumn['colId']); + // Check for standard filters + if ($filterColumn->filters) { + $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER); + $filters = $filterColumn->filters; + if ((isset($filters['blank'])) && ($filters['blank'] == 1)) { + // Operator is undefined, but always treated as EQUAL + $column->createRule()->setRule(null, '')->setRuleType(Rule::AUTOFILTER_RULETYPE_FILTER); + } + // Standard filters are always an OR join, so no join rule needs to be set + // Entries can be either filter elements + foreach ($filters->filter as $filterRule) { + // Operator is undefined, but always treated as EQUAL + $column->createRule()->setRule(null, (string) $filterRule['val'])->setRuleType(Rule::AUTOFILTER_RULETYPE_FILTER); + } + + // Or Date Group elements + $this->readDateRangeAutoFilter($filters, $column); + } + + // Check for custom filters + $this->readCustomAutoFilter($filterColumn, $column); + // Check for dynamic filters + $this->readDynamicAutoFilter($filterColumn, $column); + // Check for dynamic filters + $this->readTopTenAutoFilter($filterColumn, $column); + } + } + + private function readDateRangeAutoFilter(\SimpleXMLElement $filters, Column $column) + { + foreach ($filters->dateGroupItem as $dateGroupItem) { + // Operator is undefined, but always treated as EQUAL + $column->createRule()->setRule( + null, + [ + 'year' => (string) $dateGroupItem['year'], + 'month' => (string) $dateGroupItem['month'], + 'day' => (string) $dateGroupItem['day'], + 'hour' => (string) $dateGroupItem['hour'], + 'minute' => (string) $dateGroupItem['minute'], + 'second' => (string) $dateGroupItem['second'], + ], + (string) $dateGroupItem['dateTimeGrouping'] + )->setRuleType(Rule::AUTOFILTER_RULETYPE_DATEGROUP); + } + } + + private function readCustomAutoFilter(\SimpleXMLElement $filterColumn, Column $column) + { + if ($filterColumn->customFilters) { + $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER); + $customFilters = $filterColumn->customFilters; + // Custom filters can an AND or an OR join; + // and there should only ever be one or two entries + if ((isset($customFilters['and'])) && ($customFilters['and'] == 1)) { + $column->setJoin(Column::AUTOFILTER_COLUMN_JOIN_AND); + } + foreach ($customFilters->customFilter as $filterRule) { + $column->createRule()->setRule( + (string) $filterRule['operator'], + (string) $filterRule['val'] + )->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); + } + } + } + + private function readDynamicAutoFilter(\SimpleXMLElement $filterColumn, Column $column) + { + if ($filterColumn->dynamicFilter) { + $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); + // We should only ever have one dynamic filter + foreach ($filterColumn->dynamicFilter as $filterRule) { + // Operator is undefined, but always treated as EQUAL + $column->createRule()->setRule( + null, + (string) $filterRule['val'], + (string) $filterRule['type'] + )->setRuleType(Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); + if (isset($filterRule['val'])) { + $column->setAttribute('val', (string) $filterRule['val']); + } + if (isset($filterRule['maxVal'])) { + $column->setAttribute('maxVal', (string) $filterRule['maxVal']); + } + } + } + } + + private function readTopTenAutoFilter(\SimpleXMLElement $filterColumn, Column $column) + { + if ($filterColumn->top10) { + $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER); + // We should only ever have one top10 filter + foreach ($filterColumn->top10 as $filterRule) { + $column->createRule()->setRule( + (((isset($filterRule['percent'])) && ($filterRule['percent'] == 1)) + ? Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT + : Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE + ), + (string) $filterRule['val'], + (((isset($filterRule['top'])) && ($filterRule['top'] == 1)) + ? Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP + : Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM + ) + )->setRuleType(Rule::AUTOFILTER_RULETYPE_TOPTENFILTER); + } + } + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/BaseParserClass.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/BaseParserClass.php new file mode 100644 index 00000000000..1679f01f9f1 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/BaseParserClass.php @@ -0,0 +1,19 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + } + + /** + * Set Worksheet column attributes by attributes array passed. + * + * @param string $columnAddress A, B, ... DX, ... + * @param array $columnAttributes array of attributes (indexes are attribute name, values are value) + * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'width', ... ? + */ + private function setColumnAttributes($columnAddress, array $columnAttributes) + { + if (isset($columnAttributes['xfIndex'])) { + $this->worksheet->getColumnDimension($columnAddress)->setXfIndex($columnAttributes['xfIndex']); + } + if (isset($columnAttributes['visible'])) { + $this->worksheet->getColumnDimension($columnAddress)->setVisible($columnAttributes['visible']); + } + if (isset($columnAttributes['collapsed'])) { + $this->worksheet->getColumnDimension($columnAddress)->setCollapsed($columnAttributes['collapsed']); + } + if (isset($columnAttributes['outlineLevel'])) { + $this->worksheet->getColumnDimension($columnAddress)->setOutlineLevel($columnAttributes['outlineLevel']); + } + if (isset($columnAttributes['width'])) { + $this->worksheet->getColumnDimension($columnAddress)->setWidth($columnAttributes['width']); + } + } + + /** + * Set Worksheet row attributes by attributes array passed. + * + * @param int $rowNumber 1, 2, 3, ... 99, ... + * @param array $rowAttributes array of attributes (indexes are attribute name, values are value) + * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'rowHeight', ... ? + */ + private function setRowAttributes($rowNumber, array $rowAttributes) + { + if (isset($rowAttributes['xfIndex'])) { + $this->worksheet->getRowDimension($rowNumber)->setXfIndex($rowAttributes['xfIndex']); + } + if (isset($rowAttributes['visible'])) { + $this->worksheet->getRowDimension($rowNumber)->setVisible($rowAttributes['visible']); + } + if (isset($rowAttributes['collapsed'])) { + $this->worksheet->getRowDimension($rowNumber)->setCollapsed($rowAttributes['collapsed']); + } + if (isset($rowAttributes['outlineLevel'])) { + $this->worksheet->getRowDimension($rowNumber)->setOutlineLevel($rowAttributes['outlineLevel']); + } + if (isset($rowAttributes['rowHeight'])) { + $this->worksheet->getRowDimension($rowNumber)->setRowHeight($rowAttributes['rowHeight']); + } + } + + /** + * @param IReadFilter $readFilter + * @param bool $readDataOnly + */ + public function load(IReadFilter $readFilter = null, $readDataOnly = false) + { + if ($this->worksheetXml === null) { + return; + } + + $columnsAttributes = []; + $rowsAttributes = []; + if (isset($this->worksheetXml->cols)) { + $columnsAttributes = $this->readColumnAttributes($this->worksheetXml->cols, $readDataOnly); + } + + if ($this->worksheetXml->sheetData && $this->worksheetXml->sheetData->row) { + $rowsAttributes = $this->readRowAttributes($this->worksheetXml->sheetData->row, $readDataOnly); + } + + // set columns/rows attributes + $columnsAttributesAreSet = []; + foreach ($columnsAttributes as $columnCoordinate => $columnAttributes) { + if ($readFilter === null || + !$this->isFilteredColumn($readFilter, $columnCoordinate, $rowsAttributes)) { + if (!isset($columnsAttributesAreSet[$columnCoordinate])) { + $this->setColumnAttributes($columnCoordinate, $columnAttributes); + $columnsAttributesAreSet[$columnCoordinate] = true; + } + } + } + + $rowsAttributesAreSet = []; + foreach ($rowsAttributes as $rowCoordinate => $rowAttributes) { + if ($readFilter === null || + !$this->isFilteredRow($readFilter, $rowCoordinate, $columnsAttributes)) { + if (!isset($rowsAttributesAreSet[$rowCoordinate])) { + $this->setRowAttributes($rowCoordinate, $rowAttributes); + $rowsAttributesAreSet[$rowCoordinate] = true; + } + } + } + } + + private function isFilteredColumn(IReadFilter $readFilter, $columnCoordinate, array $rowsAttributes) + { + foreach ($rowsAttributes as $rowCoordinate => $rowAttributes) { + if (!$readFilter->readCell($columnCoordinate, $rowCoordinate, $this->worksheet->getTitle())) { + return true; + } + } + + return false; + } + + private function readColumnAttributes(\SimpleXMLElement $worksheetCols, $readDataOnly) + { + $columnAttributes = []; + + foreach ($worksheetCols->col as $column) { + $startColumn = Coordinate::stringFromColumnIndex((int) $column['min']); + $endColumn = Coordinate::stringFromColumnIndex((int) $column['max']); + ++$endColumn; + for ($columnAddress = $startColumn; $columnAddress !== $endColumn; ++$columnAddress) { + $columnAttributes[$columnAddress] = $this->readColumnRangeAttributes($column, $readDataOnly); + + if ((int) ($column['max']) == 16384) { + break; + } + } + } + + return $columnAttributes; + } + + private function readColumnRangeAttributes(\SimpleXMLElement $column, $readDataOnly) + { + $columnAttributes = []; + + if ($column['style'] && !$readDataOnly) { + $columnAttributes['xfIndex'] = (int) $column['style']; + } + if (self::boolean($column['hidden'])) { + $columnAttributes['visible'] = false; + } + if (self::boolean($column['collapsed'])) { + $columnAttributes['collapsed'] = true; + } + if (((int) $column['outlineLevel']) > 0) { + $columnAttributes['outlineLevel'] = (int) $column['outlineLevel']; + } + $columnAttributes['width'] = (float) $column['width']; + + return $columnAttributes; + } + + private function isFilteredRow(IReadFilter $readFilter, $rowCoordinate, array $columnsAttributes) + { + foreach ($columnsAttributes as $columnCoordinate => $columnAttributes) { + if (!$readFilter->readCell($columnCoordinate, $rowCoordinate, $this->worksheet->getTitle())) { + return true; + } + } + + return false; + } + + private function readRowAttributes(\SimpleXMLElement $worksheetRow, $readDataOnly) + { + $rowAttributes = []; + + foreach ($worksheetRow as $row) { + if ($row['ht'] && !$readDataOnly) { + $rowAttributes[(int) $row['r']]['rowHeight'] = (float) $row['ht']; + } + if (self::boolean($row['hidden'])) { + $rowAttributes[(int) $row['r']]['visible'] = false; + } + if (self::boolean($row['collapsed'])) { + $rowAttributes[(int) $row['r']]['collapsed'] = true; + } + if ((int) $row['outlineLevel'] > 0) { + $rowAttributes[(int) $row['r']]['outlineLevel'] = (int) $row['outlineLevel']; + } + if ($row['s'] && !$readDataOnly) { + $rowAttributes[(int) $row['r']]['xfIndex'] = (int) $row['s']; + } + } + + return $rowAttributes; + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php new file mode 100644 index 00000000000..b3de5d1cde6 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php @@ -0,0 +1,92 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + $this->dxfs = $dxfs; + } + + public function load() + { + $this->setConditionalStyles( + $this->worksheet, + $this->readConditionalStyles($this->worksheetXml) + ); + } + + private function readConditionalStyles($xmlSheet) + { + $conditionals = []; + foreach ($xmlSheet->conditionalFormatting as $conditional) { + foreach ($conditional->cfRule as $cfRule) { + if (((string) $cfRule['type'] == Conditional::CONDITION_NONE + || (string) $cfRule['type'] == Conditional::CONDITION_CELLIS + || (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSTEXT + || (string) $cfRule['type'] == Conditional::CONDITION_EXPRESSION) + && isset($this->dxfs[(int) ($cfRule['dxfId'])])) { + $conditionals[(string) $conditional['sqref']][(int) ($cfRule['priority'])] = $cfRule; + } + } + } + + return $conditionals; + } + + private function setConditionalStyles(Worksheet $worksheet, array $conditionals) + { + foreach ($conditionals as $ref => $cfRules) { + ksort($cfRules); + $conditionalStyles = $this->readStyleRules($cfRules); + + // Extract all cell references in $ref + $cellBlocks = explode(' ', str_replace('$', '', strtoupper($ref))); + foreach ($cellBlocks as $cellBlock) { + $worksheet->getStyle($cellBlock)->setConditionalStyles($conditionalStyles); + } + } + } + + private function readStyleRules($cfRules) + { + $conditionalStyles = []; + foreach ($cfRules as $cfRule) { + $objConditional = new Conditional(); + $objConditional->setConditionType((string) $cfRule['type']); + $objConditional->setOperatorType((string) $cfRule['operator']); + + if ((string) $cfRule['text'] != '') { + $objConditional->setText((string) $cfRule['text']); + } + + if (isset($cfRule['stopIfTrue']) && (int) $cfRule['stopIfTrue'] === 1) { + $objConditional->setStopIfTrue(true); + } + + if (count($cfRule->formula) > 1) { + foreach ($cfRule->formula as $formula) { + $objConditional->addCondition((string) $formula); + } + } else { + $objConditional->addCondition((string) $cfRule->formula); + } + $objConditional->setStyle(clone $this->dxfs[(int) ($cfRule['dxfId'])]); + $conditionalStyles[] = $objConditional; + } + + return $conditionalStyles; + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php new file mode 100644 index 00000000000..4bb44129208 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php @@ -0,0 +1,50 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + } + + public function load() + { + foreach ($this->worksheetXml->dataValidations->dataValidation as $dataValidation) { + // Uppercase coordinate + $range = strtoupper($dataValidation['sqref']); + $rangeSet = explode(' ', $range); + foreach ($rangeSet as $range) { + $stRange = $this->worksheet->shrinkRangeToFit($range); + + // Extract all cell references in $range + foreach (Coordinate::extractAllCellReferencesInRange($stRange) as $reference) { + // Create validation + $docValidation = $this->worksheet->getCell($reference)->getDataValidation(); + $docValidation->setType((string) $dataValidation['type']); + $docValidation->setErrorStyle((string) $dataValidation['errorStyle']); + $docValidation->setOperator((string) $dataValidation['operator']); + $docValidation->setAllowBlank($dataValidation['allowBlank'] != 0); + $docValidation->setShowDropDown($dataValidation['showDropDown'] == 0); + $docValidation->setShowInputMessage($dataValidation['showInputMessage'] != 0); + $docValidation->setShowErrorMessage($dataValidation['showErrorMessage'] != 0); + $docValidation->setErrorTitle((string) $dataValidation['errorTitle']); + $docValidation->setError((string) $dataValidation['error']); + $docValidation->setPromptTitle((string) $dataValidation['promptTitle']); + $docValidation->setPrompt((string) $dataValidation['prompt']); + $docValidation->setFormula1((string) $dataValidation->formula1); + $docValidation->setFormula2((string) $dataValidation->formula2); + } + } + } + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php new file mode 100644 index 00000000000..400b272528c --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php @@ -0,0 +1,58 @@ +worksheet = $workSheet; + } + + public function readHyperlinks(\SimpleXMLElement $relsWorksheet) + { + foreach ($relsWorksheet->Relationship as $element) { + if ($element['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink') { + $this->hyperlinks[(string) $element['Id']] = (string) $element['Target']; + } + } + } + + public function setHyperlinks(\SimpleXMLElement $worksheetXml) + { + foreach ($worksheetXml->hyperlink as $hyperlink) { + $this->setHyperlink($hyperlink, $this->worksheet); + } + } + + private function setHyperlink(\SimpleXMLElement $hyperlink, Worksheet $worksheet) + { + // Link url + $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + + foreach (Coordinate::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { + $cell = $worksheet->getCell($cellReference); + if (isset($linkRel['id'])) { + $hyperlinkUrl = $this->hyperlinks[(string) $linkRel['id']]; + if (isset($hyperlink['location'])) { + $hyperlinkUrl .= '#' . (string) $hyperlink['location']; + } + $cell->getHyperlink()->setUrl($hyperlinkUrl); + } elseif (isset($hyperlink['location'])) { + $cell->getHyperlink()->setUrl('sheet://' . (string) $hyperlink['location']); + } + + // Tooltip + if (isset($hyperlink['tooltip'])) { + $cell->getHyperlink()->setTooltip((string) $hyperlink['tooltip']); + } + } + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php new file mode 100644 index 00000000000..6f286769c0e --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php @@ -0,0 +1,150 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + } + + public function load(array $unparsedLoadedData) + { + if (!$this->worksheetXml) { + return $unparsedLoadedData; + } + + $this->margins($this->worksheetXml, $this->worksheet); + $unparsedLoadedData = $this->pageSetup($this->worksheetXml, $this->worksheet, $unparsedLoadedData); + $this->headerFooter($this->worksheetXml, $this->worksheet); + $this->pageBreaks($this->worksheetXml, $this->worksheet); + + return $unparsedLoadedData; + } + + private function margins(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + { + if ($xmlSheet->pageMargins) { + $docPageMargins = $worksheet->getPageMargins(); + $docPageMargins->setLeft((float) ($xmlSheet->pageMargins['left'])); + $docPageMargins->setRight((float) ($xmlSheet->pageMargins['right'])); + $docPageMargins->setTop((float) ($xmlSheet->pageMargins['top'])); + $docPageMargins->setBottom((float) ($xmlSheet->pageMargins['bottom'])); + $docPageMargins->setHeader((float) ($xmlSheet->pageMargins['header'])); + $docPageMargins->setFooter((float) ($xmlSheet->pageMargins['footer'])); + } + } + + private function pageSetup(\SimpleXMLElement $xmlSheet, Worksheet $worksheet, array $unparsedLoadedData) + { + if ($xmlSheet->pageSetup) { + $docPageSetup = $worksheet->getPageSetup(); + + if (isset($xmlSheet->pageSetup['orientation'])) { + $docPageSetup->setOrientation((string) $xmlSheet->pageSetup['orientation']); + } + if (isset($xmlSheet->pageSetup['paperSize'])) { + $docPageSetup->setPaperSize((int) ($xmlSheet->pageSetup['paperSize'])); + } + if (isset($xmlSheet->pageSetup['scale'])) { + $docPageSetup->setScale((int) ($xmlSheet->pageSetup['scale']), false); + } + if (isset($xmlSheet->pageSetup['fitToHeight']) && (int) ($xmlSheet->pageSetup['fitToHeight']) >= 0) { + $docPageSetup->setFitToHeight((int) ($xmlSheet->pageSetup['fitToHeight']), false); + } + if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) { + $docPageSetup->setFitToWidth((int) ($xmlSheet->pageSetup['fitToWidth']), false); + } + if (isset($xmlSheet->pageSetup['firstPageNumber'], $xmlSheet->pageSetup['useFirstPageNumber']) && + self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) { + $docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber'])); + } + + $relAttributes = $xmlSheet->pageSetup->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + if (isset($relAttributes['id'])) { + $unparsedLoadedData['sheets'][$worksheet->getCodeName()]['pageSetupRelId'] = (string) $relAttributes['id']; + } + } + + return $unparsedLoadedData; + } + + private function headerFooter(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + { + if ($xmlSheet->headerFooter) { + $docHeaderFooter = $worksheet->getHeaderFooter(); + + if (isset($xmlSheet->headerFooter['differentOddEven']) && + self::boolean((string) $xmlSheet->headerFooter['differentOddEven'])) { + $docHeaderFooter->setDifferentOddEven(true); + } else { + $docHeaderFooter->setDifferentOddEven(false); + } + if (isset($xmlSheet->headerFooter['differentFirst']) && + self::boolean((string) $xmlSheet->headerFooter['differentFirst'])) { + $docHeaderFooter->setDifferentFirst(true); + } else { + $docHeaderFooter->setDifferentFirst(false); + } + if (isset($xmlSheet->headerFooter['scaleWithDoc']) && + !self::boolean((string) $xmlSheet->headerFooter['scaleWithDoc'])) { + $docHeaderFooter->setScaleWithDocument(false); + } else { + $docHeaderFooter->setScaleWithDocument(true); + } + if (isset($xmlSheet->headerFooter['alignWithMargins']) && + !self::boolean((string) $xmlSheet->headerFooter['alignWithMargins'])) { + $docHeaderFooter->setAlignWithMargins(false); + } else { + $docHeaderFooter->setAlignWithMargins(true); + } + + $docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader); + $docHeaderFooter->setOddFooter((string) $xmlSheet->headerFooter->oddFooter); + $docHeaderFooter->setEvenHeader((string) $xmlSheet->headerFooter->evenHeader); + $docHeaderFooter->setEvenFooter((string) $xmlSheet->headerFooter->evenFooter); + $docHeaderFooter->setFirstHeader((string) $xmlSheet->headerFooter->firstHeader); + $docHeaderFooter->setFirstFooter((string) $xmlSheet->headerFooter->firstFooter); + } + } + + private function pageBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + { + if ($xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk) { + $this->rowBreaks($xmlSheet, $worksheet); + } + if ($xmlSheet->colBreaks && $xmlSheet->colBreaks->brk) { + $this->columnBreaks($xmlSheet, $worksheet); + } + } + + private function rowBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + { + foreach ($xmlSheet->rowBreaks->brk as $brk) { + if ($brk['man']) { + $worksheet->setBreak("A{$brk['id']}", Worksheet::BREAK_ROW); + } + } + } + + private function columnBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + { + foreach ($xmlSheet->colBreaks->brk as $brk) { + if ($brk['man']) { + $worksheet->setBreak( + Coordinate::stringFromColumnIndex(((int) $brk['id']) + 1) . '1', + Worksheet::BREAK_COLUMN + ); + } + } + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Properties.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Properties.php new file mode 100644 index 00000000000..bc6bba2cdb2 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Properties.php @@ -0,0 +1,91 @@ +securityScanner = $securityScanner; + $this->docProps = $docProps; + } + + private function extractPropertyData($propertyData) + { + return simplexml_load_string( + $this->securityScanner->scan($propertyData), + 'SimpleXMLElement', + Settings::getLibXmlLoaderOptions() + ); + } + + public function readCoreProperties($propertyData) + { + $xmlCore = $this->extractPropertyData($propertyData); + + if (is_object($xmlCore)) { + $xmlCore->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/'); + $xmlCore->registerXPathNamespace('dcterms', 'http://purl.org/dc/terms/'); + $xmlCore->registerXPathNamespace('cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); + + $this->docProps->setCreator((string) self::getArrayItem($xmlCore->xpath('dc:creator'))); + $this->docProps->setLastModifiedBy((string) self::getArrayItem($xmlCore->xpath('cp:lastModifiedBy'))); + $this->docProps->setCreated(strtotime(self::getArrayItem($xmlCore->xpath('dcterms:created')))); //! respect xsi:type + $this->docProps->setModified(strtotime(self::getArrayItem($xmlCore->xpath('dcterms:modified')))); //! respect xsi:type + $this->docProps->setTitle((string) self::getArrayItem($xmlCore->xpath('dc:title'))); + $this->docProps->setDescription((string) self::getArrayItem($xmlCore->xpath('dc:description'))); + $this->docProps->setSubject((string) self::getArrayItem($xmlCore->xpath('dc:subject'))); + $this->docProps->setKeywords((string) self::getArrayItem($xmlCore->xpath('cp:keywords'))); + $this->docProps->setCategory((string) self::getArrayItem($xmlCore->xpath('cp:category'))); + } + } + + public function readExtendedProperties($propertyData) + { + $xmlCore = $this->extractPropertyData($propertyData); + + if (is_object($xmlCore)) { + if (isset($xmlCore->Company)) { + $this->docProps->setCompany((string) $xmlCore->Company); + } + if (isset($xmlCore->Manager)) { + $this->docProps->setManager((string) $xmlCore->Manager); + } + } + } + + public function readCustomProperties($propertyData) + { + $xmlCore = $this->extractPropertyData($propertyData); + + if (is_object($xmlCore)) { + foreach ($xmlCore as $xmlProperty) { + /** @var \SimpleXMLElement $xmlProperty */ + $cellDataOfficeAttributes = $xmlProperty->attributes(); + if (isset($cellDataOfficeAttributes['name'])) { + $propertyName = (string) $cellDataOfficeAttributes['name']; + $cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); + + $attributeType = $cellDataOfficeChildren->getName(); + $attributeValue = (string) $cellDataOfficeChildren->{$attributeType}; + $attributeValue = DocumentProperties::convertProperty($attributeValue, $attributeType); + $attributeType = DocumentProperties::convertPropertyType($attributeType); + $this->docProps->setCustomProperty($propertyName, $attributeValue, $attributeType); + } + } + } + } + + private static function getArrayItem(array $array, $key = 0) + { + return isset($array[$key]) ? $array[$key] : null; + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php new file mode 100644 index 00000000000..eb61a5d306c --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php @@ -0,0 +1,124 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + } + + /** + * @param bool $readDataOnly + */ + public function load($readDataOnly = false) + { + if ($this->worksheetXml === null) { + return; + } + + if (isset($this->worksheetXml->sheetPr)) { + $this->tabColor($this->worksheetXml->sheetPr); + $this->codeName($this->worksheetXml->sheetPr); + $this->outlines($this->worksheetXml->sheetPr); + $this->pageSetup($this->worksheetXml->sheetPr); + } + + if (isset($this->worksheetXml->sheetFormatPr)) { + $this->sheetFormat($this->worksheetXml->sheetFormatPr); + } + + if (!$readDataOnly && isset($this->worksheetXml->printOptions)) { + $this->printOptions($this->worksheetXml->printOptions); + } + } + + private function tabColor(\SimpleXMLElement $sheetPr) + { + if (isset($sheetPr->tabColor, $sheetPr->tabColor['rgb'])) { + $this->worksheet->getTabColor()->setARGB((string) $sheetPr->tabColor['rgb']); + } + } + + private function codeName(\SimpleXMLElement $sheetPr) + { + if (isset($sheetPr['codeName'])) { + $this->worksheet->setCodeName((string) $sheetPr['codeName'], false); + } + } + + private function outlines(\SimpleXMLElement $sheetPr) + { + if (isset($sheetPr->outlinePr)) { + if (isset($sheetPr->outlinePr['summaryRight']) && + !self::boolean((string) $sheetPr->outlinePr['summaryRight'])) { + $this->worksheet->setShowSummaryRight(false); + } else { + $this->worksheet->setShowSummaryRight(true); + } + + if (isset($sheetPr->outlinePr['summaryBelow']) && + !self::boolean((string) $sheetPr->outlinePr['summaryBelow'])) { + $this->worksheet->setShowSummaryBelow(false); + } else { + $this->worksheet->setShowSummaryBelow(true); + } + } + } + + private function pageSetup(\SimpleXMLElement $sheetPr) + { + if (isset($sheetPr->pageSetUpPr)) { + if (isset($sheetPr->pageSetUpPr['fitToPage']) && + !self::boolean((string) $sheetPr->pageSetUpPr['fitToPage'])) { + $this->worksheet->getPageSetup()->setFitToPage(false); + } else { + $this->worksheet->getPageSetup()->setFitToPage(true); + } + } + } + + private function sheetFormat(\SimpleXMLElement $sheetFormatPr) + { + if (isset($sheetFormatPr['customHeight']) && + self::boolean((string) $sheetFormatPr['customHeight']) && + isset($sheetFormatPr['defaultRowHeight'])) { + $this->worksheet->getDefaultRowDimension() + ->setRowHeight((float) $sheetFormatPr['defaultRowHeight']); + } + + if (isset($sheetFormatPr['defaultColWidth'])) { + $this->worksheet->getDefaultColumnDimension() + ->setWidth((float) $sheetFormatPr['defaultColWidth']); + } + + if (isset($sheetFormatPr['zeroHeight']) && + ((string) $sheetFormatPr['zeroHeight'] === '1')) { + $this->worksheet->getDefaultRowDimension()->setZeroHeight(true); + } + } + + private function printOptions(\SimpleXMLElement $printOptions) + { + if (self::boolean((string) $printOptions['gridLinesSet'])) { + $this->worksheet->setShowGridlines(true); + } + if (self::boolean((string) $printOptions['gridLines'])) { + $this->worksheet->setPrintGridlines(true); + } + if (self::boolean((string) $printOptions['horizontalCentered'])) { + $this->worksheet->getPageSetup()->setHorizontalCentered(true); + } + if (self::boolean((string) $printOptions['verticalCentered'])) { + $this->worksheet->getPageSetup()->setVerticalCentered(true); + } + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php new file mode 100644 index 00000000000..2caaec3108e --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php @@ -0,0 +1,127 @@ +sheetViewXml = $sheetViewXml; + $this->worksheet = $workSheet; + } + + public function load() + { + $this->zoomScale(); + $this->view(); + $this->gridLines(); + $this->headers(); + $this->direction(); + + if (isset($this->sheetViewXml->pane)) { + $this->pane(); + } + if (isset($this->sheetViewXml->selection, $this->sheetViewXml->selection['sqref'])) { + $this->selection(); + } + } + + private function zoomScale() + { + if (isset($this->sheetViewXml['zoomScale'])) { + $zoomScale = (int) ($this->sheetViewXml['zoomScale']); + if ($zoomScale <= 0) { + // setZoomScale will throw an Exception if the scale is less than or equals 0 + // that is OK when manually creating documents, but we should be able to read all documents + $zoomScale = 100; + } + + $this->worksheet->getSheetView()->setZoomScale($zoomScale); + } + + if (isset($this->sheetViewXml['zoomScaleNormal'])) { + $zoomScaleNormal = (int) ($this->sheetViewXml['zoomScaleNormal']); + if ($zoomScaleNormal <= 0) { + // setZoomScaleNormal will throw an Exception if the scale is less than or equals 0 + // that is OK when manually creating documents, but we should be able to read all documents + $zoomScaleNormal = 100; + } + + $this->worksheet->getSheetView()->setZoomScaleNormal($zoomScaleNormal); + } + } + + private function view() + { + if (isset($this->sheetViewXml['view'])) { + $this->worksheet->getSheetView()->setView((string) $this->sheetViewXml['view']); + } + } + + private function gridLines() + { + if (isset($this->sheetViewXml['showGridLines'])) { + $this->worksheet->setShowGridLines( + self::boolean((string) $this->sheetViewXml['showGridLines']) + ); + } + } + + private function headers() + { + if (isset($this->sheetViewXml['showRowColHeaders'])) { + $this->worksheet->setShowRowColHeaders( + self::boolean((string) $this->sheetViewXml['showRowColHeaders']) + ); + } + } + + private function direction() + { + if (isset($this->sheetViewXml['rightToLeft'])) { + $this->worksheet->setRightToLeft( + self::boolean((string) $this->sheetViewXml['rightToLeft']) + ); + } + } + + private function pane() + { + $xSplit = 0; + $ySplit = 0; + $topLeftCell = null; + + if (isset($this->sheetViewXml->pane['xSplit'])) { + $xSplit = (int) ($this->sheetViewXml->pane['xSplit']); + } + + if (isset($this->sheetViewXml->pane['ySplit'])) { + $ySplit = (int) ($this->sheetViewXml->pane['ySplit']); + } + + if (isset($this->sheetViewXml->pane['topLeftCell'])) { + $topLeftCell = (string) $this->sheetViewXml->pane['topLeftCell']; + } + + $this->worksheet->freezePane( + Coordinate::stringFromColumnIndex($xSplit + 1) . ($ySplit + 1), + $topLeftCell + ); + } + + private function selection() + { + $sqref = (string) $this->sheetViewXml->selection['sqref']; + $sqref = explode(' ', $sqref); + $sqref = $sqref[0]; + + $this->worksheet->setSelectedCells($sqref); + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Styles.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Styles.php new file mode 100644 index 00000000000..c06564a3d11 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Styles.php @@ -0,0 +1,265 @@ +styleXml = $styleXml; + } + + public function setStyleBaseData(Theme $theme = null, $styles = [], $cellStyles = []) + { + self::$theme = $theme; + $this->styles = $styles; + $this->cellStyles = $cellStyles; + } + + private static function readFontStyle(Font $fontStyle, \SimpleXMLElement $fontStyleXml) + { + $fontStyle->setName((string) $fontStyleXml->name['val']); + $fontStyle->setSize((float) $fontStyleXml->sz['val']); + + if (isset($fontStyleXml->b)) { + $fontStyle->setBold(!isset($fontStyleXml->b['val']) || self::boolean((string) $fontStyleXml->b['val'])); + } + if (isset($fontStyleXml->i)) { + $fontStyle->setItalic(!isset($fontStyleXml->i['val']) || self::boolean((string) $fontStyleXml->i['val'])); + } + if (isset($fontStyleXml->strike)) { + $fontStyle->setStrikethrough(!isset($fontStyleXml->strike['val']) || self::boolean((string) $fontStyleXml->strike['val'])); + } + $fontStyle->getColor()->setARGB(self::readColor($fontStyleXml->color)); + + if (isset($fontStyleXml->u) && !isset($fontStyleXml->u['val'])) { + $fontStyle->setUnderline(Font::UNDERLINE_SINGLE); + } elseif (isset($fontStyleXml->u, $fontStyleXml->u['val'])) { + $fontStyle->setUnderline((string) $fontStyleXml->u['val']); + } + + if (isset($fontStyleXml->vertAlign, $fontStyleXml->vertAlign['val'])) { + $verticalAlign = strtolower((string) $fontStyleXml->vertAlign['val']); + if ($verticalAlign === 'superscript') { + $fontStyle->setSuperscript(true); + } + if ($verticalAlign === 'subscript') { + $fontStyle->setSubscript(true); + } + } + } + + private static function readFillStyle(Fill $fillStyle, \SimpleXMLElement $fillStyleXml) + { + if ($fillStyleXml->gradientFill) { + /** @var \SimpleXMLElement $gradientFill */ + $gradientFill = $fillStyleXml->gradientFill[0]; + if (!empty($gradientFill['type'])) { + $fillStyle->setFillType((string) $gradientFill['type']); + } + $fillStyle->setRotation((float) ($gradientFill['degree'])); + $gradientFill->registerXPathNamespace('sml', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); + $fillStyle->getStartColor()->setARGB(self::readColor(self::getArrayItem($gradientFill->xpath('sml:stop[@position=0]'))->color)); + $fillStyle->getEndColor()->setARGB(self::readColor(self::getArrayItem($gradientFill->xpath('sml:stop[@position=1]'))->color)); + } elseif ($fillStyleXml->patternFill) { + $patternType = (string) $fillStyleXml->patternFill['patternType'] != '' ? (string) $fillStyleXml->patternFill['patternType'] : 'solid'; + $fillStyle->setFillType($patternType); + if ($fillStyleXml->patternFill->fgColor) { + $fillStyle->getStartColor()->setARGB(self::readColor($fillStyleXml->patternFill->fgColor, true)); + } else { + $fillStyle->getStartColor()->setARGB('FF000000'); + } + if ($fillStyleXml->patternFill->bgColor) { + $fillStyle->getEndColor()->setARGB(self::readColor($fillStyleXml->patternFill->bgColor, true)); + } + } + } + + private static function readBorderStyle(Borders $borderStyle, \SimpleXMLElement $borderStyleXml) + { + $diagonalUp = self::boolean((string) $borderStyleXml['diagonalUp']); + $diagonalDown = self::boolean((string) $borderStyleXml['diagonalDown']); + if (!$diagonalUp && !$diagonalDown) { + $borderStyle->setDiagonalDirection(Borders::DIAGONAL_NONE); + } elseif ($diagonalUp && !$diagonalDown) { + $borderStyle->setDiagonalDirection(Borders::DIAGONAL_UP); + } elseif (!$diagonalUp && $diagonalDown) { + $borderStyle->setDiagonalDirection(Borders::DIAGONAL_DOWN); + } else { + $borderStyle->setDiagonalDirection(Borders::DIAGONAL_BOTH); + } + + self::readBorder($borderStyle->getLeft(), $borderStyleXml->left); + self::readBorder($borderStyle->getRight(), $borderStyleXml->right); + self::readBorder($borderStyle->getTop(), $borderStyleXml->top); + self::readBorder($borderStyle->getBottom(), $borderStyleXml->bottom); + self::readBorder($borderStyle->getDiagonal(), $borderStyleXml->diagonal); + } + + private static function readBorder(Border $border, \SimpleXMLElement $borderXml) + { + if (isset($borderXml['style'])) { + $border->setBorderStyle((string) $borderXml['style']); + } + if (isset($borderXml->color)) { + $border->getColor()->setARGB(self::readColor($borderXml->color)); + } + } + + private static function readAlignmentStyle(Alignment $alignment, \SimpleXMLElement $alignmentXml) + { + $alignment->setHorizontal((string) $alignmentXml->alignment['horizontal']); + $alignment->setVertical((string) $alignmentXml->alignment['vertical']); + + $textRotation = 0; + if ((int) $alignmentXml->alignment['textRotation'] <= 90) { + $textRotation = (int) $alignmentXml->alignment['textRotation']; + } elseif ((int) $alignmentXml->alignment['textRotation'] > 90) { + $textRotation = 90 - (int) $alignmentXml->alignment['textRotation']; + } + + $alignment->setTextRotation((int) $textRotation); + $alignment->setWrapText(self::boolean((string) $alignmentXml->alignment['wrapText'])); + $alignment->setShrinkToFit(self::boolean((string) $alignmentXml->alignment['shrinkToFit'])); + $alignment->setIndent((int) ((string) $alignmentXml->alignment['indent']) > 0 ? (int) ((string) $alignmentXml->alignment['indent']) : 0); + $alignment->setReadOrder((int) ((string) $alignmentXml->alignment['readingOrder']) > 0 ? (int) ((string) $alignmentXml->alignment['readingOrder']) : 0); + } + + private function readStyle(Style $docStyle, $style) + { + $docStyle->getNumberFormat()->setFormatCode($style->numFmt); + + if (isset($style->font)) { + self::readFontStyle($docStyle->getFont(), $style->font); + } + + if (isset($style->fill)) { + self::readFillStyle($docStyle->getFill(), $style->fill); + } + + if (isset($style->border)) { + self::readBorderStyle($docStyle->getBorders(), $style->border); + } + + if (isset($style->alignment)) { + self::readAlignmentStyle($docStyle->getAlignment(), $style->alignment); + } + + // protection + if (isset($style->protection)) { + $this->readProtectionLocked($docStyle, $style); + $this->readProtectionHidden($docStyle, $style); + } + + // top-level style settings + if (isset($style->quotePrefix)) { + $docStyle->setQuotePrefix(true); + } + } + + private function readProtectionLocked(Style $docStyle, $style) + { + if (isset($style->protection['locked'])) { + if (self::boolean((string) $style->protection['locked'])) { + $docStyle->getProtection()->setLocked(Protection::PROTECTION_PROTECTED); + } else { + $docStyle->getProtection()->setLocked(Protection::PROTECTION_UNPROTECTED); + } + } + } + + private function readProtectionHidden(Style $docStyle, $style) + { + if (isset($style->protection['hidden'])) { + if (self::boolean((string) $style->protection['hidden'])) { + $docStyle->getProtection()->setHidden(Protection::PROTECTION_PROTECTED); + } else { + $docStyle->getProtection()->setHidden(Protection::PROTECTION_UNPROTECTED); + } + } + } + + private static function readColor($color, $background = false) + { + if (isset($color['rgb'])) { + return (string) $color['rgb']; + } elseif (isset($color['indexed'])) { + return Color::indexedColor($color['indexed'] - 7, $background)->getARGB(); + } elseif (isset($color['theme'])) { + if (self::$theme !== null) { + $returnColour = self::$theme->getColourByIndex((int) $color['theme']); + if (isset($color['tint'])) { + $tintAdjust = (float) $color['tint']; + $returnColour = Color::changeBrightness($returnColour, $tintAdjust); + } + + return 'FF' . $returnColour; + } + } + + return ($background) ? 'FFFFFFFF' : 'FF000000'; + } + + public function dxfs($readDataOnly = false) + { + $dxfs = []; + if (!$readDataOnly && $this->styleXml) { + // Conditional Styles + if ($this->styleXml->dxfs) { + foreach ($this->styleXml->dxfs->dxf as $dxf) { + $style = new Style(false, true); + $this->readStyle($style, $dxf); + $dxfs[] = $style; + } + } + // Cell Styles + if ($this->styleXml->cellStyles) { + foreach ($this->styleXml->cellStyles->cellStyle as $cellStyle) { + if ((int) ($cellStyle['builtinId']) == 0) { + if (isset($this->cellStyles[(int) ($cellStyle['xfId'])])) { + // Set default style + $style = new Style(); + $this->readStyle($style, $this->cellStyles[(int) ($cellStyle['xfId'])]); + + // normal style, currently not using it for anything + } + } + } + } + } + + return $dxfs; + } + + public function styles() + { + return $this->styles; + } + + private static function getArrayItem($array, $key = 0) + { + return isset($array[$key]) ? $array[$key] : null; + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml.php index 2b7959f47c1..8ab7a9c3954 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml.php @@ -41,7 +41,7 @@ class Xml extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); $this->securityScanner = XmlScanner::getInstance($this); } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/ReferenceHelper.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/ReferenceHelper.php index 54bc182a8eb..13dbe042a75 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/ReferenceHelper.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/ReferenceHelper.php @@ -82,13 +82,13 @@ class ReferenceHelper */ public static function cellSort($a, $b) { - $ac = $bc = ''; - $ar = $br = 0; + // TODO Scrutinizer doesn't like sscanf($a, '%[A-Z]%d', $ac, $ar), and we can't use short list() syntax + // [$ac, $ar] = sscanf($a, '%[A-Z]%d') while retaining PHP 5.6 support. + // Switch when we drop support for 5.6 + list($ac, $ar) = sscanf($a, '%[A-Z]%d'); + list($bc, $br) = sscanf($b, '%[A-Z]%d'); - sscanf($a, '%[A-Z]%d', $ac, $ar); - sscanf($b, '%[A-Z]%d', $bc, $br); - - if ($ar == $br) { + if ($ar === $br) { return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); } @@ -106,13 +106,13 @@ class ReferenceHelper */ public static function cellReverseSort($a, $b) { - $ac = $bc = ''; - $ar = $br = 0; + // TODO Scrutinizer doesn't like sscanf($a, '%[A-Z]%d', $ac, $ar), and we can't use short list() syntax + // [$ac, $ar] = sscanf($a, '%[A-Z]%d') while retaining PHP 5.6 support. + // Switch when we drop support for 5.6 + list($ac, $ar) = sscanf($a, '%[A-Z]%d'); + list($bc, $br) = sscanf($b, '%[A-Z]%d'); - sscanf($a, '%[A-Z]%d', $ac, $ar); - sscanf($b, '%[A-Z]%d', $bc, $br); - - if ($ar == $br) { + if ($ar === $br) { return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); } @@ -625,7 +625,7 @@ class ReferenceHelper * Update references within formulas. * * @param string $pFormula Formula to update - * @param int $pBefore Insert before this one + * @param string $pBefore Insert before this one * @param int $pNumCols Number of columns to insert * @param int $pNumRows Number of rows to insert * @param string $sheetName Worksheet name/title diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Settings.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Settings.php index 22196b7e0e2..c297dd682ea 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Settings.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Settings.php @@ -24,6 +24,20 @@ class Settings */ private static $libXmlLoaderOptions = null; + /** + * Allow/disallow libxml_disable_entity_loader() call when not thread safe. + * Default behaviour is to do the check, but if you're running PHP versions + * 7.2 < 7.2.1 + * 7.1 < 7.1.13 + * 7.0 < 7.0.27 + * 5.6 ANY + * then you may need to disable this check to prevent unwanted behaviour in other threads + * SECURITY WARNING: Changing this flag is not recommended. + * + * @var bool + */ + private static $libXmlDisableEntityLoader = true; + /** * The cache implementation to be used for cell collection. * @@ -101,6 +115,34 @@ class Settings return self::$libXmlLoaderOptions; } + /** + * Enable/Disable the entity loader for libxml loader. + * Allow/disallow libxml_disable_entity_loader() call when not thread safe. + * Default behaviour is to do the check, but if you're running PHP versions + * 7.2 < 7.2.1 + * 7.1 < 7.1.13 + * 7.0 < 7.0.27 + * 5.6 ANY + * then you may need to disable this check to prevent unwanted behaviour in other threads + * SECURITY WARNING: Changing this flag to false is not recommended. + * + * @param bool $state + */ + public static function setLibXmlDisableEntityLoader($state) + { + self::$libXmlDisableEntityLoader = (bool) $state; + } + + /** + * Return the state of the entity loader (disabled/enabled) for libxml loader. + * + * @return bool $state + */ + public static function getLibXmlDisableEntityLoader() + { + return self::$libXmlDisableEntityLoader; + } + /** * Sets the implementation of cache that should be used for cell collection. * diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Date.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Date.php index 91c3ee0e2ca..5d2deb32c95 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Date.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Date.php @@ -192,7 +192,7 @@ class Date $interval = $days . ' days'; return $baseDate->modify($interval) - ->setTime($hours, $minutes, $seconds); + ->setTime((int) $hours, (int) $minutes, (int) $seconds); } /** @@ -244,12 +244,12 @@ class Date public static function dateTimeToExcel(DateTimeInterface $dateValue) { return self::formattedPHPToExcel( - $dateValue->format('Y'), - $dateValue->format('m'), - $dateValue->format('d'), - $dateValue->format('H'), - $dateValue->format('i'), - $dateValue->format('s') + (int) $dateValue->format('Y'), + (int) $dateValue->format('m'), + (int) $dateValue->format('d'), + (int) $dateValue->format('H'), + (int) $dateValue->format('i'), + (int) $dateValue->format('s') ); } @@ -325,11 +325,12 @@ class Date */ public static function isDateTime(Cell $pCell) { - return self::isDateTimeFormat( - $pCell->getWorksheet()->getStyle( - $pCell->getCoordinate() - )->getNumberFormat() - ); + return is_numeric($pCell->getValue()) && + self::isDateTimeFormat( + $pCell->getWorksheet()->getStyle( + $pCell->getCoordinate() + )->getNumberFormat() + ); } /** diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php index 2e9ec256734..f09fbc92adc 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php @@ -537,31 +537,37 @@ class OLE /** * Returns a timestamp from an OLE container's date. * - * @param int $string A binary string with the encoded date + * @param string $oleTimestamp A binary string with the encoded date * - * @return string The timestamp corresponding to the string + * @throws ReaderException + * + * @return int The Unix timestamp corresponding to the string */ - public static function OLE2LocalDate($string) + public static function OLE2LocalDate($oleTimestamp) { - if (strlen($string) != 8) { + if (strlen($oleTimestamp) != 8) { throw new ReaderException('Expecting 8 byte string'); } - // factor used for separating numbers into 4 bytes parts - $factor = pow(2, 32); - list(, $high_part) = unpack('V', substr($string, 4, 4)); - list(, $low_part) = unpack('V', substr($string, 0, 4)); + // convert to units of 100 ns since 1601: + $unpackedTimestamp = unpack('v4', $oleTimestamp); + $timestampHigh = (float) $unpackedTimestamp[4] * 65536 + (float) $unpackedTimestamp[3]; + $timestampLow = (float) $unpackedTimestamp[2] * 65536 + (float) $unpackedTimestamp[1]; - $big_date = ($high_part * $factor) + $low_part; - // translate to seconds - $big_date /= 10000000; + // translate to seconds since 1601: + $timestampHigh /= 10000000; + $timestampLow /= 10000000; - // days from 1-1-1601 until the beggining of UNIX era + // days from 1601 to 1970: $days = 134774; - // translate to seconds from beggining of UNIX era - $big_date -= $days * 24 * 3600; + // translate to seconds since 1970: + $unixTimestamp = floor(65536.0 * 65536.0 * $timestampHigh + $timestampLow - $days * 24 * 3600 + 0.5); - return floor($big_date); + if ((int) $unixTimestamp == $unixTimestamp) { + return (int) $unixTimestamp; + } + + return $unixTimestamp >= 0.0 ? PHP_INT_MAX : PHP_INT_MIN; } } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php index 03723d84d4e..5b57f4b71fe 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php @@ -113,7 +113,9 @@ class ExponentialBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->exponentialRegression($yValues, $xValues, $const); } } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php index 367e9d6ec56..217f0964770 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php @@ -72,7 +72,9 @@ class LinearBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->linearRegression($yValues, $xValues, $const); } } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php index 9092cef8215..96ca2ed8794 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php @@ -81,7 +81,9 @@ class LogarithmicBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->logarithmicRegression($yValues, $xValues, $const); } } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php index afcf5f477e4..a1510491f73 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -182,7 +182,9 @@ class PolynomialBestFit extends BestFit */ public function __construct($order, $yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { if ($order < $this->valueCount) { $this->bestFitType .= '_' . $order; $this->order = $order; diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php index e1b3b8297cb..4eefec8265c 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php @@ -105,7 +105,9 @@ class PowerBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->powerRegression($yValues, $xValues, $const); } } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php index 150f71b1e4f..8eadcbe8b1a 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php @@ -715,7 +715,7 @@ class Spreadsheet * * @param string $pName Sheet name * - * @return Worksheet + * @return null|Worksheet */ public function getSheetByName($pName) { diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php index b6b803787cd..37442249a50 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php @@ -49,6 +49,8 @@ class NumberFormat extends Supervisor const FORMAT_CURRENCY_USD = '$#,##0_-'; const FORMAT_CURRENCY_EUR_SIMPLE = '#,##0.00_-"€"'; const FORMAT_CURRENCY_EUR = '#,##0_-"€"'; + const FORMAT_ACCOUNTING_USD = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)'; + const FORMAT_ACCOUNTING_EUR = '_("€"* #,##0.00_);_("€"* \(#,##0.00\);_("€"* "-"??_);_(@_)'; /** * Excel built-in number formats. @@ -308,6 +310,22 @@ class NumberFormat extends Supervisor self::$builtInFormats[69] = 't# ?/?'; self::$builtInFormats[70] = 't# ??/??'; + // JPN + self::$builtInFormats[28] = '[$-411]ggge"年"m"月"d"日"'; + self::$builtInFormats[29] = '[$-411]ggge"年"m"月"d"日"'; + self::$builtInFormats[31] = 'yyyy"年"m"月"d"日"'; + self::$builtInFormats[32] = 'h"時"mm"分"'; + self::$builtInFormats[33] = 'h"時"mm"分"ss"秒"'; + self::$builtInFormats[34] = 'yyyy"年"m"月"'; + self::$builtInFormats[35] = 'm"月"d"日"'; + self::$builtInFormats[51] = '[$-411]ggge"年"m"月"d"日"'; + self::$builtInFormats[52] = 'yyyy"年"m"月"'; + self::$builtInFormats[53] = 'm"月"d"日"'; + self::$builtInFormats[54] = '[$-411]ggge"年"m"月"d"日"'; + self::$builtInFormats[55] = 'yyyy"年"m"月"'; + self::$builtInFormats[56] = 'm"月"d"日"'; + self::$builtInFormats[58] = '[$-411]ggge"年"m"月"d"日"'; + // Flip array (for faster lookups) self::$flippedBuiltInFormats = array_flip(self::$builtInFormats); } @@ -596,7 +614,7 @@ class NumberFormat extends Supervisor } // Convert any other escaped characters to quoted strings, e.g. (\T to "T") - $format = preg_replace('/(\\\([^ ]))(?=(?:[^"]|"[^"]*")*$)/u', '"${2}"', $format); + $format = preg_replace('/(\\\(((.)(?!((AM\/PM)|(A\/P))))|([^ ])))(?=(?:[^"]|"[^"]*")*$)/u', '"${2}"', $format); // Get the sections, there can be up to four sections, separated with a semi-colon (but only if not a quoted literal) $sections = preg_split('/(;)(?=(?:[^"]|"[^"]*")*$)/u', $format); diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php index 44e66323206..697fc97efc3 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php @@ -64,7 +64,7 @@ abstract class Dimension */ public function setVisible($pValue) { - $this->visible = $pValue; + $this->visible = (bool) $pValue; return $this; } @@ -119,7 +119,7 @@ abstract class Dimension */ public function setCollapsed($pValue) { - $this->collapsed = $pValue; + $this->collapsed = (bool) $pValue; return $this; } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 59ef329c8b9..8510d402a35 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -170,6 +170,16 @@ class RowCellIterator extends CellIterator return $this->currentColumnIndex <= $this->endColumnIndex && $this->currentColumnIndex >= $this->startColumnIndex; } + /** + * Return the current iterator position. + * + * @return int + */ + public function getCurrentColumnIndex() + { + return $this->currentColumnIndex; + } + /** * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary. * diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php index d0224037616..1e525a3fecb 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -1096,7 +1096,7 @@ class Worksheet implements IComparable * @param string $column Return the highest data row for the specified column, * or the highest data row of any column if no column letter is passed * - * @return string Highest row number that contains data + * @return int Highest row number that contains data */ public function getHighestDataRow($column = null) { @@ -2064,7 +2064,7 @@ class Worksheet implements IComparable /** * Insert a new column, updating all possible related data. * - * @param int $pBefore Insert before this one, eg: 'A' + * @param string $pBefore Insert before this one, eg: 'A' * @param int $pNumCols Number of columns to insert * * @throws Exception diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php index 122783f30c6..f13150d7eb3 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php @@ -35,27 +35,11 @@ abstract class BaseWriter implements IWriter */ private $diskCachingDirectory = './'; - /** - * Write charts in workbook? - * If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object. - * If false (the default) it will ignore any charts defined in the PhpSpreadsheet object. - * - * @return bool - */ public function getIncludeCharts() { return $this->includeCharts; } - /** - * Set write charts in workbook - * Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object. - * Set to false (the default) to ignore charts. - * - * @param bool $pValue - * - * @return IWriter - */ public function setIncludeCharts($pValue) { $this->includeCharts = (bool) $pValue; @@ -63,30 +47,11 @@ abstract class BaseWriter implements IWriter return $this; } - /** - * Get Pre-Calculate Formulas flag - * If this is true (the default), then the writer will recalculate all formulae in a workbook when saving, - * so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet - * viewer when opening the file - * If false, then formulae are not calculated on save. This is faster for saving in PhpSpreadsheet, but slower - * when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself. - * - * @return bool - */ public function getPreCalculateFormulas() { return $this->preCalculateFormulas; } - /** - * Set Pre-Calculate Formulas - * Set to true (the default) to advise the Writer to calculate all formulae on save - * Set to false to prevent precalculation of formulae on save. - * - * @param bool $pValue Pre-Calculate Formulas? - * - * @return IWriter - */ public function setPreCalculateFormulas($pValue) { $this->preCalculateFormulas = (bool) $pValue; @@ -94,26 +59,11 @@ abstract class BaseWriter implements IWriter return $this; } - /** - * Get use disk caching where possible? - * - * @return bool - */ public function getUseDiskCaching() { return $this->useDiskCaching; } - /** - * Set use disk caching where possible? - * - * @param bool $pValue - * @param string $pDirectory Disk caching directory - * - * @throws Exception when directory does not exist - * - * @return IWriter - */ public function setUseDiskCaching($pValue, $pDirectory = null) { $this->useDiskCaching = $pValue; @@ -129,11 +79,6 @@ abstract class BaseWriter implements IWriter return $this; } - /** - * Get disk caching directory. - * - * @return string - */ public function getDiskCachingDirectory() { return $this->diskCachingDirectory; diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/IWriter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/IWriter.php index 9ce45a1946a..448b532fc2a 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/IWriter.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/IWriter.php @@ -13,6 +13,49 @@ interface IWriter */ public function __construct(Spreadsheet $spreadsheet); + /** + * Write charts in workbook? + * If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object. + * If false (the default) it will ignore any charts defined in the PhpSpreadsheet object. + * + * @return bool + */ + public function getIncludeCharts(); + + /** + * Set write charts in workbook + * Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object. + * Set to false (the default) to ignore charts. + * + * @param bool $pValue + * + * @return IWriter + */ + public function setIncludeCharts($pValue); + + /** + * Get Pre-Calculate Formulas flag + * If this is true (the default), then the writer will recalculate all formulae in a workbook when saving, + * so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet + * viewer when opening the file + * If false, then formulae are not calculated on save. This is faster for saving in PhpSpreadsheet, but slower + * when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself. + * + * @return bool + */ + public function getPreCalculateFormulas(); + + /** + * Set Pre-Calculate Formulas + * Set to true (the default) to advise the Writer to calculate all formulae on save + * Set to false to prevent precalculation of formulae on save. + * + * @param bool $pValue Pre-Calculate Formulas? + * + * @return IWriter + */ + public function setPreCalculateFormulas($pValue); + /** * Save PhpSpreadsheet to file. * @@ -21,4 +64,30 @@ interface IWriter * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ public function save($pFilename); + + /** + * Get use disk caching where possible? + * + * @return bool + */ + public function getUseDiskCaching(); + + /** + * Set use disk caching where possible? + * + * @param bool $pValue + * @param string $pDirectory Disk caching directory + * + * @throws Exception when directory does not exist + * + * @return IWriter + */ + public function setUseDiskCaching($pValue, $pDirectory = null); + + /** + * Get disk caching directory. + * + * @return string + */ + public function getDiskCachingDirectory(); } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php index e87d09a2233..6049e32878b 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -1009,7 +1009,7 @@ class Parser break; case '>': - if ($this->lookAhead == '=') { // it's a GE token + if ($this->lookAhead === '=') { // it's a GE token break; } @@ -1018,7 +1018,7 @@ class Parser break; case '<': // it's a LE or a NE token - if (($this->lookAhead == '=') or ($this->lookAhead == '>')) { + if (($this->lookAhead === '=') or ($this->lookAhead === '>')) { break; } @@ -1027,12 +1027,12 @@ class Parser break; default: // if it's a reference A1 or $A$1 or $A1 or A$1 - if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?\d+$/', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.') and ($this->lookAhead != '!')) { + if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?\d+$/', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.') and ($this->lookAhead !== '!')) { return $token; - } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?[A-Ia-i]?[A-Za-z]\$?\\d+$/u', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) { + } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?[A-Ia-i]?[A-Za-z]\$?\\d+$/u', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.')) { // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) return $token; - } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?[A-Ia-i]?[A-Za-z]\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) { + } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?[A-Ia-i]?[A-Za-z]\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.')) { // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) return $token; } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $token) && !preg_match('/\d/', $this->lookAhead)) { @@ -1044,19 +1044,19 @@ class Parser } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+:\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead)) { // If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2 return $token; - } elseif (is_numeric($token) and (!is_numeric($token . $this->lookAhead) or ($this->lookAhead == '')) and ($this->lookAhead != '!') and ($this->lookAhead != ':')) { + } elseif (is_numeric($token) and (!is_numeric($token . $this->lookAhead) or ($this->lookAhead == '')) and ($this->lookAhead !== '!') and ($this->lookAhead !== ':')) { // If it's a number (check that it's not a sheet name or range) return $token; - } elseif (preg_match('/"([^"]|""){0,255}"/', $token) and $this->lookAhead != '"' and (substr_count($token, '"') % 2 == 0)) { + } elseif (preg_match('/"([^"]|""){0,255}"/', $token) and $this->lookAhead !== '"' and (substr_count($token, '"') % 2 == 0)) { // If it's a string (of maximum 255 characters) return $token; - } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) or $token == '#N/A') { + } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) or $token === '#N/A') { // If it's an error code return $token; - } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/i", $token) and ($this->lookAhead == '(')) { + } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/i", $token) and ($this->lookAhead === '(')) { // if it's a function call return $token; - } elseif (substr($token, -1) == ')') { + } elseif (substr($token, -1) === ')') { // It's an argument of some description (e.g. a named range), // precise nature yet to be determined return $token; @@ -1078,8 +1078,7 @@ class Parser { $this->currentCharacter = 0; $this->formula = $formula; - $this->lookAhead = isset($formula[1]) ? $formula[1] - : ''; + $this->lookAhead = isset($formula[1]) ? $formula[1] : ''; $this->advance(); $this->parseTree = $this->condition(); @@ -1248,10 +1247,10 @@ class Parser */ private function fact() { - if ($this->currentToken == '(') { + if ($this->currentToken === '(') { $this->advance(); // eat the "(" $result = $this->parenthesizedExpression(); - if ($this->currentToken != ')') { + if ($this->currentToken !== ')') { throw new WriterException("')' token expected."); } $this->advance(); // eat the ")" @@ -1299,7 +1298,7 @@ class Parser return $result; } elseif (is_numeric($this->currentToken)) { // If it's a number or a percent - if ($this->lookAhead == '%') { + if ($this->lookAhead === '%') { $result = $this->createTree('ptgPercent', $this->currentToken, ''); $this->advance(); // Skip the percentage operator once we've pre-built that tree } else { @@ -1331,9 +1330,9 @@ class Parser $result = ''; // initialize result $this->advance(); $this->advance(); // eat the "(" - while ($this->currentToken != ')') { + while ($this->currentToken !== ')') { if ($num_args > 0) { - if ($this->currentToken == ',' || $this->currentToken == ';') { + if ($this->currentToken === ',' || $this->currentToken === ';') { $this->advance(); // eat the "," or ";" } else { throw new WriterException("Syntax error: comma expected in function $function, arg #{$num_args}"); diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Workbook.php index b463ce4a8f0..41c8e64e297 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -267,9 +267,7 @@ class Workbook extends BIFFwriter $this->xfWriters[] = $xfWriter; - $xfIndex = count($this->xfWriters) - 1; - - return $xfIndex; + return count($this->xfWriters) - 1; } /** @@ -319,7 +317,7 @@ class Workbook extends BIFFwriter if ($colorIndex) { $this->colors[$rgb] = $colorIndex; } else { - if (count($this->colors) == 0) { + if (count($this->colors) === 0) { $lastColor = 7; } else { $lastColor = end($this->colors); @@ -437,7 +435,7 @@ class Workbook extends BIFFwriter // Prepare part 3 of the workbook global stream, what goes after the SHEET records $part3 = ''; - if ($this->countryCode != -1) { + if ($this->countryCode !== -1) { $part3 .= $this->writeCountry(); } $part3 .= $this->writeRecalcId(); @@ -918,7 +916,7 @@ class Workbook extends BIFFwriter $record = 0x0022; // Record identifier $length = 0x0002; // Bytes to follow - $f1904 = (Date::getExcelCalendar() == Date::CALENDAR_MAC_1904) + $f1904 = (Date::getExcelCalendar() === Date::CALENDAR_MAC_1904) ? 1 : 0; // Flag for 1904 date system diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php index dd19021e46e..58897639024 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php @@ -328,6 +328,17 @@ class Xlsx extends BaseWriter $zip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts)); } + // Add unparsed drawings + if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['Drawings'])) { + foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['Drawings'] as $relId => $drawingXml) { + $drawingFile = array_search($relId, $unparsedLoadedData['sheets'][$sheetCodeName]['drawingOriginalIds']); + if ($drawingFile !== false) { + $drawingFile = ltrim($drawingFile, '.'); + $zip->addFromString('xl' . $drawingFile, $drawingXml); + } + } + } + // Add comment relationship parts if (count($this->spreadSheet->getSheet($i)->getComments()) > 0) { // VML Comments @@ -338,8 +349,8 @@ class Xlsx extends BaseWriter } // Add unparsed relationship parts - if (isset($unparsedLoadedData['sheets'][$this->spreadSheet->getSheet($i)->getCodeName()]['vmlDrawings'])) { - foreach ($unparsedLoadedData['sheets'][$this->spreadSheet->getSheet($i)->getCodeName()]['vmlDrawings'] as $vmlDrawing) { + if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'])) { + foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'] as $vmlDrawing) { $zip->addFromString($vmlDrawing['filePath'], $vmlDrawing['content']); } } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php index e3ddb03c143..b9f8f99b71f 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php @@ -93,7 +93,7 @@ class Workbook extends WriterPart { $objWriter->startElement('workbookPr'); - if (Date::getExcelCalendar() == Date::CALENDAR_MAC_1904) { + if (Date::getExcelCalendar() === Date::CALENDAR_MAC_1904) { $objWriter->writeAttribute('date1904', '1'); } @@ -225,7 +225,7 @@ class Workbook extends WriterPart $objWriter->startElement('sheet'); $objWriter->writeAttribute('name', $pSheetname); $objWriter->writeAttribute('sheetId', $pSheetId); - if ($sheetState != 'visible' && $sheetState != '') { + if ($sheetState !== 'visible' && $sheetState != '') { $objWriter->writeAttribute('state', $sheetState); } $objWriter->writeAttribute('r:id', 'rId' . $pRelId); diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 78a62e9eca4..065eaaf1c9b 100644 --- a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -141,7 +141,7 @@ class Worksheet extends WriterPart $objWriter->startElement('sheetPr'); if ($pSheet->getParent()->hasMacros()) { //if the workbook have macros, we need to have codeName for the sheet - if ($pSheet->hasCodeName() == false) { + if (!$pSheet->hasCodeName()) { $pSheet->setCodeName($pSheet->getTitle()); } $objWriter->writeAttribute('codeName', $pSheet->getCodeName()); @@ -322,7 +322,7 @@ class Worksheet extends WriterPart } // Set Zero Height row - if ((string) $pSheet->getDefaultRowDimension()->getZeroHeight() == '1' || + if ((string) $pSheet->getDefaultRowDimension()->getZeroHeight() === '1' || strtolower((string) $pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true') { $objWriter->writeAttribute('zeroHeight', '1'); } @@ -383,7 +383,7 @@ class Worksheet extends WriterPart } // Column visibility - if ($colDimension->getVisible() == false) { + if ($colDimension->getVisible() === false) { $objWriter->writeAttribute('hidden', 'true'); } @@ -398,7 +398,7 @@ class Worksheet extends WriterPart } // Collapsed - if ($colDimension->getCollapsed() == true) { + if ($colDimension->getCollapsed() === true) { $objWriter->writeAttribute('collapsed', 'true'); } @@ -428,7 +428,7 @@ class Worksheet extends WriterPart // sheetProtection $objWriter->startElement('sheetProtection'); - if ($pSheet->getProtection()->getPassword() != '') { + if ($pSheet->getProtection()->getPassword() !== '') { $objWriter->writeAttribute('password', $pSheet->getProtection()->getPassword()); } @@ -519,6 +519,9 @@ class Worksheet extends WriterPart // Formula $objWriter->writeElement('formula', $formula); } + } elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSBLANKS) { + // formula copied from ms xlsx xml source file + $objWriter->writeElement('formula', 'LEN(TRIM(' . $cellCoordinate . '))=0'); } $objWriter->endElement(); @@ -624,8 +627,9 @@ class Worksheet extends WriterPart $objWriter->writeAttribute('location', str_replace('sheet://', '', $hyperlink->getUrl())); } - if ($hyperlink->getTooltip() != '') { + if ($hyperlink->getTooltip() !== '') { $objWriter->writeAttribute('tooltip', $hyperlink->getTooltip()); + $objWriter->writeAttribute('display', $hyperlink->getTooltip()); } $objWriter->endElement(); @@ -991,12 +995,12 @@ class Worksheet extends WriterPart } // Row visibility - if ($rowDimension->getVisible() == false) { + if (!$rowDimension->getVisible() === true) { $objWriter->writeAttribute('hidden', 'true'); } // Collapsed - if ($rowDimension->getCollapsed() == true) { + if ($rowDimension->getCollapsed() === true) { $objWriter->writeAttribute('collapsed', 'true'); } @@ -1101,7 +1105,7 @@ class Worksheet extends WriterPart break; case 'f': // Formula $attributes = $pCell->getFormulaAttributes(); - if ($attributes['t'] == 'array') { + if ($attributes['t'] === 'array') { $objWriter->startElement('f'); $objWriter->writeAttribute('t', 'array'); $objWriter->writeAttribute('ref', $pCellAddress); @@ -1114,7 +1118,7 @@ class Worksheet extends WriterPart } if ($this->getParentWriter()->getOffice2003Compatibility() === false) { if ($this->getParentWriter()->getPreCalculateFormulas()) { - if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') { + if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) !== '#') { $objWriter->writeElement('v', StringHelper::formatNumber($calculatedValue)); } else { $objWriter->writeElement('v', '0'); @@ -1135,7 +1139,7 @@ class Worksheet extends WriterPart break; case 'e': // Error - if (substr($cellValue, 0, 1) == '=') { + if (substr($cellValue, 0, 1) === '=') { $objWriter->writeElement('f', substr($cellValue, 1)); $objWriter->writeElement('v', substr($cellValue, 1)); } else { From dfdae71e42c435fd97f1ee1a43ce9a9fb40a802d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 18:33:01 +0200 Subject: [PATCH 562/618] Update phpspeadsheet to 1.8.2 --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index f9d06530c9a..130fda34945 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,7 @@ "ckeditor/ckeditor" : "4.12.1", "mike42/escpos-php" : "2.2", "mobiledetect/mobiledetectlib" : "2.8.34", + "phpoffice/phpexcel" : "1.8.2", "restler/framework" : "3.0.0-RC6", "tecnickcom/tcpdf" : "6.3.2", "nnnick/chartjs" : "^2.9", From 6c84b858eeb57b6eee9e7f3f3edd0f2301d7e9a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 18:51:42 +0200 Subject: [PATCH 563/618] Fix #yogosha5832 --- htdocs/bom/class/api_boms.class.php | 4 ++++ htdocs/mrp/class/api_mos.class.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index b0f536140dd..1fe104987a3 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -99,6 +99,10 @@ class Boms extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->bom->read) { + throw new RestException(401); + } + $obj_ret = array(); $tmpobject = new BOM($this->db); diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 281ec0fb731..48f93976d29 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -98,6 +98,10 @@ class Mos extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->mrp->read) { + throw new RestException(401); + } + $obj_ret = array(); $tmpobject = new Mo($this->db); From 667481acd580ce827062883a281e03cdc03859bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 19:05:28 +0200 Subject: [PATCH 564/618] Fix #yogosha5832 - Missin test on permission for /index routes on APIs --- htdocs/comm/propal/class/api_proposals.class.php | 4 ++++ htdocs/commande/class/api_orders.class.php | 4 ++++ htdocs/compta/facture/class/api_invoices.class.php | 4 ++++ htdocs/contrat/class/api_contracts.class.php | 4 ++++ htdocs/don/class/api_donations.class.php | 7 +++++++ htdocs/expedition/class/api_shipments.class.php | 4 ++++ htdocs/expensereport/class/api_expensereports.class.php | 7 +++++++ htdocs/fichinter/class/api_interventions.class.php | 4 ++++ htdocs/fourn/class/api_supplier_invoices.class.php | 4 ++++ htdocs/fourn/class/api_supplier_orders.class.php | 4 ++++ htdocs/product/class/api_products.class.php | 4 ++++ htdocs/projet/class/api_projects.class.php | 4 ++++ htdocs/projet/class/api_tasks.class.php | 4 ++++ htdocs/societe/class/api_contacts.class.php | 2 ++ htdocs/societe/class/api_thirdparties.class.php | 6 ++++++ .../class/api_supplier_proposals.class.php | 4 ++++ htdocs/ticket/class/api_tickets.class.php | 4 ++++ htdocs/zapier/class/api_zapier.class.php | 7 +++++++ 18 files changed, 81 insertions(+) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 9f5cdea8000..042303b7eed 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -155,6 +155,10 @@ class Proposals extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->propal->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 17b7d4285b4..1bf3b97a040 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -158,6 +158,10 @@ class Orders extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->commande->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 87bcbe12b3e..0633affef49 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -165,6 +165,10 @@ class Invoices extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->facture->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index cf821ccb2c6..1de8f0c480d 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -106,6 +106,10 @@ class Contracts extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->contrat->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index ab0d6e5f483..2773ab62c14 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -103,6 +103,10 @@ class Donations extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->don->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid @@ -179,6 +183,7 @@ class Donations extends DolibarrApi if (!DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401, "Insuffisant rights"); } + // Check mandatory fields $result = $this->_validate($request_data); @@ -247,6 +252,7 @@ class Donations extends DolibarrApi if (!DolibarrApiAccess::$user->rights->don->supprimer) { throw new RestException(401); } + $result = $this->don->fetch($id); if (!$result) { throw new RestException(404, 'Donation not found'); @@ -295,6 +301,7 @@ class Donations extends DolibarrApi if (!DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); } + $result = $this->don->fetch($id); if (!$result) { throw new RestException(404, 'Donation not found'); diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index cc5267cdd47..961790cc3bd 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -103,6 +103,10 @@ class Shipments extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->expedition->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 13148e4247a..7321cb40625 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -99,6 +99,10 @@ class ExpenseReports extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->expensereport->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $societe param is ignored and replaced by user's socid @@ -164,6 +168,7 @@ class ExpenseReports extends DolibarrApi if (!DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401, "Insuffisant rights"); } + // Check mandatory fields $result = $this->_validate($request_data); @@ -427,6 +432,7 @@ class ExpenseReports extends DolibarrApi if (!DolibarrApiAccess::$user->rights->expensereport->supprimer) { throw new RestException(401); } + $result = $this->expensereport->fetch($id); if (!$result) { throw new RestException(404, 'Expense Report not found'); @@ -469,6 +475,7 @@ class ExpenseReports extends DolibarrApi if(! DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401); } + $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index 17aa2b3db53..423bb31f348 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -110,6 +110,10 @@ class Interventions extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 5e977473146..b9b541f0229 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -102,6 +102,10 @@ class SupplierInvoices extends DolibarrApi { global $db; + if (!DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 8076900b100..b09b5677e10 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -101,6 +101,10 @@ class SupplierOrders extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->fournisseur->commande->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c38437fb2f0..79751ea2e14 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -172,6 +172,10 @@ class Products extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->produit->lire) { + throw new RestException(403); + } + $obj_ret = array(); $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 47536986a80..6a08aa7a4bd 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -103,6 +103,10 @@ class Projects extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->projet->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 748d9ce2594..cd6df68d590 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -109,6 +109,10 @@ class Tasks extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->projet->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 3993ad38e5f..5a6513ef6e5 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -74,6 +74,7 @@ class Contacts extends DolibarrApi if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { throw new RestException(401, 'No permission to read contacts'); } + if ($id == 0) { $result = $this->contact->initAsSpecimen(); } else { @@ -117,6 +118,7 @@ class Contacts extends DolibarrApi if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { throw new RestException(401, 'No permission to read contacts'); } + if (empty($email)) { $result = $this->contact->initAsSpecimen(); } else { diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index f5eae0be948..b0b486459b1 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -132,6 +132,10 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); + if (!DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } + // case of external user, we force socids $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; @@ -1842,9 +1846,11 @@ class Thirdparties extends DolibarrApi private function _fetch($rowid, $ref = '', $ref_ext = '', $barcode = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') { global $conf; + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } + if ($rowid === 0) { $result = $this->company->initAsSpecimen(); } else { diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index 1368cce7811..3e38ac10b41 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -98,6 +98,10 @@ class Supplierproposals extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->supplier_proposal->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index d8e36933ea6..f814beb3398 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -232,6 +232,10 @@ class Tickets extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->ticket->read) { + throw new RestException(403); + } + $obj_ret = array(); if (!$socid && DolibarrApiAccess::$user->socid) { diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index ebf62d115ab..c141588a7f9 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -104,6 +104,7 @@ class ZapierApi extends DolibarrApi if (!DolibarrApiAccess::$user->rights->zapier->read) { throw new RestException(401); } + $arraychoices = array( 'invoices' => 'Invoices', 'orders' => 'Orders', @@ -143,6 +144,10 @@ class ZapierApi extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->zapier->read) { + throw new RestException(401); + } + $obj_ret = array(); $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; @@ -242,6 +247,7 @@ class ZapierApi extends DolibarrApi if (!DolibarrApiAccess::$user->rights->zapier->write) { throw new RestException(401); } + // Check mandatory fields $fields = array( 'url', @@ -313,6 +319,7 @@ class ZapierApi extends DolibarrApi if (!DolibarrApiAccess::$user->rights->zapier->delete) { throw new RestException(401); } + $result = $this->hook->fetch($id); if (!$result) { throw new RestException(404, 'Hook not found'); From 60711f415da3f47fb47bbd2956d70d02a54293fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Apr 2021 19:52:07 +0200 Subject: [PATCH 565/618] Fix permission on external user --- .../fourn/class/fournisseur.product.class.php | 6 +- htdocs/product/class/api_products.class.php | 58 +++++++++++++++---- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index c910cffe8d4..21b4ec377a2 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -634,9 +634,10 @@ class ProductFournisseur extends Product * @param string $sortorder Sort order * @param int $limit Limit * @param int $offset Offset + * @param int $socid Filter on a third party id * @return array Array of Products with new properties to define supplier price */ - public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) + public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0) { // phpcs:enable global $conf; @@ -652,7 +653,8 @@ class ProductFournisseur extends Product $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; - $sql .= " AND s.status=1"; // only enabled company selected + $sql .= ($socid > 0 ? ' AND pfp.fk_soc = '.((int) $socid) : ''); + $sql .= " AND s.status = 1"; // only enabled company selected $sql .= " AND pfp.fk_product = ".((int) $prodid); if (empty($sortfield)) { $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 79751ea2e14..a572d0946c4 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -574,8 +574,8 @@ class Products extends DolibarrApi /** * Get prices per customer for a product * - * @param int $id ID of product - * @param string $thirdparty_id Thirdparty id to filter orders of (example '1') {@pattern /^[0-9,]*$/i} + * @param int $id ID of product + * @param string $thirdparty_id Thirdparty id to filter orders of (example '1') {@pattern /^[0-9,]*$/i} * * @return mixed * @@ -593,6 +593,11 @@ class Products extends DolibarrApi throw new RestException(400, 'API not available: this mode of pricing is not enabled by setup'); } + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + if ($socid > 0 && $socid != $thirdparty_id) { + throw new RestException(401, 'Getting prices for all customers or for the customer ID '.$thirdparty_id.' is not allowed for login '.DolibarrApiAccess::$user->login); + } + $result = $this->product->fetch($id); if (!$result) { throw new RestException(404, 'Product not found'); @@ -700,6 +705,11 @@ class Products extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + if ($socid > 0 && $socid != $fourn_id) { + throw new RestException(401, 'Adding purchase price for the supplier ID '.$fourn_id.' is not allowed for login '.DolibarrApiAccess::$user->login); + } + $result = $this->productsupplier->add_fournisseur(DolibarrApiAccess::$user, $fourn_id, $ref_fourn, $qty); if ($result < 0) { throw new RestException(500, "Error adding supplier to product : ".$this->db->lasterror()); @@ -774,9 +784,19 @@ class Products extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->produit->lire) { + throw new RestException(401); + } + $obj_ret = array(); + // Force id of company for external users $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + if ($socid > 0) { + if ($supplier != $socid || empty($supplier)) { + throw new RestException(401, 'As an external user, you can request only for your supplier id = '.$socid); + } + } $sql = "SELECT t.rowid, t.ref, t.ref_ext"; $sql .= " FROM ".MAIN_DB_PREFIX."product as t"; @@ -788,12 +808,15 @@ class Products extends DolibarrApi $sql .= ' WHERE t.entity IN ('.getEntity('product').')'; if ($supplier > 0) { - $sql .= " AND s.fk_soc = ".$this->db->escape($supplier); + $sql .= " AND s.fk_soc = "((int) $supplier); + } + if ($socid > 0) { // if external user + $sql .= " AND s.fk_soc = ".((int) $socid); } $sql .= " AND s.fk_product = t.rowid"; // Select products of given category if ($category > 0) { - $sql .= " AND c.fk_categorie = ".$this->db->escape($category); + $sql .= " AND c.fk_categorie = ".((int) $category); $sql .= " AND c.fk_product = t.rowid"; } if ($mode == 1) { @@ -878,6 +901,8 @@ class Products extends DolibarrApi throw new RestException(403); } + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + $result = $this->product->fetch($id, $ref, $ref_ext, $barcode); if (!$result) { throw new RestException(404, 'Product not found'); @@ -891,7 +916,7 @@ class Products extends DolibarrApi if ($result) { $product_fourn = new ProductFournisseur($this->db); - $product_fourn_list = $product_fourn->list_product_fournisseur_price($this->product->id, '', '', 0, 0); + $product_fourn_list = $product_fourn->list_product_fournisseur_price($this->product->id, '', '', 0, 0, ($socid > 0 ? $socid : 0)); } foreach ($product_fourn_list as $tmpobj) { @@ -911,7 +936,9 @@ class Products extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:color)" * @return array * - * @throws RestException + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 503 * * @url GET attributes */ @@ -976,7 +1003,6 @@ class Products extends DolibarrApi * @param int $id ID of Attribute * @return array * - * @throws RestException * @throws RestException 401 * @throws RestException 404 * @@ -1020,8 +1046,8 @@ class Products extends DolibarrApi * @param string $ref Reference of Attribute * @return array * - * @throws RestException 500 * @throws RestException 401 + * @throws RestException 404 * * @url GET attributes/ref/{ref} */ @@ -1272,7 +1298,10 @@ class Products extends DolibarrApi throw new RestException(401); } - $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '".trim($ref)."' AND fk_product_attribute = ".(int) $id." AND entity IN (".getEntity('product').")"; + $ref = trim($ref); + + $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value"; + $sql .= " WHERE ref LIKE '".$this->db->escape($ref)."' AND fk_product_attribute = ".((int) $id)." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); @@ -1312,7 +1341,10 @@ class Products extends DolibarrApi throw new RestException(401); } - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '".trim($ref)."' AND fk_product_attribute = ".(int) $id." AND entity IN (".getEntity('product').")"; + $ref = trim($ref); + + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute_value"; + $sql .= " WHERE ref LIKE '".$this->db->escape($ref)."' AND fk_product_attribute = ".((int) $id)." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); if (!$query) { @@ -1383,11 +1415,13 @@ class Products extends DolibarrApi throw new RestException(401); } + $ref = trim($ref); + $return = array(); $sql = 'SELECT '; $sql .= 'v.fk_product_attribute, v.rowid, v.ref, v.value FROM '.MAIN_DB_PREFIX.'product_attribute_value as v'; - $sql .= " WHERE v.fk_product_attribute IN (SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '".$this->db->escape(trim($ref))."')"; + $sql .= " WHERE v.fk_product_attribute IN (SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '".$this->db->escape($ref)."')"; $resql = $this->db->query($sql); @@ -1428,7 +1462,7 @@ class Products extends DolibarrApi } $objectval = new ProductAttributeValue($this->db); - $objectval->fk_product_attribute = $id; + $objectval->fk_product_attribute = ((int) $id); $objectval->ref = $ref; $objectval->value = $value; From 2d771704d0d088af79eb674e7187f822ed7f20f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 00:36:08 +0200 Subject: [PATCH 566/618] Better suggestion for data after clone of social contribution --- htdocs/compta/sociales/card.php | 15 ++++++++++++--- .../sociales/class/chargesociales.class.php | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index b2ac294021c..0f38181e284 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -235,17 +235,26 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char $object->label = $langs->trans("CopyOf").' '.$object->label; } - if (GETPOST('clone_for_next_month', 'int')) { + if (GETPOST('clone_for_next_month', 'int')) { // This can be true only if TAX_ADD_CLONE_FOR_NEXT_MONTH_CHECKBOX has been set $object->periode = dol_time_plus_duree($object->periode, 1, 'm'); $object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm'); } else { + // Note dateech is often a little bit higher than dateperiod $newdateperiod = dol_mktime(0, 0, 0, GETPOST('clone_periodmonth', 'int'), GETPOST('clone_periodday', 'int'), GETPOST('clone_periodyear', 'int')); $newdateech = dol_mktime(0, 0, 0, GETPOST('clone_date_echmonth', 'int'), GETPOST('clone_date_echday', 'int'), GETPOST('clone_date_echyear', 'int')); if ($newdateperiod) { $object->periode = $newdateperiod; + if (empty($newdateech)) { + $object->date_ech = $object->periode; + } } if ($newdateech) { $object->date_ech = $newdateech; + if (empty($newdateperiod)) { + // TODO We can here get dol_get_last_day of previous month: + // $object->periode = dol_get_last_day(year of $object->date_ech - 1m, month or $object->date_ech -1m) + $object->periode = $object->date_ech; + } } } @@ -410,9 +419,9 @@ if ($id > 0) { // Clone confirmation if ($action === 'clone') { $formquestion = array( - array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label), + array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label, 'tdclass'=>'fieldrequired'), ); - if (!empty($conf->global->TAX_ADD_CLON_FOR_NEXT_MONTH_CHECKBOX)) { + if (!empty($conf->global->TAX_ADD_CLONE_FOR_NEXT_MONTH_CHECKBOX)) { $formquestion[] = array('type' => 'checkbox', 'name' => 'clone_for_next_month', 'label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1); } else { $formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1); diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index d7fcd9278a9..20cc2c82b0c 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -197,7 +197,7 @@ class ChargeSociales extends CommonObject { $newamount = price2num($this->amount, 'MT'); - // Validation parametres + // Validation of parameters if (!$newamount > 0 || empty($this->date_ech) || empty($this->periode)) { return false; } From 475bdc24f4bf4377c394ff8c759b9981169f9dae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 01:31:55 +0200 Subject: [PATCH 567/618] Fix sql error --- htdocs/website/class/websitepage.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 32c8c0b8688..f22a5200148 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -426,7 +426,7 @@ class WebsitePage extends CommonObject } $listoflang[] = "'".$this->db->escape(substr(str_replace("'", '', $tmpvalue), 0, 2))."'"; } - $stringtouse = $key." IN (".$this->db->sanitize(join(',', $listoflang)).")"; + $stringtouse = $key." IN (".$this->db->sanitize(join(',', $listoflang), 1).")"; if ($foundnull) { $stringtouse = '('.$stringtouse.' OR '.$key.' IS NULL)'; } From f2a49ef72ff9f4eb0358694d09db47273e01439b Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 9 Apr 2021 02:23:22 +0200 Subject: [PATCH 568/618] New option amount by member type --- htdocs/adherents/admin/member.php | 16 ++++++++++- htdocs/adherents/admin/website.php | 2 +- htdocs/adherents/class/adherent.class.php | 5 +++- htdocs/langs/en_US/members.lang | 1 + htdocs/langs/fr_FR/members.lang | 1 + htdocs/public/payment/newpayment.php | 33 +++++++++++++++++++++++ htdocs/public/payment/paymentok.php | 8 +++--- 7 files changed, 60 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 3d40f8d758b..73770f38905 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -33,6 +33,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "members")); @@ -101,11 +102,12 @@ if ($action == 'set_default') { } } elseif ($action == 'updateall') { $db->begin(); - $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; + $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = $res7 = 0; $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity); $res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); + $res7 = dolibarr_set_const($db, "MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE", json_encode(GETPOST('MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE')), 'array', 0, '', $conf->entity); // Use vat for invoice creation if ($conf->facture->enabled) { $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -217,6 +219,18 @@ print '
    '.$langs->trans("MemberSendInformationByMailByDef print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? $conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL : 0), 1); print "
    '.$langs->trans("DefineAmountMemberType").''; +foreach ($adht->liste_array(1) as $typeid => $type){ + print $type .' : '; + print ''; + print '
    '; +} +print "
    '.$langs->trans("MoreActionsOnSubscription").''; $listofval = array(); - $listofval += $adht->liste_array(); + $listofval += $adht->liste_array(1); $forcetype = empty($conf->global->MEMBER_NEWFORM_FORCETYPE) ? -1 : $conf->global->MEMBER_NEWFORM_FORCETYPE; print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0); print "
    '.$langs->trans("LastMemberType"); + print ''.dol_escape_htmltag($member->type); + print "
    '.$langs->trans("NewSubscription"); + print ''; + print $form->selectarray("typeid", $adht->liste_array(1) , $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.$source.'&ref='.$ref.'&amount='.$amount.'&typeid=\' + this.value + \'&securekey='.$SECUREKEY.'\');"', 0, 0, 0, '', '', 1); + print "
    '.$langs->trans("NewMemberType"); + print ''.dol_escape_htmltag($member->type); + print ''; + print "
    '.$langs->trans("Amount"); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 99a97e0c321..bf957d4cf6b 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -98,10 +98,11 @@ $FULLTAG = GETPOST('FULLTAG'); if (empty($FULLTAG)) { $FULLTAG = GETPOST('fulltag'); } -$source = GETPOST('s', 'alpha') ?GETPOST('s', 'alpha') : GETPOST('source', 'alpha'); +$source = GETPOST('s', 'alpha') ? GETPOST('s', 'alpha') : GETPOST('source', 'alpha'); $ref = GETPOST('ref'); $suffix = GETPOST("suffix", 'aZ09'); +$membertypeid = GETPOST("membertypeid", 'int'); // Detect $paymentmethod @@ -339,7 +340,8 @@ if ($ispaymentok) { $user->rights->facture = new stdClass(); } if (empty($user->rights->adherent)) { - $user->rights->adherent = new stdClass(); $user->rights->adherent->cotisation = new stdClass(); + $user->rights->adherent = new stdClass(); + $user->rights->adherent->cotisation = new stdClass(); } $user->rights->societe->creer = 1; $user->rights->facture->creer = 1; @@ -460,7 +462,7 @@ if ($ispaymentok) { if (!$error) { dol_syslog("Call ->subscription to create subscription", LOG_DEBUG, 0, '_payment'); - $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); + $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid); if ($crowid <= 0) { $error++; $errmsg = $object->error; From dce5c6be8f5cb78c8fe7a4ccf1faa5554e49301b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 9 Apr 2021 00:28:07 +0000 Subject: [PATCH 569/618] Fixing style errors. --- htdocs/adherents/admin/member.php | 8 ++-- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/public/payment/newpayment.php | 58 +++++++++++------------ htdocs/public/payment/paymentok.php | 2 +- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 73770f38905..98da5281088 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -224,10 +224,10 @@ print "
    '.$langs->trans("DefineAmountMemberType").''; -foreach ($adht->liste_array(1) as $typeid => $type){ - print $type .' : '; - print ''; - print '
    '; +foreach ($adht->liste_array(1) as $typeid => $type) { + print $type .' : '; + print ''; + print '
    '; } print "
    '.$langs->trans("LastMemberType"); - print ''.dol_escape_htmltag($member->type); - print "
    '.$langs->trans("LastMemberType"); + print ''.dol_escape_htmltag($member->type); + print "
    '.$langs->trans("NewSubscription"); - print ''; - print $form->selectarray("typeid", $adht->liste_array(1) , $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.$source.'&ref='.$ref.'&amount='.$amount.'&typeid=\' + this.value + \'&securekey='.$SECUREKEY.'\');"', 0, 0, 0, '', '', 1); - print "
    '.$langs->trans("NewMemberType"); - print ''.dol_escape_htmltag($member->type); - print ''; - print "
    '.$langs->trans("NewSubscription"); + print ''; + print $form->selectarray("typeid", $adht->liste_array(1), $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.$source.'&ref='.$ref.'&amount='.$amount.'&typeid=\' + this.value + \'&securekey='.$SECUREKEY.'\');"', 0, 0, 0, '', '', 1); + print "
    '.$langs->trans("NewMemberType"); + print ''.dol_escape_htmltag($member->type); + print ''; + print "
    '.$langs->trans("LastMemberType"); print ''.dol_escape_htmltag($member->type); - print "
    '.$langs->trans("NewSubscription"); print ''; print $form->selectarray("typeid", $adht->liste_array(1) , $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.$source.'&ref='.$ref.'&amount='.$amount.'&typeid=\' + this.value + \'&securekey='.$SECUREKEY.'\');"', 0, 0, 0, '', '', 1); - print "
    '.$langs->trans("NewMemberType"); print ''.dol_escape_htmltag($member->type); print ''; - print "
    '.$langs->trans("LastMemberType"); print ''.dol_escape_htmltag($member->type); - print "
    '.$langs->trans("NewSubscription"); print ''; print $form->selectarray("typeid", $adht->liste_array(1) , $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.$source.'&ref='.$ref.'&amount='.$amount.'&typeid=\' + this.value + \'&securekey='.$SECUREKEY.'\');"', 0, 0, 0, '', '', 1); - print "
    '.$langs->trans("NewMemberType"); print ''.dol_escape_htmltag($member->type); print ''; - print "
    '.$langs->trans("LastMemberType"); print ''.dol_escape_htmltag($member->type); - print "
    '.$langs->trans("NewSubscription"); print ''; print $form->selectarray("typeid", $adht->liste_array(1), $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.$source.'&ref='.$ref.'&amount='.$amount.'&typeid=\' + this.value + \'&securekey='.$SECUREKEY.'\');"', 0, 0, 0, '', '', 1); - print "
    '.$langs->trans("NewMemberType"); print ''.dol_escape_htmltag($member->type); print ''; - print "
    '.$langs->trans("DefineAmountMemberType").'
    '; print dol_escape_htmltag($proplabel); print ''; - print ''.dol_escape_htmltag($proptype).''; - print ''; - if ($proparrayofkeyval) { - print ''; - print dol_escape_htmltag(json_encode($proparrayofkeyval)); + if ($action == 'editproperty' && $propname == $propertykey) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''.dol_escape_htmltag($proptype).''; + print ''; + if ($proparrayofkeyval) { + print ''; + print dol_escape_htmltag(json_encode($proparrayofkeyval)); + print ''; + } + print ''; + print dol_escape_htmltag($propnotnull); + print ''; + print dol_escape_htmltag($propdefault); + print ''; + print $propindex ? '1' : ''; + print ''; + print $propforeignkey ? dol_escape_htmltag($propforeignkey) : ''; + print ''; + print dol_escape_htmltag($propposition); + print ''; + print $propenabled ? dol_escape_htmltag($propenabled) : ''; + print ''; + print $propvisible ? dol_escape_htmltag($propvisible) : '0'; + print ''; + print $propnoteditable ? dol_escape_htmltag($propnoteditable) : ''; + print ''; + print $propsearchall ? '1' : ''; + print ''; + print $propisameasure ? dol_escape_htmltag($propisameasure) : ''; + print ''; + print $propcss ? dol_escape_htmltag($propcss) : ''; + print ''; + print $propcssview ? dol_escape_htmltag($propcssview) : ''; + print ''; + print $propcsslist ? dol_escape_htmltag($propcsslist) : ''; + print ''; + print $prophelp ? dol_escape_htmltag($prophelp) : ''; + print ''; + print $propshowoncombobox ? dol_escape_htmltag($propshowoncombobox) : ''; + print ''; + print $propdisabled?$propdisabled:''; + print ''; + print ''; + print dol_escape_htmltag($propcomment); print ''; + print ''; + if ($propname != 'rowid') { + print ''.img_delete().''; + print ' '; + print ''.img_edit().''; + } + print ''; - print dol_escape_htmltag($propnotnull); - print ''; - print dol_escape_htmltag($propdefault); - print ''; - print $propindex ? '1' : ''; - print ''; - print $propforeignkey ? dol_escape_htmltag($propforeignkey) : ''; - print ''; - print dol_escape_htmltag($propposition); - print ''; - print $propenabled ? dol_escape_htmltag($propenabled) : ''; - print ''; - print $propvisible ? dol_escape_htmltag($propvisible) : '0'; - print ''; - print $propnoteditable ? dol_escape_htmltag($propnoteditable) : ''; - print ''; - print $propsearchall ? '1' : ''; - print ''; - print $propisameasure ? dol_escape_htmltag($propisameasure) : ''; - print ''; - print $propcss ? dol_escape_htmltag($propcss) : ''; - print ''; - print $propcssview ? dol_escape_htmltag($propcssview) : ''; - print ''; - print $propcsslist ? dol_escape_htmltag($propcsslist) : ''; - print ''; - print $prophelp ? dol_escape_htmltag($prophelp) : ''; - print ''; - print $propshowoncombobox ? dol_escape_htmltag($propshowoncombobox) : ''; - print ''; - print $propdisabled?$propdisabled:''; - print ''; - print ''; - print dol_escape_htmltag($propcomment); - print ''; - print ''; - if ($propname != 'rowid') { - print ''.img_delete().''; - } - print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; - $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); - print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; - print ''; + if ($val['enabled']==1) { + $setupnotempty++; + print '
    '; + $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); + print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; + print ''; if ($val['type'] == 'textarea') { print ''; + + /*print '
    '.$langs->trans("or").'
    '; print '
    '; - print 'Scan a product lot or serial number
    '; print '     Qty
    '; - + */ print '
    '; + print '
    '; + print '
    '; + print ''.$langs->trans("FeatureNotYetAvailable").''; // TODO Add javascript so each scan will add qty into the inventory page + an ajax save. + print '
    '; print ''; + print ''; } From 725c6be7db1e591ec638c64070a92d6ccadb3ad8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 12:13:02 +0200 Subject: [PATCH 587/618] CSS --- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index dc9fa7b6047..4cf7bc0de34 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -987,7 +987,7 @@ div.div-for-modal { div.div-for-modal-topright { /* display: none; */ - position:absolute; + position: fixed; top: 0; right: 0; width:50%; /* adjust as per your needs */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index c5cd7da18c7..e807ae62234 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1072,7 +1072,7 @@ div.div-for-modal { div.div-for-modal-topright { /* display: none; */ - position:absolute; + position: fixed; top: 0; right: 0; width:50%; /* adjust as per your needs */ From 445309bef2b4076ebca49fe6ff54c2d076c89235 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 12:25:45 +0200 Subject: [PATCH 588/618] Clean code --- htdocs/modulebuilder/index.html | 0 htdocs/modulebuilder/index.php | 11 +++++------ 2 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 htdocs/modulebuilder/index.html diff --git a/htdocs/modulebuilder/index.html b/htdocs/modulebuilder/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 8918250fc67..572fff42369 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2755,9 +2755,9 @@ if ($module == 'initmodule') { print '
    '; print ''; print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; @@ -2825,9 +2825,8 @@ if ($module == 'initmodule') { print ''; if ($propname != 'rowid') { - print ''.img_delete().''; - print ' '; - print ''.img_edit().''; + print ''.img_edit().''; + print ''.img_delete().''; } print ''.$langs->trans("QtyShipped").''.$langs->trans("QtyToShip"); if (empty($conf->productbatch->enabled)) { - print '
    '.$langs->trans("Fill").''; + print '
    '.img_picto($langs->trans("Autofill"), 'autofill', 'class="paddingrightonly"').$langs->trans("Fill").''; print ' / '; } else { print '
    '; diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 809b4803ff5..cba2e14cf74 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -65,6 +65,7 @@ if (!empty($user->socid)) { $result = restrictedArea($user, 'commande', $id); $object = new Commande($db); +$shipment = new Expedition($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels @@ -77,7 +78,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'expedition', $object->id, ''); + +$result = restrictedArea($user, 'expedition', 0, ''); // We use 0 for id, because there is no particular shipment on this tab, only id of order is known @@ -94,13 +96,11 @@ if ($reshook < 0) { if (empty($reshook)) { // Categorisation dans projet if ($action == 'classin') { - $object = new Commande($db); $object->fetch($id); $object->setProject(GETPOST('projectid', 'int')); } if ($action == 'confirm_cloture' && GETPOST('confirm', 'alpha') == 'yes') { - $object = new Commande($db); $object->fetch($id); $result = $object->cloture($user); } elseif ($action == 'setref_client' && $user->rights->commande->creer) { @@ -132,7 +132,6 @@ if (empty($reshook)) { } */ if ($action == 'setmode' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) { @@ -141,7 +140,6 @@ if (empty($reshook)) { } if ($action == 'setavailability' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->availability(GETPOST('availability_id')); if ($result < 0) { @@ -150,7 +148,6 @@ if (empty($reshook)) { } if ($action == 'setdemandreason' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->demand_reason(GETPOST('demand_reason_id')); if ($result < 0) { @@ -159,7 +156,6 @@ if (empty($reshook)) { } if ($action == 'setconditions' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) { @@ -175,7 +171,6 @@ if (empty($reshook)) { // shipping method if ($action == 'setshippingmethod' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); if ($result < 0) { @@ -185,7 +180,6 @@ if (empty($reshook)) { // warehouse if ($action == 'setwarehouse' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); if ($result < 0) { diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index b3f01b00cf7..eb238941eae 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -254,4 +254,4 @@ ReOpen=Reopen ConfirmFinish=Do you confirm the closing of the inventory ? This will generate all stock movements to update your stock. ObjectNotFound=%s not found MakeMovementsAndClose=Generate movements and close -AutofillWithExpected=Auto-fill expected quantity with real quantity \ No newline at end of file +AutofillWithExpected=Fill real quantity with expected quantity \ No newline at end of file diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index cb3231389b4..bc927a06c50 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -448,23 +448,25 @@ if ($object->id > 0) { print ''.$langs->trans('UpdateByScaningLot').''; }*/ if (!empty($conf->barcode->enabled) || !empty($conf->productbatch->enabled)) { - print ''.$langs->trans("UpdateByScaning").''; + print ''.img_picto('', 'barcode', 'class="paddingrightonly"').$langs->trans("UpdateByScaning").''; } } else { - print ''.$langs->trans("Save").''."\n"; + print ''.$langs->trans("Save").''."\n"; } if ($permissiontoadd && $conf->use_javascript_ajax) { - print ' '; - print ''; + print ''.img_picto('', 'autofill', 'class="paddingrightonly"').$langs->trans('AutofillWithExpected').''; + print ''; } print '
    '; From 4025488e08f34fa9a9c3fa30d7a40ce25ece95d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 13:19:57 +0200 Subject: [PATCH 592/618] css --- htdocs/bookmarks/bookmarks.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 950cce19420..199944165b4 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -67,7 +67,7 @@ function printDropdownBookmarksList() // Url to list bookmark $listbtn = ''; - $listbtn .= ''.$langs->trans('Bookmarks').''; + $listbtn .= img_picto('', 'bookmark', 'class="paddingright"').$langs->trans('Bookmarks').''; // Url to go on create new bookmark page $newbtn = ''; @@ -75,7 +75,7 @@ function printDropdownBookmarksList() //$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&urlsource='.urlencode($url).'&url='.urlencode($url); $urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&url='.urlencode($url); $newbtn .= ''; - $newbtn .= img_picto('', 'bookmark', '', false, 0, 0, '', 'paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).''; + $newbtn .= img_picto('', 'add', '', false, 0, 0, '', 'paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).''; } // Menu with list of bookmarks From fe7654c06789667000c5169fe0799a704a6e1a10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 13:34:19 +0200 Subject: [PATCH 593/618] Complete doc --- htdocs/comm/action/class/actioncomm.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 1e506526a1d..e105d011e96 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -82,16 +82,19 @@ class ActionComm extends CommonObject /** * @var int Id into parent table llx_c_actioncomm (used only if option to use type is set) + * This field is stored info fk_action. It contains the id into table llx_ac_actioncomm. */ public $type_id; /** * @var string Calendar of event (Type of type of event). 'system'=Default calendar, 'systemauto'=Auto calendar, 'birthdate', 'holiday', 'module'=Calendar specific to a module + * This field contains the type into table llx_ac_actioncomm ('system', 'systemauto', ...). It should be named 'type_type'. */ public $type; /** * @var string Code into parent table llx_c_actioncomm (used only if option to use type is set). With default setup, should be AC_OTH_AUTO or AC_OTH. + * This field contains the code into table llx_ac_actioncomm. */ public $type_code; @@ -112,6 +115,7 @@ class ActionComm extends CommonObject /** * @var string Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...) + * This field is stored into field 'code' into llx_actioncomm. */ public $code; From 4016c300d27f88244dea32561f7196a18a600c3a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 13:38:29 +0200 Subject: [PATCH 594/618] Fix missing lin to thirdparty on some actions --- .../core/triggers/interface_50_modAgenda_ActionsAuto.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index fdd18638053..7f7cd5a77be 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -942,6 +942,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $societeforaction->fetch($object->socid); } elseif (isset($object->fk_soc) && $object->fk_soc > 0) { $societeforaction->fetch($object->fk_soc); + } elseif (isset($object->thirdparty) && isset($object->thirdparty->id) && $object->thirdparty->id > 0) { + $societeforaction = $object->thirdparty; } $projectid = isset($object->fk_project) ? $object->fk_project : 0; From 7f91713c4a93fe41421b8752223de2eb073d53ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 14:06:30 +0200 Subject: [PATCH 595/618] Fix merge not complete --- htdocs/comm/index.php | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 54d9453971d..17f1f20718f 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -809,7 +809,6 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { } -<<<<<<< HEAD /* * Opened (validated) order */ @@ -822,14 +821,6 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; -======= - $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.fk_statut, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; - $sql .= ", s.code_client"; - $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande as c"; ->>>>>>> branch '12.0' of git@github.com:Dolibarr/dolibarr.git if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")"; $sql .= " AND c.fk_soc = s.rowid"; @@ -862,18 +853,11 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $orderstatic->id = $obj->commandeid; $orderstatic->ref = $obj->ref; -<<<<<<< HEAD $orderstatic->ref_client = $obj->ref_client; + $orderstatic->statut = $obj->fk_statut; $orderstatic->total_ht = $obj->total_ht; $orderstatic->total_tva = $obj->total_tva; $orderstatic->total_ttc = $obj->total_ttc; -======= - $orderstatic->statut = $obj->fk_statut; - $orderstatic->ref_client = $obj->ref_client; - $orderstatic->total_ht = $obj->total_ht; - $orderstatic->total_tva = $obj->total_tva; - $orderstatic->total_ttc = $obj->total_ttc; ->>>>>>> branch '12.0' of git@github.com:Dolibarr/dolibarr.git $companystatic->id = $obj->socid; $companystatic->name = $obj->name; From 4d243ae0729d3b805d0c69bddb5fae7247508285 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 9 Apr 2021 14:56:52 +0200 Subject: [PATCH 596/618] Update llx_10_c_regions.sql Italy Spain --- .../install/mysql/data/llx_10_c_regions.sql | 86 ++++++++++--------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 2feb15e8436..6c25826c4ca 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -65,6 +65,8 @@ -- France -- Germany -> for Departmements -- Greece +-- Italy +-- Spain @@ -194,50 +196,50 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (10 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10213, NULL, NULL, 'Δυτική Μακεδονία'); --- Regions Italy (id country=3) -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 301, NULL, 1, 'Abruzzo'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 302, NULL, 1, 'Basilicata'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 303, NULL, 1, 'Calabria'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 304, NULL, 1, 'Campania'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 305, NULL, 1, 'Emilia-Romagna'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 306, NULL, 1, 'Friuli-Venezia Giulia'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 307, NULL, 1, 'Lazio'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 308, NULL, 1, 'Liguria'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 309, NULL, 1, 'Lombardia'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 310, NULL, 1, 'Marche'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 311, NULL, 1, 'Molise'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 312, NULL, 1, 'Piemonte'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 313, NULL, 1, 'Puglia'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 314, NULL, 1, 'Sardegna'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 315, NULL, 1, 'Sicilia'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 316, NULL, 1, 'Toscana'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 317, NULL, 1, 'Trentino-Alto Adige'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 318, NULL, 1, 'Umbria'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 319, NULL, 1, 'Valle d Aosta'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 320, NULL, 1, 'Veneto'); +-- Italy Regions (id country=3) +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 301, NULL, 1, 'Abruzzo'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 302, NULL, 1, 'Basilicata'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 303, NULL, 1, 'Calabria'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 304, NULL, 1, 'Campania'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 305, NULL, 1, 'Emilia-Romagna'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 306, NULL, 1, 'Friuli-Venezia Giulia'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 307, NULL, 1, 'Lazio'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 308, NULL, 1, 'Liguria'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 309, NULL, 1, 'Lombardia'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 310, NULL, 1, 'Marche'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 311, NULL, 1, 'Molise'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 312, NULL, 1, 'Piemonte'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 313, NULL, 1, 'Puglia'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 314, NULL, 1, 'Sardegna'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 315, NULL, 1, 'Sicilia'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 316, NULL, 1, 'Toscana'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 317, NULL, 1, 'Trentino-Alto Adige'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 318, NULL, 1, 'Umbria'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 319, NULL, 1, 'Valle d Aosta'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 320, NULL, 1, 'Veneto'); --- Regions Spain (id country=4) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 401, '', 0, 'Andalucia', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 402, '', 0, 'Aragón', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 403, '', 0, 'Castilla y León', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 404, '', 0, 'Castilla la Mancha', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 405, '', 0, 'Canarias', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 406, '', 0, 'Cataluña', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 407, '', 0, 'Comunidad de Ceuta', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 408, '', 0, 'Comunidad Foral de Navarra', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 409, '', 0, 'Comunidad de Melilla', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 410, '', 0, 'Cantabria', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 411, '', 0, 'Comunidad Valenciana', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 412, '', 0, 'Extemadura', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 413, '', 0, 'Galicia', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 414, '', 0, 'Islas Baleares', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 415, '', 0, 'La Rioja', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 416, '', 0, 'Comunidad de Madrid', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 417, '', 0, 'Región de Murcia', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 418, '', 0, 'Principado de Asturias', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 419, '', 0, 'Pais Vasco', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 420, '', 0, 'Otros', 1); +--Spain Regions (id country=4) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 401, '', 0, 'Andalucia'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 402, '', 0, 'Aragón'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 403, '', 0, 'Castilla y León'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 404, '', 0, 'Castilla la Mancha'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 405, '', 0, 'Canarias'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 406, '', 0, 'Cataluña'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 407, '', 0, 'Comunidad de Ceuta'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 408, '', 0, 'Comunidad Foral de Navarra'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 409, '', 0, 'Comunidad de Melilla'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 410, '', 0, 'Cantabria'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 411, '', 0, 'Comunidad Valenciana'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 412, '', 0, 'Extemadura'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 413, '', 0, 'Galicia'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 414, '', 0, 'Islas Baleares'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 415, '', 0, 'La Rioja'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 416, '', 0, 'Comunidad de Madrid'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 417, '', 0, 'Región de Murcia'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 418, '', 0, 'Principado de Asturias'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 419, '', 0, 'Pais Vasco'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 420, '', 0, 'Otros'); -- Regions Switzerland (id country=6) From cf83963e5f36c86df2667fb3bd675bd093992b90 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 9 Apr 2021 15:07:32 +0200 Subject: [PATCH 597/618] Update llx_20_c_departements.sql Netherlands/Nederland --- .../mysql/data/llx_20_c_departements.sql | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 9675fa126c8..445a970b3f9 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -52,6 +52,7 @@ -- Honduras -- (Italy) -- Luxembourg +-- Netherlands @@ -631,6 +632,21 @@ INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14003, 'LU0012', '', 0, '', 'Mersch'); +-- Netherlands/Nederland Provinces (id country=17) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'GR', NULL, NULL, NULL, 'Groningen'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'FR', NULL, NULL, NULL, 'Friesland'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'DR', NULL, NULL, NULL, 'Drenthe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'OV', NULL, NULL, NULL, 'Overijssel'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'GD', NULL, NULL, NULL, 'Gelderland'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'FL', NULL, NULL, NULL, 'Flevoland'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'UT', NULL, NULL, NULL, 'Utrecht'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'NH', NULL, NULL, NULL, 'Noord-Holland'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'ZH', NULL, NULL, NULL, 'Zuid-Holland'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'ZL', NULL, NULL, NULL, 'Zeeland'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'NB', NULL, NULL, NULL, 'Noord-Brabant'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'LB', NULL, NULL, NULL, 'Limburg'); + + -- Provinces Maroc - Moroco (id country=12) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA', 1209, '', 0, '', 'Province de Benslimane', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA1', 1209, '', 0, '', 'Province de Berrechid', 1); @@ -1186,21 +1202,6 @@ insert into llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc insert into llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) values ('WY', 1101, '', 0, 'WYOMING', 'Wyoming', 1); --- Provincies van het Koninkrijk der Nederlanden (id country=17) -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('GR',1701,NULL,NULL,NULL,'Groningen'); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('FR',1701,NULL,NULL,NULL,'Friesland'); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('DR',1701,NULL,NULL,NULL,'Drenthe'); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('OV',1701,NULL,NULL,NULL,'Overijssel'); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('GD',1701,NULL,NULL,NULL,'Gelderland'); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('FL',1701,NULL,NULL,NULL,'Flevoland'); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('UT',1701,NULL,NULL,NULL,'Utrecht'); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('NH',1701,NULL,NULL,NULL,'Noord-Holland'); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('ZH',1701,NULL,NULL,NULL,'Zuid-Holland'); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('ZL',1701,NULL,NULL,NULL,'Zeeland'); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('NB',1701,NULL,NULL,NULL,'Noord-Brabant'); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom) VALUES ('LB',1701,NULL,NULL,NULL,'Limburg'); - - -- San Salvador (id country=86) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SS', 8601, '', 0, '', 'San Salvador', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SA', 8603, '', 0, '', 'Santa Ana', 1); From 19ee78e123958e0dcdde25961d1841aa4be1f2d1 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 9 Apr 2021 15:44:47 +0200 Subject: [PATCH 598/618] Close #17193 : Move button convert in webp --- htdocs/core/tpl/filemanager.tpl.php | 42 +++++++++++++++++++++++++++++ htdocs/langs/en_US/ecm.lang | 4 +++ htdocs/website/index.php | 37 +------------------------ 3 files changed, 47 insertions(+), 36 deletions(-) diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index 6ff7bba2390..bfd10e25424 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -86,6 +86,9 @@ if ($module == 'ecm') { print ''; print ''; } +if ($permtoadd) { + print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("GenerateImgWebp")).'">'; +} // Start "Add new file" area $nameforformuserfile = 'formuserfileecm'; @@ -133,6 +136,45 @@ if ($action == 'delete_section') { } // End confirm +if ($action == 'confirmconvertimgwebp') { + print $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmImgWebpCreation'), $langs->trans('ConfirmGenerateImgWebp', $object->ref), 'convertimgwebp', '', "yes", 1); + $action = 'file_manager'; +} + +if ($action == 'convertimgwebp' && $permtoadd) { + if ($module == 'medias') { + $imagefolder = $conf->website->dir_output.'/'.$websitekey.'/medias/image/'.$websitekey.'/'; + } else { + $imagefolder = $conf->ecm->dir_output; + } + + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; + + $regeximgext = getListOfPossibleImageExt(); + + $filelist = dol_dir_list($imagefolder, "all", 1, $regeximgext); + + foreach ($filelist as $filename) { + $filepath = $filename['fullname']; + if (!(substr_compare($filepath, 'webp', -strlen('webp')) === 0)) { + if (image_format_supported($filepath) == 1) { + $filepathnoext = preg_replace("/\..*/", "", $filepath); + $result = dol_imageResizeOrCrop($filepath, 0, 0, 0, 0, 0, $filepathnoext.'.webp'); + if (!dol_is_file($result)) { + $error++; + setEventMessages($result, null, 'errors'); + } + } + } + if ($error) { + break; + } + } + if (!$error) { + setEventMessages($langs->trans('SucessConvertImgWebp'), null); + } + $action = 'file_manager'; +} if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'delete') { $langs->load("ecm"); diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index 71df60734fb..2bac434deb0 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -41,3 +41,7 @@ FileNotYetIndexedInDatabase=File not yet indexed into database (try to re-upload ExtraFieldsEcmFiles=Extrafields Ecm Files ExtraFieldsEcmDirectories=Extrafields Ecm Directories ECMSetup=ECM Setup +GenerateImgWebp=Convert all images into webp +ConfirmGenerateImgWebp=If you confirm, you will generate all images in this folder and subfolder in webp format... +ConfirmImgWebpCreation=Confirm all images convertion +SucessConvertImgWebp=Images successfully converted diff --git a/htdocs/website/index.php b/htdocs/website/index.php index b7609878196..60e4b514e01 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2275,36 +2275,6 @@ if ($action == 'generatesitemaps' && $usercanedit) { $action = 'preview'; } -$imagefolder = $conf->website->dir_output.'/'.$websitekey.'/medias/image/'.$websitekey.'/'; - -if ($action == 'convertimgwebp' && $usercanedit) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - - $regeximgext = getListOfPossibleImageExt(); - - $filelist = dol_dir_list($imagefolder, "all", 1, $regeximgext); - - foreach ($filelist as $filename) { - $filepath = $filename['fullname']; - if (!(substr_compare($filepath, 'webp', -strlen('webp')) === 0)) { - if (image_format_supported($filepath) == 1) { - $filepathnoext = preg_replace("/\..*/", "", $filepath); - $result = dol_imageResizeOrCrop($filepath, 0, 0, 0, 0, 0, $filepathnoext.'.webp'); - if (!dol_is_file($result)) { - $error++; - setEventMessages($result, null, 'errors'); - } - } - } - if ($error) { - break; - } - } - if (!$error) { - setEventMessages($langs->trans('SucessConvertImgWebp'), null); - } - $action = 'preview'; -} /* * View @@ -2320,10 +2290,6 @@ if ($action == 'confirmgeneratesitemaps') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref), 'generatesitemaps', '', "yes", 1); $action = 'preview'; } -if ($action == 'confirmconvertimgwebp') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmImgWebpCreation'), $langs->trans('ConfirmGenerateImgWebp', $object->ref), 'convertimgwebp', '', "yes", 1); - $action = 'preview'; -} $helpurl = 'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website'; $arrayofjs = array( @@ -2542,7 +2508,6 @@ if (!GETPOST('hide_websitemenu')) { // Generate site map print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("GenerateSitemaps")).'">'; - print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("GenerateImgWebp")).'">'; print '   '; print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("ReplaceWebsiteContent")).'">'; @@ -3882,7 +3847,7 @@ if ($action == 'preview') { print $formconfirm; } -if ($action == 'editfile' || $action == 'file_manager') { +if ($action == 'editfile' || $action == 'file_manager' || $action == 'convertimgwebp' || $action == 'confirmconvertimgwebp') { print ''."\n"; print '

    '; //print '
    '.$langs->trans("FeatureNotYetAvailable").''; From 937fe333f1a7745df43c872a9b6954968a0ee397 Mon Sep 17 00:00:00 2001 From: Ahmad Hadeed Date: Fri, 9 Apr 2021 20:49:39 +0300 Subject: [PATCH 599/618] Moving Friday to end of function declaration to maintain backward compatibility --- htdocs/core/lib/date.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 2d4bb04abb3..74953305de7 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -672,7 +672,7 @@ function getGMTEasterDatetime($year) * @return int|string Number of non working days or error message string if error * @see num_between_day(), num_open_day() */ -function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $lastday = 0, $includefriday = -1, $includesaturday = -1, $includesunday = -1) +function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $lastday = 0, $includesaturday = -1, $includesunday = -1, $includefriday = -1) { global $db, $conf, $mysoc; @@ -687,7 +687,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $country_code = $mysoc->country_code; } if ($includefriday < 0) { - $includefriday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY : 0); + $includefriday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY : 0); } if ($includesaturday < 0) { $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1); From 20e51016eda824257ed18e69d14015ea03d570ed Mon Sep 17 00:00:00 2001 From: Ahmad Hadeed Date: Fri, 9 Apr 2021 21:11:37 +0300 Subject: [PATCH 600/618] fixing function description comment to satisfy 'stickler-ci' --- htdocs/core/lib/date.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 74953305de7..63a6f83da4a 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -666,10 +666,10 @@ function getGMTEasterDatetime($year) * @param int $timestampEnd Timestamp end (UTC with hour, min, sec = 0) * @param string $country_code Country code * @param int $lastday Last day is included, 0: no, 1:yes - * @param int $includefriday Include friday as non working day (-1=use setup, 0=no, 1=yes) + * @param int $includefriday Include friday as non working day (-1=use setup, 0=no, 1=yes) * @param int $includesaturday Include saturday as non working day (-1=use setup, 0=no, 1=yes) * @param int $includesunday Include sunday as non working day (-1=use setup, 0=no, 1=yes) - * @return int|string Number of non working days or error message string if error + * @return int|string Number of non working days or error message string if error * @see num_between_day(), num_open_day() */ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $lastday = 0, $includesaturday = -1, $includesunday = -1, $includefriday = -1) @@ -693,7 +693,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1); } if ($includesunday < 0) { - $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1); + $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1); } $country_id = dol_getIdFromCode($db, $country_code, 'c_country', 'code', 'rowid'); From 63f7369adb04c03bd14d4e39419a150d4fc62e9b Mon Sep 17 00:00:00 2001 From: Ahmad Hadeed Date: Fri, 9 Apr 2021 21:16:24 +0300 Subject: [PATCH 601/618] Fixing 'stickler-ci' complaint, function description not in order --- htdocs/core/lib/date.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 63a6f83da4a..aa7476cd321 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -666,9 +666,9 @@ function getGMTEasterDatetime($year) * @param int $timestampEnd Timestamp end (UTC with hour, min, sec = 0) * @param string $country_code Country code * @param int $lastday Last day is included, 0: no, 1:yes - * @param int $includefriday Include friday as non working day (-1=use setup, 0=no, 1=yes) * @param int $includesaturday Include saturday as non working day (-1=use setup, 0=no, 1=yes) * @param int $includesunday Include sunday as non working day (-1=use setup, 0=no, 1=yes) + * @param int $includefriday Include friday as non working day (-1=use setup, 0=no, 1=yes) * @return int|string Number of non working days or error message string if error * @see num_between_day(), num_open_day() */ From d269e8da15a0e678c4f18061888ad2e51c30f966 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 9 Apr 2021 20:55:28 +0200 Subject: [PATCH 602/618] Update llx_c_socialnetworks.sql --- .../mysql/data/llx_c_socialnetworks.sql | 75 ++++++++++--------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_socialnetworks.sql b/htdocs/install/mysql/data/llx_c_socialnetworks.sql index 829cbbf0294..5bfbcf090d9 100644 --- a/htdocs/install/mysql/data/llx_c_socialnetworks.sql +++ b/htdocs/install/mysql/data/llx_c_socialnetworks.sql @@ -1,4 +1,11 @@ +-- Copyright (C) Year(-Year) Author Name -- +-- eldy +-- frederic34 +-- dolibit-ut +-- + +-- License -- 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 @@ -10,46 +17,46 @@ -- 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 . +-- along with this program. If not, see . -- -- --- +-- Note -- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors -- de l'install et tous les sigles '--' sont supprimés. -- -- socialnetworks -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'facebook', 'Facebook', 'https://www.facebook.com/{socialid}', 'fa-facebook', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'skype', 'Skype', 'https://www.skype.com/{socialid}', 'fa-skype', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'twitter', 'Twitter', 'https://www.twitter.com/{socialid}', 'fa-twitter', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'linkedin', 'LinkedIn', 'https://www.linkedin.com/{socialid}', 'fa-linkedin', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'snapchat', 'Snapchat', '{socialid}', 'fa-snapchat', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus-g', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'tumblr', 'Tumblr', 'https://www.tumblr.com/{socialid}', 'fa-tumblr', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'vero', 'Vero', 'https://vero.co/{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'viadeo', 'Viadeo', 'https://fr.viadeo.com/fr/{socialid}', 'fa-viadeo', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'slack', 'Slack', '{socialid}', 'fa-slack', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'xing', 'Xing', '{socialid}', 'fa-xing', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'meetup', 'Meetup', '{socialid}', 'fa-meetup', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'pinterest', 'Pinterest', '{socialid}', 'fa-pinterest', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'flickr', 'Flickr', '{socialid}', 'fa-flickr', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, '500px', '500px', '{socialid}', 'fa-500px', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'giphy', 'Giphy', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'gifycat', 'Gificat', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'dailymotion', 'Dailymotion', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'vimeo', 'Vimeo', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'periscope', 'Periscope', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'twitch', 'Twitch', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'discord', 'Discord', '{socialid}', 'fa-discord', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'wikipedia', 'Wikipedia', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'reddit', 'Reddit', '{socialid}', 'fa-reddit', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'quora', 'Quora', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'tripadvisor', 'Tripadvisor', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'mastodon', 'Mastodon', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'diaspora', 'Diaspora', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'viber', 'Viber', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, '500px', '500px', '{socialid}', 'fa-500px', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'dailymotion', 'Dailymotion', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'diaspora', 'Diaspora', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'discord', 'Discord', '{socialid}', 'fa-discord', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'facebook', 'Facebook', 'https://www.facebook.com/{socialid}', 'fa-facebook', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'flickr', 'Flickr', '{socialid}', 'fa-flickr', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'gifycat', 'Gificat', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'giphy', 'Giphy', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus-g', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'linkedin', 'LinkedIn', 'https://www.linkedin.com/{socialid}', 'fa-linkedin', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'mastodon', 'Mastodon', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'meetup', 'Meetup', '{socialid}', 'fa-meetup', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'periscope', 'Periscope', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'pinterest', 'Pinterest', '{socialid}', 'fa-pinterest', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'quora', 'Quora', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'reddit', 'Reddit', '{socialid}', 'fa-reddit', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'slack', 'Slack', '{socialid}', 'fa-slack', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'snapchat', 'Snapchat', '{socialid}', 'fa-snapchat', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'skype', 'Skype', 'https://www.skype.com/{socialid}', 'fa-skype', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'tripadvisor', 'Tripadvisor', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'tumblr', 'Tumblr', 'https://www.tumblr.com/{socialid}', 'fa-tumblr', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'twitch', 'Twitch', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'twitter', 'Twitter', 'https://www.twitter.com/{socialid}', 'fa-twitter', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'vero', 'Vero', 'https://vero.co/{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'viadeo', 'Viadeo', 'https://fr.viadeo.com/fr/{socialid}', 'fa-viadeo', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'viber', 'Viber', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'vimeo', 'Vimeo', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'wikipedia', 'Wikipedia', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'xing', 'Xing', '{socialid}', 'fa-xing', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); From 52213d0ac71fe688d910ed022e964cff60766376 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Apr 2021 21:15:43 +0200 Subject: [PATCH 603/618] Fix duplicate permissions --- htdocs/core/menus/init_menu_auguria.sql | 8 ++++---- htdocs/core/menus/standard/eldy.lib.php | 8 ++++---- htdocs/core/modules/modHRM.class.php | 3 ++- htdocs/user/class/api_users.class.php | 3 +-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 27eed001188..2d77f7a285b 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -19,7 +19,7 @@ insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, left insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('comptabilite|accounting|asset', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->asset->enabled', 9__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=accountancy', 'MenuAccountancy', -1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->mouvements->lire || $user->rights->asset->read', '', 2, 54, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '', '', 2, 90, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('adherent', '$conf->adherent->enabled', 13__+MAX_llx_menu__, __HANDLER__, 'top', 'members', '', 0, '/adherents/index.php?mainmenu=members&leftmenu=', 'Members', -1, 'members', '$user->rights->adherent->lire', '', 2, 19, __ENTITY__); -insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm|holiday|deplacement|expensereport', '$conf->hrm->enabled || $conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/hrm/index.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->hrm->employee->read || $user->rights->holiday->write || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__); +insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm|holiday|deplacement|expensereport', '$conf->hrm->enabled || $conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/hrm/index.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->user->user->lire || $user->rights->holiday->read || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__); -- Home - Dashboard insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 90__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/index.php', 'MyDashboard', 0, '', '', '', 2, 0, __ENTITY__); @@ -411,9 +411,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->adherent->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 5200__+MAX_llx_menu__, 'members', 'cat', 13__+MAX_llx_menu__, '/categories/index.php?mainmenu=members&leftmenu=cat&type=3', 'MembersCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->adherent->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 5201__+MAX_llx_menu__, 'members', '', 5200__+MAX_llx_menu__, '/categories/card.php?mainmenu=members&action=create&type=3', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- HRM - Employee -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee', 'Employees', 0, 'hrm', '$user->rights->hrm->employee->read', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4601__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/card.php?mainmenu=hrm&action=create&employee=1', 'NewEmployee', 1, 'hrm', '$user->rights->hrm->employee->write', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->hrm->employee->read', '', 0, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee', 'Employees', 0, 'hrm', '$user->rights->user->user->lire', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4601__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/card.php?mainmenu=hrm&action=create&employee=1', 'NewEmployee', 1, 'hrm', '$user->rights->user->user->creer', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->user->user->lire', '', 0, 2, __ENTITY__); -- HRM - Holiday insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?mainmenu=hrm&action=create', 'MenuAddCP', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 31d4baa38f1..ed835a3d4c0 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -361,7 +361,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // HRM $tmpentry = array( 'enabled'=>(!empty($conf->hrm->enabled) || (!empty($conf->holiday->enabled)) || !empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled) || !empty($conf->recruitment->enabled)), - 'perms'=>(!empty($user->rights->hrm->employee->read) || !empty($user->rights->holiday->write) || !empty($user->rights->deplacement->lire) || !empty($user->rights->expensereport->lire) || !empty($user->rights->recruitment->recruitmentjobposition->read)), + 'perms'=>(!empty($user->rights->user->user->lire) || !empty($user->rights->holiday->read) || !empty($user->rights->deplacement->lire) || !empty($user->rights->expensereport->lire) || !empty($user->rights->recruitment->recruitmentjobposition->read)), 'module'=>'hrm|holiday|deplacement|expensereport|recruitment' ); @@ -1741,9 +1741,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM if (!empty($conf->hrm->enabled)) { $langs->load("hrm"); - $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm'); - $newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->rights->hrm->employee->write); - $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1, $user->rights->hrm->employee->read); + $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->user->user->lire, '', $mainmenu, 'hrm'); + $newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->rights->user->user->creer); + $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1, $user->rights->user->user->lire); } // Leave/Holiday/Vacation module diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index ad36253fe22..759c8b7d284 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -89,6 +89,7 @@ class modHRM extends DolibarrModules $this->rights = array(); // Permission array used by this module $r = 0; + /* $this->rights[$r][0] = 4001; $this->rights[$r][1] = 'See employees'; $this->rights[$r][3] = 0; @@ -116,7 +117,7 @@ class modHRM extends DolibarrModules $this->rights[$r][4] = 'employee'; $this->rights[$r][5] = 'export'; $r++; - + */ // Menus //------- diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index d50fec76353..571bca3eb39 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -621,8 +621,7 @@ class Users extends DolibarrApi 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))); + $canreadsalary = ((!empty($conf->salaries->enabled) && !empty(DolibarrApiAccess::$user->rights->salaries->read)) || (empty($conf->salaries->enabled))); if (!$canreadsalary) { unset($object->salary); From 0c343f1f0fdd3d12376a2271619a8018af1b6803 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 9 Apr 2021 21:18:42 +0200 Subject: [PATCH 604/618] Update llx_c_type_contact.sql --- .../install/mysql/data/llx_c_type_contact.sql | 134 ++++++++++-------- 1 file changed, 76 insertions(+), 58 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_type_contact.sql b/htdocs/install/mysql/data/llx_c_type_contact.sql index 78fdade6e9a..31135710e86 100644 --- a/htdocs/install/mysql/data/llx_c_type_contact.sql +++ b/htdocs/install/mysql/data/llx_c_type_contact.sql @@ -5,7 +5,10 @@ -- Copyright (C) 2004 Guillaume Delecourt -- Copyright (C) 2005-2009 Regis Houssin -- Copyright (C) 2007 Patrick Raguin +-- Copyright (C) 2021 Udo Tamm -- + +-- -- 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 @@ -21,84 +24,99 @@ -- -- +-- Notes +-- +-- Do not place a comment at the end of the line, this file is parsed when +-- of the install and all the acronyms '-' are removed. -- -- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors -- de l'install et tous les sigles '--' sont supprimés. -- -- +-- The types of contact of an element -- Les types de contact d'un element -- -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (10, 'contrat', 'internal', 'SALESREPSIGN', 'Commercial signataire du contrat', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (11, 'contrat', 'internal', 'SALESREPFOLL', 'Commercial suivi du contrat', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (20, 'contrat', 'external', 'BILLING', 'Contact client facturation contrat', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (21, 'contrat', 'external', 'CUSTOMER', 'Contact client suivi contrat', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (22, 'contrat', 'external', 'SALESREPSIGN', 'Contact client signataire contrat', 1); - -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (31, 'propal', 'internal', 'SALESREPFOLL', 'Commercial à l''origine de la propale', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (40, 'propal', 'external', 'BILLING', 'Contact client facturation propale', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (41, 'propal', 'external', 'CUSTOMER', 'Contact client suivi propale', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (42, 'propal', 'external', 'SHIPPING', 'Contact client livraison propale', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (50, 'facture', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (60, 'facture', 'external', 'BILLING', 'Contact client facturation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (61, 'facture', 'external', 'SHIPPING', 'Contact client livraison', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (62, 'facture', 'external', 'SERVICE', 'Contact client prestation', 1); +-- Contract / Contrat +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (10, 'contrat', 'internal', 'SALESREPSIGN', 'Commercial signataire du contrat', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (11, 'contrat', 'internal', 'SALESREPFOLL', 'Commercial suivi du contrat', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (20, 'contrat', 'external', 'BILLING', 'Contact client facturation contrat', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (21, 'contrat', 'external', 'CUSTOMER', 'Contact client suivi contrat', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (22, 'contrat', 'external', 'SALESREPSIGN', 'Contact client signataire contrat', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (70, 'invoice_supplier', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (71, 'invoice_supplier', 'external', 'BILLING', 'Contact fournisseur facturation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (72, 'invoice_supplier', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (73, 'invoice_supplier', 'external', 'SERVICE', 'Contact fournisseur prestation', 1); +-- Proposal / Propal +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (31, 'propal', 'internal', 'SALESREPFOLL', 'Commercial à l''origine de la propale', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (40, 'propal', 'external', 'BILLING', 'Contact client facturation propale', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (41, 'propal', 'external', 'CUSTOMER', 'Contact client suivi propale', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (42, 'propal', 'external', 'SHIPPING', 'Contact client livraison propale', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (80, 'agenda', 'internal', 'ACTOR', 'Responsable', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (81, 'agenda', 'internal', 'GUEST', 'Guest', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (85, 'agenda', 'external', 'ACTOR', 'Responsable', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (86, 'agenda', 'external', 'GUEST', 'Guest', 1); +-- Customer Invoice / Facture +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (50, 'facture', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (60, 'facture', 'external', 'BILLING', 'Contact client facturation', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (61, 'facture', 'external', 'SHIPPING', 'Contact client livraison', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (62, 'facture', 'external', 'SERVICE', 'Contact client prestation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (91, 'commande','internal', 'SALESREPFOLL', 'Responsable suivi de la commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (100,'commande','external', 'BILLING', 'Contact client facturation commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (101,'commande','external', 'CUSTOMER', 'Contact client suivi commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (102,'commande','external', 'SHIPPING', 'Contact client livraison commande', 1); +-- Supplier Invoice +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (70, 'invoice_supplier', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (71, 'invoice_supplier', 'external', 'BILLING', 'Contact fournisseur facturation', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (72, 'invoice_supplier', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (73, 'invoice_supplier', 'external', 'SERVICE', 'Contact fournisseur prestation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (120, 'fichinter','internal', 'INTERREPFOLL', 'Responsable suivi de l''intervention', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (121, 'fichinter','internal', 'INTERVENING', 'Intervenant', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (130, 'fichinter','external', 'BILLING', 'Contact client facturation intervention', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (131, 'fichinter','external', 'CUSTOMER', 'Contact client suivi de l''intervention', 1); +-- Agenda +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (80, 'agenda', 'internal', 'ACTOR', 'Responsable', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (81, 'agenda', 'internal', 'GUEST', 'Guest', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (85, 'agenda', 'external', 'ACTOR', 'Responsable', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (86, 'agenda', 'external', 'GUEST', 'Guest', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (140, 'order_supplier','internal', 'SALESREPFOLL', 'Responsable suivi de la commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (141, 'order_supplier','internal', 'SHIPPING', 'Responsable réception de la commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (142, 'order_supplier','external', 'BILLING', 'Contact fournisseur facturation commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (143, 'order_supplier','external', 'CUSTOMER', 'Contact fournisseur suivi commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (145, 'order_supplier','external', 'SHIPPING', 'Contact fournisseur livraison commande', 1); +-- Customer Order / Commande +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (91, 'commande', 'internal', 'SALESREPFOLL', 'Responsable suivi de la commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (100,'commande', 'external', 'BILLING', 'Contact client facturation commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (101,'commande', 'external', 'CUSTOMER', 'Contact client suivi commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (102,'commande', 'external', 'SHIPPING', 'Contact client livraison commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (150, 'dolresource','internal', 'USERINCHARGE', 'In charge of resource', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (151, 'dolresource','external', 'THIRDINCHARGE', 'In charge of resource', 1); +-- Intervention / Fichinter +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (120, 'fichinter', 'internal', 'INTERREPFOLL', 'Responsable suivi de l''intervention', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (121, 'fichinter', 'internal', 'INTERVENING', 'Intervenant', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (130, 'fichinter', 'external', 'BILLING', 'Contact client facturation intervention', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (131, 'fichinter', 'external', 'CUSTOMER', 'Contact client suivi de l''intervention', 1); --- All project code can start with 'PROJECT' -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (160, 'project', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (161, 'project', 'internal', 'PROJECTCONTRIBUTOR', 'Intervenant', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (170, 'project', 'external', 'PROJECTLEADER', 'Chef de Projet', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (171, 'project', 'external', 'PROJECTCONTRIBUTOR', 'Intervenant', 1); +-- Supplier Order +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (140, 'order_supplier', 'internal', 'SALESREPFOLL', 'Responsable suivi de la commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (141, 'order_supplier', 'internal', 'SHIPPING', 'Responsable réception de la commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (142, 'order_supplier', 'external', 'BILLING', 'Contact fournisseur facturation commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (143, 'order_supplier', 'external', 'CUSTOMER', 'Contact fournisseur suivi commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (145, 'order_supplier', 'external', 'SHIPPING', 'Contact fournisseur livraison commande', 1); --- All task code can start with 'TASK' -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (180, 'project_task', 'internal', 'TASKEXECUTIVE', 'Responsable', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (181, 'project_task', 'internal', 'TASKCONTRIBUTOR', 'Intervenant', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (190, 'project_task', 'external', 'TASKEXECUTIVE', 'Responsable', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (191, 'project_task', 'external', 'TASKCONTRIBUTOR', 'Intervenant', 1); +-- Resource +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (150, 'dolresource', 'internal', 'USERINCHARGE', 'In charge of resource', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (151, 'dolresource', 'external', 'THIRDINCHARGE', 'In charge of resource', 1); -- Tickets -INSERT INTO llx_c_type_contact (rowid, element, source, code, libelle, active, module) VALUES(155, 'ticket', 'internal', 'SUPPORTTEC', 'Utilisateur contact support', 1, NULL); -INSERT INTO llx_c_type_contact (rowid, element, source, code, libelle, active, module) VALUES(156, 'ticket', 'internal', 'CONTRIBUTOR', 'Intervenant', 1, NULL); -INSERT INTO llx_c_type_contact (rowid, element, source, code, libelle, active, module) VALUES(157, 'ticket', 'external', 'SUPPORTCLI', 'Contact client suivi incident', 1, NULL); -INSERT INTO llx_c_type_contact (rowid, element, source, code, libelle, active, module) VALUES(158, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1, NULL); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active, module) values (155, 'ticket', 'internal', 'SUPPORTTEC', 'Utilisateur contact support', 1, NULL); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active, module) values (156, 'ticket', 'internal', 'CONTRIBUTOR', 'Intervenant', 1, NULL); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active, module) values (157, 'ticket', 'external', 'SUPPORTCLI', 'Contact client suivi incident', 1, NULL); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active, module) values (158, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1, NULL); + +-- Projects / Projet - All project code can start with 'PROJECT' +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (160, 'project', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (161, 'project', 'internal', 'PROJECTCONTRIBUTOR', 'Intervenant', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (170, 'project', 'external', 'PROJECTLEADER', 'Chef de Projet', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (171, 'project', 'external', 'PROJECTCONTRIBUTOR', 'Intervenant', 1); + +-- Project Tasks - All task code can start with 'TASK' +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (180, 'project_task', 'internal', 'TASKEXECUTIVE', 'Responsable', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (181, 'project_task', 'internal', 'TASKCONTRIBUTOR', 'Intervenant', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (190, 'project_task', 'external', 'TASKEXECUTIVE', 'Responsable', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (191, 'project_task', 'external', 'TASKCONTRIBUTOR', 'Intervenant', 1); -- Supplier proposal -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110, 'supplier_proposal', 'internal', 'SALESREPFOLL', 'Responsable suivi de la demande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (111, 'supplier_proposal', 'external', 'BILLING', 'Contact fournisseur facturation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (112, 'supplier_proposal', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (113, 'supplier_proposal', 'external', 'SERVICE', 'Contact fournisseur prestation', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (110, 'supplier_proposal', 'internal', 'SALESREPFOLL', 'Responsable suivi de la demande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (111, 'supplier_proposal', 'external', 'BILLING', 'Contact fournisseur facturation', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (112, 'supplier_proposal', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (113, 'supplier_proposal', 'external', 'SERVICE', 'Contact fournisseur prestation', 1); -- Event Organization -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (210, 'conferenceorbooth', 'internal', 'MANAGER', 'Conference or Booth manager', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (211, 'conferenceorbooth', 'external', 'SPEAKER', 'Conference Speaker', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (212, 'conferenceorbooth', 'external', 'RESPONSIBLE', 'Booth responsible', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (210, 'conferenceorbooth', 'internal', 'MANAGER', 'Conference or Booth manager', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (211, 'conferenceorbooth', 'external', 'SPEAKER', 'Conference Speaker', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (212, 'conferenceorbooth', 'external', 'RESPONSIBLE', 'Booth responsible', 1); From 0cf659eb8588378d2595881460b1c67e60400dc9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Apr 2021 00:26:28 +0200 Subject: [PATCH 605/618] Fix syntax error --- htdocs/product/class/api_products.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index a572d0946c4..6b26421d0f8 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -808,7 +808,7 @@ class Products extends DolibarrApi $sql .= ' WHERE t.entity IN ('.getEntity('product').')'; if ($supplier > 0) { - $sql .= " AND s.fk_soc = "((int) $supplier); + $sql .= " AND s.fk_soc = ".((int) $supplier); } if ($socid > 0) { // if external user $sql .= " AND s.fk_soc = ".((int) $socid); From 280d534b7ad0f11a2e5dd6c55ae6424bf68429ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Apr 2021 00:29:32 +0200 Subject: [PATCH 606/618] Fix phpcs --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 94f1210041a..5f88a1a3f1e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2708,7 +2708,7 @@ class CommandeFournisseur extends CommonOrder if ($qty < $this->line->packaging) { $qty = $this->line->packaging; } else { - if (! empty($this->line->packaging) && ($qty % $this->line->packaging) > 0) { + if (! empty($this->line->packaging) && ($qty % $this->line->packaging) > 0) { $coeff = intval($qty / $this->line->packaging) + 1; $qty = $this->line->packaging * $coeff; setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); From 83e272951fb3e265c71af3ef0d9c7fe1c4d73eca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Apr 2021 00:31:20 +0200 Subject: [PATCH 607/618] Fix phpcs --- htdocs/core/lib/website2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 675c691c624..6510d5fff8d 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -108,7 +108,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) $dirname = dirname($filealias); $filename = basename($filealias); foreach (explode(',', $object->otherlang) as $sublang) { - // Avoid to erase main alias file if $sublang is empty string + // Avoid to erase main alias file if $sublang is empty string if (empty(trim($sublang))) continue; $filealiassub = $dirname.'/'.$sublang.'/'.$filename; From eadd8defaf9a4a94cc9d47648c5bc8e8eca70829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20de=20la=20Cal=20Bretschneider?= Date: Sat, 10 Apr 2021 11:22:32 +0200 Subject: [PATCH 608/618] Good friday is a holiday --- htdocs/core/lib/date.lib.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index ecf1cf999de..64a8e67b999 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -775,6 +775,21 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', //print 'annee='.$annee.' $jour='.$jour.' $mois='.$mois.' $jour_lundi_paques='.$jour_lundi_paques.' $mois_lundi_paques='.$mois_lundi_paques."\n"; } + //Good Friday + if (in_array('goodfriday', $specialdayrule)) { + // Pulls the date of Easter + $easter = getGMTEasterDatetime($annee); + + // Calculates the date of Good Friday based on Easter + $date_good_friday = $easter - (2 * 3600 * 24); + $dom_good_friday = gmdate("d", $date_good_friday); + $month_good_friday = gmdate("m", $date_good_friday); + + if ($dom_good_friday == $jour && $month_good_friday == $mois) { + $ferie = true; + } + } + if (in_array('ascension', $specialdayrule)) { // Calcul du jour de l'ascension (39 days after easter day) $date_paques = getGMTEasterDatetime($annee); From c86b100477ba5601c6e25fb624a688337218c7b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Apr 2021 12:34:30 +0200 Subject: [PATCH 609/618] Update llx_c_type_contact.sql --- htdocs/install/mysql/data/llx_c_type_contact.sql | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_type_contact.sql b/htdocs/install/mysql/data/llx_c_type_contact.sql index 31135710e86..825e21ddf42 100644 --- a/htdocs/install/mysql/data/llx_c_type_contact.sql +++ b/htdocs/install/mysql/data/llx_c_type_contact.sql @@ -7,8 +7,6 @@ -- Copyright (C) 2007 Patrick Raguin -- Copyright (C) 2021 Udo Tamm -- - --- -- 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 @@ -21,9 +19,8 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . --- --- +-- -- Notes -- -- Do not place a comment at the end of the line, this file is parsed when From ce6f8eebf5a7ae513d5bb6fc1b38a868655641b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Apr 2021 12:42:43 +0200 Subject: [PATCH 610/618] Close #17206 Add comment on type of constants --- htdocs/core/lib/admin.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 3088db079e3..e2f93b1152b 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -571,7 +571,7 @@ function dolibarr_get_const($db, $name, $entity = 1) * @param DoliDB $db Database handler * @param string $name Name of constant * @param string $value Value of constant - * @param string $type Type of constant ('chaine by default) + * @param string $type Type of constant. Deprecated, only strings are allowed for $value. Caller must json encode/decode to store other type of data. * @param int $visible Is constant visible in Setup->Other page (0 by default) * @param string $note Note on parameter * @param int $entity Multi company id (0 means all entities) From 6241ba559bd3c4e19ce7892ad6d980929504d8d6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Apr 2021 12:44:41 +0200 Subject: [PATCH 611/618] Trans --- htdocs/core/lib/admin.lib.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index e2f93b1152b..ed01d9d6e9f 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -534,24 +534,23 @@ function dolibarr_del_const($db, $name, $entity = 1) } /** - * Recupere une constante depuis la base de donnees. + * Get the value of a setup constant from database * * @param DoliDB $db Database handler - * @param string $name Nom de la constante + * @param string $name Name of constant * @param int $entity Multi company id - * @return string Valeur de la constante + * @return string Value of constant * * @see dolibarr_del_const(), dolibarr_set_const(), dol_set_user_param() */ function dolibarr_get_const($db, $name, $entity = 1) { - global $conf; $value = ''; $sql = "SELECT ".$db->decrypt('value')." as value"; $sql .= " FROM ".MAIN_DB_PREFIX."const"; $sql .= " WHERE name = ".$db->encrypt($name, 1); - $sql .= " AND entity = ".$entity; + $sql .= " AND entity = ".((int) $entity); dol_syslog("admin.lib::dolibarr_get_const", LOG_DEBUG); $resql = $db->query($sql); @@ -599,7 +598,7 @@ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0, $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; $sql .= " WHERE name = ".$db->encrypt($name, 1); if ($entity >= 0) { - $sql .= " AND entity = ".$entity; + $sql .= " AND entity = ".((int) $entity); } dol_syslog("admin.lib::dolibarr_set_const", LOG_DEBUG); @@ -610,7 +609,7 @@ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0, $sql .= " VALUES ("; $sql .= $db->encrypt($name, 1); $sql .= ", ".$db->encrypt($value, 1); - $sql .= ",'".$db->escape($type)."',".$visible.",'".$db->escape($note)."',".$entity.")"; + $sql .= ",'".$db->escape($type)."',".((int) $visible).",'".$db->escape($note)."',".((int) $entity).")"; //print "sql".$value."-".pg_escape_string($value)."-".$sql;exit; //print "xx".$db->escape($value); From 260f39a4d296646ba7161f3604f0e191d0650067 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 10 Apr 2021 13:18:57 +0200 Subject: [PATCH 612/618] Update llx_10_c_regions.sql Switzerland/Suisse San Salvador Netherlands United Kingdom --- .../install/mysql/data/llx_10_c_regions.sql | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 6c25826c4ca..0c6e5bd9be8 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -66,7 +66,11 @@ -- Germany -> for Departmements -- Greece -- Italy +-- Netherlands -> for Departmements +-- San Salvador -- Spain +-- Switzerland/Suisse -> for Departmements/Cantons +-- United Kingdom @@ -219,7 +223,17 @@ insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3 insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 320, NULL, 1, 'Veneto'); ---Spain Regions (id country=4) +-- Netherlands Regions (id country=17) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 17, 1701, '', 0,'Provincies van Nederland '); + + +-- San Salvador Regions (id country=86) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (86, 8601, NULL, NULL, 'Central'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (86, 8602, NULL, NULL, 'Oriental'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (86, 8603, NULL, NULL, 'Occidental'); + + +-- Spain Regions (id country=4) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 401, '', 0, 'Andalucia'); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 402, '', 0, 'Aragón'); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 403, '', 0, 'Castilla y León'); @@ -242,14 +256,16 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 420, '', 0, 'Otros'); --- Regions Switzerland (id country=6) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 6, 601, '', 1, 'Cantons', 1); +-- Switzerland Regions (id country=6) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 6, 601, '', 1, 'Cantons'); + + +-- UK United Kingdom Regions (id_country=7) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 7, 701, '', 0, 'England'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 7, 702, '', 0, 'Wales'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 7, 703, '', 0, 'Scotland'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 7, 704, '', 0, 'Northern Ireland'); --- Regions UK United Kingdom (id_country=7) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 7, 701, '', 0, 'England', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 7, 702, '', 0, 'Wales', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 7, 703, '', 0, 'Scotland', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 7, 704, '', 0, 'Northern Ireland', 1); -- Regions Tunisia (id country=10) insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (10,1001, '',0,'Ariana'); @@ -277,25 +293,19 @@ insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (10,102 insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (10,1023, '',0,'Tunis'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (10,1024, '',0,'Zaghouan'); + -- Region USA (id country=11) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 11, 1101, '', 0, 'United-States', 1); --- Regions The Netherlands (id country=17) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 17, 1701, '', 0,'Provincies van Nederland ', 1); - - --- Regions San Salvador (id country=86) -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 8601, 86, NULL, NULL, 'Central', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 8602, 86, NULL, NULL, 'Oriental', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 8603, 86, NULL, NULL, 'Occidental', 1); - -- Regions Honduras (id country=114) insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 114, 11401, '', 0, 'Honduras', 1); + -- Regions India (id country=117) insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 117, 11701, '', 0, 'India', 1); + -- Regions Indonesia (id country=118) insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 118, 11801, '', 0, 'Indonesia', 1); From 95a5296d45f5715c93550604960fe08c773cb361 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Apr 2021 13:29:24 +0200 Subject: [PATCH 613/618] NEW Can hide columns "time consumed" on timesheet per week. --- htdocs/core/lib/project.lib.php | 40 +++++++-------- htdocs/projet/activity/perday.php | 10 +--- htdocs/projet/activity/permonth.php | 10 +--- htdocs/projet/activity/perweek.php | 76 ++++++++++++++++------------- htdocs/theme/md/style.css.php | 4 +- 5 files changed, 68 insertions(+), 72 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index abdb098eb7d..8037c6b2f70 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1903,27 +1903,29 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ 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 "'; + // $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 "'; - $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); - if ($tmptimespent['total_duration']) { - print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); - } else { - print '--:--'; + // Time spent by user + print ''; + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); + if ($tmptimespent['total_duration']) { + print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); + } else { + print '--:--'; + } + print "'.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
    '; -print ''; -print 'Photo'; -print ''.$langs->trans("Everybody").''; -print ''; -print '
    '.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
    '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').'
    '.$langs->trans("TimeSpent").'
    '; + print ''; + print 'Photo'; + print ''.$langs->trans("Everybody").''; + print ''; + print '
    '.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
    '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').'
    '; print $langs->trans("OtherFilteredTasks"); print '
    '; - print $langs->trans("Total"); - print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; - print '
    '; + print $langs->trans("Total"); + print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; + print '
     
     
     
    '.$langs->trans("NoAssignedTasks").'
    '; - // $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 "'; + // $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 "'; - $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); - if ($tmptimespent['total_duration']) { - print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); - } else { - print '--:--'; + // Time spent by user + print ''; + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); + if ($tmptimespent['total_duration']) { + print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); + } else { + 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) { - print ''; - print convertSecondToTime($lines[$i]->duration, 'allhourmin'); - print ''; - } else { - 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) { + print ''; + print convertSecondToTime($lines[$i]->duration, 'allhourmin'); + print ''; + } else { + print '--:--'; + } + print "'; - $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); - if ($tmptimespent['total_duration']) { - print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); - } else { - print '--:--'; + // Time spent by user + print ''; + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); + if ($tmptimespent['total_duration']) { + print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); + } else { + print '--:--'; + } + print "'.$langs->trans("PlannedWorkload").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
    '; -print ''; -print 'Photo'; -print ''.$langs->trans("Everybody").''; -print ''; -print '
    '.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
    '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').'
    '.$langs->trans("TimeSpent").'
    '; + print ''; + print 'Photo'; + print ''.$langs->trans("Everybody").''; + print ''; + print '
    '.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
    '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').'
    '.$langs->trans("HourStart").''; // By default, we can edit only tasks we are assigned to @@ -658,13 +655,17 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print "
    '; print $langs->trans("Total"); print ''; //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print ''; print $langs->trans("OtherFilteredTasks"); print ''; $timeonothertasks = ($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); @@ -745,6 +750,10 @@ if (count($tasksarray) > 0) { print ''; print $langs->trans("Total"); print ''; //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print ''.$langs->trans("PlannedWorkload").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
    '; -print ''; -print 'Photo'; -print ''.$langs->trans("Everybody").''; -print ''; -print '
    '.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
    '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').'
    '.$langs->trans("TimeSpent").'
    '; + print ''; + print 'Photo'; + print ''.$langs->trans("Everybody").''; + print ''; + print '
    '.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
    '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').'
    '; print $langs->trans("OtherFilteredTasks"); print '
    '; - print $langs->trans("Total"); - print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; - print '
    '; + print $langs->trans("Total"); + print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; + print '
     
     
     
    '.$langs->trans("NoAssignedTasks").'
    '.$langs->trans("NewSubscription"); print ''; - print $form->selectarray("typeid", $adht->liste_array(1), $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.$source.'&ref='.$ref.'&amount='.$amount.'&typeid=\' + this.value + \'&securekey='.$SECUREKEY.'\');"', 0, 0, 0, '', '', 1); + print $form->selectarray("typeid", $adht->liste_array(1), $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.urlencode($source).'&ref='.urlencode($ref).'&amount='.urlencode($amount).'&typeid=\' + this.value + \'&securekey='.urlencode($SECUREKEY).'\');"', 0, 0, 0, '', '', 1); print "
    '.$langs->trans("NewMemberType"); diff --git a/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php b/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php index 2be1fea7756..a7bfe03aac4 100644 --- a/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php +++ b/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php @@ -127,8 +127,8 @@ function getPublicJobPositionUrl($mode, $ref = '', $localorexternal = 0) $out = $urltouse.'/public/recruitment/view.php?ref='.($mode ? '' : '').$ref.($mode ? '' : ''); /*if (!empty($conf->global->RECRUITMENT_SECURITY_TOKEN)) { - if (empty($conf->global->RECRUITMENT_SECURITY_TOKEN)) $out .= '&securekey='.$conf->global->RECRUITMENT_SECURITY_TOKEN; - else $out .= '&securekey='.dol_hash($conf->global->RECRUITMENT_SECURITY_TOKEN, 2); + if (empty($conf->global->RECRUITMENT_SECURITY_TOKEN)) $out .= '&securekey='.urlencode($conf->global->RECRUITMENT_SECURITY_TOKEN); + else $out .= '&securekey='.urlencode(dol_hash($conf->global->RECRUITMENT_SECURITY_TOKEN, 2)); }*/ // For multicompany