From ecfa7f1676f089146d8d3f175fd35470f402cd8a Mon Sep 17 00:00:00 2001 From: Jyhere Date: Thu, 16 Mar 2023 14:58:44 +0100 Subject: [PATCH] FIX: remove obsolete preg_replace for removing commat at the beginning... needed to work --- htdocs/adherents/list.php | 6 +++--- htdocs/admin/emailcollector_list.php | 2 +- htdocs/admin/mails_senderprofile_list.php | 8 +++----- htdocs/asset/list.php | 2 +- htdocs/asset/model/list.php | 2 +- htdocs/bom/bom_list.php | 2 +- htdocs/bookcal/availabilities_list.php | 2 +- htdocs/bookcal/booking_list.php | 2 +- htdocs/bookmarks/list.php | 2 +- htdocs/compta/cashcontrol/cashcontrol_list.php | 2 +- htdocs/compta/facture/invoicetemplate_list.php | 2 +- htdocs/contact/list.php | 2 +- htdocs/contrat/list.php | 2 +- htdocs/eventorganization/conferenceorbooth_list.php | 2 +- .../conferenceorboothattendee_list.php | 2 +- htdocs/fourn/facture/list-rec.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/holiday/list.php | 2 +- htdocs/hrm/evaluation_list.php | 2 +- htdocs/hrm/job_list.php | 2 +- htdocs/hrm/position.php | 4 ++-- htdocs/hrm/position_list.php | 2 +- htdocs/hrm/skill_list.php | 2 +- htdocs/intracommreport/list.php | 2 +- htdocs/knowledgemanagement/knowledgerecord_list.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/mrp/mo_list.php | 2 +- htdocs/partnership/partnership_list.php | 2 +- htdocs/product/inventory/list.php | 2 +- htdocs/product/stock/movement_list.php | 2 +- htdocs/product/stock/productlot_list.php | 2 +- .../product/stock/stocktransfer/stocktransfer_list.php | 10 +++++----- htdocs/projet/list.php | 2 +- htdocs/projet/tasks/time.php | 2 +- htdocs/recruitment/recruitmentcandidature_list.php | 2 +- htdocs/recruitment/recruitmentjobposition_list.php | 2 +- htdocs/ticket/list.php | 2 +- htdocs/user/list.php | 2 +- htdocs/variants/list.php | 4 ++-- htdocs/webhook/target_list.php | 2 +- htdocs/workstation/workstation_list.php | 2 +- 41 files changed, 51 insertions(+), 53 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 2399b9f5b83..f4208f590fd 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -345,19 +345,19 @@ $sql .= " d.note_private, d.note_public, d.import_key,"; $sql .= " s.nom,"; $sql .= " ".$db->ifsql("d.societe IS NULL", "s.nom", "d.societe")." as companyname,"; $sql .= " t.libelle as type, t.subscription,"; -$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " state.code_departement as state_code, state.nom as state_name"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } } // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 3913d10df56..b58bb5bb15d 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -224,7 +224,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index a73b899dd00..38fb81c6430 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -226,19 +226,17 @@ print "
\n"; // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) { - $sql .= "t.".$key.", "; -} +$sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } } // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index ee35a817be3..d98165d28a2 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -214,7 +214,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php index aa80b4e5426..51e45f244d0 100644 --- a/htdocs/asset/model/list.php +++ b/htdocs/asset/model/list.php @@ -219,7 +219,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 730ad651d0c..a12bd7fdb2d 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -306,7 +306,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/bookcal/availabilities_list.php b/htdocs/bookcal/availabilities_list.php index 7c0ef05a02d..208190aaad5 100644 --- a/htdocs/bookcal/availabilities_list.php +++ b/htdocs/bookcal/availabilities_list.php @@ -227,7 +227,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); //$sql .= ", COUNT(rc.rowid) as anotherfield"; $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php index 618e8e9bb0e..033c8ec121f 100644 --- a/htdocs/bookcal/booking_list.php +++ b/htdocs/bookcal/booking_list.php @@ -227,7 +227,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); //$sql .= ", COUNT(rc.rowid) as anotherfield"; $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 79763fc3211..34b727aaa16 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -158,7 +158,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 4b3c9b31322..41aa42195dc 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -211,7 +211,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 825de33bec6..d0c8ea7f1f5 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -300,7 +300,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index a7bc1e713ff..533d2a8a42e 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -425,7 +425,7 @@ if (isModEnabled('mailing')) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index b55e09bd252..50e26a55a68 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -279,7 +279,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 4a67003180f..5892cda191b 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -524,7 +524,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); //$sql .= ", COUNT(rc.rowid) as anotherfield"; diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index b9037a366c3..8f55a4e558c 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -274,7 +274,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (!empty($confOrBooth->id)) { diff --git a/htdocs/fourn/facture/list-rec.php b/htdocs/fourn/facture/list-rec.php index d45334eba9e..2c5f8d4980e 100644 --- a/htdocs/fourn/facture/list-rec.php +++ b/htdocs/fourn/facture/list-rec.php @@ -278,7 +278,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn_rec as f'; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 2baa2cade8c..5302d5de3b2 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -431,7 +431,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 0be113d8205..ddcb4b55bd6 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -309,7 +309,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/hrm/evaluation_list.php b/htdocs/hrm/evaluation_list.php index a9749c46d7e..5dbddbd6ec6 100644 --- a/htdocs/hrm/evaluation_list.php +++ b/htdocs/hrm/evaluation_list.php @@ -231,7 +231,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { diff --git a/htdocs/hrm/job_list.php b/htdocs/hrm/job_list.php index b347c32848c..dad366d14f1 100644 --- a/htdocs/hrm/job_list.php +++ b/htdocs/hrm/job_list.php @@ -226,7 +226,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { diff --git a/htdocs/hrm/position.php b/htdocs/hrm/position.php index 35f47f2a187..3b3931fcf64 100644 --- a/htdocs/hrm/position.php +++ b/htdocs/hrm/position.php @@ -363,7 +363,7 @@ if ($job->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create' // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook - $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); + $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM " . MAIN_DB_PREFIX . $object->table_element . " as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { @@ -906,7 +906,7 @@ function DisplayPositionList() // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook - $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); + $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM " . MAIN_DB_PREFIX . $object->table_element . " as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index f5740834da7..4644382416e 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -232,7 +232,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t LEFT JOIN ".MAIN_DB_PREFIX.$userstatic->table_element." as u on t.fk_user = u.rowid, ".MAIN_DB_PREFIX."hrm_job as j"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { diff --git a/htdocs/hrm/skill_list.php b/htdocs/hrm/skill_list.php index 21adb375060..07084815b13 100644 --- a/htdocs/hrm/skill_list.php +++ b/htdocs/hrm/skill_list.php @@ -235,7 +235,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); //$sql .= ", COUNT(rc.rowid) as anotherfield"; diff --git a/htdocs/intracommreport/list.php b/htdocs/intracommreport/list.php index c107ba9e492..d7995ef275b 100644 --- a/htdocs/intracommreport/list.php +++ b/htdocs/intracommreport/list.php @@ -220,7 +220,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= $hookmanager->resPrint; diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index b70b7df6bf3..7e12bee4dc4 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -241,7 +241,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index e0cdd1f8ab4..8af27e60caf 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -289,7 +289,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); //$sql .= ", COUNT(rc.rowid) as anotherfield"; diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 30b9d288562..d1d50441ea2 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -229,7 +229,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 955bb7a5197..f03608929a5 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -312,7 +312,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 88e590c478b..fda3f60602b 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -222,7 +222,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index c0b055352c0..4da0c259bc9 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -617,7 +617,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 8981d1cff56..302a02ba108 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -225,7 +225,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_list.php b/htdocs/product/stock/stocktransfer/stocktransfer_list.php index 72c538a58c6..2a57b3f2f94 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_list.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_list.php @@ -178,17 +178,17 @@ $title = $langs->trans('StockTransferList'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) { - $sql .= "t.".$key.", "; -} +$sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); + } } // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index d0075b57ed7..1d38e5214d5 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -444,7 +444,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 17a58f3a1e9..fe7d2a093fd 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1562,7 +1562,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook - $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); + $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet as il ON il.rowid = t.invoice_line_id"; diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 05524716cad..789e9564c87 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -231,7 +231,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index 4cb2d845828..fe2d2a5d612 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -213,7 +213,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= ", COUNT(rc.rowid) as nbapplications"; $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 1eac833560c..71b6d8cff0d 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -352,7 +352,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 3ea1307224c..47962e14c66 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -379,7 +379,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php index c2f2b3e9a15..a83ecf7be89 100644 --- a/htdocs/variants/list.php +++ b/htdocs/variants/list.php @@ -227,7 +227,7 @@ $morecss = array(); // Build and execute select // -------------------------------------------------------------------- $sql = "SELECT "; -$sql .= " COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products,"; +$sql .= " COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products"; $sql .= $object->getFieldList("t"); // Add fields from extrafields //if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -238,7 +238,7 @@ $sql .= $object->getFieldList("t"); // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; //if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { diff --git a/htdocs/webhook/target_list.php b/htdocs/webhook/target_list.php index de7417d61de..d28221c0e3d 100644 --- a/htdocs/webhook/target_list.php +++ b/htdocs/webhook/target_list.php @@ -231,7 +231,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); //$sql .= ", COUNT(rc.rowid) as anotherfield"; $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 699bc52045b..47e93d8294b 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -231,7 +231,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {