diff --git a/.github/workflows/ci-on-release.yml b/.github/workflows/ci-on-release.yml new file mode 100644 index 00000000000..7c3b0d716e3 --- /dev/null +++ b/.github/workflows/ci-on-release.yml @@ -0,0 +1,22 @@ +name: "CI-RELEASE" + +on: + release: + types: [published] + +jobs: + trigger-docker: + steps: + - name: Generate a token + id: generate-token + uses: actions/create-github-app-token@v2 + with: + app-id: ${{ vars.RELEASE_DOCKER_ID }} + private-key: ${{ secrets.RELEASE_DOCKER_SECRET }} + + - uses: peter-evans/repository-dispatch@v4 + with: + token: ${{ steps.generate-token.outputs.token }} + repository: Dolibarr/dolibarr-docker + event-type: new-release + client-payload: '{"version": "${{ github.event.release.tag_name }}"}' 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/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index fbd951ba5b8..0e8a6c6f2ed 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1048,7 +1048,7 @@ class Setup extends DolibarrApi global $langs; $langs->loadLangs(array('holiday')); - if (!DolibarrApiAccess::$user->hasRight('holiday', 'lire')) { + if (!DolibarrApiAccess::$user->hasRight('holiday', 'read')) { throw new RestException(403); } 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/comm/propal/card.php b/htdocs/comm/propal/card.php index e5d201387b3..e9ff4470744 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -19,6 +19,7 @@ * Copyright (C) 2023 William Mead * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Alexandre Spangaro + * Copyright (C) 2025 Benjamin Falière * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1956,6 +1957,12 @@ if (empty($reshook)) { $type = $product->type; $price_base_type = $product->price_base_type; + + // If base type TTc, we change pu value to define the TTC one + if ($price_base_type == 'TTC') { + $pu = $pu_ttc; + } + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); $price_min = $product->price_min; @@ -3521,14 +3528,15 @@ if ($action == 'create') { if (empty($reshook)) { if ($action != 'editline') { // Subtotal - if ($object->status == Propal::STATUS_DRAFT && isModEnabled('subtotals') && getDolGlobalString('SUBTOTAL_TITLE_' . strtoupper($object->element))) { + if ($object->status == Propal::STATUS_DRAFT && isModEnabled('subtotals') + && (getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element)) || getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element)))) { $langs->load('subtotals'); $url_button = array(); $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('propal') && $object->status == Propal::STATUS_DRAFT), + 'enabled' => (isModEnabled('propal') && $object->status == Propal::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddTitleLine'), 'url' => '/comm/propal/card.php?id=' . $object->id . '&action=add_title_line&token=' . newToken() @@ -3536,7 +3544,7 @@ if ($action == 'create') { $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('propal') && $object->status == Propal::STATUS_DRAFT), + 'enabled' => (isModEnabled('propal') && $object->status == Propal::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddSubtotalLine'), 'url' => '/comm/propal/card.php?id=' . $object->id . '&action=add_subtotal_line&token=' . newToken() diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9de54f75831..e1925348e5b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -18,7 +18,7 @@ * Copyright (C) 2022 ATM Consulting * Copyright (C) 2022 OpenDSI * Copyright (C) 2022 Gauthier VERDOL - * Copyright (C) 2023 William Mead + * Copyright (C) 2023 William Mead * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -1879,6 +1879,8 @@ class Propal extends CommonObject $sql .= " deposit_percent = ".(!empty($this->deposit_percent) ? "'".$this->db->escape($this->deposit_percent)."'" : "null").","; $sql .= " fk_mode_reglement = ".(!empty($this->mode_reglement_id) ? (int) $this->mode_reglement_id : "null").","; $sql .= " fk_input_reason = ".(!empty($this->demand_reason_id) ? (int) $this->demand_reason_id : "null").","; + $sql .= " fk_shipping_method = ".(isset($this->shipping_method_id) ? (int) $this->shipping_method_id : "null").","; + $sql .= " fk_availability = ".(!empty($this->availability_id) ? (int) $this->availability_id : "null").","; $sql .= " note_private = ".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public = ".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf = ".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").","; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 4c88e4b7e54..a840478113e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -3450,14 +3450,15 @@ if ($action == 'create' && $usercancreate) { } // Subtotal - if ($object->status == Commande::STATUS_DRAFT && isModEnabled('subtotals') && getDolGlobalString('SUBTOTAL_TITLE_' . strtoupper($object->element))) { + if ($object->status == Commande::STATUS_DRAFT && isModEnabled('subtotals') + && (getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element)) || getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element)))) { $langs->load('subtotals'); $url_button = array(); $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('order') && $object->status == Commande::STATUS_DRAFT), + 'enabled' => (isModEnabled('order') && $object->status == Commande::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddTitleLine'), 'url' => '/commande/card.php?id=' . $object->id . '&action=add_title_line&token=' . newToken() @@ -3465,7 +3466,7 @@ if ($action == 'create' && $usercancreate) { $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('order') && $object->status == Commande::STATUS_DRAFT), + 'enabled' => (isModEnabled('order') && $object->status == Commande::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddSubtotalLine'), 'url' => '/commande/card.php?id=' . $object->id . '&action=add_subtotal_line&token=' . newToken() diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 11813560d86..17f635f41d2 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -2076,14 +2076,15 @@ if ($action == 'create') { ); // Subtotal - if (empty($object->suspended) && isModEnabled('subtotals') && getDolGlobalString('SUBTOTAL_TITLE_'.strtoupper($object->element))) { + if (empty($object->suspended) && isModEnabled('subtotals') + && (getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element)) || getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element)))) { $langs->load("subtotals"); $url_button = array(); $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT), + 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddTitleLine'), 'url' => '/compta/facture/card-rec.php?id='.$object->id.'&action=add_title_line&token='.newToken() @@ -2091,7 +2092,7 @@ if ($action == 'create') { $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT), + 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddSubtotalLine'), 'url' => '/compta/facture/card-rec.php?id='.$object->id.'&action=add_subtotal_line&token='.newToken() diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e02cba5e602..1b7754523cb 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -6560,14 +6560,15 @@ if ($action == 'create') { } // Subtotal - if ($object->status == Facture::STATUS_DRAFT && isModEnabled('subtotals') && getDolGlobalString('SUBTOTAL_TITLE_'.strtoupper($object->element))) { + if ($object->status == Facture::STATUS_DRAFT && isModEnabled('subtotals') + && (getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element)) || getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element)))) { $langs->load("subtotals"); $url_button = array(); $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT), + 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddTitleLine'), 'url' => '/compta/facture/card.php?facid='.$object->id.'&action=add_title_line&token='.newToken() @@ -6575,7 +6576,7 @@ if ($action == 'create') { $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT), + 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddSubtotalLine'), 'url' => '/compta/facture/card.php?facid='.$object->id.'&action=add_subtotal_line&token='.newToken() 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/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 45c35e6d7b3..80083fe486e 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -84,7 +84,7 @@ class Contracts extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to this contract is not allowed for login '.DolibarrApiAccess::$user->login); } $this->contract->fetchObjectLinked(); @@ -175,7 +175,6 @@ class Contracts extends DolibarrApi $sql .= $this->db->plimit($limit + 1, $offset); } - dol_syslog("API Rest request"); $result = $this->db->query($sql); if ($result) { @@ -234,8 +233,19 @@ class Contracts extends DolibarrApi { global $conf; if (!DolibarrApiAccess::$user->hasRight('contrat', 'creer')) { - throw new RestException(403, "Insufficient rights"); + throw new RestException(403, "Missing permission: Create/modify contracts/subscriptions"); } + + $socid = (int) $request_data['socid']; + $thirdpartytmp = new Societe($this->db); + $thirdparty_result = $thirdpartytmp->fetch($socid); + if ($thirdparty_result < 1) { + throw new RestException(404, 'Thirdparty with id='.$socid.' not found or not allowed'); + } + if (!DolibarrApi::_checkAccessToResource('societe', $thirdpartytmp->id)) { + throw new RestException(404, 'Thirdparty with id='.$thirdpartytmp->id.' not found or not allowed'); + } + // Check mandatory fields $result = $this->_validate($request_data); @@ -308,7 +318,7 @@ class Contracts extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to this contract is not allowed for login '.DolibarrApiAccess::$user->login); } $obj_ret = []; @@ -340,7 +350,6 @@ class Contracts extends DolibarrApi $sql .= $this->db->plimit($limit + 1, $offset); } - dol_syslog("API Rest request"); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); @@ -400,7 +409,7 @@ class Contracts extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to this contract is not allowed for login '.DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; @@ -460,7 +469,7 @@ class Contracts extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to this contract is not allowed for login '.DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; @@ -611,7 +620,7 @@ class Contracts extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to this contract is not allowed for login '.DolibarrApiAccess::$user->login); } $updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, (int) $datestart, $dateend, $comment); @@ -652,7 +661,7 @@ class Contracts extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to this contract is not allowed for login '.DolibarrApiAccess::$user->login); } $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, (int) $datestart, $comment); @@ -692,7 +701,7 @@ class Contracts extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to this contract is not allowed for login '.DolibarrApiAccess::$user->login); } // TODO Check the lineid $lineid is a line of object @@ -727,13 +736,24 @@ class Contracts extends DolibarrApi if ($id == 0) { throw new RestException(400, 'No contract with id=0 can exist'); } + $result = $this->contract->fetch($id); if (!$result) { throw new RestException(404, 'Contrat not found'); } + $old_socid = $this->contract->socid; + $oldthirdpartytmp = new Societe($this->db); + $old_thirdparty_result = $oldthirdpartytmp->fetch($old_socid); + if ($old_thirdparty_result < 1) { + throw new RestException(404, 'Thirdparty with id='.$old_socid.' not found or not allowed'); + } + if (!DolibarrApi::_checkAccessToResource('societe', $old_socid)) { + throw new RestException(403, 'Access to old thirdparty='.$old_socid.' is not allowed for login '.DolibarrApiAccess::$user->login); + } + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to this contract is not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { if ($field == 'id') { @@ -763,6 +783,18 @@ class Contracts extends DolibarrApi continue; } + if ($field == 'socid') { + $new_socid = (int) $value; + $loopthirdpartytmp = new Societe($this->db); + $new_thirdparty_result = $loopthirdpartytmp->fetch($new_socid); + if ($new_thirdparty_result < 1) { + throw new RestException(404, 'Thirdparty with id='.$new_socid.' not found or not allowed'); + } + if (!DolibarrApi::_checkAccessToResource('societe', $new_socid)) { + throw new RestException(403, 'Access to new thirdparty='.$new_socid.' is not allowed for login '.DolibarrApiAccess::$user->login); + } + } + $this->contract->$field = $this->_checkValForAPI($field, $value, $this->contract); } @@ -790,7 +822,7 @@ class Contracts extends DolibarrApi public function delete($id) { if (!DolibarrApiAccess::$user->hasRight('contrat', 'supprimer')) { - throw new RestException(403); + throw new RestException(403, 'Missing permission: Delete contracts/subscriptions'); } if ($id == 0) { throw new RestException(400, 'No contract with id=0 can exist'); @@ -801,7 +833,7 @@ class Contracts extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to this contract is not allowed for login '.DolibarrApiAccess::$user->login); } if (!$this->contract->delete(DolibarrApiAccess::$user)) { @@ -854,7 +886,7 @@ class Contracts extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to this contract is not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); @@ -911,7 +943,7 @@ class Contracts extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to this contract is not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); 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..dc781a719ca 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1261,7 +1261,7 @@ function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto', $saverestore = '') if ($hourTime === 'getpost' || $hourTime === 'getpostend') { $hour = (GETPOSTISSET($prefix . 'hour') && GETPOSTINT($prefix . 'hour') >= 0) ? GETPOSTINT($prefix . 'hour') : ($hourTime === 'getpostend' ? 23 : 0); $minute = (GETPOSTISSET($prefix . 'min') && GETPOSTINT($prefix . 'min') >= 0) ? GETPOSTINT($prefix . 'min') : ($hourTime === 'getpostend' ? 59 : 0); - $second = (GETPOSTISSET($prefix . 'second') && GETPOSTINT($prefix . 'second') >= 0) ? GETPOSTINT($prefix . 'second') : ($hourTime === 'getpostend' ? 59 : 0); + $second = (GETPOSTISSET($prefix . 'sec') && GETPOSTINT($prefix . 'sec') >= 0) ? GETPOSTINT($prefix . 'sec') : ($hourTime === 'getpostend' ? 59 : 0); } elseif (preg_match('/^(\d\d):(\d\d):(\d\d)$/', $hourTime, $m)) { $hour = intval($m[1]); $minute = intval($m[2]); @@ -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 '' . "\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 "