From 551256b77936fc4d24b5f3b7fd93c91603ae1eb0 Mon Sep 17 00:00:00 2001 From: Muhammad Aboelfotoh <> Date: Wed, 25 Nov 2020 15:11:09 +0000 Subject: [PATCH 01/91] FIX #13067 including opening balance in calculation of displayed balance --- htdocs/accountancy/bookkeeping/balance.php | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 456da29d954..ef19a6ae330 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -265,10 +265,16 @@ if ($action != 'export_csv') $total_credit = 0; $sous_total_debit = 0; $sous_total_credit = 0; + $total_opening_balance = 0; + $sous_total_opening_balance = 0; $displayed_account = ""; - $sql = "select t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance from ".MAIN_DB_PREFIX."accounting_bookkeeping as t where entity in ".$conf->entity; - $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."' GROUP BY t.numero_compte"; + $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; + $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features + $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'"; + $sql .= " GROUP BY t.numero_compte"; + $resql = $db->query($sql); $nrows = $resql->num_rows; $opening_balances = array(); @@ -284,17 +290,19 @@ if ($action != 'export_csv') $total_credit += $line->credit; $description = $object->get_compte_desc($line->numero_compte); // Search description of the account $root_account_description = $object->get_compte_racine($line->numero_compte); + $opening_balance = isset($opening_balances["'".$line->numero_compte."'"]) ? $opening_balances["'".$line->numero_compte."'"] : 0; + $total_opening_balance += $opening_balance; if (empty($description)) { $link = ''.img_edit_add().''; } print ''; - // Permet d'afficher le compte comptable + // Display the accounting account if (empty($displayed_account) || $root_account_description != $displayed_account) { - // Affiche un Sous-Total par compte comptable + // Display a sub-total per account if ($displayed_account != "") { - print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_credit - $sous_total_debit)).''; + print ''.$langs->trans("SubTotal").':'.price($sous_total_opening_balance).''.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_credit - $sous_total_debit)).''; print " \n"; print ''; } @@ -307,30 +315,32 @@ if ($action != 'export_csv') $displayed_account = $root_account_description; $sous_total_debit = 0; $sous_total_credit = 0; + $sous_total_opening_balance = 0; } // $object->get_compte_racine($line->numero_compte); print ''.length_accountg($line->numero_compte).''; print ''.$description.''; - print ''.price($opening_balances["'".$line->numero_compte."'"]).''; + print ''.price($opening_balance).''; print ''.price($line->debit).''; print ''.price($line->credit).''; - print ''.price($line->debit - $line->credit).''; + print ''.price($opening_balance + $line->debit - $line->credit).''; print ''.$link; print ''; print "\n"; - // Comptabilise le sous-total + // Records the sub-total $sous_total_debit += $line->debit; $sous_total_credit += $line->credit; + $sous_total_opening_balance += $opening_balance; } - print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit - $sous_total_credit)).''; + print ''.$langs->trans("SubTotal").':'.price($sous_total_opening_balance).''.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit)).''; print " \n"; print ''; - print ''.$langs->trans("AccountBalance").':'.price($total_debit).''.price($total_credit).''.price(price2num($total_debit - $total_credit)).''; + print ''.$langs->trans("AccountBalance").':'.price($total_opening_balance).''.price($total_debit).''.price($total_credit).''.price(price2num($total_opening_balance + $total_debit - $total_credit)).''; print " \n"; print ''; From be7714be1c1fa9371428072c375e0cc459fc4dff Mon Sep 17 00:00:00 2001 From: Bernard Saulme Date: Wed, 25 Nov 2020 18:11:36 +0100 Subject: [PATCH 02/91] Use email model option to joint file for subscription Allow the adherent subscription to use the email model option to join or no joint file. --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 611542b8ebc..d1dfd836696 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -333,7 +333,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $listofpaths = array(); $listofnames = array(); $listofmimes = array(); - if (is_object($object->invoice)) { + if (is_object($object->invoice) && is_object($arraydefaultmessage) && intval($arraydefaultmessage->joinfiles)) { $invoicediroutput = $conf->facture->dir_output; $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); $file = $fileparams['fullname']; From 55f26179f222cc40a743ee624a080539b6cb3e0d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 08:37:52 +0100 Subject: [PATCH 03/91] Fix phpunit --- test/phpunit/CodingPhpTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 727f8cc0ee3..9acb13432d2 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -281,7 +281,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase preg_match_all('/sql.+\s*\'"\s*\.\s*\$(.........)/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { - if (! in_array($val[1], array('this->db-', 'this->esc', 'db->escap', 'dbsession->escap', 'db->idate', 'excludeGr', 'includeGr'))) { + if (! in_array($val[1], array('this->db-', 'this->esc', 'db->escap', 'dbsession', 'db->idate', 'excludeGr', 'includeGr'))) { $ok=false; break; } From e272130a6a22b3d804b6459235a630a249f361e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 08:40:08 +0100 Subject: [PATCH 04/91] Fix phpcs --- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/core/class/commonobject.class.php | 14 +++++++------- htdocs/core/lib/phpsessionindb.lib.php | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 299a9700364..097eb38b47f 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -630,7 +630,7 @@ else $buttonLabel = $langs->trans("ExportList"); $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { -// Button re-export + // Button re-export if (!empty($conf->global->ACCOUNTING_REEXPORT)) { $newcardbutton = '' . img_picto($langs->trans("Activated"), 'switch_on') . ' '; } else { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ace39ade0ef..d7c46fba089 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8512,13 +8512,13 @@ abstract class CommonObject } $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files"; - $sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return false; - } + $sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return false; + } } $this->db->commit(); diff --git a/htdocs/core/lib/phpsessionindb.lib.php b/htdocs/core/lib/phpsessionindb.lib.php index 585967965dc..d0e96434d00 100644 --- a/htdocs/core/lib/phpsessionindb.lib.php +++ b/htdocs/core/lib/phpsessionindb.lib.php @@ -163,4 +163,3 @@ function dolSessionGC($max_lifetime) // Call to register user call back functions. session_set_save_handler("dolSessionOpen", "dolSessionClose", "dolSessionRead", "dolSessionWrite", "dolSessionDestroy", "dolSessionGC"); - From 69b06a25e8525cd84aa4e3a376b619afc92661f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 09:16:16 +0100 Subject: [PATCH 05/91] Fix code of deletion of objects --- htdocs/comm/propal/class/propal.class.php | 33 ++--- htdocs/commande/class/commande.class.php | 117 ++++++++---------- htdocs/compta/facture/class/facture.class.php | 5 + .../class/expensereport.class.php | 37 +++--- 4 files changed, 94 insertions(+), 98 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 50c63137c67..bc588f430d9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2947,10 +2947,23 @@ class Propal extends CommonObject if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } + if (!$error) { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + } + + if (!$error) { + // Delete linked contacts + $res = $this->delete_linked_contact(); + if ($res < 0) $error++; + } + // Removed extrafields of object if (!$error) { $result = $this->deleteExtraFields(); @@ -2966,25 +2979,15 @@ class Propal extends CommonObject $res = $this->db->query($sql); if (! $res) { $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } - if (! $error) { - // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; - } - - if (! $error) { - // Delete linked contacts - $res = $this->delete_linked_contact(); - if ($res < 0) $error++; - } - // Delete record into ECM index and physically if (!$error) { - $res = $this->deleteEcmFiles(); // Deleting files physically is done later with the dol_delete_dir_recursive + $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive if (! $res) { $error++; } @@ -3001,7 +3004,7 @@ class Propal extends CommonObject if (!dol_delete_file($file, 0, 0, 0, $this)) { $this->error = 'ErrorFailToDeleteFile'; - $this->errors = array('ErrorFailToDeleteFile'); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } @@ -3010,7 +3013,7 @@ class Propal extends CommonObject $res = @dol_delete_dir_recursive($dir); if (!$res) { $this->error = 'ErrorFailToDeleteDir'; - $this->errors = array('ErrorFailToDeleteDir'); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b2d0c57f4ad..7166a491118 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3342,106 +3342,95 @@ class Commande extends CommonOrder $this->db->begin(); - if (!$error && !$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('ORDER_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { $error++; } // End call triggers } + // Test we can delete if ($this->nb_expedition() != 0) { $this->errors[] = $langs->trans('SomeShipmentExists'); $error++; } - if (!$error) - { - // Delete extrafields of order details - $main = MAIN_DB_PREFIX.'commandedet'; - $ef = $main."_extrafields"; - $sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")"; - if (!$this->db->query($sql)) - { + // Delete extrafields of lines and lines + if (!$error && !empty($this->table_element_line)) { + $tabletodelete = $this->table_element_line; + $sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; + if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { $error++; - $this->errors[] = $this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } - if (!$error) - { - // Delete order details - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE fk_commande = ".$this->id; - if (!$this->db->query($sql)) - { - $error++; - $this->errors[] = $this->db->lasterror(); - } - } - - if (!$error) - { + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; } - if (!$error) - { + if (!$error) { // Delete linked contacts $res = $this->delete_linked_contact(); if ($res < 0) $error++; } - if (!$error) - { - // Remove extrafields + // Removed extrafields of object + if (!$error) { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } - if (!$error) - { - // Delete object - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id; - if (!$this->db->query($sql)) - { + // Delete main record + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; + $res = $this->db->query($sql); + if (! $res) { $error++; - $this->errors[] = $this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } - if (!$error) - { - // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive - $this->deleteEcmFiles(); + // Delete record into ECM index and physically + if (!$error) { + $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + if (! $res) { + $error++; + } + } - // Remove directory with files - $comref = dol_sanitizeFileName($this->ref); - if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref)) - { - $dir = $conf->commande->multidir_output[$this->entity]."/".$comref; - $file = $conf->commande->multidir_output[$this->entity]."/".$comref."/".$comref.".pdf"; - if (file_exists($file)) // We must delete all files before deleting directory - { + if (!$error) { + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref)) { + $dir = $conf->commande->multidir_output[$this->entity]."/".$ref; + $file = $dir."/".$ref.".pdf"; + if (file_exists($file)) { dol_delete_preview($this); - if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers - { + if (!dol_delete_file($file, 0, 0, 0, $this)) { + $this->error = 'ErrorFailToDeleteFile'; + $this->errors[] = $this->error; $this->db->rollback(); return 0; } } - if (file_exists($dir)) - { - if (!dol_delete_dir_recursive($dir)) - { - $this->error = $langs->trans("ErrorCanNotDeleteDir", $dir); + if (file_exists($dir)) { + $res = @dol_delete_dir_recursive($dir); + if (!$res) { + $this->error = 'ErrorFailToDeleteDir'; + $this->errors[] = $this->error; $this->db->rollback(); return 0; } @@ -3449,17 +3438,13 @@ class Commande extends CommonOrder } } - if (!$error) - { + if (!$error) { + dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); $this->db->commit(); return 1; } else { - foreach ($this->errors as $errmsg) - { - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } $this->db->rollback(); - return -1 * $error; + return -1; } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 51051625db6..a3d64bb0c2e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2184,6 +2184,7 @@ class Facture extends CommonInvoice if (!$this->db->query($sql)) { $this->error = $this->db->error()." sql=".$sql; + $this->errors[] = $this->error; $this->db->rollback(); return -5; } @@ -2244,6 +2245,7 @@ class Facture extends CommonInvoice { $langs->load("errors"); $this->error = $langs->trans("ErrorFailToDeleteFile", $file); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } @@ -2254,6 +2256,7 @@ class Facture extends CommonInvoice { $langs->load("errors"); $this->error = $langs->trans("ErrorFailToDeleteDir", $dir); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } @@ -2264,11 +2267,13 @@ class Facture extends CommonInvoice return 1; } else { $this->error = $this->db->lasterror()." sql=".$sql; + $this->errors[] = $this->error; $this->db->rollback(); return -6; } } else { $this->error = $this->db->lasterror()." sql=".$sql; + $this->errors[] = $this->error; $this->db->rollback(); return -4; } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 84672d90974..02c315b8e70 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1104,10 +1104,23 @@ class ExpenseReport extends CommonObject if (! $this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } + if (!$error) { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + } + + if (!$error) { + // Delete linked contacts + $res = $this->delete_linked_contact(); + if ($res < 0) $error++; + } + // Removed extrafields of object if (!$error) { $result = $this->deleteExtraFields(); @@ -1123,25 +1136,15 @@ class ExpenseReport extends CommonObject $res = $this->db->query($sql); if (! $res) { $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } - if (! $error) { - // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; - } - - if (! $error) { - // Delete linked contacts - $res = $this->delete_linked_contact(); - if ($res < 0) $error++; - } - // Delete record into ECM index and physically if (!$error) { - $res = $this->deleteEcmFiles(); // Deleting files physically is done later with the dol_delete_dir_recursive + $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive if (! $res) { $error++; } @@ -1150,15 +1153,15 @@ class ExpenseReport extends CommonObject if (!$error) { // We remove directory $ref = dol_sanitizeFileName($this->ref); - if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref)) { - $dir = $conf->propal->multidir_output[$this->entity]."/".$ref; + if ($conf->expensereport->multidir_output[$this->entity] && !empty($this->ref)) { + $dir = $conf->expensereport->multidir_output[$this->entity]."/".$ref; $file = $dir."/".$ref.".pdf"; if (file_exists($file)) { dol_delete_preview($this); if (!dol_delete_file($file, 0, 0, 0, $this)) { $this->error = 'ErrorFailToDeleteFile'; - $this->errors = array('ErrorFailToDeleteFile'); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } @@ -1167,7 +1170,7 @@ class ExpenseReport extends CommonObject $res = @dol_delete_dir_recursive($dir); if (!$res) { $this->error = 'ErrorFailToDeleteDir'; - $this->errors = array('ErrorFailToDeleteDir'); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } From f14058f29ecd4f0f36a3d536b34981fef09ef22e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 10:09:09 +0100 Subject: [PATCH 06/91] Try conditional build with Travis --- .travis.yml | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 639183de6ff..278e5df88a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,6 @@ os: linux dist: xenial #dist: bionic -# Deprecated: The key sudo has no effect anymore. -#sudo: required language: php @@ -33,10 +31,10 @@ addons: # We need pgloader for import mysql database into pgsql - pgloader -php: -- '5.6' -- '7.4' -- nightly +#php: +#- '5.6' +#- '7.4' +#- nightly env: global: @@ -49,8 +47,6 @@ env: - DB=postgresql # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP #- WS=apache - # See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test - #- WS=nginx jobs: fast_finish: true @@ -58,24 +54,17 @@ jobs: - php: nightly # We exclude some combinations not usefull to save Travis CPU exclude: - - php: '7.0' - env: DB=mysql - - php: '7.1' - env: DB=mysql - - php: '7.2' - env: DB=mysql - - php: '7.3' - env: DB=mysql - - php: '7.0' - env: DB=postgresql - - php: '7.1' - env: DB=postgresql - - php: '7.2' - env: DB=postgresql - - php: '7.3' - env: DB=postgresql - php: nightly env: DB=postgresql + include: + - if: type = pull_request + php: '7.4' + - if: type = push + php: + - '5.6' + - '7.4' + - if: type = push AND branch = develop + php: nightly notifications: email: From c7e5b0dcc199d8f7abfe837baa0801b37b8eda6a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 10:12:24 +0100 Subject: [PATCH 07/91] Fix warning --- htdocs/core/lib/pdf.lib.php | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index cb5e638ce40..3e2fbf66eaa 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1338,28 +1338,23 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // We add ref of product (and supplier ref if defined) $prefix_prodserv = ""; $ref_prodserv = ""; - if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this - { - if ($prodser->isService()) - { + if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) { // In standard mode, we do not show this + if ($prodser->isService()) { $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; } else { $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." "; } } - if (empty($hideref)) - { - if ($issupplierline) - { - if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) - $ref_prodserv = $ref_supplier; - elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) - $ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; - else // Common case - { + if (empty($hideref)) { + if ($issupplierline) { + if (empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) { // Common case $ref_prodserv = $prodser->ref; // Show local ref if ($ref_supplier) $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : ''); + } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) { + $ref_prodserv = $ref_supplier; + } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) { + $ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; } } else { $ref_prodserv = $prodser->ref; // Show local ref only From 09d0ec391d13335c39ef6c00e7215872b48bb1f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 10:15:12 +0100 Subject: [PATCH 08/91] Test conditional job with travis --- .travis.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 278e5df88a4..1a4471905dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,12 +57,10 @@ jobs: - php: nightly env: DB=postgresql include: - - if: type = pull_request - php: '7.4' - if: type = push - php: - - '5.6' - - '7.4' + php: '5.6' + - if: type = pull_request OR type = push + php: '7.4' - if: type = push AND branch = develop php: nightly From 341a059a2bfede95fd8e601ac6f045a9d59b05c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 10:19:01 +0100 Subject: [PATCH 09/91] Test travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1a4471905dc..a808fedccbc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,8 +59,10 @@ jobs: include: - if: type = push php: '5.6' + env: DB=postgresql - if: type = pull_request OR type = push php: '7.4' + env: DB=mysql - if: type = push AND branch = develop php: nightly From 3236b1d74e29a3a40817e6fff3c8b3edba95b29d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 10:21:03 +0100 Subject: [PATCH 10/91] Test travis --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a808fedccbc..ef57f908cdf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,11 +40,11 @@ env: global: # Set to true for very verbose output - DEBUG=false - jobs: + #jobs: # MariaDB overrides MySQL installation so it's not possible to test both yet #- DB=mariadb - - DB=mysql - - DB=postgresql + #- DB=mysql + #- DB=postgresql # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP #- WS=apache @@ -65,6 +65,7 @@ jobs: env: DB=mysql - if: type = push AND branch = develop php: nightly + env: DB=mysql notifications: email: From e1a6e8f2fcd7c52549540821bb9fc821dff07216 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 11:09:35 +0100 Subject: [PATCH 11/91] CSS Security: Add param to fight against Clickjacking attacks --- .travis.yml | 18 +------ htdocs/core/lib/admin.lib.php | 54 +++++++++---------- htdocs/core/website.inc.php | 4 +- htdocs/install/default.css | 4 +- htdocs/install/inc.php | 9 ++-- .../install/mysql/migration/12.0.0-13.0.0.sql | 1 + .../install/mysql/tables/llx_website_page.sql | 7 +-- htdocs/install/upgrade.php | 10 ++-- htdocs/install/upgrade2.php | 6 +-- htdocs/langs/en_US/website.lang | 3 +- htdocs/website/class/websitepage.class.php | 7 +++ htdocs/website/index.php | 42 +++++++++------ 12 files changed, 85 insertions(+), 80 deletions(-) diff --git a/.travis.yml b/.travis.yml index ef57f908cdf..2479de608ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,31 +31,15 @@ addons: # We need pgloader for import mysql database into pgsql - pgloader -#php: -#- '5.6' -#- '7.4' -#- nightly - env: global: # Set to true for very verbose output - DEBUG=false - #jobs: - # MariaDB overrides MySQL installation so it's not possible to test both yet - #- DB=mariadb - #- DB=mysql - #- DB=postgresql - # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP - #- WS=apache jobs: fast_finish: true allow_failures: - php: nightly - # We exclude some combinations not usefull to save Travis CPU - exclude: - - php: nightly - env: DB=postgresql include: - if: type = push php: '5.6' @@ -416,7 +400,7 @@ script: php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log # Enable modules not enabled into original dump - php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP > $TRAVIS_BUILD_DIR/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP,MAIN_MODULE_RECRUITMENT > $TRAVIS_BUILD_DIR/enablemodule.log echo $? cd - set +e diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 6cab3638eb5..a697fcdfdc5 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -402,36 +402,36 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle } } - if ($error == 0) - { - if (!$silent) { - print ''.$langs->trans("ProcessMigrateScript").''; - print ''.$langs->trans("OK"); - //if (! empty($conf->use_javascript_ajax)) { - print ''; - print ' - '.$langs->trans("ShowHideDetails").''; - //} - print ''."\n"; + if (!$silent) { + print ''.$langs->trans("ProcessMigrateScript").''; + print ''; + if ($error == 0) { + print ''.$langs->trans("OK").''; + } else { + print ''.$langs->trans("Error").''; } + //if (! empty($conf->use_javascript_ajax)) { + print ''; + print ' - '.$langs->trans("ShowHideDetails").''; + //} + print ''."\n"; + } + + if ($error == 0) { $ok = 1; } else { - if (!$silent) { - print ''.$langs->trans("ProcessMigrateScript").''; - print ''.$langs->trans("KO").''; - print ''."\n"; - } $ok = 0; } diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 1e94b690c8f..7fe59ad9903 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -82,11 +82,9 @@ if ($pageid > 0) if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { header("X-Content-Type-Options: nosniff"); - /* TODO Manage allow_frames flag on websitepage. - if (empty($websitepage->allow_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) { + if (empty($websitepage->allowed_in_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) { header("X-Frame-Options: SAMEORIGIN"); } - */ } // A lang was forced, so we change weblangs init diff --git a/htdocs/install/default.css b/htdocs/install/default.css index b7fd69d9ecb..ca397d1ca40 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -233,10 +233,10 @@ table.listofchoices, table.listofchoices tr, table.listofchoices td { /* OK */ div.ok { - color: #114466; + color: #009933; } span.ok { - color: #114466; + color: #009933; } /* Warning */ diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index e770e41e89c..a0890866b51 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -425,9 +425,7 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas { global $conf, $langs; - $langs->load("main"); - $langs->load("other"); - $langs->load("admin"); + $langs->loadLangs(array("main", "other", "admin")); print ''."\n"; print ''."\n"; @@ -437,7 +435,10 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas print '
'; if ($nonext == '2') { - print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : '').'

'; + print ''; + print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : ''); + print ''; + print '

'; } print '"'; diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 9951375677c..c83755009ae 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -407,6 +407,7 @@ CREATE TABLE llx_ecm_directories_extrafields ) ENGINE=innodb; ALTER TABLE llx_ecm_directories_extrafields ADD INDEX idx_ecm_directories_extrafields (fk_object); +ALTER TABLE llx_website_page ADD COLUMN allowed_in_frames integer DEFAULT 0; ALTER TABLE llx_website_page ADD COLUMN object_type varchar(255); ALTER TABLE llx_website_page ADD COLUMN fk_object varchar(255); diff --git a/htdocs/install/mysql/tables/llx_website_page.sql b/htdocs/install/mysql/tables/llx_website_page.sql index 4b1b3045d6b..499bf23d1f5 100644 --- a/htdocs/install/mysql/tables/llx_website_page.sql +++ b/htdocs/install/mysql/tables/llx_website_page.sql @@ -29,7 +29,8 @@ CREATE TABLE llx_website_page image varchar(255), keywords varchar(255), lang varchar(6), - fk_page integer, + fk_page integer, + allowed_in_frames integer DEFAULT 0, htmlheader text, content mediumtext, -- text is not enough in size status integer DEFAULT 1, @@ -40,6 +41,6 @@ CREATE TABLE llx_website_page date_creation datetime, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, import_key varchar(14), -- import key - object_type varchar(255), - fk_object varchar(255) + object_type varchar(255), -- To link page to an object + fk_object varchar(255) -- To link page to an object ) ENGINE=innodb; diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index a7addd98547..29b51746a14 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -146,11 +146,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ if ($db->connected) { print ''; - print $langs->trans("ServerConnection")." : ".$dolibarr_main_db_host.''.$langs->trans("OK").''."\n"; + print $langs->trans("ServerConnection")." : ".$dolibarr_main_db_host.''.$langs->trans("OK").''."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection").": $dolibarr_main_db_host ".$langs->transnoentities("OK")); $ok = 1; } else { - print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).''.$langs->transnoentities("Error")."\n"; + print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).''.$langs->transnoentities("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); $ok = 0; } @@ -160,11 +160,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ if ($db->database_selected) { print ''; - print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name.''.$langs->trans("OK")."\n"; + print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name.''.$langs->trans("OK")."\n"; dolibarr_install_syslog("upgrade: Database connection successful: ".$dolibarr_main_db_name); $ok = 1; } else { - print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).''.$langs->trans("Error")."\n"; + print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).''.$langs->trans("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); $ok = 0; } @@ -196,7 +196,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ && versioncompare($versionarray, $versionmindb) < 0) { // Warning: database version too low. - print "".$langs->trans("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb))."".$langs->trans("Error")."\n"; + print "".$langs->trans("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb)).''.$langs->trans("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb))); $ok = 0; } diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index a77606abb3f..2d84e234cf2 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -531,7 +531,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ print ''; } else { print ''; - print ''.$langs->trans('UpgradeExternalModule').': OK'; + print ''.$langs->trans('UpgradeExternalModule').': OK'; print ""; print ''; } @@ -1353,9 +1353,9 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) if ($insert_resql) { $nb++; - print ''.$langs->trans("OK").''; + print ''.$langs->trans("OK").''; } else { - print 'Error on insert'; + print 'Error on insert'; $error++; } print ''; diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index c32fcd06f09..1d62d1c07f8 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -135,4 +135,5 @@ ReplacementDoneInXPages=Replacement done in %s pages or containers RSSFeed=RSS Feed RSSFeedDesc=You can get a RSS feed of latest articles with type 'blogpost' using this URL PagesRegenerated=%s page(s)/container(s) regenerated -RegenerateWebsiteContent=Regenerate web site cache files \ No newline at end of file +RegenerateWebsiteContent=Regenerate web site cache files +AllowedInFrames=Allowed in Frames \ No newline at end of file diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 5108fe4c25b..ff072827423 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -81,6 +81,7 @@ class WebsitePage extends CommonObject */ public $lang; + public $allowed_in_frames; public $htmlheader; public $content; public $grabbed_from; @@ -160,6 +161,7 @@ class WebsitePage extends CommonObject //'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000), 'fk_website' =>array('type'=>'integer', 'label'=>'WebsiteId', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>40, 'searchall'=>0, 'foreignkey'=>'websitepage.rowid'), 'fk_page' =>array('type'=>'integer', 'label'=>'ParentPageId', 'enabled'=>1, 'visible'=>1, 'notnull'=>-1, 'position'=>45, 'searchall'=>0, 'foreignkey'=>'website.rowid'), + 'allowed_in_frames' =>array('type'=>'integer', 'label'=>'AllowedInFrames', 'enabled'=>1, 'visible'=>-1, 'position'=>48, 'searchall'=>0), 'htmlheader' =>array('type'=>'text', 'label'=>'HtmlHeader', 'enabled'=>1, 'visible'=>0, 'position'=>50, 'searchall'=>0), 'content' =>array('type'=>'mediumtext', 'label'=>'Content', 'enabled'=>1, 'visible'=>0, 'position'=>51, 'searchall'=>0), 'grabbed_from' =>array('type'=>'varchar(255)', 'label'=>'GrabbedFrom', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>400, 'comment'=>'URL page content was grabbed from'), @@ -265,6 +267,7 @@ class WebsitePage extends CommonObject $sql .= " t.content,"; $sql .= " t.lang,"; $sql .= " t.fk_page,"; + $sql .= " t.allowed_in_frames,"; $sql .= " t.status,"; $sql .= " t.grabbed_from,"; $sql .= " t.date_creation,"; @@ -325,6 +328,7 @@ class WebsitePage extends CommonObject $this->content = $obj->content; $this->lang = $obj->lang; $this->fk_page = $obj->fk_page; + $this->allowed_in_frames = $obj->allowed_in_frames; $this->status = $obj->status; $this->grabbed_from = $obj->grabbed_from; $this->date_creation = $this->db->jdate($obj->date_creation); @@ -383,6 +387,7 @@ class WebsitePage extends CommonObject $sql .= " t.content,"; $sql .= " t.lang,"; $sql .= " t.fk_page,"; + $sql .= " t.allowed_in_frames,"; $sql .= " t.status,"; $sql .= " t.grabbed_from,"; $sql .= " t.date_creation,"; @@ -453,6 +458,7 @@ class WebsitePage extends CommonObject $record->content = $obj->content; $record->lang = $obj->lang; $record->fk_page = $obj->fk_page; + $record->allowed_in_frames = $obj->allowed_in_frames; $record->status = $obj->status; $record->grabbed_from = $obj->grabbed_from; $record->date_creation = $this->db->jdate($obj->date_creation); @@ -839,6 +845,7 @@ class WebsitePage extends CommonObject $this->description = 'This is my page'; $this->image = ''; $this->keywords = 'keyword1, keyword2'; + $this->allowed_in_frames = 1; $this->htmlheader = ''; $this->content = 'This is a html content'; $this->status = ''; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 2a073aded73..d8f93da3ba1 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -940,6 +940,7 @@ if ($action == 'addcontainer') $objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma'); $objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha'); $objectpage->keywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml')); + $objectpage->allowed_in_frames = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09'); $objectpage->htmlheader = GETPOST('htmlheader', 'none'); $objectpage->author_alias = GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml'); $objectpage->object_type = GETPOST('WEBSITE_OBJECTCLASS'); @@ -1562,7 +1563,7 @@ if ($action == 'setashome') } } -// Update page (meta) +// Update page properties (meta) if ($action == 'updatemeta') { $db->begin(); @@ -1656,6 +1657,7 @@ if ($action == 'updatemeta') $objectpage->description = str_replace(array('<', '>'), '', GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml')); $objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha'); $objectpage->keywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml')); + $objectpage->allowed_in_frames = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09'); $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); $objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0); $objectpage->author_alias = trim(GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml')); @@ -2831,7 +2833,6 @@ if (!GETPOST('hide_websitemenu')) print ''; // end websitehelp - if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') { // Adding jquery code to change on the fly url of preview ext @@ -2887,7 +2888,6 @@ if (!GETPOST('hide_websitemenu')) } - $head = array(); @@ -3279,7 +3279,7 @@ if ($action == 'importsite') print '
'; } -if ($action == 'editmeta' || $action == 'createcontainer') +if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of a web site OR properties of a web page { print '
'; @@ -3366,6 +3366,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') $pageimage = $objectpage->image; $pagekeywords = $objectpage->keywords; $pagelang = $objectpage->lang; + $pageallowedinframes = $objectpage->allowed_in_frames; $pagehtmlheader = $objectpage->htmlheader; $pagedatecreation = $objectpage->date_creation; $pagedatemodification = $objectpage->date_modification; @@ -3389,6 +3390,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage = GETPOST('WEBSITE_IMAGE', 'alpha'); if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml')); if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang = GETPOST('WEBSITE_LANG', 'aZ09'); + if (GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09')) $pageallowedinframes = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09'); if (GETPOST('htmlheader', 'none')) $pagehtmlheader = GETPOST('htmlheader', 'none'); if ($action != 'createcontainer') @@ -3542,6 +3544,15 @@ if ($action == 'editmeta' || $action == 'createcontainer') } print ''; + // Allowed in frames + print ''; + print $langs->trans('AllowedInFrames'); + //$htmlhelp = $langs->trans("AllowedInFramesDesc"); + //print $form->textwithpicto($langs->trans('AllowedInFrames'), $htmlhelp, 1, 'help', '', 0, 2, 'allowedinframestooltip'); + print ''; + print ''; + print ''; + // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { @@ -3566,18 +3577,19 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ""; } - print ''; - print 'ObjectClass'; - print ''; - print ''; - print ''; - - print ''; - print 'ObjectID'; - print ''; - print ''; - print ''; + if (!empty($conf->global->WEBSITE_PAGE_SHOW_INTERNAL_LINKS_TO_OBJECT)) { + print ''; + print 'ObjectClass'; + print ''; + print ''; + print ''; + print ''; + print 'ObjectID'; + print ''; + print ''; + print ''; + } $fuser = new User($db); From 5d0a54c0de1adc2fccfd96747988046b611c1cf2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 12:07:01 +0100 Subject: [PATCH 12/91] Fix var not defined --- htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php | 1 - htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 159ff81e33e..a84e6fed4a2 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -635,7 +635,6 @@ class pdf_eratosthene extends ModelePDFCommandes } - $nexY = max($pdf->GetY(), $posYAfterImage); diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 4ea8fcc585d..5e2e4380a0b 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -400,6 +400,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pageposbefore = $pdf->getPage(); $showpricebeforepagebreak = 1; + $posYAfterImage = 0; // Description of product line $curX = $this->posxdesc - 1; From 906669a54265931e1626e472315379ea3daa5c01 Mon Sep 17 00:00:00 2001 From: Thatoo Date: Thu, 26 Nov 2020 13:54:44 +0100 Subject: [PATCH 13/91] Update sync_members_types_dolibarr2ldap.php Solve following error : "Object of class AdherentType could not be converted to string in /var/www/html/dolibarr/scripts/members/sync_members_types_dolibarr2ldap.php on line 88" --- scripts/members/sync_members_types_dolibarr2ldap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/members/sync_members_types_dolibarr2ldap.php b/scripts/members/sync_members_types_dolibarr2ldap.php index 0a22469ec80..d0cf6ae7f04 100755 --- a/scripts/members/sync_members_types_dolibarr2ldap.php +++ b/scripts/members/sync_members_types_dolibarr2ldap.php @@ -89,7 +89,7 @@ if ($resql) { $membertype->id = $obj->rowid; $membertype->fetch($membertype->id); - print $langs->trans("UpdateMemberType")." rowid=".$membertype->id." ".$membertype - label; + print $langs->trans("UpdateMemberType")." rowid=".$membertype->id." ".$membertype->label; $oldobject = $membertype; From 17e13eb82127a0ce951c4c2b63df53e02fa5b066 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 26 Nov 2020 14:12:02 +0100 Subject: [PATCH 14/91] NEW show stock in supplier product select list --- htdocs/core/class/html.form.class.php | 42 ++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0c7b9d46f3c..41e0487e973 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2743,7 +2743,7 @@ class Form public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') { // phpcs:enable - global $langs, $conf, $db; + global $langs, $conf, $db, $user; $out = ''; $outarray = array(); @@ -2757,6 +2757,9 @@ class Form } $sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type,"; + if (!empty($conf->stock->enabled)) { + $sql .= " p.stock,"; + } $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"; @@ -2974,6 +2977,43 @@ class Form } } + if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) + { + if (!empty($user->rights->stock->lire)) { + $optlabel .= ' - '.$langs->trans("Stock").':'.$objp->stock; + + if ($objp->stock > 0) { + $outval .= ' - '; + } elseif ($objp->stock <= 0) { + $outval .= ' - '; + } + $outval .= $langs->transnoentities("Stock").':'.$objp->stock; + $outval .= ''; + if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation + { + $langs->load("stocks"); + + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after) + $tmpproduct->load_virtual_stock(); + $virtualstock = $tmpproduct->stock_theorique; + + $optlabel .= ' - '.$langs->trans("VirtualStock").':'.$virtualstock; + + $outval .= ' - '.$langs->transnoentities("VirtualStock").':'; + if ($virtualstock > 0) { + $outval .= ''; + } elseif ($virtualstock <= 0) { + $outval .= ''; + } + $outval .= $virtualstock; + $outval .= ''; + + unset($tmpproduct); + } + } + } + $opt = '