From 042038d185686e88dc727941694034d1145e9909 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 18 Feb 2021 22:42:55 +0100 Subject: [PATCH 1/5] Code enhanced - Standardize field name #14697 --- htdocs/comm/propal/class/propal.class.php | 8 ++++- htdocs/comm/propal/index.php | 2 +- htdocs/comm/propal/list.php | 30 +++++++++---------- .../install/mysql/migration/13.0.0-14.0.0.sql | 3 ++ htdocs/install/mysql/tables/llx_propal.sql | 6 ++-- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a115d8bca5e..51ec7e6e53a 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -185,6 +185,12 @@ class Propal extends CommonObject */ public $total; + public $total_ht = 0; + public $total_tva = 0; + public $total_localtax1 = 0; + public $total_localtax2 = 0; + public $total_ttc = 0; + public $cond_reglement_code; public $mode_reglement_code; public $remise = 0; @@ -285,7 +291,7 @@ class Propal extends CommonObject 'remise_absolue' =>array('type'=>'double', 'label'=>'CustomerRelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>115), //'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>120), 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1), - 'tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1), + 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1), 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LocalTax1', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LocalTax2', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1), 'total' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1), diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index b51f138b0e5..c274ebf74f3 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -198,7 +198,7 @@ if ($resql) * Draft proposals */ if (!empty($conf->propal->enabled)) { - $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc"; + $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total as total_ttc"; $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 5eca82f022c..d05543530d1 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -181,14 +181,14 @@ $arrayfields = array( 'p.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>0), 'p.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>0), 'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), - 'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), + 'p.total_tva'=>array('label'=>"AmountVAT", 'checked'=>0), 'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), 'p.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'p.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'p.multicurrency_total_tva'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), @@ -391,8 +391,8 @@ $sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.tow $sql .= " typent.code as typent_code,"; $sql .= " ava.rowid as availability,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; -$sql .= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut as status, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; -$sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva as multicurrency_total_vat, p.multicurrency_total_ttc,'; +$sql .= ' p.rowid, p.entity, p.note_private, p.total_ht, p.total_tva, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut as status, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; +$sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc,'; $sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,'; $sql .= ' p.note_public, p.note_private,'; $sql .= ' p.fk_cond_reglement,p.fk_mode_reglement,p.fk_shipping_method,'; @@ -449,7 +449,7 @@ if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_societe_alias) $sql .= natural_search('s.name_alias', $search_societe_alias); if ($search_login) $sql .= natural_search("u.login", $search_login); if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1); -if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1); +if ($search_montant_vat != '') $sql .= natural_search("p.total_tva", $search_montant_vat, 1); if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1); if ($search_multicurrency_code != '') $sql .= ' AND p.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; if ($search_multicurrency_tx != '') $sql .= natural_search('p.multicurrency_tx', $search_multicurrency_tx, 1); @@ -834,7 +834,7 @@ if ($resql) print ''; print ''; } - if (!empty($arrayfields['p.total_vat']['checked'])) + if (!empty($arrayfields['p.total_tva']['checked'])) { // Amount print ''; @@ -881,7 +881,7 @@ if ($resql) print ''; print ''; } - if (!empty($arrayfields['p.multicurrency_total_vat']['checked'])) + if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) { // Amount print ''; @@ -992,14 +992,14 @@ if ($resql) if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['p.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['p.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.total_tva']['checked'])) print_liste_field_titre($arrayfields['p.total_tva']['label'], $_SERVER["PHP_SELF"], 'p.total_tva', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_code', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_tx', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['p.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); @@ -1267,12 +1267,12 @@ if ($resql) $totalarray['val']['p.total_ht'] += $obj->total_ht; } // Amount VAT - if (!empty($arrayfields['p.total_vat']['checked'])) + if (!empty($arrayfields['p.total_tva']['checked'])) { - print ''.price($obj->total_vat)."\n"; + print ''.price($obj->total_tva)."\n"; if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_vat'; - $totalarray['val']['p.total_vat'] += $obj->total_vat; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_tva'; + $totalarray['val']['p.total_tva'] += $obj->total_tva; } // Amount TTC if (!empty($arrayfields['p.total_ttc']['checked'])) @@ -1320,9 +1320,9 @@ if ($resql) if (!$i) $totalarray['nbfield']++; } // Amount VAT - if (!empty($arrayfields['p.multicurrency_total_vat']['checked'])) + if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) { - print ''.price($obj->multicurrency_total_vat)."\n"; + print ''.price($obj->multicurrency_total_tva)."\n"; if (!$i) $totalarray['nbfield']++; } // Amount TTC diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index f2be5893c0a..49809f2de91 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -170,3 +170,6 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


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

