diff --git a/dev/resources/dbmodel/dolibarr_schema.mwb b/dev/resources/dbmodel/dolibarr_schema.mwb
index 54f5f065b39..9103be2bc11 100644
Binary files a/dev/resources/dbmodel/dolibarr_schema.mwb and b/dev/resources/dbmodel/dolibarr_schema.mwb differ
diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php
index c433043b6c5..13f34b955bd 100755
--- a/dev/tools/apstats.php
+++ b/dev/tools/apstats.php
@@ -61,7 +61,7 @@ if (empty($argv[1])) {
$outputpath = $argv[1];
$outputdir = dirname($outputpath);
$outputfile = basename($outputpath);
-$outputfilerss = preg_replace('/\.\w+$/i', '', $outputfile).'-security.rss';
+$outputfilerss = preg_replace('/\.\w+$/i', '', $outputfile).'-security.rss'; // Replace the .html by -security.rss
if (!is_dir($outputdir)) {
print 'Error: dir '.$outputdir.' does not exists or is not writable'."\n";
@@ -271,7 +271,7 @@ $nbofmonth = 6;
$delay = (3600 * 24 * 30 * $nbofmonth);
$arrayofalerts = array();
-$commandcheck = "git log --all --shortstat --no-renames --use-mailmap --pretty=".escapeshellarg('format:%cI;%H;%aN;%aE;%ce;%s')." --since=".escapeshellarg(dol_print_date(dol_now() - $delay, '%Y-%m-%d'))." | grep -i -E ".escapeshellarg("(#yogosha|CVE|Sec:|Sec |Sec$)");
+$commandcheck = "git log --all --shortstat --no-renames --use-mailmap --pretty=".escapeshellarg('format:%cI;%H;%aN;%aE;%ce;%s')." --since=".escapeshellarg(dol_print_date(dol_now() - $delay, '%Y-%m-%d'))." | grep -i -E ".escapeshellarg("(#yogosha|CVE|Sec:|Sec |^Sec$)");
print 'Execute git log to get commits related to security: '.$commandcheck."\n";
$output_arrglpu = array();
$resexecglpu = 0;
@@ -280,7 +280,7 @@ foreach ($output_arrglpu as $valgitlog) { // The most recent lines are first.
// Parse the line to split interesting data
$tmpval = cleanVal2($valgitlog);
- if (preg_match('/(#yogosha|CVE[\s\-]*\d|Sec:|Sec\s|Sec$)/i', $tmpval['title'])) { // Recommended git comment: "Sec: Fix #..."
+ if (preg_match('/(#yogosha|CVE[\s\-]*\d|Sec:|Sec\s|^Sec$)/i', $tmpval['title'])) { // Recommended git comment: "Sec: Fix #..."
$alreadyfound = '';
$alreadyfoundcommitid = '';
foreach ($arrayofalerts as $val) { // Loop on already found alerts
@@ -932,7 +932,7 @@ $html .= '';
$html .= '';
$html .= '
';
-$html .= 'Note:Search is done in git repository on regex string "#yogosha|CVE[\s\-]*\d|Sec:|Sec\s" (not case sensitive)
';
+$html .= 'Note:Search is done in git repository on regex string "#yogosha|CVE[\s\-]*\d|Sec:|Sec |^Sec\s" (not case sensitive)
';
$html .= 'You can use this URL for RSS notifications: '.$outputfilerss.'
';
$html .= '';
diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php
index 4fb0673c52b..d1b82802feb 100644
--- a/htdocs/asset/class/asset.class.php
+++ b/htdocs/asset/class/asset.class.php
@@ -747,25 +747,9 @@ class Asset extends CommonObject
return -1;
}
- // Old request with 'WITH'
- /*
- $sql = "WITH in_accounting_bookkeeping(fk_docdet) AS (";
- $sql .= " SELECT DISTINCT fk_docdet";
- $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
- $sql .= " WHERE doc_type = 'asset'";
- $sql .= ")";
- $sql .= "SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht";
- $sql .= ", " . $this->db->ifsql('iab.fk_docdet IS NOT NULL', 1, 0) . " AS bookkeeping";
+ $sql = "SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht,";
+ $sql .= " " . $this->db->ifsql('EXISTS (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type = \'asset\' AND ab.fk_docdet = ad.rowid)', '1', '0') . " AS bookkeeping";
$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad";
- $sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid";
- $sql .= " WHERE ad.fk_asset = " . (int) $this->id;
- $sql .= " ORDER BY ad.depreciation_date ASC";
- */
-
- $sql = "SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht";
- $sql .= ", " . $this->db->ifsql('iab.fk_docdet IS NOT NULL', '1', '0') . " AS bookkeeping";
- $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad";
- $sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid";
$sql .= " WHERE ad.fk_asset = " . (int) $this->id;
$sql .= " ORDER BY ad.depreciation_date ASC";
diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php
index 1ff57280382..732dfcf3c90 100644
--- a/htdocs/blockedlog/admin/blockedlog.php
+++ b/htdocs/blockedlog/admin/blockedlog.php
@@ -120,10 +120,9 @@ print ''.$langs->trans("BlockedLogDesc")."
country_code == 'FR') {
$htmltext = $langs->trans("UnalterableLogTool1FR").'
';
+ print info_admin($htmltext, 0, 0, 'warning');
}
-print info_admin($htmltext, 0, 0, 'warning');
-
print '
';
print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
diff --git a/htdocs/blockedlog/admin/blockedlog_archives.php b/htdocs/blockedlog/admin/blockedlog_archives.php
index 17978cfd7d4..3c37541cd4b 100644
--- a/htdocs/blockedlog/admin/blockedlog_archives.php
+++ b/htdocs/blockedlog/admin/blockedlog_archives.php
@@ -54,7 +54,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : get
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
-$hmacexportkey = GETPOST('hmacexportkey', 'password');
+//$hmacexportkey = GETPOST('hmacexportkey', 'password');
$search_showonlyerrors = GETPOSTINT('search_showonlyerrors');
if ($search_showonlyerrors < 0) {
@@ -179,10 +179,12 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { /
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Year")), null, "errors");
$error++;
}
+ /*
if (empty($hmacexportkey)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Password")), null, "errors");
$error++;
}
+ */
$dates = dol_get_first_day(GETPOSTINT('yeartoexport'), GETPOSTINT('monthtoexport') ? GETPOSTINT('monthtoexport') : 1);
$datee = dol_get_last_day(GETPOSTINT('yeartoexport'), GETPOSTINT('monthtoexport') ? GETPOSTINT('monthtoexport') : 12);
@@ -256,14 +258,17 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { /
$sql .= " FROM ".MAIN_DB_PREFIX."blockedlog";
$sql .= " WHERE entity = ".((int) $conf->entity);
if (GETPOSTINT('monthtoexport') > 0 || GETPOSTINT('yeartoexport') > 0) {
- $dates = dol_get_first_day(GETPOSTINT('yeartoexport'), GETPOSTINT('monthtoexport') ? GETPOSTINT('monthtoexport') : 1);
- $datee = dol_get_last_day(GETPOSTINT('yeartoexport'), GETPOSTINT('monthtoexport') ? GETPOSTINT('monthtoexport') : 12);
+ $dates = dol_get_first_day(GETPOSTINT('yeartoexport'), GETPOSTINT('monthtoexport') > 0 ? GETPOSTINT('monthtoexport') : 1);
+ $datee = dol_get_last_day(GETPOSTINT('yeartoexport'), GETPOSTINT('monthtoexport') > 0 ? GETPOSTINT('monthtoexport') : 12);
$sql .= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
}
$sql .= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature()
$resql = $db->query($sql);
if ($resql) {
+ $registrationnumber = getHashUniqueIdOfRegistration();
+ $secretkey = $registrationnumber;
+
$yearmonthtoexport = GETPOSTINT('yeartoexport').(GETPOSTINT('monthtoexport') > 0 ? sprintf("%02d", GETPOSTINT('monthtoexport')) : '');
$yearmonthdateofexport = dol_print_date(dol_now(), 'dayhourlog', 'gmt');
@@ -275,7 +280,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { /
$fh = fopen($tmpfile, 'w');
// Print line with title
- fwrite($fh, "BEGIN - date=".$yearmonthdateofexport
+ fwrite($fh, "BEGIN - date=".$yearmonthdateofexport." - period=".$yearmonthtoexport
.';'.$langs->transnoentities('Id')
.';'.$langs->transnoentities('DateCreation')
.';'.$langs->transnoentities('Action')
@@ -290,6 +295,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { /
.';'.$langs->transnoentities('Fingerprint')
.';'.$langs->transnoentities('Status')
.';'.$langs->transnoentities('FingerprintExport')
+ //.';'.$langs->transnoentities('FingerprintExportHMAC')
."\n");
$loweridinerror = 0;
@@ -355,6 +361,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { /
}
$signatureexport = 'TODO';
+ $signatureexporthmac = 'TODO';
fwrite($fh,
';'.$block_static->id
@@ -370,7 +377,8 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { /
.';"'.str_replace('"', '""', $block_static->object_version).'";"'
.str_replace('"', '""', $block_static->signature).'";"'
.str_replace('"', '""', $statusofrecord).'";"'
- .str_replace('"', '""', $signatureexport).'"'
+ .str_replace('"', '""', $signatureexport).'";'
+ //.str_replace('"', '""', $signatureexporthmac).'"'
//.';'.$statusofrecordnote
."\n");
@@ -384,11 +392,11 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { /
// Calculate the md5 of the file (the last line has a return line)
$algo = 'sha256';
- $secretkey = 'TODOASKBEFOREEXPORT';
+ $sha256 = hash_file($algo, $tmpfile);
$hmacsha256 = hash_hmac_file($algo, $tmpfile, $secretkey);
// Now add a signature to check integrity at end of file
- file_put_contents($tmpfile, 'END - hmac_sha256='.$hmacsha256, FILE_APPEND);
+ file_put_contents($tmpfile, 'END - sha256='.$sha256.' - hmac_sha256='.$hmacsha256, FILE_APPEND);
setEventMessages($langs->trans("FileGenerated"), null);
} else {
@@ -540,7 +548,8 @@ print '';
+// Disabled, we will use the getHashUniqueIdOfRegistration() as secret HMAC
+//print '';
print ' ';
diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php
index e219d9d50bb..2a44e0b631c 100644
--- a/htdocs/blockedlog/admin/blockedlog_list.php
+++ b/htdocs/blockedlog/admin/blockedlog_list.php
@@ -426,7 +426,7 @@ $htmltext = '';
$htmltext .= $langs->trans("UnalterableLogTool2", $langs->transnoentitiesnoconv("Archives"))."
";
$htmltext .= $langs->trans("UnalterableLogTool3")."
";
-print info_admin($htmltext);
+print info_admin($htmltext, 0, 0, 'warning');
print '
';
diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php
index 266c79ef765..3848fbef831 100644
--- a/htdocs/blockedlog/ajax/block-info.php
+++ b/htdocs/blockedlog/ajax/block-info.php
@@ -129,6 +129,8 @@ function formatObject($objtoshow, $prefix)
'pos_source' => "POSTerminal",
'posmodule' => 'POSModule',
'posnumber' => 'POSTerminal',
+ 'pos_print_counter' => "NumberOfPrints",
+ 'email_sent_counter' => "NumberOfEmailsSent",
'managers' => 'Managers',
'type_code' => 'PaymentMode',
'datec' => 'DateCreation',
@@ -153,11 +155,13 @@ function formatObject($objtoshow, $prefix)
'tva_tx' => 'VatRate',
'localtax1_tx' => 'Localtax1Rate',
'localtax2_tx' => 'Localtax2Rate',
+ 'vat_src_code' => 'VatCode',
'multicurrency_code' => 'Currency',
'qty' => 'Quantity',
'nom' => 'Name',
'name' => 'Name',
'email' => 'Email',
+ 'state_code' => 'State',
'revenuestamp' => 'RevenueStamp',
'code_client' => 'CustomerCode',
'capital' => 'Capital',
@@ -167,9 +171,10 @@ function formatObject($objtoshow, $prefix)
'localtax2_value' => 'LocalTax2DefaultValue',
'subprice' => 'UnitPrice',
'product_type' => 'ProductType',
+ 'product_label' => 'ProductLabel',
'type' => 'InvoiceType',
'info_bits' => 'TVA NPR or NOT',
- 'special_code' => 'Special line (WEEE line, option, id of module...)'
+ 'special_code' => 'Special line (WEEE line, option, id of module...)',
);
if (is_object($newobjtoshow) || is_array($newobjtoshow)) {
diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php
index 7c3e965e266..3981bca7afa 100644
--- a/htdocs/blockedlog/class/blockedlog.class.php
+++ b/htdocs/blockedlog/class/blockedlog.class.php
@@ -193,7 +193,7 @@ class BlockedLog
$sep = 0;
- // Customer Invoice/Facture / Payment
+ // Customer Invoice/Facture / Payment (For most VAT antifraud laws)
if (isModEnabled('invoice')) {
$sep++;
$this->trackedevents['separator_'.$sep] = array('id' => 'separator_'.$sep, 'label' => '----------', 'labelhtml' => '----- '.$langs->trans("Invoices").' | '.$langs->trans("Payments").'', 'disabled' => 1);
@@ -221,7 +221,7 @@ class BlockedLog
*/
// Donation
- if (isModEnabled('don')) {
+ if (isModEnabled('don') && getDolGlobalString('BLOCKEDLOG_ENABLE_DONATION')) { // For countries that need unalterable logs for donations
if (!empty($this->trackedevents)) {
$sep++;
$this->trackedevents['separator_'.$sep] = array('id' => 'separator_'.$sep, 'label' => '----------', 'labelhtml' => '----- '.$langs->trans("Donations").' | '.$langs->trans("Payments").'', 'disabled' => 1);
@@ -244,7 +244,7 @@ class BlockedLog
*/
// Members
- if (isModEnabled('member')) {
+ if (isModEnabled('member') && getDolGlobalString('BLOCKEDLOG_ENABLE_MEMBER')) { // For countries that need unalterable logs for membership management
if (!empty($this->trackedevents)) {
$sep++;
$this->trackedevents['separator_'.$sep] = array('id' => 'separator_'.$sep, 'label' => '----------', 'labelhtml' => '----- '.$langs->trans("MenuMembers").'', 'disabled' => 1);
@@ -256,6 +256,7 @@ class BlockedLog
}
// Bank
+ /*
if (isModEnabled("bank")) {
if (!empty($this->trackedevents)) {
$sep++;
@@ -266,6 +267,7 @@ class BlockedLog
$this->trackedevents['PAYMENT_VARIOUS_MODIFY'] = array('id' => 'PAYMENT_VARIOUS_MODIFY', 'label' => 'logPAYMENT_VARIOUS_MODIFY', 'labelhtml' => img_picto('', 'bank', 'class="pictofixedwidth").').$langs->trans('logPAYMENT_VARIOUS_MODIFY'));
$this->trackedevents['PAYMENT_VARIOUS_DELETE'] = array('id' => 'PAYMENT_VARIOUS_DELETE', 'label' => 'logPAYMENT_VARIOUS_DELETE', 'labelhtml' => img_picto('', 'bank', 'class="pictofixedwidth").').$langs->trans('logPAYMENT_VARIOUS_DELETE'));
}
+ */
// Cash register closing
// $conf->global->BANK_ENABLE_POS_CASHCONTROL must be set to 1 by all external POS modules
@@ -279,8 +281,8 @@ class BlockedLog
$this->trackedevents['CASHCONTROL_VALIDATE'] = array('id' => 'CASHCONTROL_VALIDATE', 'label' => 'logCASHCONTROL_VALIDATE', 'labelhtml' => img_picto('', 'pos', 'class="pictofixedwidth").').$langs->trans('logCASHCONTROL_VALIDATE'));
}
- // Add more action to track from a conf variable
- // For example: STOCK_MOVEMENT,...
+ // Add more action to track from a conf variable. For the case we want to track other actions into the unalterable log.
+ // For example: STOCK_MOVEMENT, ...
if (getDolGlobalString('BLOCKEDLOG_ADD_ACTIONS_SUPPORTED')) {
if (!empty($this->trackedevents)) {
$sep++;
@@ -515,7 +517,8 @@ class BlockedLog
'table_element', 'fields',
'ref_previous', 'ref_next',
'origin', 'origin_id',
- 'oldcopy', 'picto', 'error', 'errors', 'model_pdf', 'modelpdf', 'last_main_doc', 'civility_id', 'contact', 'contact_id',
+ 'oldcopy', 'picto', 'error', 'errors',
+ 'model_pdf', 'modelpdf', 'last_main_doc', 'civility_id', 'contact', 'contact_id',
'table_element_line', 'ismultientitymanaged', 'isextrafieldmanaged',
'array_languages',
'childtables',
@@ -554,17 +557,32 @@ class BlockedLog
// List of fields qualified
if (!in_array($key, array(
'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode',
- 'tva_intra', 'tva_assuj', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
+ 'tva_intra', 'tva_assuj', 'localtax1_assuj', 'localtax2_assuj', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
))) {
continue; // Discard if not into this dedicated list
}
- if (!is_object($value) && !is_null($value) && $value !== '') {
+
+ $valuequalifiedforstorage = false;
+ if (!is_object($value)) {
+ if (empty($value) && in_array($key, array('country_code', 'idprof1', 'idprof2', 'tva_intra'))) {
+ $valuequalifiedforstorage = true; // We accept '' value for some fields
+ $value = (string) $value;
+ }
+ if (!is_null($value) && empty($value) && in_array($key, array('tva_assuj', 'localtax1_assuj', 'localtax2_assuj'))) {
+ $valuequalifiedforstorage = true; // We accept zero value for amounts
+ }
+ if (!is_null($value) && (string) $value !== '') {
+ $valuequalifiedforstorage = true;
+ }
+ }
+
+ if ($valuequalifiedforstorage) {
$this->object_data->thirdparty->$key = $value;
}
}
}
- // Add company info
+ // Add my company info
if (!empty($mysoc)) {
$this->object_data->mycompany = new stdClass();
@@ -572,14 +590,29 @@ class BlockedLog
if (in_array($key, $arrayoffieldstoexclude)) {
continue; // Discard some properties
}
- // List of fields qualified
+ // List of fields qualified to keep
if (!in_array($key, array(
'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode',
'tva_assuj', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
))) {
continue; // Discard if not into this dedicated list
}
- if (!is_object($value) && !is_null($value) && $value !== '') {
+
+ $valuequalifiedforstorage = false;
+ if (!is_object($value)) {
+ if (empty($value) && in_array($key, array('country_code', 'idprof1', 'idprof2', 'tva_intra'))) {
+ $valuequalifiedforstorage = true; // We accept '' value for some fields
+ $value = (string) $value;
+ }
+ if (!is_null($value) && empty($value) && in_array($key, array('tva_assuj'))) {
+ $valuequalifiedforstorage = true; // We accept zero value for amounts
+ }
+ if (!is_null($value) && (string) $value !== '') {
+ $valuequalifiedforstorage = true;
+ }
+ }
+
+ if ($valuequalifiedforstorage) {
$this->object_data->mycompany->$key = $value;
}
}
@@ -600,10 +633,14 @@ class BlockedLog
}
// List of fields qualified
if (!in_array($key, array(
- 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'datev', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public', 'lines',
- 'module_source', 'pos_source'
+ 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'datev', 'type',
+ //'vat_src_code', 'tva_tx', 'localtax1_tx', 'localtax2_tx', There is no rate at full doc level
+ 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2',
+ 'revenuestamp', 'datepointoftax', 'note_public',
+ 'lines',
+ 'module_source', 'pos_source', 'pos_print_counter', 'email_sent_counter'
))) {
- continue; // Discard if not into a dedicated list
+ continue; // Discarded if not into the dedicated list
}
if ($key == 'lines') {
$lineid = 0;
@@ -612,8 +649,7 @@ class BlockedLog
foreach ($tmpline as $keyline => $valueline) {
if (!in_array($keyline, array(
'ref', 'product_type', 'product_label',
- 'qty',
- 'subprice',
+ 'qty', 'subprice',
'vat_src_code', 'tva_tx', 'localtax1_tx', 'localtax2_tx',
'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2',
'multicurrency_code', 'multicurrency_total_ht', 'multicurrency_total_tva', 'multicurrency_total_ttc',
@@ -626,13 +662,43 @@ class BlockedLog
$this->object_data->invoiceline[$lineid] = new stdClass();
}
- if (!is_object($valueline) && !is_null($valueline) && $valueline !== '') {
+ $valuequalifiedforstorage = false;
+ if (!is_object($valueline)) {
+ if (!is_null($valueline) && empty($valueline) && in_array($key, array('tva_tx', 'localtax1_tx', 'localtax2_tx', 'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2'))) {
+ $valuequalifiedforstorage = true; // We accept zero value for amounts
+ }
+ if (!is_null($valueline) && (string) $valueline !== '') {
+ $valuequalifiedforstorage = true;
+ }
+ }
+ if ($keyline == 'product_label' && empty($valueline)) {
+ $valueline = dol_trunc(dolGetFirstLineOfText($tmpline->desc)); // Fallback on description if label is empty
+ $valuequalifiedforstorage = true;
+ }
+
+ if ($valuequalifiedforstorage) {
$this->object_data->invoiceline[$lineid]->$keyline = $valueline;
}
}
}
- } elseif (!is_object($value) && !is_null($value) && $value !== '') {
- $this->object_data->$key = $value;
+ } else {
+ $valuequalifiedforstorage = false;
+ if (!is_object($value)) {
+ if (empty($value) && in_array($key, array('pos_source', 'module_source'))) {
+ $valuequalifiedforstorage = true; // We accept '' value for some fields
+ $value = (string) $value;
+ }
+ if (!is_null($value) && empty($value) && in_array($key, array('total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'pos_print_counter', 'email_sent_counter'))) {
+ $valuequalifiedforstorage = true; // We accept zero value for amounts
+ }
+ if (!is_null($value) && (string) $value !== '') {
+ $valuequalifiedforstorage = true;
+ }
+ }
+
+ if ($valuequalifiedforstorage) {
+ $this->object_data->$key = $value;
+ }
}
}
@@ -651,7 +717,22 @@ class BlockedLog
))) {
continue; // Discard if not into a dedicated list
}
- if (!is_object($value) && !is_null($value) && $value !== '') {
+
+ $valuequalifiedforstorage = false;
+ if (!is_object($value)) {
+ if (empty($value) && in_array($key, array('pos_source', 'module_source'))) {
+ $valuequalifiedforstorage = true; // We accept '' value for some fields
+ $value = (string) $value;
+ }
+ if (!is_null($value) && empty($value) && in_array($key, array('total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'pos_print_counter', 'email_sent_counter'))) {
+ $valuequalifiedforstorage = true; // We accept zero value for amounts
+ }
+ if (!is_null($value) && (string) $value !== '') {
+ $valuequalifiedforstorage = true;
+ }
+ }
+
+ if ($valuequalifiedforstorage) {
$this->object_data->$key = $value;
}
}
@@ -679,7 +760,7 @@ class BlockedLog
$totalamount = 0;
- // Loop on each invoice payment amount (payment_part)
+ // Loop on each invoice payment amount (the payment_part)
if (is_array($object->amounts) && !empty($object->amounts)) {
$paymentpartnumber = 0;
foreach ($object->amounts as $objid => $amount) {
@@ -738,7 +819,7 @@ class BlockedLog
if (in_array($key, $arrayoffieldstoexclude)) {
continue; // Discard some properties
}
- // List of fields qualified
+ // List of thirdparty fields qualified
if (!in_array($key, array(
'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode',
'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
@@ -754,6 +835,8 @@ class BlockedLog
// Init object to avoid warnings
if ($this->element == 'payment_donation') {
$paymentpart->donation = new stdClass();
+ } elseif ($this->element == 'payment_various') {
+ $paymentpart->various = new stdClass();
} else {
$paymentpart->invoice = new stdClass();
}
@@ -765,11 +848,27 @@ class BlockedLog
}
// List of fields qualified
if (!in_array($key, array(
- 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public'
+ 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public',
+ 'pos_source', 'module_source', 'pos_print_counter', 'email_sent_counter'
))) {
continue; // Discard if not into a dedicated list
}
- if (!is_object($value) && !is_null($value) && $value !== '') {
+
+ $valuequalifiedforstorage = false;
+ if (!is_object($value)) {
+ if (empty($value) && in_array($key, array('pos_source', 'module_source'))) {
+ $valuequalifiedforstorage = true; // We accept '' value for some fields
+ $value = (string) $value;
+ }
+ if (!is_null($value) && empty($value) && in_array($key, array('total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'pos_print_counter', 'email_sent_counter'))) {
+ $valuequalifiedforstorage = true; // We accept zero value for amounts
+ }
+ if (!is_null($value) && (string) $value !== '') {
+ $valuequalifiedforstorage = true;
+ }
+ }
+
+ if ($valuequalifiedforstorage) {
if ($this->element == 'payment_donation') {
$paymentpart->donation->$key = $value;
} elseif ($this->element == 'payment_various') {
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index 39a070b4cf8..ae8ea1ab4bd 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -801,7 +801,8 @@ if ($sql) {
print '
';
$parameters = array('user' => $user);
-$reshook = $hookmanager->executeHooks('dashboardAccountancy', $parameters, $object); // Note that $action and $object may have been modified by hook
+$object = null;
+$reshook = $hookmanager->executeHooks('dashboardAccountancy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
// End of page
llxFooter();
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 39ef25cb706..ab80518641f 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -9874,7 +9874,7 @@ abstract class CommonObject
}
}
- if (empty($buyPrice) && isset($conf->global->MARGIN_TYPE) && in_array($conf->global->MARGIN_TYPE, array('1', 'pmp', 'costprice'))) {
+ if (empty($buyPrice) && in_array(getDolGlobalString('MARGIN_TYPE'), array('1', 'pmp', 'costprice'))) {
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$productFournisseur = new ProductFournisseur($this->db);
if (($result = $productFournisseur->find_min_price_product_fournisseur($fk_product)) > 0) {
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index c1575a91f69..5736d0a50d9 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -7579,7 +7579,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
//print $amount."-";
$data = explode('.', $amount);
$decpart = isset($data[1]) ? $data[1] : '';
- $decpart = preg_replace('/0+$/i', '', $decpart); // Supprime les 0 de fin de partie decimale
+ $decpart = preg_replace('/0+$/i', '', $decpart); // Remove 0 at end of decimal part
//print "decpart=".$decpart."
";
$end = '';
@@ -7662,7 +7662,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
*/
function price2num($amount, $rounding = '', $option = 0)
{
- global $langs, $conf;
+ global $langs;
// Clean parameters
if (is_null($amount)) {
@@ -12698,7 +12698,6 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
function printCommonFooter($zone = 'private')
{
global $conf, $hookmanager, $user, $langs;
- global $debugbar;
global $action;
global $micro_start_time;
@@ -12712,8 +12711,9 @@ function printCommonFooter($zone = 'private')
print "\n\n";
print '' . (GETPOST('page_y') ? GETPOST('page_y') : '') . '
' . "\n";
- $parameters = array();
- $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks
+ $parameters = array('zone' => $zone);
+ $tmpobject = null;
+ $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters, $tmpobject, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) {
if (getDolGlobalString('MAIN_HTML_FOOTER')) {
print getDolGlobalString('MAIN_HTML_FOOTER') . "\n";
@@ -12907,7 +12907,7 @@ function printCommonFooter($zone = 'private')
print "\n" . '' . "\n";
// Google Analytics
- // TODO Add a hook here
+ // TODO Remove this, can be replaced with the hook printCommonFooter
if (isModEnabled('google') && getDolGlobalString('MAIN_GOOGLE_AN_ID')) {
$tmptagarray = explode(',', getDolGlobalString('MAIN_GOOGLE_AN_ID'));
foreach ($tmptagarray as $tmptag) {
@@ -12933,15 +12933,23 @@ function printCommonFooter($zone = 'private')
print_r(xdebug_get_code_coverage());
}
+ // Output string from hooks
+ if (!empty($hookmanager->resPrint)) {
+ print $hookmanager->resPrint;
+ }
+
// Add DebugBar data
- if ($user->hasRight('debugbar', 'read') && $debugbar instanceof DebugBar\DebugBar) {
- if (isset($debugbar['time'])) {
- // @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
- $debugbar['time']->stopMeasure('pageaftermaster');
+ if ($user->hasRight('debugbar', 'read')) {
+ global $debugbar;
+ if ($debugbar instanceof DebugBar\DebugBar) {
+ if (isset($debugbar['time'])) {
+ // @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
+ $debugbar['time']->stopMeasure('pageaftermaster');
+ }
+ print '' . "\n";
+ $renderer = $debugbar->getJavascriptRenderer();
+ print $renderer->render();
}
- print '' . "\n";
- $renderer = $debugbar->getJavascriptRenderer();
- print $renderer->render();
} elseif (count($conf->logbuffer)) { // If there is some logs in buffer to show
print "\n";
print "