From 2df7d79421da19d1cb7680e1f6139dd732b6c8d7 Mon Sep 17 00:00:00 2001 From: oscim Date: Thu, 9 Apr 2020 15:54:25 +0200 Subject: [PATCH 01/18] Update llx_societe.key.sql Add index in table for optimise search in big database --- htdocs/install/mysql/tables/llx_societe.key.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/install/mysql/tables/llx_societe.key.sql b/htdocs/install/mysql/tables/llx_societe.key.sql index eee239566e6..03358d2838b 100644 --- a/htdocs/install/mysql/tables/llx_societe.key.sql +++ b/htdocs/install/mysql/tables/llx_societe.key.sql @@ -26,5 +26,20 @@ ALTER TABLE llx_societe ADD UNIQUE INDEX uk_societe_barcode (barcode, fk_barcode ALTER TABLE llx_societe ADD INDEX idx_societe_user_creat(fk_user_creat); ALTER TABLE llx_societe ADD INDEX idx_societe_user_modif(fk_user_modif); +ALTER TABLE llx_societe ADD INDEX idx_societe_stcomm(fk_stcomm); +ALTER TABLE llx_societe ADD INDEX idx_societe_departement(fk_departement); +ALTER TABLE llx_societe ADD INDEX idx_societe_pays(fk_pays); +ALTER TABLE llx_societe ADD INDEX idx_societe_account(fk_account); +ALTER TABLE llx_societe ADD INDEX idx_societe_prospectlevel(fk_prospectlevel); +ALTER TABLE llx_societe ADD INDEX idx_societe_incoterms(fk_incoterms); +ALTER TABLE llx_societe ADD INDEX idx_societe_effectif(fk_effectif); +ALTER TABLE llx_societe ADD INDEX idx_societe_typent(fk_typent); +ALTER TABLE llx_societe ADD INDEX idx_societe_forme_juridique(fk_forme_juridique); +ALTER TABLE llx_societe ADD INDEX idx_societe_currency(fk_currency); +ALTER TABLE llx_societe ADD INDEX idx_societe_shipping_method(fk_shipping_method); +ALTER TABLE llx_societe ADD INDEX idx_societe_barcode_type(fk_barcode_type); +ALTER TABLE llx_societe ADD INDEX idx_societe_entrepot(fk_entrepot); +ALTER TABLE llx_societe ADD INDEX idx_societe_multicurrency(fk_multicurrency); -- ALTER TABLE llx_societe ADD FOREIGN KEY fk_prospectlevel llx_c_prospectlevel(code); + From d75f1138ba96a8616ae9239dcd022416d2853328 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Apr 2020 13:00:46 +0200 Subject: [PATCH 02/18] Fix phpcs --- htdocs/adherents/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index c6b14848185..0a9fc7cd2c6 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -108,7 +108,7 @@ $fieldstosearchall = array( 'd.town'=>'Town', 'd.phone'=>"Phone", 'd.phone_perso'=>"PhonePerso", - 'd.phone_mobile'=>"PhoneMobile"? + 'd.phone_mobile'=>"PhoneMobile", 'd.note_public'=>'NotePublic', 'd.note_private'=>'NotePrivate', ); From f7726cd3669e65b2174baf1a17416e6bd4c7ec50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Apr 2020 13:04:30 +0200 Subject: [PATCH 03/18] Try to disable a not expected rule --- dev/setup/codesniffer/ruleset.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 8bd3ff8b319..10d6e29bbe2 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -222,6 +222,9 @@ + + 0 + From 267677a925929d67586b3f280405d3daf9b84840 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Apr 2020 14:02:35 +0200 Subject: [PATCH 04/18] Fix phpcs --- htdocs/accountancy/class/lettering.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 1909a8cd074..d663e0ec9c4 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -168,7 +168,7 @@ class Lettering extends BookKeeping if ($object->code_compta_fournisseur != "") { $sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' "; } - $sql .= " ) "; + $sql .= " )"; $resql2 = $this->db->query($sql); if ($resql2) { @@ -217,7 +217,7 @@ class Lettering extends BookKeeping } if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::".__METHOD__.$errmsg, LOG_ERR); + dol_syslog(__METHOD__.' '.$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } return -1 * $error; @@ -237,8 +237,6 @@ class Lettering extends BookKeeping $error = 0; $lettre = 'AAA'; - dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); - $sql = "SELECT DISTINCT lettering_code FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; $sql .= " lettering_code != '' ORDER BY lettering_code DESC limit 1; "; From 0aab98abfff88a8f114d59a1386c90cfd758f6c4 Mon Sep 17 00:00:00 2001 From: philazerty Date: Fri, 10 Apr 2020 17:05:53 +0200 Subject: [PATCH 05/18] Index optimization for ticket When there are a lot of tickets, the search can be long without these indexes. --- htdocs/install/mysql/tables/llx_ticket.key.sql | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/install/mysql/tables/llx_ticket.key.sql b/htdocs/install/mysql/tables/llx_ticket.key.sql index 948eba45a83..28bf2a88188 100644 --- a/htdocs/install/mysql/tables/llx_ticket.key.sql +++ b/htdocs/install/mysql/tables/llx_ticket.key.sql @@ -15,3 +15,10 @@ -- along with this program. If not, see . ALTER TABLE llx_ticket ADD UNIQUE uk_ticket_track_id (track_id); +ALTER TABLE `llx_ticket` ADD UNIQUE `uk_ticket_ref` (`ref`); +ALTER TABLE `llx_ticket` ADD INDEX idx_ticket_entity (`entity`); +ALTER TABLE `llx_ticket` ADD INDEX idx_ticket_fk_soc (`fk_soc`); +ALTER TABLE `llx_ticket` ADD INDEX idx_ticket_fk_user_assign (`fk_user_assign`); +ALTER TABLE `llx_ticket` ADD INDEX idx_ticket_fk_project (`fk_project`); +ALTER TABLE `llx_ticket` ADD INDEX idx_ticket_fk_statut (`fk_statut`); + From 66659f0693e4301ddad7758960ed666493dcc4a4 Mon Sep 17 00:00:00 2001 From: "jove@bisquerra.com" Date: Fri, 10 Apr 2020 19:18:42 +0200 Subject: [PATCH 06/18] Two diferents order printers --- htdocs/core/class/dolreceiptprinter.class.php | 27 +++++++------------ htdocs/takepos/admin/terminal.php | 12 ++++++--- htdocs/takepos/invoice.php | 14 ++++++---- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 6ea04d4a548..f2099460d5b 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -49,8 +49,7 @@ * Print object total tax * Print object local tax * Print object total - * Print order lines for Printer1 - * Print order lines for Printer2 + * Print order lines for Printer * Print payment method * * Code which can be placed everywhere @@ -133,6 +132,12 @@ class dolReceiptPrinter extends Printer public $tags; public $printer; public $template; + + /** + * Number of order printer + * @var int + */ + public $orderprinter; /** * @var string Error code (or message) @@ -191,8 +196,7 @@ class dolReceiptPrinter extends Printer 'dol_print_object_local_tax', 'dol_print_object_total', 'dol_print_object_number', - 'dol_print_order_lines_printer1', - 'dol_print_order_lines_printer2', + 'dol_print_order_lines', 'dol_value_customer_firstname', 'dol_value_customer_lastname', 'dol_value_customer_mail', @@ -726,20 +730,9 @@ class dolReceiptPrinter extends Printer case 'DOL_BEEP': $this->printer->getPrintConnector() -> write("\x1e"); break; - case 'DOL_PRINT_ORDER_LINES_PRINTER1': + case 'DOL_PRINT_ORDER_LINES': foreach ($object->lines as $line) { - if ($line->special_code == 1) - { - $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); - $this->printer->text(strip_tags(htmlspecialchars_decode($line->desc))."\n"); - } - } - break; - case 'DOL_PRINT_ORDER_LINES_PRINTER2': - foreach ($object->lines as $line) { - if ($line->special_code == 2) + if ($line->special_code==$this->orderprinter) { $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; $spaces = str_repeat(' ', $spacestoadd); diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index c83f57173e5..10a679615a9 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -41,7 +41,7 @@ if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id'])) // Security check if (!$user->admin) accessforbidden(); -$langs->loadLangs(array("admin", "cashdesk")); +$langs->loadLangs(array("admin", "cashdesk", "printing")); global $db; @@ -85,6 +85,8 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "CASHDESK_ID_WAREHOUSE".$terminaltouse, (GETPOST('CASHDESK_ID_WAREHOUSE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminaltouse, GETPOST('CASHDESK_NO_DECREASE_STOCK'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_PRINTER_TO_USE".$terminaltouse, GETPOST('TAKEPOS_PRINTER_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER1_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER2_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); @@ -234,9 +236,13 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}), 1); print ''; if ($conf->global->TAKEPOS_ORDER_PRINTERS) { - print ''.$langs->trans("OrderPrinterToUse").''; + print ''.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 1'; print ''; - print $form->selectarray('TAKEPOS_ORDER_PRINTER_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER_TO_USE'.$terminal}), 1); + print $form->selectarray('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal}), 1); + print ''; + print ''.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 2'; + print ''; + print $form->selectarray('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}), 1); print ''; } $printer->listPrintersTemplates(); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 2e85f8c2afa..95766802b76 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -526,6 +526,7 @@ if ($action == "order" and $placeid != 0) $result = array_intersect($catsprinter1, $existing); $count = count($result); if ($count > 0) { + $linestoprint++; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1 $db->query($sql); $order_receipt_printer1 .= ''.$line->product_label.''.$line->qty; @@ -533,17 +534,18 @@ if ($action == "order" and $placeid != 0) $order_receipt_printer1 .= ''; } } - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $count > 0) { + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer - $ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 1 + $printer->orderprinter=1; + $ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_ORDER_PRINTER1_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 1 } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed $db->query($sql); $invoice->fetch($placeid); //Reload object after set lines as printed + $linestoprint=0; foreach ($invoice->lines as $line) { - $count=0; if ($line->special_code == "4") { continue; } @@ -552,6 +554,7 @@ if ($action == "order" and $placeid != 0) $result = array_intersect($catsprinter2, $existing); $count = count($result); if ($count > 0) { + $linestoprint++; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2 $db->query($sql); $order_receipt_printer2 .= ''.$line->product_label.''.$line->qty; @@ -559,9 +562,10 @@ if ($action == "order" and $placeid != 0) $order_receipt_printer2 .= ''; } } - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $count > 0) { + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer - $ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 2 + $printer->orderprinter=2; + $ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 2 } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed $db->query($sql); From bcbd7632bf662c4d84bce5e4b7f869099e26ad1a Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Fri, 10 Apr 2020 19:49:59 +0200 Subject: [PATCH 07/18] Fix travis --- htdocs/core/class/dolreceiptprinter.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index f2099460d5b..7c5f72e12c6 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -132,7 +132,7 @@ class dolReceiptPrinter extends Printer public $tags; public $printer; public $template; - + /** * Number of order printer * @var int From 6960f79e40f20df346296eb223e10b4fd7f182c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Apr 2020 19:59:45 +0200 Subject: [PATCH 08/18] Update llx_ticket.key.sql --- htdocs/install/mysql/tables/llx_ticket.key.sql | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_ticket.key.sql b/htdocs/install/mysql/tables/llx_ticket.key.sql index 28bf2a88188..d4805d8a788 100644 --- a/htdocs/install/mysql/tables/llx_ticket.key.sql +++ b/htdocs/install/mysql/tables/llx_ticket.key.sql @@ -15,10 +15,9 @@ -- along with this program. If not, see . ALTER TABLE llx_ticket ADD UNIQUE uk_ticket_track_id (track_id); -ALTER TABLE `llx_ticket` ADD UNIQUE `uk_ticket_ref` (`ref`); -ALTER TABLE `llx_ticket` ADD INDEX idx_ticket_entity (`entity`); -ALTER TABLE `llx_ticket` ADD INDEX idx_ticket_fk_soc (`fk_soc`); -ALTER TABLE `llx_ticket` ADD INDEX idx_ticket_fk_user_assign (`fk_user_assign`); -ALTER TABLE `llx_ticket` ADD INDEX idx_ticket_fk_project (`fk_project`); -ALTER TABLE `llx_ticket` ADD INDEX idx_ticket_fk_statut (`fk_statut`); - +ALTER TABLE llx_ticket ADD UNIQUE uk_ticket_ref (ref, entity); +ALTER TABLE llx_ticket ADD INDEX idx_ticket_entity (entity); +ALTER TABLE llx_ticket ADD INDEX idx_ticket_fk_soc (fk_soc); +ALTER TABLE llx_ticket ADD INDEX idx_ticket_fk_user_assign (fk_user_assign); +ALTER TABLE llx_ticket ADD INDEX idx_ticket_fk_project (fk_project); +ALTER TABLE llx_ticket ADD INDEX idx_ticket_fk_statut (fk_statut); From eb3ed7ffdfd58b260455da10f945186a8c91c240 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Apr 2020 20:02:57 +0200 Subject: [PATCH 09/18] Complete index on tickets --- htdocs/install/mysql/migration/11.0.0-12.0.0.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index faa10f15950..91361d76ec6 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -73,6 +73,14 @@ ALTER TABLE llx_holiday_users ADD UNIQUE INDEX uk_holiday_users(fk_user, fk_type ALTER TABLE llx_ticket ADD COLUMN import_key varchar(14); +ALTER TABLE llx_ticket ADD UNIQUE uk_ticket_ref (ref, entity); +ALTER TABLE llx_ticket ADD INDEX idx_ticket_entity (entity); +ALTER TABLE llx_ticket ADD INDEX idx_ticket_fk_soc (fk_soc); +ALTER TABLE llx_ticket ADD INDEX idx_ticket_fk_user_assign (fk_user_assign); +ALTER TABLE llx_ticket ADD INDEX idx_ticket_fk_project (fk_project); +ALTER TABLE llx_ticket ADD INDEX idx_ticket_fk_statut (fk_statut); + + --ALTER TABLE llx_facturerec DROP COLUMN vat_src_code; From db30f0bbc4b5188107d006b75c0cf4287173c16b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Apr 2020 00:56:18 +0200 Subject: [PATCH 10/18] NEW Receipt printer module moved from 'development' to 'experimental' --- htdocs/core/modules/modReceiptPrinter.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index c36d8f2bc77..47f62a21b08 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -53,7 +53,7 @@ class modReceiptPrinter extends DolibarrModules // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "ReceiptPrinterDesc"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version - $this->version = 'development'; + $this->version = 'experimental'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' From 47f00f8bc8633b2900d3f94c51e229686c301ec7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Apr 2020 01:31:03 +0200 Subject: [PATCH 11/18] Update llx_societe.key.sql Keep only fields that are enough discriminent for new indexes --- htdocs/install/mysql/tables/llx_societe.key.sql | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_societe.key.sql b/htdocs/install/mysql/tables/llx_societe.key.sql index 03358d2838b..494874884fc 100644 --- a/htdocs/install/mysql/tables/llx_societe.key.sql +++ b/htdocs/install/mysql/tables/llx_societe.key.sql @@ -27,19 +27,13 @@ ALTER TABLE llx_societe ADD INDEX idx_societe_user_creat(fk_user_creat); ALTER TABLE llx_societe ADD INDEX idx_societe_user_modif(fk_user_modif); ALTER TABLE llx_societe ADD INDEX idx_societe_stcomm(fk_stcomm); -ALTER TABLE llx_societe ADD INDEX idx_societe_departement(fk_departement); ALTER TABLE llx_societe ADD INDEX idx_societe_pays(fk_pays); ALTER TABLE llx_societe ADD INDEX idx_societe_account(fk_account); ALTER TABLE llx_societe ADD INDEX idx_societe_prospectlevel(fk_prospectlevel); -ALTER TABLE llx_societe ADD INDEX idx_societe_incoterms(fk_incoterms); -ALTER TABLE llx_societe ADD INDEX idx_societe_effectif(fk_effectif); ALTER TABLE llx_societe ADD INDEX idx_societe_typent(fk_typent); ALTER TABLE llx_societe ADD INDEX idx_societe_forme_juridique(fk_forme_juridique); -ALTER TABLE llx_societe ADD INDEX idx_societe_currency(fk_currency); ALTER TABLE llx_societe ADD INDEX idx_societe_shipping_method(fk_shipping_method); -ALTER TABLE llx_societe ADD INDEX idx_societe_barcode_type(fk_barcode_type); ALTER TABLE llx_societe ADD INDEX idx_societe_entrepot(fk_entrepot); -ALTER TABLE llx_societe ADD INDEX idx_societe_multicurrency(fk_multicurrency); -- ALTER TABLE llx_societe ADD FOREIGN KEY fk_prospectlevel llx_c_prospectlevel(code); From d8e00368176e5086e7a227838da5bedbc953b822 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Apr 2020 12:41:53 +0200 Subject: [PATCH 12/18] css --- htdocs/admin/ihm.php | 18 +++++++------- htdocs/core/lib/usergroups.lib.php | 2 +- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 38 +++++++++++++++++++++++++++++- htdocs/theme/md/theme_vars.inc.php | 2 +- 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 2f33b3ab49b..0bb16b3cbd6 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -241,9 +241,9 @@ print ''; clearstatcache(); print '
'; -print ''; -print ''; -print ''; +print '
'.$langs->trans("Language").' 
'; +print ''; +print ''; // Default language @@ -268,9 +268,9 @@ showSkins(null, 1); print '
'; // Other -print '
'.$langs->trans("Language").' '; print '
'; -print ''; -print ''; +print '
'.$langs->trans("Miscellaneous").' 
'; +print ''; +print ''; // Disable javascript and ajax @@ -385,9 +385,9 @@ print '
'; // Other print '
'; -print '
'.$langs->trans("Miscellaneous").' '; print '
'; -print ''; -print ''; +print '
'.$langs->trans("LoginPage").' 
'; +print ''; +print ''; print ''; // Message on login page diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index bc20612c747..f3e7cee141d 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -331,7 +331,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) if ($foruserprofile) $colspan = 4; $thumbsbyrow = 6; - print '
'.$langs->trans("LoginPage").' 
'; + print '
'; // Title if ($foruserprofile) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 32c1a2d5bfb..8f3b7325b2a 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1724,7 +1724,7 @@ div#id-top { display:none; background: var(--colorbackhmenu1); - background-image: linear-gradient(-45deg, , var(--colorbackhmenu1)); + /* background-image: linear-gradient(-45deg, , var(--colorbackhmenu1)); */ /* box-shadow: 0px 0px 5px #eee; */ } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index edc28e7b87e..94f63228126 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -229,6 +229,42 @@ print '*/'."\n"; /* Default styles */ /* ============================================================================== */ +:root { + --colorbackhmenu1: rgb(); + --colorbackvmenu1: rgb(); + --colorbacktitle1: rgb(); + --colorbacktabcard1: rgb(); + --colorbacktabactive: rgb(); + --colorbacklineimpair1: rgb(); + --colorbacklineimpair2: rgb(); + --colorbacklinepair1: rgb(); + --colorbacklinepair2: rgb(); + --colorbacklinepairhover: rgb(); + --colorbacklinepairchecked: rgb(); + --colorbackbody: rgb(); + --colortexttitlenotab: rgb(); + --colortexttitle: rgb(); + --colortext: rgb(); + --colortextlink: rgb(); + --colortextbackhmenu: #; + --colortextbackvmenu: #; + --listetotal: #551188; + --inputbackgroundcolor: #FFF; + --inputbordercolor: rgba(0,0,0,.2); + --tooltipbgcolor: ; + --tooltipfontcolor : ; + --oddevencolor: #202020; + --colorboxstatsborder: #ddd; + --dolgraphbg: rgba(255,255,255,0); + --fieldrequiredcolor: #000055; + --colortextbacktab: #; + --colorboxiconbg: #eee; + --refidnocolor:#444; + --tableforfieldcolor:#666; + --amountremaintopaycolor:#880000; + --amountpaymentcomplete:#008800; + --amountremaintopaybackcolor:none; +} body { @@ -3846,7 +3882,7 @@ div.titre { } div.titre, .secondary { font-family: ; - color: rgb(); + color: var(--colortexttitlenotab); } table.centpercent.notopnoleftnoright.table-fiche-title { diff --git a/htdocs/theme/md/theme_vars.inc.php b/htdocs/theme/md/theme_vars.inc.php index 106a4b5b854..d15444acb6c 100644 --- a/htdocs/theme/md/theme_vars.inc.php +++ b/htdocs/theme/md/theme_vars.inc.php @@ -63,7 +63,7 @@ $colorbacklinepairhover = '230,237,244'; // line hover $colorbacklinepairchecked = '230,237,244'; // line checked $colorbacklinebreak = '214,218,220'; $colorbackbody = '248,248,248'; -$colortexttitlenotab = '90,90,90'; +$colortexttitlenotab = '80,71,5'; $colortexttitle = '20,20,20'; $colortext = '0,0,0'; $colortextlink = '0,0,120'; From 1ed24d394977be8b201ebba7f4ccef3f4a3d866d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Apr 2020 12:42:08 +0200 Subject: [PATCH 13/18] Fix trans --- htdocs/langs/en_US/products.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 602b3b9fb53..f31118ab8d7 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -167,7 +167,7 @@ SuppliersPrices=Vendor prices SuppliersPricesOfProductsOrServices=Vendor prices (of products or services) CustomCode=Customs / Commodity / HS code CountryOrigin=Origin country -Nature=Nature of produt (material/finished) +Nature=Nature of product (material/finished) ShortLabel=Short label Unit=Unit p=u. From 760121a3d1aa05157e73e329ff5600d2e1db4cbe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Apr 2020 14:13:16 +0200 Subject: [PATCH 14/18] Can sort list of answers. --- htdocs/compta/bank/transfer.php | 2 +- htdocs/core/lib/functions.lib.php | 6 +++--- htdocs/projet/index.php | 4 ++-- htdocs/theme/eldy/global.inc.php | 11 +++++++---- htdocs/website/index.php | 22 ++++++++++++++-------- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index cb6073f1109..afc1c6711e0 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -231,7 +231,7 @@ if ($error) print load_fiche_titre($langs->trans("MenuBankInternalTransfer"), '', 'bank_account'); -print $langs->trans("TransferDesc"); +print ''.$langs->trans("TransferDesc").''; print "