__(ThisIsContentOfYourOragnisationEventBulkMailToAttendes)__

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

__(ThisIsContentOfYourOragnisationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); + +-- Uniformize field total_ht, total_tva, total_ttc +ALTER TABLE llx_propal CHANGE COLUMN tva total_tva double(24,8) default 0; diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index 6e3e38dffd6..0a348c6aa6c 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -48,7 +48,7 @@ create table llx_propal remise_absolue real DEFAULT 0, -- remise globale absolue (obsolete) remise real DEFAULT 0, -- remise calculee (obsolete) total_ht double(24,8) DEFAULT 0, -- montant total ht apres remise globale - tva double(24,8) DEFAULT 0, -- montant total tva apres remise globale + total_tva double(24,8) DEFAULT 0, -- montant total tva apres remise globale localtax1 double(24,8) DEFAULT 0, -- amount total localtax1 localtax2 double(24,8) DEFAULT 0, -- amount total localtax2 total double(24,8) DEFAULT 0, -- montant total ttc apres remise globale @@ -76,9 +76,9 @@ create table llx_propal fk_delivery_address integer, -- delivery address (deprecated) fk_multicurrency integer, - multicurrency_code varchar(255), + multicurrency_code varchar(255), multicurrency_tx double(24,8) DEFAULT 1, - multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_ht double(24,8) DEFAULT 0, multicurrency_total_tva double(24,8) DEFAULT 0, multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; From 041390dc2242745efe913e076e7629558240bc3d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 19 Feb 2021 06:49:24 +0100 Subject: [PATCH 2/5] Code enhanced - Standardize field name #14697 --- ChangeLog | 1 + htdocs/comm/propal/class/propal.class.php | 14 ++++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b73c4b2212..de736200364 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The ICS value for direct debit or credit transfer is now store on each bank account instead of into the global setup. * API /setup/shipment_methods has been replaced with API /setup/shipping_methods +* Field tva move to total_tva in llx_propal diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 51ec7e6e53a..aadc1f55281 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -185,12 +185,6 @@ class Propal extends CommonObject */ public $total; - public $total_ht = 0; - public $total_tva = 0; - public $total_localtax1 = 0; - public $total_localtax2 = 0; - public $total_ttc = 0; - public $cond_reglement_code; public $mode_reglement_code; public $remise = 0; @@ -1044,7 +1038,7 @@ class Propal extends CommonObject $sql .= ", remise"; $sql .= ", remise_percent"; $sql .= ", remise_absolue"; - $sql .= ", tva"; + $sql .= ", total_tva"; $sql .= ", total"; $sql .= ", datep"; $sql .= ", datec"; @@ -1431,7 +1425,7 @@ class Propal extends CommonObject public function fetch($rowid, $ref = '', $ref_ext = '') { $sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; - $sql .= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; + $sql .= ", p.total, p.total_tva, p.localtax1, p.localtax2, p.total_ht"; $sql .= ", p.datec"; $sql .= ", p.date_valid as datev"; $sql .= ", p.datep as dp"; @@ -1489,7 +1483,7 @@ class Propal extends CommonObject $this->remise_absolue = $obj->remise_absolue; $this->total = $obj->total; // TODO deprecated $this->total_ht = $obj->total_ht; - $this->total_tva = $obj->tva; + $this->total_tva = $obj->total_tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total; @@ -1624,7 +1618,7 @@ class Propal extends CommonObject $sql .= " datep=".(strval($this->date) != '' ? "'".$this->db->idate($this->date)."'" : 'null').","; if (!empty($this->fin_validite)) $sql .= " fin_validite=".(strval($this->fin_validite) != '' ? "'".$this->db->idate($this->fin_validite)."'" : 'null').","; $sql .= " date_valid=".(strval($this->date_validation) != '' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; - $sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; + $sql .= " total_tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; $sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").","; $sql .= " localtax2=".(isset($this->total_localtax2) ? $this->total_localtax2 : "null").","; $sql .= " total_ht=".(isset($this->total_ht) ? $this->total_ht : "null").","; From 708a9fb453cd3d14a93bb06e52efb36c4ff6c926 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 19 Feb 2021 21:57:54 +0100 Subject: [PATCH 3/5] Code enhanced - Standardize field name --- htdocs/core/class/commonobject.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 08391a4a797..367ca1cc813 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3230,7 +3230,10 @@ abstract class CommonObject // Specific code for backward compatibility with old field names if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht = 'total'; if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva = 'total_tva'; - if ($this->element == 'propal') $fieldttc = 'total'; + if ($this->element == 'propal') { + $fieldttc = 'total'; + $fieldtva = 'total_tva'; + } if ($this->element == 'expensereport') $fieldtva = 'total_tva'; if ($this->element == 'supplier_proposal') $fieldttc = 'total'; From ade5d98d560ab3d18b7fa7ffcd47a49be90dc0c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 20 Feb 2021 17:03:27 +0100 Subject: [PATCH 4/5] Rename script to run cron by url to avoid confusion with script from cli --- htdocs/core/lib/cron.lib.php | 4 ++-- .../cron/{cron_run_jobs.php => cron_run_jobs_by_url.php} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename htdocs/public/cron/{cron_run_jobs.php => cron_run_jobs_by_url.php} (100%) diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php index fda122be7bf..9702c8ab1dc 100644 --- a/htdocs/core/lib/cron.lib.php +++ b/htdocs/core/lib/cron.lib.php @@ -99,10 +99,10 @@ function dol_print_cron_urls() // Cron launch print '
'; print $langs->trans("URLToLaunchCronJobs").':
'; - $url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; + $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; print img_picto('', 'globe').' '.$url."
\n"; print ' '.$langs->trans("OrToLaunchASpecificJob").'
'; - $url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; + $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; print img_picto('', 'globe').' '.$url."
\n"; print '
'; print '
'; diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs_by_url.php similarity index 100% rename from htdocs/public/cron/cron_run_jobs.php rename to htdocs/public/cron/cron_run_jobs_by_url.php From cfccc4923572186e99f0982cabd54d6283317e4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 20 Feb 2021 17:23:03 +0100 Subject: [PATCH 5/5] Code comment --- htdocs/core/class/translate.class.php | 2 +- htdocs/core/lib/memory.lib.php | 29 ++++++++++----------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index a706d9a880e..c2850990ff5 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -460,7 +460,7 @@ class Translate $tmparray = dol_getcache($usecachekey); if (is_array($tmparray) && count($tmparray)) { - $this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a valuer already exists into tab_translate, value into tmparaay is not added. + $this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added. //print $newdomain."\n"; //var_dump($this->tab_translate); $fileread = 1; diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 90120dc63f1..95e9aff52d3 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -36,7 +36,7 @@ $shmoffset = 1000; // Max number of entries found into a language file. If too l * Save data into a memory area shared by all users, all sessions on server * * @param string $memoryid Memory id of shared area - * @param mixed $data Data to save + * @param mixed $data Data to save. It must not be a null value. * @return int <0 if KO, Nb of bytes written if OK * @see dol_getcache() */ @@ -100,7 +100,7 @@ function dol_setcache($memoryid, $data) * Read a memory area shared by all users, all sessions on server * * @param string $memoryid Memory id of shared area - * @return int|mixed <0 if KO, data if OK + * @return int|mixed <0 if KO, data if OK, null if not found into cache * @see dol_setcache() */ function dol_getcache($memoryid) @@ -108,11 +108,9 @@ function dol_getcache($memoryid) global $conf; // Using a memcached server - if (!empty($conf->memcached->enabled) && class_exists('Memcached')) - { + if (!empty($conf->memcached->enabled) && class_exists('Memcached')) { global $m; - if (empty($m) || !is_object($m)) - { + if (empty($m) || !is_object($m)) { $m = new Memcached(); $tmparray = explode(':', $conf->global->MEMCACHED_SERVER); $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211); @@ -126,17 +124,14 @@ function dol_getcache($memoryid) $rescode = $m->getResultCode(); //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n
"; //var_dump($data); - if ($rescode == 0) - { + if ($rescode == 0) { return $data; } else { return -$rescode; } - } elseif (!empty($conf->memcached->enabled) && class_exists('Memcache')) - { + } elseif (!empty($conf->memcached->enabled) && class_exists('Memcache')) { global $m; - if (empty($m) || !is_object($m)) - { + if (empty($m) || !is_object($m)) { $m = new Memcache(); $tmparray = explode(':', $conf->global->MEMCACHED_SERVER); $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211); @@ -148,20 +143,18 @@ function dol_getcache($memoryid) $data = $m->get($memoryid); //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n
"; //var_dump($data); - if ($data) - { + if ($data) { return $data; } else { return -1; } - } // Using shmop - elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) - { + } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { + // Using shmop $data = dol_getshmop($memoryid); return $data; } - return 0; + return null; }