From c43515f4847f54bf362474337de93a51d67db8b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20Llu=C3=ADs?= Date: Fri, 15 Sep 2017 17:11:03 +0200 Subject: [PATCH 001/179] Fix: Custom info view in services In services view, custom info should be hide. Also, Nature field is moved and grouped with product fields --- htdocs/product/card.php | 76 ++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 54afc80691f..6449ded2f93 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1,20 +1,21 @@ - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2015 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2006 Auguria SARL - * Copyright (C) 2010-2015 Juanjo Menent - * Copyright (C) 2013-2016 Marcos García - * Copyright (C) 2012-2013 Cédric Salvador - * Copyright (C) 2011-2017 Alexandre Spangaro - * Copyright (C) 2014 Cédric Gross - * Copyright (C) 2014-2015 Ferran Marcet - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2016 Meziane Sof + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005-2015 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2006 Auguria SARL + * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2013-2016 Marcos García + * Copyright (C) 2012-2013 Cédric Salvador + * Copyright (C) 2011-2017 Alexandre Spangaro + * Copyright (C) 2014 Cédric Gross + * Copyright (C) 2014-2015 Ferran Marcet + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2016 Meziane Sof + * Copyright (C) 2017 Josep Lluís Amador * * 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 @@ -1004,15 +1005,6 @@ else print ''; } - // Nature - if ($type != 1) - { - print ''.$langs->trans("Nature").''; - $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - print $form->selectarray('finished',$statutarray,GETPOST('finished'),1); - print ''; - } - // Duration if ($type == 1) { @@ -1025,8 +1017,14 @@ else print ''; } - if ($type != 1) // Le poids et le volume ne concerne que les produits et pas les services + if ($type != 1) // Nature, Weight and volume only applies to products and not to services { + // Nature + print ''.$langs->trans("Nature").''; + $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); + print $form->selectarray('finished',$statutarray,GETPOST('finished'),1); + print ''; + // Weight print ''.$langs->trans("Weight").''; print ''; @@ -1318,15 +1316,6 @@ else print ''; }*/ - // Nature - if($object->type!= Product::TYPE_SERVICE) - { - print ''.$langs->trans("Nature").''; - $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - print $form->selectarray('finished',$statutarray,$object->finished); - print ''; - } - if ($object->isService()) { // Duration @@ -1346,6 +1335,11 @@ else } else { + // Nature + print ''.$langs->trans("Nature").''; + $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); + print $form->selectarray('finished',$statutarray,$object->finished); + print ''; // Weight print ''.$langs->trans("Weight").''; print ' '; @@ -1659,14 +1653,6 @@ else print '
'; print ''; - // Nature - if($object->type!= Product::TYPE_SERVICE) - { - print ''; - } - if ($object->isService()) { // Duration @@ -1685,6 +1671,10 @@ else } else { + // Nature + print ''; // Weight print ''; From 1ab5eece6b7e79ab5b03c7c214b4dfb715693a5b Mon Sep 17 00:00:00 2001 From: jean Date: Tue, 22 May 2018 09:40:49 +0200 Subject: [PATCH 002/179] Adding code to show update date of supplier price shown --- htdocs/fourn/class/fournisseur.product.class.php | 4 ++-- htdocs/langs/en_US/suppliers.lang | 1 + htdocs/langs/fr_FR/suppliers.lang | 1 + htdocs/product/fournisseurs.php | 6 ++++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index b9a2f72b9bd..dc04139232c 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -526,7 +526,7 @@ class ProductFournisseur extends Product $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_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.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, pfp.tms as date_modification "; $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; @@ -568,7 +568,7 @@ class ProductFournisseur extends Product $prodfourn->fourn_tva_npr = $record["info_bits"]; $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; $prodfourn->supplier_reputation = $record["supplier_reputation"]; - + $prodfourn->date_modification = $this->db->jdate($record["date_modification"]); $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"]; $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"]; diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index d0cf540d3eb..0e6ffe8a6cd 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -45,3 +45,4 @@ BuyerName=Buyer name AllProductServicePrices=All product / service prices AllProductReferencesOfSupplier=All product / service references of supplier BuyingPriceNumShort=Vendor prices +PriceUpdate=Updated on \ No newline at end of file diff --git a/htdocs/langs/fr_FR/suppliers.lang b/htdocs/langs/fr_FR/suppliers.lang index 2f9b93ff323..0aad31d294c 100644 --- a/htdocs/langs/fr_FR/suppliers.lang +++ b/htdocs/langs/fr_FR/suppliers.lang @@ -45,3 +45,4 @@ BuyerName=Nom de l'acheteur AllProductServicePrices=Tous les prix du produits / service AllProductReferencesOfSupplier=Toutes les références des produits/services du fournisseur BuyingPriceNumShort=Prix fournisseurs +PriceUpdate=Mis à jour le \ No newline at end of file diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 21439a1ac8a..70776a989df 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -754,6 +754,7 @@ SCRIPT; print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); } print_liste_field_titre("DiscountQtyMin",$_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre("PriceUpdate",$_SERVER["PHP_SELF"],"pfp.date_modification","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("NbDaysToDelivery",$_SERVER["PHP_SELF"],"pfp.delivery_time_days","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("ReputationForThisProduct",$_SERVER["PHP_SELF"],"pfp.supplier_reputation","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); @@ -828,6 +829,11 @@ SCRIPT; print price2num($productfourn->fourn_remise_percent).'%'; print ''; + // Date + print ''; + // Delivery delay print ''; // Delivery delay From f51b89def32d90b2284f2adb0a623bffc1c78104 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 20 Feb 2019 16:14:24 +0100 Subject: [PATCH 004/179] NEW supplier buyprice barcode --- htdocs/core/class/html.form.class.php | 11 ++++- .../fourn/class/fournisseur.product.class.php | 24 ++++++++-- .../install/mysql/migration/8.0.0-9.0.0.sql | 7 ++- .../llx_product_fournisseur_price.key.sql | 5 +++ .../tables/llx_product_fournisseur_price.sql | 2 + htdocs/langs/fr_FR/companies.lang | 1 + htdocs/product/fournisseurs.php | 45 +++++++++++++++++-- htdocs/product/list.php | 1 + 8 files changed, 87 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e41bcf2b5e4..c6e22a3b3a1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2636,6 +2636,7 @@ class Form $sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,"; $sql.= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; $sql.= " pfp.supplier_reputation"; + if (! empty($conf->barcode->enabled)) $sql.= " ,pfp.barcode"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; if ($socid) $sql.= " AND pfp.fk_soc = ".$socid; @@ -2660,7 +2661,11 @@ class Form $i++; } if (count($scrit) > 1) $sql.=")"; - if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + if (! empty($conf->barcode->enabled)){ + $sql.= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + $sql.= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + + } $sql.=')'; } $sql.= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; @@ -2780,6 +2785,10 @@ class Form $opt .= " - ".dol_trunc($objp->name, 8); $outval.=" - ".dol_trunc($objp->name, 8); } + if (! empty($conf->barcode->enabled) && !empty($objp->barcode)){ + $opt .= " - ".$objp->barcode; + $outval.=" - ".$objp->barcode; + } if ($objp->supplier_reputation) { //TODO dictionary diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 731695d8d27..1a1ebecf0f5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -229,7 +229,7 @@ class ProductFournisseur extends Product * @param string $desc_fourn Custom description for product_fourn_price * @return int <0 if KO, >=0 if OK */ - 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 = '') + 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; @@ -350,7 +350,9 @@ class ProductFournisseur extends Product $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.= " 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)."'"); $sql.= " WHERE rowid = ".$this->product_fourn_price_id; // TODO Add price_base_type and price_ttc @@ -400,7 +402,7 @@ class ProductFournisseur extends Product // 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)"; + $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)"; $sql .= " values("; $sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').","; $sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').","; @@ -426,6 +428,8 @@ class ProductFournisseur extends Product $sql .= $conf->entity . ","; $sql .= $delivery_time_days . ","; $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) . "'"); $sql .= ")"; $idinserted = 0; @@ -490,6 +494,7 @@ class ProductFournisseur extends Product $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"; + if($conf->barcode->enabled) $sql.=" ,pfp.barcode, pfp.fk_barcode_type"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.rowid = ".$rowid; @@ -529,7 +534,10 @@ class ProductFournisseur extends Product $this->fourn_multicurrency_tx = $obj->multicurrency_tx; $this->fourn_multicurrency_id = $obj->fk_multicurrency; $this->fourn_multicurrency_code = $obj->multicurrency_code; - + if($conf->barcode->enabled) { + $this->fourn_barcode = $obj->barcode; + $this->fourn_fk_barcode_type = $obj->fk_barcode_type; + } if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) { $priceparser = new PriceParser($this->db); @@ -583,6 +591,9 @@ class ProductFournisseur extends Product $sql.= " pfp.rowid as product_fourn_pri_id, 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"; + if($conf->barcode->enabled){ + $sql.= " ,pfp.barcode, pfp.fk_barcode_type"; + } $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; $sql.= " AND pfp.fk_soc = s.rowid"; @@ -632,6 +643,11 @@ class ProductFournisseur extends Product $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; + if($conf->barcode->enabled){ + $prodfourn->barcode = $record["barcode"]; + $prodfourn->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); diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 575573c41c9..e7054be51fd 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -279,4 +279,9 @@ ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account; ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); - +ALTER TABLE llx_product_fournisseur_price ADD COLUMN barcode varchar(180) DEFAULT NULL; +ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_barcode_type integer DEFAULT NULL; +ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_barcode (barcode); +ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fk_barcode_type (fk_barcode_type); +ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_barcode (barcode, fk_barcode_type, entity); +ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid); diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql index 110736718d1..67817733255 100644 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql @@ -31,3 +31,8 @@ ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_p ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_soc (fk_soc, entity); ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); + +ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_barcode (barcode); +ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fk_barcode_type (fk_barcode_type); +ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_barcode (barcode, fk_barcode_type, entity); +ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid); diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql index 940967b13d4..af5aa743db2 100755 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql @@ -37,6 +37,8 @@ create table llx_product_fournisseur_price unitprice double(24,8) DEFAULT 0, -- unit price without tax charges double(24,8) DEFAULT 0, -- to store transport cost. Constant PRODUCT_CHARGES must be set to see it. default_vat_code varchar(10), + barcode varchar(180) DEFAULT NULL, -- barcode + fk_barcode_type integer DEFAULT NULL, -- barcode type tva_tx double(6,3) NOT NULL, localtax1_tx double(6,3) DEFAULT 0, localtax1_type varchar(10) NOT NULL DEFAULT '0', diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 7a423b0b007..f88f418e8d3 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -103,6 +103,7 @@ WrongSupplierCode=Code fournisseur incorrect CustomerCodeModel=Modèle de code client SupplierCodeModel=Modèle de code fournisseur Gencod=Code-barres +GencodBuyPrice=Code-barres lié au prix d'achat ##### Professional ID ##### ProfId1Short=Id. prof. 1 ProfId2Short=Id. prof. 2 diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index c0e4c7fabb2..0be06145886 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_expression.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - +if(!empty($conf->barcode->enabled)) dol_include_once('/core/class/html.formbarcode.class.php'); // Load translation files required by the page $langs->loadLangs(array('products', 'suppliers', 'bills', 'margins')); @@ -158,6 +158,8 @@ if (empty($reshook)) $delivery_time_days = GETPOST('delivery_time_days', 'int') ? GETPOST('delivery_time_days', 'int') : ''; $supplier_reputation = GETPOST('supplier_reputation'); $supplier_description = GETPOST('supplier_description', 'alpha'); + $barcode=GETPOST('barcode', 'alpha'); + $fk_barcode_type=GETPOST('fk_barcode_type', 'int'); if ($tva_tx == '') { @@ -258,9 +260,9 @@ if (empty($reshook)) $multicurrency_price = price2num(GETPOST("multicurrency_price", 'alpha')); $multicurrency_code = GETPOST("multicurrency_code", 'alpha'); - $ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $multicurrency_price, $_POST["multicurrency_price_base_type"], $multicurrency_tx, $multicurrency_code, $supplier_description); + $ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $multicurrency_price, $_POST["multicurrency_price_base_type"], $multicurrency_tx, $multicurrency_code, $supplier_description, $barcode, $fk_barcode_type); } else { - $ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description); + $ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description, $barcode, $fk_barcode_type); } if ($ret < 0) { @@ -666,8 +668,24 @@ SCRIPT; print ''; + if(!empty($conf->barcode->enabled)) { // Option to define a transport cost on supplier price + print ''; + print ''; + print ''; + print ''; + $formbarcode = new FormBarCode($db); + + // Barcode type + print ''; + print ''; + print ''; + print ''; + } + // Option to define a transport cost on supplier price if ($conf->global->PRODUCT_CHARGES) { if (! empty($conf->margin->enabled)) @@ -780,6 +798,10 @@ SCRIPT; print_liste_field_titre("DiscountQtyMin", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center '); + if($conf->barcode->enabled) { + print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, 'align="center"', $sortfield, $sortorder); + } print_liste_field_titre(''); print "\n"; @@ -871,6 +893,23 @@ SCRIPT; } print''; + if($conf->barcode->enabled) { + // Barcode + print ''; + + + + // Barcode type + print ''; + } + if (is_object($hookmanager)) { $parameters=array('id_pfp'=>$productfourn->product_fourn_price_id,'id_fourn'=>$id_fourn,'prod_id'=>$object->id); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index b37a0d31df9..a938c8e5e7f 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -142,6 +142,7 @@ if (! empty($conf->global->MAIN_MULTILANGS)) } if (! empty($conf->barcode->enabled)) { $fieldstosearchall['p.barcode']='Gencod'; + $fieldstosearchall['pfp.barcode']='GencodBuyPrice'; } if (empty($conf->global->PRODUIT_MULTIPRICES)) From 394659f84a30fa3ebc08387898a2eff4320f4584 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 20 Feb 2019 17:00:07 +0100 Subject: [PATCH 005/179] missing doc --- htdocs/fourn/class/fournisseur.product.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 1a1ebecf0f5..cc31bbdb4d5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -227,6 +227,8 @@ class ProductFournisseur extends Product * @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 */ 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='') From f1055d0e5cc6fe91f15104df9f2c94d571797240 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 20 Feb 2019 17:09:54 +0100 Subject: [PATCH 006/179] make select2 focus to earn time during scanning --- htdocs/fourn/commande/card.php | 8 ++++++++ htdocs/fourn/facture/card.php | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 644ebd79347..e951bfa3813 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2769,6 +2769,14 @@ elseif (! empty($object->id)) } } +?> + +close(); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 70407661d52..69ca7f85a14 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3234,6 +3234,13 @@ else } } +?> + +close(); From 95593bfaadfe27db4886ab442d12d8bb763d4192 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 21 Feb 2019 09:34:05 +0100 Subject: [PATCH 007/179] fix scan barcode only one time instead of 2 (when it was focus we need to open and then write) --- htdocs/fourn/commande/card.php | 7 ++++++- htdocs/fourn/facture/card.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index e951bfa3813..2aa0b3a3460 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2772,7 +2772,12 @@ elseif (! empty($object->id)) ?> Date: Thu, 21 Feb 2019 09:35:52 +0100 Subject: [PATCH 008/179] FIX blank space travis --- htdocs/core/class/html.form.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c6e22a3b3a1..a24cb0cab40 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2664,7 +2664,6 @@ class Form if (! empty($conf->barcode->enabled)){ $sql.= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; $sql.= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; - } $sql.=')'; } From cb3a4ac94c5cbd1582b0d234f9428a07a0a4fb9c Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 21 Feb 2019 09:47:00 +0100 Subject: [PATCH 009/179] missing 1st char --- htdocs/fourn/commande/card.php | 4 +++- htdocs/fourn/facture/card.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 2aa0b3a3460..99ce83fef1a 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2771,10 +2771,12 @@ elseif (! empty($object->id)) ?> + '; echo ''; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 99ce83fef1a..229d31c35a5 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2769,20 +2769,7 @@ elseif (! empty($object->id)) } } -?> - - - -close(); From e39f85ac4d3e7a33f381aafa55ed4fe282adf63c Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 21 Feb 2019 15:51:45 +0100 Subject: [PATCH 011/179] FIX js focusing --- htdocs/core/tpl/objectline_create.tpl.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 8b24d555a9a..446e81f4bae 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -280,11 +280,13 @@ else { From 1b9a2e5cfc638ac6c16a6c7ddcbfebc9a8794101 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 27 Feb 2019 09:27:15 +0100 Subject: [PATCH 012/179] FIX migration 9 to 10 --- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 6 ------ htdocs/install/mysql/migration/9.0.0-10.0.0.sql | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index e7054be51fd..df370e0f54f 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -279,9 +279,3 @@ ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account; ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); -ALTER TABLE llx_product_fournisseur_price ADD COLUMN barcode varchar(180) DEFAULT NULL; -ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_barcode_type integer DEFAULT NULL; -ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_barcode (barcode); -ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fk_barcode_type (fk_barcode_type); -ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_barcode (barcode, fk_barcode_type, entity); -ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid); diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index fe7cdb9faf6..3d6d995eebd 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -229,3 +229,10 @@ ALTER TABLE llx_bom_bom ADD INDEX idx_bom_bom_fk_product (fk_product); ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_rowid (rowid); ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_product (fk_product); ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_bom (fk_bom); + +ALTER TABLE llx_product_fournisseur_price ADD COLUMN barcode varchar(180) DEFAULT NULL; +ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_barcode_type integer DEFAULT NULL; +ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_barcode (barcode); +ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fk_barcode_type (fk_barcode_type); +ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_barcode (barcode, fk_barcode_type, entity); +ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid); From 9b797eb98097efe248dbdd768223a4f896fc82f7 Mon Sep 17 00:00:00 2001 From: Lionel VESSILLER Date: Tue, 5 Mar 2019 14:55:04 +0100 Subject: [PATCH 013/179] Fix sort by field in all events (action and emailing type) and fix multiple contacts in one event --- htdocs/core/lib/company.lib.php | 246 ++++++++++++++++---------------- 1 file changed, 124 insertions(+), 122 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 94707467166..b2980093769 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1222,21 +1222,30 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $numaction = 0 ; $now=dol_now('tzuser'); + // Open DSI -- Fix order by -- Begin + $sortfield_list = explode(',', $sortfield); + $sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent'); + $sortfield_new_list = array(); + foreach ($sortfield_list as $sortfield_value) { + $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)]; + } + $sortfield_new = implode(',', $sortfield_new_list); + if (! empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm - if (is_object($objcon) && $objcon->id) { - $sql = "SELECT DISTINCT a.id, a.label,"; - } - else - { - $sql = "SELECT a.id, a.label,"; - } - $sql.= " a.datep as dp,"; + if (is_object($objcon) && $objcon->id) { + $sql = "SELECT DISTINCT a.id, a.label as note,"; + } + else + { + $sql = "SELECT a.id, a.label as note,"; + } + $sql.= " a.datep as dp,"; $sql.= " a.datep2 as dp2,"; - $sql.= " a.note, a.percent,"; + $sql.= " a.percent as percent, 'action' as type,"; $sql.= " a.fk_element, a.elementtype,"; - $sql.= " a.fk_user_author, a.fk_contact,"; + $sql.= " a.fk_contact,"; $sql.= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; $sql.= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; @@ -1248,17 +1257,19 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; + $force_filter_contact = FALSE; if (is_object($objcon) && $objcon->id) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; - $sql.= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . $objcon->id; - } + $force_filter_contact = TRUE; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; + $sql.= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . $objcon->id; + } - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; - $sql.= " ON er.resource_type = 'dolresource'"; - $sql.= " AND er.element_id = a.id"; - $sql.= " AND er.resource_id = ".$filterobj->id; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; + $sql.= " ON er.resource_type = 'dolresource'"; + $sql.= " AND er.element_id = a.id"; + $sql.= " AND er.resource_id = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; @@ -1266,9 +1277,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", ".MAIN_DB_PREFIX."ticket as o"; $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; - if (is_object($objcon) && $objcon->id) { - $sql.= " AND a.fk_contact = ".$objcon->id; - } else { + if ($force_filter_contact === FALSE) { if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') @@ -1316,69 +1325,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']); - - //TODO Add limit in nb of results - $sql.= $db->order($sortfield, $sortorder); - dol_syslog("company.lib::show_actions_done", LOG_DEBUG); - $resql=$db->query($sql); - if ($resql) - { - $i = 0 ; - $num = $db->num_rows($resql); - - while ($i < $num) - { - $obj = $db->fetch_object($resql); - - $contactaction = new ActionComm($db); - $contactaction->id=$obj->id; - $result = $contactaction->fetchResources(); - if ($result<0) { - dol_print_error($db); - setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); - } - - //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - $tododone=''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone='todo'; - - $histo[$numaction]=array( - 'type'=>'action', - 'tododone'=>$tododone, - 'id'=>$obj->id, - 'datestart'=>$db->jdate($obj->dp), - 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->label, - 'percent'=>$obj->percent, - - 'userid'=>$obj->user_id, - 'login'=>$obj->user_login, - 'userfirstname'=>$obj->user_firstname, - 'userlastname'=>$obj->user_lastname, - 'userphoto'=>$obj->user_photo, - - 'contact_id'=>$obj->fk_contact, - 'socpeopleassigned' => $contactaction->socpeopleassigned, - 'lastname'=>$obj->lastname, - 'firstname'=>$obj->firstname, - 'fk_element'=>$obj->fk_element, - 'elementtype'=>$obj->elementtype, - // Type of event - 'acode'=>$obj->acode, - 'alabel'=>$obj->alabel, - 'libelle'=>$obj->alabel, // deprecated - 'apicto'=>$obj->apicto - ); - - $numaction++; - $i++; - } - } - else - { - dol_print_error($db); - } } // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. @@ -1387,52 +1333,108 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin { $langs->load("mails"); - $sql = "SELECT m.rowid as id, mc.date_envoi as da, m.titre as note, '100' as percentage,"; - $sql.= " 'AC_EMAILING' as acode,"; - $sql.= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action - $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. - $sql.= " AND mc.statut = 1"; - $sql.= " AND u.rowid = m.fk_user_valid"; - $sql.= " AND mc.fk_mailing=m.rowid"; - $sql.= " ORDER BY mc.date_envoi DESC, m.rowid DESC"; + $sql2 = "SELECT m.rowid as id, m.titre as note, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; + $sql2.= ", '' as fk_element, '' as elementtype, '' as contact_id"; + $sql2.= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; + $sql2.= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2.= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2.= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2.= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2.= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2.= ", '' as ref"; + $sql2.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; + $sql2.= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. + $sql2.= " AND mc.statut = 1"; + $sql2.= " AND u.rowid = m.fk_user_valid"; + $sql2.= " AND mc.fk_mailing=m.rowid"; + } - dol_syslog("company.lib::show_actions_done", LOG_DEBUG); - $resql=$db->query($sql); - if ($resql) + if (!empty($sql) && !empty($sql2)) { + $sql = $sql . " UNION " . $sql2; + } else if (empty($sql) && !empty($sql2)) { + $sql = $sql2; + } + //TODO Add limit in nb of results + $sql.= $db->order($sortfield_new, $sortorder); + dol_syslog("company.lib::show_actions_done", LOG_DEBUG); + $resql=$db->query($sql); + if ($resql) + { + $i = 0 ; + $num = $db->num_rows($resql); + + while ($i < $num) { - $i = 0 ; - $num = $db->num_rows($resql); + $obj = $db->fetch_object($resql); + + if ($obj->type == 'action') { + $contactaction = new ActionComm($db); + $contactaction->id=$obj->id; + $result = $contactaction->fetchResources(); + if ($result<0) { + dol_print_error($db); + setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); + } + + //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + $tododone=''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone='todo'; - while ($i < $num) - { - $obj = $db->fetch_object($resql); $histo[$numaction]=array( - 'type'=>'mailing', - 'tododone'=>'done', - 'id'=>$obj->id, - 'datestart'=>$db->jdate($obj->da), - 'dateend'=>$db->jdate($obj->da), - 'note'=>$obj->note, - 'percent'=>$obj->percentage, - 'acode'=>$obj->acode, + 'type'=>$obj->type, + 'tododone'=>$tododone, + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->note, + 'percent'=>$obj->percent, - 'userid'=>$obj->user_id, - 'login'=>$obj->user_login, - 'userfirstname'=>$obj->user_firstname, - 'userlastname'=>$obj->user_lastname, - 'userphoto'=>$obj->user_photo - ); - $numaction++; - $i++; + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo, + + 'contact_id'=>$obj->fk_contact, + 'socpeopleassigned' => $contactaction->socpeopleassigned, + 'lastname'=>$obj->lastname, + 'firstname'=>$obj->firstname, + 'fk_element'=>$obj->fk_element, + 'elementtype'=>$obj->elementtype, + // Type of event + 'acode'=>$obj->acode, + 'alabel'=>$obj->alabel, + 'libelle'=>$obj->alabel, // deprecated + 'apicto'=>$obj->apicto + ); + } else { + $histo[$numaction]=array( + 'type'=>$obj->type, + 'tododone'=>'done', + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->note, + 'percent'=>$obj->percent, + 'acode'=>$obj->acode, + + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo + ); } - $db->free($resql); - } - else - { - dol_print_error($db); + + $numaction++; + $i++; } } + else + { + dol_print_error($db); + } if (! empty($conf->agenda->enabled) || (! empty($conf->mailing->enabled) && ! empty($objcon->email))) { From bf5b482f3d3cda304d9c1473a7c4ccabf637e1e3 Mon Sep 17 00:00:00 2001 From: Lionel VESSILLER Date: Wed, 6 Mar 2019 09:05:07 +0100 Subject: [PATCH 014/179] Fix replace TRUE and FALSE for php checkstyle and aliasing label instead of note in SQL request --- htdocs/core/lib/company.lib.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index b2980093769..225cab69f87 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1235,11 +1235,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin { // Recherche histo sur actioncomm if (is_object($objcon) && $objcon->id) { - $sql = "SELECT DISTINCT a.id, a.label as note,"; + $sql = "SELECT DISTINCT a.id, a.label as label,"; } else { - $sql = "SELECT a.id, a.label as note,"; + $sql = "SELECT a.id, a.label as label,"; } $sql.= " a.datep as dp,"; $sql.= " a.datep2 as dp2,"; @@ -1257,9 +1257,9 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; - $force_filter_contact = FALSE; + $force_filter_contact = false; if (is_object($objcon) && $objcon->id) { - $force_filter_contact = TRUE; + $force_filter_contact = true; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; $sql.= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . $objcon->id; } @@ -1277,7 +1277,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", ".MAIN_DB_PREFIX."ticket as o"; $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; - if ($force_filter_contact === FALSE) { + if ($force_filter_contact === false) { if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') @@ -1333,7 +1333,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin { $langs->load("mails"); - $sql2 = "SELECT m.rowid as id, m.titre as note, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; + $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; $sql2.= ", '' as fk_element, '' as elementtype, '' as contact_id"; $sql2.= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; $sql2.= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action @@ -1387,7 +1387,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin 'id'=>$obj->id, 'datestart'=>$db->jdate($obj->dp), 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->note, + 'note'=>$obj->label, 'percent'=>$obj->percent, 'userid'=>$obj->user_id, @@ -1415,7 +1415,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin 'id'=>$obj->id, 'datestart'=>$db->jdate($obj->dp), 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->note, + 'note'=>$obj->label, 'percent'=>$obj->percent, 'acode'=>$obj->acode, From 218690db00d0b3a8ae737320437de654292af34d Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 7 Mar 2019 17:05:27 +0100 Subject: [PATCH 015/179] add css behavior --- htdocs/core/lib/functions.lib.php | 4 +--- htdocs/theme/eldy/style.css.php | 5 +++++ htdocs/theme/md/style.css.php | 5 +++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 36cdf2c7686..7d5487f1215 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7197,9 +7197,7 @@ function printCommonFooter($zone = 'private') print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'."\n"; print 'jQuery(".menuhider").click(function() {'; print ' console.log("We click on .menuhider");'."\n"; - //print " $('.side-nav').animate({width:'toggle'},200);\n"; // OK with eldy theme but not with md - print " $('.side-nav').toggle()\n"; - print " $('.login_block').toggle()\n"; + print " $('body').toggleClass('sidebar-collapse')\n"; print '});'."\n"; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b21a399f8bd..076d2797f08 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1221,6 +1221,11 @@ td.showDragHandle { box-shadow: 3px 0 6px -2px #eee; background: rgb(); } + +body.sidebar-collapse .side-nav { + display: none; +} + div.blockvmenulogo { border-bottom: 0 !important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index fcff90c4359..a7cf2785810 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1246,6 +1246,11 @@ div.login_block { z-index: 90; } +body.sidebar-collapse .side-nav { + display: none; +} + + div.backgroundsemitransparent { background:rgba(255,255,255,0.6); padding-left: 10px; From 1127716abff7d3b043f375b226dac43efd5a3ced Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 7 Mar 2019 17:50:26 +0100 Subject: [PATCH 016/179] add support for md theme --- htdocs/theme/md/style.css.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a7cf2785810..c8cce686e34 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1246,9 +1246,6 @@ div.login_block { z-index: 90; } -body.sidebar-collapse .side-nav { - display: none; -} div.backgroundsemitransparent { @@ -5721,6 +5718,27 @@ border-top-right-radius: 6px; } +/* +* Slide animation +*/ + + +.side-nav-vert, #id-right { + transition: padding-left 0.5s ease, margin-left 0.5s ease; +} + +.side-nav, .login_block { + transition: left 0.5s ease; +} + + +body.sidebar-collapse .side-nav, body.sidebar-collapse .login_block { + left: -228px; +} + +body.sidebar-collapse .side-nav-vert, body.sidebar-collapse #id-right { + margin-left: 0;padding-left:0 +} close(); From 56a40c7de8065021eddc1ea684f7ceaea90988c2 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Fri, 8 Mar 2019 14:06:37 +0100 Subject: [PATCH 017/179] Fix sidebar collapse behavior --- htdocs/main.inc.php | 4 +++ htdocs/theme/eldy/style.css.php | 4 +-- htdocs/theme/md/style.css.php | 53 +++++++++++++++++---------------- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 70571964162..4f4dcd9a092 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1095,6 +1095,10 @@ if (! function_exists("llxHeader")) // html header top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + if ($conf->browser->layout == 'phone'){ + $morecssonbody.= ' sidebar-collapse'; + } + print '' . "\n"; // top menu and left menu area diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 076d2797f08..3793db64a61 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1220,6 +1220,7 @@ td.showDragHandle { border-right: 1px solid #d0d0d0; box-shadow: 3px 0 6px -2px #eee; background: rgb(); + transition: left 0.5s ease; } body.sidebar-collapse .side-nav { @@ -1268,11 +1269,8 @@ div.vmenu, td.vmenu { background: #FFF; padding-left: 20px; padding-right: 20px; -} -.side-nav { position: absolute; z-index: 90; - display: none; } div.blockvmenulogo { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index c8cce686e34..8af835b44bb 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1210,9 +1210,33 @@ td.showDragHandle { } + +/* +* Slide animation +*/ +.side-nav-vert, #id-right { + transition: padding-left 0.5s ease, margin-left 0.5s ease; +} + +.side-nav, .login_block { + transition: left 0.5s ease; +} + +body.sidebar-collapse .side-nav-vert, body.sidebar-collapse #id-right { + margin-left: 0;padding-left:0 +} + + .side-nav-vert { margin-left: 228px; } +body.sidebar-collapse .side-nav, body.sidebar-collapse .login_block { +browser->layout, array('phone','tablet')) && ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { ?> + left: -240px; + + left: -229px; + +} global->THEME_DISABLE_STICKY_TOPMENU)) { ?> .side-nav-vert { position: sticky; @@ -1239,11 +1263,9 @@ div.login_block { overflow-x: initial !important; overflow-y: scroll; - display: none; + display: block; - position: auto; - top: auto; - z-index: 90; + position: relative; } @@ -1260,7 +1282,7 @@ div.backgroundsemitransparent { div.login_block { /* position: initial !important;*/ - display: none; + /*display: none;*/ } .login_block_getinfo { text-align: center; @@ -5718,27 +5740,6 @@ border-top-right-radius: 6px; } -/* -* Slide animation -*/ - - -.side-nav-vert, #id-right { - transition: padding-left 0.5s ease, margin-left 0.5s ease; -} - -.side-nav, .login_block { - transition: left 0.5s ease; -} - - -body.sidebar-collapse .side-nav, body.sidebar-collapse .login_block { - left: -228px; -} - -body.sidebar-collapse .side-nav-vert, body.sidebar-collapse #id-right { - margin-left: 0;padding-left:0 -} close(); From 37cd62b564fd6950a9776a8cf839e35f16a1eead Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Fri, 8 Mar 2019 14:26:06 +0100 Subject: [PATCH 018/179] Add user friendly behavior --- htdocs/core/lib/functions.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7d5487f1215..7d1fdab5bad 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7195,7 +7195,8 @@ function printCommonFooter($zone = 'private') { print "\n"; print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'."\n"; - print 'jQuery(".menuhider").click(function() {'; + print 'jQuery(".menuhider").click(function(event) {'; + print ' if(!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'."\n"; print ' console.log("We click on .menuhider");'."\n"; print " $('body').toggleClass('sidebar-collapse')\n"; print '});'."\n"; From 749bbcba18052ef88838cc4e197758b34c1b5a8e Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Mar 2019 09:21:04 +0100 Subject: [PATCH 019/179] retrieve from dolibarr repo --- htdocs/custom/.gitignore | 4 ---- htdocs/custom/README.md | 22 ---------------------- htdocs/custom/index.html | 0 3 files changed, 26 deletions(-) delete mode 100644 htdocs/custom/.gitignore delete mode 100644 htdocs/custom/README.md delete mode 100644 htdocs/custom/index.html diff --git a/htdocs/custom/.gitignore b/htdocs/custom/.gitignore deleted file mode 100644 index 89ebd12182c..00000000000 --- a/htdocs/custom/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/* -!.gitignore -!README.md -!index.html \ No newline at end of file diff --git a/htdocs/custom/README.md b/htdocs/custom/README.md deleted file mode 100644 index 3a486e5a4a8..00000000000 --- a/htdocs/custom/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# DOLIBARR ERP & CRM custom directory for external modules. - -This directory is dedicated to store external modules. -To use it, just copy here the directory of the module into this directory. - -Note: On linux or MAC systems, it is better to unzip/store the external module directory into -a different place than this directory and just adding a symbolic link here to the htdocs directory -of the module. - -For example on Linux OS: Get the module from the command -mkdir ~/git; cd ~/git -git clone https://git.framasoft.org/p/newmodule/newmodule.git -Then create the symbolic link -ln -fs ~/git/newmodule/htdocs /path_to_dolibarr/htdocs/custom/newmodule - -WARNING !!! -Check also that the /custom directory is active by adding into dolibarr conf/conf.php file the following -two lines, so dolibarr will also scan /custom directory to find external external modules: - -$dolibarr_main_url_root_alt='/custom'; -$dolibarr_main_document_root_alt='/path_to_dolibarr/htdocs/custom/'; - diff --git a/htdocs/custom/index.html b/htdocs/custom/index.html deleted file mode 100644 index e69de29bb2d..00000000000 From ff206a3e261ec75e52aed02420b1da08042ccfa9 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Mar 2019 10:32:01 +0100 Subject: [PATCH 020/179] custom content was deleted --- htdocs/custom/README.md | 22 ++++++++++++++++++++++ htdocs/custom/index.html | 0 2 files changed, 22 insertions(+) create mode 100644 htdocs/custom/README.md create mode 100644 htdocs/custom/index.html diff --git a/htdocs/custom/README.md b/htdocs/custom/README.md new file mode 100644 index 00000000000..3a486e5a4a8 --- /dev/null +++ b/htdocs/custom/README.md @@ -0,0 +1,22 @@ +# DOLIBARR ERP & CRM custom directory for external modules. + +This directory is dedicated to store external modules. +To use it, just copy here the directory of the module into this directory. + +Note: On linux or MAC systems, it is better to unzip/store the external module directory into +a different place than this directory and just adding a symbolic link here to the htdocs directory +of the module. + +For example on Linux OS: Get the module from the command +mkdir ~/git; cd ~/git +git clone https://git.framasoft.org/p/newmodule/newmodule.git +Then create the symbolic link +ln -fs ~/git/newmodule/htdocs /path_to_dolibarr/htdocs/custom/newmodule + +WARNING !!! +Check also that the /custom directory is active by adding into dolibarr conf/conf.php file the following +two lines, so dolibarr will also scan /custom directory to find external external modules: + +$dolibarr_main_url_root_alt='/custom'; +$dolibarr_main_document_root_alt='/path_to_dolibarr/htdocs/custom/'; + diff --git a/htdocs/custom/index.html b/htdocs/custom/index.html new file mode 100644 index 00000000000..e69de29bb2d From 519672cdc9a5cc4199f6d7a8c1f5a7234adea101 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Mar 2019 10:32:55 +0100 Subject: [PATCH 021/179] custom content was deleted --- htdocs/custom/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 htdocs/custom/.gitignore diff --git a/htdocs/custom/.gitignore b/htdocs/custom/.gitignore new file mode 100644 index 00000000000..9420e8c61eb --- /dev/null +++ b/htdocs/custom/.gitignore @@ -0,0 +1,4 @@ +/* +!.gitignore +!README.md +!index.html From be612a1f6e5a7c2aac4006d7f5af786f454f5c76 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Mar 2019 12:58:03 +0100 Subject: [PATCH 022/179] harmonize propal index pages --- htdocs/comm/index.php | 62 +++++++++++++++++++++++------------- htdocs/comm/propal/index.php | 32 ++++++++++++------- 2 files changed, 60 insertions(+), 34 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index e6fc5e95010..2040338f543 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -159,12 +159,13 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print '
'; print '
'.$langs->trans("Nature").''; - print $object->getLibFinished(); - print '
'.$langs->trans("Nature").''; + print $object->getLibFinished(); + print '
'.$langs->trans("Weight").''; if ($object->weight != '') @@ -1756,7 +1746,7 @@ else } // Custom code - if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) + if (! $object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) { print '
'.$langs->trans("CustomCode").''.$object->customcode.''; + print dol_print_date($productfourn->date_modification, "%d/%m/%Y %H:%M"); + print ''; print $productfourn->delivery_time_days; From fb96857b734148d9f75c6348bc82a6319c1f9ec3 Mon Sep 17 00:00:00 2001 From: jean Date: Fri, 25 May 2018 15:33:27 +0200 Subject: [PATCH 003/179] use dayhour instead of % format --- htdocs/product/fournisseurs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 70776a989df..b63c22482b4 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -831,7 +831,7 @@ SCRIPT; // Date print ''; - print dol_print_date($productfourn->date_modification, "%d/%m/%Y %H:%M"); + print dol_print_date($productfourn->date_modification, "dayhour"); print '
'.$langs->trans("SupplierReputation").''; echo $form->selectarray('supplier_reputation', $object->reputations, $supplier_reputation?$supplier_reputation:$object->supplier_reputation); print '
' . $langs->trans('BarcodeValue') . '
' . $langs->trans('BarcodeType') . ''; + print $formbarcode->selectBarcodeType(($rowid ? $object->fourn_fk_barcode_type : ''), 'fk_barcode_type', 1); + print '
'; + print $productfourn->barcode; + print ''; + + $productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type:0; + $productfourn->fetch_barcode(); + print $productfourn->barcode_type_label?$productfourn->barcode_type_label:($productfourn->barcode?'
'.$langs->trans("SetDefaultBarcodeType").'
':''); + print '
'; print ''; - print ''; + print ''; if ($num > 0) { $i = 0; - while ($i < $num) + $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?5:$conf->global->MAIN_MAXLIST_OVERLOAD)); + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); @@ -190,10 +191,13 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $i++; $total += $obj->total_ht; } - if ($total>0) + if ($num > $nbofloop) { - - print '"; + print '"; + } + elseif ($total>0) + { + print '"; } } else @@ -245,7 +249,8 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos if ($num > 0) { $i = 0; - while ($i < $num) + $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?5:$conf->global->MAIN_MAXLIST_OVERLOAD)); + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); @@ -270,9 +275,13 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos $i++; $total += $obj->total_ht; } - if ($total>0) + if ($num > $nbofloop) + { + print '"; + } + elseif ($total>0) { - print '"; + print '"; } } else @@ -322,9 +331,9 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) if ($num > 0) { $i = 0; - while ($i < $num) + $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?5:$conf->global->MAIN_MAXLIST_OVERLOAD)); + while ($i < $nbofloop) { - $obj = $db->fetch_object($resql); print '"; + print '"; + } + elseif ($total>0) + { + print '"; } } else @@ -409,7 +421,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande if ($num > 0) { $i = 0; - while ($i < $num) + $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?5:$conf->global->MAIN_MAXLIST_OVERLOAD)); + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); @@ -440,10 +453,13 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $i++; $total += $obj->total_ttc; } - if ($total>0) + if ($num > $nbofloop) + { + print '"; + } + elseif ($total>0) { - - print '"; + print '"; } } else @@ -700,7 +716,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print '
'.$langs->trans("ProposalsDraft").($num?' '.$num.'':'').'
'.$langs->trans("ProposalsDraft").' '.$num.'
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("Total").''.price($total)."
'; $orderstatic->id=$obj->rowid; @@ -353,10 +362,13 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $i++; $total += $obj->total_ttc; } - if ($total>0) + if ($num > $nbofloop) { - - print '
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("Total").''.price($total)."
'; print ''; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?5:$conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($result); @@ -757,11 +773,11 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) } if ($num > $nbofloop) { - print '"; + print '"; } elseif ($total>0) { - print '"; + print '"; } print "
'.$langs->trans("ProposalsOpened").' '.$num.'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total")."".price($total)." 
'.$langs->trans("Total")."".price($total)." 
"; print "
"; @@ -804,7 +820,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print ''; print ''; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?5:$conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($result); @@ -861,11 +877,11 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) } if ($num > $nbofloop) { - print '"; + print '"; } elseif ($total>0) { - print '"; + print '"; } print "
'.$langs->trans("OrdersOpened").' '.$num.'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total")."".price($total)." 
'.$langs->trans("Total")."".price($total)." 
"; print "
"; diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 2bc710394bb..55145381951 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -172,16 +172,18 @@ if (! empty($conf->propal->enabled)) $resql=$db->query($sql); if ($resql) { - print '
'; - print ''; - print ''; - print ''; - $langs->load("propal"); $num = $db->num_rows($resql); if ($num) { + print '
'; + print '
'.$langs->trans("DraftPropals").'
'; + print ''; + $langs->load("propal"); + print ''; + $i = 0; - while ($i < $num) + $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?5:$conf->global->MAIN_MAXLIST_OVERLOAD)); + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); print ''; @@ -199,9 +201,17 @@ if (! empty($conf->propal->enabled)) print ''; $i++; } + if ($num > $nbofloop) + { + print '"; + } + elseif ($total>0) + { + print '"; + } + print "
'.$langs->trans("DraftPropals").' '.$num.'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
"; + print "

"; } - print ""; - print "
"; } } @@ -320,7 +330,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) print ''; print ''; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?5:$conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($result); @@ -365,11 +375,11 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) } if ($num > $nbofloop) { - print '"; + print '"; } elseif ($total>0) { - print '"; + print '"; } print "
'.$langs->trans("ProposalsOpened").' '.$num.'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total")."".price($total)." 
'.$langs->trans("Total")."".price($total)." 
"; print "
"; From 40a1562077d94c11deec1583d7c020357d4781bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Mar 2019 09:09:26 +0100 Subject: [PATCH 023/179] update doc --- htdocs/core/lib/functions2.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 99823fba3af..2c756d36a2f 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2183,7 +2183,7 @@ function colorArrayToHex($arraycolor, $colorifnotfound = '888888') * * @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') * @param array $colorifnotfound Color code array to return if entry not defined - * @return string RGB hex value (without # before). For example: FF00FF + * @return array RGB hex value (without # before). For example: FF00FF * @see colorArrayToHex() */ function colorStringToArray($stringcolor, $colorifnotfound = array(88,88,88)) @@ -2274,7 +2274,7 @@ function colorLighten($hex, $percent) * @param string $hex color in hex * @param float $alpha 0 to 1 * @param bool $returnArray set to 1 to return an array instead of string - * @return string + * @return string|array */ function colorHexToRgb($hex, $alpha = false, $returnArray = false) { From 2726cc335dd6f8e810f1cf5573f39775d0363ff7 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 12 Mar 2019 10:24:11 +0100 Subject: [PATCH 024/179] replace align by css align --- htdocs/comm/index.php | 24 ++++++++++++------------ htdocs/comm/propal/index.php | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 2040338f543..1dac0b902c7 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -193,11 +193,11 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) } if ($num > $nbofloop) { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; + print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; } elseif ($total>0) { - print ''.$langs->trans("Total").''.price($total).""; + print ''.$langs->trans("Total").''.price($total).""; } } else @@ -277,11 +277,11 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos } if ($num > $nbofloop) { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; + print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; } elseif ($total>0) { - print ''.$langs->trans("Total").''.price($total).""; + print ''.$langs->trans("Total").''.price($total).""; } } else @@ -364,11 +364,11 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) } if ($num > $nbofloop) { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; + print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; } elseif ($total>0) { - print ''.$langs->trans("Total").''.price($total).""; + print ''.$langs->trans("Total").''.price($total).""; } } else @@ -455,11 +455,11 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande } if ($num > $nbofloop) { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; + print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; } elseif ($total>0) { - print ''.$langs->trans("Total").''.price($total).""; + print ''.$langs->trans("Total").''.price($total).""; } } else @@ -773,11 +773,11 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) } if ($num > $nbofloop) { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; + print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; } elseif ($total>0) { - print ''.$langs->trans("Total")."".price($total)." "; + print ''.$langs->trans("Total")."".price($total)." "; } print ""; print "
"; @@ -877,11 +877,11 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) } if ($num > $nbofloop) { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; + print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; } elseif ($total>0) { - print ''.$langs->trans("Total")."".price($total)." "; + print ''.$langs->trans("Total")."".price($total)." "; } print ""; print "
"; diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 55145381951..122730aee8e 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -203,11 +203,11 @@ if (! empty($conf->propal->enabled)) } if ($num > $nbofloop) { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; + print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; } elseif ($total>0) { - print ''.$langs->trans("Total").''.price($total).""; + print ''.$langs->trans("Total").''.price($total).""; } print ""; print "
"; @@ -375,11 +375,11 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) } if ($num > $nbofloop) { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; + print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; } elseif ($total>0) { - print ''.$langs->trans("Total")."".price($total)." "; + print ''.$langs->trans("Total")."".price($total)." "; } print ""; print "
"; From ae50a8b8969f22a8b6df4827db5071425cf500e2 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 12 Mar 2019 10:48:08 +0100 Subject: [PATCH 025/179] change add_commercial signature --- htdocs/societe/class/societe.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 466cda8e05f..60790698b24 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1939,11 +1939,11 @@ class Societe extends CommonObject * * @param User $user Object user * @param int $commid Id of user - * @return void + * @return int <0 if KO, >0 if OK */ public function add_commercial(User $user, $commid) { - // phpcs:enable + // phpcs:enable $error=0; @@ -1961,14 +1961,18 @@ class Societe extends CommonObject if (! $this->db->query($sql) ) { dol_syslog(get_class($this)."::add_commercial Erreur"); + return -2; } else { $this->context=array('commercial_modified'=>$commid); $result=$this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE', $user); - if ($result < 0) $error++; + if ($result < 0) return $result; + + return 1; } } + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps From 17647de4ccc1d5f653b11867a5208aed53a587c0 Mon Sep 17 00:00:00 2001 From: Joan Louis Date: Tue, 12 Mar 2019 11:24:54 +0100 Subject: [PATCH 026/179] Fix extrafields calls from cards for Dolibarr 8 See #10803 --- htdocs/comm/propal/card.php | 4 ++-- htdocs/commande/card.php | 4 ++-- htdocs/compta/facture/card.php | 4 ++-- htdocs/compta/facture/fiche-rec.php | 4 ++-- htdocs/contrat/card.php | 4 ++-- htdocs/fichinter/card.php | 6 +++--- htdocs/fourn/commande/card.php | 4 ++-- htdocs/fourn/facture/card.php | 4 ++-- htdocs/supplier_proposal/card.php | 4 ++-- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index be5494fbb75..ba68e3324bb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -751,7 +751,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -1119,7 +1119,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0b0348ee5e0..66f01399183 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -662,7 +662,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -1023,7 +1023,7 @@ if (empty($reshook)) // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6568ac03eba..414a86f4c27 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1682,7 +1682,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -2089,7 +2089,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index fb70da42665..36c1aec55b9 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -453,7 +453,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { @@ -776,7 +776,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); $objectline = new FactureLigneRec($db); if ($objectline->fetch(GETPOST('lineid'))) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 5f418cb0568..b681e8147a7 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -456,7 +456,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -737,7 +737,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); $objectline->array_options=$array_options; // TODO verifier price_min si fk_product et multiprix diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 15b75495c38..24aca7e9dbf 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -362,7 +362,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); $result = $object->addline( $user, @@ -509,7 +509,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); $result=$object->addline( $user, @@ -622,7 +622,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); $objectline->array_options = $array_options; $result = $objectline->update($user); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 9009364d4b1..41a6d030e16 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -308,7 +308,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -614,7 +614,7 @@ if (empty($reshook)) // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c9715278074..a294cf3c6ad 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1056,7 +1056,7 @@ if (empty($reshook)) // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { @@ -1132,7 +1132,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 7b1bf417b40..d7ac16e67ea 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -550,7 +550,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -814,7 +814,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields From 36b44b1348f3c401ced793d01b0520ad73d9901e Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 12 Mar 2019 11:28:36 +0100 Subject: [PATCH 027/179] FIX: several hooks in shipping/delivery cards --- htdocs/expedition/card.php | 1287 ++++++++++++++++---------------- htdocs/expedition/shipment.php | 276 +++---- htdocs/livraison/card.php | 142 ++-- 3 files changed, 865 insertions(+), 840 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 0f45ca61804..aa85132b243 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1141,448 +1141,455 @@ if ($action == 'create') $line = $object->lines[$indiceAsked]; - // Show product and description - $type=$line->product_type?$line->product_type:$line->fk_product_type; - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($line->date_start)) $type=1; - if (! empty($line->date_end)) $type=1; + $parameters = array('i' => $indiceAsked, 'line' => $line, 'num' => $numAsked); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''."\n"; - print ''."\n"; - - // Product label - if ($line->fk_product > 0) // If predefined product + if(empty($reshook)) { - $product->fetch($line->fk_product); - $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch - //var_dump($product->stock_warehouse[1]); + // Show product and description + $type=$line->product_type?$line->product_type:$line->fk_product_type; + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($line->date_start)) $type=1; + if (! empty($line->date_end)) $type=1; - print ''; - print ''; // ancre pour retourner sur la ligne + print ''."\n"; + print ''."\n"; - // Show product and description - $product_static->type=$line->fk_product_type; - $product_static->id=$line->fk_product; - $product_static->ref=$line->ref; - $product_static->status_batch=$line->product_tobatch; - $text=$product_static->getNomUrl(1); - $text.= ' - '.(! empty($line->label)?$line->label:$line->product_label); - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->desc)); - print $form->textwithtooltip($text,$description,3,'','',$i); + // Product label + if ($line->fk_product > 0) // If predefined product + { + $product->fetch($line->fk_product); + $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch + //var_dump($product->stock_warehouse[1]); - // Show range - print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); + print ''; + print ''; // ancre pour retourner sur la ligne - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) - { - print ($line->desc && $line->desc!=$line->product_label)?'
'.dol_htmlentitiesbr($line->desc):''; - } + // Show product and description + $product_static->type=$line->fk_product_type; + $product_static->id=$line->fk_product; + $product_static->ref=$line->ref; + $product_static->status_batch=$line->product_tobatch; + $text=$product_static->getNomUrl(1); + $text.= ' - '.(! empty($line->label)?$line->label:$line->product_label); + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->desc)); + print $form->textwithtooltip($text,$description,3,'','',$i); - print ''; - } - else - { - print ""; - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); + // Show range + print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); - if (! empty($line->label)) { - $text.= ' '.$line->label.''; - print $form->textwithtooltip($text,$line->desc,3,'','',$i); - } else { - print $text.' '.nl2br($line->desc); - } + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + print ($line->desc && $line->desc!=$line->product_label)?'
'.dol_htmlentitiesbr($line->desc):''; + } - // Show range - print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); - print "\n"; - } - - // Qty - print ''.$line->qty; - print ''; - print ''; - $qtyProdCom=$line->qty; - - // Qty already shipped - print ''; - $quantityDelivered = $object->expeditions[$line->id]; - print $quantityDelivered; - print ''; - print ''; - - // Qty to ship - $quantityAsked = $line->qty; - if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $quantityToBeDelivered = 0; - } - else - { - $quantityToBeDelivered = $quantityAsked - $quantityDelivered; - } - $warehouse_id = GETPOST('entrepot_id','int'); - - $warehouseObject = null; - if ($warehouse_id > 0 || ! ($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection - { - print ''; - //ship from preselected location - $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number - $deliverableQty=min($quantityToBeDelivered, $stock); - if ($deliverableQty < 0) $deliverableQty = 0; - if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) + print ''; + } + else { - // Quantity to send - print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty=GETPOST('qtyl'.$indiceAsked, 'int'); - print ''; - print ''; - } - else print $langs->trans("NA"); - print ''; + print ""; + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); - // Stock - if (! empty($conf->stock->enabled)) - { - print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? - { - // Show warehouse combo list - $ent = "entl".$indiceAsked; - $idl = "idl".$indiceAsked; - $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):$warehouse_id; - if ($line->fk_product > 0) - { - print ''; - print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1); - if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) - { - //print $stock.' '.$quantityToBeDelivered; - if ($stock < $quantityToBeDelivered) - { - print ' '.img_warning($langs->trans("StockTooLow")); // Stock too low for this $warehouse_id but you can change warehouse - } - } - } - } - else - { - print $langs->trans("Service"); - } - print ''; - } + if (! empty($line->label)) { + $text.= ' '.$line->label.''; + print $form->textwithtooltip($text,$line->desc,3,'','',$i); + } else { + print $text.' '.nl2br($line->desc); + } - print "\n"; + // Show range + print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); + print "\n"; + } - // Show subproducts of product - if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) - { - $product->get_sousproduits_arbo(); - $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); - if(count($prods_arbo) > 0) - { - foreach($prods_arbo as $key => $value) - { - //print $value[0]; - $img=''; - if ($value['stock'] < $value['stock_alert']) - { - $img=img_warning($langs->trans("StockTooLow")); - } - print "      -> - ".$value['fullpath']." - (".$value['nb'].") ".$value['nb_total']."   - ".$value['stock']." ".$img.""; - } - } - } + // Qty + print ''.$line->qty; + print ''; + print ''; + $qtyProdCom=$line->qty; + + // Qty already shipped + print ''; + $quantityDelivered = $object->expeditions[$line->id]; + print $quantityDelivered; + print ''; + print ''; + + // Qty to ship + $quantityAsked = $line->qty; + if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $quantityToBeDelivered = 0; } else { - // Product need lot - print ''; // end line and start a new one for lot/serial - print ''; + $quantityToBeDelivered = $quantityAsked - $quantityDelivered; + } + $warehouse_id = GETPOST('entrepot_id','int'); - $staticwarehouse=new Entrepot($db); - if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id); - - $subj=0; - // Define nb of lines suggested for this order line - $nbofsuggested=0; - if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) + $warehouseObject = null; + if ($warehouse_id > 0 || ! ($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection + { + print ''; + //ship from preselected location + $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number + $deliverableQty=min($quantityToBeDelivered, $stock); + if ($deliverableQty < 0) $deliverableQty = 0; + if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) { - foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) - { - $nbofsuggested++; - } - } - print ''; - if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) - { - foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) // $dbatch is instance of Productbatch + // Quantity to send + print ''; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - //var_dump($dbatch); - $batchStock = + $dbatch->qty; // To get a numeric - $deliverableQty = min($quantityToBeDelivered,$batchStock); - print ''; - print ''; - print ''; - print ''; + if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty=GETPOST('qtyl'.$indiceAsked, 'int'); + print ''; + print ''; + } + else print $langs->trans("NA"); + print ''; - print ''; + // Stock + if (! empty($conf->stock->enabled)) + { print ''; - - print $staticwarehouse->getNomUrl(0).' / '; - - print ''; - - $detail=''; - $detail.= $langs->trans("Batch").': '.$dbatch->batch; - $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); - $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); - $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; - $detail.= '
'; - print $detail; - - $quantityToBeDelivered -= $deliverableQty; - if ($quantityToBeDelivered < 0) + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? { - $quantityToBeDelivered = 0; + // Show warehouse combo list + $ent = "entl".$indiceAsked; + $idl = "idl".$indiceAsked; + $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):$warehouse_id; + if ($line->fk_product > 0) + { + print ''; + print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1); + if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) + { + //print $stock.' '.$quantityToBeDelivered; + if ($stock < $quantityToBeDelivered) + { + print ' '.img_warning($langs->trans("StockTooLow")); // Stock too low for this $warehouse_id but you can change warehouse + } + } + } + } + else + { + print $langs->trans("Service"); + } + print ''; + } + + print "\n"; + + // Show subproducts of product + if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) + { + $product->get_sousproduits_arbo(); + $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); + if(count($prods_arbo) > 0) + { + foreach($prods_arbo as $key => $value) + { + //print $value[0]; + $img=''; + if ($value['stock'] < $value['stock_alert']) + { + $img=img_warning($langs->trans("StockTooLow")); + } + print "      -> + ".$value['fullpath']." + (".$value['nb'].") ".$value['nb_total']."   + ".$value['stock']." ".$img.""; + } } - $subj++; - print ''; } } else { - print ''; - print ''; - print ' '; - print ''; + // Product need lot + print ''; // end line and start a new one for lot/serial + print ''; - print ''; - print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle); - print ''; - } - } - } - else - { - // ship from multiple locations - if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) - { - print ''; - print ''."\n"; // end line and start a new one for each warehouse + $staticwarehouse=new Entrepot($db); + if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id); - print ''; - $subj=0; - // Define nb of lines suggested for this order line - $nbofsuggested=0; - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) - { - if ($stock_warehouse->real > 0) + $subj=0; + // Define nb of lines suggested for this order line + $nbofsuggested=0; + if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) { - $nbofsuggested++; - } - } - $tmpwarehouseObject=new Entrepot($db); - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock - { - $tmpwarehouseObject->fetch($warehouse_id); - if ($stock_warehouse->real > 0) - { - $stock = + $stock_warehouse->real; // Convert it to number - $deliverableQty = min($quantityToBeDelivered,$stock); - $deliverableQty = max(0, $deliverableQty); - // Quantity to send - print ''; - print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - print ''; - print ''; - } - else print $langs->trans("NA"); - print ''; - - // Stock - if (! empty($conf->stock->enabled)) - { - print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - print $tmpwarehouseObject->getNomUrl(0).' '; - - print ''; - print '('.$stock.')'; - - } - else - { - print $langs->trans("Service"); - } - print ''; - } - $quantityToBeDelivered -= $deliverableQty; - if ($quantityToBeDelivered < 0) - { - $quantityToBeDelivered = 0; - } - $subj++; - print "\n"; + foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) + { + $nbofsuggested++; + } } - } - // Show subproducts of product (not recommanded) - if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) - { - $product->get_sousproduits_arbo(); - $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); - if (count($prods_arbo) > 0) + print ''; + if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) { - foreach($prods_arbo as $key => $value) - { - //print $value[0]; - $img=''; - if ($value['stock'] < $value['stock_alert']) - { - $img=img_warning($langs->trans("StockTooLow")); - } - print ''; - print "      -> - ".$value['fullpath']." - (".$value['nb'].") ".$value['nb_total']."   - ".$value['stock']." ".$img.""; - print ""; - } - } - } - } - else - { - print ''; - print ''; // end line and start a new one for lot/serial - - $subj=0; - print ''; - - $tmpwarehouseObject=new Entrepot($db); - $productlotObject=new Productlot($db); - // Define nb of lines suggested for this order line - $nbofsuggested=0; - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) - { - if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { - foreach ($stock_warehouse->detail_batch as $dbatch) - { - $nbofsuggested++; - } - } - } - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) - { - $tmpwarehouseObject->fetch($warehouse_id); - if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { - foreach ($stock_warehouse->detail_batch as $dbatch) + foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) // $dbatch is instance of Productbatch { //var_dump($dbatch); $batchStock = + $dbatch->qty; // To get a numeric $deliverableQty = min($quantityToBeDelivered,$batchStock); - if ($deliverableQty < 0) $deliverableQty = 0; - print ''; + print ''; + print ''; print ''; print ''; + print ''; print ''; - print $tmpwarehouseObject->getNomUrl(0).' / '; + print $staticwarehouse->getNomUrl(0).' / '; - print ''; print ''; - //print '|'.$line->fk_product.'|'.$dbatch->batch.'|
'; - print $langs->trans("Batch").': '; - $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch); - if ($result > 0) print $productlotObject->getNomUrl(1); - else print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed'; - print ' ('.$dbatch->qty.')'; + $detail=''; + $detail.= $langs->trans("Batch").': '.$dbatch->batch; + $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); + $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); + $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; + $detail.= '
'; + print $detail; + $quantityToBeDelivered -= $deliverableQty; if ($quantityToBeDelivered < 0) { $quantityToBeDelivered = 0; } - //dol_syslog('deliverableQty = '.$deliverableQty.' batchStock = '.$batchStock); $subj++; print ''; } } - } + else + { + print ''; + print ''; + print ' '; + print ''; + print ''; + print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle); + print ''; + } + } } - if ($subj == 0) // Line not shown yet, we show it + else { - print ''; - print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + // ship from multiple locations + if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) { - $disabled=''; - if (! empty($conf->productbatch->enabled) && $product->hasbatch()) - { - $disabled='disabled="disabled"'; - } - print ' '; - } - else - { - print $langs->trans("NA"); - } - print ''; + print ''; + print ''."\n"; // end line and start a new one for each warehouse - print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $warehouse_selected_id = GETPOST('entrepot_id','int'); - if ($warehouse_selected_id > 0) - { - $warehouseObject=new Entrepot($db); - $warehouseObject->fetch($warehouse_selected_id); - print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle); - } - else - { - if ($line->fk_product) print img_warning().' '.$langs->trans("StockTooLow"); - else print ''; - } + print ''; + $subj=0; + // Define nb of lines suggested for this order line + $nbofsuggested=0; + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + { + if ($stock_warehouse->real > 0) + { + $nbofsuggested++; + } + } + $tmpwarehouseObject=new Entrepot($db); + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock + { + $tmpwarehouseObject->fetch($warehouse_id); + if ($stock_warehouse->real > 0) + { + $stock = + $stock_warehouse->real; // Convert it to number + $deliverableQty = min($quantityToBeDelivered,$stock); + $deliverableQty = max(0, $deliverableQty); + // Quantity to send + print ''; + print ''; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + print ''; + print ''; + } + else print $langs->trans("NA"); + print ''; + + // Stock + if (! empty($conf->stock->enabled)) + { + print ''; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + print $tmpwarehouseObject->getNomUrl(0).' '; + + print ''; + print '('.$stock.')'; + + } + else + { + print $langs->trans("Service"); + } + print ''; + } + $quantityToBeDelivered -= $deliverableQty; + if ($quantityToBeDelivered < 0) + { + $quantityToBeDelivered = 0; + } + $subj++; + print "\n"; + } + } + // Show subproducts of product (not recommanded) + if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) + { + $product->get_sousproduits_arbo(); + $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); + if (count($prods_arbo) > 0) + { + foreach($prods_arbo as $key => $value) + { + //print $value[0]; + $img=''; + if ($value['stock'] < $value['stock_alert']) + { + $img=img_warning($langs->trans("StockTooLow")); + } + print ''; + print "      -> + ".$value['fullpath']." + (".$value['nb'].") ".$value['nb_total']."   + ".$value['stock']." ".$img.""; + print ""; + } + } + } } else { - print $langs->trans("Service"); + print ''; + print ''; // end line and start a new one for lot/serial + + $subj=0; + print ''; + + $tmpwarehouseObject=new Entrepot($db); + $productlotObject=new Productlot($db); + // Define nb of lines suggested for this order line + $nbofsuggested=0; + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + { + if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { + foreach ($stock_warehouse->detail_batch as $dbatch) + { + $nbofsuggested++; + } + } + } + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + { + $tmpwarehouseObject->fetch($warehouse_id); + if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { + foreach ($stock_warehouse->detail_batch as $dbatch) + { + //var_dump($dbatch); + $batchStock = + $dbatch->qty; // To get a numeric + $deliverableQty = min($quantityToBeDelivered,$batchStock); + if ($deliverableQty < 0) $deliverableQty = 0; + print ''; + print ''; + print ''; + + print ''; + + print $tmpwarehouseObject->getNomUrl(0).' / '; + + print ''; + print ''; + + //print '|'.$line->fk_product.'|'.$dbatch->batch.'|
'; + print $langs->trans("Batch").': '; + $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch); + if ($result > 0) print $productlotObject->getNomUrl(1); + else print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed'; + print ' ('.$dbatch->qty.')'; + $quantityToBeDelivered -= $deliverableQty; + if ($quantityToBeDelivered < 0) + { + $quantityToBeDelivered = 0; + } + //dol_syslog('deliverableQty = '.$deliverableQty.' batchStock = '.$batchStock); + $subj++; + print ''; + } + } + } + } - print ''; + if ($subj == 0) // Line not shown yet, we show it + { + print ''; + print ''; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $disabled=''; + if (! empty($conf->productbatch->enabled) && $product->hasbatch()) + { + $disabled='disabled="disabled"'; + } + print ' '; + } + else + { + print $langs->trans("NA"); + } + print ''; + + print ''; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $warehouse_selected_id = GETPOST('entrepot_id','int'); + if ($warehouse_selected_id > 0) + { + $warehouseObject=new Entrepot($db); + $warehouseObject->fetch($warehouse_selected_id); + print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle); + } + else + { + if ($line->fk_product) print img_warning().' '.$langs->trans("StockTooLow"); + else print ''; + } + } + else + { + print $langs->trans("Service"); + } + print ''; + print ''; + } + } + + + //Display lines extrafields + if (is_array($extralabelslines) && count($extralabelslines)>0) + { + $colspan=5; + $orderLineExtrafields = new Extrafields($db); + $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line); + $srcLine = new OrderLine($db); + $srcLine->fetch_optionals($line->id); // fetch extrafields also available in orderline + $line = new ExpeditionLigne($db); + //$line->fetch_optionals($line->id); + $line->array_options = array_merge($line->array_options, $srcLine->array_options); + print ''; + print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); print ''; } - } - - - //Display lines extrafields - if (is_array($extralabelslines) && count($extralabelslines)>0) - { - $colspan=5; - $orderLineExtrafields = new Extrafields($db); - $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line); - $srcLine = new OrderLine($db); - $srcLine->fetch_optionals($line->id); // fetch extrafields also available in orderline - $line = new ExpeditionLigne($db); - //$line->fetch_optionals($line->id); - $line->array_options = array_merge($line->array_options, $srcLine->array_options); - print ''; - print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); - print ''; - } + } $indiceAsked++; } @@ -1986,6 +1993,11 @@ else if ($id || $ref) print ''; } + // Other attributes + $parameters = array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print ""; print ''; @@ -2140,298 +2152,305 @@ else if ($id || $ref) // Loop on each product to send/sent for ($i = 0 ; $i < $num_prod ; $i++) { - print ''; // id of order line - print ''; + $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => $editColspan, 'outputlangs' => $outputlangs); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); + if($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - // # - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + if(empty($reshook)) { - print ''.($i+1).''; - } + print ''; // id of order line + print ''; - // Predefined product or service - if ($lines[$i]->fk_product > 0) - { - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + // # + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - $prod = new Product($db); - $prod->fetch($lines[$i]->fk_product); - $label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; + print ''.($i+1).''; + } + + // Predefined product or service + if ($lines[$i]->fk_product > 0) + { + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $prod = new Product($db); + $prod->fetch($lines[$i]->fk_product); + $label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; + } + else + $label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label); + + print ''; + + // Show product and description + $product_static->type=$lines[$i]->fk_product_type; + $product_static->id=$lines[$i]->fk_product; + $product_static->ref=$lines[$i]->ref; + $product_static->status_batch=$lines[$i]->product_tobatch; + $text=$product_static->getNomUrl(1); + $text.= ' - '.$label; + $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description)); + print $form->textwithtooltip($text,$description,3,'','',$i); + print_date_range($lines[$i]->date_start,$lines[$i]->date_end); + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + print (! empty($lines[$i]->description) && $lines[$i]->description!=$lines[$i]->product)?'
'.dol_htmlentitiesbr($lines[$i]->description):''; + } + print "\n"; } else - $label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label); - - print ''; - - // Show product and description - $product_static->type=$lines[$i]->fk_product_type; - $product_static->id=$lines[$i]->fk_product; - $product_static->ref=$lines[$i]->ref; - $product_static->status_batch=$lines[$i]->product_tobatch; - $text=$product_static->getNomUrl(1); - $text.= ' - '.$label; - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description)); - print $form->textwithtooltip($text,$description,3,'','',$i); - print_date_range($lines[$i]->date_start,$lines[$i]->date_end); - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print (! empty($lines[$i]->description) && $lines[$i]->description!=$lines[$i]->product)?'
'.dol_htmlentitiesbr($lines[$i]->description):''; - } - print "\n"; - } - else - { - print ""; - if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); + print ""; + if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); - if (! empty($lines[$i]->label)) { - $text.= ' '.$lines[$i]->label.''; - print $form->textwithtooltip($text,$lines[$i]->description,3,'','',$i); - } else { - print $text.' '.nl2br($lines[$i]->description); - } - - print_date_range($lines[$i]->date_start,$lines[$i]->date_end); - print "\n"; - } - - // Qty ordered - print ''.$lines[$i]->qty_asked.''; - - // Qty in other shipments (with shipment and warehouse used) - if ($origin && $origin_id > 0) - { - print ''; - foreach ($alreadysent as $key => $val) - { - if ($lines[$i]->fk_origin_line == $key) - { - $j = 0; - foreach($val as $shipmentline_id=> $shipmentline_var) - { - if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) continue; // We want to show only "other shipments" - - $j++; - if ($j > 1) print '
'; - $shipment_static->fetch($shipmentline_var['shipment_id']); - print $shipment_static->getNomUrl(1); - print ' - '.$shipmentline_var['qty_shipped']; - $htmltext=$langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid'])?$langs->trans("Draft"):dol_print_date($shipmentline_var['date_valid'], 'dayhour')); - if (! empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0) - { - $warehousestatic->fetch($shipmentline_var['warehouse']); - $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1); - } - print ' '.$form->textwithpicto('', $htmltext, 1); - } - } - } - } - print ''; - - if ($action == 'editline' && $lines[$i]->id == $line_id) - { - // edit mode - print ''; - if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) - { - print ''; - $line = new ExpeditionLigne($db); - foreach ($lines[$i]->detail_batch as $detail_batch) - { - print ''; - // Qty to ship or shipped - print ''; - // Batch number managment - if ($lines[$i]->entrepot_id == 0) - { - // only show lot numbers from src warehouse when shipping from multiple warehouses - $line->fetch($detail_batch->fk_expeditiondet); - } - print ''; - print ''; + if (! empty($lines[$i]->label)) { + $text.= ' '.$lines[$i]->label.''; + print $form->textwithtooltip($text,$lines[$i]->description,3,'','',$i); + } else { + print $text.' '.nl2br($lines[$i]->description); } - // add a 0 qty lot row to be able to add a lot - print ''; - // Qty to ship or shipped - print ''; - // Batch number managment - print ''; - print ''; + + print_date_range($lines[$i]->date_start,$lines[$i]->date_end); + print "\n"; } - else if (! empty($conf->stock->enabled)) + + // Qty ordered + print ''; + + // Qty in other shipments (with shipment and warehouse used) + if ($origin && $origin_id > 0) + { + print ''; + + if ($action == 'editline' && $lines[$i]->id == $line_id) { - if ($lines[$i]->fk_product > 0) + // edit mode + print ''; - } - else - { - // Qty to ship or shipped - print ''; - - // Warehouse source - if (! empty($conf->stock->enabled)) - { - print ''; - } - - // Batch number managment - if (! empty($conf->productbatch->enabled)) - { - if (isset($lines[$i]->detail_batch)) - { - print ''; - print ''; - } else { - print ''; - } - } - } - - // Weight - print ''; - - // Volume - print ''; - - // Size - //print ''; - - if ($action == 'editline' && $lines[$i]->id == $line_id) - { - print ''; - print ''; - - // Display lines extrafields - if (! empty($rowExtrafieldsStart)) - { - print $rowExtrafieldsStart; - print $rowExtrafieldsView; - print $rowEnd; - } - } - print ""; - - // Display lines extrafields - if (is_array($extralabelslines) && count($extralabelslines)>0) { - $colspan= empty($conf->productbatch->enabled) ? 5 : 6; - $line = new ExpeditionLigne($db); - $line->fetch_optionals($lines[$i]->id); - print ''; - if ($action == 'editline' && $lines[$i]->id == $line_id) - { - print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); + print '
' . '' . '' . $formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id). '
' . '' . '' . $formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product). '
'.$lines[$i]->qty_asked.''; + foreach ($alreadysent as $key => $val) + { + if ($lines[$i]->fk_origin_line == $key) + { + $j = 0; + foreach($val as $shipmentline_id=> $shipmentline_var) + { + if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) continue; // We want to show only "other shipments" + + $j++; + if ($j > 1) print '
'; + $shipment_static->fetch($shipmentline_var['shipment_id']); + print $shipment_static->getNomUrl(1); + print ' - '.$shipmentline_var['qty_shipped']; + $htmltext=$langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid'])?$langs->trans("Draft"):dol_print_date($shipmentline_var['date_valid'], 'dayhour')); + if (! empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0) + { + $warehousestatic->fetch($shipmentline_var['warehouse']); + $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1); + } + print ' '.$form->textwithpicto('', $htmltext, 1); + } + } + } + } + print '
'; + if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) { - if ($lines[$i]->entrepot_id > 0) + print ''; + $line = new ExpeditionLigne($db); + foreach ($lines[$i]->detail_batch as $detail_batch) { - print ''; print ''; // Qty to ship or shipped - print ''; - // Warehouse source - print ''; + print ''; // Batch number managment - print ''; + if ($lines[$i]->entrepot_id == 0) + { + // only show lot numbers from src warehouse when shipping from multiple warehouses + $line->fetch($detail_batch->fk_expeditiondet); + } + print ''; print ''; } - else if (count($lines[$i]->details_entrepot) > 1) + // add a 0 qty lot row to be able to add a lot + print ''; + // Qty to ship or shipped + print ''; + // Batch number managment + print ''; + print ''; + } + else if (! empty($conf->stock->enabled)) + { + if ($lines[$i]->fk_product > 0) { - print ''; - foreach ($lines[$i]->details_entrepot as $detail_entrepot) + if ($lines[$i]->entrepot_id > 0) { + print ''; print ''; // Qty to ship or shipped - print ''; + print ''; // Warehouse source - print ''; + print ''; // Batch number managment print ''; print ''; } + else if (count($lines[$i]->details_entrepot) > 1) + { + print ''; + foreach ($lines[$i]->details_entrepot as $detail_entrepot) + { + print ''; + // Qty to ship or shipped + print ''; + // Warehouse source + print ''; + // Batch number managment + print ''; + print ''; + } + } + else + { + print ''; + print ''; + } } else { - print ''; - print ''; + print ''; + print ''; + // Qty to ship or shipped + print ''; + // Warehouse source + print ''; + // Batch number managment + print ''; + print ''; } } - else - { - print ''; - print ''; - // Qty to ship or shipped - print ''; - // Warehouse source - print ''; - // Batch number managment - print ''; - print ''; - } - } - print '
' . '' . '' . $formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1). '' . '' . ' - ' . $langs->trans("NA") . '' . $formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id). '
' . '' . '' . $formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product). '
' . '' . '' . '' . '' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1) . '' . $formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1). ' - ' . $langs->trans("NA") . '
' . '' . '' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1) . ' - ' . $langs->trans("NA") . '
'.$langs->trans("NotEnoughStock").'
'.$langs->trans("NotEnoughStock").'
' . '' . '' . '' . '
' . '' . '' . '' . '
'.$lines[$i]->qty_shipped.''; - if ($lines[$i]->entrepot_id > 0) - { - $entrepot = new Entrepot($db); - $entrepot->fetch($lines[$i]->entrepot_id); - print $entrepot->getNomUrl(1); - } - else if (count($lines[$i]->details_entrepot) > 1) - { - $detail = ''; - foreach ($lines[$i]->details_entrepot as $detail_entrepot) - { - if ($detail_entrepot->entrepot_id > 0) - { - $entrepot = new Entrepot($db); - $entrepot->fetch($detail_entrepot->entrepot_id); - $detail.= $langs->trans("DetailWarehouseFormat",$entrepot->libelle,$detail_entrepot->qty_shipped).'
'; - } - } - print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"),$detail); - } - print '
'; - if ($lines[$i]->product_tobatch) - { - $detail = ''; - foreach ($lines[$i]->detail_batch as $dbatch) // $dbatch is instance of ExpeditionLineBatch - { - $detail.= $langs->trans("Batch").': '.$dbatch->batch; - $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); - $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); - $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; - $detail.= '
'; - } - print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail); - } - else - { - print $langs->trans("NA"); - } - print '
'; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight"); - else print ' '; - print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume"); - else print ' '; - print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume").''; - print '
'; - print '
'; - } - else if ($object->statut == 0) - { - // edit-delete buttons - print '
'; - print 'id . '">' . img_edit() . ''; - print ''; - print 'id . '">' . img_delete() . ''; - print '
'; } else { - print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); + // Qty to ship or shipped + print ''.$lines[$i]->qty_shipped.''; + + // Warehouse source + if (! empty($conf->stock->enabled)) + { + print ''; + if ($lines[$i]->entrepot_id > 0) + { + $entrepot = new Entrepot($db); + $entrepot->fetch($lines[$i]->entrepot_id); + print $entrepot->getNomUrl(1); + } + else if (count($lines[$i]->details_entrepot) > 1) + { + $detail = ''; + foreach ($lines[$i]->details_entrepot as $detail_entrepot) + { + if ($detail_entrepot->entrepot_id > 0) + { + $entrepot = new Entrepot($db); + $entrepot->fetch($detail_entrepot->entrepot_id); + $detail.= $langs->trans("DetailWarehouseFormat",$entrepot->libelle,$detail_entrepot->qty_shipped).'
'; + } + } + print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"),$detail); + } + print ''; + } + + // Batch number managment + if (! empty($conf->productbatch->enabled)) + { + if (isset($lines[$i]->detail_batch)) + { + print ''; + print ''; + if ($lines[$i]->product_tobatch) + { + $detail = ''; + foreach ($lines[$i]->detail_batch as $dbatch) // $dbatch is instance of ExpeditionLineBatch + { + $detail.= $langs->trans("Batch").': '.$dbatch->batch; + $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); + $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); + $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; + $detail.= '
'; + } + print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail); + } + else + { + print $langs->trans("NA"); + } + print ''; + } else { + print ''; + } + } + } + + // Weight + print ''; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight"); + else print ' '; + print ''; + + // Volume + print ''; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume"); + else print ' '; + print ''; + + // Size + //print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume").''; + + if ($action == 'editline' && $lines[$i]->id == $line_id) + { + print ''; + print '
'; + print '
'; + } + else if ($object->statut == 0) + { + // edit-delete buttons + print ''; + print 'id . '">' . img_edit() . ''; + print ''; + print ''; + print 'id . '">' . img_delete() . ''; + print ''; + + // Display lines extrafields + if (! empty($rowExtrafieldsStart)) + { + print $rowExtrafieldsStart; + print $rowExtrafieldsView; + print $rowEnd; + } + } + print ""; + + // Display lines extrafields + if (is_array($extralabelslines) && count($extralabelslines)>0) { + $colspan= empty($conf->productbatch->enabled) ? 5 : 6; + $line = new ExpeditionLigne($db); + $line->fetch_optionals($lines[$i]->id); + print ''; + if ($action == 'editline' && $lines[$i]->id == $line_id) + { + print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); + } + else + { + print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); + } + print ''; } - print ''; } } diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index cb058e44598..bbf990f2ec6 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -42,6 +42,8 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) requi // Load translation files required by the page $langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm')); +$hookmanager->initHooks(array('ordershipmentcard')); + $id=GETPOST('id','int'); // id of order $ref= GETPOST('ref','alpha'); $action=GETPOST('action','alpha'); @@ -613,6 +615,7 @@ if ($id > 0 || ! empty($ref)) $sql.= " cd.qty,"; $sql.= ' cd.date_start,'; $sql.= ' cd.date_end,'; + $sql.= ' cd.special_code,'; $sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc'; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; @@ -648,164 +651,169 @@ if ($id > 0 || ! empty($ref)) { $objp = $db->fetch_object($resql); + $parameters = array('i' => $i, 'line' => $objp, 'num' => $num); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - // Show product and description - $type=isset($objp->type)?$objp->type:$objp->product_type; - - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($objp->date_start)) $type=1; - if (! empty($objp->date_end)) $type=1; - - print ''; - - // Product label - if ($objp->fk_product > 0) + if(empty($reshook)) { - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + // Show product and description + $type=isset($objp->type)?$objp->type:$objp->product_type; + + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($objp->date_start)) $type=1; + if (! empty($objp->date_end)) $type=1; + + print ''; + + // Product label + if ($objp->fk_product > 0) { - $object->fetch_thirdparty(); - - $prod = new Product($db); - $prod->id = $objp->fk_product; - $prod->entity = $objp->entity; - $prod->getMultiLangs(); - - $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + $object->fetch_thirdparty(); + + $prod = new Product($db); + $prod->id = $objp->fk_product; + $prod->entity = $objp->entity; + $prod->getMultiLangs(); + + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if (empty($newlang)) $newlang=$object->thirdparty->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; + } + else + $label = (! empty($objp->label)?$objp->label:$objp->product_label); + + print ''; + print ''; // ancre pour retourner sur la ligne + + // Show product and description + $product_static->type=$type; + $product_static->id=$objp->fk_product; + $product_static->ref=$objp->ref; + $product_static->entity = $objp->entity; + $text=$product_static->getNomUrl(1); + $text.= ' - '.$label; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'
'; + $description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); + print $form->textwithtooltip($text,$description,3,'','',$i); + + // Show range + print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end)); + + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + print ($objp->description && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; } - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; + print ''; } else - $label = (! empty($objp->label)?$objp->label:$objp->product_label); - - print ''; - print ''; // ancre pour retourner sur la ligne - - // Show product and description - $product_static->type=$type; - $product_static->id=$objp->fk_product; - $product_static->ref=$objp->ref; - $product_static->entity = $objp->entity; - $text=$product_static->getNomUrl(1); - $text.= ' - '.$label; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'
'; - $description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); - print $form->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end)); - - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print ($objp->description && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; + print ""; + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + + if (! empty($objp->label)) { + $text.= ' '.$objp->label.''; + print $form->textwithtooltip($text,$objp->description,3,'','',$i); + } else { + print $text.' '.nl2br($objp->description); + } + + // Show range + print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end)); + print "\n"; } - print ''; - } - else - { - print ""; - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); + // Qty ordered + print '' . $objp->qty . ''; - if (! empty($objp->label)) { - $text.= ' '.$objp->label.''; - print $form->textwithtooltip($text,$objp->description,3,'','',$i); - } else { - print $text.' '.nl2br($objp->description); - } - - // Show range - print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end)); - print "\n"; - } - - // Qty ordered - print '' . $objp->qty . ''; - - // Qty already shipped - $qtyProdCom=$objp->qty; - print ''; - // Nb of sending products for this line of order - $qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0); - print $qtyAlreadyShipped; - print ''; - - // Qty remains to ship - print ''; - if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped; - $toBeShippedTotal += $toBeShipped[$objp->fk_product]; - print $toBeShipped[$objp->fk_product]; - } - else - { - print '0 ('.$langs->trans("Service").')'; - } - print ''; - - if ($objp->fk_product > 0) - { - $product = new Product($db); - $product->fetch($objp->fk_product); - $product->load_stock('warehouseopen'); - } - - if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && ! empty($conf->stock->enabled)) - { + // Qty already shipped + $qtyProdCom=$objp->qty; print ''; - print $product->stock_reel; - if ($product->stock_reel < $toBeShipped[$objp->fk_product]) + // Nb of sending products for this line of order + $qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0); + print $qtyAlreadyShipped; + print ''; + + // Qty remains to ship + print ''; + if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - print ' '.img_warning($langs->trans("StockTooLow")); + $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped; + $toBeShippedTotal += $toBeShipped[$objp->fk_product]; + print $toBeShipped[$objp->fk_product]; + } + else + { + print '0 ('.$langs->trans("Service").')'; } print ''; - } - else - { - print ' '; - } - print "\n"; - // Show subproducts lines - if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS)) - { - // Set tree of subproducts in product->sousprods - $product->get_sousproduits_arbo(); - //var_dump($product->sousprods);exit; - - // Define a new tree with quantiies recalculated - $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); - //var_dump($prods_arbo); - if (count($prods_arbo) > 0) + if ($objp->fk_product > 0) { - foreach($prods_arbo as $key => $value) + $product = new Product($db); + $product->fetch($objp->fk_product); + $product->load_stock('warehouseopen'); + } + + if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && ! empty($conf->stock->enabled)) + { + print ''; + print $product->stock_reel; + if ($product->stock_reel < $toBeShipped[$objp->fk_product]) { - $img=''; - if ($value['stock'] < $value['stock_alert']) + print ' '.img_warning($langs->trans("StockTooLow")); + } + print ''; + } + else + { + print ' '; + } + print "\n"; + + // Show subproducts lines + if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS)) + { + // Set tree of subproducts in product->sousprods + $product->get_sousproduits_arbo(); + //var_dump($product->sousprods);exit; + + // Define a new tree with quantiies recalculated + $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); + //var_dump($prods_arbo); + if (count($prods_arbo) > 0) + { + foreach($prods_arbo as $key => $value) { - $img=img_warning($langs->trans("StockTooLow")); + $img=''; + if ($value['stock'] < $value['stock_alert']) + { + $img=img_warning($langs->trans("StockTooLow")); + } + print '      -> '.$value['fullpath'].' ('.$value['nb'].')'; + print ' '.$value['nb_total'].''; + print ' '; + print ' '; + print ''.$value['stock'].' '.$img.''."\n"; } - print '      -> '.$value['fullpath'].' ('.$value['nb'].')'; - print ' '.$value['nb_total'].''; - print ' '; - print ' '; - print ''.$value['stock'].' '.$img.''."\n"; } } } - $i++; } $db->free($resql); diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index d6cefb24d83..2e1c9cb47c1 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -346,7 +346,7 @@ else print ''; print ''; - dol_fiche_head($head, 'delivery', $langs->trans("Shipment"), 0, 'sending'); + dol_fiche_head($head, 'delivery', $langs->trans("Shipment"), -1, 'sending'); /* * Confirmation de la suppression @@ -607,87 +607,85 @@ else $var=true; while ($i < $num_prod) { + $parameters = array('i' => $i, 'line' => $object->lines[$i], 'num' => $num_prod); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if(empty($reshook)) { - print ''; - if ($object->lines[$i]->fk_product > 0) - { - $product = new Product($db); - $product->fetch($object->lines[$i]->fk_product); + print ''; + if ($object->lines[$i]->fk_product > 0) { + $product = new Product($db); + $product->fetch($object->lines[$i]->fk_product); - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) - { - $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + // Define output language + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; + if (empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $label = (!empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label; + } else + $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label); + + print ''; + + // Affiche ligne produit + $text = ''; + if ($object->lines[$i]->fk_product_type == 1) $text .= img_object($langs->trans('ShowService'), 'service'); + else $text .= img_object($langs->trans('ShowProduct'), 'product'); + $text .= ' ' . $object->lines[$i]->product_ref . ''; + $text .= ' - ' . $label; + $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($object->lines[$i]->description)); + //print $description; + print $form->textwithtooltip($text, $description, 3, '', '', $i); + print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end); + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { + print (!empty($object->lines[$i]->description) && $object->lines[$i]->description != $object->lines[$i]->product_label) ? '
' . dol_htmlentitiesbr($object->lines[$i]->description) : ''; + } + } else { + print ""; + if ($object->lines[$i]->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service'); + else $text = img_object($langs->trans('Product'), 'product'); + + if (!empty($object->lines[$i]->label)) { + $text .= ' ' . $object->lines[$i]->label . ''; + print $form->textwithtooltip($text, $object->lines[$i]->description, 3, '', '', $i); + } else { + print $text . ' ' . nl2br($object->lines[$i]->description); } - $label = (! empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label; - } - else - $label = ( ! empty($object->lines[$i]->label)?$object->lines[$i]->label:$object->lines[$i]->product_label); - - print ''; - - // Affiche ligne produit - $text = ''; - if ($object->lines[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service'); - else $text.= img_object($langs->trans('ShowProduct'),'product'); - $text.= ' '.$object->lines[$i]->product_ref.''; - $text.= ' - '.$label; - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($object->lines[$i]->description)); - //print $description; - print $form->textwithtooltip($text,$description,3,'','',$i); - print_date_range($object->lines[$i]->date_start,$object->lines[$i]->date_end); - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) - { - print (! empty($object->lines[$i]->description) && $object->lines[$i]->description!=$object->lines[$i]->product_label)?'
'.dol_htmlentitiesbr($object->lines[$i]->description):''; - } - } - else - { - print ""; - if ($object->lines[$i]->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - - if (! empty($object->lines[$i]->label)) { - $text.= ' '.$object->lines[$i]->label.''; - print $form->textwithtooltip($text,$object->lines[$i]->description,3,'','',$i); - } else { - print $text.' '.nl2br($object->lines[$i]->description); + print_date_range($objp->date_start, $objp->date_end); + print "\n"; } - print_date_range($objp->date_start,$objp->date_end); - print "\n"; - } + print '' . $object->lines[$i]->qty_asked . ''; + print '' . $object->lines[$i]->qty_shipped . ''; - print ''.$object->lines[$i]->qty_asked.''; - print ''.$object->lines[$i]->qty_shipped.''; + print ""; - print ""; - - //Display lines extrafields - if (is_array($extralabelslines) && count($extralabelslines)>0) { - $colspan=2; - $mode = ($object->statut == 0) ? 'edit' : 'view'; - $line = new LivraisonLigne($db); - $line->fetch_optionals($object->lines[$i]->id); - if ($action = 'create_delivery') { - $srcLine = new ExpeditionLigne($db); - $expeditionLineExtrafields = new Extrafields($db); - $expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element); - $srcLine->fetch_optionals($expedition->lines[$i]->id); - $line->array_options = array_merge($line->array_options, $srcLine->array_options); + //Display lines extrafields + if (is_array($extralabelslines) && count($extralabelslines) > 0) { + $colspan = 2; + $mode = ($object->statut == 0) ? 'edit' : 'view'; + $line = new LivraisonLigne($db); + $line->fetch_optionals($object->lines[$i]->id); + if ($action = 'create_delivery') { + $srcLine = new ExpeditionLigne($db); + $expeditionLineExtrafields = new Extrafields($db); + $expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element); + $srcLine->fetch_optionals($expedition->lines[$i]->id); + $line->array_options = array_merge($line->array_options, $srcLine->array_options); + } + print ''; + print $line->showOptionals($extrafieldsline, $mode, array('style' => $bc[$var], 'colspan' => $colspan), $i); + print ''; } - print ''; - print $line->showOptionals($extrafieldsline, $mode, array('style'=>$bc[$var], 'colspan'=>$colspan),$i); - print ''; } $i++; From a524bbc5c692523fe6fcfdb1ab609b21adbf5ef2 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 13 Mar 2019 15:58:58 +0100 Subject: [PATCH 028/179] FIX : when we create deposit with multi tva, we mustn't add line if amount = 0 (example when we have a 100% reduc on one of origin invoice line) --- htdocs/compta/facture/card.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b379bf31602..dcf167da515 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1218,6 +1218,9 @@ if (empty($reshook)) foreach ($amountdeposit as $tva => $amount) { + + if(empty($amount)) continue; + $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); $descline = $langs->trans('Deposit'); $descline.= ' - '.$langs->trans($arraylist[$typeamount]); From d8599b52d97077a89b66b5ffa08f073baad34396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Mar 2019 08:19:22 +0100 Subject: [PATCH 029/179] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b643f1dfcb9..66cff43e562 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1056,12 +1056,12 @@ class FormMail extends Form //if (! $this->errorstomail) $this->errorstomail=$this->frommail; $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); if ($this->witherrorstoreadonly) { - $out.= ''.$langs->trans("MailErrorsTo").''; - $out = ''; + $out= ''.$langs->trans("MailErrorsTo").''; + $out.= ''; $out.= $errorstomail; $out.= "\n"; } else { - $out.= ''.$langs->trans("MailErrorsTo").''; + $out= ''.$langs->trans("MailErrorsTo").''; $out.= ''; $out.= "\n"; } From 7dcdbe64773aa8361fb4829a4c434e089f88f911 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:04:57 +0100 Subject: [PATCH 030/179] update with html5 compliant code --- htdocs/bom/bom_list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index b0ffd62155c..baa2ced0c4a 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -387,7 +387,7 @@ $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print ''; +print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print ''; @@ -509,7 +509,7 @@ if (isset($totalarray['pos'])) while ($i < $totalarray['nbfield']) { $i++; - if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).''; + if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).''; else { if ($i == 1) From 43b827aae77054f3c9ef0e204f3f16d60492c540 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:07:26 +0100 Subject: [PATCH 031/179] update with html5 compliant code --- htdocs/comm/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index cfe6ff817f7..c4ec266d454 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -7,7 +7,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Alexandre Spangaro - * Copyright (C) 2015-2019 Frédéric France + * Copyright (C) 2015-2019 Frédéric France * Copyright (C) 2015 Marcos García * * This program is free software; you can redistribute it and/or modify @@ -386,7 +386,7 @@ if ($object->id > 0) print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; } else { print ''; - print ''; - $texte.= ''; + $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; // Parametrage du prefix suppliers $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= '
'; print $langs->trans("CustomerRelativeDiscountShort"); - print ''; + print ''; if ($user->rights->societe->creer && !$user->societe_id > 0) { print ''.img_edit($langs->trans("Modify")).''; @@ -400,7 +400,7 @@ if ($object->id > 0) print ''; print ''; // Opp status - print ''; // Opp percent - print ''; // Status - print ''; + print ''; print ''; } @@ -887,7 +887,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), - 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>40, 'align'=>'center'), + 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>40, 'class'=>'center'), ); // Extra fields if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) From 0832e9873caf6b7909ee292cbf79456f372c8060 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:10:41 +0100 Subject: [PATCH 033/179] update with html5 compliant code --- htdocs/core/lib/doleditor.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/doleditor.lib.php b/htdocs/core/lib/doleditor.lib.php index ef58497ccdd..e2c863cd2ba 100644 --- a/htdocs/core/lib/doleditor.lib.php +++ b/htdocs/core/lib/doleditor.lib.php @@ -64,7 +64,7 @@ function show_skin($fuser, $edit = 0) // Title print ''; - print '
'; print $langs->trans("CustomerAbsoluteDiscountShort"); - print ''; + print ''; if ($user->rights->societe->creer && !$user->societe_id > 0) { print ''.img_edit($langs->trans("Modify")).''; From 63b1a1459bd9954f7726bfc7ff1fa50c48ad8984 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:09:54 +0100 Subject: [PATCH 032/179] update with html5 compliant code --- htdocs/core/lib/company.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 94707467166..1dda075afe6 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -800,15 +800,15 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel } print ''; + print ''; if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code); print ''; + print ''; if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%'; print ''.$projecttmp->getLibStatut(5).''.$projecttmp->getLibStatut(5).'
'.$langs->trans("DefaultSkin").''; + print ''; $url='http://ckeditor.com/addons/skins/all'; /*print ''; print $langs->trans('DownloadMoreSkins'); @@ -84,7 +84,7 @@ function show_skin($fuser, $edit = 0) // print '
'; - print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (! empty($conf->stock->enabled)) { print ''; @@ -236,8 +236,8 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') if (! empty($conf->livraison_bon->enabled)) { print ''; - //print ''; - print ''; + //print ''; + print ''; } print "\n"; @@ -248,7 +248,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''; // Sending id - print ''; @@ -324,16 +324,16 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print "\n"; } - //print ''; + //print ''; // Date creation - print ''; + print ''; // Date shipping creation - print ''; + print ''; // Qty shipped - print ''; + print ''; // Warehouse if (! empty($conf->stock->enabled)) @@ -403,13 +403,13 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') //print ''.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.''; print ''; // Qty received - //print ''; // Date shipping real - print ''; } From d506cf7700655e97d699f8804e1d4bcbb835ad80 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:21:54 +0100 Subject: [PATCH 037/179] update with html5 compliant code --- htdocs/core/lib/treeview.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index eacf0386eb5..34683e5b29f 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -171,7 +171,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset print '   '; print $tab[$x]['title']; print '  (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; - print '
'; + print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; // Customer proposals @@ -339,11 +339,11 @@ function show_stats_for_company($product, $socid) $langs->load("propal"); print ''; print ''; @@ -357,11 +357,11 @@ function show_stats_for_company($product, $socid) $langs->load("propal"); print ''; print ''; @@ -375,11 +375,11 @@ function show_stats_for_company($product, $socid) $langs->load("orders"); print ''; print ''; @@ -393,11 +393,11 @@ function show_stats_for_company($product, $socid) $langs->load("orders"); print ''; print ''; @@ -411,11 +411,11 @@ function show_stats_for_company($product, $socid) $langs->load("bills"); print ''; print ''; @@ -429,11 +429,11 @@ function show_stats_for_company($product, $socid) $langs->load("bills"); print ''; print ''; @@ -448,11 +448,11 @@ function show_stats_for_company($product, $socid) $langs->load("contracts"); print ''; print ''; From 38822a9bb13a2110b5a26cb26cb5e3812d89191a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:18:44 +0100 Subject: [PATCH 035/179] update with html5 compliant code --- htdocs/core/lib/project.lib.php | 78 ++++++++++++++++----------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 83072279268..92df28d9922 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -489,12 +489,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print "\n"; // Date start - print ''; // Date end - print ''; // Time spent - print ''; // Progress calculated (Note: ->duration is time spent) - print ''; // Progress declared - print ''; + print ''; } print "\n"; @@ -605,15 +605,15 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; print ''; print ''; - print ''; - print ''; - print ''; print ''; @@ -773,7 +773,7 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec print "\n"; // Date - print ''; @@ -794,7 +794,7 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec } // Hour - print ''; @@ -804,7 +804,7 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; // Duration - print ''; // Note - print ''; // Warning - print '\n"; // Planned Workload - print ''; // Progress declared % - print ''; // Time spent by everybody - print '\n"; // Time spent by user - print ''; @@ -1097,13 +1097,13 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print ''; // Note - print ''; // Warning - print '\n"; // Planned Workload - print ''; // Progress declared % - print ''; // Time spent by everybody - print '\n"; // Time spent by user - print ''; if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print ''; - print ''; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print ''; + print ''; $plannedworkload=$objp->planned_workload; $total_plannedworkload+=$plannedworkload; if (! in_array('plannedworkload', $hiddenfields)) { - print ''; + print ''; } if (! in_array('declaredprogress', $hiddenfields)) { $declaredprogressworkload=$objp->declared_progess_workload; $total_declaredprogressworkload+=$declaredprogressworkload; - print ''; } } - print ''; + print ''; print "\n"; $total_task = $total_task + $objp->nb; @@ -1673,14 +1673,14 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print '"; if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print ''; - print ''; + print ''; + print ''; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print ''; - if (! in_array('plannedworkload', $hiddenfields)) print ''; - if (! in_array('declaredprogress', $hiddenfields)) print ''; + print ''; + if (! in_array('plannedworkload', $hiddenfields)) print ''; + if (! in_array('declaredprogress', $hiddenfields)) print ''; } print ''; print ''; @@ -1702,7 +1702,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print '
'; $i=0; foreach($dirskins as $dir) From 6984cd25d8025ca0b15ae253840407402535c800 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:11:43 +0100 Subject: [PATCH 034/179] update with html5 compliant code --- htdocs/core/lib/product.lib.php | 50 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 162bee68128..9592cd7fb16 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -324,10 +324,10 @@ function show_stats_for_company($product, $socid) $nblines = 0; print '
'.$langs->trans("Referers").''.$langs->trans("NbOfThirdParties").''.$langs->trans("NbOfObjectReferers").''.$langs->trans("TotalQuantity").''.$langs->trans("Referers").''.$langs->trans("NbOfThirdParties").''.$langs->trans("NbOfObjectReferers").''.$langs->trans("TotalQuantity").'
'; print ''.img_object('', 'propal').' '.$langs->trans("Proposals").''; - print ''; + print ''; print $product->stats_propale['customers']; - print ''; + print ''; print $product->stats_propale['nb']; - print ''; + print ''; print $product->stats_propale['qty']; print '
'; print ''.img_object('', 'propal').' '.$langs->trans("SupplierProposals").''; - print ''; + print ''; print $product->stats_proposal_supplier['suppliers']; - print ''; + print ''; print $product->stats_proposal_supplier['nb']; - print ''; + print ''; print $product->stats_proposal_supplier['qty']; print '
'; print ''.img_object('', 'order').' '.$langs->trans("CustomersOrders").''; - print ''; + print ''; print $product->stats_commande['customers']; - print ''; + print ''; print $product->stats_commande['nb']; - print ''; + print ''; print $product->stats_commande['qty']; print '
'; print ''.img_object('', 'order').' '.$langs->trans("SuppliersOrders").''; - print ''; + print ''; print $product->stats_commande_fournisseur['suppliers']; - print ''; + print ''; print $product->stats_commande_fournisseur['nb']; - print ''; + print ''; print $product->stats_commande_fournisseur['qty']; print '
'; print ''.img_object('', 'bill').' '.$langs->trans("CustomersInvoices").''; - print ''; + print ''; print $product->stats_facture['customers']; - print ''; + print ''; print $product->stats_facture['nb']; - print ''; + print ''; print $product->stats_facture['qty']; print '
'; print ''.img_object('', 'bill').' '.$langs->trans("SuppliersInvoices").''; - print ''; + print ''; print $product->stats_facture_fournisseur['suppliers']; - print ''; + print ''; print $product->stats_facture_fournisseur['nb']; - print ''; + print ''; print $product->stats_facture_fournisseur['qty']; print '
'; print ''.img_object('', 'contract').' '.$langs->trans("Contracts").''; - print ''; + print ''; print $product->stats_contrat['customers']; - print ''; + print ''; print $product->stats_contrat['nb']; - print ''; + print ''; print $product->stats_contrat['qty']; print '
'; + print ''; print dol_print_date($lines[$i]->date_start, 'dayhour'); print ''; + print ''; $taskstatic->projectstatus = $lines[$i]->projectstatus; $taskstatic->progress = $lines[$i]->progress; $taskstatic->fk_statut = $lines[$i]->status; @@ -509,7 +509,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; // Planned Workload (in working hours) - print ''; + print ''; $fullhour=convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); $workingdelay=convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks if ($lines[$i]->planned_workload != '') @@ -522,7 +522,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; + print ''; if ($showlineingray) print ''; else print ''; if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); @@ -532,7 +532,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; + print ''; if ($lines[$i]->planned_workload || $lines[$i]->duration) { if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %'; @@ -541,7 +541,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; + print ''; if ($lines[$i]->progress != '') { print $lines[$i]->progress.' %'; @@ -572,7 +572,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Tick to drag and drop if ($addordertick) { - print '  
'; + print ''; print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); print ''; + print ''; if ($projectidfortotallink > 0) print ''; print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); if ($projectidfortotallink > 0) print ''; print ''; + print ''; if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2).' %'; print ''; + print ''; print dol_print_date($lines[$i]->timespent_datehour, 'day'); print ''; + print ''; print dol_print_date($lines[$i]->timespent_datehour, 'hour'); print ''; + print ''; $dayWorkLoad = $lines[$i]->timespent_duration; $totalforeachline[$preselectedday]+=$lines[$i]->timespent_duration; @@ -825,14 +825,14 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec print ''; + print ''; print ''; print ''; + print ''; /*if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); else if ($disabledtask) { @@ -1001,18 +1001,18 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print "'; + print ''; if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); else print '--:--'; print ''; + print ''; print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); 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) { @@ -1024,7 +1024,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print "'; + print ''; $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); else print '--:--'; @@ -1047,7 +1047,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr } // Form to add new time - print ''; + print ''; $tableCell = $form->selectDate($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, $disabledtask); print $tableCell; print ''; + print ''; print ''; print ''; + print ''; if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); elseif ($disabledtask) { @@ -1291,18 +1291,18 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ print "'; + print ''; if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); else print '--:--'; print ''; + print ''; print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); 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) { @@ -1314,7 +1314,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ print "'; + print ''; $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); else print '--:--'; @@ -1381,7 +1381,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ } // Warning - print ''; + print ''; if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); elseif ($disabledtask) { @@ -1629,36 +1629,36 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; + print ''; if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); print ''; + print ''; $code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code'); if ($code) print $langs->trans("OppStatus".$code); print ''.$objp->nb.''.$objp->nb.''.($plannedworkload?convertSecondToTime($plannedworkload):'').''.($plannedworkload?convertSecondToTime($plannedworkload):'').''; + print ''; //print $objp->planned_workload.'-'.$objp->declared_progess_workload."
"; print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload, 0).'%':''); print '
'.$projectstatic->getLibStatut(3).''.$projectstatic->getLibStatut(3).'
'.$langs->trans("Total")."'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).''.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).''.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).''.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).''.$total_task.''.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').''.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload, 0).'%':'').''.$total_task.''.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').''.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload, 0).'%':'').'
'; print ''; print ''; - print '\n"; print '
'.$langs->trans("Year").''; + print ''; print "
'; } From 68c6c0513d42f1c4abf19bd4ae247f58d2c20009 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:20:32 +0100 Subject: [PATCH 036/179] update with html5 compliant code --- htdocs/core/lib/sendings.lib.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index cc7d2c95115..97d8a318e5c 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -220,9 +220,9 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') //print '
'.$langs->trans("QtyOrdered").''.$langs->trans("SendingSheet").''.$langs->trans("Description").''.$langs->trans("DateCreation").''.$langs->trans("DateDeliveryPlanned").''.$langs->trans("QtyPreparedOrShipped").''.$langs->trans("DateCreation").''.$langs->trans("DateDeliveryPlanned").''.$langs->trans("QtyPreparedOrShipped").''.$langs->trans("Warehouse").''.$langs->trans("DeliveryOrder").''.$langs->trans("QtyReceived").''.$langs->trans("DeliveryDate").''.$langs->trans("QtyReceived").''.$langs->trans("DeliveryDate").'
'; + print ''; print ''.img_object($langs->trans("ShowSending"), 'sending').' '.$objp->exp_ref.''; print ''.$objp->qty_asked.''.$objp->qty_asked.''.dol_print_date($db->jdate($objp->date_creation), 'day').''.dol_print_date($db->jdate($objp->date_creation), 'day').''.dol_print_date($db->jdate($objp->date_delivery), 'day').''.dol_print_date($db->jdate($objp->date_delivery), 'day').''.$objp->qty_shipped.''.$objp->qty_shipped.''; + //print ''; // TODO No solution for the moment to link a line det of receipt with a line det of shipping, // so no way to know the qty received for this line of shipping. //print $langs->trans("FeatureNotYetAvailable"); //print ''; + print ''; print dol_print_date($receiving->date_delivery, 'day'); print ''; + print ''; print $tab[$x]['buttons']; print '
'; } @@ -207,7 +207,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset print $tab[$x]['title']; print ''; print '  (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; - print '
'; + print ''; print $tab[$x]['buttons']; print '
'; } From 27b7ec82025c4335897530e23cdeb79f74a9f612 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:24:17 +0100 Subject: [PATCH 038/179] update with html5 compliant code --- htdocs/core/lib/usergroups.lib.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index de85a573cab..8e45308d3e8 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -343,14 +343,14 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("DefaultSkin").''.$conf->global->MAIN_THEME.' '.$langs->trans("UsePersonalValue").' '.$langs->trans("UsePersonalValue").' 
'.$langs->trans("DefaultSkin").''; + print ''; $url='https://www.dolistore.com/lang-en/4-skins'; if (preg_match('/fr/i', $langs->defaultlang)) $url='https://www.dolistore.com/fr/4-themes'; //if (preg_match('/es/i',$langs->defaultlang)) $url='http://www.dolistore.com/lang-es/4-themes'; @@ -372,7 +372,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print '
'; - print ''; - $texte.= ''; + $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; From b4a9b3aa205bdd8443017b8485d5afa93a487e8a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:30:08 +0100 Subject: [PATCH 046/179] update with html5 compliant code --- htdocs/core/modules/project/mod_project_universal.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index f987d4d3b32..be8a9c3f362 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -83,9 +83,9 @@ class mod_project_universal extends ModeleNumRefProjects // Parametrage du prefix $texte.= ''; - $texte.= ''; + $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; From f13d52083088429f42f98fe4a84de686860a62da Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:30:41 +0100 Subject: [PATCH 047/179] update with html5 compliant code --- htdocs/core/modules/propale/mod_propale_saphir.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 972bb94cb64..ddf856d5003 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -85,9 +85,9 @@ class mod_propale_saphir extends ModeleNumRefPropales // Parametrage du prefix $texte.= ''; - $texte.= ''; + $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; From f71769e0e668a7b5c6750904ae377b192af88f57 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:31:08 +0100 Subject: [PATCH 048/179] update with html5 compliant code --- htdocs/core/modules/reception/mod_reception_moonstone.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/reception/mod_reception_moonstone.php b/htdocs/core/modules/reception/mod_reception_moonstone.php index 6f7d66f8ef3..84b35cb7771 100644 --- a/htdocs/core/modules/reception/mod_reception_moonstone.php +++ b/htdocs/core/modules/reception/mod_reception_moonstone.php @@ -60,8 +60,8 @@ class mod_reception_moonstone extends ModelNumRefReception $tooltip.=$langs->trans("GenericMaskCodes5"); $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= '
'; + 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 ''; @@ -857,7 +857,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print ''; print ''; print ''; - print ''; + print ''; print ''; From 6b878a2c64e3a9070958711337da69c8c9df7b59 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:25:21 +0100 Subject: [PATCH 039/179] update with html5 compliant code --- htdocs/core/modules/dons/html_cerfafr.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/dons/html_cerfafr.html b/htdocs/core/modules/dons/html_cerfafr.html index 614f22cf998..65408d80863 100644 --- a/htdocs/core/modules/dons/html_cerfafr.html +++ b/htdocs/core/modules/dons/html_cerfafr.html @@ -275,7 +275,7 @@
'; $i=0; foreach($dirthemes as $dir) @@ -432,7 +432,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("TopMenuDisableImages").''.($conf->global->THEME_TOPMENU_DISABLE_IMAGE?$conf->global->THEME_TOPMENU_DISABLE_IMAGE:$langs->trans("Default")).'conf->THEME_ELDY_TEXTLINK)?" checked":""); + print 'conf->THEME_ELDY_TEXTLINK)?" checked":""); print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; @@ -477,7 +477,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("TopMenuBackgroundColor").''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); + print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; @@ -524,7 +524,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("TopMenuBackgroundColor").''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); + print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; @@ -573,7 +573,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("TopMenuBackgroundColor").''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_VERMENU_BACK1:$langs->trans("Default")).'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); + print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; @@ -763,7 +763,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("TopMenuBackgroundColor").''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TEXTLINK:$langs->trans("Default")).'conf->THEME_ELDY_TEXTLINK)?" checked":""); + print 'conf->THEME_ELDY_TEXTLINK)?" checked":""); print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; @@ -814,7 +814,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("HighlightLinesOnMouseHover").'global->THEME_ELDY_USE_HOVER?" checked":"").'> '.$langs->trans("UsePersonalValue").' '.$langs->trans("UsePersonalValue").''; print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; print '
'.$langs->trans("HighlightLinesOnMouseHover").'global->THEME_ELDY_USE_HOVER?" checked":"").'> '.$langs->trans("UsePersonalValue").' '.$langs->trans("UsePersonalValue").''; print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; print '
- '; - $texte.= ''; + $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; From 310670b3f606fc1f17b9e4f04ffcce35a52f37ad Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:27:54 +0100 Subject: [PATCH 043/179] update with html5 compliant code --- htdocs/core/modules/payment/mod_payment_ant.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/payment/mod_payment_ant.php b/htdocs/core/modules/payment/mod_payment_ant.php index 19e74cf3c19..2f3114bfd09 100644 --- a/htdocs/core/modules/payment/mod_payment_ant.php +++ b/htdocs/core/modules/payment/mod_payment_ant.php @@ -82,9 +82,9 @@ class mod_payment_ant extends ModeleNumRefPayments // Parametrage du prefix $texte.= ''; - $texte.= ''; + $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; From 6c4070eb87bcda41f293a73cf715f8767574a874 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:28:36 +0100 Subject: [PATCH 044/179] update with html5 compliant code --- htdocs/core/modules/product/mod_codeproduct_elephant.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index 97a00a14575..e7e20db532f 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -113,15 +113,15 @@ class mod_codeproduct_elephant extends ModeleProductCode // Parametrage du prefix customers $texte.= ''; - $texte.= ''; + $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; // Parametrage du prefix suppliers $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= '
+ '; - $texte.= ''; + $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; From af4edbba2b11a012cbbf0f81378d0f1c743f580f Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:26:43 +0100 Subject: [PATCH 041/179] update with html5 compliant code --- htdocs/core/modules/holiday/mod_holiday_immaculate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index 8c6fd9ebe97..9d1fa644c0a 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -82,8 +82,8 @@ class mod_holiday_immaculate extends ModelNumRefHolidays $tooltip.=$langs->trans("GenericMaskCodes5"); $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= '
Date et signature

From d21dbe915b17cc7ed9cc477d07b1083d9ae44d3e Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:26:08 +0100 Subject: [PATCH 040/179] update with html5 compliant code --- htdocs/core/modules/fichinter/mod_arctic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index 25b98473238..db7b2febbb2 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -84,9 +84,9 @@ class mod_arctic extends ModeleNumRefFicheinter // Parametrage du prefix $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'  '.$form->textwithpicto('', $tooltip, 1, 1).' 
'; $texte.= ''; From f082bd3e964ea243422c8c867d2b703dacbb3b02 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:27:16 +0100 Subject: [PATCH 042/179] update with html5 compliant code --- htdocs/core/modules/livraison/mod_livraison_saphir.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/livraison/mod_livraison_saphir.php b/htdocs/core/modules/livraison/mod_livraison_saphir.php index 2fc2e16d7fd..b8f00725858 100644 --- a/htdocs/core/modules/livraison/mod_livraison_saphir.php +++ b/htdocs/core/modules/livraison/mod_livraison_saphir.php @@ -83,9 +83,9 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder // Parametrage du prefix $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").' ('.$langs->trans("ServiceCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).'
'; From 5977cdad2612c97261781e833607d94598f67b81 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:29:16 +0100 Subject: [PATCH 045/179] update with html5 compliant code --- htdocs/core/modules/project/task/mod_task_universal.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index f1d295802a9..a9dc2846ad6 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -83,9 +83,9 @@ class mod_task_universal extends ModeleNumRefTask // Parametrage du prefix $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'  '.$form->textwithpicto('', $tooltip, 1, 1).' 
'; $texte.= ''; From 80858b39d9e7b267ee37afd61cbc58e50b103ca4 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:31:40 +0100 Subject: [PATCH 049/179] update with html5 compliant code --- htdocs/core/modules/societe/mod_codeclient_elephant.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index f8d4f137048..4be4ea5d50e 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -114,15 +114,15 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode // Parametrage du prefix customers $texte.= '
'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).'
'; From ad9f75d3e9f6d8e090aa8a2af2dfef6c3216229f Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:32:26 +0100 Subject: [PATCH 050/179] update with html5 compliant code --- .../supplier_invoice/mod_facture_fournisseur_tulip.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index 7f85cbe5bb6..8ab95ab3336 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -93,28 +93,28 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices // Parametrage du prefix $texte.= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')'; $texte.= ':'; - $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte.= '  '; + $texte.= '  '; $texte.= ''; // Parametrage du prefix des avoirs $texte.= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):'; - $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; $texte.= ''; if ($conf->global->MAIN_FEATURE_LEVEL >= 2) { // Parametrage du prefix des replacement $texte.= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):'; - $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; $texte.= ''; // Parametrage du prefix des acomptes $texte.= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):'; - $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; $texte.= ''; } From 9ee27936f728bf9374f90f3bd06fcbb72664fd90 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:33:00 +0100 Subject: [PATCH 051/179] update with html5 compliant code --- .../supplier_order/mod_commande_fournisseur_orchidee.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index 320c33dce7d..1d1bc920237 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -85,9 +85,9 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders // Parametrage du prefix $texte.= ''.$langs->trans("Mask").':'; - $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte.= '  '; + $texte.= '  '; $texte.= ''; From 756bdfc6a8a64c378b1aeac0107c32abb5fc61be Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:33:36 +0100 Subject: [PATCH 052/179] update with html5 compliant code --- .../supplier_payment/mod_supplier_payment_brodator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php index c1f6e003d6d..2b29a18e2f0 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php @@ -82,9 +82,9 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments // Parametrage du prefix $texte.= ''.$langs->trans("Mask").':'; - $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte.= '  '; + $texte.= '  '; $texte.= ''; From 719ecde6e901c378539ad4204ebe52ad26d04e04 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:34:04 +0100 Subject: [PATCH 053/179] update with html5 compliant code --- .../supplier_proposal/mod_supplier_proposal_saphir.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php index f8cd365d5a7..d3a9de6c72b 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php @@ -85,9 +85,9 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal // Parametrage du prefix $texte.= ''.$langs->trans("Mask").':'; - $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte.= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte.= '  '; + $texte.= '  '; $texte.= ''; From 3d65b887a7b192be4ab9e40dd7d14a88f21501cd Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 14:34:33 +0100 Subject: [PATCH 054/179] update with html5 compliant code --- htdocs/core/modules/ticket/mod_ticket_universal.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php index f33042aca67..deb7c4481cc 100644 --- a/htdocs/core/modules/ticket/mod_ticket_universal.php +++ b/htdocs/core/modules/ticket/mod_ticket_universal.php @@ -81,9 +81,9 @@ class mod_ticket_universal extends ModeleNumRefTicket // Parametrage du prefix $texte .= '' . $langs->trans("Mask") . ':'; - $texte .= '' . $form->textwithpicto('', $tooltip, 1, 1) . ''; + $texte .= '' . $form->textwithpicto('', $tooltip, 1, 1) . ''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; From 8bc795c05555cafaf08366e88d290dee0c16cabf Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 14 Mar 2019 15:19:38 +0100 Subject: [PATCH 055/179] Fix missing hook for export agenda --- htdocs/comm/action/class/actioncomm.class.php | 11 +++++++++++ htdocs/public/agenda/agendaexport.php | 2 ++ 2 files changed, 13 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index e5a90c86661..0205281f117 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1456,6 +1456,11 @@ class ActionComm extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; + + $parameters=array('filters' => $filters); + $reshook=$hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + // We must filter on assignement table if ($filters['logint']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; $sql.= " WHERE a.fk_action=c.id"; @@ -1501,7 +1506,13 @@ class ActionComm extends CommonObject elseif ($result < 0 || $condition == '=') $sql.= " AND ar.fk_element = 0"; } } + $sql.= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import + + $parameters=array('filters' => $filters); + $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + $sql.= " ORDER by datep"; //print $sql;exit; diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index 6e08f06d630..a69c940f7e2 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -106,6 +106,8 @@ if (empty($_GET["exportkey"]) || $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY != $_ exit; } +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks +$hookmanager->initHooks(array('agendaexport')); // Define filename with prefix on filters predica (each predica set must have on cache file) $shortfilename='dolibarrcalendar'; From 3ab5c3e6ab5df33ae2f2ff5ee2f802bb4f489be0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 16:03:37 +0100 Subject: [PATCH 056/179] FIX Edit of personalized groups --- htdocs/accountancy/admin/categories.php | 11 ++++++----- .../class/accountancycategory.class.php | 15 +++++++++++---- htdocs/langs/en_US/accountancy.lang | 3 ++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index decae324ac5..faba7fb1c62 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -60,7 +60,7 @@ $accountingcategory = new AccountancyCategory($db); // si ajout de comptes if (! empty($selectcpt)) { - $cpts = array (); + $cpts = array(); foreach ($selectcpt as $selectedoption) { if (! array_key_exists($selectedoption, $cpts)) $cpts[$selectedoption] = "'" . $selectedoption . "'"; @@ -71,13 +71,13 @@ if (! empty($selectcpt)) { if ($return<0) { setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors'); } else { - setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordModifiedSuccessfully'), null, 'mesgs'); } } if ($action == 'delete') { if ($cpt_id) { if ($accountingcategory->deleteCptCat($cpt_id)) { - setEventMessages($langs->trans('CategoryDeleted'), null, 'mesgs'); + setEventMessages($langs->trans('AccountRemovedFromGroup'), null, 'mesgs'); } else { setEventMessages($langs->trans('errors'), null, 'errors'); } @@ -173,8 +173,9 @@ if ($action == 'display' || $action == 'delete') { print '' . $cpt->label . ''; print ''; print ""; - print img_delete($langs->trans("DeleteFromCat")).' '; - print $langs->trans("DeleteFromCat").""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink'); + print ""; print ""; print "\n"; } diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 73cccdfd721..ae4b42c8e3c 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -514,7 +514,7 @@ class AccountancyCategory // extends CommonObject /** * Function to select accounting category of an accounting account present in chart of accounts * - * @param int $id Id category + * @param int $id Id of category to know which account to exclude * * @return int <0 if KO, 0 if not found, >0 if OK */ @@ -569,12 +569,13 @@ class AccountancyCategory // extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $sql = "SELECT aa.rowid,aa.account_number "; + $sql = "SELECT aa.rowid, aa.account_number"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; $sql .= " AND aa.entity = " . $conf->entity; + $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql $this->db->begin(); @@ -587,10 +588,16 @@ class AccountancyCategory // extends CommonObject return -1; } - while ( $obj = $this->db->fetch_object($resql)) + $accountincptsadded=array(); + while ($obj = $this->db->fetch_object($resql)) { - if (array_key_exists(length_accountg($obj->account_number), $cpts)) + $account_number_formated=length_accountg($obj->account_number); + if (! empty($accountincptsadded[$account_number_formated])) continue; + + if (array_key_exists($account_number_formated, $cpts)) { + $accountincptsadded[$account_number_formated]=1; + // We found an account number that is in list $cpts of account to add $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account"; $sql .= " SET fk_accounting_category=" . $id_cat; $sql .= " WHERE rowid=".$obj->rowid; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index fc2cb928903..30d97cc6e3e 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -256,7 +256,7 @@ NotYetAccounted=Not yet accounted in ledger ## Admin ApplyMassCategories=Apply mass categories -AddAccountFromBookKeepingWithNoCategories=Available account not yet in a personalized group +AddAccountFromBookKeepingWithNoCategories=Available account not yet in the personalized group CategoryDeleted=Category for the accounting account has been removed AccountingJournals=Accounting journals AccountingJournal=Accounting journal @@ -308,6 +308,7 @@ PredefinedGroups=Predefined groups WithoutValidAccount=Without valid dedicated account WithValidAccount=With valid dedicated account ValueNotIntoChartOfAccount=This value of accounting account does not exist into chart of account +AccountRemovedFromGroup=Account removed from group ## Dictionary Range=Range of accounting account From 5ccfba12106cc55d8101153a9310bf0659669da6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 16:03:37 +0100 Subject: [PATCH 057/179] FIX Edit of personalized groups Conflicts: htdocs/accountancy/admin/categories.php --- htdocs/accountancy/admin/categories.php | 13 +++++++------ .../class/accountancycategory.class.php | 15 +++++++++++---- htdocs/langs/en_US/accountancy.lang | 3 ++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 6e003738173..9b3ca9ebddc 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -60,8 +60,8 @@ $accountingcategory = new AccountancyCategory($db); // si ajout de comptes if (! empty($selectcpt)) { - $cpts = array (); - foreach ( $selectcpt as $selectedoption ) { + $cpts = array(); + foreach ($selectcpt as $selectedoption) { if (! array_key_exists($selectedoption, $cpts)) $cpts[$selectedoption] = "'" . $selectedoption . "'"; } @@ -71,13 +71,13 @@ if (! empty($selectcpt)) { if ($return<0) { setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors'); } else { - setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordModifiedSuccessfully'), null, 'mesgs'); } } if ($action == 'delete') { if ($cpt_id) { if ($accountingcategory->deleteCptCat($cpt_id)) { - setEventMessages($langs->trans('CategoryDeleted'), null, 'mesgs'); + setEventMessages($langs->trans('AccountRemovedFromGroup'), null, 'mesgs'); } else { setEventMessages($langs->trans('errors'), null, 'errors'); } @@ -173,8 +173,9 @@ if ($action == 'display' || $action == 'delete') { print '' . $cpt->label . ''; print ''; print ""; - print img_delete($langs->trans("DeleteFromCat")).' '; - print $langs->trans("DeleteFromCat").""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink'); + print ""; print ""; print "\n"; } diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index a6c9f09c7cb..f7421acba3c 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -514,7 +514,7 @@ class AccountancyCategory // extends CommonObject /** * Function to select accounting category of an accounting account present in chart of accounts * - * @param int $id Id category + * @param int $id Id of category to know which account to exclude * * @return int <0 if KO, 0 if not found, >0 if OK */ @@ -569,12 +569,13 @@ class AccountancyCategory // extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $sql = "SELECT aa.rowid,aa.account_number "; + $sql = "SELECT aa.rowid, aa.account_number"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; $sql .= " AND aa.entity = " . $conf->entity; + $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql $this->db->begin(); @@ -587,10 +588,16 @@ class AccountancyCategory // extends CommonObject return -1; } - while ( $obj = $this->db->fetch_object($resql)) + $accountincptsadded=array(); + while ($obj = $this->db->fetch_object($resql)) { - if (array_key_exists(length_accountg($obj->account_number), $cpts)) + $account_number_formated=length_accountg($obj->account_number); + if (! empty($accountincptsadded[$account_number_formated])) continue; + + if (array_key_exists($account_number_formated, $cpts)) { + $accountincptsadded[$account_number_formated]=1; + // We found an account number that is in list $cpts of account to add $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account"; $sql .= " SET fk_accounting_category=" . $id_cat; $sql .= " WHERE rowid=".$obj->rowid; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index e2f6083e6a6..31f3d5e264a 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -238,7 +238,7 @@ NotYetAccounted=Not yet accounted in ledger ## Admin ApplyMassCategories=Apply mass categories -AddAccountFromBookKeepingWithNoCategories=Available account not yet in a personalized group +AddAccountFromBookKeepingWithNoCategories=Available account not yet in the personalized group CategoryDeleted=Category for the accounting account has been removed AccountingJournals=Accounting journals AccountingJournal=Accounting journal @@ -287,6 +287,7 @@ PredefinedGroups=Predefined groups WithoutValidAccount=Without valid dedicated account WithValidAccount=With valid dedicated account ValueNotIntoChartOfAccount=This value of accounting account does not exist into chart of account +AccountRemovedFromGroup=Account removed from group ## Dictionary Range=Range of accounting account From 31e588dbab8a6a9d93793e0f934298de75c2f8f9 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 14 Mar 2019 16:13:32 +0100 Subject: [PATCH 058/179] fix hookmanager global --- htdocs/comm/action/class/actioncomm.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 0205281f117..fd91864af04 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1391,6 +1391,8 @@ class ActionComm extends CommonObject */ function build_exportfile($format,$type,$cachedelay,$filename,$filters) { + global $hookmanager; + // phpcs:enable global $conf,$langs,$dolibarr_main_url_root,$mysoc; From 8410d59182c558ecb36cbea899ca587c9af71444 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 16:16:50 +0100 Subject: [PATCH 059/179] FIX Missing field "In sale" in list --- htdocs/accountancy/admin/productaccount.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 246d3752f56..389dd8df7b8 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -65,6 +65,8 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); $btn_changeaccount = GETPOST('changeaccount', 'alpha'); $btn_changetype = GETPOST('changetype', 'alpha'); +if (empty($accounting_product_mode)) $accounting_product_mode='ACCOUNTANCY_SELL'; + $limit = GETPOST('limit','int')?GETPOST('limit','int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -112,8 +114,6 @@ if ($action == 'update') { 'ACCOUNTANCY_BUY' ); - $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); - if (in_array($accounting_product_mode, $accounting_product_modes)) { if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) { From a0d8ba268e7ac8ecfccab5752aa318feab1e4634 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 16:28:32 +0100 Subject: [PATCH 060/179] Update doc with the new menu entries --- htdocs/accountancy/index.php | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index ca66201dac7..b34efe5ea04 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -64,13 +64,13 @@ if ($conf->accounting->enabled) // STEPS $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, ''.''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("AccountingJournals").''.''); + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").''.''); print "
\n"; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, ''.''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Pcg_version").''.''); + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").''.''); print "
\n"; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, ''.''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Chartofaccounts").''.''); + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").''.''); print "
\n"; print "
\n"; @@ -79,20 +79,20 @@ if ($conf->accounting->enabled) print "
\n"; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, ''.''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''.''); + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''.''); print "
\n"; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, ''.''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuBankAccounts").''.'')."\n"; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").''.'')."\n"; print "
\n"; $step++; - $textlink = ''.''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuVatAccounts").''.''; + $textlink = ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").''.''; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink); print "
\n"; if (! empty($conf->tax->enabled)) { - $textlink = ''.''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuTaxAccounts").''.''; + $textlink = ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").''.''; $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); print "
\n"; @@ -100,7 +100,7 @@ if ($conf->accounting->enabled) /*if (! empty($conf->salaries->enabled)) { $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSal", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSal", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); // htdocs/admin/salaries.php print "
\n"; print "
\n"; @@ -108,36 +108,37 @@ if ($conf->accounting->enabled) if (! empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. { $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''.''); + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''.''); print "
\n"; } /* if (! empty($conf->loan->enabled)) { $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("MenuSpecialExpenses").'-'.$langs->transnoentitiesnoconv("Loans").' '.$langs->transnoentitiesnoconv("or").' '.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("MenuSpecialExpenses").' - '.$langs->transnoentitiesnoconv("Loans").' '.$langs->transnoentitiesnoconv("or").' '.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); print "
\n"; } if (! empty($conf->don->enabled)) { $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); print "
\n"; } if (! empty($conf->adherents->enabled)) { $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSubscription", $step, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSubscription", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); print "
\n"; }*/ $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").''.''); + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").''.''); print "
\n"; print '
'; + // Step A - E print "
\n"; print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionFreq"), '', ''); @@ -148,22 +149,22 @@ if ($conf->accounting->enabled) $langs->loadLangs(array('bills', 'trips')); $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsCustomers"), ''.''.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("CustomersVentilation").''.'')."\n"; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsCustomers"), ''.''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").''.'')."\n"; print "
\n"; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), ''.''.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("SuppliersVentilation").''.'')."\n"; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), ''.''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").''.'')."\n"; print "
\n"; if (! empty($conf->expensereport->enabled) || ! empty($conf->deplacement->enabled)) { $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), ''.''.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("ExpenseReportsVentilation").''.'')."\n"; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), ''.''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").''.'')."\n"; print "
\n"; } $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("Journalization"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n"; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n"; print "
\n"; $step++; From daa940d75bcdad741091bd37e1ebaa4b79184bd8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 14 Mar 2019 16:35:36 +0100 Subject: [PATCH 061/179] FIX multiple bugs for show products/categories --- htdocs/takepos/ajax.php | 3 +- htdocs/takepos/customers.php | 4 +- htdocs/takepos/invoice.php | 102 ++++++++++++++++++----------------- htdocs/takepos/takepos.php | 14 +++-- 4 files changed, 66 insertions(+), 57 deletions(-) diff --git a/htdocs/takepos/ajax.php b/htdocs/takepos/ajax.php index 4b16cc9ec81..db8b3fdff56 100644 --- a/htdocs/takepos/ajax.php +++ b/htdocs/takepos/ajax.php @@ -49,9 +49,10 @@ if ($action=="getProducts") { echo json_encode($prods); } -if ($action=="search") { +else if ($action=="search") { $sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'product'; $sql .= ' WHERE entity IN ('.getEntity('product').')'; + $sql .= ' AND tosell = 1'; $sql .= natural_search(array('label','barcode'), $term); $resql = $db->query($sql); $rows = array(); diff --git a/htdocs/takepos/customers.php b/htdocs/takepos/customers.php index 3bf79f38382..16884e48f1d 100644 --- a/htdocs/takepos/customers.php +++ b/htdocs/takepos/customers.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2019 Regis Houssin * Copyright (C) 2012 Marcos García * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2015 Florian Henry @@ -45,7 +45,7 @@ $show_files=GETPOST('show_files', 'int'); $confirm=GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $idcustomer = GETPOST('idcustomer', 'int'); -$place = GETPOST('place', 'int'); +$place = (GETPOSTISSET('place')?GETPOST('place', 'int'):0); $_GET['optioncss'] = 'print'; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 4d8130daeb4..35509165732 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -25,39 +25,28 @@ if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } + require '../main.inc.php'; - - // Load $user and permissions - require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; - require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; -$langs->loadLangs( - array( - "bills", - "cashdesk" - ) -); +$langs->loadLangs(array("bills", "cashdesk")); + $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $idproduct = GETPOST('idproduct', 'int'); -$place = GETPOST('place', 'int'); +$place = (GETPOSTISSET('place')?GETPOST('place', 'int'):0); // $place is id of POS $number = GETPOST('number'); $idline = GETPOST('idline'); $desc = GETPOST('desc', 'alpha'); $pay = GETPOST('pay'); -$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS-".$place.")'"; -$resql = $db->query($sql); -$row = $db->fetch_array($resql); -$placeid = $row[0]; -if (!$placeid) { $placeid = 0; // not necessary -} else -{ - $invoice = new Facture($db); - $invoice->fetch($placeid); -} +$placeid = 0; // $placeid is id of invoice + +$invoice = new Facture($db); +$ret = $invoice->fetch('', '(PROV-POS-'.$place.')'); +if ($ret > 0) $placeid = $invoice->id; + /* * Actions @@ -65,53 +54,68 @@ if (!$placeid) { $placeid = 0; // not necessary if ($action == 'valid' && $user->rights->facture->creer) { - if ($pay=="cash") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CASH; - elseif ($pay=="card") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CB; - elseif ($pay=="cheque") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; + if ($pay == "cash") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH; + elseif ($pay == "card") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CB; + elseif ($pay == "cheque") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; + $now=dol_now(); + $invoice = new Facture($db); $invoice->fetch($placeid); + if (! empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK!="1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); else $invoice->validate($user); + // Add the payment $payment=new Paiement($db); - $payment->datepaye=$now; - $payment->bank_account=$bankaccount; - $payment->amounts[$invoice->id]=$invoice->total_ttc; + $payment->datepaye = $now; + $payment->bank_account = $bankaccount; + $payment->amounts[$invoice->id] = $invoice->total_ttc; - if ($pay=="cash") $payment->paiementid=4; - elseif ($pay=="card") $payment->paiementid=6; - elseif ($pay=="cheque") $payment->paiementid=7; - $payment->num_paiement=$invoice->ref; + if ($pay=="cash") $payment->paiementid = 4; + elseif ($pay=="card") $payment->paiementid = 6; + elseif ($pay=="cheque") $payment->paiementid = 7; + $payment->num_payment = $invoice->ref; - $payment->create($user); + $payment->create($user); $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - $invoice->set_paid($user); + $invoice->set_paid($user); } -if (($action=="addline" || $action=="freezone") && $placeid==0) +if (($action=="addline" || $action=="freezone") && $placeid == 0) { - // $place is id of POS, $placeid is id of invoice - if ($placeid==0) - { - $invoice = new Facture($db); - $invoice->socid=$conf->global->CASHDESK_ID_THIRDPARTY; - $invoice->date=dol_now(); - $invoice->ref="(PROV-POS)"; - $invoice->module_source = 'takepos'; - $invoice->pos_source = (string) (empty($place)?'0':$place); + $invoice->socid = $conf->global->CASHDESK_ID_THIRDPARTY; + $invoice->date = dol_now(); + $invoice->ref = "(PROV-POS-".$place.")"; + $invoice->module_source = 'takepos'; + $invoice->pos_source = (string) $place; - $placeid=$invoice->create($user); - $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS-".$place.")' where rowid=".$placeid; - $db->query($sql); - } + $placeid = $invoice->create($user); } if ($action == "addline") { - $prod = new Product($db); + + $prod = new Product($db); $prod->fetch($idproduct); - $invoice->addline($prod->description, $prod->price, 1, $prod->tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $prod->remise_percent, '', 0, 0, 0, '', $prod->price_base_type, $prod->price_ttc, $prod->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); + + $price = $prod->price; + $tva_tx = $prod->tva_tx; + $price_ttc = $prod->price_ttc; + $price_base_type = $prod->price_base_type; + + if (! empty($conf->global->PRODUIT_MULTIPRICES)) + { + $customer = new Societe($db); + $customer->fetch($invoice->socid); + + $price = $prod->multiprices[$customer->price_level]; + $tva_tx = $prod->multiprices_tva_tx[$customer->price_level]; + $price_ttc = $prod->multiprices_ttc[$customer->price_level]; + $price_base_type = $prod->multiprices_base_type[$customer->price_level]; + } + + $invoice->addline($prod->description, $price, 1, $tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $prod->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); $invoice->fetch($placeid); } diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 41f4c99a508..8e7053b8242 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -65,21 +65,25 @@ $categorie = new Categorie($db); $categories = $categorie->get_full_arbo('product'); $maincategories = array_filter($categories, function ($item) { - if (($item['level']==1) !== false) { + if (($item['level']==1) !== false && ($item['visible']==1) !== false) { return true; } return false; }); +sort($maincategories); + $subcategories = array_filter($categories, function ($item) { - if (($item['level']!=1) !== false) { + if (($item['level']!=1) !== false && ($item['visible']==1) !== false) { return true; } return false; }); + +sort($subcategories); ?> -var categories = ; +var categories = ; var subcategories = ; var currentcat; @@ -151,7 +155,7 @@ function LoadProducts(position, issubcat=false){ idata=0; //product data counter $.getJSON('./ajax.php?action=getProducts&category='+currentcat, function(data) { - while (idata < 30 && ishow < 30) { + while (ishow < 30) { if (typeof (data[idata]) == "undefined") { $("#prodesc"+ishow).text(""); $("#proimg"+ishow).attr("src","genimg/empty.png"); @@ -191,7 +195,7 @@ function MoreProducts(moreorless){ } idata=30*pageproducts; //product data counter ishow=0; //product to show counter - while (idata < (30*pageproducts)+30) { + while (ishow < 30) { if (typeof (data[idata]) == "undefined") { $("#prodesc"+ishow).text(""); $("#proimg"+ishow).attr("src","genimg/empty.png"); From 1222d9053736bc158a2388fc4ae199ea9f9e436f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Mar 2019 16:40:44 +0100 Subject: [PATCH 062/179] phpcs fix --- htdocs/admin/propal.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index e9a037b98c9..1ba9ed50cac 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -70,7 +70,7 @@ if ($action == 'updateMask') } } -else if ($action == 'specimen') +elseif ($action == 'specimen') { $modele=GETPOST('module', 'alpha'); @@ -115,13 +115,13 @@ else if ($action == 'specimen') } } -else if ($action == 'setribchq') +elseif ($action == 'setribchq') { - $rib = GETPOST('rib','alpha'); - $chq = GETPOST('chq','alpha'); + $rib = GETPOST('rib', 'alpha'); + $chq = GETPOST('chq', 'alpha'); - $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER",$rib,'chaine',0,'',$conf->entity); - $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER",$chq,'chaine',0,'',$conf->entity); + $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); if (! $res > 0) $error++; @@ -135,7 +135,7 @@ else if ($action == 'setribchq') } } -else if ($action == 'set_PROPALE_DRAFT_WATERMARK') +elseif ($action == 'set_PROPALE_DRAFT_WATERMARK') { $draft = GETPOST('PROPALE_DRAFT_WATERMARK', 'alpha'); @@ -152,7 +152,7 @@ else if ($action == 'set_PROPALE_DRAFT_WATERMARK') } } -else if ($action == 'set_PROPOSAL_FREE_TEXT') +elseif ($action == 'set_PROPOSAL_FREE_TEXT') { $freetext = GETPOST('PROPOSAL_FREE_TEXT', 'none'); // No alpha here, we want exact string @@ -170,7 +170,7 @@ else if ($action == 'set_PROPOSAL_FREE_TEXT') } } -else if ($action == 'setdefaultduration') +elseif ($action == 'setdefaultduration') { $res = dolibarr_set_const($db, "PROPALE_VALIDITY_DURATION", $value, 'chaine', 0, '', $conf->entity); @@ -186,7 +186,7 @@ else if ($action == 'setdefaultduration') } } -else if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') +elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') { $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); @@ -203,7 +203,7 @@ else if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') } // Activate a model -else if ($action == 'set') +elseif ($action == 'set') { $ret = addDocumentModel($value, $type, $label, $scandir); } @@ -526,7 +526,7 @@ print ''; if (empty($conf->facture->enabled)) { print '
'; - print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInProposal"),'',''); + print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInProposal"), '', ''); print '
'; print ''; @@ -608,7 +608,7 @@ if (empty($conf->facture->enabled)) print ''; + print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).''; $i++; } From 321a919fb1801bb5065763828edefd60299b56e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Mar 2019 16:42:35 +0100 Subject: [PATCH 063/179] Update result.php --- htdocs/compta/resultat/result.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 59984ee444c..f505b97a5fc 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -289,12 +289,12 @@ elseif ($modecompta=="BOOKKEEPING") $sommes = array(); $totPerAccount = array(); if (!is_array($cats) && $cats<0) { - setEventMessages(null,$AccCat->errors,'errors'); + setEventMessages(null, $AccCat->errors, 'errors'); } elseif (is_array($cats) && count($cats)>0) { - foreach ($cats as $cat) // Loop on each group - { - if (!empty($cat['category_type'])) // category calculed - { + foreach ($cats as $cat) { + // Loop on each group + if (!empty($cat['category_type'])) { + // category calculed // When we enter here, $sommes was filled by group of accounts $formula = $cat['formula']; From b1032f838ca5bc9c99ab5323f841b58782a0da1c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 16:43:19 +0100 Subject: [PATCH 064/179] Fix some PSR rules --- htdocs/admin/facture.php | 20 ++++++-------------- htdocs/admin/propal.php | 31 ++++++++++++------------------- htdocs/comm/propal/contact.php | 2 +- htdocs/commande/contact.php | 2 +- htdocs/compta/resultat/result.php | 5 ++--- htdocs/expedition/card.php | 2 +- htdocs/expedition/contact.php | 2 +- htdocs/reception/card.php | 2 +- htdocs/reception/contact.php | 2 +- htdocs/societe/societecontact.php | 2 +- 10 files changed, 27 insertions(+), 43 deletions(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index e1d65250b6d..b1c9df224ea 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -77,8 +77,7 @@ if ($action == 'updateMask') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'specimen') +elseif ($action == 'specimen') { $modele=GETPOST('module', 'alpha'); @@ -122,7 +121,6 @@ else if ($action == 'specimen') dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } - // Activate a model elseif ($action == 'set') { @@ -137,7 +135,6 @@ elseif ($action == 'del') if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity); } } - // Set default model elseif ($action == 'setdoc') { @@ -155,7 +152,6 @@ elseif ($action == 'setdoc') $ret = addDocumentModel($value, $type, $label, $scandir); } } - elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active @@ -163,8 +159,7 @@ elseif ($action == 'setmod') dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); } - -else if ($action == 'setribchq') +elseif ($action == 'setribchq') { $rib = GETPOST('rib', 'alpha'); $chq = GETPOST('chq', 'alpha'); @@ -183,8 +178,7 @@ else if ($action == 'setribchq') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'set_FACTURE_DRAFT_WATERMARK') +elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') { $draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha'); @@ -202,7 +196,7 @@ else if ($action == 'set_FACTURE_DRAFT_WATERMARK') } } -else if ($action == 'set_INVOICE_FREE_TEXT') +elseif ($action == 'set_INVOICE_FREE_TEXT') { $freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string @@ -219,8 +213,7 @@ else if ($action == 'set_INVOICE_FREE_TEXT') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'setforcedate') +elseif ($action == 'setforcedate') { $forcedate = GETPOST('forcedate', 'alpha'); @@ -237,8 +230,7 @@ else if ($action == 'setforcedate') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'setDefaultPDFModulesByType') +elseif ($action == 'setDefaultPDFModulesByType') { $invoicetypemodels = GETPOST('invoicetypemodels'); diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index e9a037b98c9..fdaf16da5b2 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -69,8 +69,7 @@ if ($action == 'updateMask') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'specimen') +elseif ($action == 'specimen') { $modele=GETPOST('module', 'alpha'); @@ -114,14 +113,13 @@ else if ($action == 'specimen') dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } - -else if ($action == 'setribchq') +elseif ($action == 'setribchq') { - $rib = GETPOST('rib','alpha'); - $chq = GETPOST('chq','alpha'); + $rib = GETPOST('rib', 'alpha'); + $chq = GETPOST('chq', 'alpha'); - $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER",$rib,'chaine',0,'',$conf->entity); - $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER",$chq,'chaine',0,'',$conf->entity); + $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); if (! $res > 0) $error++; @@ -134,8 +132,7 @@ else if ($action == 'setribchq') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'set_PROPALE_DRAFT_WATERMARK') +elseif ($action == 'set_PROPALE_DRAFT_WATERMARK') { $draft = GETPOST('PROPALE_DRAFT_WATERMARK', 'alpha'); @@ -151,8 +148,7 @@ else if ($action == 'set_PROPALE_DRAFT_WATERMARK') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'set_PROPOSAL_FREE_TEXT') +elseif ($action == 'set_PROPOSAL_FREE_TEXT') { $freetext = GETPOST('PROPOSAL_FREE_TEXT', 'none'); // No alpha here, we want exact string @@ -169,8 +165,7 @@ else if ($action == 'set_PROPOSAL_FREE_TEXT') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'setdefaultduration') +elseif ($action == 'setdefaultduration') { $res = dolibarr_set_const($db, "PROPALE_VALIDITY_DURATION", $value, 'chaine', 0, '', $conf->entity); @@ -186,7 +181,7 @@ else if ($action == 'setdefaultduration') } } -else if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') +elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') { $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); @@ -201,13 +196,11 @@ else if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') setEventMessages($langs->trans("Error"), null, 'errors'); } } - // Activate a model -else if ($action == 'set') +elseif ($action == 'set') { $ret = addDocumentModel($value, $type, $label, $scandir); } - elseif ($action == 'del') { $ret = delDocumentModel($value, $type); @@ -476,7 +469,7 @@ foreach ($dirmodels as $reldir) print ''; // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip = $langs->trans("Name").': '.$module->name; $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); if ($module->type == 'pdf') { diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 24bd5fb1abb..813b91cca0a 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -129,7 +129,7 @@ elseif ($action == 'deletecontact' && $user->rights->propale->creer) } } /* -else if ($action == 'setaddress' && $user->rights->propale->creer) +elseif ($action == 'setaddress' && $user->rights->propale->creer) { $result=$object->setDeliveryAddress($_POST['fk_address']); if ($result < 0) dol_print_error($db,$object->error); diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 73da3525a14..f95b9fcf40a 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -107,7 +107,7 @@ elseif ($action == 'deletecontact' && $user->rights->commande->creer) } } /* -else if ($action == 'setaddress' && $user->rights->commande->creer) +elseif ($action == 'setaddress' && $user->rights->commande->creer) { $object->fetch($id); $result=$object->setDeliveryAddress($_POST['fk_address']); diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 59984ee444c..55d492bef0a 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -288,8 +288,8 @@ elseif ($modecompta=="BOOKKEEPING") $j=1; $sommes = array(); $totPerAccount = array(); - if (!is_array($cats) && $cats<0) { - setEventMessages(null,$AccCat->errors,'errors'); + if (!is_array($cats) && $cats < 0) { + setEventMessages(null, $AccCat->errors, 'errors'); } elseif (is_array($cats) && count($cats)>0) { foreach ($cats as $cat) // Loop on each group { @@ -315,7 +315,6 @@ elseif ($modecompta=="BOOKKEEPING") $vars[$code] = $det['NP']; } - $result = strtr($formula, $vars); //var_dump($result); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 5a063fcbf4a..2e6a1796df1 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -479,7 +479,7 @@ if (empty($reshook)) } } // TODO add alternative status - /*else if ($action == 'reopen' && (! empty($user->rights->expedition->creer) || ! empty($user->rights->expedition->shipping_advance->validate))) + /*elseif ($action == 'reopen' && (! empty($user->rights->expedition->creer) || ! empty($user->rights->expedition->shipping_advance->validate))) { $result = $object->setStatut(0); if ($result < 0) diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 202808d5d58..4acb2fce932 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -123,7 +123,7 @@ elseif ($action == 'deletecontact' && $user->rights->expedition->creer) } } /* -else if ($action == 'setaddress' && $user->rights->expedition->creer) +elseif ($action == 'setaddress' && $user->rights->expedition->creer) { $object->fetch($id); $result=$object->setDeliveryAddress($_POST['fk_address']); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index c2400abea1d..dfe1eb5e2e6 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -438,7 +438,7 @@ if (empty($reshook)) } } // TODO add alternative status - /*else if ($action == 'reopen' && (! empty($user->rights->reception->creer) || ! empty($user->rights->reception->reception_advance->validate))) + /*elseif ($action == 'reopen' && (! empty($user->rights->reception->creer) || ! empty($user->rights->reception->reception_advance->validate))) { $result = $object->setStatut(0); if ($result < 0) diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index a94d6d68377..d51062ef7ef 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -126,7 +126,7 @@ elseif ($action == 'deletecontact' && $user->rights->reception->creer) } } /* -else if ($action == 'setaddress' && $user->rights->reception->creer) +elseif ($action == 'setaddress' && $user->rights->reception->creer) { $object->fetch($id); $result=$object->setDeliveryAddress($_POST['fk_address']); diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 193703a8468..72bf7f6d27e 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -110,7 +110,7 @@ elseif ($action == 'deletecontact' && $user->rights->societe->creer) } } /* -else if ($action == 'setaddress' && $user->rights->societe->creer) +elseif ($action == 'setaddress' && $user->rights->societe->creer) { $object->fetch($id); $result=$object->setDeliveryAddress($_POST['fk_address']); From cdf6e4b65a70d1eca19b2f7295b594ecf2a8efca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 16:43:19 +0100 Subject: [PATCH 065/179] Fix some PSR rules --- htdocs/admin/facture.php | 20 ++++++-------------- htdocs/admin/prelevement.php | 2 +- htdocs/admin/propal.php | 31 ++++++++++++------------------- htdocs/comm/propal/contact.php | 2 +- htdocs/commande/contact.php | 2 +- htdocs/compta/resultat/result.php | 5 ++--- htdocs/expedition/card.php | 2 +- htdocs/expedition/contact.php | 2 +- htdocs/reception/card.php | 2 +- htdocs/reception/contact.php | 2 +- htdocs/societe/societecontact.php | 2 +- 11 files changed, 28 insertions(+), 44 deletions(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index e1d65250b6d..b1c9df224ea 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -77,8 +77,7 @@ if ($action == 'updateMask') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'specimen') +elseif ($action == 'specimen') { $modele=GETPOST('module', 'alpha'); @@ -122,7 +121,6 @@ else if ($action == 'specimen') dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } - // Activate a model elseif ($action == 'set') { @@ -137,7 +135,6 @@ elseif ($action == 'del') if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity); } } - // Set default model elseif ($action == 'setdoc') { @@ -155,7 +152,6 @@ elseif ($action == 'setdoc') $ret = addDocumentModel($value, $type, $label, $scandir); } } - elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active @@ -163,8 +159,7 @@ elseif ($action == 'setmod') dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); } - -else if ($action == 'setribchq') +elseif ($action == 'setribchq') { $rib = GETPOST('rib', 'alpha'); $chq = GETPOST('chq', 'alpha'); @@ -183,8 +178,7 @@ else if ($action == 'setribchq') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'set_FACTURE_DRAFT_WATERMARK') +elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') { $draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha'); @@ -202,7 +196,7 @@ else if ($action == 'set_FACTURE_DRAFT_WATERMARK') } } -else if ($action == 'set_INVOICE_FREE_TEXT') +elseif ($action == 'set_INVOICE_FREE_TEXT') { $freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string @@ -219,8 +213,7 @@ else if ($action == 'set_INVOICE_FREE_TEXT') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'setforcedate') +elseif ($action == 'setforcedate') { $forcedate = GETPOST('forcedate', 'alpha'); @@ -237,8 +230,7 @@ else if ($action == 'setforcedate') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'setDefaultPDFModulesByType') +elseif ($action == 'setDefaultPDFModulesByType') { $invoicetypemodels = GETPOST('invoicetypemodels'); diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 34e407bd863..144ec744d41 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -173,7 +173,7 @@ if ($action == 'specimen') } // Set default model -else if ($action == 'setdoc') +elseif ($action == 'setdoc') { if (dolibarr_set_const($db, "PAYMENTORDER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index e9a037b98c9..fdaf16da5b2 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -69,8 +69,7 @@ if ($action == 'updateMask') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'specimen') +elseif ($action == 'specimen') { $modele=GETPOST('module', 'alpha'); @@ -114,14 +113,13 @@ else if ($action == 'specimen') dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } - -else if ($action == 'setribchq') +elseif ($action == 'setribchq') { - $rib = GETPOST('rib','alpha'); - $chq = GETPOST('chq','alpha'); + $rib = GETPOST('rib', 'alpha'); + $chq = GETPOST('chq', 'alpha'); - $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER",$rib,'chaine',0,'',$conf->entity); - $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER",$chq,'chaine',0,'',$conf->entity); + $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); if (! $res > 0) $error++; @@ -134,8 +132,7 @@ else if ($action == 'setribchq') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'set_PROPALE_DRAFT_WATERMARK') +elseif ($action == 'set_PROPALE_DRAFT_WATERMARK') { $draft = GETPOST('PROPALE_DRAFT_WATERMARK', 'alpha'); @@ -151,8 +148,7 @@ else if ($action == 'set_PROPALE_DRAFT_WATERMARK') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'set_PROPOSAL_FREE_TEXT') +elseif ($action == 'set_PROPOSAL_FREE_TEXT') { $freetext = GETPOST('PROPOSAL_FREE_TEXT', 'none'); // No alpha here, we want exact string @@ -169,8 +165,7 @@ else if ($action == 'set_PROPOSAL_FREE_TEXT') setEventMessages($langs->trans("Error"), null, 'errors'); } } - -else if ($action == 'setdefaultduration') +elseif ($action == 'setdefaultduration') { $res = dolibarr_set_const($db, "PROPALE_VALIDITY_DURATION", $value, 'chaine', 0, '', $conf->entity); @@ -186,7 +181,7 @@ else if ($action == 'setdefaultduration') } } -else if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') +elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') { $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); @@ -201,13 +196,11 @@ else if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') setEventMessages($langs->trans("Error"), null, 'errors'); } } - // Activate a model -else if ($action == 'set') +elseif ($action == 'set') { $ret = addDocumentModel($value, $type, $label, $scandir); } - elseif ($action == 'del') { $ret = delDocumentModel($value, $type); @@ -476,7 +469,7 @@ foreach ($dirmodels as $reldir) print ''; // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip = $langs->trans("Name").': '.$module->name; $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); if ($module->type == 'pdf') { diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 24bd5fb1abb..813b91cca0a 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -129,7 +129,7 @@ elseif ($action == 'deletecontact' && $user->rights->propale->creer) } } /* -else if ($action == 'setaddress' && $user->rights->propale->creer) +elseif ($action == 'setaddress' && $user->rights->propale->creer) { $result=$object->setDeliveryAddress($_POST['fk_address']); if ($result < 0) dol_print_error($db,$object->error); diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 73da3525a14..f95b9fcf40a 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -107,7 +107,7 @@ elseif ($action == 'deletecontact' && $user->rights->commande->creer) } } /* -else if ($action == 'setaddress' && $user->rights->commande->creer) +elseif ($action == 'setaddress' && $user->rights->commande->creer) { $object->fetch($id); $result=$object->setDeliveryAddress($_POST['fk_address']); diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 59984ee444c..55d492bef0a 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -288,8 +288,8 @@ elseif ($modecompta=="BOOKKEEPING") $j=1; $sommes = array(); $totPerAccount = array(); - if (!is_array($cats) && $cats<0) { - setEventMessages(null,$AccCat->errors,'errors'); + if (!is_array($cats) && $cats < 0) { + setEventMessages(null, $AccCat->errors, 'errors'); } elseif (is_array($cats) && count($cats)>0) { foreach ($cats as $cat) // Loop on each group { @@ -315,7 +315,6 @@ elseif ($modecompta=="BOOKKEEPING") $vars[$code] = $det['NP']; } - $result = strtr($formula, $vars); //var_dump($result); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 5a063fcbf4a..2e6a1796df1 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -479,7 +479,7 @@ if (empty($reshook)) } } // TODO add alternative status - /*else if ($action == 'reopen' && (! empty($user->rights->expedition->creer) || ! empty($user->rights->expedition->shipping_advance->validate))) + /*elseif ($action == 'reopen' && (! empty($user->rights->expedition->creer) || ! empty($user->rights->expedition->shipping_advance->validate))) { $result = $object->setStatut(0); if ($result < 0) diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 202808d5d58..4acb2fce932 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -123,7 +123,7 @@ elseif ($action == 'deletecontact' && $user->rights->expedition->creer) } } /* -else if ($action == 'setaddress' && $user->rights->expedition->creer) +elseif ($action == 'setaddress' && $user->rights->expedition->creer) { $object->fetch($id); $result=$object->setDeliveryAddress($_POST['fk_address']); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index c2400abea1d..dfe1eb5e2e6 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -438,7 +438,7 @@ if (empty($reshook)) } } // TODO add alternative status - /*else if ($action == 'reopen' && (! empty($user->rights->reception->creer) || ! empty($user->rights->reception->reception_advance->validate))) + /*elseif ($action == 'reopen' && (! empty($user->rights->reception->creer) || ! empty($user->rights->reception->reception_advance->validate))) { $result = $object->setStatut(0); if ($result < 0) diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index a94d6d68377..d51062ef7ef 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -126,7 +126,7 @@ elseif ($action == 'deletecontact' && $user->rights->reception->creer) } } /* -else if ($action == 'setaddress' && $user->rights->reception->creer) +elseif ($action == 'setaddress' && $user->rights->reception->creer) { $object->fetch($id); $result=$object->setDeliveryAddress($_POST['fk_address']); diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 193703a8468..72bf7f6d27e 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -110,7 +110,7 @@ elseif ($action == 'deletecontact' && $user->rights->societe->creer) } } /* -else if ($action == 'setaddress' && $user->rights->societe->creer) +elseif ($action == 'setaddress' && $user->rights->societe->creer) { $object->fetch($id); $result=$object->setDeliveryAddress($_POST['fk_address']); From f25ce3b40c87961b16fd6eb88bdb59651e3d3df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Mar 2019 16:43:52 +0100 Subject: [PATCH 066/179] Update facture.php --- htdocs/admin/facture.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index e1d65250b6d..327c1f6bbd8 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -78,7 +78,7 @@ if ($action == 'updateMask') } } -else if ($action == 'specimen') +elseif ($action == 'specimen') { $modele=GETPOST('module', 'alpha'); @@ -164,7 +164,7 @@ elseif ($action == 'setmod') dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); } -else if ($action == 'setribchq') +elseif ($action == 'setribchq') { $rib = GETPOST('rib', 'alpha'); $chq = GETPOST('chq', 'alpha'); @@ -184,7 +184,7 @@ else if ($action == 'setribchq') } } -else if ($action == 'set_FACTURE_DRAFT_WATERMARK') +elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') { $draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha'); @@ -202,7 +202,7 @@ else if ($action == 'set_FACTURE_DRAFT_WATERMARK') } } -else if ($action == 'set_INVOICE_FREE_TEXT') +elseif ($action == 'set_INVOICE_FREE_TEXT') { $freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string @@ -220,7 +220,7 @@ else if ($action == 'set_INVOICE_FREE_TEXT') } } -else if ($action == 'setforcedate') +elseif ($action == 'setforcedate') { $forcedate = GETPOST('forcedate', 'alpha'); @@ -238,7 +238,7 @@ else if ($action == 'setforcedate') } } -else if ($action == 'setDefaultPDFModulesByType') +elseif ($action == 'setDefaultPDFModulesByType') { $invoicetypemodels = GETPOST('invoicetypemodels'); From b67429218df35b67d5df8c4a38840155e267fa1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Mar 2019 08:19:22 +0100 Subject: [PATCH 067/179] Update html.formmail.class.php Conflicts: htdocs/core/class/html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 6dd2264bf8b..c42acac2549 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -78,7 +78,7 @@ class FormMail extends Form /** * @var int * @deprecated Fill withto with array before calling method. - * @see withto + * @see $withto */ public $withtosocid; @@ -1290,7 +1290,7 @@ class FormMail extends Form * @param CommonObject $object Object to use * @param Translate $outputlangs Object lang * @return void - * @see getCommonSubstitutionArray + * @see getCommonSubstitutionArray() */ function setSubstitFromObject($object, $outputlangs) { From 885797b748ee286e30ecf1066e69bc544034de43 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 14 Mar 2019 17:00:51 +0100 Subject: [PATCH 068/179] FIX : useless join --- htdocs/hrm/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 5b3548cc8fb..5c523640033 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -299,7 +299,7 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire { $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.statut, u.photo, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = x.fk_user_author"; $sql.= " AND x.entity = ".$conf->entity; if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND x.fk_user_author IN ('.join(',',$childids).')'; From fd393218d34c3cf50c403ccc968b7c29c8abbfbd Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 14 Mar 2019 17:07:49 +0100 Subject: [PATCH 069/179] FIX you should prefer "elseif" than "else if" --- htdocs/takepos/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax.php b/htdocs/takepos/ajax.php index db8b3fdff56..9586e71fd18 100644 --- a/htdocs/takepos/ajax.php +++ b/htdocs/takepos/ajax.php @@ -49,7 +49,7 @@ if ($action=="getProducts") { echo json_encode($prods); } -else if ($action=="search") { +elseif ($action=="search") { $sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'product'; $sql .= ' WHERE entity IN ('.getEntity('product').')'; $sql .= ' AND tosell = 1'; From 4a9694782c101a59635d2aec411cf4f1a84e9dde Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 17:08:45 +0100 Subject: [PATCH 070/179] phpcs --- htdocs/takepos/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax.php b/htdocs/takepos/ajax.php index db8b3fdff56..9586e71fd18 100644 --- a/htdocs/takepos/ajax.php +++ b/htdocs/takepos/ajax.php @@ -49,7 +49,7 @@ if ($action=="getProducts") { echo json_encode($prods); } -else if ($action=="search") { +elseif ($action=="search") { $sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'product'; $sql .= ' WHERE entity IN ('.getEntity('product').')'; $sql .= ' AND tosell = 1'; From a40cba194f68588ff10d223b7225403db79b264d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 14 Mar 2019 17:24:42 +0100 Subject: [PATCH 071/179] FIX wrong url --- htdocs/takepos/takepos.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 8e7053b8242..47584a8c2a7 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -446,11 +446,11 @@ $menus[$r++]=array('title'=>$langs->trans("FreeZone"), $menus[$r++]=array('title'=>$langs->trans("Customer"), 'action'=>'Customer();'); $menus[$r++]=array('title'=>$langs->trans("BackOffice"), - 'action'=>'window.open(\''.DOL_URL_ROOT.'\', \'backoffice\');'); + 'action'=>'window.open(\''.(empty(DOL_URL_ROOT)?'/':DOL_URL_ROOT).'\', \'_self\');'); $menus[$r++]=array('title'=>$langs->trans("ValidateBill"), 'action'=>'CloseBill();'); $menus[$r++]=array('title'=>$langs->trans("Logout"), - 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';'); + 'action'=>'window.location.href=\''.(empty(DOL_URL_ROOT)?'/':DOL_URL_ROOT).'user/logout.php\';'); //BAR RESTAURANT specified menu if($conf->global->TAKEPOS_BAR_RESTAURANT){ From c6b3d81d618dc617134c4069e64d3470db4f6125 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 17:35:44 +0100 Subject: [PATCH 072/179] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a24cb0cab40..f049f7ba800 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2663,7 +2663,7 @@ class Form if (count($scrit) > 1) $sql.=")"; if (! empty($conf->barcode->enabled)){ $sql.= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; - $sql.= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + if (! empty($conf->global->BARCODE_USE_BARCODE_FOR_SUPPLIER_PRICES)) $sql.= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; } $sql.=')'; } From 69bfac7eef97abd49f8efcd805c1937d7828a8c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 17:36:35 +0100 Subject: [PATCH 073/179] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f049f7ba800..3ef8b1426f8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2784,7 +2784,8 @@ class Form $opt .= " - ".dol_trunc($objp->name, 8); $outval.=" - ".dol_trunc($objp->name, 8); } - if (! empty($conf->barcode->enabled) && !empty($objp->barcode)){ + if (! empty($conf->barcode->enabled) && !empty($objp->barcode) && ! empty($conf->global->BARCODE_USE_BARCODE_FOR_SUPPLIER_PRICES)) + { $opt .= " - ".$objp->barcode; $outval.=" - ".$objp->barcode; } From 3fb6978bc8c288deaabfb2f6228351d1204ec7a2 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 14 Mar 2019 17:36:49 +0100 Subject: [PATCH 074/179] FIX : no need to test anything to display documents tabs on expense report --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index c204809e9a1..9162676795c 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -382,7 +382,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh $checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet','project'); // Test for project object $checktask = array('projet_task'); - $nocheck = array('barcode','stock'); // No test + $nocheck = array('barcode','stock','expensereport'); // No test $checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...). // If dbtablename not defined, we use same name for table than module name From dd962fa044e3d4f3bfde8981f71ed1a481477866 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 17:39:01 +0100 Subject: [PATCH 075/179] Update fournisseur.product.class.php --- 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 cc31bbdb4d5..903f846d1f3 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -231,7 +231,7 @@ class ProductFournisseur extends Product * @param int $fk_barcode_type Barcode type * @return int <0 if KO, >=0 if OK */ - 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='') + 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; From 250e0bbaac2d6857d49bb6c1b85f25f3134abca9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 17:40:39 +0100 Subject: [PATCH 076/179] Update fournisseur.product.class.php --- htdocs/fourn/class/fournisseur.product.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 903f846d1f3..a4dbace29b4 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -592,10 +592,8 @@ class ProductFournisseur extends Product $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql.= " pfp.rowid as product_fourn_pri_id, 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"; - if($conf->barcode->enabled){ - $sql.= " ,pfp.barcode, pfp.fk_barcode_type"; - } + $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"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; $sql.= " AND pfp.fk_soc = s.rowid"; From 60db66d2bff1984886a17f704232a8fb21f3e21e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 17:41:33 +0100 Subject: [PATCH 077/179] Update fournisseur.product.class.php --- htdocs/fourn/class/fournisseur.product.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index a4dbace29b4..32776e5418f 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -494,9 +494,9 @@ class ProductFournisseur extends Product $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"; - if($conf->barcode->enabled) $sql.=" ,pfp.barcode, pfp.fk_barcode_type"; + $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"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.rowid = ".$rowid; From f50638b7d84b39e511a3162beaa5229fc8f15acf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 17:44:54 +0100 Subject: [PATCH 078/179] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3ef8b1426f8..8cfce60797a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2663,7 +2663,7 @@ class Form if (count($scrit) > 1) $sql.=")"; if (! empty($conf->barcode->enabled)){ $sql.= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; - if (! empty($conf->global->BARCODE_USE_BARCODE_FOR_SUPPLIER_PRICES)) $sql.= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + $sql.= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; } $sql.=')'; } @@ -2784,7 +2784,7 @@ class Form $opt .= " - ".dol_trunc($objp->name, 8); $outval.=" - ".dol_trunc($objp->name, 8); } - if (! empty($conf->barcode->enabled) && !empty($objp->barcode) && ! empty($conf->global->BARCODE_USE_BARCODE_FOR_SUPPLIER_PRICES)) + if (! empty($conf->barcode->enabled) && !empty($objp->barcode)) { $opt .= " - ".$objp->barcode; $outval.=" - ".$objp->barcode; From 56104e6d8962acc76be6128831c9206684cd562e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 14 Mar 2019 17:58:32 +0100 Subject: [PATCH 079/179] FIX regression --- htdocs/takepos/takepos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 47584a8c2a7..740978e7db6 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -450,7 +450,7 @@ $menus[$r++]=array('title'=>$langs->trans("BackOffice"), $menus[$r++]=array('title'=>$langs->trans("ValidateBill"), 'action'=>'CloseBill();'); $menus[$r++]=array('title'=>$langs->trans("Logout"), - 'action'=>'window.location.href=\''.(empty(DOL_URL_ROOT)?'/':DOL_URL_ROOT).'user/logout.php\';'); + 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';'); //BAR RESTAURANT specified menu if($conf->global->TAKEPOS_BAR_RESTAURANT){ From 5aee322b30f25b792e2102dc18a10fa4bb0faa34 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 18:36:05 +0100 Subject: [PATCH 080/179] Update fournisseurs.php --- htdocs/product/fournisseurs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index b63c22482b4..21163f0b54e 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -754,7 +754,7 @@ SCRIPT; print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); } print_liste_field_titre("DiscountQtyMin",$_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre("PriceUpdate",$_SERVER["PHP_SELF"],"pfp.date_modification","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre("PriceUpdate",$_SERVER["PHP_SELF"],"pfp.tms","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("NbDaysToDelivery",$_SERVER["PHP_SELF"],"pfp.delivery_time_days","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("ReputationForThisProduct",$_SERVER["PHP_SELF"],"pfp.supplier_reputation","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); From 463c83efec449dca40d654a9e7466cb27375527e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 18:37:03 +0100 Subject: [PATCH 081/179] Update fournisseur.product.class.php --- 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 dc04139232c..fc16a3e6922 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -568,7 +568,7 @@ class ProductFournisseur extends Product $prodfourn->fourn_tva_npr = $record["info_bits"]; $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; $prodfourn->supplier_reputation = $record["supplier_reputation"]; - $prodfourn->date_modification = $this->db->jdate($record["date_modification"]); + $prodfourn->fourn_date_modification = $this->db->jdate($record["date_modification"]); $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"]; $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"]; From 911962ec120fef9d623cd31fbf8cf2abd3223b29 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 18:43:51 +0100 Subject: [PATCH 082/179] Update suppliers.lang --- htdocs/langs/en_US/suppliers.lang | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index e541971e160..b69b11272b4 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -45,4 +45,3 @@ BuyerName=Buyer name AllProductServicePrices=All product / service prices AllProductReferencesOfSupplier=All product / service references of vendor BuyingPriceNumShort=Vendor prices -PriceUpdate=Updated on \ No newline at end of file From 2e270d95e9d11cd3ac5adb18cb77c23e354a2d30 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 18:44:03 +0100 Subject: [PATCH 083/179] Update suppliers.lang --- htdocs/langs/fr_FR/suppliers.lang | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/langs/fr_FR/suppliers.lang b/htdocs/langs/fr_FR/suppliers.lang index 0aad31d294c..2f9b93ff323 100644 --- a/htdocs/langs/fr_FR/suppliers.lang +++ b/htdocs/langs/fr_FR/suppliers.lang @@ -45,4 +45,3 @@ BuyerName=Nom de l'acheteur AllProductServicePrices=Tous les prix du produits / service AllProductReferencesOfSupplier=Toutes les références des produits/services du fournisseur BuyingPriceNumShort=Prix fournisseurs -PriceUpdate=Mis à jour le \ No newline at end of file From e3e8e660052a669641b21872ee9185b55e4bb1c9 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 19:00:12 +0100 Subject: [PATCH 084/179] update with html5 compliant code --- htdocs/cron/list.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 11d2b3acd35..ab905f745de 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -394,7 +394,7 @@ print ' '; print ' '; print ''; print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Enabled"), '-2'=>$langs->trans("EnabledAndDisabled"), '2'=>$langs->trans("Archived")), $search_status, 1); -print ''; +print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print ''; @@ -505,11 +505,11 @@ if ($num > 0) if(!empty($obj->dateend)) {print dol_print_date($db->jdate($obj->dateend), 'dayhour');} print ''; - print ''; + print ''; if (!empty($obj->maxrun)) {print $obj->maxrun;} print ''; - print ''; + print ''; if (!empty($obj->nbrun)) {print $obj->nbrun;} else {print '0';} print ''; @@ -554,11 +554,11 @@ if ($num > 0) print ''; // Status - print ''; + print ''; print $object->getLibStatut(3); print ''; - print ''; + print ''; $backtourl = urlencode($_SERVER["PHP_SELF"].'?'.$param.($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'')); if ($user->rights->cron->create) From c61fbcf190cb14d644bbdee45f55111de2d8c356 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 19:01:47 +0100 Subject: [PATCH 085/179] update with html5 compliant code --- htdocs/ecm/search.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index 951c2586346..a5e296ae1e6 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -137,10 +137,10 @@ print ''; print ''; print ""; print ''; -print "'; -print "'; -print "'; -print "'; +print "'; +print "'; +print "'; +print "'; print "
'.$langs->trans("ECMSearchByKeywords").'
".$langs->trans("Ref").':
".$langs->trans("Title").':
".$langs->trans("Keyword").':
".$langs->trans("Ref").':
".$langs->trans("Title").':
".$langs->trans("Keyword").':
"; //print $langs->trans("ECMSectionManualDesc"); @@ -162,7 +162,7 @@ foreach($sectionauto as $sectioncur) print "".$sectioncur['label'].':'; print ''; print ''; print ''; @@ -173,7 +173,7 @@ foreach($sectionauto as $sectioncur) //if ($butshown % 2 == 1) // print '  '; -print ''; +print ''; print ""; //print $langs->trans("ECMSectionAutoDesc"); From 9f420bdd0817ce04939c85116424ee63686d2d3b Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 19:02:37 +0100 Subject: [PATCH 086/179] update with html5 compliant code --- htdocs/expensereport/class/expensereport.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 48902b45ca8..3fd386f4f69 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -856,12 +856,12 @@ class ExpenseReport extends CommonObject print ''; print ''.$objp->ref_num.''; - print ''.dol_print_date($objp->date, 'day').''; + print ''.dol_print_date($objp->date, 'day').''; print ''.$author->getNomUrl(1).''; print ''.$objp->comments.''; - print ''.price($objp->total_ht).''; - print ''.price($objp->total_ttc).''; - print ''; + print ''.price($objp->total_ht).''; + print ''.price($objp->total_ttc).''; + print ''; switch($objp->fk_c_expensereport_status) { case 4: @@ -895,8 +895,8 @@ class ExpenseReport extends CommonObject } print ''.$langs->trans("Number").': '.$i.''; - print ''.$langs->trans("TotalHT").' : '.price($total_HT).''; - print ''.$langs->trans("TotalTTC").' : '.price($total_TTC).''; + print ''.$langs->trans("TotalHT").' : '.price($total_HT).''; + print ''.$langs->trans("TotalTTC").' : '.price($total_TTC).''; print ' '; print ''; } From 309514c15c462aeaf764337cd5db51d0720c9806 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 19:03:58 +0100 Subject: [PATCH 087/179] update with html5 compliant code --- htdocs/expensereport/payment/card.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index 83de49358bc..73da11f4619 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -229,10 +229,10 @@ if ($resql) print ''; print ''.$langs->trans('ExpenseReport').''; - print ''.$langs->trans('ExpectedToPay').''; - print ''.$langs->trans('PayedByThisPayment').''; - print ''.$langs->trans('RemainderToPay').''; - print ''.$langs->trans('Status').''; + print ''.$langs->trans('ExpectedToPay').''; + print ''.$langs->trans('PayedByThisPayment').''; + print ''.$langs->trans('RemainderToPay').''; + print ''.$langs->trans('Status').''; print "\n"; if ($num > 0) @@ -252,16 +252,16 @@ if ($resql) print "\n"; // Expected to pay - print ''.price($objp->total_ttc).''; + print ''.price($objp->total_ttc).''; // Amount paid - print ''.price($objp->amount).''; + print ''.price($objp->amount).''; // Remain to pay - print ''.price($remaintopay).''; + print ''.price($remaintopay).''; // Status - print ''.$expensereport->getLibStatut(4, $objp->amount).''; + print ''.$expensereport->getLibStatut(4, $objp->amount).''; print "\n"; From 33aa7fa309fa8cd931e07d7b3665f32f38634d79 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 19:06:30 +0100 Subject: [PATCH 088/179] update with html5 compliant code --- htdocs/expensereport/payment/payment.php | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index cda372317ab..d95edae6450 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -289,10 +289,10 @@ if ($action == 'create' || empty($action)) print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print "\n"; $total=0; @@ -304,10 +304,10 @@ if ($action == 'create' || empty($action)) print ''; - print '"; - print '"; - print '"; - print '"; + print '"; + print '"; + print ''; - print ''; - print ""; - print ""; - print ""; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print "\n"; } From 133997b19587615a27f6f33291adb75992330cad Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 19:07:22 +0100 Subject: [PATCH 089/179] update with html5 compliant code --- htdocs/expensereport/stats/index.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index eb269d4f5f8..8980238c07b 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -242,7 +242,7 @@ if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; arsort($arrayyears); print $form->selectarray('year', $arrayyears, $year, 0); print ''; -print ''; +print ''; print '
'.$langs->trans("Amount").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").''.$langs->trans("Amount").''.$langs->trans("Amount").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").''.$langs->trans("Amount").'
'.price($objp->total_ttc)."'.price($sumpaid)."'.price($objp->total_ttc - $sumpaid)."'; + print ''.price($objp->total_ttc)."'.price($sumpaid)."'.price($objp->total_ttc - $sumpaid)."'; if ($sumpaid < $objp->total_ttc) { $namef = "amount_".$objp->id; @@ -335,11 +335,11 @@ if ($action == 'create' || empty($action)) { // Print total print '
'.$langs->trans("Total").':".price($total_ttc)."".price($totalrecu)."".price($total_ttc - $totalrecu)." '.$langs->trans("Total").':'.price($total_ttc).''.price($totalrecu).''.price($total_ttc - $totalrecu).' 
'; print ''; print '

'; @@ -250,10 +250,10 @@ print '

'; print '
'; print ''; print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; print ''; $oldyear=0; @@ -265,19 +265,19 @@ foreach ($data as $val) $oldyear--; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; } print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; $oldyear=$year; } @@ -289,7 +289,7 @@ print '
'; // Show graphs -print '
'.$langs->trans("Year").''.$langs->trans("Number").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").''.$langs->trans("Year").''.$langs->trans("Number").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
'.$oldyear.'000'.$oldyear.'000
'.$year.''.$val['nb'].''.price(price2num($val['total'], 'MT'), 1).''.price(price2num($val['avg'], 'MT'), 1).''.$year.''.$val['nb'].''.price(price2num($val['total'], 'MT'), 1).''.price(price2num($val['avg'], 'MT'), 1).'
'; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index fbc53183ea1..5f7789e72f5 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2310,6 +2310,7 @@ class CommandeFournisseur extends CommonOrder { $this->oldcopy= clone $this; $this->fk_projet = $id_projet; + $this->fk_project = $id_projet; } if (! $notrigger && empty($error)) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 6b533ae2d21..690acedb35d 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -578,7 +578,7 @@ class FactureFournisseur extends CommonInvoice $sql.= " t.fk_user_author,"; $sql.= " t.fk_user_valid,"; $sql.= " t.fk_facture_source,"; - $sql.= " t.fk_projet,"; + $sql.= " t.fk_projet as fk_project,"; $sql.= " t.fk_cond_reglement,"; $sql.= " t.fk_account,"; $sql.= " t.fk_mode_reglement,"; @@ -641,8 +641,8 @@ class FactureFournisseur extends CommonInvoice $this->author = $obj->fk_user_author; $this->fk_user_valid = $obj->fk_user_valid; $this->fk_facture_source = $obj->fk_facture_source; - $this->fk_project = $obj->fk_projet; - $this->cond_reglement_id = $obj->fk_cond_reglement; + $this->fk_project = $obj->fk_project; + $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; $this->cond_reglement_doc = $obj->cond_reglement_libelle; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 68eef7f5bd5..2cee7a5bade 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -65,7 +65,8 @@ DictionarySetup=Dictionary setup Dictionary=Dictionaries ErrorReservedTypeSystemSystemAuto=Value 'system' and 'systemauto' for type is reserved. You can use 'user' as value to add your own record ErrorCodeCantContainZero=Code can't contain value 0 -DisableJavascript=Disable JavaScript and Ajax functions (Recommended for blind person or text browsers) +DisableJavascript=Disable JavaScript and Ajax functions +DisableJavascriptNote=Note: For test or debug purpose. For optimization for blind person or text browsers, you may prefer to use the setup on the profile of user UseSearchToSelectCompanyTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant COMPANY_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. UseSearchToSelectContactTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant CONTACT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. DelaiedFullListToSelectCompany=Wait until a key is pressed before loading content of Third Parties combo list.
This may increase performance if you have a large number of third parties, but it is less convenient. diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index 19710e8915d..e34078e8fc2 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -148,3 +148,4 @@ nolimitbyEX_EXP=by line (no limitation) CarCategory=Category of car ExpenseRangeOffset=Offset amount: %s RangeIk=Mileage range +AttachTheNewLineToTheDocument=Attach the new line to an existing document diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index a1211ead4ee..73a6d9d2493 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -704,7 +704,7 @@ class Task extends CommonObject { $this->id=0; - $this->fk_projet=''; + $this->fk_project=''; $this->ref='TK01'; $this->fk_task_parent=null; $this->label='Specimen task TK01'; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index ae557aeb885..510ddce966e 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -57,7 +57,8 @@ input.select2-input { .liste_titre input[name=search_day_lim], .liste_titre input[name=search_day_start], .liste_titre input[name=search_day_end], .liste_titre input[name=search_day_create], .liste_titre input[name=search_day_create], .liste_titre input[name=search_day_start], .liste_titre input[name=search_day_end], .liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when], -.liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth] +.liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth], +select#date_startday, select#date_startmonth, select#date_endday, select#date_endmonth, select#reday, select#remonth { margin-right: 4px; } @@ -511,6 +512,9 @@ select.flat.selectlimit { .nomarginleft { margin-left: 0px !important; } +.margintoponly { + margin-top: 10px !important; +} .marginbottomonly { margin-bottom: 10px !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index cebdaad8164..d4da4f98fba 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -294,7 +294,8 @@ textarea.cke_source:focus .liste_titre input[name=search_day_lim], .liste_titre input[name=search_day_start], .liste_titre input[name=search_day_end], .liste_titre input[name=search_day_create], .liste_titre input[name=search_day_create], .liste_titre input[name=search_day_start], .liste_titre input[name=search_day_end], .liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when], -.liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth] +.liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth], +select#date_startday, select#date_startmonth, select#date_endday, select#date_endmonth, select#reday, select#remonth { margin-right: 4px; } @@ -744,6 +745,9 @@ select.flat.selectlimit { .nomarginleft { margin-left: 0px !important; } +.margintoponly { + margin-top: 10px !important; +} .marginbottomonly { margin-bottom: 10px !important; } From e5c08978c3df114bdf4fc6e64fcb7d31016c40ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 15:13:28 +0100 Subject: [PATCH 105/179] FIX Param keepn must be 1 when dol_escape_htmltag used for textarea --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/don/card.php | 4 ++-- htdocs/expensereport/card.php | 4 ++-- htdocs/projet/card.php | 2 +- htdocs/public/members/new.php | 4 ++-- htdocs/public/opensurvey/studs.php | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c302093c2d1..fbca9c33ca5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -923,7 +923,7 @@ function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0) * * @param string $stringtoescape String to escape * @param int $keepb 1=Preserve b tags (otherwise, remove them) - * @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value) + * @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value). Set to 1 when escaping for a '; + print ''; // Zip / Town print ''; print ''; print ''; + print ''; // Zip / Town print ''; // VAT @@ -2399,7 +2399,7 @@ else // Add comments print ''; // Select VAT diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 8089b66680d..362359f0999 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -616,7 +616,7 @@ if ($action == 'create' && $user->rights->projet->creer) // Description print ''; print ''; // Bill time diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 6ff856ed238..873a6858a1a 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -594,7 +594,7 @@ print ''; print ''."\n"; // Address print ''."\n"; +print ''."\n"; // Zip / Town print ''; print ''; -print ''; +print ''; print ''."\n"; // Add specific fields used by Dolibarr foundation for example diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index baa1e539a3b..d242b2df3c1 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -752,7 +752,7 @@ if ($comments) if ($object->allow_comments) { print '
' .$langs->trans("AddACommentForPoll") . "
\n"; - print '
'."\n"; + print '
'."\n"; print $langs->trans("Name") .': '; print '   '."\n"; print '
'."\n"; From 2da60fb885cbdfbd0f0ec3fdf4d8277b4b41225b Mon Sep 17 00:00:00 2001 From: atm-ph Date: Fri, 15 Mar 2019 15:15:03 +0100 Subject: [PATCH 106/179] Fix var name --- htdocs/projet/activity/perday.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 89ed60a0632..164a7462e83 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -498,7 +498,7 @@ $holiday = new Holiday($db); $isavailable=array(); $statusofholidaytocheck = '3'; -$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholiday); // $daytoparse is a date with hours = 0 +$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck); // $daytoparse is a date with hours = 0 $isavailable[$daytoparse]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day if (count($tasksarray) > 0) From 6f0fbc42c18d10dde65c4266b945d5634b64f76e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 15:13:28 +0100 Subject: [PATCH 107/179] FIX Param keepn must be 1 when dol_escape_htmltag used for textarea Conflicts: htdocs/expensereport/card.php htdocs/projet/card.php htdocs/public/members/new.php htdocs/public/opensurvey/studs.php --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/don/card.php | 4 ++-- htdocs/expensereport/card.php | 4 ++-- htdocs/projet/card.php | 2 +- htdocs/public/members/new.php | 4 ++-- htdocs/public/opensurvey/studs.php | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0a81f729fc8..57d5329717c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -965,7 +965,7 @@ function dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0) * * @param string $stringtoescape String to escape * @param int $keepb 1=Preserve b tags (otherwise, remove them) - * @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value) + * @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value). Set to 1 when escaping for a '; + print ''; // Zip / Town print '
'; print ''; print ''; + print ''; // Zip / Town print ''; // VAT @@ -2215,7 +2215,7 @@ else // Add comments print ''; // Select VAT diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index f2b735e6340..56646a1a470 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -616,7 +616,7 @@ if ($action == 'create' && $user->rights->projet->creer) // Description print ''; print ''; // Bill time diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 9a85191e34f..e793547edd7 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -586,7 +586,7 @@ print ''."\n"; // Address print ''."\n"; +print ''."\n"; // Zip / Town print ''; print ''; -print ''; +print ''; print ''."\n"; // Add specific fields used by Dolibarr foundation for example diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index acf986bb226..6b7eef356b3 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -752,7 +752,7 @@ if ($comments) if ($object->allow_comments) { print '
' .$langs->trans("AddACommentForPoll") . "
\n"; - print '
'."\n"; + print '
'."\n"; print $langs->trans("Name") .': '; print '   '."\n"; print '
'."\n"; From 0126303fae8a0d54adf80b7edd5dd34fb95213ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 16:05:50 +0100 Subject: [PATCH 108/179] Fix new line on description of expense report --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 819014a092e..d2a6fc965f8 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2076,7 +2076,7 @@ else $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code)); print $labeltype; print ''; - print '
'; + print ''; print ''; // Unit price HT print ''; } if (! empty($arrayfields['d.civility']['checked'])) { print ''; + print ''; } if (! empty($arrayfields['d.firstname']['checked'])) { print ''; + print ''; } if (! empty($arrayfields['d.lastname']['checked'])) { print ''; + print ''; } if (! empty($arrayfields['d.gender']['checked'])) { @@ -464,12 +464,12 @@ if (! empty($arrayfields['d.gender']['checked'])) if (! empty($arrayfields['d.company']['checked'])) { print ''; + print ''; } if (! empty($arrayfields['d.login']['checked'])) { print ''; + print ''; } if (! empty($arrayfields['d.morphy']['checked'])) { @@ -487,24 +487,24 @@ if (! empty($arrayfields['t.libelle']['checked'])) if (! empty($arrayfields['d.address']['checked'])) { print ''; + print ''; } if (! empty($arrayfields['d.zip']['checked'])) { print ''; + print ''; } if (! empty($arrayfields['d.town']['checked'])) { print ''; + print ''; } // State if (! empty($arrayfields['state.nom']['checked'])) { print ''; } // Country @@ -518,7 +518,7 @@ if (! empty($arrayfields['country.code_iso']['checked'])) if (! empty($arrayfields['d.phone']['checked'])) { print ''; + print ''; } // Phone perso if (! empty($arrayfields['d.phone_perso']['checked'])) @@ -530,13 +530,13 @@ if (! empty($arrayfields['d.phone_perso']['checked'])) if (! empty($arrayfields['d.phone_mobile']['checked'])) { print ''; + print ''; } // Email if (! empty($arrayfields['d.email']['checked'])) { print ''; + print ''; } if (! empty($arrayfields['d.datefin']['checked'])) From 91f80934f322701285b42629599428086b4234e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 20:39:55 +0100 Subject: [PATCH 126/179] Fix: On smartphone, hide label of status only on lists. --- htdocs/core/lib/functions.lib.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6814fc6d0ec..dcb64f47d9f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1501,10 +1501,6 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi if ($object->statut == 0) $morehtmlstatus.=$object->getLibStatut(5); else $morehtmlstatus.=$object->getLibStatut(4); } - elseif ($object->element == 'member') - { - $morehtmlstatus.=$object->getLibStatut(6); - } elseif ($object->element == 'facturerec') { if ($object->frequency == 0) $morehtmlstatus.=$object->getLibStatut(2); @@ -1520,7 +1516,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } else { // Generic case $tmptxt=$object->getLibStatut(6); - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt=$object->getLibStatut(5); $morehtmlstatus.=$tmptxt; } @@ -8022,8 +8018,8 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st // use status with images elseif (empty($conf->global->MAIN_STATUS_USES_CSS)){ $return = ''; - $htmlLabel = ''.(!empty($html)?$html:$statusLabel).''; - $htmlLabelShort = ''.(!empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel)).''; + $htmlLabel = (in_array($displayMode, array(1,2,5))?'':'').(!empty($html)?$html:$statusLabel).(in_array($displayMode, array(1,2,5))?'':''); + $htmlLabelShort = (in_array($displayMode, array(1,2,5))?'':'').(!empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel)).(in_array($displayMode, array(1,2,5))?'':''); if(!empty($statusImg[$statusType])){ $htmlImg = img_picto($statusLabel, $statusImg[$statusType]); @@ -8051,13 +8047,13 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st elseif (!empty($conf->global->MAIN_STATUS_USES_CSS) && !empty($displayMode)) { $statusLabelShort = !empty($statusLabelShort)?$statusLabelShort:$statusLabel; - if($displayMode == 3){ + if ($displayMode == 3) { $return = dolGetBadge($statusLabel, '', $statusType, 'dot'); } - elseif($displayMode === 5){ + elseif ($displayMode === 5) { $return = dolGetBadge($statusLabelShort, $html, $statusType); } - else{ + else { $return = dolGetBadge($statusLabel, $html, $statusType); } } From 7cdfff72636df68cce3436839a380f9b3bf12529 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 20:42:49 +0100 Subject: [PATCH 127/179] Fix syntax error --- htdocs/comm/propal/class/api_proposals.class.php | 2 +- htdocs/commande/class/api_orders.class.php | 2 +- htdocs/compta/facture/class/api_invoices.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 30a8e03cbd3..d9fe5ccaf1a 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -593,7 +593,7 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->propal->setDraftDolibarrApiAccess::$user); + $result = $this->propal->setDraft(DolibarrApiAccess::$user); if ($result == 0) { throw new RestException(304, 'Nothing done. May be object is already draft'); } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 777236bc4d8..27b55f9e57f 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -770,7 +770,7 @@ class Orders extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->commande->setDraftDolibarrApiAccess::$user, $idwarehouse); + $result = $this->commande->setDraft(DolibarrApiAccess::$user, $idwarehouse); if ($result == 0) { throw new RestException(304, 'Nothing done. May be object is already closed'); } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index cbaf2115c3e..bf7a102ffeb 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -745,7 +745,7 @@ class Invoices extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->invoice->setDraftDolibarrApiAccess::$user, $idwarehouse); + $result = $this->invoice->setDraft(DolibarrApiAccess::$user, $idwarehouse); if ($result == 0) { throw new RestException(304, 'Nothing done.'); } From 7a5a5611706dcc1538e68f7ad5fe7f4d4b5252ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 23:00:50 +0100 Subject: [PATCH 128/179] Fix label of status of invoice record when using smartphone --- htdocs/core/class/commoninvoice.class.php | 18 +++++++++--------- htdocs/core/lib/functions.lib.php | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 8ea15b31938..6e939a6278c 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -472,26 +472,26 @@ abstract class CommonInvoice extends CommonObject $statusType='status0'; $prefix='Short'; if (! $paye){ - if ($status == 0){ + if ($status == 0) { $labelstatut = $langs->trans('BillStatusDraft'); $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusDraft'); } - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0){ + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { $labelstatut = $langs->trans('BillStatusClosedUnpaid'); $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); $statusType='status5'; } - elseif (($status == 3 || $status == 2) && $alreadypaid > 0){ + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { $labelstatut = $langs->trans('BillStatusClosedPaidPartially'); $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); $statusType='status9'; } - elseif ($alreadypaid <= 0){ + elseif ($alreadypaid <= 0) { $labelstatut = $langs->trans('BillStatusNotPaid'); $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusNotPaid'); $statusType='status1'; } - else{ + else { $labelstatut = $langs->trans('BillStatusStarted'); $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusStarted'); $statusType='status3'; @@ -500,7 +500,7 @@ abstract class CommonInvoice extends CommonObject else { $statusType='status6'; - + if ($type == self::TYPE_CREDIT_NOTE){ $labelstatut = $langs->trans('BillStatusPaidBackOrConverted'); // credit note $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note @@ -514,8 +514,8 @@ abstract class CommonInvoice extends CommonObject $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusPaid'); } } - - + + return dolGetStatus($labelstatut, $labelstatutShort, '', $statusType, $mode); } @@ -525,7 +525,7 @@ abstract class CommonInvoice extends CommonObject * conditions de reglements de la facture et date de facturation. * * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. - * @return date Date limite de reglement si ok, <0 si ko + * @return integer Date limite de reglement si ok, <0 si ko */ public function calculate_date_lim_reglement($cond_reglement = 0) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dcb64f47d9f..3499e327f80 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1493,7 +1493,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) { $tmptxt=$object->getLibStatut(6, $object->totalpaye); - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt=$object->getLibStatut(5, $object->totalpaye); $morehtmlstatus.=$tmptxt; } elseif ($object->element == 'contrat' || $object->element == 'contract') @@ -8037,7 +8037,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st $return = $htmlImg .' '. $htmlLabel; } elseif ($displayMode === 5) { - $return = $htmlLabelShort .' '. $htmlImg; + $return = $displayMode.$htmlLabelShort .' '. $htmlImg; } else { // $displayMode >= 6 $return = $htmlLabel .' '. $htmlImg; From 40c2ca43101d57cf840573346f9269c88acc2708 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 23:08:00 +0100 Subject: [PATCH 129/179] Fix label of status of third party record when using smartphone --- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/societe/class/societe.class.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3499e327f80..76cbaa8e6d6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1480,14 +1480,14 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlstatus.=ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { - $morehtmlstatus.=''.$object->getLibStatut(5, 0).''; + $morehtmlstatus.=''.$object->getLibStatut(6, 0).''; } $morehtmlstatus.='   '; //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Buy").') '; if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlstatus.=ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { - $morehtmlstatus.=''.$object->getLibStatut(5, 1).''; + $morehtmlstatus.=''.$object->getLibStatut(6, 1).''; } } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index d0f7c012f83..31de0f24b20 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2288,8 +2288,8 @@ class Societe extends CommonObject } elseif ($mode == 6) { - if ($statut==0) return ''.$langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"'); - elseif ($statut==1) return ''.$langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"'); + if ($statut==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"'); + elseif ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"'); } } From 68945c7d518dfe27e4cc9ca1a522b02eeca2742f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 16 Mar 2019 09:10:25 +0100 Subject: [PATCH 130/179] Fix #10177 --- htdocs/societe/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 7fd461000ef..76d627249eb 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -973,7 +973,7 @@ else $object->idprof6 = GETPOST('idprof6', 'alpha'); $object->typent_id = GETPOST('typent_id', 'int'); $object->effectif_id = GETPOST('effectif_id', 'int'); - $object->civility_id = GETPOST('civility_id', 'int'); + $object->civility_id = GETPOST('civility_id', 'alpha'); $object->tva_assuj = GETPOST('assujtva_value', 'int'); $object->status = GETPOST('status', 'int'); From 21e2d364219b5df2faf78c018246213827fcea0f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 16 Mar 2019 09:28:47 +0100 Subject: [PATCH 131/179] Fix #9311 --- htdocs/fourn/facture/rapport.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fourn/facture/rapport.php b/htdocs/fourn/facture/rapport.php index c20b26b1263..b2126aae80b 100644 --- a/htdocs/fourn/facture/rapport.php +++ b/htdocs/fourn/facture/rapport.php @@ -26,6 +26,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/rapport/pdf_paiement_fourn.class.p require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +$langs->loadLangs(array('bills')); + // Security check $socid=''; if (! empty($user->societe_id)) $socid=$user->societe_id; From 4822a2d396eb89bc9c3502b8e1a3a4fab9280944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 16 Mar 2019 09:51:57 +0100 Subject: [PATCH 132/179] Update accountancycategory.class.php --- .../class/accountancycategory.class.php | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 1f30bcfcef3..523fba7acda 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -63,7 +63,7 @@ class AccountancyCategory // extends CommonObject public $id; /** - * @var mixed Sample property 1 + * @var string Accountancy code */ public $code; @@ -73,7 +73,7 @@ class AccountancyCategory // extends CommonObject public $label; /** - * @var mixed Sample property 1 + * @var string Accountancy range account */ public $range_account; @@ -83,37 +83,37 @@ class AccountancyCategory // extends CommonObject public $sens; /** - * @var mixed Sample property 1 + * @var int Category type of accountancy */ public $category_type; /** - * @var mixed Sample property 1 + * @var string Formula */ public $formula; /** - * @var mixed Sample property 1 + * @var int Position */ public $position; /** - * @var mixed Sample property 1 + * @var int country id */ public $fk_country; /** - * @var mixed Sample property 1 + * @var int Is active */ public $active; /** - * @var mixed Sample property 1 + * @var array Lines cptbk */ public $lines_cptbk; /** - * @var mixed Sample property 1 + * @var array Lines display */ public $lines_display; @@ -151,12 +151,12 @@ class AccountancyCategory // extends CommonObject if (isset($this->code)) $this->code=trim($this->code); if (isset($this->label)) $this->label=trim($this->label); if (isset($this->range_account)) $this->range_account=trim($this->range_account); - if (isset($this->sens)) $this->sens=trim($this->sens); - if (isset($this->category_type)) $this->category_type=trim($this->category_type); + if (isset($this->sens)) $this->sens = (int) $this->sens; + if (isset($this->category_type)) $this->category_type = (int) $this->category_type; if (isset($this->formula)) $this->formula=trim($this->formula); - if (isset($this->position)) $this->position=trim($this->position); - if (isset($this->fk_country)) $this->fk_country=trim($this->fk_country); - if (isset($this->active)) $this->active=trim($this->active); + if (isset($this->position)) $this->position = (int) $this->position; + if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country; + if (isset($this->active)) $this->active = (int) $this->active; // Check parameters // Put here code to add control on parameters values @@ -308,12 +308,12 @@ class AccountancyCategory // extends CommonObject if (isset($this->code)) $this->code=trim($this->code); if (isset($this->label)) $this->label=trim($this->label); if (isset($this->range_account)) $this->range_account=trim($this->range_account); - if (isset($this->sens)) $this->sens=trim($this->sens); - if (isset($this->category_type)) $this->category_type=trim($this->category_type); + if (isset($this->sens)) $this->sens = (int) $this->sens; + if (isset($this->category_type)) $this->category_type = (int) $this->category_type; if (isset($this->formula)) $this->formula=trim($this->formula); - if (isset($this->position)) $this->position=trim($this->position); - if (isset($this->fk_country)) $this->fk_country=trim($this->fk_country); - if (isset($this->active)) $this->active=trim($this->active); + if (isset($this->position)) $this->position = (int) $this->position; + if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country; + if (isset($this->active)) $this->active = (int) $this->active; // Check parameters @@ -338,8 +338,8 @@ class AccountancyCategory // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { + //if (! $error) + //{ // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. //if (! $notrigger) @@ -351,7 +351,7 @@ class AccountancyCategory // extends CommonObject // if ($result < 0) { $error++; $this->errors=$interface->errors; } // // End call triggers //} - } + //} // Commit or rollback if ($error) @@ -393,8 +393,8 @@ class AccountancyCategory // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { + //if (! $error) + //{ // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. //if (! $notrigger) @@ -406,7 +406,7 @@ class AccountancyCategory // extends CommonObject // if ($result < 0) { $error++; $this->errors=$interface->errors; } // // End call triggers //} - } + //} // Commit or rollback if ($error) From e5567c7ee4bc414b0f9bb5a1b78cc640695df513 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Mar 2019 14:48:41 +0100 Subject: [PATCH 133/179] Fix typo --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/functions.lib.php | 6 +++--- htdocs/theme/eldy/main_menu_fa_icons.inc.php | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 94fc1dc9e0e..9a84782e920 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1866,7 +1866,7 @@ class Adherent extends CommonObject $error=0; - // Check paramaters + // Check parameters if ($this->statut == 0) { dol_syslog(get_class($this)."::resiliate statut of member does not allow this", LOG_WARNING); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 69ff39ba0dd..3cb5cc6ecfa 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3916,7 +3916,7 @@ class Form * print '});'."\n"; * print ''."\n"; * - * @param string $page Url of page to call if confirmation is OK. Can contains paramaters (param 'action' and 'confirm' will be reformated) + * @param string $page Url of page to call if confirmation is OK. Can contains parameters (param 'action' and 'confirm' will be reformated) * @param string $title Title * @param string $question Question * @param string $action Action diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 76cbaa8e6d6..6623525341a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -437,7 +437,7 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti } } - // Substitution variables for GETPOST (used to get final url with variable parameters or final default value with variable paramaters) + // Substitution variables for GETPOST (used to get final url with variable parameters or final default value with variable parameters) // Example of variables: __DAY__, __MONTH__, __YEAR__, __MYCOMPANY_COUNTRY_ID__, __USER_ID__, ... // We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text. if (! is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) @@ -4194,7 +4194,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', * * @param int $page Number of page * @param string $file Page URL (in most cases provided with $_SERVER["PHP_SELF"]) - * @param string $options Other url paramaters to propagate ("" by default, may include sortfield and sortorder) + * @param string $options Other url parameters to propagate ("" by default, may include sortfield and sortorder) * @param integer $nextpage Do we show a next page button * @param string $betweenarrows HTML content to show between arrows. MUST contains '
  • ' tags or '
  • '. * @param string $afterarrows HTML content to show after arrows. Must NOT contains '
  • ' tags. @@ -7172,7 +7172,7 @@ function printCommonFooter($zone = 'private') else print "\n".''."\n"; // A div to store page_y POST parameter so we can read it using javascript - print "\n\n"; + print "\n\n"; print ''."\n"; $parameters=array(); diff --git a/htdocs/theme/eldy/main_menu_fa_icons.inc.php b/htdocs/theme/eldy/main_menu_fa_icons.inc.php index 94b02ea7323..6afa5cd90c0 100644 --- a/htdocs/theme/eldy/main_menu_fa_icons.inc.php +++ b/htdocs/theme/eldy/main_menu_fa_icons.inc.php @@ -81,7 +81,7 @@ div.mainmenu.companies::before { } div.mainmenu.commercial::before { - content: "\f508"; + content: "\f0f2"; } div.mainmenu.ecm::before { @@ -97,7 +97,7 @@ div.mainmenu.ftp::before { } div.mainmenu.hrm::before { - content: "\f5ca"; + content: "\f508"; } div.mainmenu.members::before { @@ -105,11 +105,11 @@ div.mainmenu.members::before { } div.mainmenu.products::before { - content: "\f468"; + content: "\f1b2"; } div.mainmenu.mrp::before { - content: "\f474"; + content: "\f1b3"; } div.mainmenu.project::before { From c2badb57d782dcd5f710cdaaad3ab972253c3577 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Mar 2019 16:27:14 +0100 Subject: [PATCH 134/179] NEW: Add module debugbar --- htdocs/core/modules/modDav.class.php | 2 +- htdocs/core/modules/modDebugBar.class.php | 133 ++ .../DataCollector/DolConfigCollector.php | 81 ++ .../DataCollector/DolExceptionsCollector.php | 34 + .../class/DataCollector/DolLogsCollector.php | 182 +++ .../DataCollector/DolMemoryCollector.php | 28 + .../DataCollector/DolMessagesCollector.php | 35 + .../class/DataCollector/DolQueryCollector.php | 117 ++ .../DataCollector/DolRequestDataCollector.php | 28 + .../DataCollector/DolTimeDataCollector.php | 34 + .../class/DataCollector/DolibarrCollector.php | 140 ++ htdocs/debugbar/class/DebugBar.php | 55 + htdocs/debugbar/class/TraceableDB.php | 679 ++++++++++ .../debugbar/class/actions_debugbar.class.php | 112 ++ htdocs/debugbar/class/autoloader.php | 19 + htdocs/debugbar/js/widgets.js | 75 ++ .../DebugBar/Bridge/CacheCacheCollector.php | 62 + .../DebugBar/Bridge/DoctrineCollector.php | 98 ++ .../DebugBar/Bridge/MonologCollector.php | 103 ++ .../DebugBar/Bridge/PropelCollector.php | 253 ++++ .../DebugBar/Bridge/SlimCollector.php | 66 + .../Bridge/SwiftMailer/SwiftLogCollector.php | 44 + .../Bridge/SwiftMailer/SwiftMailCollector.php | 92 ++ .../Bridge/Twig/TraceableTwigEnvironment.php | 417 ++++++ .../Bridge/Twig/TraceableTwigTemplate.php | 131 ++ .../DebugBar/Bridge/Twig/TwigCollector.php | 87 ++ .../DataCollector/AggregatedCollector.php | 166 +++ .../DebugBar/DataCollector/AssetProvider.php | 28 + .../DataCollector/ConfigCollector.php | 71 + .../DebugBar/DataCollector/DataCollector.php | 90 ++ .../DataCollector/DataCollectorInterface.php | 31 + .../DataCollector/ExceptionsCollector.php | 111 ++ .../DataCollector/LocalizationCollector.php | 64 + .../DataCollector/MemoryCollector.php | 63 + .../MessagesAggregateInterface.php | 21 + .../DataCollector/MessagesCollector.php | 152 +++ .../DataCollector/PDO/PDOCollector.php | 182 +++ .../DataCollector/PDO/TraceablePDO.php | 196 +++ .../PDO/TraceablePDOStatement.php | 74 ++ .../DataCollector/PDO/TracedStatement.php | 240 ++++ .../DataCollector/PhpInfoCollector.php | 51 + .../DebugBar/DataCollector/Renderable.php | 25 + .../DataCollector/RequestDataCollector.php | 48 + .../DataCollector/TimeDataCollector.php | 228 ++++ .../DebugBar/DataFormatter/DataFormatter.php | 169 +++ .../DataFormatter/DataFormatterInterface.php | 42 + htdocs/includes/DebugBar/DebugBar.php | 468 +++++++ .../includes/DebugBar/DebugBarException.php | 16 + .../includes/DebugBar/HttpDriverInterface.php | 63 + .../includes/DebugBar/JavascriptRenderer.php | 960 ++++++++++++++ htdocs/includes/DebugBar/OpenHandler.php | 107 ++ htdocs/includes/DebugBar/PhpHttpDriver.php | 49 + .../includes/DebugBar/RequestIdGenerator.php | 22 + .../DebugBar/RequestIdGeneratorInterface.php | 21 + .../includes/DebugBar/Resources/debugbar.css | 289 ++++ .../includes/DebugBar/Resources/debugbar.js | 1161 +++++++++++++++++ .../DebugBar/Resources/openhandler.css | 69 + .../DebugBar/Resources/openhandler.js | 202 +++ .../font-awesome/css/font-awesome.min.css | 4 + .../vendor/font-awesome/fonts/FontAwesome.otf | Bin 0 -> 85908 bytes .../fonts/fontawesome-webfont.eot | Bin 0 -> 56006 bytes .../fonts/fontawesome-webfont.svg | 520 ++++++++ .../fonts/fontawesome-webfont.ttf | Bin 0 -> 112160 bytes .../fonts/fontawesome-webfont.woff | Bin 0 -> 65452 bytes .../vendor/highlightjs/highlight.pack.js | 1 + .../vendor/highlightjs/styles/github.css | 125 ++ .../vendor/jquery/dist/jquery.min.js | 2 + .../includes/DebugBar/Resources/widgets.css | 243 ++++ htdocs/includes/DebugBar/Resources/widgets.js | 499 +++++++ .../Resources/widgets/mails/widget.css | 12 + .../Resources/widgets/mails/widget.js | 40 + .../Resources/widgets/sqlqueries/widget.css | 82 ++ .../Resources/widgets/sqlqueries/widget.js | 96 ++ .../Resources/widgets/templates/widget.css | 60 + .../Resources/widgets/templates/widget.js | 69 + htdocs/includes/DebugBar/StandardDebugBar.php | 34 + .../includes/DebugBar/Storage/FileStorage.php | 108 ++ .../DebugBar/Storage/MemcachedStorage.php | 91 ++ .../includes/DebugBar/Storage/PdoStorage.php | 117 ++ .../DebugBar/Storage/RedisStorage.php | 74 ++ .../DebugBar/Storage/StorageInterface.php | 45 + .../DebugBar/Storage/pdo_storage_schema.sql | 16 + htdocs/includes/Psr/Log/AbstractLogger.php | 128 ++ .../Psr/Log/InvalidArgumentException.php | 7 + htdocs/includes/Psr/Log/LogLevel.php | 18 + .../includes/Psr/Log/LoggerAwareInterface.php | 18 + htdocs/includes/Psr/Log/LoggerAwareTrait.php | 26 + htdocs/includes/Psr/Log/LoggerInterface.php | 123 ++ htdocs/includes/Psr/Log/LoggerTrait.php | 140 ++ htdocs/includes/Psr/Log/NullLogger.php | 28 + .../Psr/Log/Test/LoggerInterfaceTest.php | 140 ++ htdocs/langs/en_US/admin.lang | 7 +- .../core/modules/modMyModule.class.php | 4 +- htdocs/theme/eldy/img/object_debugbar.png | Bin 0 -> 827 bytes htdocs/theme/md/img/object_debugbar.png | Bin 0 -> 827 bytes 95 files changed, 11459 insertions(+), 4 deletions(-) create mode 100644 htdocs/core/modules/modDebugBar.class.php create mode 100644 htdocs/debugbar/class/DataCollector/DolConfigCollector.php create mode 100644 htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php create mode 100644 htdocs/debugbar/class/DataCollector/DolLogsCollector.php create mode 100644 htdocs/debugbar/class/DataCollector/DolMemoryCollector.php create mode 100644 htdocs/debugbar/class/DataCollector/DolMessagesCollector.php create mode 100644 htdocs/debugbar/class/DataCollector/DolQueryCollector.php create mode 100644 htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php create mode 100644 htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php create mode 100644 htdocs/debugbar/class/DataCollector/DolibarrCollector.php create mode 100644 htdocs/debugbar/class/DebugBar.php create mode 100644 htdocs/debugbar/class/TraceableDB.php create mode 100644 htdocs/debugbar/class/actions_debugbar.class.php create mode 100644 htdocs/debugbar/class/autoloader.php create mode 100644 htdocs/debugbar/js/widgets.js create mode 100644 htdocs/includes/DebugBar/Bridge/CacheCacheCollector.php create mode 100644 htdocs/includes/DebugBar/Bridge/DoctrineCollector.php create mode 100644 htdocs/includes/DebugBar/Bridge/MonologCollector.php create mode 100644 htdocs/includes/DebugBar/Bridge/PropelCollector.php create mode 100644 htdocs/includes/DebugBar/Bridge/SlimCollector.php create mode 100644 htdocs/includes/DebugBar/Bridge/SwiftMailer/SwiftLogCollector.php create mode 100644 htdocs/includes/DebugBar/Bridge/SwiftMailer/SwiftMailCollector.php create mode 100644 htdocs/includes/DebugBar/Bridge/Twig/TraceableTwigEnvironment.php create mode 100644 htdocs/includes/DebugBar/Bridge/Twig/TraceableTwigTemplate.php create mode 100644 htdocs/includes/DebugBar/Bridge/Twig/TwigCollector.php create mode 100644 htdocs/includes/DebugBar/DataCollector/AggregatedCollector.php create mode 100644 htdocs/includes/DebugBar/DataCollector/AssetProvider.php create mode 100644 htdocs/includes/DebugBar/DataCollector/ConfigCollector.php create mode 100644 htdocs/includes/DebugBar/DataCollector/DataCollector.php create mode 100644 htdocs/includes/DebugBar/DataCollector/DataCollectorInterface.php create mode 100644 htdocs/includes/DebugBar/DataCollector/ExceptionsCollector.php create mode 100644 htdocs/includes/DebugBar/DataCollector/LocalizationCollector.php create mode 100644 htdocs/includes/DebugBar/DataCollector/MemoryCollector.php create mode 100644 htdocs/includes/DebugBar/DataCollector/MessagesAggregateInterface.php create mode 100644 htdocs/includes/DebugBar/DataCollector/MessagesCollector.php create mode 100644 htdocs/includes/DebugBar/DataCollector/PDO/PDOCollector.php create mode 100644 htdocs/includes/DebugBar/DataCollector/PDO/TraceablePDO.php create mode 100644 htdocs/includes/DebugBar/DataCollector/PDO/TraceablePDOStatement.php create mode 100644 htdocs/includes/DebugBar/DataCollector/PDO/TracedStatement.php create mode 100644 htdocs/includes/DebugBar/DataCollector/PhpInfoCollector.php create mode 100644 htdocs/includes/DebugBar/DataCollector/Renderable.php create mode 100644 htdocs/includes/DebugBar/DataCollector/RequestDataCollector.php create mode 100644 htdocs/includes/DebugBar/DataCollector/TimeDataCollector.php create mode 100644 htdocs/includes/DebugBar/DataFormatter/DataFormatter.php create mode 100644 htdocs/includes/DebugBar/DataFormatter/DataFormatterInterface.php create mode 100644 htdocs/includes/DebugBar/DebugBar.php create mode 100644 htdocs/includes/DebugBar/DebugBarException.php create mode 100644 htdocs/includes/DebugBar/HttpDriverInterface.php create mode 100644 htdocs/includes/DebugBar/JavascriptRenderer.php create mode 100644 htdocs/includes/DebugBar/OpenHandler.php create mode 100644 htdocs/includes/DebugBar/PhpHttpDriver.php create mode 100644 htdocs/includes/DebugBar/RequestIdGenerator.php create mode 100644 htdocs/includes/DebugBar/RequestIdGeneratorInterface.php create mode 100644 htdocs/includes/DebugBar/Resources/debugbar.css create mode 100644 htdocs/includes/DebugBar/Resources/debugbar.js create mode 100644 htdocs/includes/DebugBar/Resources/openhandler.css create mode 100644 htdocs/includes/DebugBar/Resources/openhandler.js create mode 100644 htdocs/includes/DebugBar/Resources/vendor/font-awesome/css/font-awesome.min.css create mode 100644 htdocs/includes/DebugBar/Resources/vendor/font-awesome/fonts/FontAwesome.otf create mode 100644 htdocs/includes/DebugBar/Resources/vendor/font-awesome/fonts/fontawesome-webfont.eot create mode 100644 htdocs/includes/DebugBar/Resources/vendor/font-awesome/fonts/fontawesome-webfont.svg create mode 100644 htdocs/includes/DebugBar/Resources/vendor/font-awesome/fonts/fontawesome-webfont.ttf create mode 100644 htdocs/includes/DebugBar/Resources/vendor/font-awesome/fonts/fontawesome-webfont.woff create mode 100644 htdocs/includes/DebugBar/Resources/vendor/highlightjs/highlight.pack.js create mode 100644 htdocs/includes/DebugBar/Resources/vendor/highlightjs/styles/github.css create mode 100644 htdocs/includes/DebugBar/Resources/vendor/jquery/dist/jquery.min.js create mode 100644 htdocs/includes/DebugBar/Resources/widgets.css create mode 100644 htdocs/includes/DebugBar/Resources/widgets.js create mode 100644 htdocs/includes/DebugBar/Resources/widgets/mails/widget.css create mode 100644 htdocs/includes/DebugBar/Resources/widgets/mails/widget.js create mode 100644 htdocs/includes/DebugBar/Resources/widgets/sqlqueries/widget.css create mode 100644 htdocs/includes/DebugBar/Resources/widgets/sqlqueries/widget.js create mode 100644 htdocs/includes/DebugBar/Resources/widgets/templates/widget.css create mode 100644 htdocs/includes/DebugBar/Resources/widgets/templates/widget.js create mode 100644 htdocs/includes/DebugBar/StandardDebugBar.php create mode 100644 htdocs/includes/DebugBar/Storage/FileStorage.php create mode 100644 htdocs/includes/DebugBar/Storage/MemcachedStorage.php create mode 100644 htdocs/includes/DebugBar/Storage/PdoStorage.php create mode 100644 htdocs/includes/DebugBar/Storage/RedisStorage.php create mode 100644 htdocs/includes/DebugBar/Storage/StorageInterface.php create mode 100644 htdocs/includes/DebugBar/Storage/pdo_storage_schema.sql create mode 100644 htdocs/includes/Psr/Log/AbstractLogger.php create mode 100644 htdocs/includes/Psr/Log/InvalidArgumentException.php create mode 100644 htdocs/includes/Psr/Log/LogLevel.php create mode 100644 htdocs/includes/Psr/Log/LoggerAwareInterface.php create mode 100644 htdocs/includes/Psr/Log/LoggerAwareTrait.php create mode 100644 htdocs/includes/Psr/Log/LoggerInterface.php create mode 100644 htdocs/includes/Psr/Log/LoggerTrait.php create mode 100644 htdocs/includes/Psr/Log/NullLogger.php create mode 100644 htdocs/includes/Psr/Log/Test/LoggerInterfaceTest.php create mode 100644 htdocs/theme/eldy/img/object_debugbar.png create mode 100644 htdocs/theme/md/img/object_debugbar.png diff --git a/htdocs/core/modules/modDav.class.php b/htdocs/core/modules/modDav.class.php index 55378e6b5fb..676b8e9b8bc 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -19,7 +19,7 @@ * \defgroup dav Module dav * \brief dav module descriptor. * - * \file htdocs/dav/core/modules/modDav.class.php + * \file htdocs/core/modules/modDav.class.php * \ingroup dav * \brief Description and activation file for module dav */ diff --git a/htdocs/core/modules/modDebugBar.class.php b/htdocs/core/modules/modDebugBar.class.php new file mode 100644 index 00000000000..84c18d1b220 --- /dev/null +++ b/htdocs/core/modules/modDebugBar.class.php @@ -0,0 +1,133 @@ +. + */ + +/** + * \defgroup debugbar Debug bar + * \brief debugbar module descriptor. + * + * \file htdocs/core/modules/modDebugBar.class.php + * \ingroup debugbar + * \brief Description and activation file for module debugbar + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + + +/** + * Class to describe and enable module + */ +class modDebugBar extends DolibarrModules +{ + + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + + $this->numero = 43; + + $this->rights_class = 'debugbar'; + + $this->family = "base"; + $this->module_position = '75'; + + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Debug bar"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + $this->picto='technic'; + + $this->module_parts = array( + // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' + 'hooks' => array( + 'data' => array( + 'main', + 'login', + ), + 'entity' => '0', + ), + // Set this to 1 if feature of module are opened to external users + 'moduleforexternal' => 0, + ); + + // Data directories to create when module is enabled + $this->dirs = array(); + + // Dependencies + $this->depends = array(); // May be used for product or service or third party module + $this->requiredby = array(); + + // Config pages + $this->config_page_url = array(); + + // Constants + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); + $this->const = array( + 0 => array('DEBUGBAR_LOGS_LINES_NUMBER', 'chaine', '100', 'Number of log lines to show in debug bar', 1) + ); + + // Boxes + $this->boxes = array(); + + // Permissions + $this->rights = array(); + + $this->rights[1][0] = 430; // 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 + $this->rights[1][4] = 'read'; + } + + + /** + * 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 ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + // Permissions + $this->remove($options); + + $sql = array( + ); + + return $this->_init($sql, $options); + } + + /** + * Function called after module configuration. + * + */ + public function loadSettings() + { + $this->addPermission("use", "UseDebugBar", "u"); + + $this->enableHooks(array( + 'main', + 'login' + )); + } +} diff --git a/htdocs/debugbar/class/DataCollector/DolConfigCollector.php b/htdocs/debugbar/class/DataCollector/DolConfigCollector.php new file mode 100644 index 00000000000..c047f36a5ce --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/DolConfigCollector.php @@ -0,0 +1,81 @@ +transnoentities('Config') => array( + "icon" => "gear", + "widget" => "PhpDebugBar.Widgets.VariableListWidget", + "map" => $this->getName(), + "default" => "{}" + ) + ); + } + + /** + * Return collected data + * + */ + public function collect() + { + $this->data = $this->getConfig(); + + return parent::collect(); + } + + /** + * Returns an array with config data + * + */ + protected function getConfig() + { + global $conf, $user; + + // Get constants + $const = get_defined_constants(true); + + $config = array( + 'Dolibarr' => array( + 'const' => $const['user'], + '$conf' => $this->object_to_array($conf), + '$user' => $this->object_to_array($user) + ), + 'PHP' => array( + 'version' => PHP_VERSION, + 'interface' => PHP_SAPI, + 'os' => PHP_OS + ) + ); + + return $config; + } + + /** + * Convert an object to array + * + */ + protected function object_to_array($obj) + { + $_arr = is_object($obj) ? get_object_vars($obj) : $obj; + foreach ($_arr as $key => $val) { + $val = (is_array($val) || is_object($val)) ? $this->object_to_array($val) : $val; + $arr[$key] = $val; + } + + return $arr; + } +} \ No newline at end of file diff --git a/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php b/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php new file mode 100644 index 00000000000..a39d6189792 --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php @@ -0,0 +1,34 @@ +transnoentities('Exceptions'); + + return array( + "$title" => array( + 'icon' => 'bug', + 'widget' => 'PhpDebugBar.Widgets.ExceptionsWidget', + 'map' => 'exceptions.exceptions', + 'default' => '[]' + ), + "$title:badge" => array( + 'map' => 'exceptions.count', + 'default' => 'null' + ) + ); + } +} \ No newline at end of file diff --git a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php new file mode 100644 index 00000000000..b282f1a4a02 --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php @@ -0,0 +1,182 @@ +path = $path ?: $this->getLogsFile(); + $this->lines = $conf->global->DEBUGBAR_LOGS_LINES_NUMBER ? $conf->global->DEBUGBAR_LOGS_LINES_NUMBER : 100; + } + + /** + * Return widget settings + * + */ + public function getWidgets() + { + global $langs; + + $title = $langs->transnoentities('Logs'); + $name = $this->getName(); + + return array( + "$title" => array( + "icon" => "list-alt", + "widget" => "PhpDebugBar.Widgets.MessagesWidget", + "map" => "$name.messages", + "default" => "[]" + ), + "$title:badge" => array( + "map" => "$name.count", + "default" => "null" + ) + ); + } + + /** + * Return collected data + * + */ + public function collect() + { + $this->getStorageLogs($this->path); + + return parent::collect(); + } + + /** + * Get the path to the logs file + * + * @return string + */ + public function getLogsFile() + { + // default dolibarr log file + $path = DOL_DATA_ROOT . '/dolibarr.log'; + + return $path; + } + + /** + * Get logs + * + * @param string $path + * @return array + */ + public function getStorageLogs($path) + { + if (! file_exists($path)) { + return; + } + + // Load the latest lines + $file = implode("", $this->tailFile($path, $this->lines)); + + foreach ($this->getLogs($file) as $log) { + $this->addMessage($log['line'], $log['level'], false); + } + } + + /** + * Get latest file lines + * + * @param string $file + * @param int $lines + * @return array + */ + protected function tailFile($file, $lines) + { + $handle = fopen($file, "r"); + $linecounter = $lines; + $pos = -2; + $beginning = false; + $text = []; + while ($linecounter > 0) { + $t = " "; + while ($t != "\n") { + if (fseek($handle, $pos, SEEK_END) == -1) { + $beginning = true; + break; + } + $t = fgetc($handle); + $pos--; + } + $linecounter--; + if ($beginning) { + rewind($handle); + } + $text[$lines - $linecounter - 1] = fgets($handle); + if ($beginning) { + break; + } + } + fclose($handle); + return array_reverse($text); + } + + /** + * Search a string for log entries + * + * @param $file + * @return array + */ + public function getLogs($file) + { + $pattern = "/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*/"; + $log_levels = $this->getLevels(); + preg_match_all($pattern, $file, $matches); + $log = []; + foreach ($matches as $lines) { + foreach ($lines as $line) { + foreach ($log_levels as $level_key => $level) { + if (strpos(strtolower($line), strtolower($level_key)) == 20) { + $log[] = ['level' => $level, 'line' => $line]; + } + } + } + } + $log = array_reverse($log); + return $log; + } + + /** + * Get the log levels from psr/log. + * + * @return array + */ + public function getLevels() + { + $class = new ReflectionClass(new LogLevel()); + $levels = $class->getConstants(); + $levels['ERR'] = 'error'; + + return $levels; + } +} \ No newline at end of file diff --git a/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php b/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php new file mode 100644 index 00000000000..0c956c420dc --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php @@ -0,0 +1,28 @@ + array( + "icon" => "cogs", + "tooltip" => $langs->transnoentities('MemoryUsage'), + "map" => "memory.peak_usage_str", + "default" => "'0B'" + ) + ); + } +} \ No newline at end of file diff --git a/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php b/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php new file mode 100644 index 00000000000..b989b882e3c --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php @@ -0,0 +1,35 @@ +transnoentities('Messages'); + $name = $this->getName(); + + return array( + "$title" => array( + "icon" => "list-alt", + "widget" => "PhpDebugBar.Widgets.MessagesWidget", + "map" => "$name.messages", + "default" => "[]" + ), + "$title:badge" => array( + "map" => "$name.count", + "default" => "null" + ) + ); + } +} \ No newline at end of file diff --git a/htdocs/debugbar/class/DataCollector/DolQueryCollector.php b/htdocs/debugbar/class/DataCollector/DolQueryCollector.php new file mode 100644 index 00000000000..9ef01b58a79 --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/DolQueryCollector.php @@ -0,0 +1,117 @@ +db = $db; + } + + /** + * Return collected data + * + */ + public function collect() + { + $queries = array(); + $totalExecTime = 0; + $totalMemoryUsage = 0; + $totalFailed = 0; + foreach ($this->db->queries as $query) { + $queries[] = array( + 'sql' => $query['sql'], + 'duration' => $query['duration'], + 'duration_str' => $this->formatDuration($query['duration']), + 'memory' => $query['memory_usage'], + 'memory_str' => $this->formatBytes($query['memory_usage']), + 'is_success' => $query['is_success'], + 'error_code' => $query['error_code'], + 'error_message' => $query['error_message'] + ); + $totalExecTime += $query['duration']; + $totalMemoryUsage += $query['memory_usage']; + if (! $query['is_success']) { + $totalFailed += 1; + } + } + + return array( + 'nb_statements' => count($queries), + 'nb_failed_statements' => $totalFailed, + 'accumulated_duration' => $totalExecTime, + 'accumulated_duration_str' => $this->formatDuration($totalExecTime), + 'memory_usage' => $totalMemoryUsage, + 'memory_usage_str' => $this->formatBytes($totalMemoryUsage), + 'statements' => $queries + ); + } + + /** + * Return collector name + * + */ + public function getName() + { + return 'query'; + } + + /** + * Return widget settings + * + */ + public function getWidgets() + { + global $langs; + + $title = $langs->transnoentities('Database'); + + return array( + "$title" => array( + "icon" => "arrow-right", + "widget" => "PhpDebugBar.Widgets.SQLQueriesWidget", + "map" => "query", + "default" => "[]" + ), + "$title:badge" => array( + "map" => "query.nb_statements", + "default" => 0 + ) + ); + } + + /** + * Return assets + * + */ + public function getAssets() + { + return array( + 'css' => 'widgets/sqlqueries/widget.css', + 'js' => 'widgets/sqlqueries/widget.js' + ); + } +} \ No newline at end of file diff --git a/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php b/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php new file mode 100644 index 00000000000..55cee351904 --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php @@ -0,0 +1,28 @@ +transnoentities('Request') => array( + "icon" => "tags", + "widget" => "PhpDebugBar.Widgets.VariableListWidget", + "map" => "request", + "default" => "{}" + ) + ); + } +} \ No newline at end of file diff --git a/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php b/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php new file mode 100644 index 00000000000..dd78d21f726 --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php @@ -0,0 +1,34 @@ + array( + "icon" => "clock-o", + "tooltip" => $langs->transnoentities('RequestDuration'), + "map" => "time.duration_str", + "default" => "'0ms'" + ), + $langs->transnoentities('Timeline') => array( + "icon" => "tasks", + "widget" => "PhpDebugBar.Widgets.TimelineWidget", + "map" => "time", + "default" => "{}" + ) + ); + } +} \ No newline at end of file diff --git a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php new file mode 100644 index 00000000000..ea1381774af --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php @@ -0,0 +1,140 @@ +trans('Host') . ': ' . $conf->db->host . '
    '; + $info .= $langs->trans('Port') . ': ' . $conf->db->port . '
    '; + $info .= $langs->trans('Name') . ': ' . $conf->db->name . '
    '; + $info .= $langs->trans('User') . ': ' . $conf->db->user . '
    '; + $info .= $langs->trans('Type') . ': ' . $conf->db->type . '
    '; + $info .= $langs->trans('Prefix') . ': ' . $conf->db->prefix . '
    '; + $info .= $langs->trans('Charset') . ': ' . $conf->db->character_set . ''; + + return $info; + } + + /** + * Return dolibarr info as an HTML string + * + */ + protected function getDolibarrInfo() + { + global $conf, $langs; + + $info = $langs->trans('Version') . ': ' . DOL_VERSION . '
    '; + $info .= $langs->trans('Theme') . ': ' . $conf->theme . '
    '; + $info .= $langs->trans('Locale') . ': ' . $conf->global->MAIN_LANG_DEFAULT . '
    '; + $info .= $langs->trans('Currency') . ': ' . $conf->currency . '
    '; + $info .= $langs->trans('DolEntity') . ': ' . $conf->entity . '
    '; + $info .= $langs->trans('ListLimit') . ': ' . ($conf->liste_limit ?: $conf->global->MAIN_SIZE_LISTE_LIMIT) . '
    '; + $info .= $langs->trans('UploadSize') . ': ' . $conf->global->MAIN_UPLOAD_DOC . ''; + + return $info; + } + + /** + * Return mail info as an HTML string + * + */ + protected function getMailInfo() + { + global $conf, $langs; + + $info = $langs->trans('Method') . ': ' . $conf->global->MAIN_MAIL_SENDMODE . '
    '; + $info .= $langs->trans('Server') . ': ' . $conf->global->MAIN_MAIL_SMTP_SERVER . '
    '; + $info .= $langs->trans('Port') . ': ' . $conf->global->MAIN_MAIL_SMTP_PORT . '
    '; + $info .= $langs->trans('ID') . ': ' . $conf->global->MAIN_MAIL_SMTPS_ID . '
    '; + $info .= $langs->trans('Pwd') . ': ' . $conf->global->MAIN_MAIL_SMTPS_PW . '
    '; + $info .= $langs->trans('TLS/STARTTLS') . ': ' . $conf->global->MAIN_MAIL_EMAIL_TLS . ' / ' . $conf->global->MAIN_MAIL_EMAIL_STARTTLS . '
    '; + $info .= $langs->trans('Status') . ': ' . ($conf->global->MAIN_DISABLE_ALL_MAILS ? $langs->trans('StatusDisabled') : $langs->trans('StatusEnabled')) . ''; + + return $info; + } + + /** + * Return widget settings + * + */ + public function getWidgets() + { + return array( + "database_info" => array( + "icon" => "database", + "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator", + "tooltip" => array( + "html" => $this->getDatabaseInfo(), + "class" => "tooltip-wide" + ), + "map" => "", + "default" => "" + ), + "dolibarr_info" => array( + "icon" => "desktop", + "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator", + "tooltip" => array( + "html" => $this->getDolibarrInfo(), + "class" => "tooltip-wide" + ), + "map" => "", + "default" => "" + ), + "mail_info" => array( + "icon" => "envelope", + "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator", + "tooltip" => array( + "html" => $this->getMailInfo(), + "class" => "tooltip-extra-wide" + ), + "map" => "", + "default" => "" + ) + ); + } + + /** + * Return collector assests + * + */ + public function getAssets() + { + return array( + 'base_url' => dol_buildpath('/debugbar', 1), + 'js' => 'js/widgets.js' + ); + } +} \ No newline at end of file diff --git a/htdocs/debugbar/class/DebugBar.php b/htdocs/debugbar/class/DebugBar.php new file mode 100644 index 00000000000..5ac6d828035 --- /dev/null +++ b/htdocs/debugbar/class/DebugBar.php @@ -0,0 +1,55 @@ +addCollector(new PhpInfoCollector()); + $this->addCollector(new DolMessagesCollector()); + $this->addCollector(new DolRequestDataCollector()); + $this->addCollector(new DolConfigCollector()); + $this->addCollector(new DolTimeDataCollector()); + $this->addCollector(new DolMemoryCollector()); + $this->addCollector(new DolExceptionsCollector()); + $this->addCollector(new DolQueryCollector()); + $this->addCollector(new DolibarrCollector()); + if ($conf->syslog->enabled) { + $this->addCollector(new DolLogsCollector()); + } + } + + /** + * Returns a JavascriptRenderer for this instance + * + */ + public function getRenderer() + { + return parent::getJavascriptRenderer(DOL_URL_ROOT.'/includes/DebugBar/Resources'); + } +} \ No newline at end of file diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php new file mode 100644 index 00000000000..b0f871a97c4 --- /dev/null +++ b/htdocs/debugbar/class/TraceableDB.php @@ -0,0 +1,679 @@ +db::LABEL (but this is a constant? o_O) + /** + * @const Version min database + */ + const VERSIONMIN = ''; // TODO: the same thing here, $this->db::VERSIONMIN is the right value + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + $this->type = $db->type; + $this->queries = array(); + } + + /** + * Format a SQL IF + * + * @param string $test Test string (example: 'cd.statut=0', 'field IS NULL') + * @param string $resok resultat si test egal + * @param string $resko resultat si test non egal + * @return string SQL string + */ + public function ifsql($test, $resok, $resko) + { + return $this->db->ifsql($test, $resok, $resko); + } + + /** + * Return datas as an array + * + * @param resource $resultset Resultset of request + * @return array Array + */ + public function fetch_row($resultset) + { + return $this->db->fetch_row($resultset); + } + + /** + * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. + * Function to use to build INSERT, UPDATE or WHERE predica + * + * @param int $param Date TMS to convert + * @return string Date in a string YYYYMMDDHHMMSS + */ + public function idate($param) + { + return $this->db->idate($param); + } + + /** + * Return last error code + * + * @return string lasterrno + */ + public function lasterrno() + { + return $this->db->lasterrno(); + } + + /** + * Start transaction + * + * @return int 1 if transaction successfuly opened or already opened, 0 if error + */ + public function begin() + { + return $this->db->begin(); + } + + /** + * Create a new database + * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated + * We force to create database with charset this->forcecharset and collate this->forcecollate + * + * @param string $database Database name to create + * @param string $charset Charset used to store data + * @param string $collation Charset used to sort data + * @param string $owner Username of database owner + * @return resource resource defined if OK, null if KO + */ + public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') + { + return $this->db->DDLCreateDb($database, $charset, $collation, $owner); + } + + /** + * Return version of database server into an array + * + * @return array Version array + */ + public function getVersionArray() + { + return $this->db->getVersionArray(); + } + + /** + * Convert a SQL request in Mysql syntax to native syntax + * + * @param string $line SQL request line to convert + * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) + * @return string SQL request line converted + */ + public static function convertSQLFromMysql($line, $type = 'ddl') + { + return $this->db->convertSQLFromMysql($line); + } + + /** + * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE + * + * @param resource $resultset Curseur de la requete voulue + * @return int Nombre de lignes + * @see num_rows + */ + public function affected_rows($resultset) + { + return $this->db->affected_rows($resultset); + } + + /** + * Return description of last error + * + * @return string Error text + */ + public function error() + { + return $this->db->error(); + } + + /** + * List tables into a database + * + * @param string $database Name of database + * @param string $table Nmae of table filter ('xxx%') + * @return array List of tables in an array + */ + public function DDLListTables($database, $table = '') + { + return $this->db->DDLListTables($database, $table); + } + + /** + * Return last request executed with query() + * + * @return string Last query + */ + public function lastquery() + { + return $this->db->lastquery(); + } + + /** + * Define sort criteria of request + * + * @param string $sortfield List of sort fields + * @param string $sortorder Sort order + * @return string String to provide syntax of a sort sql string + */ + public function order($sortfield = null, $sortorder = null) + { + return $this->db->order($sortfield, $sortorder); + } + + /** + * Decrypt sensitive data in database + * + * @param string $value Value to decrypt + * @return string Decrypted value if used + */ + public function decrypt($value) + { + return $this->db->decrypt($value); + } + + /** + * Return datas as an array + * + * @param resource $resultset Resultset of request + * @return array Array + */ + public function fetch_array($resultset) + { + return $this->db->fetch_array($resultset); + } + + /** + * Return last error label + * + * @return string lasterror + */ + public function lasterror() + { + return $this->db->lasterror(); + } + + /** + * Escape a string to insert data + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + public function escape($stringtoencode) + { + return $this->db->escape($stringtoencode); + } + + /** + * Get last ID after an insert INSERT + * + * @param string $tab Table name concerned by insert. Ne sert pas sous MySql mais requis pour compatibilite avec Postgresql + * @param string $fieldid Field name + * @return int Id of row + */ + public function last_insert_id($tab, $fieldid = 'rowid') + { + return $this->db->last_insert_id($tab, $fieldid); + } + + /** + * Return full path of restore program + * + * @return string Full path of restore program + */ + public function getPathOfRestore() + { + return $this->db->getPathOfRestore(); + } + + /** + * Annulation d'une transaction et retour aux anciennes valeurs + * + * @param string $log Add more log to default log line + * @return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur + */ + public function rollback($log = '') + { + return $this->db->rollback($log); + } + + /** + * Execute a SQL request and return the resultset + * + * @param string $query SQL query string + * @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollback to savepoint if error (this allow to have some request with errors inside global transactions). + * Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints. + * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) + * @return resource Resultset of answer + */ + public function query($query, $usesavepoint = 0, $type = 'auto') + { + $this->startTracing(); + + $resql = $this->db->query($query, $usesavepoint, $type); + + $this->endTracing($query, $resql); + + return $resql; + } + + /** + * Start query tracing + */ + protected function startTracing() + { + $this->startTime = microtime(true); + $this->startMemory = memory_get_usage(true); + } + + /** + * End query tracing + * + * @param $sql query string + * @param $resql query result + */ + protected function endTracing($sql, $resql) + { + $endTime = microtime(true); + $duration = $endTime - $this->startTime; + $endMemory = memory_get_usage(true); + $memoryDelta = $endMemory - $this->startMemory; + + $this->queries[] = array( + 'sql' => $sql, + 'duration' => $duration, + 'memory_usage' => $memoryDelta, + 'is_success' => $resql, + 'error_code' => ! $resql ? $this->db->lasterrno() : null, + 'error_message' => ! $resql ? $this->db->lasterror() : null + ); + } + + /** + * Connexion to server + * + * @param string $host database server host + * @param string $login login + * @param string $passwd password + * @param string $name name of database (not used for mysql, used for pgsql) + * @param int $port Port of database server + * @return resource Database access handler + * @see close + */ + public function connect($host, $login, $passwd, $name, $port = 0) + { + return $this->db->connect($host, $login, $passwd, $name, $port); + } + + /** + * Define limits and offset of request + * + * @param int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit) + * @param int $offset Numero of line from where starting fetch + * @return string String with SQL syntax to add a limit and offset + */ + public function plimit($limit = 0, $offset = 0) + { + return $this->db->plimit($limit, $offset); + } + + /** + * Return value of server parameters + * + * @param string $filter Filter list on a particular value + * @return array Array of key-values (key=>value) + */ + public function getServerParametersValues($filter = '') + { + return $this->db->getServerParametersValues($filter); + } + + /** + * Return value of server status + * + * @param string $filter Filter list on a particular value + * @return array Array of key-values (key=>value) + */ + public function getServerStatusValues($filter = '') + { + return $this->db->getServerStatusValues($filter); + } + + /** + * Return collation used in database + * + * @return string Collation value + */ + public function getDefaultCollationDatabase() + { + return $this->db->getDefaultCollationDatabase(); + } + + /** + * Return number of lines for result of a SELECT + * + * @param resource $resultset Resulset of requests + * @return int Nb of lines + * @see affected_rows + */ + public function num_rows($resultset) + { + return $this->db->num_rows($resultset); + } + + /** + * Return full path of dump program + * + * @return string Full path of dump program + */ + public function getPathOfDump() + { + return $this->db->getPathOfDump(); + } + + /** + * Return version of database client driver + * + * @return string Version string + */ + public function getDriverInfo() + { + return $this->db->getDriverInfo(); + } + + /** + * Return generic error code of last operation. + * + * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) + */ + public function errno() + { + return $this->db->errno(); + } + + /** + * Create a table into database + * + * @param string $table Name of table + * @param array $fields Tableau associatif [nom champ][tableau des descriptions] + * @param string $primary_key Nom du champ qui sera la clef primaire + * @param string $type Type de la table + * @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur + * @param array $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext + * @param array $keys Tableau des champs cles noms => valeur + * @return int <0 if KO, >=0 if OK + */ + public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) + { + return $this->db->DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys, $fulltext_keys, $keys); + } + + /** + * Drop a table into database + * + * @param string $table Name of table + * @return int <0 if KO, >=0 if OK + */ + public function DDLDropTable($table) + { + return $this->db->DDLDropTable($table); + } + + /** + * Return list of available charset that can be used to store data in database + * + * @return array List of Charset + */ + public function getListOfCharacterSet() + { + return $this->db->getListOfCharacterSet(); + } + + /** + * Create a new field into table + * + * @param string $table Name of table + * @param string $field_name Name of field to add + * @param string $field_desc Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre] + * @param string $field_position Optionnel ex.: "after champtruc" + * @return int <0 if KO, >0 if OK + */ + public function DDLAddField($table, $field_name, $field_desc, $field_position = "") + { + return $this->db->DDLAddField($table, $field_name, $field_desc, $field_position); + } + + /** + * Drop a field from table + * + * @param string $table Name of table + * @param string $field_name Name of field to drop + * @return int <0 if KO, >0 if OK + */ + public function DDLDropField($table, $field_name) + { + return $this->db->DDLDropField($table, $field_name); + } + + /** + * Update format of a field into a table + * + * @param string $table Name of table + * @param string $field_name Name of field to modify + * @param string $field_desc Array with description of field format + * @return int <0 if KO, >0 if OK + */ + public function DDLUpdateField($table, $field_name, $field_desc) + { + return $this->db->DDLUpdateField($table, $field_name, $field_desc); + } + + /** + * Return list of available collation that can be used for database + * + * @return array List of Collation + */ + public function getListOfCollation() + { + return $this->db->getListOfCollation(); + } + + /** + * Return a pointer of line with description of a table or field + * + * @param string $table Name of table + * @param string $field Optionnel : Name of field if we want description of field + * @return resource Resource + */ + public function DDLDescTable($table, $field = "") + { + return $this->db->DDLDescTable($table, $field); + } + + /** + * Return version of database server + * + * @return string Version string + */ + public function getVersion() + { + return $this->db->getVersion(); + } + + /** + * Return charset used to store data in database + * + * @return string Charset + */ + public function getDefaultCharacterSetDatabase() + { + return $this->db->getDefaultCharacterSetDatabase(); + } + + /** + * Create a user and privileges to connect to database (even if database does not exists yet) + * + * @param string $dolibarr_main_db_host Ip serveur + * @param string $dolibarr_main_db_user Nom user a creer + * @param string $dolibarr_main_db_pass Mot de passe user a creer + * @param string $dolibarr_main_db_name Database name where user must be granted + * @return int <0 if KO, >=0 if OK + */ + public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) + { + return $this->db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name); + } + + /** + * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) + * 19700101020000 -> 3600 with TZ+1 and gmt=0 + * 19700101020000 -> 7200 whaterver is TZ if gmt=1 + * + * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) + * @param bool $gm 1=Input informations are GMT values, otherwise local to server TZ + * @return int|string Date TMS or '' + */ + public function jdate($string, $gm=false) + { + return $this->db->jdate($string, $gm); + } + + /** + * Encrypt sensitive data in database + * Warning: This function includes the escape, so it must use direct value + * + * @param string $fieldorvalue Field name or value to encrypt + * @param int $withQuotes Return string with quotes + * @return string XXX(field) or XXX('value') or field or 'value' + */ + public function encrypt($fieldorvalue, $withQuotes = 0) + { + return $this->db->encrypt($fieldorvalue, $withQuotes); + } + + /** + * Validate a database transaction + * + * @param string $log Add more log to default log line + * @return int 1 if validation is OK or transaction level no started, 0 if ERROR + */ + public function commit($log = '') + { + return $this->db->commit($log); + } + + /** + * List information of columns into a table. + * + * @param string $table Name of table + * @return array Array with inforation on table + */ + public function DDLInfoTable($table) + { + return $this->db->DDLInfoTable($table); + } + + /** + * Free last resultset used. + * + * @param resource $resultset Fre cursor + * @return void + */ + public function free($resultset = null) + { + return $this->db->free($resultset); + } + + /** + * Close database connexion + * + * @return boolean True if disconnect successfull, false otherwise + * @see connect + */ + public function close() + { + return $this->db->close(); + } + + /** + * Return last query in error + * + * @return string lastqueryerror + */ + public function lastqueryerror() + { + return $this->db->lastqueryerror(); + } + + /** + * Return connexion ID + * + * @return string Id connexion + */ + public function DDLGetConnectId() + { + return $this->db->DDLGetConnectId(); + } + + /** + * Renvoie la ligne courante (comme un objet) pour le curseur resultset + * + * @param resource $resultset Curseur de la requete voulue + * @return Object Object result line or false if KO or end of cursor + */ + public function fetch_object($resultset) + { + return $this->db->fetch_object($resultset); + } + + /** + * Select a database + * + * @param string $database Name of database + * @return boolean true if OK, false if KO + */ + public function select_db($database) + { + return $this->db->select_db($database); + } +} \ No newline at end of file diff --git a/htdocs/debugbar/class/actions_debugbar.class.php b/htdocs/debugbar/class/actions_debugbar.class.php new file mode 100644 index 00000000000..3678cd2189d --- /dev/null +++ b/htdocs/debugbar/class/actions_debugbar.class.php @@ -0,0 +1,112 @@ +getRenderer(); + $conf->global->MAIN_HTML_HEADER .= $renderer->renderHead(); + } + + /** + * Overloading the afterLogin function + * + * @param array() $parameters Hook metadatas (context, etc...) + * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string &$action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function afterLogin($parameters, &$object, &$action, $hookmanager) + { + $error = 0; // Error counter + + if (in_array('login', explode(':', $parameters['context']))) + { + $this->loadDebugBar(); + } + + if (! $error) + { + return 0; // or return 1 to replace standard code + } + else + { + return -1; + } + } + + /** + * Overloading the updateSession function + * + * @param array() $parameters Hook metadatas (context, etc...) + * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string &$action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function updateSession($parameters, &$object, &$action, $hookmanager) + { + $error = 0; // Error counter + + if (in_array('main', explode(':', $parameters['context']))) + { + $this->loadDebugBar(); + } + + if (! $error) + { + return 0; // or return 1 to replace standard code + } + else + { + return -1; + } + } + + /** + * Overloading the printCommonFooter function + * + * @param array() $parameters Hook metadatas (context, etc...) + * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string &$action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function printCommonFooter($parameters, &$object, &$action, $hookmanager) + { + global $user, $debugbar, $langs; + + $error = 0; // Error counter + $context = explode(':', $parameters['context']); + + if (in_array('main', $context) || in_array('login', $context)) + { + if ($user->rights->debugbar->read && is_object($debugbar)) { + $renderer = $debugbar->getRenderer(); + echo $renderer->render(); + } + } + + if (! $error) + { + return 0; // or return 1 to replace standard code + } + else + { + return -1; + } + } +} diff --git a/htdocs/debugbar/class/autoloader.php b/htdocs/debugbar/class/autoloader.php new file mode 100644 index 00000000000..e7840dcb23c --- /dev/null +++ b/htdocs/debugbar/class/autoloader.php @@ -0,0 +1,19 @@ + '', 'class' => '') + * - data: alias of title + */ + var TooltipIndicator = PhpDebugBar.DebugBar.TooltipIndicator = PhpDebugBar.DebugBar.Indicator.extend({ + + render: function() { + this.$icon = $('').appendTo(this.$el); + this.bindAttr('icon', function(icon) { + if (icon) { + this.$icon.attr('class', 'fa fa-' + icon); + } else { + this.$icon.attr('class', ''); + } + }); + + this.bindAttr(['title', 'data'], $('').addClass(csscls('text')).appendTo(this.$el)); + + this.$tooltip = $('').addClass(csscls('tooltip disabled')).appendTo(this.$el); + this.bindAttr('tooltip', function(tooltip) { + if (tooltip['html']) { + tooltipHTML = $('').html(tooltip['html']).addClass(csscls('tooltip-html')); + this.$tooltip.html(tooltipHTML).removeClass(csscls('disabled')); + if (tooltip['class']) { + this.$tooltip.addClass(csscls(tooltip['class'])); + } + } else { + this.$tooltip.addClass(csscls('disabled')); + } + }); + } + + }); + + /** + * LinkIndicator + * + * A customised indicator class that will allow "click" behaviour. + * + * Options: + * - icon + * - title + * - tooltip + * - data: alias of title + * - href + * - target + */ + var LinkIndicator = PhpDebugBar.DebugBar.LinkIndicator = PhpDebugBar.DebugBar.Indicator.extend({ + + tagName: 'a', + + render: function() { + LinkIndicator.__super__.render.apply(this); + this.bindAttr('href', function(href) { + this.$el.attr('href', href); + }); + this.bindAttr('target', function(target) { + this.$el.attr('target', target); + }); + } + + }); + +})(PhpDebugBar.$); \ No newline at end of file diff --git a/htdocs/includes/DebugBar/Bridge/CacheCacheCollector.php b/htdocs/includes/DebugBar/Bridge/CacheCacheCollector.php new file mode 100644 index 00000000000..3d841c6784e --- /dev/null +++ b/htdocs/includes/DebugBar/Bridge/CacheCacheCollector.php @@ -0,0 +1,62 @@ + + * $debugbar->addCollector(new CacheCacheCollector(CacheManager::get('default'))); + * // or + * $debugbar->addCollector(new CacheCacheCollector()); + * $debugbar['cache']->addCache(CacheManager::get('default')); + * + */ +class CacheCacheCollector extends MonologCollector +{ + protected $logger; + + public function __construct(Cache $cache = null, Logger $logger = null, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct(null, $level, $bubble); + + if ($logger === null) { + $logger = new Logger('Cache'); + } + $this->logger = $logger; + + if ($cache !== null) { + $this->addCache($cache); + } + } + + public function addCache(Cache $cache) + { + $backend = $cache->getBackend(); + if (!($backend instanceof LoggingBackend)) { + $backend = new LoggingBackend($backend, $this->logger); + } + $cache->setBackend($backend); + $this->addLogger($backend->getLogger()); + } + + public function getName() + { + return 'cache'; + } +} diff --git a/htdocs/includes/DebugBar/Bridge/DoctrineCollector.php b/htdocs/includes/DebugBar/Bridge/DoctrineCollector.php new file mode 100644 index 00000000000..6fa358e29ab --- /dev/null +++ b/htdocs/includes/DebugBar/Bridge/DoctrineCollector.php @@ -0,0 +1,98 @@ + + * $debugStack = new Doctrine\DBAL\Logging\DebugStack(); + * $entityManager->getConnection()->getConfiguration()->setSQLLogger($debugStack); + * $debugbar->addCollector(new DoctrineCollector($debugStack)); + * + */ +class DoctrineCollector extends DataCollector implements Renderable, AssetProvider +{ + protected $debugStack; + + public function __construct($debugStackOrEntityManager) + { + if ($debugStackOrEntityManager instanceof EntityManager) { + $debugStackOrEntityManager = $debugStackOrEntityManager->getConnection()->getConfiguration()->getSQLLogger(); + } + if (!($debugStackOrEntityManager instanceof DebugStack)) { + throw new DebugBarException("'DoctrineCollector' requires an 'EntityManager' or 'DebugStack' object"); + } + $this->debugStack = $debugStackOrEntityManager; + } + + public function collect() + { + $queries = array(); + $totalExecTime = 0; + foreach ($this->debugStack->queries as $q) { + $queries[] = array( + 'sql' => $q['sql'], + 'params' => (object) $q['params'], + 'duration' => $q['executionMS'], + 'duration_str' => $this->formatDuration($q['executionMS']) + ); + $totalExecTime += $q['executionMS']; + } + + return array( + 'nb_statements' => count($queries), + 'accumulated_duration' => $totalExecTime, + 'accumulated_duration_str' => $this->formatDuration($totalExecTime), + 'statements' => $queries + ); + } + + public function getName() + { + return 'doctrine'; + } + + public function getWidgets() + { + return array( + "database" => array( + "icon" => "arrow-right", + "widget" => "PhpDebugBar.Widgets.SQLQueriesWidget", + "map" => "doctrine", + "default" => "[]" + ), + "database:badge" => array( + "map" => "doctrine.nb_statements", + "default" => 0 + ) + ); + } + + public function getAssets() + { + return array( + 'css' => 'widgets/sqlqueries/widget.css', + 'js' => 'widgets/sqlqueries/widget.js' + ); + } +} diff --git a/htdocs/includes/DebugBar/Bridge/MonologCollector.php b/htdocs/includes/DebugBar/Bridge/MonologCollector.php new file mode 100644 index 00000000000..609d5c5f837 --- /dev/null +++ b/htdocs/includes/DebugBar/Bridge/MonologCollector.php @@ -0,0 +1,103 @@ + + * $debugbar->addCollector(new MonologCollector($logger)); + * + */ +class MonologCollector extends AbstractProcessingHandler implements DataCollectorInterface, Renderable, MessagesAggregateInterface +{ + protected $name; + + protected $records = array(); + + /** + * @param Logger $logger + * @param int $level + * @param boolean $bubble + * @param string $name + */ + public function __construct(Logger $logger = null, $level = Logger::DEBUG, $bubble = true, $name = 'monolog') + { + parent::__construct($level, $bubble); + $this->name = $name; + if ($logger !== null) { + $this->addLogger($logger); + } + } + + /** + * Adds logger which messages you want to log + * + * @param Logger $logger + */ + public function addLogger(Logger $logger) + { + $logger->pushHandler($this); + } + + protected function write(array $record) + { + $this->records[] = array( + 'message' => $record['formatted'], + 'is_string' => true, + 'label' => strtolower($record['level_name']), + 'time' => $record['datetime']->format('U') + ); + } + + public function getMessages() + { + return $this->records; + } + + public function collect() + { + return array( + 'count' => count($this->records), + 'records' => $this->records + ); + } + + public function getName() + { + return $this->name; + } + + public function getWidgets() + { + $name = $this->getName(); + return array( + $name => array( + "icon" => "suitcase", + "widget" => "PhpDebugBar.Widgets.MessagesWidget", + "map" => "$name.records", + "default" => "[]" + ), + "$name:badge" => array( + "map" => "$name.count", + "default" => "null" + ) + ); + } +} diff --git a/htdocs/includes/DebugBar/Bridge/PropelCollector.php b/htdocs/includes/DebugBar/Bridge/PropelCollector.php new file mode 100644 index 00000000000..93ad4ff82fd --- /dev/null +++ b/htdocs/includes/DebugBar/Bridge/PropelCollector.php @@ -0,0 +1,253 @@ + + * $debugbar->addCollector(new PropelCollector($debugbar['messages'])); + * PropelCollector::enablePropelProfiling(); + * + */ +class PropelCollector extends DataCollector implements BasicLogger, Renderable, AssetProvider +{ + protected $logger; + + protected $statements = array(); + + protected $accumulatedTime = 0; + + protected $peakMemory = 0; + + /** + * Sets the needed configuration option in propel to enable query logging + * + * @param PropelConfiguration $config Apply profiling on a specific config + */ + public static function enablePropelProfiling(PropelConfiguration $config = null) + { + if ($config === null) { + $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); + } + $config->setParameter('debugpdo.logging.details.method.enabled', true); + $config->setParameter('debugpdo.logging.details.time.enabled', true); + $config->setParameter('debugpdo.logging.details.mem.enabled', true); + $allMethods = array( + 'PropelPDO::__construct', // logs connection opening + 'PropelPDO::__destruct', // logs connection close + 'PropelPDO::exec', // logs a query + 'PropelPDO::query', // logs a query + 'PropelPDO::beginTransaction', // logs a transaction begin + 'PropelPDO::commit', // logs a transaction commit + 'PropelPDO::rollBack', // logs a transaction rollBack (watch out for the capital 'B') + 'DebugPDOStatement::execute', // logs a query from a prepared statement + ); + $config->setParameter('debugpdo.logging.methods', $allMethods, false); + } + + /** + * @param LoggerInterface $logger A logger to forward non-query log lines to + * @param PropelPDO $conn Bound this collector to a connection only + */ + public function __construct(LoggerInterface $logger = null, PropelPDO $conn = null) + { + if ($conn) { + $conn->setLogger($this); + } else { + Propel::setLogger($this); + } + $this->logger = $logger; + $this->logQueriesToLogger = false; + } + + public function setLogQueriesToLogger($enable = true) + { + $this->logQueriesToLogger = $enable; + return $this; + } + + public function isLogQueriesToLogger() + { + return $this->logQueriesToLogger; + } + + public function emergency($m) + { + $this->log($m, Propel::LOG_EMERG); + } + + public function alert($m) + { + $this->log($m, Propel::LOG_ALERT); + } + + public function crit($m) + { + $this->log($m, Propel::LOG_CRIT); + } + + public function err($m) + { + $this->log($m, Propel::LOG_ERR); + } + + public function warning($m) + { + $this->log($m, Propel::LOG_WARNING); + } + + public function notice($m) + { + $this->log($m, Propel::LOG_NOTICE); + } + + public function info($m) + { + $this->log($m, Propel::LOG_INFO); + } + + public function debug($m) + { + $this->log($m, Propel::LOG_DEBUG); + } + + public function log($message, $severity = null) + { + if (strpos($message, 'DebugPDOStatement::execute') !== false) { + list($sql, $duration_str) = $this->parseAndLogSqlQuery($message); + if (!$this->logQueriesToLogger) { + return; + } + $message = "$sql ($duration_str)"; + } + + if ($this->logger !== null) { + $this->logger->log($this->convertLogLevel($severity), $message); + } + } + + /** + * Converts Propel log levels to PSR log levels + * + * @param int $level + * @return string + */ + protected function convertLogLevel($level) + { + $map = array( + Propel::LOG_EMERG => LogLevel::EMERGENCY, + Propel::LOG_ALERT => LogLevel::ALERT, + Propel::LOG_CRIT => LogLevel::CRITICAL, + Propel::LOG_ERR => LogLevel::ERROR, + Propel::LOG_WARNING => LogLevel::WARNING, + Propel::LOG_NOTICE => LogLevel::NOTICE, + Propel::LOG_DEBUG => LogLevel::DEBUG + ); + return $map[$level]; + } + + /** + * Parse a log line to extract query information + * + * @param string $message + */ + protected function parseAndLogSqlQuery($message) + { + $parts = explode('|', $message, 4); + $sql = trim($parts[3]); + + $duration = 0; + if (preg_match('/([0-9]+\.[0-9]+)/', $parts[1], $matches)) { + $duration = (float) $matches[1]; + } + + $memory = 0; + if (preg_match('/([0-9]+\.[0-9]+) ([A-Z]{1,2})/', $parts[2], $matches)) { + $memory = (float) $matches[1]; + if ($matches[2] == 'KB') { + $memory *= 1024; + } elseif ($matches[2] == 'MB') { + $memory *= 1024 * 1024; + } + } + + $this->statements[] = array( + 'sql' => $sql, + 'is_success' => true, + 'duration' => $duration, + 'duration_str' => $this->formatDuration($duration), + 'memory' => $memory, + 'memory_str' => $this->formatBytes($memory) + ); + $this->accumulatedTime += $duration; + $this->peakMemory = max($this->peakMemory, $memory); + return array($sql, $this->formatDuration($duration)); + } + + public function collect() + { + return array( + 'nb_statements' => count($this->statements), + 'nb_failed_statements' => 0, + 'accumulated_duration' => $this->accumulatedTime, + 'accumulated_duration_str' => $this->formatDuration($this->accumulatedTime), + 'peak_memory_usage' => $this->peakMemory, + 'peak_memory_usage_str' => $this->formatBytes($this->peakMemory), + 'statements' => $this->statements + ); + } + + public function getName() + { + return 'propel'; + } + + public function getWidgets() + { + return array( + "propel" => array( + "icon" => "bolt", + "widget" => "PhpDebugBar.Widgets.SQLQueriesWidget", + "map" => "propel", + "default" => "[]" + ), + "propel:badge" => array( + "map" => "propel.nb_statements", + "default" => 0 + ) + ); + } + + public function getAssets() + { + return array( + 'css' => 'widgets/sqlqueries/widget.css', + 'js' => 'widgets/sqlqueries/widget.js' + ); + } +} diff --git a/htdocs/includes/DebugBar/Bridge/SlimCollector.php b/htdocs/includes/DebugBar/Bridge/SlimCollector.php new file mode 100644 index 00000000000..030a3baf624 --- /dev/null +++ b/htdocs/includes/DebugBar/Bridge/SlimCollector.php @@ -0,0 +1,66 @@ +slim = $slim; + if ($log = $slim->getLog()) { + $this->originalLogWriter = $log->getWriter(); + $log->setWriter($this); + $log->setEnabled(true); + } + } + + public function write($message, $level) + { + if ($this->originalLogWriter) { + $this->originalLogWriter->write($message, $level); + } + $this->addMessage($message, $this->getLevelName($level)); + } + + protected function getLevelName($level) + { + $map = array( + Log::EMERGENCY => LogLevel::EMERGENCY, + Log::ALERT => LogLevel::ALERT, + Log::CRITICAL => LogLevel::CRITICAL, + Log::ERROR => LogLevel::ERROR, + Log::WARN => LogLevel::WARNING, + Log::NOTICE => LogLevel::NOTICE, + Log::INFO => LogLevel::INFO, + Log::DEBUG => LogLevel::DEBUG + ); + return $map[$level]; + } + + public function getName() + { + return 'slim'; + } +} diff --git a/htdocs/includes/DebugBar/Bridge/SwiftMailer/SwiftLogCollector.php b/htdocs/includes/DebugBar/Bridge/SwiftMailer/SwiftLogCollector.php new file mode 100644 index 00000000000..fdef79a0bdc --- /dev/null +++ b/htdocs/includes/DebugBar/Bridge/SwiftMailer/SwiftLogCollector.php @@ -0,0 +1,44 @@ +registerPlugin(new Swift_Plugins_LoggerPlugin($this)); + } + + public function add($entry) + { + $this->addMessage($entry); + } + + public function dump() + { + return implode(PHP_EOL, $this->_log); + } + + public function getName() + { + return 'swiftmailer_logs'; + } +} diff --git a/htdocs/includes/DebugBar/Bridge/SwiftMailer/SwiftMailCollector.php b/htdocs/includes/DebugBar/Bridge/SwiftMailer/SwiftMailCollector.php new file mode 100644 index 00000000000..01a5e906c88 --- /dev/null +++ b/htdocs/includes/DebugBar/Bridge/SwiftMailer/SwiftMailCollector.php @@ -0,0 +1,92 @@ +messagesLogger = new Swift_Plugins_MessageLogger(); + $mailer->registerPlugin($this->messagesLogger); + } + + public function collect() + { + $mails = array(); + foreach ($this->messagesLogger->getMessages() as $msg) { + $mails[] = array( + 'to' => $this->formatTo($msg->getTo()), + 'subject' => $msg->getSubject(), + 'headers' => $msg->getHeaders()->toString() + ); + } + return array( + 'count' => count($mails), + 'mails' => $mails + ); + } + + protected function formatTo($to) + { + if (!$to) { + return ''; + } + + $f = array(); + foreach ($to as $k => $v) { + $f[] = (empty($v) ? '' : "$v ") . "<$k>"; + } + return implode(', ', $f); + } + + public function getName() + { + return 'swiftmailer_mails'; + } + + public function getWidgets() + { + return array( + 'emails' => array( + 'icon' => 'inbox', + 'widget' => 'PhpDebugBar.Widgets.MailsWidget', + 'map' => 'swiftmailer_mails.mails', + 'default' => '[]', + 'title' => 'Mails' + ), + 'emails:badge' => array( + 'map' => 'swiftmailer_mails.count', + 'default' => 'null' + ) + ); + } + + public function getAssets() + { + return array( + 'css' => 'widgets/mails/widget.css', + 'js' => 'widgets/mails/widget.js' + ); + } +} diff --git a/htdocs/includes/DebugBar/Bridge/Twig/TraceableTwigEnvironment.php b/htdocs/includes/DebugBar/Bridge/Twig/TraceableTwigEnvironment.php new file mode 100644 index 00000000000..0d4c957f5b2 --- /dev/null +++ b/htdocs/includes/DebugBar/Bridge/Twig/TraceableTwigEnvironment.php @@ -0,0 +1,417 @@ +twig = $twig; + $this->timeDataCollector = $timeDataCollector; + } + + public function __call($name, $arguments) + { + return call_user_func_array(array($this->twig, $name), $arguments); + } + + public function getRenderedTemplates() + { + return $this->renderedTemplates; + } + + public function addRenderedTemplate(array $info) + { + $this->renderedTemplates[] = $info; + } + + public function getTimeDataCollector() + { + return $this->timeDataCollector; + } + + public function getBaseTemplateClass() + { + return $this->twig->getBaseTemplateClass(); + } + + public function setBaseTemplateClass($class) + { + $this->twig->setBaseTemplateClass($class); + } + + public function enableDebug() + { + $this->twig->enableDebug(); + } + + public function disableDebug() + { + $this->twig->disableDebug(); + } + + public function isDebug() + { + return $this->twig->isDebug(); + } + + public function enableAutoReload() + { + $this->twig->enableAutoReload(); + } + + public function disableAutoReload() + { + $this->twig->disableAutoReload(); + } + + public function isAutoReload() + { + return $this->twig->isAutoReload(); + } + + public function enableStrictVariables() + { + $this->twig->enableStrictVariables(); + } + + public function disableStrictVariables() + { + $this->twig->disableStrictVariables(); + } + + public function isStrictVariables() + { + return $this->twig->isStrictVariables(); + } + + public function getCache() + { + return $this->twig->getCache(); + } + + public function setCache($cache) + { + $this->twig->setCache($cache); + } + + public function getCacheFilename($name) + { + return $this->twig->getCacheFilename($name); + } + + public function getTemplateClass($name, $index = null) + { + return $this->twig->getTemplateClass($name, $index); + } + + public function getTemplateClassPrefix() + { + return $this->twig->getTemplateClassPrefix(); + } + + public function render($name, array $context = array()) + { + return $this->loadTemplate($name)->render($context); + } + + public function display($name, array $context = array()) + { + $this->loadTemplate($name)->display($context); + } + + public function loadTemplate($name, $index = null) + { + $cls = $this->twig->getTemplateClass($name, $index); + + if (isset($this->twig->loadedTemplates[$cls])) { + return $this->twig->loadedTemplates[$cls]; + } + + if (!class_exists($cls, false)) { + if (false === $cache = $this->getCacheFilename($name)) { + eval('?>'.$this->compileSource($this->getLoader()->getSource($name), $name)); + } else { + if (!is_file($cache) || ($this->isAutoReload() && !$this->isTemplateFresh($name, filemtime($cache)))) { + $this->writeCacheFile($cache, $this->compileSource($this->getLoader()->getSource($name), $name)); + } + + require_once $cache; + } + } + + if (!$this->twig->runtimeInitialized) { + $this->initRuntime(); + } + + return $this->twig->loadedTemplates[$cls] = new TraceableTwigTemplate($this, new $cls($this)); + } + + public function isTemplateFresh($name, $time) + { + return $this->twig->isTemplateFresh($name, $time); + } + + public function resolveTemplate($names) + { + return $this->twig->resolveTemplate($names); + } + + public function clearTemplateCache() + { + $this->twig->clearTemplateCache(); + } + + public function clearCacheFiles() + { + $this->twig->clearCacheFiles(); + } + + public function getLexer() + { + return $this->twig->getLexer(); + } + + public function setLexer(Twig_LexerInterface $lexer) + { + $this->twig->setLexer($lexer); + } + + public function tokenize($source, $name = null) + { + return $this->twig->tokenize($source, $name); + } + + public function getParser() + { + return $this->twig->getParser(); + } + + public function setParser(Twig_ParserInterface $parser) + { + $this->twig->setParser($parser); + } + + public function parse(Twig_TokenStream $tokens) + { + return $this->twig->parse($tokens); + } + + public function getCompiler() + { + return $this->twig->getCompiler(); + } + + public function setCompiler(Twig_CompilerInterface $compiler) + { + $this->twig->setCompiler($compiler); + } + + public function compile(Twig_NodeInterface $node) + { + return $this->twig->compile($node); + } + + public function compileSource($source, $name = null) + { + return $this->twig->compileSource($source, $name); + } + + public function setLoader(Twig_LoaderInterface $loader) + { + $this->twig->setLoader($loader); + } + + public function getLoader() + { + return $this->twig->getLoader(); + } + + public function setCharset($charset) + { + $this->twig->setCharset($charset); + } + + public function getCharset() + { + return $this->twig->getCharset(); + } + + public function initRuntime() + { + $this->twig->initRuntime(); + } + + public function hasExtension($name) + { + return $this->twig->hasExtension($name); + } + + public function getExtension($name) + { + return $this->twig->getExtension($name); + } + + public function addExtension(Twig_ExtensionInterface $extension) + { + $this->twig->addExtension($extension); + } + + public function removeExtension($name) + { + $this->twig->removeExtension($name); + } + + public function setExtensions(array $extensions) + { + $this->twig->setExtensions($extensions); + } + + public function getExtensions() + { + return $this->twig->getExtensions(); + } + + public function addTokenParser(Twig_TokenParserInterface $parser) + { + $this->twig->addTokenParser($parser); + } + + public function getTokenParsers() + { + return $this->twig->getTokenParsers(); + } + + public function getTags() + { + return $this->twig->getTags(); + } + + public function addNodeVisitor(Twig_NodeVisitorInterface $visitor) + { + $this->twig->addNodeVisitor($visitor); + } + + public function getNodeVisitors() + { + return $this->twig->getNodeVisitors(); + } + + public function addFilter($name, $filter = null) + { + $this->twig->addFilter($name, $filter); + } + + public function getFilter($name) + { + return $this->twig->getFilter($name); + } + + public function registerUndefinedFilterCallback($callable) + { + $this->twig->registerUndefinedFilterCallback($callable); + } + + public function getFilters() + { + return $this->twig->getFilters(); + } + + public function addTest($name, $test = null) + { + $this->twig->addTest($name, $test); + } + + public function getTests() + { + return $this->twig->getTests(); + } + + public function getTest($name) + { + return $this->twig->getTest($name); + } + + public function addFunction($name, $function = null) + { + $this->twig->addFunction($name, $function); + } + + public function getFunction($name) + { + return $this->twig->getFunction($name); + } + + public function registerUndefinedFunctionCallback($callable) + { + $this->twig->registerUndefinedFunctionCallback($callable); + } + + public function getFunctions() + { + return $this->twig->getFunctions(); + } + + public function addGlobal($name, $value) + { + $this->twig->addGlobal($name, $value); + } + + public function getGlobals() + { + return $this->twig->getGlobals(); + } + + public function mergeGlobals(array $context) + { + return $this->twig->mergeGlobals($context); + } + + public function getUnaryOperators() + { + return $this->twig->getUnaryOperators(); + } + + public function getBinaryOperators() + { + return $this->twig->getBinaryOperators(); + } + + public function computeAlternatives($name, $items) + { + return $this->twig->computeAlternatives($name, $items); + } +} diff --git a/htdocs/includes/DebugBar/Bridge/Twig/TraceableTwigTemplate.php b/htdocs/includes/DebugBar/Bridge/Twig/TraceableTwigTemplate.php new file mode 100644 index 00000000000..dab53d15e1f --- /dev/null +++ b/htdocs/includes/DebugBar/Bridge/Twig/TraceableTwigTemplate.php @@ -0,0 +1,131 @@ +env = $env; + $this->template = $template; + } + + public function __call($name, $arguments) + { + return call_user_func_array(array($this->template, $name), $arguments); + } + + public function getTemplateName() + { + return $this->template->getTemplateName(); + } + + public function getEnvironment() + { + return $this->template->getEnvironment(); + } + + public function getParent(array $context) + { + return $this->template->getParent($context); + } + + public function isTraitable() + { + return $this->template->isTraitable(); + } + + public function displayParentBlock($name, array $context, array $blocks = array()) + { + $this->template->displayParentBlock($name, $context, $blocks); + } + + public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true) + { + $this->template->displayBlock($name, $context, $blocks, $useBlocks); + } + + public function renderParentBlock($name, array $context, array $blocks = array()) + { + return $this->template->renderParentBlock($name, $context, $blocks); + } + + public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true) + { + return $this->template->renderBlock($name, $context, $blocks, $useBlocks); + } + + public function hasBlock($name) + { + return $this->template->hasBlock($name); + } + + public function getBlockNames() + { + return $this->template->getBlockNames(); + } + + public function getBlocks() + { + return $this->template->getBlocks(); + } + + public function display(array $context, array $blocks = array()) + { + $start = microtime(true); + $this->template->display($context, $blocks); + $end = microtime(true); + + if ($timeDataCollector = $this->env->getTimeDataCollector()) { + $name = sprintf("twig.render(%s)", $this->template->getTemplateName()); + $timeDataCollector->addMeasure($name, $start, $end); + } + + $this->env->addRenderedTemplate(array( + 'name' => $this->template->getTemplateName(), + 'render_time' => $end - $start + )); + } + + public function render(array $context) + { + $level = ob_get_level(); + ob_start(); + try { + $this->display($context); + } catch (Exception $e) { + while (ob_get_level() > $level) { + ob_end_clean(); + } + + throw $e; + } + + return ob_get_clean(); + } + + public static function clearCache() + { + Twig_Template::clearCache(); + } +} diff --git a/htdocs/includes/DebugBar/Bridge/Twig/TwigCollector.php b/htdocs/includes/DebugBar/Bridge/Twig/TwigCollector.php new file mode 100644 index 00000000000..fde5a3f85ba --- /dev/null +++ b/htdocs/includes/DebugBar/Bridge/Twig/TwigCollector.php @@ -0,0 +1,87 @@ + + * $env = new TraceableTwigEnvironment(new Twig_Environment($loader)); + * $debugbar->addCollector(new TwigCollector($env)); + * + */ +class TwigCollector extends DataCollector implements Renderable, AssetProvider +{ + public function __construct(TraceableTwigEnvironment $twig) + { + $this->twig = $twig; + } + + public function collect() + { + $templates = array(); + $accuRenderTime = 0; + + foreach ($this->twig->getRenderedTemplates() as $tpl) { + $accuRenderTime += $tpl['render_time']; + $templates[] = array( + 'name' => $tpl['name'], + 'render_time' => $tpl['render_time'], + 'render_time_str' => $this->formatDuration($tpl['render_time']) + ); + } + + return array( + 'nb_templates' => count($templates), + 'templates' => $templates, + 'accumulated_render_time' => $accuRenderTime, + 'accumulated_render_time_str' => $this->formatDuration($accuRenderTime) + ); + } + + public function getName() + { + return 'twig'; + } + + public function getWidgets() + { + return array( + 'twig' => array( + 'icon' => 'leaf', + 'widget' => 'PhpDebugBar.Widgets.TemplatesWidget', + 'map' => 'twig', + 'default' => '[]' + ), + 'twig:badge' => array( + 'map' => 'twig.nb_templates', + 'default' => 0 + ) + ); + } + + public function getAssets() + { + return array( + 'css' => 'widgets/templates/widget.css', + 'js' => 'widgets/templates/widget.js' + ); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/AggregatedCollector.php b/htdocs/includes/DebugBar/DataCollector/AggregatedCollector.php new file mode 100644 index 00000000000..6c8e711ef76 --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/AggregatedCollector.php @@ -0,0 +1,166 @@ + + * $aggcollector = new AggregateCollector('foobar'); + * $aggcollector->addCollector(new MessagesCollector('msg1')); + * $aggcollector->addCollector(new MessagesCollector('msg2')); + * $aggcollector['msg1']->addMessage('hello world'); + * + */ +class AggregatedCollector implements DataCollectorInterface, ArrayAccess +{ + protected $name; + + protected $mergeProperty; + + protected $sort; + + protected $collectors = array(); + + /** + * @param string $name + * @param string $mergeProperty + * @param boolean $sort + */ + public function __construct($name, $mergeProperty = null, $sort = false) + { + $this->name = $name; + $this->mergeProperty = $mergeProperty; + $this->sort = $sort; + } + + /** + * @param DataCollectorInterface $collector + */ + public function addCollector(DataCollectorInterface $collector) + { + $this->collectors[$collector->getName()] = $collector; + } + + /** + * @return array + */ + public function getCollectors() + { + return $this->collectors; + } + + /** + * Merge data from one of the key/value pair of the collected data + * + * @param string $property + */ + public function setMergeProperty($property) + { + $this->mergeProperty = $property; + } + + /** + * @return string + */ + public function getMergeProperty() + { + return $this->mergeProperty; + } + + /** + * Sorts the collected data + * + * If true, sorts using sort() + * If it is a string, sorts the data using the value from a key/value pair of the array + * + * @param bool|string $sort + */ + public function setSort($sort) + { + $this->sort = $sort; + } + + /** + * @return bool|string + */ + public function getSort() + { + return $this->sort; + } + + public function collect() + { + $aggregate = array(); + foreach ($this->collectors as $collector) { + $data = $collector->collect(); + if ($this->mergeProperty !== null) { + $data = $data[$this->mergeProperty]; + } + $aggregate = array_merge($aggregate, $data); + } + + return $this->sort($aggregate); + } + + /** + * Sorts the collected data + * + * @param array $data + * @return array + */ + protected function sort($data) + { + if (is_string($this->sort)) { + $p = $this->sort; + usort($data, function ($a, $b) use ($p) { + if ($a[$p] == $b[$p]) { + return 0; + } + return $a[$p] < $b[$p] ? -1 : 1; + }); + } elseif ($this->sort === true) { + sort($data); + } + return $data; + } + + public function getName() + { + return $this->name; + } + + // -------------------------------------------- + // ArrayAccess implementation + + public function offsetSet($key, $value) + { + throw new DebugBarException("AggregatedCollector[] is read-only"); + } + + public function offsetGet($key) + { + return $this->collectors[$key]; + } + + public function offsetExists($key) + { + return isset($this->collectors[$key]); + } + + public function offsetUnset($key) + { + throw new DebugBarException("AggregatedCollector[] is read-only"); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/AssetProvider.php b/htdocs/includes/DebugBar/DataCollector/AssetProvider.php new file mode 100644 index 00000000000..6910f737e17 --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/AssetProvider.php @@ -0,0 +1,28 @@ +name = $name; + $this->data = $data; + } + + /** + * Sets the data + * + * @param array $data + */ + public function setData(array $data) + { + $this->data = $data; + } + + public function collect() + { + $data = array(); + foreach ($this->data as $k => $v) { + if (!is_string($v)) { + $v = $this->getDataFormatter()->formatVar($v); + } + $data[$k] = $v; + } + return $data; + } + + public function getName() + { + return $this->name; + } + + public function getWidgets() + { + $name = $this->getName(); + return array( + "$name" => array( + "icon" => "gear", + "widget" => "PhpDebugBar.Widgets.VariableListWidget", + "map" => "$name", + "default" => "{}" + ) + ); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/DataCollector.php b/htdocs/includes/DebugBar/DataCollector/DataCollector.php new file mode 100644 index 00000000000..081f66e6872 --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/DataCollector.php @@ -0,0 +1,90 @@ +dataFormater = $formater; + return $this; + } + + public function getDataFormatter() + { + if ($this->dataFormater === null) { + $this->dataFormater = self::getDefaultDataFormatter(); + } + return $this->dataFormater; + } + + /** + * @deprecated + */ + public function formatVar($var) + { + return $this->getDataFormatter()->formatVar($var); + } + + /** + * @deprecated + */ + public function formatDuration($seconds) + { + return $this->getDataFormatter()->formatDuration($seconds); + } + + /** + * @deprecated + */ + public function formatBytes($size, $precision = 2) + { + return $this->getDataFormatter()->formatBytes($size, $precision); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/DataCollectorInterface.php b/htdocs/includes/DebugBar/DataCollector/DataCollectorInterface.php new file mode 100644 index 00000000000..b7f234cbff9 --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/DataCollectorInterface.php @@ -0,0 +1,31 @@ +exceptions[] = $e; + if ($this->chainExceptions && $previous = $e->getPrevious()) { + $this->addException($previous); + } + } + + /** + * Configure whether or not all chained exceptions should be shown. + * + * @param bool $chainExceptions + */ + public function setChainExceptions($chainExceptions = true) + { + $this->chainExceptions = $chainExceptions; + } + + /** + * Returns the list of exceptions being profiled + * + * @return array[Exception] + */ + public function getExceptions() + { + return $this->exceptions; + } + + public function collect() + { + return array( + 'count' => count($this->exceptions), + 'exceptions' => array_map(array($this, 'formatExceptionData'), $this->exceptions) + ); + } + + /** + * Returns exception data as an array + * + * @param Exception $e + * @return array + */ + public function formatExceptionData(Exception $e) + { + $filePath = $e->getFile(); + if ($filePath && file_exists($filePath)) { + $lines = file($filePath); + $start = $e->getLine() - 4; + $lines = array_slice($lines, $start < 0 ? 0 : $start, 7); + } else { + $lines = array("Cannot open the file ($filePath) in which the exception occurred "); + } + + return array( + 'type' => get_class($e), + 'message' => $e->getMessage(), + 'code' => $e->getCode(), + 'file' => $filePath, + 'line' => $e->getLine(), + 'surrounding_lines' => $lines + ); + } + + public function getName() + { + return 'exceptions'; + } + + public function getWidgets() + { + return array( + 'exceptions' => array( + 'icon' => 'bug', + 'widget' => 'PhpDebugBar.Widgets.ExceptionsWidget', + 'map' => 'exceptions.exceptions', + 'default' => '[]' + ), + 'exceptions:badge' => array( + 'map' => 'exceptions.count', + 'default' => 'null' + ) + ); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/LocalizationCollector.php b/htdocs/includes/DebugBar/DataCollector/LocalizationCollector.php new file mode 100644 index 00000000000..98b9e6334b2 --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/LocalizationCollector.php @@ -0,0 +1,64 @@ + $this->getLocale(), + 'domain' => $this->getDomain(), + ); + } + + public function getName() + { + return 'localization'; + } + + public function getWidgets() + { + return array( + 'domain' => array( + 'icon' => 'bookmark', + 'map' => 'localization.domain', + ), + 'locale' => array( + 'icon' => 'flag', + 'map' => 'localization.locale', + ) + ); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/MemoryCollector.php b/htdocs/includes/DebugBar/DataCollector/MemoryCollector.php new file mode 100644 index 00000000000..1a27c40bf3a --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/MemoryCollector.php @@ -0,0 +1,63 @@ +peakUsage; + } + + /** + * Updates the peak memory usage value + */ + public function updatePeakUsage() + { + $this->peakUsage = memory_get_peak_usage(true); + } + + public function collect() + { + $this->updatePeakUsage(); + return array( + 'peak_usage' => $this->peakUsage, + 'peak_usage_str' => $this->getDataFormatter()->formatBytes($this->peakUsage) + ); + } + + public function getName() + { + return 'memory'; + } + + public function getWidgets() + { + return array( + "memory" => array( + "icon" => "cogs", + "tooltip" => "Memory Usage", + "map" => "memory.peak_usage_str", + "default" => "'0B'" + ) + ); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/MessagesAggregateInterface.php b/htdocs/includes/DebugBar/DataCollector/MessagesAggregateInterface.php new file mode 100644 index 00000000000..1e2d4d2d3f2 --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/MessagesAggregateInterface.php @@ -0,0 +1,21 @@ +name = $name; + } + + /** + * Sets the data formater instance used by this collector + * + * @param DataFormatterInterface $formater + */ + public function setDataFormatter(DataFormatterInterface $formater) + { + $this->dataFormater = $formater; + return $this; + } + + public function getDataFormatter() + { + if ($this->dataFormater === null) { + $this->dataFormater = DataCollector::getDefaultDataFormatter(); + } + return $this->dataFormater; + } + + /** + * Adds a message + * + * A message can be anything from an object to a string + * + * @param mixed $message + * @param string $label + */ + public function addMessage($message, $label = 'info', $isString = true) + { + if (!is_string($message)) { + $message = $this->getDataFormatter()->formatVar($message); + $isString = false; + } + $this->messages[] = array( + 'message' => $message, + 'is_string' => $isString, + 'label' => $label, + 'time' => microtime(true) + ); + } + + /** + * Aggregates messages from other collectors + * + * @param MessagesAggregateInterface $messages + */ + public function aggregate(MessagesAggregateInterface $messages) + { + $this->aggregates[] = $messages; + } + + public function getMessages() + { + $messages = $this->messages; + foreach ($this->aggregates as $collector) { + $msgs = array_map(function ($m) use ($collector) { + $m['collector'] = $collector->getName(); + return $m; + }, $collector->getMessages()); + $messages = array_merge($messages, $msgs); + } + + // sort messages by their timestamp + usort($messages, function ($a, $b) { + if ($a['time'] === $b['time']) { + return 0; + } + return $a['time'] < $b['time'] ? -1 : 1; + }); + + return $messages; + } + + public function log($level, $message, array $context = array()) + { + $this->addMessage($message, $level); + } + + /** + * Deletes all messages + */ + public function clear() + { + $this->messages = array(); + } + + public function collect() + { + $messages = $this->getMessages(); + return array( + 'count' => count($messages), + 'messages' => $messages + ); + } + + public function getName() + { + return $this->name; + } + + public function getWidgets() + { + $name = $this->getName(); + return array( + "$name" => array( + 'icon' => 'list-alt', + "widget" => "PhpDebugBar.Widgets.MessagesWidget", + "map" => "$name.messages", + "default" => "[]" + ), + "$name:badge" => array( + "map" => "$name.count", + "default" => "null" + ) + ); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/PDO/PDOCollector.php b/htdocs/includes/DebugBar/DataCollector/PDO/PDOCollector.php new file mode 100644 index 00000000000..37e7b020b1f --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/PDO/PDOCollector.php @@ -0,0 +1,182 @@ +'; + + /** + * @param TraceablePDO $pdo + * @param TimeDataCollector $timeCollector + */ + public function __construct(TraceablePDO $pdo = null, TimeDataCollector $timeCollector = null) + { + $this->timeCollector = $timeCollector; + if ($pdo !== null) { + $this->addConnection($pdo, 'default'); + } + } + + /** + * Renders the SQL of traced statements with params embeded + * + * @param boolean $enabled + */ + public function setRenderSqlWithParams($enabled = true, $quotationChar = '<>') + { + $this->renderSqlWithParams = $enabled; + $this->sqlQuotationChar = $quotationChar; + } + + public function isSqlRenderedWithParams() + { + return $this->renderSqlWithParams; + } + + public function getSqlQuotationChar() + { + return $this->sqlQuotationChar; + } + + /** + * Adds a new PDO instance to be collector + * + * @param TraceablePDO $pdo + * @param string $name Optional connection name + */ + public function addConnection(TraceablePDO $pdo, $name = null) + { + if ($name === null) { + $name = spl_object_hash($pdo); + } + $this->connections[$name] = $pdo; + } + + /** + * Returns PDO instances to be collected + * + * @return array + */ + public function getConnections() + { + return $this->connections; + } + + public function collect() + { + $data = array( + 'nb_statements' => 0, + 'nb_failed_statements' => 0, + 'accumulated_duration' => 0, + 'memory_usage' => 0, + 'peak_memory_usage' => 0, + 'statements' => array() + ); + + foreach ($this->connections as $name => $pdo) { + $pdodata = $this->collectPDO($pdo, $this->timeCollector); + $data['nb_statements'] += $pdodata['nb_statements']; + $data['nb_failed_statements'] += $pdodata['nb_failed_statements']; + $data['accumulated_duration'] += $pdodata['accumulated_duration']; + $data['memory_usage'] += $pdodata['memory_usage']; + $data['peak_memory_usage'] = max($data['peak_memory_usage'], $pdodata['peak_memory_usage']); + $data['statements'] = array_merge($data['statements'], + array_map(function ($s) use ($name) { $s['connection'] = $name; return $s; }, $pdodata['statements'])); + } + + $data['accumulated_duration_str'] = $this->getDataFormatter()->formatDuration($data['accumulated_duration']); + $data['memory_usage_str'] = $this->getDataFormatter()->formatBytes($data['memory_usage']); + $data['peak_memory_usage_str'] = $this->getDataFormatter()->formatBytes($data['peak_memory_usage']); + + return $data; + } + + /** + * Collects data from a single TraceablePDO instance + * + * @param TraceablePDO $pdo + * @param TimeDataCollector $timeCollector + * @return array + */ + protected function collectPDO(TraceablePDO $pdo, TimeDataCollector $timeCollector = null) + { + $stmts = array(); + foreach ($pdo->getExecutedStatements() as $stmt) { + $stmts[] = array( + 'sql' => $this->renderSqlWithParams ? $stmt->getSqlWithParams($this->sqlQuotationChar) : $stmt->getSql(), + 'row_count' => $stmt->getRowCount(), + 'stmt_id' => $stmt->getPreparedId(), + 'prepared_stmt' => $stmt->getSql(), + 'params' => (object) $stmt->getParameters(), + 'duration' => $stmt->getDuration(), + 'duration_str' => $this->getDataFormatter()->formatDuration($stmt->getDuration()), + 'memory' => $stmt->getMemoryUsage(), + 'memory_str' => $this->getDataFormatter()->formatBytes($stmt->getMemoryUsage()), + 'end_memory' => $stmt->getEndMemory(), + 'end_memory_str' => $this->getDataFormatter()->formatBytes($stmt->getEndMemory()), + 'is_success' => $stmt->isSuccess(), + 'error_code' => $stmt->getErrorCode(), + 'error_message' => $stmt->getErrorMessage() + ); + if ($timeCollector !== null) { + $timeCollector->addMeasure($stmt->getSql(), $stmt->getStartTime(), $stmt->getEndTime()); + } + } + + return array( + 'nb_statements' => count($stmts), + 'nb_failed_statements' => count($pdo->getFailedExecutedStatements()), + 'accumulated_duration' => $pdo->getAccumulatedStatementsDuration(), + 'accumulated_duration_str' => $this->getDataFormatter()->formatDuration($pdo->getAccumulatedStatementsDuration()), + 'memory_usage' => $pdo->getMemoryUsage(), + 'memory_usage_str' => $this->getDataFormatter()->formatBytes($pdo->getPeakMemoryUsage()), + 'peak_memory_usage' => $pdo->getPeakMemoryUsage(), + 'peak_memory_usage_str' => $this->getDataFormatter()->formatBytes($pdo->getPeakMemoryUsage()), + 'statements' => $stmts + ); + } + + public function getName() + { + return 'pdo'; + } + + public function getWidgets() + { + return array( + "database" => array( + "icon" => "inbox", + "widget" => "PhpDebugBar.Widgets.SQLQueriesWidget", + "map" => "pdo", + "default" => "[]" + ), + "database:badge" => array( + "map" => "pdo.nb_statements", + "default" => 0 + ) + ); + } + + public function getAssets() + { + return array( + 'css' => 'widgets/sqlqueries/widget.css', + 'js' => 'widgets/sqlqueries/widget.js' + ); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/PDO/TraceablePDO.php b/htdocs/includes/DebugBar/DataCollector/PDO/TraceablePDO.php new file mode 100644 index 00000000000..5f7688b978e --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/PDO/TraceablePDO.php @@ -0,0 +1,196 @@ +pdo = $pdo; + $this->pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DebugBar\DataCollector\PDO\TraceablePDOStatement', array($this))); + } + + public function beginTransaction() + { + return $this->pdo->beginTransaction(); + } + + public function commit() + { + return $this->pdo->commit(); + } + + public function errorCode() + { + return $this->pdo->errorCode(); + } + + public function errorInfo() + { + return $this->pdo->errorInfo(); + } + + public function exec($sql) + { + return $this->profileCall('exec', $sql, func_get_args()); + } + + public function getAttribute($attr) + { + return $this->pdo->getAttribute($attr); + } + + public function inTransaction() + { + return $this->pdo->inTransaction(); + } + + public function lastInsertId($name = null) + { + return $this->pdo->lastInsertId($name); + } + + public function prepare($sql, $driver_options = array()) + { + return $this->pdo->prepare($sql, $driver_options); + } + + public function query($sql) + { + return $this->profileCall('query', $sql, func_get_args()); + } + + public function quote($expr, $parameter_type = PDO::PARAM_STR) + { + return $this->pdo->quote($expr, $parameter_type); + } + + public function rollBack() + { + return $this->pdo->rollBack(); + } + + public function setAttribute($attr, $value) + { + return $this->pdo->setAttribute($attr, $value); + } + + /** + * Profiles a call to a PDO method + * + * @param string $method + * @param string $sql + * @param array $args + * @return mixed The result of the call + */ + protected function profileCall($method, $sql, array $args) + { + $trace = new TracedStatement($sql); + $trace->start(); + + $ex = null; + try { + $result = call_user_func_array(array($this->pdo, $method), $args); + } catch (PDOException $e) { + $ex = $e; + } + + if ($this->pdo->getAttribute(PDO::ATTR_ERRMODE) !== PDO::ERRMODE_EXCEPTION && $result === false) { + $error = $this->pdo->errorInfo(); + $ex = new PDOException($error[2], $error[0]); + } + + $trace->end($ex); + $this->addExecutedStatement($trace); + + if ($this->pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_EXCEPTION && $ex !== null) { + throw $ex; + } + return $result; + } + + /** + * Adds an executed TracedStatement + * + * @param TracedStatement $stmt + */ + public function addExecutedStatement(TracedStatement $stmt) + { + $this->executedStatements[] = $stmt; + } + + /** + * Returns the accumulated execution time of statements + * + * @return int + */ + public function getAccumulatedStatementsDuration() + { + return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getDuration(); }); + } + + /** + * Returns the peak memory usage while performing statements + * + * @return int + */ + public function getMemoryUsage() + { + return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getMemoryUsage(); }); + } + + /** + * Returns the peak memory usage while performing statements + * + * @return int + */ + public function getPeakMemoryUsage() + { + return array_reduce($this->executedStatements, function ($v, $s) { $m = $s->getEndMemory(); return $m > $v ? $m : $v; }); + } + + /** + * Returns the list of executed statements as TracedStatement objects + * + * @return array + */ + public function getExecutedStatements() + { + return $this->executedStatements; + } + + /** + * Returns the list of failed statements + * + * @return array + */ + public function getFailedExecutedStatements() + { + return array_filter($this->executedStatements, function ($s) { return !$s->isSuccess(); }); + } + + public function __get($name) + { + return $this->pdo->$name; + } + + public function __set($name, $value) + { + $this->pdo->$name = $value; + } + + public function __call($name, $args) + { + return call_user_func_array(array($this->pdo, $name), $args); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/PDO/TraceablePDOStatement.php b/htdocs/includes/DebugBar/DataCollector/PDO/TraceablePDOStatement.php new file mode 100644 index 00000000000..b903b10c361 --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/PDO/TraceablePDOStatement.php @@ -0,0 +1,74 @@ +pdo = $pdo; + } + + public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null) + { + $this->boundParameters[$column] = $param; + $args = array_merge(array($column, &$param), array_slice(func_get_args(), 2)); + return call_user_func_array(array("parent", 'bindColumn'), $args); + } + + public function bindParam($param, &$var, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null) + { + $this->boundParameters[$param] = $var; + $args = array_merge(array($param, &$var), array_slice(func_get_args(), 2)); + return call_user_func_array(array("parent", 'bindParam'), $args); + } + + public function bindValue($param, $value, $data_type = PDO::PARAM_STR) + { + $this->boundParameters[$param] = $value; + return call_user_func_array(array("parent", 'bindValue'), func_get_args()); + } + + public function execute($params = null) + { + $preparedId = spl_object_hash($this); + $boundParameters = $this->boundParameters; + if (is_array($params)) { + $boundParameters = array_merge($boundParameters, $params); + } + + $trace = new TracedStatement($this->queryString, $boundParameters, $preparedId); + $trace->start(); + + $ex = null; + try { + $result = parent::execute($params); + } catch (PDOException $e) { + $ex = $e; + } + + if ($this->pdo->getAttribute(PDO::ATTR_ERRMODE) !== PDO::ERRMODE_EXCEPTION && $result === false) { + $error = $this->errorInfo(); + $ex = new PDOException($error[2], $error[0]); + } + + $trace->end($ex, $this->rowCount()); + $this->pdo->addExecutedStatement($trace); + + if ($this->pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_EXCEPTION && $ex !== null) { + throw $ex; + } + return $result; + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/PDO/TracedStatement.php b/htdocs/includes/DebugBar/DataCollector/PDO/TracedStatement.php new file mode 100644 index 00000000000..dc51cee1764 --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/PDO/TracedStatement.php @@ -0,0 +1,240 @@ +sql = $sql; + $this->parameters = $this->checkParameters($params); + $this->preparedId = $preparedId; + } + + public function start($startTime = null, $startMemory = null) + { + $this->startTime = $startTime ?: microtime(true); + $this->startMemory = $startMemory ?: memory_get_usage(true); + } + + public function end(\Exception $exception = null, $rowCount = 0, $endTime = null, $endMemory = null) + { + $this->endTime = $endTime ?: microtime(true); + $this->duration = $this->endTime - $this->startTime; + $this->endMemory = $endMemory ?: memory_get_usage(true); + $this->memoryDelta = $this->endMemory - $this->startMemory; + $this->exception = $exception; + $this->rowCount = $rowCount; + } + + /** + * Check parameters for illegal (non UTF-8) strings, like Binary data. + * + * @param $params + * @return mixed + */ + public function checkParameters($params) + { + foreach ($params as &$param) { + if (!mb_check_encoding($param, 'UTF-8')) { + $param = '[BINARY DATA]'; + } + } + return $params; + } + + /** + * Returns the SQL string used for the query + * + * @return string + */ + public function getSql() + { + return $this->sql; + } + + /** + * Returns the SQL string with any parameters used embedded + * + * @param string $quotationChar + * @return string + */ + public function getSqlWithParams($quotationChar = '<>') + { + if (($l = strlen($quotationChar)) > 1) { + $quoteLeft = substr($quotationChar, 0, $l / 2); + $quoteRight = substr($quotationChar, $l / 2); + } else { + $quoteLeft = $quoteRight = $quotationChar; + } + + $sql = $this->sql; + foreach ($this->parameters as $k => $v) { + $v = "$quoteLeft$v$quoteRight"; + if (!is_numeric($k)) { + $sql = str_replace($k, $v, $sql); + } else { + $p = strpos($sql, '?'); + $sql = substr($sql, 0, $p) . $v. substr($sql, $p + 1); + } + } + return $sql; + } + + /** + * Returns the number of rows affected/returned + * + * @return int + */ + public function getRowCount() + { + return $this->rowCount; + } + + /** + * Returns an array of parameters used with the query + * + * @return array + */ + public function getParameters() + { + $params = array(); + foreach ($this->parameters as $param) { + $params[] = htmlentities($param, ENT_QUOTES, 'UTF-8', false); + } + return $params; + } + + /** + * Returns the prepared statement id + * + * @return string + */ + public function getPreparedId() + { + return $this->preparedId; + } + + /** + * Checks if this is a prepared statement + * + * @return boolean + */ + public function isPrepared() + { + return $this->preparedId !== null; + } + + public function getStartTime() + { + return $this->startTime; + } + + public function getEndTime() + { + return $this->endTime; + } + + /** + * Returns the duration in seconds of the execution + * + * @return int + */ + public function getDuration() + { + return $this->duration; + } + + public function getStartMemory() + { + return $this->startMemory; + } + + public function getEndMemory() + { + return $this->endMemory; + } + + /** + * Returns the memory usage during the execution + * + * @return int + */ + public function getMemoryUsage() + { + return $this->memoryDelta; + } + + /** + * Checks if the statement was successful + * + * @return boolean + */ + public function isSuccess() + { + return $this->exception === null; + } + + /** + * Returns the exception triggered + * + * @return \Exception + */ + public function getException() + { + return $this->exception; + } + + /** + * Returns the exception's code + * + * @return string + */ + public function getErrorCode() + { + return $this->exception !== null ? $this->exception->getCode() : 0; + } + + /** + * Returns the exception's message + * + * @return string + */ + public function getErrorMessage() + { + return $this->exception !== null ? $this->exception->getMessage() : ''; + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/PhpInfoCollector.php b/htdocs/includes/DebugBar/DataCollector/PhpInfoCollector.php new file mode 100644 index 00000000000..57e9e45f47f --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/PhpInfoCollector.php @@ -0,0 +1,51 @@ + PHP_VERSION, + 'interface' => PHP_SAPI + ); + } + + /** + * {@inheritDoc} + */ + public function getWidgets() + { + return array( + "php_version" => array( + "icon" => "code", + "tooltip" => "Version", + "map" => "php.version", + "default" => "" + ), + ); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/Renderable.php b/htdocs/includes/DebugBar/DataCollector/Renderable.php new file mode 100644 index 00000000000..1a6a833f5d1 --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/Renderable.php @@ -0,0 +1,25 @@ +getDataFormatter()->formatVar($GLOBALS[$var]); + } + } + + return $data; + } + + public function getName() + { + return 'request'; + } + + public function getWidgets() + { + return array( + "request" => array( + "icon" => "tags", + "widget" => "PhpDebugBar.Widgets.VariableListWidget", + "map" => "request", + "default" => "{}" + ) + ); + } +} diff --git a/htdocs/includes/DebugBar/DataCollector/TimeDataCollector.php b/htdocs/includes/DebugBar/DataCollector/TimeDataCollector.php new file mode 100644 index 00000000000..19e5a63ced1 --- /dev/null +++ b/htdocs/includes/DebugBar/DataCollector/TimeDataCollector.php @@ -0,0 +1,228 @@ +requestStartTime = $requestStartTime; + } + + /** + * Starts a measure + * + * @param string $name Internal name, used to stop the measure + * @param string|null $label Public name + * @param string|null $collector The source of the collector + */ + public function startMeasure($name, $label = null, $collector = null) + { + $start = microtime(true); + $this->startedMeasures[$name] = array( + 'label' => $label ?: $name, + 'start' => $start, + 'collector' => $collector + ); + } + + /** + * Check a measure exists + * + * @param string $name + * @return bool + */ + public function hasStartedMeasure($name) + { + return isset($this->startedMeasures[$name]); + } + + /** + * Stops a measure + * + * @param string $name + * @param array $params + * @throws DebugBarException + */ + public function stopMeasure($name, $params = array()) + { + $end = microtime(true); + if (!$this->hasStartedMeasure($name)) { + throw new DebugBarException("Failed stopping measure '$name' because it hasn't been started"); + } + $this->addMeasure( + $this->startedMeasures[$name]['label'], + $this->startedMeasures[$name]['start'], + $end, + $params, + $this->startedMeasures[$name]['collector'] + ); + unset($this->startedMeasures[$name]); + } + + /** + * Adds a measure + * + * @param string $label + * @param float $start + * @param float $end + * @param array $params + * @param string|null $collector + */ + public function addMeasure($label, $start, $end, $params = array(), $collector = null) + { + $this->measures[] = array( + 'label' => $label, + 'start' => $start, + 'relative_start' => $start - $this->requestStartTime, + 'end' => $end, + 'relative_end' => $end - $this->requestEndTime, + 'duration' => $end - $start, + 'duration_str' => $this->getDataFormatter()->formatDuration($end - $start), + 'params' => $params, + 'collector' => $collector + ); + } + + /** + * Utility function to measure the execution of a Closure + * + * @param string $label + * @param \Closure $closure + * @param string|null $collector + */ + public function measure($label, \Closure $closure, $collector = null) + { + $name = spl_object_hash($closure); + $this->startMeasure($name, $label, $collector); + $result = $closure(); + $params = is_array($result) ? $result : array(); + $this->stopMeasure($name, $params); + } + + /** + * Returns an array of all measures + * + * @return array + */ + public function getMeasures() + { + return $this->measures; + } + + /** + * Returns the request start time + * + * @return float + */ + public function getRequestStartTime() + { + return $this->requestStartTime; + } + + /** + * Returns the request end time + * + * @return float + */ + public function getRequestEndTime() + { + return $this->requestEndTime; + } + + /** + * Returns the duration of a request + * + * @return float + */ + public function getRequestDuration() + { + if ($this->requestEndTime !== null) { + return $this->requestEndTime - $this->requestStartTime; + } + return microtime(true) - $this->requestStartTime; + } + + public function collect() + { + $this->requestEndTime = microtime(true); + foreach (array_keys($this->startedMeasures) as $name) { + $this->stopMeasure($name); + } + + return array( + 'start' => $this->requestStartTime, + 'end' => $this->requestEndTime, + 'duration' => $this->getRequestDuration(), + 'duration_str' => $this->getDataFormatter()->formatDuration($this->getRequestDuration()), + 'measures' => array_values($this->measures) + ); + } + + public function getName() + { + return 'time'; + } + + public function getWidgets() + { + return array( + "time" => array( + "icon" => "clock-o", + "tooltip" => "Request Duration", + "map" => "time.duration_str", + "default" => "'0ms'" + ), + "timeline" => array( + "icon" => "tasks", + "widget" => "PhpDebugBar.Widgets.TimelineWidget", + "map" => "time", + "default" => "{}" + ) + ); + } +} diff --git a/htdocs/includes/DebugBar/DataFormatter/DataFormatter.php b/htdocs/includes/DebugBar/DataFormatter/DataFormatter.php new file mode 100644 index 00000000000..73269459838 --- /dev/null +++ b/htdocs/includes/DebugBar/DataFormatter/DataFormatter.php @@ -0,0 +1,169 @@ +kintLite($data); + } + + public function formatDuration($seconds) + { + if ($seconds < 0.001) { + return round($seconds * 1000000) . 'μs'; + } elseif ($seconds < 1) { + return round($seconds * 1000, 2) . 'ms'; + } + return round($seconds, 2) . 's'; + } + + public function formatBytes($size, $precision = 2) + { + if ($size === 0 || $size === null) { + return "0B"; + } + $base = log($size) / log(1024); + $suffixes = array('B', 'KB', 'MB', 'GB', 'TB'); + return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; + } + + /** + * lightweight version of Kint::dump(). Uses whitespace for formatting instead of html + * sadly not DRY yet + * + * Extracted from Kint.class.php in raveren/kint, https://github.com/raveren/kint + * Copyright (c) 2013 Rokas Šleinius (raveren@gmail.com) + * + * @param mixed $var + * @param int $level + * + * @return string + */ + protected function kintLite(&$var, $level = 0) + { + // initialize function names into variables for prettier string output (html and implode are also DRY) + $html = "htmlspecialchars"; + $implode = "implode"; + $strlen = "strlen"; + $count = "count"; + $getClass = "get_class"; + + if ( $var === null ) { + return 'NULL'; + } elseif ( is_bool( $var ) ) { + return 'bool ' . ( $var ? 'TRUE' : 'FALSE' ); + } elseif ( is_float( $var ) ) { + return 'float ' . $var; + } elseif ( is_int( $var ) ) { + return 'integer ' . $var; + } elseif ( is_resource( $var ) ) { + if ( ( $type = get_resource_type( $var ) ) === 'stream' and $meta = stream_get_meta_data( $var ) ) { + if ( isset( $meta['uri'] ) ) { + $file = $meta['uri']; + + return "resource ({$type}) {$html( $file, 0 )}"; + } else { + return "resource ({$type})"; + } + } else { + return "resource ({$type})"; + } + } elseif ( is_string( $var ) ) { + return "string ({$strlen( $var )}) \"{$html( $var )}\""; + } elseif ( is_array( $var ) ) { + $output = array(); + $space = str_repeat( $s = ' ', $level ); + + static $marker; + + if ( $marker === null ) { + // Make a unique marker + $marker = uniqid( "\x00" ); + } + + if ( empty( $var ) ) { + return "array()"; + } elseif ( isset( $var[$marker] ) ) { + $output[] = "[\n$space$s*RECURSION*\n$space]"; + } elseif ( $level < 7 ) { + $isSeq = array_keys( $var ) === range( 0, count( $var ) - 1 ); + + $output[] = "["; + + $var[$marker] = true; + + foreach ( $var as $key => &$val ) { + if ( $key === $marker ) { + continue; + } + + $key = $space . $s . ( $isSeq ? "" : "'{$html( $key, 0 )}' => " ); + + $dump = $this->kintLite( $val, $level + 1 ); + $output[] = "{$key}{$dump}"; + } + + unset( $var[$marker] ); + $output[] = "$space]"; + } else { + $output[] = "[\n$space$s*depth too great*\n$space]"; + } + return "array({$count( $var )}) {$implode( "\n", $output )}"; + } elseif ( is_object( $var ) ) { + if ( $var instanceof SplFileInfo ) { + return "object SplFileInfo " . $var->getRealPath(); + } + + // Copy the object as an array + $array = (array) $var; + + $output = array(); + $space = str_repeat( $s = ' ', $level ); + + $hash = spl_object_hash( $var ); + + // Objects that are being dumped + static $objects = array(); + + if ( empty( $array ) ) { + return "object {$getClass( $var )} {}"; + } elseif ( isset( $objects[$hash] ) ) { + $output[] = "{\n$space$s*RECURSION*\n$space}"; + } elseif ( $level < 7 ) { + $output[] = "{"; + $objects[$hash] = true; + + foreach ( $array as $key => & $val ) { + if ( $key[0] === "\x00" ) { + $access = $key[1] === "*" ? "protected" : "private"; + + // Remove the access level from the variable name + $key = substr( $key, strrpos( $key, "\x00" ) + 1 ); + } else { + $access = "public"; + } + + $output[] = "$space$s$access $key -> " . $this->kintLite( $val, $level + 1 ); + } + unset( $objects[$hash] ); + $output[] = "$space}"; + } else { + $output[] = "{\n$space$s*depth too great*\n$space}"; + } + + return "object {$getClass( $var )} ({$count( $array )}) {$implode( "\n", $output )}"; + } else { + return gettype( $var ) . htmlspecialchars( var_export( $var, true ), ENT_NOQUOTES ); + } + } +} diff --git a/htdocs/includes/DebugBar/DataFormatter/DataFormatterInterface.php b/htdocs/includes/DebugBar/DataFormatter/DataFormatterInterface.php new file mode 100644 index 00000000000..cb7b426e70b --- /dev/null +++ b/htdocs/includes/DebugBar/DataFormatter/DataFormatterInterface.php @@ -0,0 +1,42 @@ + + * $debugbar = new DebugBar(); + * $debugbar->addCollector(new DataCollector\MessagesCollector()); + * $debugbar['messages']->addMessage("foobar"); + * + */ +class DebugBar implements ArrayAccess +{ + public static $useOpenHandlerWhenSendingDataHeaders = false; + + protected $collectors = array(); + + protected $data; + + protected $jsRenderer; + + protected $requestIdGenerator; + + protected $requestId; + + protected $storage; + + protected $httpDriver; + + protected $stackSessionNamespace = 'PHPDEBUGBAR_STACK_DATA'; + + protected $stackAlwaysUseSessionStorage = false; + + /** + * Adds a data collector + * + * @param DataCollectorInterface $collector + * + * @throws DebugBarException + * @return $this + */ + public function addCollector(DataCollectorInterface $collector) + { + if ($collector->getName() === '__meta') { + throw new DebugBarException("'__meta' is a reserved name and cannot be used as a collector name"); + } + if (isset($this->collectors[$collector->getName()])) { + throw new DebugBarException("'{$collector->getName()}' is already a registered collector"); + } + $this->collectors[$collector->getName()] = $collector; + return $this; + } + + /** + * Checks if a data collector has been added + * + * @param string $name + * @return boolean + */ + public function hasCollector($name) + { + return isset($this->collectors[$name]); + } + + /** + * Returns a data collector + * + * @param string $name + * @return DataCollectorInterface + */ + public function getCollector($name) + { + if (!isset($this->collectors[$name])) { + throw new DebugBarException("'$name' is not a registered collector"); + } + return $this->collectors[$name]; + } + + /** + * Returns an array of all data collectors + * + * @return array[DataCollectorInterface] + */ + public function getCollectors() + { + return $this->collectors; + } + + /** + * Sets the request id generator + * + * @param RequestIdGeneratorInterface $generator + */ + public function setRequestIdGenerator(RequestIdGeneratorInterface $generator) + { + $this->requestIdGenerator = $generator; + return $this; + } + + /** + * @return RequestIdGeneratorInterface + */ + public function getRequestIdGenerator() + { + if ($this->requestIdGenerator === null) { + $this->requestIdGenerator = new RequestIdGenerator(); + } + return $this->requestIdGenerator; + } + + /** + * Returns the id of the current request + * + * @return string + */ + public function getCurrentRequestId() + { + if ($this->requestId === null) { + $this->requestId = $this->getRequestIdGenerator()->generate(); + } + return $this->requestId; + } + + /** + * Sets the storage backend to use to store the collected data + * + * @param StorageInterface $storage + */ + public function setStorage(StorageInterface $storage = null) + { + $this->storage = $storage; + return $this; + } + + /** + * @return StorageInterface + */ + public function getStorage() + { + return $this->storage; + } + + /** + * Checks if the data will be persisted + * + * @return boolean + */ + public function isDataPersisted() + { + return $this->storage !== null; + } + + /** + * Sets the HTTP driver + * + * @param HttpDriverInterface $driver + */ + public function setHttpDriver(HttpDriverInterface $driver) + { + $this->httpDriver = $driver; + return $this; + } + + /** + * Returns the HTTP driver + * + * If no http driver where defined, a PhpHttpDriver is automatically created + * + * @return HttpDriverInterface + */ + public function getHttpDriver() + { + if ($this->httpDriver === null) { + $this->httpDriver = new PhpHttpDriver(); + } + return $this->httpDriver; + } + + /** + * Collects the data from the collectors + * + * @return array + */ + public function collect() + { + $this->data = array( + '__meta' => array( + 'id' => $this->getCurrentRequestId(), + 'datetime' => date('Y-m-d H:i:s'), + 'utime' => microtime(true), + 'method' => isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null, + 'uri' => isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null, + 'ip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null + ) + ); + + foreach ($this->collectors as $name => $collector) { + $this->data[$name] = $collector->collect(); + } + + // Remove all invalid (non UTF-8) characters + array_walk_recursive($this->data, function (&$item) { + if (is_string($item) && !mb_check_encoding($item, 'UTF-8')) { + $item = mb_convert_encoding($item, 'UTF-8', 'UTF-8'); + } + }); + + if ($this->storage !== null) { + $this->storage->save($this->getCurrentRequestId(), $this->data); + } + + return $this->data; + } + + /** + * Returns collected data + * + * Will collect the data if none have been collected yet + * + * @return array + */ + public function getData() + { + if ($this->data === null) { + $this->collect(); + } + return $this->data; + } + + /** + * Returns an array of HTTP headers containing the data + * + * @param string $headerName + * @param integer $maxHeaderLength + * @return array + */ + public function getDataAsHeaders($headerName = 'phpdebugbar', $maxHeaderLength = 4096, $maxTotalHeaderLength = 250000) + { + $data = rawurlencode(json_encode(array( + 'id' => $this->getCurrentRequestId(), + 'data' => $this->getData() + ))); + + if (strlen($data) > $maxTotalHeaderLength) { + $data = rawurlencode(json_encode(array( + 'error' => 'Maximum header size exceeded' + ))); + } + + $chunks = array(); + + while (strlen($data) > $maxHeaderLength) { + $chunks[] = substr($data, 0, $maxHeaderLength); + $data = substr($data, $maxHeaderLength); + } + $chunks[] = $data; + + $headers = array(); + for ($i = 0, $c = count($chunks); $i < $c; $i++) { + $name = $headerName . ($i > 0 ? "-$i" : ''); + $headers[$name] = $chunks[$i]; + } + + return $headers; + } + + /** + * Sends the data through the HTTP headers + * + * @param bool $useOpenHandler + * @param string $headerName + * @param integer $maxHeaderLength + */ + public function sendDataInHeaders($useOpenHandler = null, $headerName = 'phpdebugbar', $maxHeaderLength = 4096) + { + if ($useOpenHandler === null) { + $useOpenHandler = self::$useOpenHandlerWhenSendingDataHeaders; + } + if ($useOpenHandler && $this->storage !== null) { + $this->getData(); + $headerName .= '-id'; + $headers = array($headerName => $this->getCurrentRequestId()); + } else { + $headers = $this->getDataAsHeaders($headerName, $maxHeaderLength); + } + $this->getHttpDriver()->setHeaders($headers); + return $this; + } + + /** + * Stacks the data in the session for later rendering + */ + public function stackData() + { + $http = $this->initStackSession(); + + $data = null; + if (!$this->isDataPersisted() || $this->stackAlwaysUseSessionStorage) { + $data = $this->getData(); + } elseif ($this->data === null) { + $this->collect(); + } + + $stack = $http->getSessionValue($this->stackSessionNamespace); + $stack[$this->getCurrentRequestId()] = $data; + $http->setSessionValue($this->stackSessionNamespace, $stack); + return $this; + } + + /** + * Checks if there is stacked data in the session + * + * @return boolean + */ + public function hasStackedData() + { + try { + $http = $this->initStackSession(); + } catch (DebugBarException $e) { + return false; + } + return count($http->getSessionValue($this->stackSessionNamespace)) > 0; + } + + /** + * Returns the data stacked in the session + * + * @param boolean $delete Whether to delete the data in the session + * @return array + */ + public function getStackedData($delete = true) + { + $http = $this->initStackSession(); + $stackedData = $http->getSessionValue($this->stackSessionNamespace); + if ($delete) { + $http->deleteSessionValue($this->stackSessionNamespace); + } + + $datasets = array(); + if ($this->isDataPersisted() && !$this->stackAlwaysUseSessionStorage) { + foreach ($stackedData as $id => $data) { + $datasets[$id] = $this->getStorage()->get($id); + } + } else { + $datasets = $stackedData; + } + + return $datasets; + } + + /** + * Sets the key to use in the $_SESSION array + * + * @param string $ns + */ + public function setStackDataSessionNamespace($ns) + { + $this->stackSessionNamespace = $ns; + return $this; + } + + /** + * Returns the key used in the $_SESSION array + * + * @return string + */ + public function getStackDataSessionNamespace() + { + return $this->stackSessionNamespace; + } + + /** + * Sets whether to only use the session to store stacked data even + * if a storage is enabled + * + * @param boolean $enabled + */ + public function setStackAlwaysUseSessionStorage($enabled = true) + { + $this->stackAlwaysUseSessionStorage = $enabled; + return $this; + } + + /** + * Checks if the session is always used to store stacked data + * even if a storage is enabled + * + * @return boolean + */ + public function isStackAlwaysUseSessionStorage() + { + return $this->stackAlwaysUseSessionStorage; + } + + /** + * Initializes the session for stacked data + * + * @return HttpDriverInterface + */ + protected function initStackSession() + { + $http = $this->getHttpDriver(); + if (!$http->isSessionStarted()) { + throw new DebugBarException("Session must be started before using stack data in the debug bar"); + } + + if (!$http->hasSessionValue($this->stackSessionNamespace)) { + $http->setSessionValue($this->stackSessionNamespace, array()); + } + + return $http; + } + + /** + * Returns a JavascriptRenderer for this instance + * + * @param string $baseUrl + * @param string $basePathng + * @return JavascriptRenderer + */ + public function getJavascriptRenderer($baseUrl = null, $basePath = null) + { + if ($this->jsRenderer === null) { + $this->jsRenderer = new JavascriptRenderer($this, $baseUrl, $basePath); + } + return $this->jsRenderer; + } + + // -------------------------------------------- + // ArrayAccess implementation + + public function offsetSet($key, $value) + { + throw new DebugBarException("DebugBar[] is read-only"); + } + + public function offsetGet($key) + { + return $this->getCollector($key); + } + + public function offsetExists($key) + { + return $this->hasCollector($key); + } + + public function offsetUnset($key) + { + throw new DebugBarException("DebugBar[] is read-only"); + } +} diff --git a/htdocs/includes/DebugBar/DebugBarException.php b/htdocs/includes/DebugBar/DebugBarException.php new file mode 100644 index 00000000000..32ffe255cdc --- /dev/null +++ b/htdocs/includes/DebugBar/DebugBarException.php @@ -0,0 +1,16 @@ + 'vendor/font-awesome/css/font-awesome.min.css', + 'highlightjs' => 'vendor/highlightjs/styles/github.css' + ); + + protected $jsVendors = array( + 'jquery' => 'vendor/jquery/dist/jquery.min.js', + 'highlightjs' => 'vendor/highlightjs/highlight.pack.js' + ); + + protected $includeVendors = true; + + protected $cssFiles = array('debugbar.css', 'widgets.css', 'openhandler.css'); + + protected $jsFiles = array('debugbar.js', 'widgets.js', 'openhandler.js'); + + protected $additionalAssets = array(); + + protected $javascriptClass = 'PhpDebugBar.DebugBar'; + + protected $variableName = 'phpdebugbar'; + + protected $enableJqueryNoConflict = true; + + protected $initialization; + + protected $controls = array(); + + protected $ignoredCollectors = array(); + + protected $ajaxHandlerClass = 'PhpDebugBar.AjaxHandler'; + + protected $ajaxHandlerBindToJquery = true; + + protected $ajaxHandlerBindToXHR = false; + + protected $openHandlerClass = 'PhpDebugBar.OpenHandler'; + + protected $openHandlerUrl; + + /** + * @param \DebugBar\DebugBar $debugBar + * @param string $baseUrl + * @param string $basePath + */ + public function __construct(DebugBar $debugBar, $baseUrl = null, $basePath = null) + { + $this->debugBar = $debugBar; + + if ($baseUrl === null) { + $baseUrl = '/vendor/maximebf/debugbar/src/DebugBar/Resources'; + } + $this->baseUrl = $baseUrl; + + if ($basePath === null) { + $basePath = __DIR__ . DIRECTORY_SEPARATOR . 'Resources'; + } + $this->basePath = $basePath; + + // bitwise operations cannot be done in class definition :( + $this->initialization = self::INITIALIZE_CONSTRUCTOR | self::INITIALIZE_CONTROLS; + } + + /** + * Sets options from an array + * + * Options: + * - base_path + * - base_url + * - include_vendors + * - javascript_class + * - variable_name + * - initialization + * - enable_jquery_noconflict + * - controls + * - disable_controls + * - ignore_collectors + * - ajax_handler_classname + * - ajax_handler_bind_to_jquery + * - open_handler_classname + * - open_handler_url + * + * @param array $options [description] + */ + public function setOptions(array $options) + { + if (array_key_exists('base_path', $options)) { + $this->setBasePath($options['base_path']); + } + if (array_key_exists('base_url', $options)) { + $this->setBaseUrl($options['base_url']); + } + if (array_key_exists('include_vendors', $options)) { + $this->setIncludeVendors($options['include_vendors']); + } + if (array_key_exists('javascript_class', $options)) { + $this->setJavascriptClass($options['javascript_class']); + } + if (array_key_exists('variable_name', $options)) { + $this->setVariableName($options['variable_name']); + } + if (array_key_exists('initialization', $options)) { + $this->setInitialization($options['initialization']); + } + if (array_key_exists('enable_jquery_noconflict', $options)) { + $this->setEnableJqueryNoConflict($options['enable_jquery_noconflict']); + } + if (array_key_exists('controls', $options)) { + foreach ($options['controls'] as $name => $control) { + $this->addControl($name, $control); + } + } + if (array_key_exists('disable_controls', $options)) { + foreach ((array) $options['disable_controls'] as $name) { + $this->disableControl($name); + } + } + if (array_key_exists('ignore_collectors', $options)) { + foreach ((array) $options['ignore_collectors'] as $name) { + $this->ignoreCollector($name); + } + } + if (array_key_exists('ajax_handler_classname', $options)) { + $this->setAjaxHandlerClass($options['ajax_handler_classname']); + } + if (array_key_exists('ajax_handler_bind_to_jquery', $options)) { + $this->setBindAjaxHandlerToJquery($options['ajax_handler_bind_to_jquery']); + } + if (array_key_exists('open_handler_classname', $options)) { + $this->setOpenHandlerClass($options['open_handler_classname']); + } + if (array_key_exists('open_handler_url', $options)) { + $this->setOpenHandlerUrl($options['open_handler_url']); + } + } + + /** + * Sets the path which assets are relative to + * + * @param string $path + */ + public function setBasePath($path) + { + $this->basePath = $path; + return $this; + } + + /** + * Returns the path which assets are relative to + * + * @return string + */ + public function getBasePath() + { + return $this->basePath; + } + + /** + * Sets the base URL from which assets will be served + * + * @param string $url + */ + public function setBaseUrl($url) + { + $this->baseUrl = $url; + return $this; + } + + /** + * Returns the base URL from which assets will be served + * + * @return string + */ + public function getBaseUrl() + { + return $this->baseUrl; + } + + /** + * Whether to include vendor assets + * + * You can only include js or css vendors using + * setIncludeVendors('css') or setIncludeVendors('js') + * + * @param boolean $enabled + */ + public function setIncludeVendors($enabled = true) + { + if (is_string($enabled)) { + $enabled = array($enabled); + } + $this->includeVendors = $enabled; + + if (!$enabled || (is_array($enabled) && !in_array('js', $enabled))) { + // no need to call jQuery.noConflict() if we do not include our own version + $this->enableJqueryNoConflict = false; + } + + return $this; + } + + /** + * Checks if vendors assets are included + * + * @return boolean + */ + public function areVendorsIncluded() + { + return $this->includeVendors !== false; + } + + /** + * Disable a specific vendor's assets. + * + * @param string $name "jquery", "fontawesome", "highlightjs" + * + * @return void + */ + public function disableVendor($name) + { + if (array_key_exists($name, $this->cssVendors)) { + unset($this->cssVendors[$name]); + } + if (array_key_exists($name, $this->jsVendors)) { + unset($this->jsVendors[$name]); + } + } + + /** + * Sets the javascript class name + * + * @param string $className + */ + public function setJavascriptClass($className) + { + $this->javascriptClass = $className; + return $this; + } + + /** + * Returns the javascript class name + * + * @return string + */ + public function getJavascriptClass() + { + return $this->javascriptClass; + } + + /** + * Sets the variable name of the class instance + * + * @param string $name + */ + public function setVariableName($name) + { + $this->variableName = $name; + return $this; + } + + /** + * Returns the variable name of the class instance + * + * @return string + */ + public function getVariableName() + { + return $this->variableName; + } + + /** + * Sets what should be initialized + * + * - INITIALIZE_CONSTRUCTOR: only initializes the instance + * - INITIALIZE_CONTROLS: initializes the controls and data mapping + * - INITIALIZE_CONSTRUCTOR | INITIALIZE_CONTROLS: initialize everything (default) + * + * @param integer $init + */ + public function setInitialization($init) + { + $this->initialization = $init; + return $this; + } + + /** + * Returns what should be initialized + * + * @return integer + */ + public function getInitialization() + { + return $this->initialization; + } + + /** + * Sets whether to call jQuery.noConflict() + * + * @param boolean $enabled + */ + public function setEnableJqueryNoConflict($enabled = true) + { + $this->enableJqueryNoConflict = $enabled; + return $this; + } + + /** + * Checks if jQuery.noConflict() will be called + * + * @return boolean + */ + public function isJqueryNoConflictEnabled() + { + return $this->enableJqueryNoConflict; + } + + /** + * Adds a control to initialize + * + * Possible options: + * - icon: icon name + * - tooltip: string + * - widget: widget class name + * - title: tab title + * - map: a property name from the data to map the control to + * - default: a js string, default value of the data map + * + * "icon" or "widget" are at least needed + * + * @param string $name + * @param array $options + */ + public function addControl($name, array $options) + { + if (count(array_intersect(array_keys($options), array('icon', 'widget', 'tab', 'indicator'))) === 0) { + throw new DebugBarException("Not enough options for control '$name'"); + } + $this->controls[$name] = $options; + return $this; + } + + /** + * Disables a control + * + * @param string $name + */ + public function disableControl($name) + { + $this->controls[$name] = null; + return $this; + } + + /** + * Returns the list of controls + * + * This does not include controls provided by collectors + * + * @return array + */ + public function getControls() + { + return $this->controls; + } + + /** + * Ignores widgets provided by a collector + * + * @param string $name + */ + public function ignoreCollector($name) + { + $this->ignoredCollectors[] = $name; + return $this; + } + + /** + * Returns the list of ignored collectors + * + * @return array + */ + public function getIgnoredCollectors() + { + return $this->ignoredCollectors; + } + + /** + * Sets the class name of the ajax handler + * + * Set to false to disable + * + * @param string $className + */ + public function setAjaxHandlerClass($className) + { + $this->ajaxHandlerClass = $className; + return $this; + } + + /** + * Returns the class name of the ajax handler + * + * @return string + */ + public function getAjaxHandlerClass() + { + return $this->ajaxHandlerClass; + } + + /** + * Sets whether to call bindToJquery() on the ajax handler + * + * @param boolean $bind + */ + public function setBindAjaxHandlerToJquery($bind = true) + { + $this->ajaxHandlerBindToJquery = $bind; + return $this; + } + + /** + * Checks whether bindToJquery() will be called on the ajax handler + * + * @return boolean + */ + public function isAjaxHandlerBoundToJquery() + { + return $this->ajaxHandlerBindToJquery; + } + + /** + * Sets whether to call bindToXHR() on the ajax handler + * + * @param boolean $bind + */ + public function setBindAjaxHandlerToXHR($bind = true) + { + $this->ajaxHandlerBindToXHR = $bind; + return $this; + } + + /** + * Checks whether bindToXHR() will be called on the ajax handler + * + * @return boolean + */ + public function isAjaxHandlerBoundToXHR() + { + return $this->ajaxHandlerBindToXHR; + } + + /** + * Sets the class name of the js open handler + * + * @param string $className + */ + public function setOpenHandlerClass($className) + { + $this->openHandlerClass = $className; + return $this; + } + + /** + * Returns the class name of the js open handler + * + * @return string + */ + public function getOpenHandlerClass() + { + return $this->openHandlerClass; + } + + /** + * Sets the url of the open handler + * + * @param string $url + */ + public function setOpenHandlerUrl($url) + { + $this->openHandlerUrl = $url; + return $this; + } + + /** + * Returns the url for the open handler + * + * @return string + */ + public function getOpenHandlerUrl() + { + return $this->openHandlerUrl; + } + + /** + * Add assets to render in the head + * + * @param array $cssFiles An array of filenames + * @param array $jsFiles An array of filenames + * @param string $basePath Base path of those files + * @param string $baseUrl Base url of those files + */ + public function addAssets($cssFiles, $jsFiles, $basePath = null, $baseUrl = null) + { + $this->additionalAssets[] = array( + 'base_path' => $basePath, + 'base_url' => $baseUrl, + 'css' => (array) $cssFiles, + 'js' => (array) $jsFiles + ); + return $this; + } + + /** + * Returns the list of asset files + * + * @param string $type Only return css or js files + * @param string $relativeTo The type of path to which filenames must be relative (path, url or null) + * @return array + */ + public function getAssets($type = null, $relativeTo = self::RELATIVE_PATH) + { + $cssFiles = $this->cssFiles; + $jsFiles = $this->jsFiles; + + if ($this->includeVendors !== false) { + if ($this->includeVendors === true || in_array('css', $this->includeVendors)) { + $cssFiles = array_merge($this->cssVendors, $cssFiles); + } + if ($this->includeVendors === true || in_array('js', $this->includeVendors)) { + $jsFiles = array_merge($this->jsVendors, $jsFiles); + } + } + + if ($relativeTo) { + $root = $this->getRelativeRoot($relativeTo, $this->basePath, $this->baseUrl); + $cssFiles = $this->makeUriRelativeTo($cssFiles, $root); + $jsFiles = $this->makeUriRelativeTo($jsFiles, $root); + } + + $additionalAssets = $this->additionalAssets; + // finds assets provided by collectors + foreach ($this->debugBar->getCollectors() as $collector) { + if (($collector instanceof AssetProvider) && !in_array($collector->getName(), $this->ignoredCollectors)) { + $additionalAssets[] = $collector->getAssets(); + } + } + + foreach ($additionalAssets as $assets) { + $basePath = isset($assets['base_path']) ? $assets['base_path'] : null; + $baseUrl = isset($assets['base_url']) ? $assets['base_url'] : null; + $root = $this->getRelativeRoot($relativeTo, + $this->makeUriRelativeTo($basePath, $this->basePath), + $this->makeUriRelativeTo($baseUrl, $this->baseUrl)); + $cssFiles = array_merge($cssFiles, $this->makeUriRelativeTo((array) $assets['css'], $root)); + $jsFiles = array_merge($jsFiles, $this->makeUriRelativeTo((array) $assets['js'], $root)); + } + + return $this->filterAssetArray(array($cssFiles, $jsFiles), $type); + } + + /** + * Returns the correct base according to the type + * + * @param string $relativeTo + * @param string $basePath + * @param string $baseUrl + * @return string + */ + protected function getRelativeRoot($relativeTo, $basePath, $baseUrl) + { + if ($relativeTo === self::RELATIVE_PATH) { + return $basePath; + } + if ($relativeTo === self::RELATIVE_URL) { + return $baseUrl; + } + return null; + } + + /** + * Makes a URI relative to another + * + * @param string|array $uri + * @param string $root + * @return string + */ + protected function makeUriRelativeTo($uri, $root) + { + if (!$root) { + return $uri; + } + + if (is_array($uri)) { + $uris = array(); + foreach ($uri as $u) { + $uris[] = $this->makeUriRelativeTo($u, $root); + } + return $uris; + } + + if (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri)) { + return $uri; + } + return rtrim($root, '/') . "/$uri"; + } + + /** + * Filters a tuple of (css, js) assets according to $type + * + * @param array $array + * @param string $type 'css', 'js' or null for both + * @return array + */ + protected function filterAssetArray($array, $type = null) + { + $type = strtolower($type); + if ($type === 'css') { + return $array[0]; + } + if ($type === 'js') { + return $array[1]; + } + return $array; + } + + /** + * Returns a tuple where the both items are Assetic AssetCollection, + * the first one being css files and the second js files + * + * @param string $type Only return css or js collection + * @return array or \Assetic\Asset\AssetCollection + */ + public function getAsseticCollection($type = null) + { + list($cssFiles, $jsFiles) = $this->getAssets(); + return $this->filterAssetArray(array( + $this->createAsseticCollection($cssFiles), + $this->createAsseticCollection($jsFiles) + ), $type); + } + + /** + * Create an Assetic AssetCollection with the given files. + * Filenames will be converted to absolute path using + * the base path. + * + * @param array $files + * @return \Assetic\Asset\AssetCollection + */ + protected function createAsseticCollection($files) + { + $assets = array(); + foreach ($files as $file) { + $assets[] = new \Assetic\Asset\FileAsset($file); + } + return new \Assetic\Asset\AssetCollection($assets); + } + + /** + * Write all CSS assets to standard output or in a file + * + * @param string $targetFilename + */ + public function dumpCssAssets($targetFilename = null) + { + $this->dumpAssets($this->getAssets('css'), $targetFilename); + } + + /** + * Write all JS assets to standard output or in a file + * + * @param string $targetFilename + */ + public function dumpJsAssets($targetFilename = null) + { + $this->dumpAssets($this->getAssets('js'), $targetFilename); + } + + /** + * Write assets to standard output or in a file + * + * @param array $files + * @param string $targetFilename + */ + protected function dumpAssets($files, $targetFilename = null) + { + $content = ''; + foreach ($files as $file) { + $content .= file_get_contents($file) . "\n"; + } + if ($targetFilename !== null) { + file_put_contents($targetFilename, $content); + } else { + echo $content; + } + } + + /** + * Renders the html to include needed assets + * + * Only useful if Assetic is not used + * + * @return string + */ + public function renderHead() + { + list($cssFiles, $jsFiles) = $this->getAssets(null, self::RELATIVE_URL); + $html = ''; + + foreach ($cssFiles as $file) { + $html .= sprintf('' . "\n", $file); + } + + foreach ($jsFiles as $file) { + $html .= sprintf('' . "\n", $file); + } + + if ($this->enableJqueryNoConflict) { + $html .= '' . "\n"; + } + + return $html; + } + + /** + * Register shutdown to display the debug bar + * + * @param boolean $here Set position of HTML. True if is to current position or false for end file + * @param boolean $initialize Whether to render the de bug bar initialization code + * @return string Return "{--DEBUGBAR_OB_START_REPLACE_ME--}" or return an empty string if $here == false + */ + public function renderOnShutdown($here = true, $initialize = true, $renderStackedData = true, $head = false) + { + register_shutdown_function(array($this, "replaceTagInBuffer"), $here, $initialize, $renderStackedData, $head); + + if (ob_get_level() === 0) { + ob_start(); + } + + return ($here) ? self::REPLACEABLE_TAG : ""; + } + + /** + * Same as renderOnShutdown() with $head = true + * + * @param boolean $here + * @param boolean $initialize + * @param boolean $renderStackedData + * @return string + */ + public function renderOnShutdownWithHead($here = true, $initialize = true, $renderStackedData = true) + { + return $this->renderOnShutdown($here, $initialize, $renderStackedData, true); + } + + /** + * Is callback function for register_shutdown_function(...) + * + * @param boolean $here Set position of HTML. True if is to current position or false for end file + * @param boolean $initialize Whether to render the de bug bar initialization code + */ + public function replaceTagInBuffer($here = true, $initialize = true, $renderStackedData = true, $head = false) + { + $render = ($head ? $this->renderHead() : "") + . $this->render($initialize, $renderStackedData); + + $current = ($here && ob_get_level() > 0) ? ob_get_clean() : self::REPLACEABLE_TAG; + + echo str_replace(self::REPLACEABLE_TAG, $render, $current, $count); + + if ($count === 0) { + echo $render; + } + } + + /** + * Returns the code needed to display the debug bar + * + * AJAX request should not render the initialization code. + * + * @param boolean $initialize Whether to render the de bug bar initialization code + * @return string + */ + public function render($initialize = true, $renderStackedData = true) + { + $js = ''; + + if ($initialize) { + $js = $this->getJsInitializationCode(); + } + + if ($renderStackedData && $this->debugBar->hasStackedData()) { + foreach ($this->debugBar->getStackedData() as $id => $data) { + $js .= $this->getAddDatasetCode($id, $data, '(stacked)'); + } + } + + $suffix = !$initialize ? '(ajax)' : null; + $js .= $this->getAddDatasetCode($this->debugBar->getCurrentRequestId(), $this->debugBar->getData(), $suffix); + + return "\n"; + } + + /** + * Returns the js code needed to initialize the debug bar + * + * @return string + */ + protected function getJsInitializationCode() + { + $js = ''; + + if (($this->initialization & self::INITIALIZE_CONSTRUCTOR) === self::INITIALIZE_CONSTRUCTOR) { + $js .= sprintf("var %s = new %s();\n", $this->variableName, $this->javascriptClass); + } + + if (($this->initialization & self::INITIALIZE_CONTROLS) === self::INITIALIZE_CONTROLS) { + $js .= $this->getJsControlsDefinitionCode($this->variableName); + } + + if ($this->ajaxHandlerClass) { + $js .= sprintf("%s.ajaxHandler = new %s(%s);\n", $this->variableName, $this->ajaxHandlerClass, $this->variableName); + if ($this->ajaxHandlerBindToXHR) { + $js .= sprintf("%s.ajaxHandler.bindToXHR();\n", $this->variableName); + } elseif ($this->ajaxHandlerBindToJquery) { + $js .= sprintf("if (jQuery) %s.ajaxHandler.bindToJquery(jQuery);\n", $this->variableName); + } + } + + if ($this->openHandlerUrl !== null) { + $js .= sprintf("%s.setOpenHandler(new %s(%s));\n", $this->variableName, + $this->openHandlerClass, + json_encode(array("url" => $this->openHandlerUrl))); + } + + return $js; + } + + /** + * Returns the js code needed to initialized the controls and data mapping of the debug bar + * + * Controls can be defined by collectors themselves or using {@see addControl()} + * + * @param string $varname Debug bar's variable name + * @return string + */ + protected function getJsControlsDefinitionCode($varname) + { + $js = ''; + $dataMap = array(); + $excludedOptions = array('indicator', 'tab', 'map', 'default', 'widget', 'position'); + + // finds controls provided by collectors + $widgets = array(); + foreach ($this->debugBar->getCollectors() as $collector) { + if (($collector instanceof Renderable) && !in_array($collector->getName(), $this->ignoredCollectors)) { + if ($w = $collector->getWidgets()) { + $widgets = array_merge($widgets, $w); + } + } + } + $controls = array_merge($widgets, $this->controls); + + foreach (array_filter($controls) as $name => $options) { + $opts = array_diff_key($options, array_flip($excludedOptions)); + + if (isset($options['tab']) || isset($options['widget'])) { + if (!isset($opts['title'])) { + $opts['title'] = ucfirst(str_replace('_', ' ', $name)); + } + $js .= sprintf("%s.addTab(\"%s\", new %s({%s%s}));\n", + $varname, + $name, + isset($options['tab']) ? $options['tab'] : 'PhpDebugBar.DebugBar.Tab', + substr(json_encode($opts, JSON_FORCE_OBJECT), 1, -1), + isset($options['widget']) ? sprintf('%s"widget": new %s()', count($opts) ? ', ' : '', $options['widget']) : '' + ); + } elseif (isset($options['indicator']) || isset($options['icon'])) { + $js .= sprintf("%s.addIndicator(\"%s\", new %s(%s), \"%s\");\n", + $varname, + $name, + isset($options['indicator']) ? $options['indicator'] : 'PhpDebugBar.DebugBar.Indicator', + json_encode($opts, JSON_FORCE_OBJECT), + isset($options['position']) ? $options['position'] : 'right' + ); + } + + if (isset($options['map']) && isset($options['default'])) { + $dataMap[$name] = array($options['map'], $options['default']); + } + } + + // creates the data mapping object + $mapJson = array(); + foreach ($dataMap as $name => $values) { + $mapJson[] = sprintf('"%s": ["%s", %s]', $name, $values[0], $values[1]); + } + $js .= sprintf("%s.setDataMap({\n%s\n});\n", $varname, implode(",\n", $mapJson)); + + // activate state restoration + $js .= sprintf("%s.restoreState();\n", $varname); + + return $js; + } + + /** + * Returns the js code needed to add a dataset + * + * @param string $requestId + * @param array $data + * @return string + */ + protected function getAddDatasetCode($requestId, $data, $suffix = null) + { + $js = sprintf("%s.addDataSet(%s, \"%s\"%s);\n", + $this->variableName, + json_encode($data), + $requestId, + $suffix ? ", " . json_encode($suffix) : '' + ); + return $js; + } +} diff --git a/htdocs/includes/DebugBar/OpenHandler.php b/htdocs/includes/DebugBar/OpenHandler.php new file mode 100644 index 00000000000..cbabea268ae --- /dev/null +++ b/htdocs/includes/DebugBar/OpenHandler.php @@ -0,0 +1,107 @@ +isDataPersisted()) { + throw new DebugBarException("DebugBar must have a storage backend to use OpenHandler"); + } + $this->debugBar = $debugBar; + } + + /** + * Handles the current request + * + * @param array $request Request data + */ + public function handle($request = null, $echo = true, $sendHeader = true) + { + if ($request === null) { + $request = $_REQUEST; + } + + $op = 'find'; + if (isset($request['op'])) { + $op = $request['op']; + if (!in_array($op, array('find', 'get', 'clear'))) { + throw new DebugBarException("Invalid operation '{$request['op']}'"); + } + } + + if ($sendHeader) { + $this->debugBar->getHttpDriver()->setHeaders(array( + 'Content-Type' => 'application/json' + )); + } + + $response = json_encode(call_user_func(array($this, $op), $request)); + if ($echo) { + echo $response; + } + return $response; + } + + /** + * Find operation + */ + protected function find($request) + { + $max = 20; + if (isset($request['max'])) { + $max = $request['max']; + } + + $offset = 0; + if (isset($request['offset'])) { + $offset = $request['offset']; + } + + $filters = array(); + foreach (array('utime', 'datetime', 'ip', 'uri', 'method') as $key) { + if (isset($request[$key])) { + $filters[$key] = $request[$key]; + } + } + + return $this->debugBar->getStorage()->find($filters, $max, $offset); + } + + /** + * Get operation + */ + protected function get($request) + { + if (!isset($request['id'])) { + throw new DebugBarException("Missing 'id' parameter in 'get' operation"); + } + return $this->debugBar->getStorage()->get($request['id']); + } + + /** + * Clear operation + */ + protected function clear($request) + { + $this->debugBar->getStorage()->clear(); + return array('success' => true); + } +} diff --git a/htdocs/includes/DebugBar/PhpHttpDriver.php b/htdocs/includes/DebugBar/PhpHttpDriver.php new file mode 100644 index 00000000000..af07060d279 --- /dev/null +++ b/htdocs/includes/DebugBar/PhpHttpDriver.php @@ -0,0 +1,49 @@ + $value) { + header("$name: $value"); + } + } + + function isSessionStarted() + { + return isset($_SESSION); + } + + function setSessionValue($name, $value) + { + $_SESSION[$name] = $value; + } + + function hasSessionValue($name) + { + return array_key_exists($name, $_SESSION); + } + + function getSessionValue($name) + { + return $_SESSION[$name]; + } + + function deleteSessionValue($name) + { + unset($_SESSION[$name]); + } +} diff --git a/htdocs/includes/DebugBar/RequestIdGenerator.php b/htdocs/includes/DebugBar/RequestIdGenerator.php new file mode 100644 index 00000000000..934f407ff8f --- /dev/null +++ b/htdocs/includes/DebugBar/RequestIdGenerator.php @@ -0,0 +1,22 @@ + div > * { + padding: 10px 10px; + font-size: 14px; + color: #555; + text-decoration: none; + outline: none; +} +div.phpdebugbar-header-left > * { + float: left; +} +div.phpdebugbar-header-right > * { + float: right; +} +div.phpdebugbar-header-right > select { + padding: 0; +} + +/* -------------------------------------- */ + +span.phpdebugbar-indicator, +a.phpdebugbar-indicator, +a.phpdebugbar-close-btn { + border-right: 1px solid #ddd; +} + +a.phpdebugbar-tab.phpdebugbar-active { + background: #3d6c99; + color: #fff; +} + +a.phpdebugbar-tab.phpdebugbar-active span.phpdebugbar-badge { + background: #fff; + color: #3d6c99; +} + + a.phpdebugbar-tab span.phpdebugbar-badge { + display: none; + margin-left: 5px; + float: right; + font-size: 11px; + line-height: 14px; + padding: 1px 7px; + background: #3d6c99; + border-radius: 4px; + color: #fff; + font-weight: normal; + text-shadow: none; + vertical-align: middle; + } + a.phpdebugbar-tab i { + display: none; + vertical-align: middle; + } + a.phpdebugbar-tab span.phpdebugbar-badge.phpdebugbar-important { + background: #ed6868; + color: white; + } + +a.phpdebugbar-close-btn, a.phpdebugbar-open-btn, a.phpdebugbar-minimize-btn , a.phpdebugbar-maximize-btn { + width: 16px; + height: 16px; +} + +a.phpdebugbar-restore-btn { + width: 26px; + height: 16px; +} + +a.phpdebugbar-minimize-btn , a.phpdebugbar-maximize-btn { + padding-right: 0px !important; +} + +a.phpdebugbar-maximize-btn { display: none} + +a.phpdebugbar-minimize-btn { display: block} + +div.phpdebugbar-minimized a.phpdebugbar-maximize-btn { display: block} + +div.phpdebugbar-minimized a.phpdebugbar-minimize-btn { display: none} + +a.phpdebugbar-minimize-btn { + background: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201792%201792%22%20id%3D%22chevron-down%22%3E%3Cpath%20d%3D%22M1683%20808l-742%20741q-19%2019-45%2019t-45-19l-742-741q-19-19-19-45.5t19-45.5l166-165q19-19%2045-19t45%2019l531%20531%20531-531q19-19%2045-19t45%2019l166%20165q19%2019%2019%2045.5t-19%2045.5z%22%2F%3E%3C%2Fsvg%3E) no-repeat 10px 10px / 14px 14px; +} + +a.phpdebugbar-maximize-btn { + background: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201792%201792%22%20id%3D%22chevron-up%22%3E%3Cpath%20d%3D%22M1683%201331l-166%20165q-19%2019-45%2019t-45-19l-531-531-531%20531q-19%2019-45%2019t-45-19l-166-165q-19-19-19-45.5t19-45.5l742-741q19-19%2045-19t45%2019l742%20741q19%2019%2019%2045.5t-19%2045.5z%22%2F%3E%3C%2Fsvg%3E) no-repeat 10px 10px / 14px 14px; +} + +a.phpdebugbar-close-btn { + background: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201792%201792%22%20id%3D%22close%22%3E%3Cpath%20d%3D%22M1490%201322q0%2040-28%2068l-136%20136q-28%2028-68%2028t-68-28l-294-294-294%20294q-28%2028-68%2028t-68-28l-136-136q-28-28-28-68t28-68l294-294-294-294q-28-28-28-68t28-68l136-136q28-28%2068-28t68%2028l294%20294%20294-294q28-28%2068-28t68%2028l136%20136q28%2028%2028%2068t-28%2068l-294%20294%20294%20294q28%2028%2028%2068z%22%2F%3E%3C%2Fsvg%3E) no-repeat 10px 10px / 14px 14px; +} + +a.phpdebugbar-open-btn { + background: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201792%201792%22%20id%3D%22folder-open%22%3E%3Cpath%20d%3D%22M1815%20952q0%2031-31%2066l-336%20396q-43%2051-120.5%2086.5t-143.5%2035.5h-1088q-34%200-60.5-13t-26.5-43q0-31%2031-66l336-396q43-51%20120.5-86.5t143.5-35.5h1088q34%200%2060.5%2013t26.5%2043zm-343-344v160h-832q-94%200-197%2047.5t-164%20119.5l-337%20396-5%206q0-4-.5-12.5t-.5-12.5v-960q0-92%2066-158t158-66h320q92%200%20158%2066t66%20158v32h544q92%200%20158%2066t66%20158z%22%2F%3E%3C%2Fsvg%3E) no-repeat 10px 10px / 14px 14px; +} + +.phpdebugbar-indicator { + position: relative; + cursor: pointer; +} + .phpdebugbar-indicator span.phpdebugbar-text { + margin-left: 5px; + } + .phpdebugbar-indicator span.phpdebugbar-tooltip { + display: none; + position: absolute; + bottom: 45px; + background: #efefef; + border: 1px solid #ccc; + color: #555; + font-size: 11px; + padding: 2px 3px; + z-index: 1000; + text-align: center; + width: 200%; + right: 0; + } + .phpdebugbar-indicator:hover span.phpdebugbar-tooltip:not(.phpdebugbar-disabled) { + display: block; + } + .phpdebugbar-indicator span.phpdebugbar-tooltip-wide { + width: 300%; + } + .phpdebugbar-indicator span.phpdebugbar-tooltip-extra-wide { + width: 400%; + } + .phpdebugbar-indicator span.phpdebugbar-tooltip-html { + display: inline-block; + text-align: left; + } + +select.phpdebugbar-datasets-switcher { + float: right; + display: none; + margin: 8px 0 0 7px; + max-width: 200px; + max-height: 23px; + padding: 0; +} + +/* -------------------------------------- */ + +div.phpdebugbar-body { + border-top: 1px solid #ccc; + display: none; + position: relative; + height: 300px; +} + +/* -------------------------------------- */ + +div.phpdebugbar-panel { + display: none; + height: 100%; + overflow: auto; + width: 100%; +} +div.phpdebugbar-panel.phpdebugbar-active { + display: block; +} + +/* -------------------------------------- */ + +div.phpdebugbar-mini-design a.phpdebugbar-tab { + position: relative; + border-right: 1px solid #ddd; +} + div.phpdebugbar-mini-design a.phpdebugbar-tab span.phpdebugbar-text { + display: none; + } + div.phpdebugbar-mini-design a.phpdebugbar-tab:hover span.phpdebugbar-text { + display: block; + position: absolute; + top: -30px; + background: #efefef; + opacity: .7; + border: 1px solid #ccc; + color: #555; + font-size: 11px; + padding: 2px 3px; + z-index: 1000; + text-align: center; + right: 0; + } + div.phpdebugbar-mini-design a.phpdebugbar-tab i { + display:inline-block; + } diff --git a/htdocs/includes/DebugBar/Resources/debugbar.js b/htdocs/includes/DebugBar/Resources/debugbar.js new file mode 100644 index 00000000000..faf567e37c1 --- /dev/null +++ b/htdocs/includes/DebugBar/Resources/debugbar.js @@ -0,0 +1,1161 @@ +if (typeof(PhpDebugBar) == 'undefined') { + // namespace + var PhpDebugBar = {}; + PhpDebugBar.$ = jQuery; +} + +(function($) { + + if (typeof(localStorage) == 'undefined') { + // provide mock localStorage object for dumb browsers + localStorage = { + setItem: function(key, value) {}, + getItem: function(key) { return null; } + }; + } + + if (typeof(PhpDebugBar.utils) == 'undefined') { + PhpDebugBar.utils = {}; + } + + /** + * Returns the value from an object property. + * Using dots in the key, it is possible to retrieve nested property values + * + * @param {Object} dict + * @param {String} key + * @param {Object} default_value + * @return {Object} + */ + var getDictValue = PhpDebugBar.utils.getDictValue = function(dict, key, default_value) { + var d = dict, parts = key.split('.'); + for (var i = 0; i < parts.length; i++) { + if (!d[parts[i]]) { + return default_value; + } + d = d[parts[i]]; + } + return d; + } + + /** + * Counts the number of properties in an object + * + * @param {Object} obj + * @return {Integer} + */ + var getObjectSize = PhpDebugBar.utils.getObjectSize = function(obj) { + if (Object.keys) { + return Object.keys(obj).length; + } + var count = 0; + for (var k in obj) { + if (obj.hasOwnProperty(k)) { + count++; + } + } + return count; + } + + /** + * Returns a prefixed css class name + * + * @param {String} cls + * @return {String} + */ + PhpDebugBar.utils.csscls = function(cls, prefix) { + if (cls.indexOf(' ') > -1) { + var clss = cls.split(' '), out = []; + for (var i = 0, c = clss.length; i < c; i++) { + out.push(PhpDebugBar.utils.csscls(clss[i], prefix)); + } + return out.join(' '); + } + if (cls.indexOf('.') === 0) { + return '.' + prefix + cls.substr(1); + } + return prefix + cls; + }; + + /** + * Creates a partial function of csscls where the second + * argument is already defined + * + * @param {string} prefix + * @return {Function} + */ + PhpDebugBar.utils.makecsscls = function(prefix) { + var f = function(cls) { + return PhpDebugBar.utils.csscls(cls, prefix); + }; + return f; + } + + var csscls = PhpDebugBar.utils.makecsscls('phpdebugbar-'); + + + // ------------------------------------------------------------------ + + /** + * Base class for all elements with a visual component + * + * @param {Object} options + * @constructor + */ + var Widget = PhpDebugBar.Widget = function(options) { + this._attributes = $.extend({}, this.defaults); + this._boundAttributes = {}; + this.$el = $('<' + this.tagName + ' />'); + if (this.className) { + this.$el.addClass(this.className); + } + this.initialize.apply(this, [options || {}]); + this.render.apply(this); + }; + + $.extend(Widget.prototype, { + + tagName: 'div', + + className: null, + + defaults: {}, + + /** + * Called after the constructor + * + * @param {Object} options + */ + initialize: function(options) { + this.set(options); + }, + + /** + * Called after the constructor to render the element + */ + render: function() {}, + + /** + * Sets the value of an attribute + * + * @param {String} attr Can also be an object to set multiple attributes at once + * @param {Object} value + */ + set: function(attr, value) { + if (typeof(attr) != 'string') { + for (var k in attr) { + this.set(k, attr[k]); + } + return; + } + + this._attributes[attr] = value; + if (typeof(this._boundAttributes[attr]) !== 'undefined') { + for (var i = 0, c = this._boundAttributes[attr].length; i < c; i++) { + this._boundAttributes[attr][i].apply(this, [value]); + } + } + }, + + /** + * Checks if an attribute exists and is not null + * + * @param {String} attr + * @return {[type]} [description] + */ + has: function(attr) { + return typeof(this._attributes[attr]) !== 'undefined' && this._attributes[attr] !== null; + }, + + /** + * Returns the value of an attribute + * + * @param {String} attr + * @return {Object} + */ + get: function(attr) { + return this._attributes[attr]; + }, + + /** + * Registers a callback function that will be called whenever the value of the attribute changes + * + * If cb is a jQuery element, text() will be used to fill the element + * + * @param {String} attr + * @param {Function} cb + */ + bindAttr: function(attr, cb) { + if ($.isArray(attr)) { + for (var i = 0, c = attr.length; i < c; i++) { + this.bindAttr(attr[i], cb); + } + return; + } + + if (typeof(this._boundAttributes[attr]) == 'undefined') { + this._boundAttributes[attr] = []; + } + if (typeof(cb) == 'object') { + var el = cb; + cb = function(value) { el.text(value || ''); }; + } + this._boundAttributes[attr].push(cb); + if (this.has(attr)) { + cb.apply(this, [this._attributes[attr]]); + } + } + + }); + + + /** + * Creates a subclass + * + * Code from Backbone.js + * + * @param {Array} props Prototype properties + * @return {Function} + */ + Widget.extend = function(props) { + var parent = this; + + var child = function() { return parent.apply(this, arguments); }; + $.extend(child, parent); + + var Surrogate = function(){ this.constructor = child; }; + Surrogate.prototype = parent.prototype; + child.prototype = new Surrogate; + $.extend(child.prototype, props); + + child.__super__ = parent.prototype; + + return child; + }; + + // ------------------------------------------------------------------ + + /** + * Tab + * + * A tab is composed of a tab label which is always visible and + * a tab panel which is visible only when the tab is active. + * + * The panel must contain a widget. A widget is an object which has + * an element property containing something appendable to a jQuery object. + * + * Options: + * - title + * - badge + * - widget + * - data: forward data to widget data + */ + var Tab = Widget.extend({ + + className: csscls('panel'), + + render: function() { + this.$tab = $('').addClass(csscls('tab')); + + this.$icon = $('').appendTo(this.$tab); + this.bindAttr('icon', function(icon) { + if (icon) { + this.$icon.attr('class', 'fa fa-' + icon); + } else { + this.$icon.attr('class', ''); + } + }); + + this.bindAttr('title', $('').addClass(csscls('text')).appendTo(this.$tab)); + + this.$badge = $('').addClass(csscls('badge')).appendTo(this.$tab); + this.bindAttr('badge', function(value) { + if (value !== null) { + this.$badge.text(value); + this.$badge.show(); + } else { + this.$badge.hide(); + } + }); + + this.bindAttr('widget', function(widget) { + this.$el.empty().append(widget.$el); + }); + + this.bindAttr('data', function(data) { + if (this.has('widget')) { + this.get('widget').set('data', data); + } + }) + } + + }); + + // ------------------------------------------------------------------ + + /** + * Indicator + * + * An indicator is a text and an icon to display single value information + * right inside the always visible part of the debug bar + * + * Options: + * - icon + * - title + * - tooltip + * - data: alias of title + */ + var Indicator = Widget.extend({ + + tagName: 'span', + + className: csscls('indicator'), + + render: function() { + this.$icon = $('').appendTo(this.$el); + this.bindAttr('icon', function(icon) { + if (icon) { + this.$icon.attr('class', 'fa fa-' + icon); + } else { + this.$icon.attr('class', ''); + } + }); + + this.bindAttr(['title', 'data'], $('').addClass(csscls('text')).appendTo(this.$el)); + + this.$tooltip = $('').addClass(csscls('tooltip disabled')).appendTo(this.$el); + this.bindAttr('tooltip', function(tooltip) { + if (tooltip) { + this.$tooltip.text(tooltip).removeClass(csscls('disabled')); + } else { + this.$tooltip.addClass(csscls('disabled')); + } + }); + } + + }); + + // ------------------------------------------------------------------ + + /** + * Dataset title formater + * + * Formats the title of a dataset for the select box + */ + var DatasetTitleFormater = PhpDebugBar.DatasetTitleFormater = function(debugbar) { + this.debugbar = debugbar; + }; + + $.extend(DatasetTitleFormater.prototype, { + + /** + * Formats the title of a dataset + * + * @this {DatasetTitleFormater} + * @param {String} id + * @param {Object} data + * @param {String} suffix + * @return {String} + */ + format: function(id, data, suffix) { + if (suffix) { + suffix = ' ' + suffix; + } else { + suffix = ''; + } + + var nb = getObjectSize(this.debugbar.datasets) + 1; + + if (typeof(data['__meta']) === 'undefined') { + return "#" + nb + suffix; + } + + var uri = data['__meta']['uri'], filename; + if (uri.length && uri.charAt(uri.length - 1) === '/') { + // URI ends in a trailing /: get the portion before then to avoid returning an empty string + filename = uri.substr(0, uri.length - 1); // strip trailing '/' + filename = filename.substr(filename.lastIndexOf('/') + 1); // get last path segment + filename += '/'; // add the trailing '/' back + } else { + filename = uri.substr(uri.lastIndexOf('/') + 1); + } + + // truncate the filename in the label, if it's too long + var maxLength = 150; + if (filename.length > maxLength) { + filename = filename.substr(0, maxLength) + '...'; + } + + var label = "#" + nb + " " + filename + suffix + ' (' + data['__meta']['datetime'].split(' ')[1] + ')'; + return label; + } + + }); + + // ------------------------------------------------------------------ + + + /** + * DebugBar + * + * Creates a bar that appends itself to the body of your page + * and sticks to the bottom. + * + * The bar can be customized by adding tabs and indicators. + * A data map is used to fill those controls with data provided + * from datasets. + */ + var DebugBar = PhpDebugBar.DebugBar = Widget.extend({ + + className: "phpdebugbar " + csscls('minimized'), + + options: { + bodyMarginBottom: true, + bodyMarginBottomHeight: parseInt($('body').css('margin-bottom')) + }, + + initialize: function() { + this.controls = {}; + this.dataMap = {}; + this.datasets = {}; + this.firstTabName = null; + this.activePanelName = null; + this.datesetTitleFormater = new DatasetTitleFormater(this); + this.registerResizeHandler(); + }, + + /** + * Register resize event, for resize debugbar with reponsive css. + * + * @this {DebugBar} + */ + registerResizeHandler: function() { + if (typeof this.resize.bind == 'undefined') return; + + var f = this.resize.bind(this); + this.respCSSSize = 0; + $(window).resize(f); + setTimeout(f, 20); + }, + + /** + * Resizes the debugbar to fit the current browser window + */ + resize: function() { + var contentSize = this.respCSSSize; + if (this.respCSSSize == 0) { + this.$header.find("> div > *:visible").each(function () { + contentSize += $(this).outerWidth(); + }); + } + + var currentSize = this.$header.width(); + var cssClass = "phpdebugbar-mini-design"; + var bool = this.$header.hasClass(cssClass); + + if (currentSize <= contentSize && !bool) { + this.respCSSSize = contentSize; + this.$header.addClass(cssClass); + } else if (contentSize < currentSize && bool) { + this.respCSSSize = 0; + this.$header.removeClass(cssClass); + } + + // Reset height to ensure bar is still visible + this.setHeight(this.$body.height()); + }, + + /** + * Initialiazes the UI + * + * @this {DebugBar} + */ + render: function() { + var self = this; + this.$el.appendTo('body'); + this.$dragCapture = $('
    ').addClass(csscls('drag-capture')).appendTo(this.$el); + this.$resizehdle = $('
    ').addClass(csscls('resize-handle')).appendTo(this.$el); + this.$header = $('
    ').addClass(csscls('header')).appendTo(this.$el); + this.$headerLeft = $('
    ').addClass(csscls('header-left')).appendTo(this.$header); + this.$headerRight = $('
    ').addClass(csscls('header-right')).appendTo(this.$header); + var $body = this.$body = $('
    ').addClass(csscls('body')).appendTo(this.$el); + this.recomputeBottomOffset(); + + // dragging of resize handle + var pos_y, orig_h; + this.$resizehdle.on('mousedown', function(e) { + orig_h = $body.height(), pos_y = e.pageY; + $body.parents().on('mousemove', mousemove).on('mouseup', mouseup); + self.$dragCapture.show(); + e.preventDefault(); + }); + var mousemove = function(e) { + var h = orig_h + (pos_y - e.pageY); + self.setHeight(h); + }; + var mouseup = function() { + $body.parents().off('mousemove', mousemove).off('mouseup', mouseup); + self.$dragCapture.hide(); + }; + + // close button + this.$closebtn = $('').addClass(csscls('close-btn')).appendTo(this.$headerRight); + this.$closebtn.click(function() { + self.close(); + }); + + // minimize button + this.$minimizebtn = $('').addClass(csscls('minimize-btn') ).appendTo(this.$headerRight); + this.$minimizebtn.click(function() { + self.minimize(); + }); + + // maximize button + this.$maximizebtn = $('').addClass(csscls('maximize-btn') ).appendTo(this.$headerRight); + this.$maximizebtn.click(function() { + self.restore(); + }); + + // restore button + this.$restorebtn = $('').addClass(csscls('restore-btn')).hide().appendTo(this.$el); + this.$restorebtn.click(function() { + self.restore(); + }); + + // open button + this.$openbtn = $('').addClass(csscls('open-btn')).appendTo(this.$headerRight).hide(); + this.$openbtn.click(function() { + self.openHandler.show(function(id, dataset) { + self.addDataSet(dataset, id, "(opened)"); + self.showTab(); + }); + }); + + // select box for data sets + this.$datasets = $('
    '); + $('
    PHP DebugBar | Open
    ').addClass(csscls('header')).append(this.$closebtn).appendTo(this.$el); + $('
    '; +print ' - - + - - + + Date: Thu, 14 Mar 2019 19:17:00 +0100 Subject: [PATCH 091/179] update with html5 compliant code --- htdocs/expensereport/card.php | 104 +++++++++++++++++----------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index c6d87acef4d..922d493864a 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1892,9 +1892,9 @@ else print ''; print ''; if (! empty($conf->banque->enabled)) { - print ''; + print ''; } - print ''; + print ''; print ''; print ''; @@ -1948,12 +1948,12 @@ else $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } - print ''; } - print '"; + print '"; print ''; print ""; $totalpaid += $objp->amount; @@ -1975,10 +1975,10 @@ else { $cssforamountpaymentcomplete = 'amountpaymentneutral'; } - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; print ''; $db->free($resql); @@ -2014,26 +2014,26 @@ else $i = 0;$total = 0; print ''; - print ''; - //print ''; - print ''; + print ''; + //print ''; + print ''; if (! empty($conf->projet->enabled)) print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if ($action != 'editline') { - print ''; - print ''; + print ''; + print ''; } // Ajout des boutons de modification/suppression if (($object->fk_statut < 2 || $object->fk_statut == 99) && $user->rights->expensereport->creer) { - print ''; + print ''; } print ''; @@ -2045,16 +2045,16 @@ else { print ''; - print ''; - /*print '';*/ - print ''; + print ''; if (! empty($conf->projet->enabled)) { print ''; - print ''; - print ''; + print ''; + print ''; // Unit price HT - print ''; - print ''; + print ''; - print ''; + print ''; if ($action != 'editline') { - print ''; - print ''; + print ''; + print ''; } // Ajout des boutons de modification/suppression if (($object->fk_statut < ExpenseReport::STATUS_VALIDATED || $object->fk_statut == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer) { - print ''; // VAT - print ''; // Unit price - print ''; // Unit price with tax - print ''; // Quantity - print ''; if ($action != 'editline') { - print ''; - print ''; + print ''; + print ''; } - print ''; print ''; - print ''; + print ''; if (! empty($conf->projet->enabled)) print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; - print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; @@ -2271,7 +2271,7 @@ else print ''; // Select date - print ''; @@ -2292,7 +2292,7 @@ else } // Select type - print ''; @@ -2302,34 +2302,34 @@ else print ''; // Select VAT - print ''; // Unit price net - print ''; // Unit price with tax - print ''; // Quantity - print ''; if ($action != 'editline') { - print ''; - print ''; + print ''; + print ''; } - print ''; + print ''; print ''; From 3f0bd793243d3a43d20828ab1568fadded560ee9 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 19:17:59 +0100 Subject: [PATCH 092/179] update with html5 compliant code --- htdocs/expensereport/index.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index bfe5bc59126..f7d4e2a8405 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -122,7 +122,7 @@ foreach ($listoftype as $code => $label) if ($conf->use_javascript_ajax) { - print ''; print ''; -print ''; +print ''; print ''; print '
    '; if ($mesg) { print $mesg; } else { print $px1->show(); From 6fb85c093060620ef7443dde900c178ecb973051 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 19:09:02 +0100 Subject: [PATCH 090/179] update with html5 compliant code --- htdocs/expensereport/tpl/linkedobjectblock.tpl.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php index f206a4b4424..9c7a418a6cc 100644 --- a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php @@ -45,14 +45,14 @@ foreach($linkedObjectBlock as $key => $objectlink) trans("ExpenseReport"); ?> getNomUrl(1); ?> date_debut, 'day'); ?>date_debut, 'day'); ?>rights->expensereport->lire) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } ?>getLibStatut(3); ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>getLibStatut(3); ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
    ' . $langs->trans('Date') . '' . $langs->trans('Type') . '' . $langs->trans('BankAccount') . '' . $langs->trans('BankAccount') . '' . $langs->trans('Amount') . '' . $langs->trans('Amount') . ' 
    '; + print ''; if ($bankaccountstatic->id) print $bankaccountstatic->getNomUrl(1, 'transactions'); print ''.price($objp->amount)."'.price($objp->amount)."
    '.$langs->trans("AlreadyPaid").':'.price($totalpaid).'
    '.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
    '.$langs->trans("AlreadyPaid").':'.price($totalpaid).'
    '.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
    '.$langs->trans("RemainderToPay").':
    '.$langs->trans("RemainderToPay").':'.price($resteapayeraffiche).'
    '.$langs->trans('LineNb').''.$langs->trans('Piece').''.$langs->trans('Date').''.$langs->trans('LineNb').''.$langs->trans('Piece').''.$langs->trans('Date').''.$langs->trans('Project').''.$langs->trans('CarCategory').''.$langs->trans('Type').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').''.$langs->trans('Type').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').'
    '; + print ''; print $numline; print ''; + /*print ''; print img_picto($langs->trans("Document"), "object_generic"); print ' '.$piece_comptable.''; print ''.dol_print_date($db->jdate($line->date), 'day').''.dol_print_date($db->jdate($line->date), 'day').''; @@ -2076,10 +2076,10 @@ else $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code)); print $labeltype; print ''.dol_escape_htmltag($line->comments).''.vatrate($line->vatrate, true).''.dol_escape_htmltag($line->comments).''.vatrate($line->vatrate, true).''; + print ''; if (! empty($line->value_unit_ht)) { print price($line->value_unit_ht); @@ -2092,20 +2092,20 @@ else } print ''.price($line->value_unit).''.price($line->value_unit).''.dol_escape_htmltag($line->qty).''.dol_escape_htmltag($line->qty).''.price($line->total_ht).''.price($line->total_ttc).''.price($line->total_ht).''.price($line->total_ttc).''; + print ''; print 'rowid.'#'.$line->rowid.'">'; print img_edit(); @@ -2158,32 +2158,32 @@ else print ''; + print ''; print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, '', 0, 0, '', false, 1); print ''; + print ''; print ''; print ''; + print ''; print ''; print ''; + print ''; print ''; print ''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').''; + print ''; print ''; print ''; print '
    '; @@ -2253,15 +2253,15 @@ else print '
    '.$langs->trans('Date').''.$langs->trans('Date').''.$langs->trans('Project').''.$langs->trans('CarCategory').''.$langs->trans('Type').''.$langs->trans('Type').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').'
    '; + print ''; print $form->selectDate($date?$date:-1, 'date', 0, 0, 0, '', 1, 1); print ''; + print ''; select_type_fees_id($fk_c_type_fees, 'fk_c_type_fees', 1); print ''; + print ''; $defaultvat=-1; if (! empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; print $form->load_tva('vatrate', ($vatrate!=''?$vatrate:$defaultvat), $mysoc, '', 0, 0, '', false, 1); print ''; + print ''; print ''; print ''; + print ''; print ''; print ''; + print ''; print ''; // We must be able to enter decimal qty print '
    '; + print '
    '; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); @@ -139,7 +139,7 @@ if ($conf->use_javascript_ajax) print '
    '.$langs->trans("Total").''.price($totalsum, 1, $langs, 0, 0, 0, $conf->currency).''.price($totalsum, 1, $langs, 0, 0, 0, $conf->currency).'
    '; @@ -183,9 +183,9 @@ if ($result) print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; if ($num) @@ -208,10 +208,10 @@ if ($result) print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; From dc8de23c1acf38ded47d35546e40d5c8069d0a7c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Mar 2019 19:21:27 +0100 Subject: [PATCH 093/179] update with html5 compliant code --- htdocs/expensereport/list.php | 40 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index c59b6d70e0f..c221baf7d65 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -556,16 +556,16 @@ if ($resql) // Amount with no tax if (! empty($arrayfields['d.total_ht']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['d.total_vat']['checked'])) { - print ''; + print ''; } // Amount with all taxes if (! empty($arrayfields['d.total_ttc']['checked'])) { - print ''; + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -589,12 +589,12 @@ if ($resql) // Status if (! empty($arrayfields['d.fk_statut']['checked'])) { - print ''; } // Action column - print ''; @@ -670,7 +670,7 @@ if ($resql) print ''; } print ''; - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } // End date if (! empty($arrayfields['d.date_fin']['checked'])) { - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } // Date validation if (! empty($arrayfields['d.date_valid']['checked'])) { - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } // Date approval if (! empty($arrayfields['d.date_approve']['checked'])) { - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } // Amount HT if (! empty($arrayfields['d.total_ht']['checked'])) { - print '\n"; + print '\n"; if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield']; $totalarray['totalht'] += $obj->total_ht; @@ -725,7 +725,7 @@ if ($resql) // Amount VAT if (! empty($arrayfields['d.total_vat']['checked'])) { - print '\n"; + print '\n"; if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield']; $totalarray['totalvat'] += $obj->total_tva; @@ -733,7 +733,7 @@ if ($resql) // Amount TTC if (! empty($arrayfields['d.total_ttc']['checked'])) { - print '\n"; + print '\n"; if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; $totalarray['totalttc'] += $obj->total_ttc; @@ -748,7 +748,7 @@ if ($resql) // Date creation if (! empty($arrayfields['d.date_create']['checked'])) { - print ''; if (! $i) $totalarray['nbfield']++; @@ -756,7 +756,7 @@ if ($resql) // Date modification if (! empty($arrayfields['d.tms']['checked'])) { - print ''; if (! $i) $totalarray['nbfield']++; @@ -764,11 +764,11 @@ if ($resql) // Status if (! empty($arrayfields['d.fk_statut']['checked'])) { - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } // Action column - print ''; else print ''; } - elseif ($totalarray['totalhtfield'] == $i) print ''; - elseif ($totalarray['totalvatfield'] == $i) print ''; - elseif ($totalarray['totalttcfield'] == $i) print ''; + elseif ($totalarray['totalhtfield'] == $i) print ''; + elseif ($totalarray['totalvatfield'] == $i) print ''; + elseif ($totalarray['totalttcfield'] == $i) print ''; else print ''; } print ''; From c44d9bf8e27770d15ce28b1798504072c8fe0688 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 23:27:50 +0100 Subject: [PATCH 094/179] Fix phpcs --- htdocs/expedition/card.php | 4 +--- htdocs/livraison/card.php | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 05770c7d44a..b2d45e11a6f 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1368,7 +1368,7 @@ if ($action == 'create') print ''; - + print ''; @@ -1424,7 +1424,6 @@ if ($action == 'create') print ''; print '('.$stock.')'; - } else { @@ -1525,7 +1524,6 @@ if ($action == 'create') } } } - } if ($subj == 0) // Line not shown yet, we show it { diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index f567773d714..aec52404bd1 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -608,7 +608,7 @@ else $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) + if (empty($reshook)) { print ''; if ($object->lines[$i]->fk_product > 0) @@ -635,7 +635,7 @@ else { $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label); } - + print '\n"; } @@ -1256,7 +1257,7 @@ if ($action == 'create') // Show warehouse combo list $ent = "entl".$indiceAsked; $idl = "idl".$indiceAsked; - $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):$warehouse_id; + $tmpentrepot_id = is_numeric(GETPOST($ent, 'int'))?GETPOST($ent, 'int'):$warehouse_id; if ($line->fk_product > 0) { print ''; @@ -1344,8 +1345,8 @@ if ($action == 'create') $detail=''; $detail.= $langs->trans("Batch").': '.$dbatch->batch; - $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); - $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); + $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); + $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; $detail.= '
    '; print $detail; diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 4f58fb6dd1f..d9b2537e4ba 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -686,7 +686,7 @@ if ($id > 0 || ! empty($ref)) if (empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { - $outputlangs = new Translate("",$conf); + $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -707,10 +707,10 @@ if ($id > 0 || ! empty($ref)) $text.= ' - '.$label; $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'
    '; $description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); - print $form->textwithtooltip($text,$description,3,'','',$i); + print $form->textwithtooltip($text, $description, 3, '', '', $i); // Show range - print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end)); + print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end)); // Add description in form if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) @@ -723,18 +723,18 @@ if ($id > 0 || ! empty($ref)) else { print "\n"; } diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 3a35105104b..9eedea68335 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -231,7 +231,7 @@ class ProductFournisseur extends Product * @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='') + 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; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6fc421e19a4..68eef7f5bd5 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1860,3 +1860,5 @@ MAIN_OPTIMIZEFORTEXTBROWSERDesc=Enable this option if you are a blind person, or ThisValueCanOverwrittenOnUserLevel=This value can be overwritten by each user from its user page - tab '%s' DefaultCustomerType=Default thirdparty type for "New customer" creation form ABankAccountMustBeDefinedOnPaymentModeSetup=Note: The bank account must be defined on the module of each payment mode (Paypal, Stripe, ...) to have this feature working. +RootCategoryForProductsToSell=Root category of products to sell +RootCategoryForProductsToSellDesc=If defined, only products inside this category or childs of this category will be available in the Point Of Sale \ No newline at end of file diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index eb34e302cad..a6c3ffa01b0 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -83,7 +83,7 @@ DeleteFromCat=Remove from tags/category ExtraFieldsCategories=Complementary attributes CategoriesSetup=Tags/categories setup CategorieRecursiv=Link with parent tag/category automatically -CategorieRecursivHelp=If activated, product will also linked to parent category when adding into a subcategory +CategorieRecursivHelp=If option is on, when you add a product into a subcategory, product will also be added into the parent category. AddProductServiceIntoCategory=Add the following product/service ShowCategory=Show tag/category ByDefaultInList=By default in list diff --git a/htdocs/product/card.php b/htdocs/product/card.php index dc286faa36c..8fcc2af6634 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1496,7 +1496,7 @@ else // Tags-Categories if ($conf->categorie->enabled) { - print '\n"; @@ -913,7 +913,7 @@ SCRIPT; print ''; - + if (is_object($hookmanager)) { $parameters=array('id_pfp'=>$productfourn->product_fourn_price_id,'id_fourn'=>$id_fourn,'prod_id'=>$object->id); diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index e7d21acbc75..c00fa060493 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -26,6 +26,7 @@ require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // If socid provided by ajax company selector if (! empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) @@ -56,6 +57,8 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "CASHDESK_ID_WAREHOUSE", (GETPOST('CASHDESK_ID_WAREHOUSE', 'alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", GETPOST('CASHDESK_NO_DECREASE_STOCK', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_SERVICES", GETPOST('CASHDESK_SERVICES', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_ROOT_CATEGORY_ID", GETPOST('TAKEPOS_ROOT_CATEGORY_ID', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOSCONNECTOR", GETPOST('TAKEPOSCONNECTOR', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_BAR_RESTAURANT", GETPOST('TAKEPOS_BAR_RESTAURANT', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -64,7 +67,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity); - + if ($conf->global->TAKEPOS_ORDER_NOTES==1) { $extrafields = new ExtraFields($db); @@ -121,6 +124,13 @@ if (! empty($conf->service->enabled)) print "\n"; } +print '\n"; + // Use Takepos printing print ''; - + print ''; - print ''; + // Add line to upload new file + print 'global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display: none"':'').'>'; print ''; + // Add line to select existing file + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); + $arrayoffiles=dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png|'.preg_quote(dol_sanitizeFileName($object->ref.'.pdf'), '/').')$'); + $nbFiles = count($arrayoffiles); + $nbLinks=Link::count($db, $object->element, $object->id); + if ($nbFiles >= 0) + { + print 'global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display: none"':'').'>'; + print ''; + } + } + print ''; print ''; print ''; @@ -2332,16 +2433,6 @@ else print ''; print ''; - - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) - { - print ''; - } } // Fin si c'est payé/validé print '
    '.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").' 
    '.$expensereportstatic->getNomUrl(1).''.$userstatic->getNomUrl(-1).''.price($obj->total_ht).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->dm), 'day').''; + print ''.price($obj->total_ht).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->dm), 'day').''; //print $obj->libelle; print $expensereportstatic->LibStatut($obj->fk_status, 3); print ''; + print ''; select_expensereport_statut($search_status, 'search_status', 1, 1); print ''; + print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print ''; + print ''; $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->expensereport->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; @@ -696,28 +696,28 @@ if ($resql) } // Start date if (! empty($arrayfields['d.date_debut']['checked'])) { - print ''.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').''.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').''.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').''.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').''.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').''.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').''.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').''.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').''.price($obj->total_ht)."'.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.price($obj->total_ttc)."'; + print ''; print dol_print_date($db->jdate($obj->date_create), 'dayhour'); print ''; + print ''; print dol_print_date($db->jdate($obj->date_modif), 'dayhour'); print ''.$expensereportstatic->getLibStatut(5).''.$expensereportstatic->getLibStatut(5).''; + print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; @@ -808,9 +808,9 @@ if ($resql) if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).'
    '; print ' '; print ''; print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle); print '
    '; // Affiche ligne produit From 6aa9a5f13ae4f6ec4b9cace2de5bfb184288061f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 23:36:55 +0100 Subject: [PATCH 095/179] Fix link to backoffice --- htdocs/takepos/takepos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 740978e7db6..cdb693fdcae 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -446,7 +446,7 @@ $menus[$r++]=array('title'=>$langs->trans("FreeZone"), $menus[$r++]=array('title'=>$langs->trans("Customer"), 'action'=>'Customer();'); $menus[$r++]=array('title'=>$langs->trans("BackOffice"), - 'action'=>'window.open(\''.(empty(DOL_URL_ROOT)?'/':DOL_URL_ROOT).'\', \'_self\');'); + 'action'=>'window.open(\''.(DOL_URL_ROOT ? DOL_URL_ROOT : '/').'\', \'_self\');'); $menus[$r++]=array('title'=>$langs->trans("ValidateBill"), 'action'=>'CloseBill();'); $menus[$r++]=array('title'=>$langs->trans("Logout"), From ca31f654e7cbfdb6b1d01a7e1ff821b7a276fec2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 23:42:22 +0100 Subject: [PATCH 096/179] Reduce text for graph title --- htdocs/core/boxes/box_graph_product_distribution.php | 10 +++------- htdocs/langs/en_US/boxes.lang | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index d1c85cb2044..0fe5c66d532 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -128,10 +128,6 @@ class box_graph_product_distribution extends ModeleBoxes ); - $paramtitle=$langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services"); - if (empty($conf->produit->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Services"); - if (empty($conf->service->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Products"); - $socid=empty($user->societe_id)?0:$user->societe_id; $userid=0; // No filter on user creation @@ -190,7 +186,7 @@ class box_graph_product_distribution extends ModeleBoxes $px1->SetCssPrefix("cssboxes"); //$px1->mode='depth'; $px1->SetType(array('pie')); - $px1->SetTitle($langs->trans("BoxProductDistributionFor", $paramtitle, $langs->transnoentitiesnoconv("Invoices"))); + $px1->SetTitle($langs->trans("ForObject", $langs->transnoentitiesnoconv("Invoices"))); $px1->combine = 0.05; $px1->draw($filenamenb, $fileurlnb); @@ -250,7 +246,7 @@ class box_graph_product_distribution extends ModeleBoxes $px2->SetCssPrefix("cssboxes"); //$px2->mode='depth'; $px2->SetType(array('pie')); - $px2->SetTitle($langs->trans("BoxProductDistributionFor", $paramtitle, $langs->transnoentitiesnoconv("Proposals"))); + $px2->SetTitle($langs->trans("ForObject", $langs->transnoentitiesnoconv("Proposals"))); $px2->combine = 0.05; $px2->draw($filenamenb, $fileurlnb); @@ -311,7 +307,7 @@ class box_graph_product_distribution extends ModeleBoxes $px3->SetCssPrefix("cssboxes"); //$px3->mode='depth'; $px3->SetType(array('pie')); - $px3->SetTitle($langs->trans("BoxProductDistributionFor", $paramtitle, $langs->transnoentitiesnoconv("Orders"))); + $px3->SetTitle($langs->trans("ForObject", $langs->transnoentitiesnoconv("Orders"))); $px3->combine = 0.05; $px3->draw($filenamenb, $fileurlnb); diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 78b03ea8caf..2af485dac7f 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -72,7 +72,7 @@ BoxSuppliersOrdersPerMonth=Vendor Orders per month BoxProposalsPerMonth=Proposals per month NoTooLowStockProducts=No products are under the low stock limit BoxProductDistribution=Products/Services Distribution -BoxProductDistributionFor=%s by %s +ForObject=On %s BoxTitleLastModifiedSupplierBills=Vendor Invoices: last %s modified BoxTitleLatestModifiedSupplierOrders=Vendor Orders: last %s modified BoxTitleLastModifiedCustomerBills=Customer Invoices: last %s modified From 86c5dc20e3b5c74c559130290ab7d171cebebd37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 01:28:54 +0100 Subject: [PATCH 097/179] NEW Can choose the root category to show for TakePOS module --- htdocs/categories/admin/categorie.php | 2 +- htdocs/categories/class/categorie.class.php | 65 ++++++++++++------- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/ajax.lib.php | 3 +- htdocs/expedition/card.php | 19 +++--- htdocs/expedition/shipment.php | 14 ++-- .../fourn/class/fournisseur.product.class.php | 2 +- htdocs/langs/en_US/admin.lang | 2 + htdocs/langs/en_US/categories.lang | 2 +- htdocs/product/card.php | 2 +- htdocs/product/fournisseurs.php | 10 +-- htdocs/takepos/admin/setup.php | 14 +++- htdocs/takepos/css/pos.css | 2 +- htdocs/takepos/takepos.php | 30 +++++++-- 14 files changed, 110 insertions(+), 59 deletions(-) diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index fd198e043e9..e506906808a 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -31,7 +31,7 @@ if (!$user->admin) accessforbidden(); // Load translation files required by the page -$langs->load("categories"); +$langs->loadLangs(array("categories","admin")); $action=GETPOST('action', 'aZ09'); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d5159f003e2..5db9b4be136 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -909,7 +909,7 @@ class Categorie extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return direct childs of a category + * Return direct childs id of a category into an array * * @return array|int <0 KO, array ok */ @@ -947,9 +947,7 @@ class Categorie extends CommonObject protected function load_motherof() { // phpcs:enable - global $conf; - - $this->motherof=array(); + $this->motherof=array(); // Load array[child]=parent $sql = "SELECT fk_parent as id_parent, rowid as id_son"; @@ -985,12 +983,12 @@ class Categorie extends CommonObject * fulllabel = nom avec chemin complet de la categorie * fullpath = chemin complet compose des id * - * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...). - * @param int $markafterid Removed all categories including the leaf $markafterid in category tree. - * - * @return array|int Array of categories. this->cats and this->motherof are set, -1 on error + * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...). + * @param int $markafterid Removed all categories including the leaf $markafterid in category tree. + * @param int $keeponlyifinleafid Keep only of category is inside the leaf starting with this id. + * @return array|int Array of categories. this->cats and this->motherof are set, -1 on error */ - public function get_full_arbo($type, $markafterid = 0) + public function get_full_arbo($type, $markafterid = 0, $keeponlyifinleafid = 0) { // phpcs:enable global $conf, $langs; @@ -1059,6 +1057,27 @@ class Categorie extends CommonObject } } } + // Exclude leaf including $markafterid from tree + if ($keeponlyifinleafid) + { + //print "Look to discard category ".$keeponlyifinleafid."\n"; + $keyfilter1='^'.$keeponlyifinleafid.'$'; + $keyfilter2='_'.$keeponlyifinleafid.'$'; + $keyfilter3='^'.$keeponlyifinleafid.'_'; + $keyfilter4='_'.$keeponlyifinleafid.'_'; + foreach($this->cats as $key => $val) + { + if (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) + || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])) + { + // We keep + } + else + { + unset($this->cats[$key]); + } + } + } dol_syslog(get_class($this)."::get_full_arbo dol_sort_array", LOG_DEBUG); $this->cats=dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); @@ -1070,7 +1089,8 @@ class Categorie extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * For category id_categ and its childs available in this->cats, define property fullpath and fulllabel + * For category id_categ and its childs available in this->cats, define property fullpath and fulllabel. + * This function is a memory scan only from $this->cats and $this->motherof, no database access must be done here. * * @param int $id_categ id_categ entry to update * @param int $protection Deep counter to avoid infinite loop @@ -1174,6 +1194,19 @@ class Categorie extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns the top level categories (which are not child) + * + * @param int $type Type of category (0, 1, ...) + * @return array + */ + public function get_main_categories($type = null) + { + // phpcs:enable + return $this->get_all_categories($type, true); + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if no category with same label already exists for this cat's parent or root and for this cat's type @@ -1225,18 +1258,6 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Returns the top level categories (which are not girls) - * - * @param int $type Type of category (0, 1, ...) - * @return array - */ - public function get_main_categories($type = null) - { - // phpcs:enable - return $this->get_all_categories($type, true); - } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 765bd307464..69ff39ba0dd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3805,7 +3805,7 @@ class Form * @param int $excludeafterid Exclude all categories after this leaf in category tree. * @param int $outputmode 0=HTML select string, 1=Array * @return string - * @see select_categories + * @see select_categories() */ public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $excludeafterid = 0, $outputmode = 0) { diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index f1a06b46262..a96e63a4f43 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -375,8 +375,7 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = { global $conf; - // select2 disabled for smartphones with standard browser. - // TODO With select2 v4, it seems ok, except that responsive style on table become crazy when scrolling at end of array) + // select2 can be disabled for smartphones if (! empty($conf->browser->layout) && $conf->browser->layout == 'phone' && ! empty($conf->global->MAIN_DISALLOW_SELECT2_WITH_SMARTPHONE)) return ''; if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return ''; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index e88e435df67..05819fe91be 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -784,7 +784,8 @@ if (empty($reshook)) $stockLocation="entl".$detail_entrepot->line_id; $qty = "qtyl".$detail_entrepot->line_id; $warehouse = GETPOST($stockLocation, 'int'); - if (!empty($warehouse)) { + if (!empty($warehouse)) + { $line->id = $detail_entrepot->line_id; $line->entrepot_id = $warehouse; $line->qty = GETPOST($qty, 'int'); @@ -1173,7 +1174,7 @@ if ($action == 'create') print $form->textwithtooltip($text, $description, 3, '', '', $i); // Show range - print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); + print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); // Add description in form if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) @@ -1186,18 +1187,18 @@ if ($action == 'create') else { print ""; - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); + if ($type==1) $text = img_object($langs->trans('Service'), 'service'); + else $text = img_object($langs->trans('Product'), 'product'); if (! empty($line->label)) { $text.= ' '.$line->label.''; - print $form->textwithtooltip($text,$line->desc,3,'','',$i); + print $form->textwithtooltip($text, $line->desc, 3, '', '', $i); } else { print $text.' '.nl2br($line->desc); } // Show range - print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); + print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); print ""; - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); + if ($type==1) $text = img_object($langs->trans('Service'), 'service'); + else $text = img_object($langs->trans('Product'), 'product'); if (! empty($objp->label)) { $text.= ' '.$objp->label.''; - print $form->textwithtooltip($text,$objp->description,3,'','',$i); + print $form->textwithtooltip($text, $objp->description, 3, '', '', $i); } else { print $text.' '.nl2br($objp->description); } // Show range - print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end)); + print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end)); print "
    '.$langs->trans("Categories").''; + print '
    '.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_PRODUCT); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 0e34c9adce6..e2d05cc7e0c 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -799,10 +799,10 @@ SCRIPT; print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center '); if ($conf->barcode->enabled) { - print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, 'align="center"', $sortfield, $sortorder); - } - print_liste_field_titre("DateModification",$_SERVER["PHP_SELF"],"pfp.tms","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center '); + } + print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre(''); print "
    '; print dol_print_date($productfourn->date_modification, "dayhour"); print '
    '; +print $form->textwithpicto($langs->trans("RootCategoryForProductsToSell"), $langs->trans("RootCategoryForProductsToSellDesc")); +print ''; +print $form->select_all_categories(Categorie::TYPE_PRODUCT, $conf->global->TAKEPOS_ROOT_CATEGORY_ID, 'TAKEPOS_ROOT_CATEGORY_ID', 64, 0, 0); +print ajax_combobox('TAKEPOS_ROOT_CATEGORY_ID'); +print "
    '; print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("TakeposConnectorNecesary").')'; @@ -149,7 +159,7 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT && $conf->global->TAKEPOSCONNECTOR){ print ''; print $form->selectyesno("TAKEPOS_ORDER_PRINTERS", $conf->global->TAKEPOS_ORDER_PRINTERS, 1); print '
    '; print $langs->trans("OrderNotes"); print ''; diff --git a/htdocs/takepos/css/pos.css b/htdocs/takepos/css/pos.css index fff566e6aaa..086e4e5fcb0 100644 --- a/htdocs/takepos/css/pos.css +++ b/htdocs/takepos/css/pos.css @@ -83,7 +83,7 @@ div.wrapper2{ width:12.5%; height:25%; margin:0; - padding:1px; + /* padding:1px; */ border: 0.1em solid; box-shadow: 2px 2px 1px #888; text-align: center; diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index bcfca236925..36b670146f9 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -40,6 +40,11 @@ $action = GETPOST('action', 'alpha'); $langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter")); +$categorie = new Categorie($db); + +$MAXCATEG = 16; +$MAXPRODUCT = 32; + /* * View @@ -61,14 +66,30 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); '."\n"; print '
    '; $modulepart = 'expensereport'; @@ -2251,6 +2293,65 @@ else print '
    '; + //print ''.$langs->trans("AttachTheNewLineToTheDocument").'
    '; + $modulepart='expensereport';$maxheightmini=48; + $relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/'; + foreach($arrayoffiles as $file) + { + print '
    '; + $fileinfo = pathinfo($file['name']); + if (image_format_supported($file['name']) > 0) + { + $minifile=getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original + //if (! dol_is_file($file['path'].'/'.$minifile)) $minifile=getImageFileNameForSize($file['name'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension + //print $file['path'].'/'.$minifile.'
    '; + $urlforhref=getAdvancedPreviewUrl($modulepart, $fileinfo['relativename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); + if (empty($urlforhref)) { + $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($fileinfo['relativename'].'.'.strtolower($fileinfo['extension'])); + print ''; + } else { + print ''; + } + print ''; + print ''; + } + else print ' '; + print '
    '; + $checked=''; + //var_dump(GETPOST($file['relativename'])); var_dump($file['relativename']); var_dump($_FILES['userfile']['name']); + foreach($_FILES['userfile']['name'] as $tmpfile) + { + if ($file['relativename'] == (GETPOST('savingdocmask','alpha') ? dol_sanitizeFileName($object->ref.'-') : '').$tmpfile) + { + $checked=' checked'; + break; + } + elseif ($file['relativename'] && in_array($file['relativename'], GETPOST('attachfile','array'))) { + $checked=' checked'; + break; + } + } + print ' '.$file['relativename']; + print '
    '; + } + print '
    '.$langs->trans('Date').'
    '; - print $langs->trans("AttachTheNewLineToTheDocument"); - - print '...'; - - print '
    '; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 48902b45ca8..fd073e28fba 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -971,7 +971,7 @@ class ExpenseReport extends CommonObject $this->lines=array(); $sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date, de.rang,'; - $sql.= ' de.'.$this->fk_element.', de.fk_c_type_fees, de.fk_c_exp_tax_cat, de.fk_projet, de.tva_tx,'; + $sql.= ' de.'.$this->fk_element.', de.fk_c_type_fees, de.fk_c_exp_tax_cat, de.fk_projet as fk_project, de.tva_tx,'; $sql.= ' de.total_ht, de.total_tva, de.total_ttc,'; $sql.= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,'; $sql.= ' p.ref as ref_projet, p.title as title_projet'; @@ -1010,7 +1010,8 @@ class ExpenseReport extends CommonObject $deplig->fk_expensereport = $objp->fk_expensereport; $deplig->fk_c_type_fees = $objp->fk_c_type_fees; $deplig->fk_c_exp_tax_cat = $objp->fk_c_exp_tax_cat; - $deplig->fk_projet = $objp->fk_projet; + $deplig->fk_projet = $objp->fk_project; + $deplig->fk_project = $objp->fk_project; $deplig->total_ht = $objp->total_ht; $deplig->total_tva = $objp->total_tva; @@ -1994,7 +1995,8 @@ class ExpenseReport extends CommonObject $this->line->fk_expensereport= $expensereport_id; $this->line->fk_c_type_fees = $type_fees_id; $this->line->fk_c_exp_tax_cat = $fk_c_exp_tax_cat; - $this->line->fk_projet = $projet_id; + $this->line->fk_projet = $projet_id; // deprecated + $this->line->fk_project = $projet_id; $this->line->vat_src_code = $vat_src_code; $this->line->vatrate = price2num($vatrate); @@ -2513,7 +2515,7 @@ class ExpenseReportLine */ public function fetch($rowid) { - $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_c_exp_tax_cat, fde.fk_projet, fde.date,'; + $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_c_exp_tax_cat, fde.fk_projet as fk_project, fde.date,'; $sql.= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; $sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; @@ -2539,7 +2541,8 @@ class ExpenseReportLine $this->value_unit = $objp->value_unit; $this->fk_c_type_fees = $objp->fk_c_type_fees; $this->fk_c_exp_tax_cat = $objp->fk_c_exp_tax_cat; - $this->fk_projet = $objp->fk_projet; + $this->fk_projet = $objp->fk_project; // deprecated + $this->fk_project = $objp->fk_project; $this->type_fees_code = $objp->type_fees_code; $this->type_fees_libelle = $objp->type_fees_libelle; $this->projet_ref = $objp->projet_ref; @@ -2585,7 +2588,7 @@ class ExpenseReportLine $sql.= ' tva_tx, vat_src_code, comments, qty, value_unit, total_ht, total_tva, total_ttc, date, rule_warning_message, fk_c_exp_tax_cat)'; $sql.= " VALUES (".$this->db->escape($this->fk_expensereport).","; $sql.= " ".$this->db->escape($this->fk_c_type_fees).","; - $sql.= " ".$this->db->escape($this->fk_projet>0?$this->fk_projet:'null').","; + $sql.= " ".$this->db->escape($this->fk_project>0?$this->fk_project:($this->fk_projet>0?$this->fk_projet:'null')).","; $sql.= " ".$this->db->escape($this->vatrate).","; $sql.= " '".$this->db->escape($this->vat_src_code)."',"; $sql.= " '".$this->db->escape($this->comments)."',"; @@ -2713,7 +2716,7 @@ class ExpenseReportLine $sql.= ",fk_c_exp_tax_cat=".$this->db->escape($this->fk_c_exp_tax_cat); if ($this->fk_c_type_fees) $sql.= ",fk_c_type_fees=".$this->db->escape($this->fk_c_type_fees); else $sql.= ",fk_c_type_fees=null"; - if ($this->fk_projet) $sql.= ",fk_projet=".$this->db->escape($this->fk_projet); + if ($this->fk_project > 0) $sql.= ",fk_projet=".$this->db->escape($this->fk_project); else $sql.= ",fk_projet=null"; $sql.= " WHERE rowid = ".$this->db->escape($this->rowid); diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 38871f55c0e..2afd0745c8e 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -162,6 +162,7 @@ if ($action == 'add') { if ($object->socid > 0) { $newinter->socid=$object->socid; $newinter->fk_projet=$object->fk_projet; + $newinter->fk_project=$object->fk_projet; $newinter->fk_contrat=$object->fk_contrat; } else $newinter->socid=GETPOST("socid"); @@ -772,8 +773,8 @@ $date_next_execution = (GETPOST('remonth') ? dol_mktime( /* * List mode */ - $sql = "SELECT f.rowid as fich_rec, s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, "; - $sql.= " f.duree, f.fk_contrat, f.fk_projet, f.frequency, f.nb_gen_done, f.nb_gen_max,"; + $sql = "SELECT f.rowid as fich_rec, s.nom as name, s.rowid as socid, f.rowid as facid, f.titre,"; + $sql.= " f.duree, f.fk_contrat, f.fk_projet as fk_project, f.frequency, f.nb_gen_done, f.nb_gen_max,"; $sql.= " f.date_last_gen, f.date_when, f.datec"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter_rec as f"; @@ -863,7 +864,7 @@ $date_next_execution = (GETPOST('remonth') ? dol_mktime( if (! empty($conf->projet->enabled)) { print '
    '; if ($objp->fk_project > 0) { - $projectstatic->fetch($objp->fk_projet); + $projectstatic->fetch($objp->fk_project); print $projectstatic->getNomUrl(1); } print '
    '.$langs->trans("Zip").' / '.$langs->trans("Town").''; @@ -544,7 +544,7 @@ if ( $object->socid && ! empty($conf->societe->enabled) && ! empty($conf->global print '
    '.$langs->trans("Lastname").'
    '.$langs->trans("Firstname").'
    '.$langs->trans("Address").''; - print '
    '.$langs->trans("Zip").' / '.$langs->trans("Town").''; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 613efa62c70..819014a092e 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2154,7 +2154,7 @@ else // Add comments print ''; - print ''; + print ''; print ''; - print ''; + print ''; print '
    '.$langs->trans("Description").''; - print ''; + print ''; print '
    '.$langs->trans("Company").'
    '.$langs->trans("Address").''."\n"; -print '
    '.$langs->trans('Zip').' / '.$langs->trans('Town').''; print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town','selectcountry_id','state_id'), 6, 1); @@ -649,7 +649,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments print '
    '.$langs->trans("Comments").'
    '.$langs->trans("Zip").' / '.$langs->trans("Town").''; @@ -535,7 +535,7 @@ if (! empty($id) && $action == 'edit') print '
    '.$langs->trans("Lastname").'
    '.$langs->trans("Firstname").'
    '.$langs->trans("Address").''; - print '
    '.$langs->trans("Zip").' / '.$langs->trans("Town").''; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index fab70b1200a..ddd1f7cd306 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2132,7 +2132,7 @@ else // Add comments print ''; - print ''; + print ''; print ''; - print ''; + print ''; print '
    '.$langs->trans("Description").''; - print ''; + print ''; print '
    '.$langs->trans("Firstname").' *'.$langs->trans("Company").'
    '.$langs->trans("Address").''."\n"; -print '
    '.$langs->trans('Zip').' / '.$langs->trans('Town').''; print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town','selectcountry_id','state_id'), 6, 1); @@ -641,7 +641,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments print '
    '.$langs->trans("Comments").'
    '.dol_escape_htmltag($line->comments).''.dol_nl2br($line->comments).''.vatrate($line->vatrate, true).''; From 82a9ac4f65059f5906f9cf7d3a2cce8dd7709db5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 16:07:08 +0100 Subject: [PATCH 109/179] Fix phpcs --- htdocs/expensereport/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index d2a6fc965f8..c39b67a8680 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2238,7 +2238,7 @@ else jQuery(".trattachnewfilenow").toggle(); return false; });'; - if (is_array(GETPOST('attachfile','array')) && count(GETPOST('attachfile','array'))) + if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array'))) { print 'jQuery(".trattachnewfilenow").toggle();'."\n"; } @@ -2335,12 +2335,12 @@ else //var_dump(GETPOST($file['relativename'])); var_dump($file['relativename']); var_dump($_FILES['userfile']['name']); foreach($_FILES['userfile']['name'] as $tmpfile) { - if ($file['relativename'] == (GETPOST('savingdocmask','alpha') ? dol_sanitizeFileName($object->ref.'-') : '').$tmpfile) + if ($file['relativename'] == (GETPOST('savingdocmask', 'alpha') ? dol_sanitizeFileName($object->ref.'-') : '').$tmpfile) { $checked=' checked'; break; } - elseif ($file['relativename'] && in_array($file['relativename'], GETPOST('attachfile','array'))) { + elseif ($file['relativename'] && in_array($file['relativename'], GETPOST('attachfile', 'array'))) { $checked=' checked'; break; } From 63b6900f2cca3d663c21173d2f483d9aed724160 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 16:09:20 +0100 Subject: [PATCH 110/179] Fix phpcs --- .../class/accountancycategory.class.php | 2 +- .../accountancy/class/accountancyexport.class.php | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index ae4b42c8e3c..1f30bcfcef3 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -38,7 +38,7 @@ class AccountancyCategory // extends CommonObject /** * @var string Error string - * @see errors + * @see $errors */ public $error; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 90b722d7959..a641ccb4db5 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -31,20 +31,15 @@ * \brief Class accountancy export */ -/** - * Class AccountancyExport - * - * Manage the different format accountancy export - */ - require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; +/** + * Manage the different format accountancy export + */ class AccountancyExport { - /** - * Type of export. Defined by $conf->global->ACCOUNTING_EXPORT_MODELCSV - */ - public static $EXPORT_TYPE_NORMAL = 1; // CSV + // Type of export. Used into $conf->global->ACCOUNTING_EXPORT_MODELCSV + public static $EXPORT_TYPE_NORMAL = 1; // CSV public static $EXPORT_TYPE_CONFIGURABLE = 10; // CSV public static $EXPORT_TYPE_CEGID = 2; public static $EXPORT_TYPE_COALA = 3; From bca18f22aec1d811849c27ebb47c4948b6b59edd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 16:23:38 +0100 Subject: [PATCH 111/179] Prepare link with expense report line and document --- htdocs/install/mysql/migration/9.0.0-10.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_expensereport_det.sql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 6f90b41f62b..a7f5ca87c9a 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -172,7 +172,7 @@ ALTER TABLE llx_socpeople ADD COLUMN linkedin varchar(255) after whatsapp; ALTER TABLE llx_adherent ADD COLUMN linkedin varchar(255) after whatsapp; ALTER TABLE llx_user ADD COLUMN linkedin varchar(255) after whatsapp; - +ALTER TABLE llx_expensereport_det ADD COLUMN fk_expensereport_line integer DEFAULT NULL; CREATE TABLE llx_bom_bom( diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql index 59bfd60b0ca..c87d26c94a8 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_det.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql @@ -51,6 +51,7 @@ CREATE TABLE llx_expensereport_det multicurrency_total_tva double(24,8) DEFAULT 0, multicurrency_total_ttc double(24,8) DEFAULT 0, fk_facture integer DEFAULT 0, -- ID of customer invoice line if expense is rebilled to a customer + fk_expensereport_line integer DEFAULT NULL, -- ID of ECM file that is source document of expense report fk_code_ventilation integer DEFAULT 0, rang integer DEFAULT 0, -- position of line import_key varchar(14), From ab4076c54a14fca32baa1e6bfea360133bab68c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 18:06:26 +0100 Subject: [PATCH 112/179] WIP Work on BOM module --- htdocs/bom/class/bom.class.php | 59 +++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 47aae86db04..ec695e05637 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -397,6 +397,62 @@ class BOM extends CommonObject } + /** + * Returns the reference to the following non used BOM depending on the active numbering module + * defined into BOM_ADDON + * + * @param Product $prod Object product + * @return string BOM free reference + */ + public function getNextNumRef($prod) + { + global $langs, $conf; + $langs->load("mrp"); + + if (! empty($conf->global->BOM_ADDON)) + { + $mybool=false; + + $file = $conf->global->BOM_ADDON.".php"; + $classname = $conf->global->BOM_ADDON; + + // Include file with class + $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $dir = dol_buildpath($reldir."core/modules/bom/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; + } + + if ($mybool === false) + { + dol_print_error('', "Failed to include file ".$file); + return ''; + } + + $obj = new $classname(); + $numref = $obj->getNextValue($prod, $this); + + if ($numref != "") + { + return $numref; + } + else + { + $this->error=$obj->error; + //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); + return ""; + } + } + else + { + print $langs->trans("Error")." ".$langs->trans("Error_BOM_ADDON_NotDefined"); + return ""; + } + } + /** * Validate bom * @@ -433,7 +489,8 @@ class BOM extends CommonObject // Define new ref if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { - $num = $this->getNextNumRef(); + $this->fetch_product(); + $num = $this->getNextNumRef($this->product); } else { From d075e97ba6b3d9bc10e147f5ca20befca9b0803f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 18:09:44 +0100 Subject: [PATCH 113/179] Remove warnings --- htdocs/cron/class/cronjob.class.php | 8 +++++++- htdocs/holiday/class/holiday.class.php | 12 ++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index c223f3c76ff..dafe772a0eb 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -67,7 +67,13 @@ class Cronjob extends CommonObject public $md5params; public $module_name; public $priority; + /** + * @var string|int Date for last job execution + */ public $datelastrun=''; + /** + * @var string|int Date for next job execution + */ public $datenextrun=''; public $dateend=''; public $datestart=''; @@ -1220,7 +1226,7 @@ class Cronjob extends CommonObject $result=$user->fetch('', $userlogin); if ($result<0) { - $this->error="User Error:".$user->error; + $this->error="User Error : ".$user->error; dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); return -1; } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 45146324e32..b05e94cccfa 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1023,12 +1023,12 @@ class Holiday extends CommonObject * Warning: It consumes a lot of memory because it load in ->holiday all holiday of a dedicated user at each call. * * @param int $fk_user Id user - * @param date $dateStart Start date of period to check - * @param date $dateEnd End date of period to check + * @param integer $dateStart Start date of period to check + * @param integer $dateEnd End date of period to check * @param int $halfday Tag to define how start and end the period to check: * 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning * @return boolean False = New range overlap an existing holiday, True = no overlapping (is never on holiday during checked period). - * @see verifDateHolidayForTimestamp + * @see verifDateHolidayForTimestamp() */ public function verifDateHolidayCP($fk_user, $dateStart, $dateEnd, $halfday = 0) { @@ -1107,10 +1107,10 @@ class Holiday extends CommonObject * Check that a user is not on holiday for a particular timestamp * * @param int $fk_user Id user - * @param timestamp $timestamp Time stamp date for a day (YYYY-MM-DD) without hours (= 12:00AM in english and not 12:00PM that is 12:00) + * @param integer $timestamp Time stamp date for a day (YYYY-MM-DD) without hours (= 12:00AM in english and not 12:00PM that is 12:00) * @param string $status Filter on holiday status. '-1' = no filter. * @return array array('morning'=> ,'afternoon'=> ), Boolean is true if user is available for day timestamp. - * @see verifDateHolidayCP + * @see verifDateHolidayCP() */ public function verifDateHolidayForTimestamp($fk_user, $timestamp, $status = '-1') { @@ -1222,7 +1222,7 @@ class Holiday extends CommonObject * * @param int $statut id statut * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @param date $startdate Date holiday should start + * @param integer $startdate Date holiday should start * @return string Label */ public function LibStatut($statut, $mode = 0, $startdate = '') From fd1e917edc212bb1d1e82177c20405af0dbc3a2b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 18:14:46 +0100 Subject: [PATCH 114/179] Implement fetchLines in BOM --- htdocs/bom/class/bom.class.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index ec695e05637..97e858ed430 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -289,6 +289,24 @@ class BOM extends CommonObject $this->lines=array(); // Load lines with object BOMLine + $sql = 'SELECT rowid, fk_product, description, qty, rank WHERE fk_bom = '.$this->id; + + $resql=$this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj) + { + $newline = new BOMLine($this->db); + $newline->id = $obj->rowid; + $newline->fk_product = $obj->fk_product; + $newline->description = $obj->description; + $newline->qty = $obj->qty; + $newline->rank = $obj->rank; + + $this->lines[] = $newline; + } + } return count($this->lines)?1:0; } From 6ecd37ea8fbc13fc03ae6300a05408b451a65db1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 18:16:25 +0100 Subject: [PATCH 115/179] WIP Clean code of BOM --- htdocs/bom/class/bom.class.php | 61 ---------------------------------- 1 file changed, 61 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 97e858ed430..72984c33504 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -964,36 +964,6 @@ class BOMLine extends CommonObject // END MODULEBUILDER PROPERTIES - - // If this object has a subtable with lines - - /** - * @var int Name of subtable line - */ - //public $table_element_line = 'bomlinedet'; - - /** - * @var int Field with ID of parent key if this field has a parent - */ - //public $fk_element = 'fk_bomline'; - - /** - * @var int Name of subtable class that manage subtable lines - */ - //public $class_element_line = 'BillOfMaterialsLineline'; - - /** - * @var array Array of child tables (child tables to delete before deleting a record) - */ - //protected $childtables=array('bomlinedet'); - - /** - * @var BillOfMaterialsLineLine[] Array of subtable lines - */ - //public $lines = array(); - - - /** * Constructor * @@ -1426,35 +1396,4 @@ class BOMLine extends CommonObject { $this->initAsSpecimenCommon(); } - - - /** - * Action executed by scheduler - * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' - * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) - */ - //public function doScheduledJob($param1, $param2, ...) - public function doScheduledJob() - { - global $conf, $langs; - - //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; - - $error = 0; - $this->output = ''; - $this->error=''; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $now = dol_now(); - - $this->db->begin(); - - // ... - - $this->db->commit(); - - return $error; - } } From c0b6699b253dbcc8aeba51bc90e3d4f1a9323e32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 19:01:40 +0100 Subject: [PATCH 116/179] All methods set_draft() were renamed into setDraft() --- ChangeLog | 1 + htdocs/bom/class/bom.class.php | 2 -- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/class/api_proposals.class.php | 2 +- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/commande/class/api_orders.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/class/api_invoices.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/reception/card.php | 2 +- htdocs/reception/class/reception.class.php | 2 +- htdocs/supplier_proposal/card.php | 2 +- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- htdocs/webservices/server_invoice.php | 2 +- 18 files changed, 17 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index c931f9ea865..efc1be2c344 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ Following changes may create regressions for some external modules, but were nec * Deprecated function img_phone as been removed. You can use img_picto(..., 'call|call_out') instead.; * Files for variables of themes were renamed from graph-color.php into theme_vars.inc.php to match naming convention of extension .inc.php for files to be included. +* All methods set_draft() were renamed into setDraft(). ***** ChangeLog for 9.0.1 compared to 9.0.0 ***** diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 72984c33504..039c41309c9 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -595,7 +595,6 @@ class BOM extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -604,7 +603,6 @@ class BOM extends CommonObject */ public function setDraft($user) { - //phpcs:enable global $conf,$langs; $error=0; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 44c05629744..9a296def86b 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -790,7 +790,7 @@ if (empty($reshook)) // Go back to draft if ($action == 'modif' && $usercancreate) { - $object->set_draft($user); + $object->setDraft($user); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 9145b8eb151..30a8e03cbd3 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -593,7 +593,7 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->propal->set_draft(DolibarrApiAccess::$user); + $result = $this->propal->setDraftDolibarrApiAccess::$user); if ($result == 0) { throw new RestException(304, 'Nothing done. May be object is already draft'); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index e0ad01a453b..fd9187afb9c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2605,7 +2605,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function set_draft($user, $notrigger = 0) + public function setDraft($user, $notrigger = 0) { // phpcs:enable $error=0; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 65dba5049f4..f85870bd6f1 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1219,7 +1219,7 @@ if (empty($reshook)) } if (! $error) { - $result = $object->set_draft($user, $idwarehouse); + $result = $object->setDraft($user, $idwarehouse); if ($result >= 0) { // Define output language diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index ca7823a6ac1..777236bc4d8 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -770,7 +770,7 @@ class Orders extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->commande->set_draft(DolibarrApiAccess::$user, $idwarehouse); + $result = $this->commande->setDraftDolibarrApiAccess::$user, $idwarehouse); if ($result == 0) { throw new RestException(304, 'Nothing done. May be object is already closed'); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7dc13b5a97e..a92bfe23eb8 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -479,7 +479,7 @@ class Commande extends CommonOrder * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on) * @return int <0 if KO, >0 if OK */ - public function set_draft($user, $idwarehouse = -1) + public function setDraft($user, $idwarehouse = -1) { //phpcs:enable global $conf,$langs; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e3fea0200dc..ac34b6f3491 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -621,7 +621,7 @@ if (empty($reshook)) { if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) { - $result=$object->set_draft($user, $idwarehouse); + $result=$object->setDraft($user, $idwarehouse); if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); // Define output language diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index d68c3d40338..cbaf2115c3e 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -745,7 +745,7 @@ class Invoices extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->invoice->set_draft(DolibarrApiAccess::$user, $idwarehouse); + $result = $this->invoice->setDraftDolibarrApiAccess::$user, $idwarehouse); if ($result == 0) { throw new RestException(304, 'Nothing done.'); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a87cd25cdf6..6076cbb6232 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2537,7 +2537,7 @@ class Facture extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - public function set_draft($user, $idwarehouse = -1) + public function setDraft($user, $idwarehouse = -1) { // phpcs:enable global $conf,$langs; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 690acedb35d..aa914b54894 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1458,7 +1458,7 @@ class FactureFournisseur extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - public function set_draft($user, $idwarehouse = -1) + public function setDraft($user, $idwarehouse = -1) { // phpcs:enable global $conf,$langs; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 71abab3a065..c2a5552f15e 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1446,7 +1446,7 @@ if (empty($reshook)) } } - $object->set_draft($user, $idwarehouse); + $object->setDraft($user, $idwarehouse); // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index dfe1eb5e2e6..2c41e2af570 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -144,7 +144,7 @@ if (empty($reshook)) // Confirm back to draft status if ($action == 'modif' && $user->rights->reception->creer) { - $result = $object->set_draft($user); + $result = $object->setDraft($user); if ($result >= 0) { // Define output language diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 607d1cc25f3..29bd65f6ae0 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1771,7 +1771,7 @@ class Reception extends CommonObject * @param User $user Object user that modify * @return int <0 if KO, >0 if OK */ - public function set_draft($user) + public function setDraft($user) { // phpcs:enable global $conf,$langs; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index d5370a7361e..c119ba2d488 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -491,7 +491,7 @@ if (empty($reshook)) // Go back to draft if ($action == 'modif' && $user->rights->supplier_proposal->creer) { - $object->set_draft($user); + $object->setDraft($user); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 24ce18bf676..3aba8afccc1 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1878,7 +1878,7 @@ class SupplierProposal extends CommonObject * @param User $user Object user that modify * @return int <0 if KO, >0 if OK */ - public function set_draft($user) + public function setDraft($user) { // phpcs:enable global $conf,$langs; diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index a0d96e8b008..60c93c488e7 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -777,7 +777,7 @@ dol_syslog("Function: updateInvoice login=".$authentication['login']." id=".$inv { if ($invoice['status'] == Facture::STATUS_DRAFT) { - $result = $object->set_draft($fuser); + $result = $object->setDraft($fuser); } if ($invoice['status'] == Facture::STATUS_VALIDATED) { From a1adcc785ce56ff53395585c35ae77fd2cd0c68c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 19:11:24 +0100 Subject: [PATCH 117/179] Clean code --- htdocs/core/class/cunits.class.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 0e3987da516..861d7f737bb 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -93,29 +93,22 @@ class CUnits // extends CommonObject if (isset($this->unit_type)) $this->active=trim($this->unit_type); if (isset($this->active)) $this->active=trim($this->active); - - // Check parameters // Put here code to add control on parameters values // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_units("; - $sql.= "rowid,"; $sql.= "code,"; $sql.= "label,"; $sql.= "short_label,"; $sql.= "unit_type"; - - $sql.= ") VALUES ("; - $sql.= " ".(! isset($this->id)?'NULL':"'".$this->db->escape($this->id)."'").","; $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; $sql.= " ".(! isset($this->short_label)?'NULL':"'".$this->db->escape($this->short_label)."'").","; $sql.= " ".(! isset($this->unit_type)?'NULL':"'".$this->db->escape($this->unit_type)."'"); - $sql.= ")"; $this->db->begin(); @@ -187,7 +180,6 @@ class CUnits // extends CommonObject if ($unit_type) $sql_where[]= " t.unit_type = '".$this->db->escape($unit_type)."'"; if ($code) $sql_where[]= " t.code = '".$this->db->escape($code)."'"; if ($short_label) $sql_where[]= " t.short_label = '".$this->db->escape($short_label)."'"; - if (count($sql_where)>0) { $sql.=' WHERE '. implode(' AND ', $sql_where); } @@ -322,7 +314,6 @@ class CUnits // extends CommonObject if (isset($this->unit_type)) $this->libelle=trim($this->unit_type); if (isset($this->active)) $this->active=trim($this->active); - // Check parameters // Put here code to add control on parameters values From b33c366b0227f9f185a9664b4eea55fb3045c802 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 19:16:49 +0100 Subject: [PATCH 118/179] Update card.php --- htdocs/compta/facture/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index dcf167da515..43f727a7ae8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1218,8 +1218,7 @@ if (empty($reshook)) foreach ($amountdeposit as $tva => $amount) { - - if(empty($amount)) continue; + if (empty($amount)) continue; $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); $descline = $langs->trans('Deposit'); From 5027a36dfb4157c6abee50c64536886b2da2360f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 19:34:04 +0100 Subject: [PATCH 119/179] Fix missing transaction on add_commercial method. --- htdocs/societe/class/societe.class.php | 60 +++++++++++++++++++------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 60790698b24..d0f7c012f83 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1939,40 +1939,68 @@ class Societe extends CommonObject * * @param User $user Object user * @param int $commid Id of user - * @return int <0 if KO, >0 if OK + * @return int <=0 if KO, >0 if OK */ public function add_commercial(User $user, $commid) { - // phpcs:enable + // phpcs:enable $error=0; - if ($this->id > 0 && $commid > 0) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; - $sql.= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; + $this->db->begin(); - $this->db->query($sql); + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; + $sql.= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_commerciaux"; - $sql.= " ( fk_soc, fk_user )"; - $sql.= " VALUES (".$this->id.",".$commid.")"; + $resql = $this->db->query($sql); + if (! $resql) + { + dol_syslog(get_class($this)."::add_commercial Error ".$this->db->lasterror()); + $error++; + } + } - if (! $this->db->query($sql) ) + if (! $error) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_commerciaux"; + $sql.= " (fk_soc, fk_user)"; + $sql.= " VALUES (".$this->id.", ".$commid.")"; + + $resql = $this->db->query($sql); + if (! $resql) + { + dol_syslog(get_class($this)."::add_commercial Error ".$this->db->lasterror()); + $error++; + } + } + + if (! $error) { - dol_syslog(get_class($this)."::add_commercial Erreur"); - return -2; - } - else { $this->context=array('commercial_modified'=>$commid); $result=$this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE', $user); - if ($result < 0) return $result; + if ($result < 0) + { + $error++; + } + } + if (! $error) + { + $this->db->commit(); return 1; } + else + { + $this->db->rollback(); + return -1; + } } - return -1; + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps From af6508b1c8669e03268aa861ca02cc52bf795b19 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 20:06:05 +0100 Subject: [PATCH 120/179] FIX Bad label of status for members (must be short version in list) --- htdocs/adherents/class/adherent.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index d4b77342c84..7f7cf0da90c 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -587,7 +587,7 @@ class Adherent extends CommonObject } } } - + dol_syslog(get_class($this)."::update update member", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -2149,7 +2149,7 @@ class Adherent extends CommonObject * @param int $statut Id statut * @param int $need_subscription 1 if member type need subscription, 0 otherwise * @param int $date_end_subscription Date fin adhesion - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ public function LibStatut($statut, $need_subscription, $date_end_subscription, $mode = 0) @@ -2209,7 +2209,7 @@ class Adherent extends CommonObject } elseif ($mode == 5) { - if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); + if ($statut == -1) return $langs->trans("MemberStatusDraftShort").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); elseif ($statut >= 1) { if (! $date_end_subscription) return ''.$langs->trans("MemberStatusActiveShort").' '.img_picto($langs->trans('MemberStatusActive'), 'statut1'); elseif ($date_end_subscription < time()) return ''.$langs->trans("MemberStatusActiveLateShort").' '.img_picto($langs->trans('MemberStatusActiveLate'), 'statut3'); From 04424ed8822a3d5dea2779edf72ca7aa1147ea66 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 20:06:05 +0100 Subject: [PATCH 121/179] FIX Bad label of status for members (must be short version in list) Conflicts: htdocs/adherents/class/adherent.class.php --- htdocs/adherents/class/adherent.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 47526d7cf70..3c2f1366464 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -578,7 +578,7 @@ class Adherent extends CommonObject } } } - + dol_syslog(get_class($this)."::update update member", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -2131,7 +2131,7 @@ class Adherent extends CommonObject * @param int $statut Id statut * @param int $need_subscription 1 if member type need subscription, 0 otherwise * @param int $date_end_subscription Date fin adhesion - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ function LibStatut($statut,$need_subscription,$date_end_subscription,$mode=0) @@ -2191,7 +2191,7 @@ class Adherent extends CommonObject } elseif ($mode == 5) { - if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'),'statut0'); + if ($statut == -1) return $langs->trans("MemberStatusDraftShort").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); elseif ($statut >= 1) { if (! $date_end_subscription) return ''.$langs->trans("MemberStatusActiveShort").' '.img_picto($langs->trans('MemberStatusActive'),'statut1'); elseif ($date_end_subscription < time()) return ''.$langs->trans("MemberStatusActiveLateShort").' '.img_picto($langs->trans('MemberStatusActiveLate'),'statut3'); From bede7b80a253075e36769df85ac6eb0e93aa8236 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 20:09:42 +0100 Subject: [PATCH 122/179] Fix smartphone --- htdocs/adherents/class/adherent.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 7f7cf0da90c..912132631f6 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2209,7 +2209,7 @@ class Adherent extends CommonObject } elseif ($mode == 5) { - if ($statut == -1) return $langs->trans("MemberStatusDraftShort").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); + if ($statut == -1) return ''.$langs->trans("MemberStatusDraftShort").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); elseif ($statut >= 1) { if (! $date_end_subscription) return ''.$langs->trans("MemberStatusActiveShort").' '.img_picto($langs->trans('MemberStatusActive'), 'statut1'); elseif ($date_end_subscription < time()) return ''.$langs->trans("MemberStatusActiveLateShort").' '.img_picto($langs->trans('MemberStatusActiveLate'), 'statut3'); @@ -2219,7 +2219,7 @@ class Adherent extends CommonObject } elseif ($mode == 6) { - if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); + if ($statut == -1) return ''.$langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); if ($statut >= 1) { if (! $date_end_subscription) return ''.$langs->trans("MemberStatusActive").' '.img_picto($langs->trans('MemberStatusActive'), 'statut1'); elseif ($date_end_subscription < time()) return ''.$langs->trans("MemberStatusActiveLate").' '.img_picto($langs->trans('MemberStatusActiveLate'), 'statut3'); From d512e5440740357d8b16f4d7a1054177ef4caa4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 20:10:39 +0100 Subject: [PATCH 123/179] Restore toggle of login_block because it was no more visible --- htdocs/core/lib/functions.lib.php | 3 ++- htdocs/main.inc.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f36901512f1..ded5f2376c8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7194,7 +7194,8 @@ function printCommonFooter($zone = 'private') print 'jQuery(".menuhider").click(function(event) {'; print ' if(!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'."\n"; print ' console.log("We click on .menuhider");'."\n"; - print " $('body').toggleClass('sidebar-collapse')\n"; + print ' $("body").toggleClass("sidebar-collapse")'."\n"; + print ' $(".login_block").toggle()'."\n"; print '});'."\n"; } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6fbad81780a..a473f9a5abd 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1099,7 +1099,7 @@ if (! function_exists("llxHeader")) if ($conf->browser->layout == 'phone'){ $morecssonbody.= ' sidebar-collapse'; } - + print '' . "\n"; // top menu and left menu area @@ -1987,7 +1987,7 @@ function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinpu global $conf,$langs,$user; $ret=''; - $ret.='
    '; + $ret.=''; $ret.=''; $ret.=''; $ret.=''; From b6cacf3a20c8227b2da80af1d972e51cfb11a76e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 20:18:35 +0100 Subject: [PATCH 124/179] Fix label of status for members on smartphone --- htdocs/adherents/class/adherent.class.php | 10 +++++----- htdocs/core/lib/functions.lib.php | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 912132631f6..94fc1dc9e0e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2219,13 +2219,13 @@ class Adherent extends CommonObject } elseif ($mode == 6) { - if ($statut == -1) return ''.$langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); + if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); if ($statut >= 1) { - if (! $date_end_subscription) return ''.$langs->trans("MemberStatusActive").' '.img_picto($langs->trans('MemberStatusActive'), 'statut1'); - elseif ($date_end_subscription < time()) return ''.$langs->trans("MemberStatusActiveLate").' '.img_picto($langs->trans('MemberStatusActiveLate'), 'statut3'); - else return ''.$langs->trans("MemberStatusPaid").' '.img_picto($langs->trans('MemberStatusPaid'), 'statut4'); + if (! $date_end_subscription) return $langs->trans("MemberStatusActive").' '.img_picto($langs->trans('MemberStatusActive'), 'statut1'); + elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLate").' '.img_picto($langs->trans('MemberStatusActiveLate'), 'statut3'); + else return $langs->trans("MemberStatusPaid").' '.img_picto($langs->trans('MemberStatusPaid'), 'statut4'); } - if ($statut == 0) return ''.$langs->trans("MemberStatusResiliated").' '.img_picto($langs->trans('MemberStatusResiliated'), 'statut5'); + if ($statut == 0) return $langs->trans("MemberStatusResiliated").' '.img_picto($langs->trans('MemberStatusResiliated'), 'statut5'); } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ded5f2376c8..6814fc6d0ec 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1501,6 +1501,10 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi if ($object->statut == 0) $morehtmlstatus.=$object->getLibStatut(5); else $morehtmlstatus.=$object->getLibStatut(4); } + elseif ($object->element == 'member') + { + $morehtmlstatus.=$object->getLibStatut(6); + } elseif ($object->element == 'facturerec') { if ($object->frequency == 0) $morehtmlstatus.=$object->getLibStatut(2); From f0796d152faceb7929fae2b3e67293151ae66a62 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2019 20:23:34 +0100 Subject: [PATCH 125/179] Responsive --- htdocs/adherents/list.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index bd5f70d0973..35e1fd1553f 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -436,23 +436,23 @@ if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) if (! empty($arrayfields['d.ref']['checked'])) { print '
    '; - print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; print ''; - print ''; - print ''; - print '
    DateMethodURLIPFilter data
    ').append(this.$table).appendTo(this.$el); + this.$actions = $('
    ').addClass(csscls('actions')).appendTo(this.$el); + + this.$closebtn.on('click', function() { + self.hide(); + }); + + this.$loadmorebtn = $('Load more') + .appendTo(this.$actions) + .on('click', function() { + self.find(self.last_find_request, self.last_find_request.offset + self.get('items_per_page'), self.handleFind.bind(self)); + }); + + this.$showonlycurrentbtn = $('Show only current URL') + .appendTo(this.$actions) + .on('click', function() { + self.$table.empty(); + self.find({uri: window.location.pathname}, 0, self.handleFind.bind(self)); + }); + + this.$showallbtn = $('Show all') + .appendTo(this.$actions) + .on('click', function() { + self.refresh(); + }); + + this.$clearbtn = $('Delete all') + .appendTo(this.$actions) + .on('click', function() { + self.clear(function() { + self.hide(); + }); + }); + + this.addSearch(); + + this.$overlay = $('
    ').addClass(csscls('overlay')).hide().appendTo('body'); + this.$overlay.on('click', function() { + self.hide(); + }); + }, + + refresh: function() { + this.$table.empty(); + this.$loadmorebtn.show(); + this.find({}, 0, this.handleFind.bind(this)); + }, + + addSearch: function(){ + var self = this; + var searchBtn = $('