"; print '
'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b40985edff0..de8c73db44a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3234,7 +3234,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'hrm'=>'bg-infoxbox-adherent', 'group'=>'bg-infoxbox-adherent', 'members'=>'bg-infoxbox-adherent', 'member'=>'bg-infoxbox-adherent', 'user'=>'bg-infoxbox-adherent', 'users'=>'bg-infoxbox-adherent', 'error'=>'pictoerror', 'warning'=>'pictowarning', 'switch_on'=>'font-status4', - 'holiday'=>'bg-infoxbox-holiday', 'resource'=>'bg-infoxbox-action', 'title_hrm'=>'bg-infoxbox-holiday', 'trip'=>'bg-infoxbox-expensereport', + 'holiday'=>'bg-infoxbox-holiday', 'project'=>'bg-infoxbox-project', 'resource'=>'bg-infoxbox-action', 'title_hrm'=>'bg-infoxbox-holiday', 'trip'=>'bg-infoxbox-expensereport', 'title_agenda'=>'bg-infoxbox-action', 'list-alt'=>'imgforviewmode', 'calendar'=>'imgforviewmode', 'calendarweek'=>'imgforviewmode', 'calendarmonth'=>'imgforviewmode', 'calendarday'=>'imgforviewmode', 'calendarperuser'=>'imgforviewmode' ); @@ -4247,7 +4247,7 @@ function load_fiche_titre($titre, $morehtmlright = '', $picto = 'generic', $pict $return .= "\n"; $return .= '
'; // maring bottom must be same than into print_barre_list $return .= ''; - if ($picto) $return .= ''; + if ($picto) $return .= ''; $return .= ''; @@ -4313,7 +4313,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', // Left - if ($picto && $titre) print ''; + if ($picto && $titre) print ''; print '
'.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).''.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).''; $return .= '
'.$titre.'
'; $return .= '
'.img_picto('', $picto, 'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).''.img_picto('', $picto, 'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).''; print '
'.$titre; if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') print '('.$totalnboflines.')'; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 26dcf788714..17a92e99cd0 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -260,8 +260,8 @@ $companystatic = new Societe($db); // We need a clean new object for next loop b print '
'; print ''; print ''; -print_liste_field_titre("OpenedProjectsByThirdparties", $_SERVER["PHP_SELF"], "s.nom", "", "", '', $sortfield, $sortorder); -print_liste_field_titre("NbOfProjects", "", "", "", "", '', $sortfield, $sortorder, 'right '); +print_liste_field_titre("OpenedProjectsByThirdparties", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder); +print_liste_field_titre("NbOfProjects", $_SERVER["PHP_SELF"], "nb", "", "", '', $sortfield, $sortorder, 'right '); print "\n"; $sql = "SELECT COUNT(p.rowid) as nb, SUM(p.opp_amount)"; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 8f3b7325b2a..4e77fc7fe2d 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -24,7 +24,7 @@ --colortextlink: rgb(); --colortextbackhmenu: #; --colortextbackvmenu: #; - --listetotal: #551188; + --listetotal: #888888; --inputbackgroundcolor: #FFF; --inputbordercolor: rgba(0,0,0,.2); --tooltipbgcolor: ; @@ -1455,6 +1455,9 @@ body.onlinepaymentbody div.fiche { /* For online payment page */ div.fiche>table:first-child { margin-bottom: 15px !important; } +div.fiche>table.table-fiche-title { + margin-bottom: 7px !important; +} div.fichecenter { width: 100%; clear: both; /* This is to have div fichecenter that are true rectangles */ @@ -1568,9 +1571,9 @@ div.nopadding { margin : 0px auto; } -td.nobordernopadding.widthpictotitle.opacityhigh.valignmiddle.col-picto { +td.nobordernopadding.widthpictotitle.col-picto { color: var(--colortexttitlenotab); - opacity: 0.6; + opacity: 0.7; } .pictotitle { margin-: 8px; @@ -2606,7 +2609,7 @@ div.tabBar { div.tabBar tr.titre td { padding-top: 20px; } -div.fiche tr.titre td { +div.fiche table:not(.table-fiche-title) tr.titre td { padding-top: 10px; } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 59da26083ed..6e290e28eca 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3410,7 +3410,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print ''."\n"; print '

'; - print load_fiche_titre($langs->trans("ReplaceWebsiteContent")); + print load_fiche_titre($langs->trans("ReplaceWebsiteContent"), '', 'search'); print '
'; @@ -3447,7 +3447,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') if (GETPOST('optioncontent')) $algo .= 'content'; if (GETPOST('optionsitefiles')) $algo .= 'sitefiles'; - $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000); + $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000, $sortfield, $sortorder); print '
'; print '
'; @@ -3471,13 +3471,19 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print '
'; } + $param = 'action=replacesiteconfirm&website='.urlencode($website->ref); + $param .= '&searchstring='.urlencode($searchkey); + if (GETPOST('optioncontent')) $param .= '&optioncontent=content'; + if (GETPOST('optionmeta')) $param .= '&optionmeta=meta'; + if (GETPOST('optionsitefiles')) $param .= '&optionsitefiles=optionsitefiles'; + print '
'; print '
'; print ''; - print ''; - print ''; - print ''; - print ''; + print getTitleFieldOfList("Type", 0, $_SERVER['PHP_SELF'], 'type_container', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList("Link", 0, $_SERVER['PHP_SELF'], 'title', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList("Description", 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList("", 0 , $_SERVER['PHP_SELF']); print ''; foreach ($listofpages['list'] as $answerrecord) @@ -3485,7 +3491,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') if (get_class($answerrecord) == 'WebsitePage') { print ''; - print ''; print ''; print ''; } From 4c515f726fcb720ac908806d0977d7f2e0cd5c16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Apr 2020 14:18:09 +0200 Subject: [PATCH 15/18] Can sort list of answers. --- htdocs/website/index.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 6e290e28eca..e89409190be 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3447,6 +3447,10 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') if (GETPOST('optioncontent')) $algo .= 'content'; if (GETPOST('optionsitefiles')) $algo .= 'sitefiles'; + if (empty($sortfield)) { + $sortfield = 'pageurl'; $sortorder = 'ASC'; + } + $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000, $sortfield, $sortorder); print '
'; @@ -3481,7 +3485,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print '
'.$langs->trans("Type").''.$langs->trans("Link").''.$langs->trans("Description").'
'.$langs->trans("Container").' - '; + print ''.$langs->trans("Container").' - '; print $langs->trans($answerrecord->type_container); // TODO Use label of container print ''; @@ -3506,7 +3512,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') $disabled = ' disabled'; $urltoedithtmlsource = ''; } - print ''.img_picto($langs->trans("EditHTMLSource"), 'edit').''; + print ''.img_picto($langs->trans("EditHTMLSource"), 'edit').''; print '
'; print ''; print getTitleFieldOfList("Type", 0, $_SERVER['PHP_SELF'], 'type_container', '', $param, '', $sortfield, $sortorder, '')."\n"; - print getTitleFieldOfList("Link", 0, $_SERVER['PHP_SELF'], 'title', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList("Link", 0, $_SERVER['PHP_SELF'], 'pageurl', '', $param, '', $sortfield, $sortorder, '')."\n"; print getTitleFieldOfList("Description", 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n"; print getTitleFieldOfList("", 0 , $_SERVER['PHP_SELF']); print ''; From 33a52881253e1bdfeac97b4d603ff7699e659bce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Apr 2020 16:34:59 +0200 Subject: [PATCH 16/18] Add log --- htdocs/core/class/html.formfile.class.php | 4 ++-- htdocs/core/lib/website2.lib.php | 6 ++++++ htdocs/website/index.php | 13 ++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index bc8aa3a9b39..8b1469dd446 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1282,7 +1282,7 @@ class FormFile $sizetoshow = dol_print_size($file['size'], 1, 1); $sizetoshowbytes = dol_print_size($file['size'], 0, 1); - print '
'; + print ''; if ($sizetoshow == $sizetoshowbytes) print $sizetoshow; else { print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1); @@ -1317,7 +1317,7 @@ class FormFile } else { print ''; } - print ''; + print ''; print ''; } else print ' '; diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index ff0fdcae67e..6c4d32bc1cb 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -72,6 +72,9 @@ function dolSavePageAlias($filealias, $object, $objectpage) $aliascontent .= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; $aliascontent .= '?>'."\n"; $result = file_put_contents($filealias, $aliascontent); + if ($result === false) { + dol_syslog("Failed to write file ".$filealias, LOG_WARNING); + } if (!empty($conf->global->MAIN_UMASK)) { @chmod($filealias, octdec($conf->global->MAIN_UMASK)); } @@ -89,6 +92,9 @@ function dolSavePageAlias($filealias, $object, $objectpage) $aliascontent .= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; $aliascontent .= '?>'."\n"; $result = file_put_contents($filealias, $aliascontent); + if ($result === false) { + dol_syslog("Failed to write file ".$filealias, LOG_WARNING); + } if (!empty($conf->global->MAIN_UMASK)) { @chmod($filealias, octdec($conf->global->MAIN_UMASK)); } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index e89409190be..9f823935bcb 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1765,7 +1765,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf // Now generate the master.inc.php page $result = dolSaveMasterFile($filemaster); - if (!$result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); + if (!$result) setEventMessages('Failed to write the master file file '.$filemaster, null, 'errors'); // Now generate the alias.php page @@ -1777,7 +1777,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf // Save page alias $result = dolSavePageAlias($filealias, $object, $objectpage); - if (!$result) setEventMessages('Failed to write file '.basename($filealias), null, 'errors'); + if (!$result) setEventMessages('Failed to write the alias file '.basename($filealias), null, 'errors'); // Save page content $result = dolSavePageContent($filetpl, $object, $objectpage); @@ -3485,8 +3485,8 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print ''; print ''; print getTitleFieldOfList("Type", 0, $_SERVER['PHP_SELF'], 'type_container', '', $param, '', $sortfield, $sortorder, '')."\n"; - print getTitleFieldOfList("Link", 0, $_SERVER['PHP_SELF'], 'pageurl', '', $param, '', $sortfield, $sortorder, '')."\n"; - print getTitleFieldOfList("Description", 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList("Page", 0, $_SERVER['PHP_SELF'], 'pageurl', '', $param, '', $sortfield, $sortorder, '')."\n"; + //print getTitleFieldOfList("Description", 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n"; print getTitleFieldOfList("", 0 , $_SERVER['PHP_SELF']); print ''; @@ -3501,8 +3501,11 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print ''; + //print ''; - print ''; print ''; foreach ($listofpages['list'] as $answerrecord) @@ -3521,6 +3612,17 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') } print ''.img_picto($langs->trans("EditHTMLSource"), 'edit').''; print ''; + + // Action column + print ''; + print ''; } else @@ -3550,11 +3652,17 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print ''; print ''; + + // Action column + print ''; + print ''; } } print '
'; print $answerrecord->getNomUrl(1); print ' ('.($answerrecord->title ? $answerrecord->title : $langs->trans("NoTitle")).')'; + //print ''; + print '
'; + print ''.$answerrecord->description.''; print '
'.$answerrecord->description.''; $param = '?action=replacesiteconfirm'; $param .= '&websiteid='.$website->id; From ca8e1f3ea513473624bb5f31021758762d5ff9af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Apr 2020 18:18:53 +0200 Subject: [PATCH 17/18] NEW Can replace a string into all pages in website module --- htdocs/core/class/html.form.class.php | 3 + htdocs/core/lib/website.lib.php | 2 +- htdocs/langs/en_US/website.lang | 3 +- htdocs/website/index.php | 156 ++++++++++++++++++++++---- 4 files changed, 138 insertions(+), 26 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0c310b92dd6..965bca72824 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -722,6 +722,7 @@ class Form else { jQuery(".massaction").hide(); + jQuery(".massactionother").hide(); } } @@ -743,10 +744,12 @@ class Form if ($(this).val() != \'0\') { jQuery(".massactionconfirmed").prop(\'disabled\', false); + jQuery(".massactionother").show(); } else { jQuery(".massactionconfirmed").prop(\'disabled\', true); + jQuery(".massactionother").hide(); } }); }); diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index af8840b33ae..770bc3fda88 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -793,7 +793,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so { $tmpwebsitepage = new WebsitePage($db); $tmpwebsitepage->fetch($obj->rowid); - if ($tmpwebsitepage->id > 0) $arrayresult['list'][] = $tmpwebsitepage; + if ($tmpwebsitepage->id > 0) $arrayresult['list'][$obj->rowid] = $tmpwebsitepage; $found++; } $i++; diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 222eeb6df0d..c3e9870266f 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -126,4 +126,5 @@ MainLanguage=Main language OtherLanguages=Other languages UseManifest=Provide a manifest.json file PublicAuthorAlias=Public author alias -AvailableLanguagesAreDefinedIntoWebsiteProperties=Available languages are defined into website properties \ No newline at end of file +AvailableLanguagesAreDefinedIntoWebsiteProperties=Available languages are defined into website properties +ReplacementDoneInXPages=Replacement done in %s pages or containers \ No newline at end of file diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 9f823935bcb..a34cfce2206 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -52,9 +52,12 @@ $websitekey = GETPOST('website', 'alpha'); $page = GETPOST('page', 'alpha'); $pageid = GETPOST('pageid', 'int'); $pageref = GETPOST('pageref', 'alphanohtml'); + $action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -260,6 +263,23 @@ $manifestjsoncontentdefault .= '{ }] }'; +$listofpages = array(); + +$algo = ''; +if (GETPOST('optionmeta')) $algo .= 'meta'; +if (GETPOST('optioncontent')) $algo .= 'content'; +if (GETPOST('optionsitefiles')) $algo .= 'sitefiles'; + +if (empty($sortfield)) { + $sortfield = 'pageurl'; $sortorder = 'ASC'; +} + +$searchkey = GETPOST('searchstring', 'none'); + +if ($action == 'replacesiteconfirm') { + $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000, $sortfield, $sortorder); +} + /* @@ -340,11 +360,67 @@ if ($action == 'unsetshowsubcontainers') exit; } -if (($action == 'replacesite' || $action == 'replacesiteconfirm') && empty(GETPOST('searchstring'))) +if (($action == 'replacesite' || $action == 'replacesiteconfirm') && ! $searchkey) { $action = 'replacesite'; } +// Replacement of string into pages +if ($massaction == 'replace') +{ + $replacestring = GETPOST('replacestring', 'alphanohtml'); + if (! $replacestring) { + setEventMessages("ErrorReplaceStringEmpty", null, 'errors'); + } + else { + $nbreplacement = 0; + + foreach($toselect as $keyselected) { + $objectpage = $listofpages['list'][$keyselected]; + if ($objectpage->pageurl) { + dol_syslog("Replace string into page ".$objectpage->pageurl); + + if (GETPOST('optioncontent', 'aZ09')) { + $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content); + } + if (GETPOST('optionmeta', 'aZ09')) { + $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title); + $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description); + $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords); + } + + if (!empty($objectpage->content)) + { + $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; + $filetpl = $pathofwebsite.'/page'.$objectpage->id.'.tpl.php'; + + // Save page alias + $result = dolSavePageAlias($filealias, $object, $objectpage); + if (!$result) + { + setEventMessages('Failed to write file '.basename($filealias), null, 'errors'); + } + + // Save page of content + $result = dolSavePageContent($filetpl, $object, $objectpage); + if ($result) + { + $nbreplacement++; + } else { + $error++; + setEventMessages('Failed to write file '.$filetpl, null, 'errors'); + $action = 'createcontainer'; + break; + } + } + } + } + if (! $error) { + setEventMessages($langs->trans("ReplacementDoneInXPages", $nbreplacement), null, 'mesgs'); + } + } +} + // Add directory /* @@ -3397,10 +3473,8 @@ print "\n"; print "\n"; -if ($action == 'replacesite' || $action == 'replacesiteconfirm') +if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction == 'replace') { - $searchkey = GETPOST('searchstring', 'none'); - print '
'; print ''; print ''; @@ -3431,37 +3505,53 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print ''; print '
'; print ''; - print '
'; - print ''; - - print ''; - - print '
'; print ''; + print ''; + print ''; + + print ''; + + if ($action == 'replacesiteconfirm') { - $algo = ''; - if (GETPOST('optionmeta')) $algo .= 'meta'; - if (GETPOST('optioncontent')) $algo .= 'content'; - if (GETPOST('optionsitefiles')) $algo .= 'sitefiles'; - - if (empty($sortfield)) { - $sortfield = 'pageurl'; $sortorder = 'ASC'; - } - - $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000, $sortfield, $sortorder); - print '
'; print '
'; if ($listofpages['code'] == 'OK') { + $arrayofselected = is_array($toselect) ? $toselect : array(); + $param = ''; + $nbtotalofrecords = count($listofpages['list']); + $num = $nbtotalofrecords = $limit; + $permissiontodelete = 0; + + // List of mass actions available + $arrayofmassactions = array( + //'validate'=>$langs->trans("Validate"), + //'generate_doc'=>$langs->trans("ReGeneratePDF"), + //'builddoc'=>$langs->trans("PDFMerge"), + 'replace'=>$langs->trans("Replace"), + ); + if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + $massactionbutton .= ''; + + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + //$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit, 1, 1, 1); + print ''."\n"; print '
'; - if ($action == 'replacesiteconfirm' && $conf->global->MAIN_FEATURES_LEVEL >= 2) + /*if ($action == 'replacesiteconfirm') { print '
'; print '
'; @@ -3469,11 +3559,11 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print '
'; print '
'; print ''; - print ''; + print ''; print '
'; print '
'; print '
'; - } + }*/ $param = 'action=replacesiteconfirm&website='.urlencode($website->ref); $param .= '&searchstring='.urlencode($searchkey); @@ -3488,6 +3578,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print getTitleFieldOfList("Page", 0, $_SERVER['PHP_SELF'], 'pageurl', '', $param, '', $sortfield, $sortorder, '')."\n"; //print getTitleFieldOfList("Description", 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n"; print getTitleFieldOfList("", 0 , $_SERVER['PHP_SELF']); + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print '
'; + if ($massactionbutton || $massaction) + { + $selected = 0; + if (in_array($answerrecord->id, $arrayofselected)) $selected = 1; + print ''; + } + print '
'; print ''; + print '
'; print ''; + print '
'; } else { From 6eab2ec295ddf79445e3f23ea3dd108b35830864 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Apr 2020 18:29:42 +0200 Subject: [PATCH 18/18] Fix Replacement --- htdocs/website/index.php | 47 +++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index a34cfce2206..629e4b91584 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -389,35 +389,38 @@ if ($massaction == 'replace') $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords); } - if (!empty($objectpage->content)) + $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; + $filetpl = $pathofwebsite.'/page'.$objectpage->id.'.tpl.php'; + + // Save page alias + $result = dolSavePageAlias($filealias, $object, $objectpage); + if (!$result) { - $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; - $filetpl = $pathofwebsite.'/page'.$objectpage->id.'.tpl.php'; + setEventMessages('Failed to write file '.basename($filealias), null, 'errors'); + } - // Save page alias - $result = dolSavePageAlias($filealias, $object, $objectpage); - if (!$result) - { - setEventMessages('Failed to write file '.basename($filealias), null, 'errors'); - } - - // Save page of content - $result = dolSavePageContent($filetpl, $object, $objectpage); - if ($result) - { - $nbreplacement++; - } else { - $error++; - setEventMessages('Failed to write file '.$filetpl, null, 'errors'); - $action = 'createcontainer'; - break; - } + // Save page of content + $result = dolSavePageContent($filetpl, $object, $objectpage); + if ($result) + { + $nbreplacement++; + //var_dump($objectpage->content);exit; + $objectpage->update($user); + } else { + $error++; + setEventMessages('Failed to write file '.$filetpl, null, 'errors'); + $action = 'createcontainer'; + break; } } } - if (! $error) { + + if ($nbreplacement > 0) { setEventMessages($langs->trans("ReplacementDoneInXPages", $nbreplacement), null, 'mesgs'); } + + // Now we reload list + $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000, $sortfield, $sortorder); } }