diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml index c2f8cc12765..1d134ff2455 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml @@ -5,6 +5,9 @@ on: schedule: - cron: "0 20 * * *" +permissions: + contents: read + jobs: exakat: runs-on: ubuntu-latest diff --git a/ChangeLog b/ChangeLog index 37957f61c1d..0b0e8695a7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ NEW: PHP 8.1 compatibility NEW: Support for recurring purchase invoices. NEW: #20292 Include German public holidays NEW: Can show ZATCA QRCode on PDFs +NEW: Can show Swiss QR Code on PDFs NEW: #17123 added ExtraFields for Stock Mouvement NEW: #20609 : new massaction to assign a sale representatives on a selection of thirdparties NEW: #20653 edit discount pourcentage for all lines in one shot @@ -197,7 +198,7 @@ Following changes may create regressions for some external modules, but were nec * Method fetch_all_resources(), fetch_all_used(), fetch_all_available() of DolResource has been removed (they were not used by core code). * Method fetch_all of DolResource has been renamed into fetchAll() to match naming conventions. * The hook 'upgrade' and 'doUpgrade2" has been renamed 'doUpgradeBefore' and 'doUpgradeAfterDB'. A new trigger 'doUpgradeAfterFiles' has been introduced. - +* The context hook 'suppliercard' when on the supplier tab of a thirdparty has been renamed into 'thirdpartysupplier' ***** ChangeLog for 15.0.2 compared to 15.0.1 ***** diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index b648bd7aff7..556ce9d0a7e 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -499,8 +499,9 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/cache.manifest`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php.mysql`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php.nova*`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php.old`; - $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php.postgres`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php.pgsql`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf*sav*`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/install/mssql/README`; diff --git a/dev/resources/iso-normes/barcodes/QR code for invoices.txt b/dev/resources/iso-normes/qr-bar-codes/QR code for invoices.txt similarity index 72% rename from dev/resources/iso-normes/barcodes/QR code for invoices.txt rename to dev/resources/iso-normes/qr-bar-codes/QR code for invoices.txt index 639435238f9..b388ed0c599 100644 --- a/dev/resources/iso-normes/barcodes/QR code for invoices.txt +++ b/dev/resources/iso-normes/qr-bar-codes/QR code for invoices.txt @@ -20,3 +20,10 @@ https://www.pwc.com/m1/en/services/tax/me-tax-legal-news/2021/saudi-arabia-guide https://www.tecklenborgh.com/post/ksa-zatca-publishes-guide-on-how-to-develop-a-fatoora-compliant-qr-code Method to encode/decode ZATCA string is available in test/phpunit/BarcodeTest.php + + +* FOR QR-Bill in switzerland +---------------------------- +Syntax of QR Code https://www.swiss-qr-invoice.org/fr/ +Syntax of complentary field named "structured information of invoice S1": https://www.swiss-qr-invoice.org/downloads/qr-bill-s1-syntax-fr.pdf +To test/validate: https://www.swiss-qr-invoice.org/validator/ diff --git a/dev/resources/iso-normes/barcodes/barcode_EAN13.txt b/dev/resources/iso-normes/qr-bar-codes/barcode_EAN13.txt similarity index 100% rename from dev/resources/iso-normes/barcodes/barcode_EAN13.txt rename to dev/resources/iso-normes/qr-bar-codes/barcode_EAN13.txt diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 48d8ab23d96..4d74237e2e4 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -350,6 +350,8 @@ if ($resql) { '; } + $newcardbutton = ''; + print '
'; if ($optioncss != '') { print ''; diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 583b12368dc..44fbef7429e 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -98,7 +98,6 @@ if (!empty($conf->loan->enabled)) { $list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE'; if (!empty($conf->societe->enabled)) { $list_account[] = '---Deposits---'; - $list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT'; } /* @@ -106,7 +105,7 @@ if (!empty($conf->societe->enabled)) { */ if ($action == 'update') { $error = 0; - + // Process $list_account_main foreach ($list_account_main as $constname) { $constvalue = GETPOST($constname, 'alpha'); @@ -114,7 +113,7 @@ if ($action == 'update') { $error++; } } - + // Process $list_account foreach ($list_account as $constname) { $reg = array(); if (preg_match('/---(.*)---/', $constname, $reg)) { // This is a separator @@ -128,6 +127,13 @@ if ($action == 'update') { } } + $constname = 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT'; + $constvalue = GETPOST($constname, 'int'); + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -195,7 +201,8 @@ foreach ($list_account_main as $key) { print ''; // Value print ''; // Do not force class=right, or it align also the content of the select box - print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'accountsmain'); + $key_value = getDolGlobalString($key); + print $formaccounting->select_account($key_value, $key, 1, '', 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'accountsmain'); print ''; print ''; } @@ -246,10 +253,24 @@ foreach ($list_account as $key) { } } + +// Customer deposit account +print ''; +// Param +print ''; +print img_picto('', 'bill', 'class="pictofixedwidth"') . $langs->trans('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT'); +print ''; +// Value +print ''; // Do not force class=right, or it align also the content of the select box +print $formaccounting->select_account(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT'), 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT', 1, '', 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'accounts'); +print ''; +print ''; + + if (!empty($conf->societe->enabled)) { print ''; print '' . img_picto('', 'bill', 'class="pictofixedwidth"') . $langs->trans("UseAuxiliaryAccountOnCustomerDeposit") . ''; - if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + if (getDolGlobalInt('ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT')) { print ''; print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); print ''; @@ -264,7 +285,7 @@ if (!empty($conf->societe->enabled)) { print "\n"; print "\n"; -print '
'; +print '
'; print '
'; diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 430c7b6abae..d0a0ab671d4 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -1,11 +1,11 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2014 Marcos García - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2017-2018 Frédéric France +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2014 Marcos García + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2017-2018 Frédéric France * * 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 @@ -211,7 +211,7 @@ if ($num) { // Value print ''; - print ''; + print ''; print ''; } } @@ -239,7 +239,7 @@ if (!$conf->use_javascript_ajax) { } else { print ''; $listmodelcsv = $accountancyexport->getType(); - print $form->selectarray("ACCOUNTING_EXPORT_MODELCSV", $listmodelcsv, $conf->global->ACCOUNTING_EXPORT_MODELCSV, 0, 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray("ACCOUNTING_EXPORT_MODELCSV", $listmodelcsv, getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV'), 0, 0, 0, '', 0, 0, 0, '', '', 1); print ''; } diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 309dc094e82..0210fa10e75 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -358,7 +358,7 @@ foreach ($list as $key) { print ''.$label.''; // Value print ''; - print ''; + print ''; print ''; print ''; @@ -409,12 +409,12 @@ foreach ($list_binding as $key) { // Value print ''; if ($key == 'ACCOUNTING_DATE_START_BINDING') { - print $form->selectDate(($conf->global->$key ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1); + print $form->selectDate((!empty($conf->global->$key) ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1); } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') { $array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0)); } else { - print ''; + print ''; } print ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index de6b8374c2a..39300579d5f 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2022 Alexandre Spangaro * * 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 @@ -76,6 +76,8 @@ if (empty($sortorder)) { $error = 0; +$search_country_id = GETPOST('search_country_id', 'int'); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admin')); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 2ee947bf720..4bc6d50de89 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -132,6 +132,7 @@ $search_not_reconciled = GETPOST('search_not_reconciled', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); +$optioncss = GETPOST('optioncss', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0) { $page = 0; @@ -206,7 +207,7 @@ if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { $accountancyexport = new AccountancyExport($db); $listofformat = $accountancyexport->getType(); -$formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV; +$formatexportset = getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV'); if (empty($listofformat[$formatexportset])) { $formatexportset = 1; } @@ -913,6 +914,8 @@ if ($massactionbutton && $contextpage != 'poslist') { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } +$moreforfilter = ''; + $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) { diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 80b2efe7050..d638a7c0c84 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -2,7 +2,7 @@ /* Copyright (C) 2016 Neil Orley * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2020 Florian Henry - * Copyright (C) 2013-2021 Alexandre Spangaro + * Copyright (C) 2013-2022 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array("accountancy", "compta")); $action = GETPOST('action', 'aZ09'); +$socid = GETPOST('socid', 'int'); $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); @@ -104,6 +105,7 @@ if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); +$optioncss = GETPOST('optioncss', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0) { $page = 0; @@ -571,6 +573,7 @@ $num = count($object->lines); //} // Print form confirm +$formconfirm = ''; print $formconfirm; // List of mass actions available diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 70e79e31063..0eca61c72c1 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -1,9 +1,9 @@ - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2021 Alexandre Spangaro - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry +/* Copyright (C) 2013 Olivier Geffroy + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -174,7 +174,9 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; - $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0 AND l.product_type <= 2 AND f.entity = ".((int) $conf->entity); + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql .= " AND l.product_type <= 2"; + $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index b9ea4fc0e54..b2a127e86a4 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -158,8 +158,8 @@ if (empty($reshook)) { // Mass actions $objectclass = 'AccountingAccount'; - $permissiontoread = $user->rights->accounting->read; - $permissiontodelete = $user->rights->accounting->delete; + $permissiontoread = $user->hasRight('accounting', 'read'); + $permissiontodelete = $user->hasRight('accounting', 'delete'); $uploaddir = $conf->accounting->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -469,7 +469,7 @@ if ($result) { print ''.$langs->trans("DescVentilTodoCustomer").'

'; - if ($msg) { + if (!empty($msg)) { print $msg.'
'; } diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 033f1164dc7..880af769183 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -150,8 +150,8 @@ if (empty($reshook)) { // Mass actions $objectclass = 'ExpenseReport'; $objectlabel = 'ExpenseReport'; - $permissiontoread = $user->rights->expensereport->read; - $permissiontodelete = $user->rights->expensereport->delete; + $permissiontoread = $user->hasRight('accounting', 'read'); + $permissiontodelete = $user->hasRight('accounting', 'delete'); $uploaddir = $conf->expensereport->dir_output; include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php'; } @@ -370,7 +370,7 @@ if ($result) { print ''.$langs->trans("DescVentilTodoExpenseReport").'

'; - if ($msg) { + if (!empty($msg)) { print $msg.'
'; } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 781218be04a..27ffb681ae0 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -305,8 +305,16 @@ if ($result) { // get_url may return -1 which is not traversable if (is_array($links) && count($links) > 0) { + $is_sc = false; + foreach ($links as $v) { + if ($v['type'] == 'sc') { + $is_sc = true; + break; + } + } // Now loop on each link of record in bank (code similar to bankentries_list.php) foreach ($links as $key => $val) { + if ($links[$key]['type'] == 'user' && !$is_sc) continue; if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) { // So we excluded 'company' and 'user' here. We want only payment lines diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index d350e2243a2..449b13f1039 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2021 Florian Henry - * Copyright (C) 2013-2021 Alexandre Spangaro + * Copyright (C) 2013-2022 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -171,8 +171,10 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; - $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0 AND l.product_type <= 2 AND f.entity = ".((int) $conf->entity); + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_product_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql .= " AND l.product_type <= 2"; + $sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } @@ -373,10 +375,14 @@ $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; +if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.")"; +} else { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.")"; +} $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; -$sql .= ' ORDER BY aa.account_number'; -dol_syslog('htdocs/accountancy/supplier/index.php'); +dol_syslog('htdocs/accountancy/supplier/index.php', LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -474,11 +480,17 @@ $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } +$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; -$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy +if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.")"; +} else { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.", ".FactureFournisseur::TYPE_DEPOSIT.")"; +} $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; +$sql .= ' ORDER BY aa.account_number'; dol_syslog('htdocs/accountancy/supplier/index.php'); $resql = $db->query($sql); @@ -494,13 +506,15 @@ if ($resql) { print length_accountg($row[0]); } print ''; - print ''; + + print ''; if ($row[0] == 'tobind') { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind")); } else { print $row[1]; } print ''; + for ($i = 2; $i <= 13; $i++) { print ''; print price($row[$i]); @@ -523,7 +537,6 @@ print "\n"; print ''; - if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report that should rely on result of this step ? print '
'; print '
'; @@ -560,9 +573,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } + $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; - $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy + if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.")"; + } else { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.", ".FactureFournisseur::TYPE_DEPOSIT.")"; + } dol_syslog('htdocs/accountancy/supplier/index.php'); $resql = $db->query($sql); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 914c355c838..c142361155d 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -384,7 +384,7 @@ if ($result) { print ''; print ''; - print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); + print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); print ''.$langs->trans("DescVentilDoneSupplier").'
'; print '
'.$langs->trans("ChangeAccount").' '; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 32e939f7bee..f274a5432dc 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -161,8 +161,8 @@ if (empty($reshook)) { // Mass actions $objectclass = 'AccountingAccount'; - $permissiontoread = $user->rights->accounting->read; - $permissiontodelete = $user->rights->accounting->delete; + $permissiontoread = $user->hasRight('accounting', 'read'); + $permissiontodelete = $user->hasRight('accounting', 'delete'); $uploaddir = $conf->accounting->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -477,7 +477,7 @@ if ($result) { print ''.$langs->trans("DescVentilTodoCustomer").'

'; - if ($msg) { + if (!empty($msg)) { print $msg.'
'; } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index d7e46749de3..4f92b9766ea 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1280,7 +1280,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ' '.$langs->trans("Delete").'

'; } print ''.$langs->trans("PhotoFile").''; - print ''; + print ''; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file + } + print ''; + print ''; print ''; } print ''; diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index 256f29b6b81..72976d4e65f 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -220,7 +220,7 @@ if ($action == 'edit') { print ''; print ''; print ''; print ''; @@ -283,7 +283,7 @@ if ($action == 'create' && $user->rights->adherent->configurer) { print ''; print ''; print ''; diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index dc56d3ae79f..459d9c47227 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -453,10 +453,10 @@ print ''; // Logo (squarred) print ''; } diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 0c8aba5ae2d..e8a1fc85790 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -445,10 +445,10 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->tr print '
'; $variablename = 'CONTRACT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index e12848e3de1..698bb187d67 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -105,7 +105,7 @@ if ($action == 'edit') { } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') { print $form->selectyesno($key, $conf->global->$key, 1); } else { - print ''; + print ''; } print ''; } diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index 6f0f4c1b415..de26d237d01 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -434,10 +434,10 @@ print '\n"; print '\n"; print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; - $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); + $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_3, '90%'); $doleditor->Create(); print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; - $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); + $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_3, '90%'); $doleditor->Create(); print '
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'BOM_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print '
'; diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 3ba8c3b854a..396d44625a7 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -261,10 +261,10 @@ print '
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'BANK_CHEQUERECEIPT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print '
'; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index f4afd27d46b..1369c5667a8 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -612,7 +612,7 @@ print '
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); @@ -661,7 +661,7 @@ if ($conf->banque->enabled) { } // Ask for warehouse during order -if ($conf->stock->enabled) { +if (isModEnabled('stock')) { print '
'; print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").' '; if (! empty($conf->use_javascript_ajax)) { diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 86800eea947..c72976f829e 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -477,6 +477,11 @@ if (!empty($conf->barcode->enabled)) { // Logo print '
'; print '
'; +$maxfilesizearray = getMaxFileSizeArray(); +$maxmin = $maxfilesizearray['maxmin']; +if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file +} print ''; print '
'; if (!empty($mysoc->logo_small)) { @@ -514,6 +519,11 @@ print '
'; print '
'; +$maxfilesizearray = getMaxFileSizeArray(); +$maxmin = $maxfilesizearray['maxmin']; +if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file +} print ''; print '
'; if (!empty($mysoc->logo_squarred_small)) { diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index 047b87ff014..d215125d51e 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -179,7 +179,7 @@ foreach ($list as $key) { // Value print '
'; - print ''; + print ''; print '
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'DELIVERY_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print '
'; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 12e0d0a6d01..cb49404a8b9 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -132,7 +132,7 @@ if ($action == 'updateMask') { } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->EXPEDITION_ADDON_PDF == "$value") { + if (getDolGlobalString('EXPEDITION_ADDON_PDF') == "$value") { dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity); } } @@ -231,7 +231,7 @@ foreach ($dirmodels as $reldir) { if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { - print 'scandir).'&label='.urlencode($module->name).'">'; + print 'name).'">'; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } @@ -367,7 +367,7 @@ foreach ($dirmodels as $reldir) { // Defaut print ''; - if ($conf->global->EXPEDITION_ADDON_PDF == $name) { + if (getDolGlobalString('EXPEDITION_ADDON_PDF') == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; @@ -441,17 +441,17 @@ print '
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'SHIPPING_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print "
'; print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; -print ''; +print ''; print "
'; diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index e5169ce55cc..0c54eade6da 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -456,10 +456,10 @@ print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnExpenseReports"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'EXPENSEREPORT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 599aac27c3f..accb3d850a0 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -743,10 +743,10 @@ print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index c95f354a189..36a55be9a95 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -507,10 +507,10 @@ print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnInterventions"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'FICHINTER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 7b0aa577a87..f208e2a658a 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -538,10 +538,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print '
'; $variablename = 'HOLIDAY_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index d3afd4035e4..959d881041d 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -636,6 +636,11 @@ if ($mode == 'login') { if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) { $disabled = ' disabled="disabled"'; } + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file + } print ''; if ($disabled) { print '(' . $langs->trans("DisabledByOptionADD_UNSPLASH_LOGIN_BACKGROUND") . ') '; diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index 59b7eb8b463..72b2a15d678 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -107,7 +107,7 @@ foreach ($list as $key) { if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1); } else { - print ''; + print ''; } print ''; } diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 0db1b26dc7d..286ccc424e8 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -1212,7 +1212,7 @@ if ($mode == 'deploy') { }); '."\n"; // MAX_FILE_SIZE doit précéder le champ input de type file - print ''; + print ''; } print ' '; diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index fac6a3f3d41..f4283373b95 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -446,10 +446,10 @@ print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'MRP_MO_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index d8afe43720f..b064cbb8cd8 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -62,6 +62,11 @@ if ($action == 'update') { } if (GETPOSTISSET('INVOICE_ADD_ZATCA_QR_CODE')) { dolibarr_set_const($db, "INVOICE_ADD_ZATCA_QR_CODE", GETPOST("INVOICE_ADD_ZATCA_QR_CODE", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_del_const($db, "INVOICE_ADD_SWISS_QR_CODE", $conf->entity); + } + if (GETPOSTISSET('INVOICE_ADD_SWISS_QR_CODE')) { + dolibarr_set_const($db, "INVOICE_ADD_SWISS_QR_CODE", GETPOST("INVOICE_ADD_SWISS_QR_CODE", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_del_const($db, "INVOICE_ADD_ZATCA_QR_CODE", $conf->entity); } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -138,6 +143,17 @@ if (isModEnabled('facture')) { } print ''; + print ''; + print $form->textwithpicto($langs->trans("INVOICE_ADD_SWISS_QR_CODE"), ''); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('INVOICE_ADD_SWISS_QR_CODE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("INVOICE_ADD_SWISS_QR_CODE", $arrval, $conf->global->INVOICE_ADD_SWISS_QR_CODE); + } + print ''; + /* print ''.$langs->trans("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING").''; if ($conf->use_javascript_ajax) { diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 3bc745a1101..fe8db9818f7 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -675,10 +675,10 @@ print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index 26300ece329..1ca874c69b5 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -455,12 +455,12 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnReceptions"), $langs->t $variablename='RECEPTION_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); + $doleditor=new DolEditor($variablename, getDolGlobalString($variablename),'',80,'dolibarr_notes'); print $doleditor->Create(); } print "\n"; diff --git a/htdocs/admin/stocktransfer.php b/htdocs/admin/stocktransfer.php index 541947bf442..0e504ec26f1 100644 --- a/htdocs/admin/stocktransfer.php +++ b/htdocs/admin/stocktransfer.php @@ -194,7 +194,7 @@ print ''.$langs->trans("StockTransferSetupPage").''; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print ''; + print ''; } print ''; @@ -217,7 +217,7 @@ print ''.$langs->trans("StockTransferSetupPage").''; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print ''.$conf->global->$key.''; + print ''.getDolGlobalString($key).''; } print ''; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 40fe58f68d6..aa337ff1f29 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -457,10 +457,10 @@ print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'SUPPLIER_INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 75f2badfda5..9482a06be41 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -505,10 +505,10 @@ print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'SUPPLIER_ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 80f2c6a62f4..bb0617c6700 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -474,10 +474,10 @@ print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnSupplierProposal"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'SUPPLIER_PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index f902c3fb39b..99d1b34749f 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -642,7 +642,7 @@ $mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_M print ''.$langs->trans("TicketMessageMailIntroLabelAdmin"); print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); +$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAIL'), ROWS_2, 70); $doleditor->Create(); print ''; print ''; @@ -654,7 +654,7 @@ $mail_signature = $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global-> print ''.$langs->trans("TicketMessageMailSignatureLabelAdmin").''; print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); +$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAIL'), ROWS_2, 70); $doleditor->Create(); print ''; print ''; diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 1a4e3342cd0..0fd654b5d28 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -375,7 +375,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''.$langs->trans("TicketPublicInterfaceTextHomeLabelAdmin").''; print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_2, 70); $doleditor->Create(); print ''; print ''; @@ -387,7 +387,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").''; print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_2, 70); $doleditor->Create(); print ''; print ''; @@ -434,7 +434,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); + $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAIL'), ROWS_2, 70); $doleditor->Create(); print ''; print ''; diff --git a/htdocs/admin/webhook.php b/htdocs/admin/webhook.php new file mode 100644 index 00000000000..963b76c238a --- /dev/null +++ b/htdocs/admin/webhook.php @@ -0,0 +1,733 @@ + + * Copyright (C) 2022 SuperAdmin + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file webhook/admin/webhook.php + * \ingroup webhook + * \brief Webhook setup page. + */ + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +global $langs, $user; + +// Libraries +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT.'/webhook/lib/webhook.lib.php'; + +// Translations +$langs->loadLangs(array("admin", "webhook")); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('webhooksetup', 'globalsetup')); + +// Access control +if (!$user->admin) { + accessforbidden(); +} + +// Parameters +$action = GETPOST('action', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); +$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php + +$value = GETPOST('value', 'alpha'); +$label = GETPOST('label', 'alpha'); +$scandir = GETPOST('scan_dir', 'alpha'); +$type = 'myobject'; + +$arrayofparameters = array( + 'WEBHOOK_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>0), + //'WEBHOOK_MYPARAM2'=>array('type'=>'textarea','enabled'=>1), + //'WEBHOOK_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + //'WEBHOOK_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), + //'WEBHOOK_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), + //'WEBHOOK_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), + //'WEBHOOK_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), + //'WEBHOOK_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), +); + +$error = 0; +$setupnotempty = 0; + +// Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only +$useFormSetup = 0; +// Convert arrayofparameter into a formSetup object +if ($useFormSetup && (float) DOL_VERSION >= 15) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; + $formSetup = new FormSetup($db); + + // you can use the param convertor + $formSetup->addItemsFromParamsArray($arrayofparameters); + + // or use the new system see exemple as follow (or use both because you can ;-) ) + + /* + // Hôte + $item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); + $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; + $item->cssClass = 'minwidth500'; + + // Setup conf WEBHOOK_MYPARAM1 as a simple string input + $item = $formSetup->newItem('WEBHOOK_MYPARAM1'); + + // Setup conf WEBHOOK_MYPARAM1 as a simple textarea input but we replace the text of field title + $item = $formSetup->newItem('WEBHOOK_MYPARAM2'); + $item->nameText = $item->getNameText().' more html text '; + + // Setup conf WEBHOOK_MYPARAM3 + $item = $formSetup->newItem('WEBHOOK_MYPARAM3'); + $item->setAsThirdpartyType(); + + // Setup conf WEBHOOK_MYPARAM4 : exemple of quick define write style + $formSetup->newItem('WEBHOOK_MYPARAM4')->setAsYesNo(); + + // Setup conf WEBHOOK_MYPARAM5 + $formSetup->newItem('WEBHOOK_MYPARAM5')->setAsEmailTemplate('thirdparty'); + + // Setup conf WEBHOOK_MYPARAM6 + $formSetup->newItem('WEBHOOK_MYPARAM6')->setAsSecureKey()->enabled = 0; // disabled + + // Setup conf WEBHOOK_MYPARAM7 + $formSetup->newItem('WEBHOOK_MYPARAM7')->setAsProduct(); + */ + + $setupnotempty = count($formSetup->items); +} + + +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + +if ($action == 'updateMask') { + $maskconst = GETPOST('maskconst', 'alpha'); + $maskvalue = GETPOST('maskvalue', 'alpha'); + + if ($maskconst) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} elseif ($action == 'specimen') { + $modele = GETPOST('module', 'alpha'); + $tmpobjectkey = GETPOST('object'); + + $tmpobject = new $tmpobjectkey($db); + $tmpobject->initAsSpecimen(); + + // Search template files + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir."core/modules/webhook/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); + if (file_exists($file)) { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($tmpobject, $langs) > 0) { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} elseif ($action == 'setmod') { + // TODO Check if numbering module chosen can be activated by calling method canBeActivated + $tmpobjectkey = GETPOST('object'); + if (!empty($tmpobjectkey)) { + $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey)."_ADDON"; + dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity); + } +} elseif ($action == 'set') { + // Activate a model + $ret = addDocumentModel($value, $type, $label, $scandir); +} elseif ($action == 'del') { + $ret = delDocumentModel($value, $type); + if ($ret > 0) { + $tmpobjectkey = GETPOST('object'); + if (!empty($tmpobjectkey)) { + $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; + if ($conf->global->$constforval == "$value") { + dolibarr_del_const($db, $constforval, $conf->entity); + } + } + } +} elseif ($action == 'setdoc') { + // Set or unset default model + $tmpobjectkey = GETPOST('object'); + if (!empty($tmpobjectkey)) { + $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; + if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { + // The constant that was read before the new set + // We therefore requires a variable to have a coherent view + $conf->global->$constforval = $value; + } + + // We disable/enable the document template (into llx_document_model table) + $ret = delDocumentModel($value, $type); + if ($ret > 0) { + $ret = addDocumentModel($value, $type, $label, $scandir); + } + } +} elseif ($action == 'unsetdoc') { + $tmpobjectkey = GETPOST('object'); + if (!empty($tmpobjectkey)) { + $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; + dolibarr_del_const($db, $constforval, $conf->entity); + } +} + + + +/* + * View + */ + +$form = new Form($db); + +$help_url = ''; +$page_name = "WebhookSetup"; + +llxHeader('', $langs->trans($page_name), $help_url); + +// Subheader +$linkback = ''.$langs->trans("BackToModuleList").''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); + +// Configuration header +$head = webhookAdminPrepareHead(); +print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "webhook@webhook"); + +// Setup page goes here +echo ''.$langs->trans("WebhookSetupPage").'

'; + + +if ($action == 'edit') { + if ($useFormSetup && (float) DOL_VERSION >= 15) { + print $formSetup->generateOutput(true); + } else { + print '
'; + print ''; + print ''; + + print ''; + print ''; + + foreach ($arrayofparameters as $constname => $val) { + if ($val['enabled']==1) { + $setupnotempty++; + print ''; + } + } + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); + print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; + print ''; + + if ($val['type'] == 'textarea') { + print '\n"; + } elseif ($val['type']== 'html') { + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor->Create(); + } elseif ($val['type'] == 'yesno') { + print $form->selectyesno($constname, $conf->global->{$constname}, 1); + } elseif (preg_match('/emailtemplate:/', $val['type'])) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $tmp = explode(':', $val['type']); + $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang + //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); + $arrayofmessagename = array(); + if (is_array($formmail->lines_model)) { + foreach ($formmail->lines_model as $modelmail) { + //var_dump($modelmail); + $moreonlabel = ''; + if (!empty($arrayofmessagename[$modelmail->label])) { + $moreonlabel = ' (' . $langs->trans("SeveralLangugeVariatFound") . ')'; + } + // The 'label' is the key that is unique if we exclude the language + $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel; + } + } + print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + } elseif (preg_match('/category:/', $val['type'])) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + $formother = new FormOther($db); + + $tmp = explode(':', $val['type']); + print img_picto('', 'category', 'class="pictofixedwidth"'); + print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + $formcompany = new FormCompany($db); + print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); + } elseif ($val['type'] == 'securekey') { + print ''; + if (!empty($conf->use_javascript_ajax)) { + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"'); + } + if (!empty($conf->use_javascript_ajax)) { + print "\n".''; + } + } elseif ($val['type'] == 'product') { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $form->select_produits($selected, $constname, '', 0); + } + } else { + print ''; + } + print '
'; + + print '
'; + print ''; + print '
'; + + print '
'; + } + + print '
'; +} else { + if ($useFormSetup && (float) DOL_VERSION >= 15) { + if (!empty($formSetup->items)) { + print $formSetup->generateOutput(); + } + } else { + if (!empty($arrayofparameters)) { + print ''; + print ''; + + foreach ($arrayofparameters as $constname => $val) { + if ($val['enabled']==1) { + $setupnotempty++; + print ''; + } + } + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); + print $form->textwithpicto($langs->trans($constname), $tooltiphelp); + print ''; + + if ($val['type'] == 'textarea') { + print dol_nl2br($conf->global->{$constname}); + } elseif ($val['type']== 'html') { + print $conf->global->{$constname}; + } elseif ($val['type'] == 'yesno') { + print ajax_constantonoff($constname); + } elseif (preg_match('/emailtemplate:/', $val['type'])) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $tmp = explode(':', $val['type']); + + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + if ($template<0) { + setEventMessages(null, $formmail->errors, 'errors'); + } + print $langs->trans($template->label); + } elseif (preg_match('/category:/', $val['type'])) { + $c = new Categorie($db); + $result = $c->fetch($conf->global->{$constname}); + if ($result < 0) { + setEventMessages(null, $c->errors, 'errors'); + } elseif ($result > 0 ) { + $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text + $toprint = array(); + foreach ($ways as $way) { + $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; + } + print '
      ' . implode(' ', $toprint) . '
    '; + } + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + if ($conf->global->{$constname}==2) { + print $langs->trans("Prospect"); + } elseif ($conf->global->{$constname}==3) { + print $langs->trans("ProspectCustomer"); + } elseif ($conf->global->{$constname}==1) { + print $langs->trans("Customer"); + } elseif ($conf->global->{$constname}==0) { + print $langs->trans("NorProspectNorCustomer"); + } + } elseif ($val['type'] == 'product') { + $product = new Product($db); + $resprod = $product->fetch($conf->global->{$constname}); + if ($resprod > 0) { + print $product->ref; + } elseif ($resprod < 0) { + setEventMessages(null, $object->errors, "errors"); + } + } else { + print $conf->global->{$constname}; + } + print '
    '; + } + } + + if ($setupnotempty) { + print '
    '; + print ''.$langs->trans("Modify").''; + print '
    '; + } else { + //print '
    '.$langs->trans("NothingToSetup"); + } +} + + +$moduledir = 'webhook'; +$myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0); + + +foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { + if ($myTmpObjectKey == 'MyObject') { + continue; + } + if ($myTmpObjectArray['includerefgeneration']) { + /* + * Orders Numbering model + */ + $setupnotempty++; + + print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', ''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''."\n"; + + clearstatcache(); + + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/".$moduledir); + + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') { + $file = substr($file, 0, dol_strlen($file) - 4); + + require_once $dir.'/'.$file.'.php'; + + $module = new $file($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + continue; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + continue; + } + + if ($module->isEnabled()) { + dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php'); + + print ''; + + // Show example of numbering model + print ''."\n"; + + print ''; + + $mytmpinstance = new $myTmpObjectKey($db); + $mytmpinstance->initAsSpecimen(); + + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
    '; + + $nextval = $module->getNextValue($mytmpinstance); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { + $nextval = $langs->trans($nextval); + } + $htmltooltip .= $nextval.'
    '; + } else { + $htmltooltip .= $langs->trans($module->error).'
    '; + } + } + + print ''; + + print "\n"; + } + } + } + closedir($handle); + } + } + } + print "
    '.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
    '.$module->name."\n"; + print $module->info(); + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
    '.$langs->trans($tmp).'
    '; + } elseif ($tmp == 'NotConfigured') { + print $langs->trans($tmp); + } else { + print $tmp; + } + print '
    '; + $constforvar = 'WEBHOOK_'.strtoupper($myTmpObjectKey).'_ADDON'; + if ($conf->global->$constforvar == $file) { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print '

    \n"; + } + + if ($myTmpObjectArray['includedocgeneration']) { + /* + * Document templates generators + */ + $setupnotempty++; + $type = strtolower($myTmpObjectKey); + + print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', ''); + + // Load array def with activated templates + $def = array(); + $sql = "SELECT nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; + $sql .= " WHERE type = '".$db->escape($type)."'"; + $sql .= " AND entity = ".$conf->entity; + $resql = $db->query($sql); + if ($resql) { + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } + } else { + dol_print_error($db); + } + + print "\n"; + print "\n"; + print ''; + print ''; + print '\n"; + print '\n"; + print ''; + print ''; + print "\n"; + + clearstatcache(); + + foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { + $realpath = $reldir."core/modules/".$moduledir.$valdir; + $dir = dol_buildpath($realpath); + + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); + + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); + + require_once $dir.'/'.$file; + $module = new $classname($db); + + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } + + if ($modulequalified) { + print ''; + + // Active + if (in_array($name, $def)) { + print ''; + } else { + print '"; + } + + // Default + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
    '.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') { + $htmltooltip .= '
    '.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
    '.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + + $htmltooltip .= '

    '.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
    '.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
    '.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } + } + + print '
    '.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
    '; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''."\n"; + print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; + $constforvar = 'WEBHOOK_'.strtoupper($myTmpObjectKey).'_ADDON'; + if ($conf->global->$constforvar == $name) { + //print img_picto($langs->trans("Default"), 'on'); + // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset + print 'scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + if ($module->type == 'pdf') { + print ''.img_object($langs->trans("Preview"), 'pdf').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
    '; + } +} + +if (empty($setupnotempty)) { + print '
    '.$langs->trans("NothingToSetup"); +} + +// Page end +print dol_get_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php index f6c92888384..1f5ebaec4c6 100644 --- a/htdocs/admin/website_options.php +++ b/htdocs/admin/website_options.php @@ -112,7 +112,7 @@ if ($action == 'edit') { foreach ($arrayofparameters as $key => $val) { print ''; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print ''; + print ''; } print ''; @@ -130,7 +130,7 @@ if ($action == 'edit') { foreach ($arrayofparameters as $key => $val) { print ''; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print ''.$conf->global->$key.''; + print ''.getDolGlobalString($key).''; } print ''; diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index 6ac7a425246..bdd7ba662cd 100644 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -188,7 +188,7 @@ if ($action == 'edit') { print ''; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print ''; + print ''; } print ''; @@ -209,7 +209,7 @@ if ($action == 'edit') { print ''; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print ''.$conf->global->$key.''; + print ''.getDolGlobalString($key).''; } print ''; diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index ec3d75dee1a..361f2a5f1ce 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -246,7 +246,7 @@ if ($user->rights->categorie->creer) { // Description print ''.$langs->trans("Description").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('description', $description, '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_5, '90%'); + $doleditor = new DolEditor('description', $description, '', 160, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_5, '90%'); $doleditor->Create(); print ''; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 14cdfe84783..27330f45ffe 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -175,11 +175,10 @@ class Categorie extends CommonObject ); /** - * @var array Object table mapping from type string (table llx_...) when value of key does not match table name. - * - * @note Move to const array when PHP 5.6 will be our minimum target + * @var array Object table mapping from type string (table llx_...) when value of key does not match table name. + * This array may be completed by external modules with hook "constructCategory" */ - public static $MAP_OBJ_TABLE = array( + public $MAP_OBJ_TABLE = array( 'customer' => 'societe', 'supplier' => 'societe', 'member' => 'adherent', diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 2bbb4b5f0a8..512f25a67e2 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -263,7 +263,7 @@ if ($action == 'edit') { // Desc $desc = (GETPOST('desc-'.$key) ? GETPOST('desc-'.$key) : $object->multilangs[$key]['description']); print ''.$langs->trans('Description').''; - $doleditor = new DolEditor("desc-$key", $desc, '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); + $doleditor = new DolEditor("desc-$key", $desc, '', 160, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_3, '90%'); $doleditor->Create(); print ''; @@ -323,7 +323,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print ''.$langs->trans('Label').''; print ''; print ''.$langs->trans('Description').''; - $doleditor = new DolEditor('desc', GETPOST('desc', 'restricthtml'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); + $doleditor = new DolEditor('desc', GETPOST('desc', 'restricthtml'), '', 160, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_3, '90%'); $doleditor->Create(); print ''; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 06e6684d99b..dd877e903e4 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -987,10 +987,10 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['a.datep']['checked'])) { print ''; if (empty($obj->fulldayevent)) { - print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser'); + print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuserrel'); } else { $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - print dol_print_date($db->jdate($obj->dp), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuser')); + print dol_print_date($db->jdate($obj->dp), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel')); } $late = 0; if ($actionstatic->hasDelay() && $actionstatic->percentage >= 0 && $actionstatic->percentage < 100 ) { @@ -1006,10 +1006,10 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['a.datep2']['checked'])) { print ''; if (empty($obj->fulldayevent)) { - print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuser'); + print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuserrel'); } else { $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - print dol_print_date($db->jdate($obj->dp2), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuser')); + print dol_print_date($db->jdate($obj->dp2), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel')); } print ''; } @@ -1091,11 +1091,11 @@ while ($i < $imaxinloop) { // Date creation if (!empty($arrayfields['a.datec']['checked'])) { // Status/Percent - print ''.dol_print_date($db->jdate($obj->datec), 'dayhour', 'tzuser').''; + print ''.dol_print_date($db->jdate($obj->datec), 'dayhour', 'tzuserrel').''; } // Date update if (!empty($arrayfields['a.tms']['checked'])) { - print ''.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuser').''; + print ''.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuserrel').''; } if (!empty($arrayfields['a.percent']['checked'])) { // Status/Percent diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 01d7102a47c..115f986e6e2 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1121,7 +1121,7 @@ if ($object->id > 0) { * Latest contracts */ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { - $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup"; + $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup, c.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; $sql .= " WHERE c.fk_soc = s.rowid "; $sql .= " AND s.rowid = ".((int) $object->id); @@ -1191,7 +1191,7 @@ if ($object->id > 0) { } } $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf'; - print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0, $param); + print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0); } // $filename = dol_sanitizeFileName($objp->ref); // $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); @@ -1409,6 +1409,7 @@ if ($object->id > 0) { $sql .= ', f.total_ht'; $sql .= ', f.total_tva'; $sql .= ', f.total_ttc'; + $sql .= ', f.entity'; $sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as status'; $sql .= ', s.nom, s.rowid as socid'; $sql .= ', SUM(pf.amount) as am'; @@ -1475,7 +1476,7 @@ if ($object->id > 0) { } } $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf'; - print $formfile->showPreview($file_list, $facturestatic->element, $relativepath, 0, $param); + print $formfile->showPreview($file_list, $facturestatic->element, $relativepath, 0); } // $filename = dol_sanitizeFileName($objp->ref); // $filedir = $conf->facture->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 5903b7e4bdb..c63ece66cd2 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -39,6 +39,9 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; +if (!empty($conf->ficheinter->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +} // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager = new HookManager($db); @@ -100,6 +103,10 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $supplierorderstatic = new CommandeFournisseur($db); } +if (!empty($conf->ficheinter->enabled)) { + $fichinterstatic = new Fichinter($db); +} + llxHeader("", $langs->trans("CommercialArea")); print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial'); @@ -508,7 +515,12 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU * Draft interventionals */ if (!empty($conf->ficheinter->enabled)) { - $sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid"; + $sql = "SELECT f.rowid, f.ref, s.nom as name, f.fk_statut"; + $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; + $sql .= ", s.code_client, s.code_compta, s.client"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; + $sql .= ", s.logo, s.email, s.entity"; + $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { @@ -524,22 +536,46 @@ if (!empty($conf->ficheinter->enabled)) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } + $resql = $db->query($sql); if ($resql) { + $num = $db->num_rows($resql); + $nbofloop = min($num, $maxofloop); + print '
    '; print ''; print ''; print ''; - $langs->load("fichinter"); - $num = $db->num_rows($resql); + if ($num) { $i = 0; - while ($i < $num) { + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); + + $fichinterstatic->id=$obj->rowid; + $fichinterstatic->ref=$obj->ref; + $fichinterstatic->statut=$obj->fk_statut; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->name_alias = $obj->name_alias; + $companystatic->code_client = $obj->code_client; + $companystatic->code_compta = $obj->code_compta; + $companystatic->client = $obj->client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + $companystatic->fournisseur = $obj->fournisseur; + $companystatic->logo = $obj->logo; + $companystatic->email = $obj->email; + $companystatic->entity = $obj->entity; + $companystatic->canvas = $obj->canvas; print ''; - print '"; - print ''; + print '"; + print ''; $i++; } } diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index b3d3dd25e90..d46a02132a1 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -753,7 +753,7 @@ if ($action == 'create') { print '
    '; // wysiwyg editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'restricthtmlallowunvalid'), '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); + $doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'restricthtmlallowunvalid'), '', 600, 'dolibarr_mailings', '', true, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '90%'); $doleditor->Create(); print '
    '; @@ -1249,6 +1249,11 @@ if ($action == 'create') { $out .= ''.$langs->trans("NoAttachedFiles").'
    '; } // Add link to add file + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $out .= ''; // MAX_FILE_SIZE must precede the field type=file + } $out .= ''; $out .= ' '; $out .= ''; @@ -1268,7 +1273,7 @@ if ($action == 'create') { if ($action == 'edit') { // wysiwyg editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '90%'); $doleditor->Create(); } if ($action == 'edithtml') { diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index aaf100d191a..c9b48665c95 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -384,6 +384,7 @@ if ($object->fetch($id) >= 0) { if ($allowaddtarget) { print ''; print ''; + print ''; } else { print '
    '; } @@ -428,7 +429,7 @@ if ($object->fetch($id) >= 0) { print '
    '; if ($allowaddtarget) { - print ''; + print ''; } else { print ''; //print $langs->trans("MailNoChangePossible"); diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 2b8c5d9047d..1e688457623 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -172,7 +172,7 @@ class PropaleStats extends Stats * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array with amount by month */ - public function getAmountByMonth($year, $format) + public function getAmountByMonth($year, $format = 0) { global $user; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3427e38d99e..b74d458ba3a 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2264,8 +2264,8 @@ class Commande extends CommonOrder } $sql .= ' ed.fk_origin_line = cd.rowid'; $sql .= ' AND cd.fk_commande = '.((int) $this->id); - if ($this->fk_product > 0) { - $sql .= ' AND cd.fk_product = '.((int) $this->fk_product); + if ($fk_product > 0) { + $sql .= ' AND cd.fk_product = '.((int) $fk_product); } if ($filtre_statut >= 0) { $sql .= ' AND e.fk_statut >= '.((int) $filtre_statut); diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 8c1df906ab7..819a6ecb74f 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -53,7 +53,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { echo ''; echo '
    '; echo ''; - echo ''; + echo ''; echo ''; diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 0091dc39512..f75ce6d4471 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2022 Alexandre Spangaro * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Tobias Sekan @@ -35,6 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "banks", "bills", "accountancy")); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlist'; // To manage different context of search + // Security check $socid = GETPOST("socid", "int"); if ($user->socid) { @@ -75,6 +77,7 @@ if (empty($search_datev_start)) { if (empty($search_datev_end)) { $search_datev_end = GETPOST("search_datev_end", 'int'); } +$search_type_id = GETPOST('search_type_id', 'int'); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -94,19 +97,6 @@ if (!$sortorder) { $filtre = GETPOST("filtre", 'alpha'); -if (!GETPOST('typeid')) { - $newfiltre = str_replace('filtre=', '', $filtre); - $filterarray = explode('-', $newfiltre); - foreach ($filterarray as $val) { - $part = explode(':', $val); - if ($part[0] == 'v.fk_typepayment') { - $typeid = $part[1]; - } - } -} else { - $typeid = GETPOST('typeid'); -} - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $search_ref = ''; $search_label = ''; @@ -120,7 +110,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_bank_entry = ''; $search_accountancy_account = ''; $search_accountancy_subledger = ''; - $typeid = ''; + $search_type_id = ''; } $search_all = GETPOSTISSET("search_all") ? trim(GETPOST("search_all", 'alpha')) : trim(GETPOST('sall')); @@ -265,8 +255,8 @@ if ($search_accountancy_account > 0) { if ($search_accountancy_subledger > 0) { $sql .= " AND v.subledger_account = ".((int) $search_accountancy_subledger); } -if ($typeid > 0) { - $sql .= " AND v.fk_typepayment=".((int) $typeid); +if ($search_type_id > 0) { + $sql .= " AND v.fk_typepayment=".((int) $search_type_id); } if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); @@ -324,8 +314,8 @@ if ($resql) { if ($search_datev_end) { $param .= '&search_datev_end='.urlencode($search_datev_end); } - if ($typeid > 0) { - $param .= '&typeid='.urlencode($typeid); + if ($search_type_id > 0) { + $param .= '&search_type_id='.urlencode($search_type_id); } if ($search_amount_deb) { $param .= '&search_amount_deb='.urlencode($search_amount_deb); @@ -375,6 +365,7 @@ if ($resql) { $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $moreforfilter= ''; print '
    '; print '
    '.$langs->trans("DraftFichinter").'
    '; - print "rowid."\">".img_object($langs->trans("ShowFichinter"), "intervention").' '.$obj->ref."'.img_object($langs->trans("ShowCompany"), "company").' '.dol_trunc($obj->name, 24).'
    '; + print $fichinterstatic->getNomUrl(1); + print "'; + print $companystatic->getNomUrl(1, 'customer'); + print '
    '.$objectlink->getNomUrl(1).''.$objectlink->ref_client.''.dol_print_date($objectlink->date, 'day').''.dol_print_date($objectlink->date, 'day').''; if ($user->rights->commande->lire) { $total = $total + $objectlink->total_ht; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 31a918b1a27..29341b0fb99 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -986,7 +986,7 @@ if ($action == 'create') { print ''; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '95%'); + $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_4, '95%'); $doleditor->Create(); print '
    '; @@ -427,7 +418,7 @@ if ($resql) { // Payment type if ($arrayfields['type']['checked']) { print ''; } @@ -544,6 +535,8 @@ if ($resql) { $totalarray = array(); + $totalarray['nbfield'] = 0; + $totalarray['val']['total_cred'] = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -656,7 +649,7 @@ if ($resql) { if ($arrayfields['account']['checked']) { $accountingaccount->fetch('', $obj->accountancy_code, 1); - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index c16b6523d1f..169666477f4 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -1,12 +1,12 @@ - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2011-2016 Alexandre Spangaro - * Copyright (C) 2011-2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2019 Nicolas ZABOURI - * Copyright (C) 2021 Gauthier VERDOL +/* Copyright (C) 2001-2003 Rodolphe Quiedeville + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2011-2022 Alexandre Spangaro + * Copyright (C) 2011-2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -58,6 +58,7 @@ $filtre = GETPOST("filtre", 'alpha'); if (!$year) { $year = date("Y", time()); } +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $search_account = GETPOST('search_account', 'int'); @@ -184,7 +185,6 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $num = $db->num_rows($resql); $i = 0; $total = 0; - $totalnb = 0; $totalpaid = 0; while ($i < min($num, $limit)) { @@ -204,7 +204,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print $socialcontrib->getNomUrl(1, '20'); print ''; // Type - print ''; + print ''; // Expected to pay print ''; // Ref payment @@ -246,7 +246,6 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print ''; $total = $total + $obj->total; - $totalnb = $totalnb + $obj->nb; $totalpaid = $totalpaid + $obj->totalpaid; $i++; } @@ -274,7 +273,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print load_fiche_titre($langs->trans("VATDeclarations").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); - $sql = "SELECT ptva.rowid, pv.rowid as id_tva, pv.amount as amount_tva, ptva.amount, pv.label, pv.datev as dm, ptva.datep as date_payment, ptva.fk_bank,"; + $sql = "SELECT ptva.rowid, pv.rowid as id_tva, pv.amount as amount_tva, ptva.amount, pv.label, pv.datev as dm, ptva.datep as date_payment, ptva.fk_bank, ptva.num_paiement as num_payment,"; $sql .= " pct.code as payment_code,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql .= " FROM ".MAIN_DB_PREFIX."tva as pv"; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ca07f30f838..9f6d68c90ab 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1030,7 +1030,7 @@ if (empty($reshook)) { $object->date = $dateinvoice; $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'restricthtml')); - // We do not copy the private note + $object->note_private = trim(GETPOST('note_private', 'restricthtml')); $object->ref_client = GETPOST('ref_client', 'alphanohtml'); $object->model_pdf = GETPOST('model', 'alphanohtml'); $object->fk_project = GETPOST('projectid', 'int'); @@ -1083,7 +1083,7 @@ if (empty($reshook)) { $object->date = $dateinvoice; $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'restricthtml')); - // We do not copy the private note + $object->note_private = trim(GETPOST('note_private', 'restricthtml')); $object->ref_client = GETPOST('ref_client'); $object->model_pdf = GETPOST('model'); $object->fk_project = GETPOST('projectid', 'int'); @@ -4711,36 +4711,36 @@ if ($action == 'create') { if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT print ''; - print ''; + print ''; print ''; // Multicurrency Amount VAT print ''; - print ''; + print ''; print ''; // Multicurrency Amount TTC print ''; - print ''; + print ''; print ''; } // Amount print ''; - print ''; + print ''; // Vat - print ''; + print ''; print ''; // Amount Local Taxes if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { // Localtax1 print ''; - print ''; + print ''; } if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { // Localtax2 print ''; - print ''; + print ''; } // Revenue stamp @@ -4796,7 +4796,7 @@ if ($action == 'create') { } // Total with tax - print ''; + print ''; print '
    '; - $form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16, 1, 'maxwidth100'); + $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, 'maxwidth100'); print ''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''.$obj->label.''.$obj->label.''.price($obj->total).'
    '.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($sign * $object->multicurrency_total_ht, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''.price($sign * $object->multicurrency_total_ht, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    '.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($sign * $object->multicurrency_total_tva, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''.price($sign * $object->multicurrency_total_tva, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    '.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($sign * $object->multicurrency_total_ttc, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''.price($sign * $object->multicurrency_total_ttc, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    '.$langs->trans('AmountHT').''.price($sign * $object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
    '.price($sign * $object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
    '.$langs->trans('AmountVAT').''.price($sign * $object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'
    '.$langs->trans('AmountVAT').''.price($sign * $object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'
    '.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($sign * $object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
    '.price($sign * $object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
    '.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($sign * $object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
    '.price($sign * $object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
    '.$langs->trans('AmountTTC').''.price($sign * $object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'
    '.$langs->trans('AmountTTC').''.price($sign * $object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'
    '; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index cac6229f86b..e963057f7ef 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -256,7 +256,7 @@ $arrayfields = array( 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); -if (getDolGlobalString("INVOICE_USE_SITUATION") && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { +if (getDolGlobalString("INVOICE_USE_SITUATION") && !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { $arrayfields['f.retained_warranty'] = array('label'=>$langs->trans("RetainedWarranty"), 'checked'=>0, 'position'=>86); } // Overwrite $arrayfields from columns into ->fields (transition before removal of $arrayoffields) @@ -1091,7 +1091,7 @@ if ($resql) { $param .= '&search_categ_cus='.urlencode($search_categ_cus); } if (!empty($search_fac_rec_source_title)) { - $param .= '&$search_fac_rec_source_title='.urlencode($search_fac_rec_source_title); + $param .= '&search_fac_rec_source_title='.urlencode($search_fac_rec_source_title); } // Add $param from extra fields diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 3d0698118ff..988d6e041be 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -564,8 +564,12 @@ while ($i < min($num, $limit)) { // Bank transaction if (!empty($arrayfields['transaction']['checked'])) { - $bankline->fetch($objp->fk_bank); - print ''.$bankline->getNomUrl(1, 0).''; + print ''; + if ($objp->fk_bank > 0) { + $bankline->fetch($objp->fk_bank); + print $bankline->getNomUrl(1, 0); + } + print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index db48b2767f2..ba62c36b0fa 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -1,6 +1,7 @@ * Copyright (C) 2016-2018 Frédéric France + * Copyright (C) 2022 Alexandre Spangaro * * 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 @@ -254,6 +255,7 @@ if ($action == 'create') { print "\n"; $total = 0; + $total_ttc = 0; $totalrecu = 0; while ($i < $num) { diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index b1ec9800aa5..f5ff5a101f2 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2014 Laurent Destailleur - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2009 Regis Houssin +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2022 Alexandre Spangaro * * 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 @@ -134,7 +135,7 @@ print ''.$langs->trans('Mode').''.$langs->trans("Pa print ''.$langs->trans('Numero').''.$object->num_payment.''; // Amount -print ''.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).''; +print ''.$langs->trans('Amount').''.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).''; // Note print ''.$langs->trans('Note').''.nl2br($object->note).''; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index fed5a42c04e..6cc3496ced0 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -1,9 +1,9 @@ - * Copyright (C) 2005-2013 Regis Houssin - * Copyright (C) 2016-2018 Frédéric France - * Copyright (C) 2017 Alexandre Spangaro - * Copyright (C) 2021 Gauthier VERDOL +/* Copyright (C) 2004-2020 Laurent Destailleur + * Copyright (C) 2005-2013 Regis Houssin + * Copyright (C) 2016-2018 Frédéric France + * Copyright (C) 2017-2022 Alexandre Spangaro + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -53,6 +53,7 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); +$lineid = GETPOST('lineid', 'int'); $fk_project = (GETPOST('fk_project') ? GETPOST('fk_project', 'int') : 0); diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 1b83915714d..318e7fcd96b 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2004-2007 Laurent Destailleur +/* Copyright (C) 2002 Rodolphe Quiedeville + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2022 Alexandre Spangaro * * 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 @@ -544,7 +545,7 @@ class PaymentSocialContribution extends CommonObject */ public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { - global $conf; + global $conf, $langs; // Clean data $this->num_payment = trim($this->num_payment); diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 93c8dea0a3e..14b8bfa043f 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -1,12 +1,12 @@ - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2016 Frédéric France - * Copyright (C) 2020 Pierre Ardoin - * Copyright (C) 2020 Tobias Sekan - * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2021 Alexandre Spangaro +/* Copyright (C) 2001-2003 Rodolphe Quiedeville + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2016 Frédéric France + * Copyright (C) 2020 Pierre Ardoin + * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2021-2022 Alexandre Spangaro * * 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 @@ -41,16 +41,17 @@ if (!empty($conf->project->enabled)) { // Load translation files required by the page $langs->loadLangs(array('compta', 'banks', 'bills', 'hrm', 'projects')); -$action = GETPOST('action', 'aZ09'); -$massaction = GETPOST('massaction', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist'; +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist'; -$search_ref = GETPOST('search_ref', 'int'); +$search_ref = GETPOST('search_ref', 'int'); $search_label = GETPOST('search_label', 'alpha'); -$search_amount = GETPOST('search_amount', 'alpha'); -$search_status = GETPOST('search_status', 'int'); +$search_typeid = GETPOST('search_typeid', 'int'); +$search_amount = GETPOST('search_amount', 'alpha'); +$search_status = GETPOST('search_status', 'int'); $search_date_startday = GETPOST('search_date_startday', 'int'); $search_date_startmonth = GETPOST('search_date_startmonth', 'int'); $search_date_startyear = GETPOST('search_date_startyear', 'int'); @@ -70,11 +71,11 @@ $search_date_limit_end = dol_mktime(23, 59, 59, $search_date_limit_endmonth, $se $search_project_ref = GETPOST('search_project_ref', 'alpha'); $search_users = GETPOST('search_users'); $search_type = GETPOST('search_type', 'int'); -$search_account = GETPOST('search_account', 'int'); +$search_account = GETPOST('search_account', 'int'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST("sortorder", 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST("sortorder", 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { @@ -93,19 +94,6 @@ if (!$sortorder) { $filtre = GETPOST("filtre", 'int'); -if (!GETPOSTISSET('search_typeid')) { - $newfiltre = str_replace('filtre=', '', $filtre); - $filterarray = explode('-', $newfiltre); - foreach ($filterarray as $val) { - $part = explode(':', $val); - if ($part[0] == 'cs.fk_type') { - $search_typeid = $part[1]; - } - } -} else { - $search_typeid = GETPOST('search_typeid', 'int'); -} - $arrayfields = array( 'cs.rowid' =>array('label'=>"Ref", 'checked'=>1, 'position'=>10), 'cs.libelle' =>array('label'=>"Label", 'checked'=>1, 'position'=>20), @@ -388,6 +376,9 @@ if (empty($mysoc->country_id) && empty($mysoc->country_code)) { $db->close(); } +$moreforfilter = ''; +$massactionbutton = ''; + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields if ($massactionbutton) { @@ -551,7 +542,9 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $ print ''; $i = 0; - $totalarray = $TLoadedUsers = array(); +$totalarray = $TLoadedUsers = array(); +$totalarray['nbfield'] = 0; +$totalarray['val']['totalttcfield'] = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index d2646d241ea..843dbd58a50 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -1,12 +1,12 @@ - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2011-2016 Alexandre Spangaro - * Copyright (C) 2011-2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2019 Nicolas ZABOURI - * Copyright (C) 2021 Gauthier VERDOL +/* Copyright (C) 2001-2003 Rodolphe Quiedeville + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2011-2022 Alexandre Spangaro + * Copyright (C) 2011-2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -37,6 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; +if (!empty($conf->accounting->enabled)) { + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +} $hookmanager = new HookManager($db); @@ -48,6 +51,7 @@ $langs->loadLangs(array('compta', 'bills', 'hrm')); $year = GETPOST("year", 'int'); $search_sc_type = GETPOST('search_sc_type', 'int'); +$optioncss = GETPOST('optioncss', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -123,6 +127,9 @@ if ($year) { if ($search_sc_type) { $param .= '&search_sc_type='.urlencode($search_sc_type); } +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} $num = 0; print ''; @@ -139,14 +146,16 @@ $sql = "SELECT c.id, c.libelle as type_label,"; $sql .= " cs.rowid, cs.libelle as label_sc, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total, cs.paye,"; $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaid, pc.num_paiement as num_payment, pc.fk_bank,"; $sql .= " pct.code as payment_code,"; -$sql .= " u.rowid uid, u.lastname, u.firstname, u.email, u.login, u.admin,"; -$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos"; +$sql .= " u.rowid as uid, u.lastname, u.firstname, u.email, u.login, u.admin, u.statut,"; +$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,"; +$sql .= " aj.label as account_journal"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON ba.fk_accountancy_journal = aj.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = cs.fk_user"; $sql .= " WHERE cs.fk_type = c.id"; $sql .= " AND cs.entity IN (".getEntity("tax").")"; @@ -278,7 +287,7 @@ while ($i < min($num, $limit)) { print $socialcontrib->getNomUrl(1, ''); print ''; // Type - print ''.$obj->label.''; + print ''.$obj->label_sc.''; // Date $date = $obj->periode; if (empty($date)) { @@ -297,8 +306,7 @@ while ($i < min($num, $limit)) { $userstatic->admin = $obj->admin; $userstatic->login = $obj->login; $userstatic->email = $obj->email; - $userstatic->socid = $obj->fk_soc; - $userstatic->statut = $obj->status; + $userstatic->statut = $obj->statut; print $userstatic->getNomUrl(1); print "\n"; } @@ -327,13 +335,16 @@ while ($i < min($num, $limit)) { $accountstatic->id = $obj->bid; $accountstatic->ref = $obj->bref; $accountstatic->number = $obj->bnumber; - $accountstatic->accountancy_number = $obj->account_number; - $accountstatic->accountancy_journal = $obj->accountancy_journal; $accountstatic->label = $obj->blabel; $accountstatic->iban = $obj->iban; $accountstatic->bic = $obj->bic; $accountstatic->currency_code = $langs->trans("Currency".$obj->currency_code); $accountstatic->clos = $obj->clos; + + if (!empty($conf->accounting->enabled)) { + $accountstatic->account_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->account_journal; + } print $accountstatic->getNomUrl(1); } else { print ' '; @@ -356,7 +367,6 @@ while ($i < min($num, $limit)) { print ''; $total = $total + $obj->total; - $totalnb = $totalnb + $obj->nb; $totalpaid = $totalpaid + $obj->totalpaid; $i++; } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 09d46d02b13..67b144ffd89 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1271,7 +1271,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ' '.$langs->trans("Delete").'

    '; } //print ''.$langs->trans("PhotoFile").''; - print ''; + print ''; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file + } + print ''; + print ''; print ''; print ''; diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index e90f8b46bd0..6030fc1e6bd 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -159,7 +159,14 @@ if ($action == 'edit') { print ' '.$langs->trans("Delete").'

    '; } print ''.$langs->trans("PhotoFile").''; - print ''; + print ''; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file + } + print ''; + print ''; print ''; print ''; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index ecc8ec22660..0f61ecada43 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1415,7 +1415,7 @@ if ($action == 'create') { } - $arrayothercontracts = $object->getListOfContracts('others'); + $arrayothercontracts = $object->getListOfContracts('others'); // array or -1 if technical error /* * Lines of contracts @@ -1544,9 +1544,9 @@ if ($action == 'create') { print ''.price($objp->pa_ht).''; } - // Icon move, update et delete (statut contrat 0=brouillon,1=valide,2=ferme) + // Icon move, update et delete (status contract 0=draft,1=validated,2=closed) print ''; - if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0)) { + if ($user->rights->contrat->creer && is_array($arrayothercontracts) && count($arrayothercontracts) && ($object->statut >= 0)) { print ''; print ''; print img_picto($langs->trans("MoveToAnotherContract"), 'uparrow'); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 8b6d7490eaf..ee59a5465dc 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1058,7 +1058,7 @@ class Contrat extends CommonObject if (count($exp->linkedObjectsIds['commande']) > 0) { foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $originforcontact = 'commande'; - $originidforcontact = $value->id; + $originidforcontact = $value; break; // We take first one } } @@ -2126,7 +2126,7 @@ class Contrat extends CommonObject } /** - * Return list of other contracts for same company than current contract + * Return list of other contracts for the same company than current contract * * @param string $option 'all' or 'others' * @param array $status sort contracts having these status @@ -2138,7 +2138,7 @@ class Contrat extends CommonObject { $tab = array(); - $sql = "SELECT c.rowid, c.ref"; + $sql = "SELECT c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; if (!empty($product_categories)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON cd.fk_contrat = c.rowid"; @@ -2159,12 +2159,12 @@ class Contrat extends CommonObject $obj = $this->db->fetch_object($resql); $contrat = new Contrat($this->db); $contrat->fetch($obj->rowid); - $tab[] = $contrat; + $tab[$contrat->id] = $contrat; $i++; } return $tab; } else { - $this->error = $this->db->error(); + $this->error = $this->db->lasterror(); return -1; } } diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 95f3cb28fd8..7dcbdd00fe7 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -278,7 +278,7 @@ if ($action == 'update' && !empty($permissiontoadd)) { $action = 'view'; $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation - if ($urltogo) { + if ($urltogo && !$noback) { header("Location: " . $urltogo); exit; } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 9ec4db2bd11..dfc9cdc7223 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1055,6 +1055,8 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' if (in_array($objecttmp->element, array('societe', 'member'))) { $result = $objecttmp->delete($objecttmp->id, $user, 1); + } elseif (in_array($objecttmp->element, array('action'))) { + $result = $objecttmp->delete(); } else { $result = $objecttmp->delete($user); } diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php index f2195659654..cd610543e47 100644 --- a/htdocs/core/boxes/box_scheduled_jobs.php +++ b/htdocs/core/boxes/box_scheduled_jobs.php @@ -63,7 +63,7 @@ class box_scheduled_jobs extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); + $this->hidden = !($user->hasRight('service', 'lire') && $user->hasRight('contrat', 'lire')); } /** diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 06d352441be..e96eee5c553 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -168,17 +168,18 @@ abstract class CommonInvoice extends CommonObject /** * Return amount (with tax) of all deposits invoices used by invoice. - * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). + * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on for sale invoices (not recommended), + * of FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS is on for purchase invoices (not recommended). * * @param int $multicurrency Return multicurrency_amount instead of amount * @return float <0 and set ->error if KO, Sum of deposits amount otherwise */ public function getSumDepositsUsed($multicurrency = 0) { - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { + /*if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { // FACTURE_DEPOSITS_ARE_JUST_PAYMENTS was never supported for purchase invoice, so we can return 0 with no need of SQL for this case. return 0.0; - } + }*/ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -899,6 +900,101 @@ abstract class CommonInvoice extends CommonObject return $s; } + + + /** + * Build string for QR-Bill (Switzerland) + * + * @return string String for Switzerland QR Code if QR-Bill + */ + public function buildSwitzerlandQRString() + { + global $conf, $mysoc; + + $tmplang = new Translate('', $conf); + $tmplang->setDefaultLang('en_US'); + $tmplang->load("main"); + + $pricewithtaxstring = price2num($this->total_ttc, 2, 1); + $pricetaxstring = price2num($this->total_tva, 2, 1); + + $complementaryinfo = ''; + /* + Example: //S1/10/10201409/11/190512/20/1400.000-53/30/106017086/31/180508/32/7.7/40/2:10;0:30 + /10/ Numéro de facture – 10201409 + /11/ Date de facture – 12.05.2019 + /20/ Référence client – 1400.000-53 + /30/ Numéro IDE pour la TVA – CHE-106.017.086 TVA + /31/ Date de la prestation pour la comptabilisation de la TVA – 08.05.2018 + /32/ Taux de TVA sur le montant total de la facture – 7.7% + /40/ Conditions – 2% d’escompte à 10 jours, paiement net à 30 jours + */ + $datestring = dol_print_date($this->date, '%y%m%d'); + //$pricewithtaxstring = price($this->total_ttc, 0, $tmplang, 0, -1, 2); + //$pricetaxstring = price($this->total_tva, 0, $tmplang, 0, -1, 2); + $complementaryinfo = '//S1/10/'.str_replace('/', '', $this->ref).'/11/'.$datestring; + if ($this->ref_client) { + $complementaryinfo .= '/20/'.$this->ref_client; + } + if ($this->thirdparty->vat_number) { + $complementaryinfo .= '/30/'.$this->thirdparty->vat_number; + } + + // Header + $s .= "SPC\n"; + $s .= "0200\n"; + $s .= "1\n"; + if ($this->fk_account > 0) { + // Bank BAN if country is LI or CH + // TODO Add + $bankaccount = new Account($this->db); + $bankaccount->fetch($this->fk_account); + $s .= $bankaccount->iban."\n"; + } else { + $s .= "\n"; + } + // Seller + $s .= "S\n"; + $s .= dol_trunc($mysoc->name, 70, 'right', 'UTF-8', 1)."\n"; + $addresslinearray = explode("\n", $mysoc->address); + $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1 + $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2 + $s .= dol_trunc($mysoc->zip, 16, 'right', 'UTF-8', 1)."\n"; + $s .= dol_trunc($mysoc->town, 35, 'right', 'UTF-8', 1)."\n"; + $s .= dol_trunc($mysoc->country_code, 2, 'right', 'UTF-8', 1)."\n"; + // Final seller + $s .= "\n"; + $s .= "\n"; + $s .= "\n"; + $s .= "\n"; + $s .= "\n"; + $s .= "\n"; + $s .= "\n"; + // Amount of payment (to do?) + $s .= price($pricewithtaxstring, 0, 'none', 0, 0, 2)."\n"; + $s .= ($this->multicurrency_code ? $this->multicurrency_code : $conf->currency)."\n"; + // Buyer + $s .= "S\n"; + $s .= dol_trunc($this->thirdparty->name, 70, 'right', 'UTF-8', 1)."\n"; + $addresslinearray = explode("\n", $this->thirdparty->address); + $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1 + $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2 + $s .= dol_trunc($this->thirdparty->zip, 16, 'right', 'UTF-8', 1)."\n"; + $s .= dol_trunc($this->thirdparty->town, 35, 'right', 'UTF-8', 1)."\n"; + $s .= dol_trunc($this->thirdparty->country_code, 2, 'right', 'UTF-8', 1)."\n"; + // ID of payment + $s .= "NON\n"; // NON or QRR + $s .= "\n"; // QR Code if previous field is QRR + if ($complementaryinfo) { + $s .= $complementaryinfo."\n"; + } else { + $s .= "\n"; + } + $s .= "EPD\n"; + $s .= "\n"; + //var_dump($s);exit; + return $s; + } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3fb25672bbe..6b13548789e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -186,6 +186,12 @@ abstract class CommonObject */ public $projet; + /** + * @deprecated + * @see fk_project + */ + public $fk_projet; + /** * @var Contact a related contact * @see fetch_contact() @@ -272,7 +278,7 @@ abstract class CommonObject public $country_id; /** - * @var string + * @var string The ISO country code on 2 chars. * @see getFullAddress(), isInEEC(), country */ public $country_code; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 602e6b560d0..0a996018e97 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -746,8 +746,8 @@ class Conf $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text } - // Default max file size for upload - $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024); + // Default max file size for upload (deprecated) + //$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024); // By default, we propagate contacts if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) { diff --git a/htdocs/core/class/evalmath.class.php b/htdocs/core/class/evalmath.class.php index 7ae9e5fcd90..c42612afda8 100644 --- a/htdocs/core/class/evalmath.class.php +++ b/htdocs/core/class/evalmath.class.php @@ -144,6 +144,10 @@ class EvalMath */ public function evaluate($expr) { + if (empty($expr)) { + return false; + } + $this->last_error = null; $this->last_error_code = null; $expr = trim($expr); @@ -374,10 +378,6 @@ class EvalMath */ private function pfx($tokens, $vars = array()) { - if ($tokens == false) { - return false; - } - $stack = new EvalMathStack(); foreach ($tokens as $token) { // nice and easy diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4f9b0d06f16..625e473e7e6 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -60,6 +60,11 @@ class ExtraFields */ public $attribute_choice; + /** + * @var array array to store extrafields definition + * @deprecated + */ + public $attribute_list; /** * @var array New array to store extrafields definition diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 56990effeb2..88f7f7aaa9a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4749,7 +4749,7 @@ class Form print img_picto('', 'bank_account', 'class="pictofixedwidth"'); $nbaccountfound = $this->select_comptes($selected, $htmlname, 0, '', $addempty); if ($nbaccountfound > 0) { - print ''; + print ''; } print ''; } else { @@ -4901,9 +4901,11 @@ class Form * @param int|string $height Force height of box (0 = auto) * @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones. * @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a
    section. + * @param string $labelbuttonyes Label for Yes + * @param string $labelbuttonno Label for No * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form */ - public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0) + public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0, $labelbuttonyes = 'Yes', $labelbuttonno = 'No') { global $langs, $conf; @@ -5012,7 +5014,7 @@ class Form $more .= ' checked="checked"'; } $more .= ' /> '; - $more .= ''; + $more .= ''; $more .= '
    '."\n"; $i++; } @@ -5118,6 +5120,7 @@ class Form $(this).parent().find("button.ui-button:eq(2)").focus(); },'; } + $formconfirm .= ' resizable: false, height: "'.$height.'", @@ -5125,7 +5128,7 @@ class Form modal: true, closeOnEscape: false, buttons: { - "'.dol_escape_js($langs->transnoentities("Yes")).'": function() { + "'.dol_escape_js($langs->transnoentities($labelbuttonyes)).'": function() { var options = "&token='.urlencode(newToken()).'"; var inputok = '.json_encode($inputok).'; /* List of fields into form */ var pageyes = "'.dol_escape_js(!empty($pageyes) ? $pageyes : '').'"; @@ -5148,7 +5151,7 @@ class Form if (pageyes.length > 0) { location.href = urljump; } $(this).dialog("close"); }, - "'.dol_escape_js($langs->transnoentities("No")).'": function() { + "'.dol_escape_js($langs->transnoentities($labelbuttonno)).'": function() { var options = "&token='.urlencode(newToken()).'"; var inputko = '.json_encode($inputko).'; /* List of fields into form */ var pageno="'.dol_escape_js(!empty($pageno) ? $pageno : '').'"; @@ -5213,7 +5216,7 @@ class Form $formconfirm .= ''; $formconfirm .= ''.$question.''; $formconfirm .= ''; - $formconfirm .= $this->selectyesno("confirm", $newselectedchoice, 0, false, 0, 0, 'marginleftonly marginrightonly'); + $formconfirm .= $this->selectyesno("confirm", $newselectedchoice, 0, false, 0, 0, 'marginleftonly marginrightonly', $labelbuttonyes, $labelbuttonno); $formconfirm .= ''; $formconfirm .= ''; $formconfirm .= ''."\n"; @@ -8844,9 +8847,11 @@ class Form * @param int $useempty 1=Add empty line * @param int $addjscombo 1=Add js beautifier on combo box * @param string $morecss More CSS - * @return string See option + * @param string $labelyes Label for Yes + * @param string $labelno Label for No + * @return string See option */ - public function selectyesno($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0, $addjscombo = 0, $morecss = '') + public function selectyesno($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0, $addjscombo = 0, $morecss = '', $labelyes = 'Yes', $labelno = 'No') { global $langs; @@ -8857,6 +8862,7 @@ class Form $no = "0"; } + $disabled = ($disabled ? ' disabled' : ''); $resultyesno = ''."\n"; @@ -9361,7 +9367,14 @@ class Form if ($object->photo) { $ret .= '

    '; } - $ret .= ''; + $ret .= ''; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $ret .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $ret .= ''; + $ret .= ''; $ret .= ''; } } else { diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 67d12147a3a..10e23f3d2e4 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -283,7 +283,7 @@ class FormAccounting extends Form $out .= ''; //if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); } else { - $out .= $langs->trans("ErrorNoAccountingCategoryForThisCountry", $mysoc->country_code); + $out = $langs->trans("ErrorNoAccountingCategoryForThisCountry", $mysoc->country_code); } } else { dol_print_error($this->db); @@ -505,6 +505,7 @@ class FormAccounting extends Form } // Build select + $out = ''; $out .= Form::selectarray($htmlname, $aux_account, $selectid, ($showempty ? (is_numeric($showempty) ? 1 : $showempty): 0), 0, 0, '', 0, 0, 0, '', $morecss, 1); //automatic filling if we give the name of the subledger_label input if (!empty($conf->use_javascript_ajax) && !empty($labelhtmlname)) { diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index f3798181bcd..6267c6ff390 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -188,7 +188,7 @@ class FormContract print ''; print ''; $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); - print ''; + print ''; print ''; } } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 97f5eca5822..9ba4ccc7f19 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -148,64 +148,15 @@ class FormFile $out .= ''; - $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb - $maxphp = @ini_get('upload_max_filesize'); // In unknown - if (preg_match('/k$/i', $maxphp)) { - $maxphp = preg_replace('/k$/i', '', $maxphp); - $maxphp = $maxphp * 1; - } - if (preg_match('/m$/i', $maxphp)) { - $maxphp = preg_replace('/m$/i', '', $maxphp); - $maxphp = $maxphp * 1024; - } - if (preg_match('/g$/i', $maxphp)) { - $maxphp = preg_replace('/g$/i', '', $maxphp); - $maxphp = $maxphp * 1024 * 1024; - } - if (preg_match('/t$/i', $maxphp)) { - $maxphp = preg_replace('/t$/i', '', $maxphp); - $maxphp = $maxphp * 1024 * 1024 * 1024; - } - $maxphp2 = @ini_get('post_max_size'); // In unknown - if (preg_match('/k$/i', $maxphp2)) { - $maxphp2 = preg_replace('/k$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1; - } - if (preg_match('/m$/i', $maxphp2)) { - $maxphp2 = preg_replace('/m$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024; - } - if (preg_match('/g$/i', $maxphp2)) { - $maxphp2 = preg_replace('/g$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024 * 1024; - } - if (preg_match('/t$/i', $maxphp2)) { - $maxphp2 = preg_replace('/t$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; - } - // Now $max and $maxphp and $maxphp2 are in Kb - $maxmin = $max; - $maxphptoshow = $maxphptoshowparam = ''; - if ($maxphp > 0) { - $maxmin = min($max, $maxphp); - $maxphptoshow = $maxphp; - $maxphptoshowparam = 'upload_max_filesize'; - } - if ($maxphp2 > 0) { - $maxmin = min($max, $maxphp2); - if ($maxphp2 < $maxphp) { - $maxphptoshow = $maxphp2; - $maxphptoshowparam = 'post_max_size'; - } - } - + $maxfilesizearray = getMaxFileSizeArray(); + $max = $maxfilesizearray['max']; + $maxmin = $maxfilesizearray['maxmin']; + $maxphptoshow = $maxfilesizearray['maxphptoshow']; + $maxphptoshowparam = $maxfilesizearray['maxphptoshowparam']; if ($maxmin > 0) { - // MAX_FILE_SIZE doit précéder le champ input de type file - $out .= ''; + $out .= ''; // MAX_FILE_SIZE must precede the field type=file } - $out .= 'global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic') ? ' name="userfile"' : ' name="userfile[]" multiple'); $out .= ((!empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $disablemulti) ? ' name="userfile"' : ' name="userfile[]" multiple'); $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); $out .= (!empty($accept) ? ' accept="'.$accept.'"' : ' accept=""'); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 27ef700cd09..f2697bc3873 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -829,6 +829,11 @@ class FormMail extends Form $out .= ''.$langs->trans("NoAttachedFiles").'
    '; } if ($this->withfile == 2) { + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $out .= ''; // MAX_FILE_SIZE must precede the field type=file + } // Can add other files if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) { $out .= ''; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 4e0d3da467e..5bee2f31dd4 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -700,11 +700,14 @@ class FormOther print ' selected'; } - $labeltoshow = $langs->trans("Project").' '.$lines[$i]->projectref; + $labeltoshow = $lines[$i]->projectref; + //$labeltoshow .= ' '.$lines[$i]->projectlabel; if (empty($lines[$i]->public)) { - $labeltoshow .= ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')'; + //$labeltoshow .= ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')'; + $labeltoshow = img_picto($lines[$i]->projectlabel, 'project', 'class="pictofixedwidth"').$labeltoshow; } else { - $labeltoshow .= ' ('.$langs->trans("Visibility").': '.$langs->trans("SharedProject").')'; + //$labeltoshow .= ' ('.$langs->trans("Visibility").': '.$langs->trans("SharedProject").')'; + $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub', 'class="pictofixedwidth"').$labeltoshow; } print ' data-html="'.dol_escape_htmltag($labeltoshow).'"'; @@ -738,12 +741,14 @@ class FormOther print ' disabled'; } - $labeltoshow = $langs->trans("Project").' '.$lines[$i]->projectref; - $labeltoshow .= ' '.$lines[$i]->projectlabel; + $labeltoshow = $lines[$i]->projectref; + //$labeltoshow .= ' '.$lines[$i]->projectlabel; if (empty($lines[$i]->public)) { - $labeltoshow .= ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')'; + //$labeltoshow .= ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')'; + $labeltoshow = img_picto($lines[$i]->projectlabel, 'project', 'class="pictofixedwidth"').$labeltoshow; } else { - $labeltoshow .= ' ('.$langs->trans("Visibility").': '.$langs->trans("SharedProject").')'; + //$labeltoshow .= ' ('.$langs->trans("Visibility").': '.$langs->trans("SharedProject").')'; + $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub', 'class="pictofixedwidth"').$labeltoshow; } if ($lines[$i]->id) { $labeltoshow .= ' > '; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index f1c6e12e925..e13aaba4685 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -418,7 +418,7 @@ class FormTicket } include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $uselocalbrowser = true; - $doleditor = new DolEditor('message', $msg, '100%', 230, $toolbarname, 'In', true, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_TICKET, ROWS_8, '90%'); + $doleditor = new DolEditor('message', $msg, '100%', 230, $toolbarname, 'In', true, $uselocalbrowser, getDolGlobalInt('FCKEDITOR_ENABLE_TICKET'), ROWS_8, '90%'); $doleditor->Create(); print ''; @@ -491,6 +491,11 @@ class FormTicket $out .= $langs->trans("NoAttachedFiles").'
    '; } if ($this->withfile == 2) { // Can add other files + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $out .= ''; // MAX_FILE_SIZE must precede the field type=file + } $out .= ''; $out .= ' '; $out .= ''; @@ -1470,7 +1475,7 @@ class FormTicket print ''; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('mail_intro', $mail_intro, '100%', 90, 'dolibarr_details', '', false, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor = new DolEditor('mail_intro', $mail_intro, '100%', 90, 'dolibarr_details', '', false, $uselocalbrowser, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_2, 70); $doleditor->Create(); print ''; @@ -1507,7 +1512,7 @@ class FormTicket //$toolbarname = 'dolibarr_details'; $toolbarname = 'dolibarr_notes'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('message', $defaultmessage, '100%', 200, $toolbarname, '', false, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, 70); + $doleditor = new DolEditor('message', $defaultmessage, '100%', 200, $toolbarname, '', false, $uselocalbrowser, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, 70); $doleditor->Create(); print ''; @@ -1519,7 +1524,7 @@ class FormTicket print $form->textwithpicto('', $langs->trans("TicketMessageMailSignatureHelp"), 1, 'help'); print ''; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('mail_signature', $mail_signature, '100%', 150, 'dolibarr_details', '', false, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor = new DolEditor('mail_signature', $mail_signature, '100%', 150, 'dolibarr_details', '', false, $uselocalbrowser, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_2, 70); $doleditor->Create(); print ''; } diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index ae9a8e56e58..49a2c6d4403 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -33,6 +33,13 @@ abstract class Stats protected $lastfetchdate = array(); // Dates of cache file read by methods public $cachefilesuffix = ''; // Suffix to add to name of cache file (to avoid file name conflicts) + /** + * @param int $year number + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return int value + */ + protected abstract function getNbByMonth($year, $format = 0); + /** * Return nb of elements by month for several years * @@ -123,6 +130,13 @@ abstract class Stats return $data; } + /** + * @param int $year year number + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return int value + */ + protected abstract function getAmountByMonth($year, $format = 0); + /** * Return amount of elements by month for several years. * Criterias used to build request are defined into the constructor of parent class into xxx/class/xxxstats.class.php @@ -460,7 +474,6 @@ abstract class Stats return $data; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Return the amount per month for a given year diff --git a/htdocs/core/class/validate.class.php b/htdocs/core/class/validate.class.php index ac4c14f7937..9d8832c36ce 100644 --- a/htdocs/core/class/validate.class.php +++ b/htdocs/core/class/validate.class.php @@ -300,13 +300,13 @@ class Validate /** * Check for all values in db * - * @param array $values Boolean to validate + * @param integer $id of element * @param string $classname the class name * @param string $classpath the class path * @return boolean Validity is ok or not * @throws Exception */ - public function isFetchable($values, $classname, $classpath) + public function isFetchable($id, $classname, $classpath) { if (!empty($classpath)) { if (dol_include_once($classpath)) { @@ -319,7 +319,7 @@ class Validate return false; } - if (!empty($object->table_element) && $object->isExistingObject($object->table_element, $values)) { + if (!empty($object->table_element) && $object->isExistingObject($object->table_element, $id)) { return true; } else { $this->error = $this->outputLang->trans('RequireValidExistingElement'); } } else { $this->error = $this->outputLang->trans('BadSetupOfFieldClassNotFoundForValidation'); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 13d44e1ec8a..13ccde98bf2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -132,6 +132,9 @@ function getEntity($element, $shared = 1, $currentobject = null) case 'order_supplier': $element = 'supplier_order'; break; // "/fourn/class/fournisseur.commande.class.php" + case 'invoice_supplier': + $element = 'supplier_invoice'; + break; // "/fourn/class/fournisseur.facture.class.php" } if (is_object($mc)) { @@ -742,7 +745,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null // - posted value not empty, or // - if posted value is empty and a default value exists that is not empty (it means we did a filter to an empty value when default was not). - if ($out != '') { // $out = '0' or 'abc', it is a search criteria to keep + if ($out != '' && isset($user)) {// $out = '0' or 'abc', it is a search criteria to keep $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out; } } @@ -2246,6 +2249,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } } + // Show address and email if (method_exists($object, 'getBannerAddress') && !in_array($object->element, array('product', 'bookmark', 'ecm_directories', 'ecm_files'))) { $moreaddress = $object->getBannerAddress('refaddress', $object); if ($moreaddress) { @@ -2950,6 +2954,7 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, //$rep .= ''; if ($hookmanager) { $parameters = array('cid' => $cid, 'socid' => $socid, 'addlink' => $addlink, 'picto' => $withpicto); + $reshook = $hookmanager->executeHooks('printEmail', $parameters, $email); if ($reshook > 0) { $rep = ''; @@ -3912,7 +3917,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'recent', 'reception', 'recruitmentcandidature', 'recruitmentjobposition', 'resource', 'recurring', 'shapes', 'square', 'stop-circle', 'supplier', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', - 'uncheck', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation', 'world', 'private', + 'uncheck', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation', 'webhook', 'world', 'private', 'conferenceorbooth', 'eventorganization' ))) { $fakey = $pictowithouttext; @@ -3963,7 +3968,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'title_agenda'=>'calendar-alt', 'uncheck'=>'times', 'uparrow'=>'share', 'vat'=>'money-check-alt', 'vcard'=>'address-card', 'jabber'=>'comment-o', - 'website'=>'globe-americas', 'workstation'=>'pallet', 'world'=>'globe', 'private'=>'user-lock', + 'website'=>'globe-americas', 'workstation'=>'pallet', 'webhook'=>'bullseye', 'world'=>'globe', 'private'=>'user-lock', 'conferenceorbooth'=>'chalkboard-teacher', 'eventorganization'=>'project-diagram' ); if ($pictowithouttext == 'off') { @@ -5464,7 +5469,7 @@ function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0) * * @param float $amount Amount to format * @param integer $form Type of format, HTML or not (not by default) - * @param Translate|string $outlangs Object langs for output + * @param Translate|string $outlangs Object langs for output. '' use default lang. 'none' use international separators. * @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before beeing inserted into database or after a computation, so this parameter should be useless. * @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT) * @param int $forcerounding Force the number of decimal to forcerounding decimal (-1=do not force) @@ -5487,25 +5492,31 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ } $nbdecimal = $rounding; - // Output separators by default (french) - $dec = ','; - $thousand = ' '; - - // If $outlangs not forced, we use use language - if (!is_object($outlangs)) { - $outlangs = $langs; - } - - if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { - $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal"); - } - if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { - $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand"); - } - if ($thousand == 'None') { + if ($outlangs === 'none') { + // Use international separators + $dec = '.'; $thousand = ''; - } elseif ($thousand == 'Space') { + } else { + // Output separators by default (french) + $dec = ','; $thousand = ' '; + + // If $outlangs not forced, we use use language + if (!is_object($outlangs)) { + $outlangs = $langs; + } + + if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { + $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal"); + } + if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { + $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand"); + } + if ($thousand == 'None') { + $thousand = ''; + } elseif ($thousand == 'Space') { + $thousand = ' '; + } } //print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'
    "; @@ -5544,7 +5555,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ } // Add symbol of currency if requested $cursymbolbefore = $cursymbolafter = ''; - if ($currency_code) { + if ($currency_code && is_object($outlangs)) { if ($currency_code == 'auto') { $currency_code = $conf->currency; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index d53870128fc..273922ff615 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -650,7 +650,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($showproject) { // Project ref - print ""; + print ''; //if ($showlineingray) print ''; if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) { print $projectstatic->getNomUrl(1); @@ -701,21 +701,21 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } if (count($arrayfields) > 0 && !empty($arrayfields['t.description']['checked'])) { - print ""; + print ''; print $lines[$i]->description; print "\n"; } // Date start if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) { - print ''; + print ''; print dol_print_date($lines[$i]->date_start, 'dayhour'); print ''; } // Date end if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) { - print ''; + print ''; print dol_print_date($lines[$i]->date_end, 'dayhour'); if ($taskstatic->hasDelay()) { print img_warning($langs->trans("Late")); @@ -2549,8 +2549,8 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $projectstatic->ref = $objp->ref; $projectstatic->status = $objp->status; $projectstatic->title = $objp->title; - $projectstatic->datee = $db->jdate($objp->datee); - $projectstatic->dateo = $db->jdate($objp->dateo); + $projectstatic->date_end = $db->jdate($objp->datee); + $projectstatic->date_start = $db->jdate($objp->dateo); print ''; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 056d28ab2cd..1d3f013e9f3 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -977,3 +977,70 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho } exit(0); } + + +/** + * Return the max allowed for file upload. + * Analyze among: upload_max_filesize, post_max_size, MAIN_UPLOAD_DOC + * + * @return array Array with all max size for file upload + */ +function getMaxFileSizeArray() +{ + global $conf; + + $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb + $maxphp = @ini_get('upload_max_filesize'); // In unknown + if (preg_match('/k$/i', $maxphp)) { + $maxphp = preg_replace('/k$/i', '', $maxphp); + $maxphp = $maxphp * 1; + } + if (preg_match('/m$/i', $maxphp)) { + $maxphp = preg_replace('/m$/i', '', $maxphp); + $maxphp = $maxphp * 1024; + } + if (preg_match('/g$/i', $maxphp)) { + $maxphp = preg_replace('/g$/i', '', $maxphp); + $maxphp = $maxphp * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp)) { + $maxphp = preg_replace('/t$/i', '', $maxphp); + $maxphp = $maxphp * 1024 * 1024 * 1024; + } + $maxphp2 = @ini_get('post_max_size'); // In unknown + if (preg_match('/k$/i', $maxphp2)) { + $maxphp2 = preg_replace('/k$/i', '', $maxphp2); + $maxphp2 = $maxphp2 * 1; + } + if (preg_match('/m$/i', $maxphp2)) { + $maxphp2 = preg_replace('/m$/i', '', $maxphp2); + $maxphp2 = $maxphp2 * 1024; + } + if (preg_match('/g$/i', $maxphp2)) { + $maxphp2 = preg_replace('/g$/i', '', $maxphp2); + $maxphp2 = $maxphp2 * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp2)) { + $maxphp2 = preg_replace('/t$/i', '', $maxphp2); + $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + } + // Now $max and $maxphp and $maxphp2 are in Kb + $maxmin = $max; + $maxphptoshow = $maxphptoshowparam = ''; + if ($maxphp > 0) { + $maxmin = min($maxmin, $maxphp); + $maxphptoshow = $maxphp; + $maxphptoshowparam = 'upload_max_filesize'; + } + if ($maxphp2 > 0) { + $maxmin = min($maxmin, $maxphp2); + if ($maxphp2 < $maxphp) { + $maxphptoshow = $maxphp2; + $maxphptoshowparam = 'post_max_size'; + } + } + //var_dump($maxphp.'-'.$maxphp2); + //var_dump($maxmin); + + return array('max'=>$max, 'maxmin'=>$maxmin, 'maxphptoshow'=>$maxphptoshow, 'maxphptoshowparam'=>$maxphptoshowparam); +} diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 23917c4b79c..43bf3ecd2cb 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -174,7 +174,13 @@ class doc_generic_bom_odt extends ModelePDFBom $texte .= ''; } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 94e0a634328..86e43a9c021 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -181,7 +181,13 @@ class doc_generic_order_odt extends ModelePDFCommandes $texte .= '
    '; } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index bdda6f26862..cb73b6fc282 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -611,6 +611,9 @@ class pdf_einstein extends ModelePDFCommandes if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index b2d0c1c0f30..8930481d219 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -835,6 +835,9 @@ class pdf_eratosthene extends ModelePDFCommandes if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == $pageposafter) { diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 23ed4bec34a..9050e1accf5 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -166,7 +166,13 @@ class doc_generic_contract_odt extends ModelePDFContract } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 4dbad109cf4..1875cfb833c 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -437,6 +437,9 @@ class pdf_strato extends ModelePDFContract $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index 9c588fdf55e..7d880328663 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -574,6 +574,9 @@ class pdf_storm extends ModelePDFDeliveryOrder if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index a9537b324f1..2e0c3f2d05c 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -498,6 +498,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 209acf648d6..f2035c89575 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -180,7 +180,13 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $texte .= '
    '; } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 982a63dade8..3a8defb8db4 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -708,6 +708,9 @@ class pdf_espadon extends ModelePdfExpedition if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index e1da387d1ad..ab9461d104f 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -614,6 +614,9 @@ class pdf_rouget extends ModelePdfExpedition if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/expedition/mod_expedition_ribera.php b/htdocs/core/modules/expedition/mod_expedition_ribera.php index 736ddc3ab3f..aae32f0f459 100644 --- a/htdocs/core/modules/expedition/mod_expedition_ribera.php +++ b/htdocs/core/modules/expedition/mod_expedition_ribera.php @@ -80,7 +80,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition $tooltip .= $langs->trans("GenericMaskCodes5"); $texte .= ''.$langs->trans("Mask").':'; - $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; $texte .= '  '; $texte .= ''; $texte .= ''; @@ -125,9 +125,9 @@ class mod_expedition_ribera extends ModelNumRefExpedition require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $mask = $conf->global->EXPEDITION_RIBERA_MASK; + $mask = getDolGlobalString('EXPEDITION_RIBERA_MASK'); - if (!$mask) { + if (empty($mask)) { $this->error = 'NotConfigured'; return 0; } diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 6dae41ca2af..43c1ae9e4de 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -450,6 +450,9 @@ class pdf_standard extends ModeleExpenseReport if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 07a1e3966a6..fc73460bd1b 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -179,7 +179,13 @@ class doc_generic_invoice_odt extends ModelePDFFactures $texte .= '
    '; } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 1bb5400acc7..63e9d61c409 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -452,8 +452,13 @@ class pdf_crabe extends ModelePDFFactures // You can add more thing under header here, if you increase $extra_under_address_shift too. $extra_under_address_shift = 0; + $qrcodestring = ''; if (! empty($conf->global->INVOICE_ADD_ZATCA_QR_CODE)) { $qrcodestring = $object->buildZATCAQRString(); + } elseif (! empty($conf->global->INVOICE_ADD_SWISS_QR_CODE)) { + $qrcodestring = $object->buildSwitzerlandQRString(); + } + if ($qrcodestring) { $qrcodecolor = array('25', '25', '25'); // set style for QR-code $styleQr = array( @@ -795,6 +800,9 @@ class pdf_crabe extends ModelePDFFactures if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index bc4dad25f91..46ac4ffde37 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -435,8 +435,13 @@ class pdf_sponge extends ModelePDFFactures // You can add more thing under header here, if you increase $extra_under_address_shift too. $extra_under_address_shift = 0; + $qrcodestring = ''; if (! empty($conf->global->INVOICE_ADD_ZATCA_QR_CODE)) { $qrcodestring = $object->buildZATCAQRString(); + } elseif (! empty($conf->global->INVOICE_ADD_SWISS_QR_CODE)) { + $qrcodestring = $object->buildSwitzerlandQRString(); + } + if ($qrcodestring) { $qrcodecolor = array('25', '25', '25'); // set style for QR-code $styleQr = array( @@ -929,6 +934,9 @@ class pdf_sponge extends ModelePDFFactures if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 8c07dbb64f3..bb4a6826278 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -418,6 +418,9 @@ class pdf_soleil extends ModelePDFFicheinter if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index 9a80484f83b..d698a646371 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -110,6 +110,11 @@ class mailing_xinputfile extends MailingTargets global $langs; $s = ''; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $s .= ''; // MAX_FILE_SIZE must precede the field type=file + } $s .= ''; return $s; } diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index fb084f312fe..0b64203798f 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -169,7 +169,13 @@ class doc_generic_member_odt extends ModelePDFMember $texte .= '
    '; } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 80a6ff1a805..2cdc8229e51 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -134,7 +134,7 @@ class modFacture extends DolibarrModules 'objectname'=>'Facture', 'method'=>'sendEmailsRemindersOnInvoiceDueDate', 'parameters'=>"10,all,EmailTemplateCode", - 'comment'=>'Send an emails when the unpaid invoices reach a due date + n days = today. First param is the offset n of days, second parameter is "all" or a payment mode code, last parameter is the code of email template to use (an email template with EmailTemplateCode must exists. the version in the language of the thirdparty will be used in priority).', + 'comment'=>'Send an emails when the unpaid invoices reach a due date + n days = today. First param is the offset n of days, second parameter is "all" or a payment mode code, last parameter is the code of email template to use (an email template with EmailTemplateCode must exists. The version in the language of the thirdparty will be used in priority to update the PDF of the sent invoice).', 'frequency'=>1, 'unitfrequency'=>3600 * 24, 'priority'=>50, diff --git a/htdocs/core/modules/modWebhook.class.php b/htdocs/core/modules/modWebhook.class.php new file mode 100644 index 00000000000..fbcb5f81003 --- /dev/null +++ b/htdocs/core/modules/modWebhook.class.php @@ -0,0 +1,542 @@ + + * Copyright (C) 2018-2019 Nicolas ZABOURI + * Copyright (C) 2019-2020 Frédéric France + * Copyright (C) 2022 SuperAdmin + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \defgroup webhook Module Webhook + * \brief Webhook module descriptor. + * + * \file htdocs/webhook/core/modules/modWebhook.class.php + * \ingroup webhook + * \brief Description and activation file for module Webhook + */ +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; + +/** + * Description and activation class for module Webhook + */ +class modWebhook extends DolibarrModules +{ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs, $conf; + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 68305; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module + + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'webhook'; + + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "interface"; + + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '90'; + + // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + // Module label (no space allowed), used if translation string 'ModuleWebhookName' not found (Webhook is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + + // Module description, used if translation string 'ModuleWebhookDesc' not found (Webhook is name of module). + $this->description = "WebhookDescription"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "WebhookDescription"; + + // Author + $this->editor_name = 'Editor name'; + $this->editor_url = 'https://www.example.com'; + + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = 'development'; + // Url to the file with your last numberversion of this module + //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; + + // Key used in llx_const table to save module status enabled/disabled (where WEBHOOK is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + // To use a supported fa-xxx css style of font awesome, use this->picto='xxx' + $this->picto = 'webhook'; + + // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) + $this->module_parts = array( + // Set this to 1 if module has its own trigger directory (core/triggers) + 'triggers' => 1, + // Set this to 1 if module has its own login method file (core/login) + 'login' => 0, + // Set this to 1 if module has its own substitution function file (core/substitutions) + 'substitutions' => 0, + // Set this to 1 if module has its own menus handler directory (core/menus) + 'menus' => 0, + // Set this to 1 if module overwrite template dir (core/tpl) + 'tpl' => 0, + // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'barcode' => 0, + // Set this to 1 if module has its own models directory (core/modules/xxx) + 'models' => 1, + // Set this to 1 if module has its own printing directory (core/modules/printing) + 'printing' => 0, + // Set this to 1 if module has its own theme directory (theme) + 'theme' => 0, + // Set this to relative path of css file if module has its own css file + 'css' => array( + // '/webhook/css/webhook.css.php', + ), + // Set this to relative path of js file if module must load a js on all pages + 'js' => array( + // '/webhook/js/webhook.js.php', + ), + // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all' + 'hooks' => array( + // 'data' => array( + // 'hookcontext1', + // 'hookcontext2', + // ), + // 'entity' => '0', + ), + // Set this to 1 if features of module are opened to external users + 'moduleforexternal' => 0, + ); + + // Data directories to create when module is enabled. + // Example: this->dirs = array("/webhook/temp","/webhook/subdir"); + $this->dirs = array("/webhook/temp"); + + // Config pages. Put here list of php page, stored into webhook/admin directory, to use to setup module. + $this->config_page_url = array("webhook.php"); + + // Dependencies + // A condition to hide module + $this->hidden = false; + // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->depends = array(); + $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + + // The language file dedicated to your module + $this->langfiles = array("webhook"); + + // Prerequisites + $this->phpmin = array(5, 6); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(11, -3); // Minimum version of Dolibarr required by module + + // Messages at activation + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','MX'='textmx'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','MX'='textmx'...) + //$this->automatic_activation = array('FR'=>'WebhookWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled + + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(1 => array('WEBHOOK_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), + // 2 => array('WEBHOOK_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) + // ); + $this->const = array(); + + // Some keys to add into the overwriting translation tables + /*$this->overwrite_translation = array( + 'en_US:ParentCompany'=>'Parent company or reseller', + 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' + )*/ + + if (!isset($conf->webhook) || !isset($conf->webhook->enabled)) { + $conf->webhook = new stdClass(); + $conf->webhook->enabled = 0; + } + + // Array to add new pages in new tabs + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@webhook:$user->rights->webhook->read:/webhook/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@webhook:$user->rights->othermodule->read:/webhook/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // + // Where objecttype can be + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + + // Dictionaries + $this->dictionaries = array(); + /* Example: + $this->dictionaries=array( + 'langs'=>'webhook@webhook', + // List of tables we want to see into dictonnary editor + 'tabname'=>array(MAIN_DB_PREFIX."table1", MAIN_DB_PREFIX."table2", MAIN_DB_PREFIX."table3"), + // Label of tables + 'tablib'=>array("Table1", "Table2", "Table3"), + // Request to select fields + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + // Sort order + 'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"), + // List of fields (result of select to show dictionary) + 'tabfield'=>array("code,label", "code,label", "code,label"), + // List of fields (list of fields to edit a record) + 'tabfieldvalue'=>array("code,label", "code,label", "code,label"), + // List of fields (list of fields for insert) + 'tabfieldinsert'=>array("code,label", "code,label", "code,label"), + // Name of columns with primary key (try to always name it 'rowid') + 'tabrowid'=>array("rowid", "rowid", "rowid"), + // Condition to show each dictionary + 'tabcond'=>array($conf->webhook->enabled, $conf->webhook->enabled, $conf->webhook->enabled) + ); + */ + + // Boxes/Widgets + // Add here list of php file(s) stored in webhook/core/boxes that contains a class to show a widget. + $this->boxes = array( + // 0 => array( + // 'file' => 'webhookwidget1.php@webhook', + // 'note' => 'Widget provided by Webhook', + // 'enabledbydefaulton' => 'Home', + // ), + // ... + ); + + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + // 0 => array( + // 'label' => 'MyJob label', + // 'jobtype' => 'method', + // 'class' => '/webhook/class/webhook_target.class.php', + // 'objectname' => 'Webhook_target', + // 'method' => 'doScheduledJob', + // 'parameters' => '', + // 'comment' => 'Comment', + // 'frequency' => 2, + // 'unitfrequency' => 3600, + // 'status' => 0, + // 'test' => '$conf->webhook->enabled', + // 'priority' => 50, + // ), + ); + // Example: $this->cronjobs=array( + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->webhook->enabled', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->webhook->enabled', 'priority'=>50) + // ); + + // Permissions provided by this module + $this->rights = array(); + $r = 0; + // Add here entries to declare new permissions + /* BEGIN MODULEBUILDER PERMISSIONS */ + $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) + $this->rights[$r][1] = 'Read objects of Webhook'; // Permission label + $this->rights[$r][4] = 'webhook_target'; + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->webhook->webhook_target->read) + $r++; + $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update objects of Webhook'; // Permission label + $this->rights[$r][4] = 'webhook_target'; + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->webhook->webhook_target->write) + $r++; + $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete objects of Webhook'; // Permission label + $this->rights[$r][4] = 'webhook_target'; + $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->webhook->webhook_target->delete) + $r++; + /* END MODULEBUILDER PERMISSIONS */ + + // Main menu entries to add + $this->menu = array(); + $r = 0; + // Add here entries to declare new menus + /* BEGIN MODULEBUILDER TOPMENU */ + /*$this->menu[$r++] = array( + 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'top', // This is a Top menu entry + 'titre'=>'ModuleWebhookName', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth valignmiddle"'), + 'mainmenu'=>'webhook', + 'leftmenu'=>'', + 'url'=>'/webhook/webhookindex.php', + 'langs'=>'webhook@webhook', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000 + $r, + 'enabled'=>'$conf->webhook->enabled', // Define condition to show or hide menu entry. Use '$conf->webhook->enabled' if entry must be visible if module is enabled. + 'perms'=>'1', // Use 'perms'=>'$user->rights->webhook->webhook_target->read' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + );*/ + /* END MODULEBUILDER TOPMENU */ + /* BEGIN MODULEBUILDER LEFTMENU WEBHOOK_TARGET + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=webhook', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'Webhook_target', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth valignmiddle"'), + 'mainmenu'=>'webhook', + 'leftmenu'=>'webhook_target', + 'url'=>'/webhook/webhookindex.php', + 'langs'=>'webhook@webhook', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->webhook->enabled', // Define condition to show or hide menu entry. Use '$conf->webhook->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->webhook->webhook_target->read', // Use 'perms'=>'$user->rights->webhook->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=webhook,fk_leftmenu=webhook_target', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'List_Webhook_target', + 'mainmenu'=>'webhook', + 'leftmenu'=>'webhook_webhook_target_list', + 'url'=>'/webhook/webhook_target_list.php', + 'langs'=>'webhook@webhook', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->webhook->enabled', // Define condition to show or hide menu entry. Use '$conf->webhook->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'$user->rights->webhook->webhook_target->read', // Use 'perms'=>'$user->rights->webhook->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=webhook,fk_leftmenu=webhook_target', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'New_Webhook_target', + 'mainmenu'=>'webhook', + 'leftmenu'=>'webhook_webhook_target_new', + 'url'=>'/webhook/webhook_target_card.php?action=create', + 'langs'=>'webhook@webhook', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->webhook->enabled', // Define condition to show or hide menu entry. Use '$conf->webhook->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'$user->rights->webhook->webhook_target->write', // Use 'perms'=>'$user->rights->webhook->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + */ + + /*$this->menu[$r++]=array( + // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'fk_menu'=>'fk_mainmenu=webhook', + // This is a Left menu entry + 'type'=>'left', + 'titre'=>'List Webhook_target', + 'mainmenu'=>'webhook', + 'leftmenu'=>'webhook_webhook_target', + 'url'=>'/webhook/webhook_target_list.php', + // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'webhook@webhook', + 'position'=>1100+$r, + // Define condition to show or hide menu entry. Use '$conf->webhook->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'$conf->webhook->enabled', + // Use 'perms'=>'$user->rights->webhook->level1->level2' if you want your menu with a permission rules + 'perms'=>'1', + 'target'=>'', + // 0=Menu for internal users, 1=external users, 2=both + 'user'=>2, + ); + $this->menu[$r++]=array( + // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'fk_menu'=>'fk_mainmenu=webhook,fk_leftmenu=webhook_webhook_target', + // This is a Left menu entry + 'type'=>'left', + 'titre'=>'New Webhook_target', + 'mainmenu'=>'webhook', + 'leftmenu'=>'webhook_webhook_target', + 'url'=>'/webhook/webhook_target_card.php?action=create', + // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'webhook@webhook', + 'position'=>1100+$r, + // Define condition to show or hide menu entry. Use '$conf->webhook->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'$conf->webhook->enabled', + // Use 'perms'=>'$user->rights->webhook->level1->level2' if you want your menu with a permission rules + 'perms'=>'1', + 'target'=>'', + // 0=Menu for internal users, 1=external users, 2=both + 'user'=>2 + );*/ + + /* END MODULEBUILDER LEFTMENU WEBHOOK_TARGET */ + // Exports profiles provided by this module + $r = 1; + /* BEGIN MODULEBUILDER EXPORT WEBHOOK_TARGET */ + /* + $langs->load("webhook@webhook"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='Webhook_targetLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='webhook_target@webhook'; + // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array + $keyforclass = 'Webhook_target'; $keyforclassfile='/webhook/class/webhook_target.class.php'; $keyforelement='webhook_target@webhook'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text'; + //unset($this->export_fields_array[$r]['t.fieldtoremove']); + //$keyforclass = 'Webhook_targetLine'; $keyforclassfile='/webhook/class/webhook_target.class.php'; $keyforelement='webhook_targetline@webhook'; $keyforalias='tl'; + //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='webhook_target'; $keyforaliasextra='extra'; $keyforelement='webhook_target@webhook'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$keyforselect='webhook_targetline'; $keyforaliasextra='extraline'; $keyforelement='webhook_targetline@webhook'; + //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r] = array('webhook_targetline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + //$this->export_special_array[$r] = array('t.field'=>'...'); + //$this->export_examplevalues_array[$r] = array('t.field'=>'Example'); + //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp'); + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'webhook_target as t'; + //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'webhook_target_line as tl ON tl.fk_webhook_target = t.rowid'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('webhook_target').')'; + $r++; */ + /* END MODULEBUILDER EXPORT WEBHOOK_TARGET */ + + // Imports profiles provided by this module + $r = 1; + /* BEGIN MODULEBUILDER IMPORT WEBHOOK_TARGET */ + /* + $langs->load("webhook@webhook"); + $this->import_code[$r]=$this->rights_class.'_'.$r; + $this->import_label[$r]='Webhook_targetLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->import_icon[$r]='webhook_target@webhook'; + $this->import_tables_array[$r] = array('t' => MAIN_DB_PREFIX.'webhook_webhook_target', 'extra' => MAIN_DB_PREFIX.'webhook_webhook_target_extrafields'); + $this->import_tables_creator_array[$r] = array('t' => 'fk_user_author'); // Fields to store import user id + $import_sample = array(); + $keyforclass = 'Webhook_target'; $keyforclassfile='/webhook/class/webhook_target.class.php'; $keyforelement='webhook_target@webhook'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinimport.inc.php'; + $import_extrafield_sample = array(); + $keyforselect='webhook_target'; $keyforaliasextra='extra'; $keyforelement='webhook_target@webhook'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php'; + $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'webhook_webhook_target'); + $this->import_regex_array[$r] = array(); + $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); + $this->import_updatekeys_array[$r] = array('t.ref' => 'Ref'); + $this->import_convertvalue_array[$r] = array( + 't.ref' => array( + 'rule'=>'getrefifauto', + 'class'=>(empty($conf->global->WEBHOOK_WEBHOOK_TARGET_ADDON) ? 'mod_webhook_target_standard' : $conf->global->WEBHOOK_WEBHOOK_TARGET_ADDON), + 'path'=>"/core/modules/commande/".(empty($conf->global->WEBHOOK_WEBHOOK_TARGET_ADDON) ? 'mod_webhook_target_standard' : $conf->global->WEBHOOK_WEBHOOK_TARGET_ADDON).'.php' + 'classobject'=>'Webhook_target', + 'pathobject'=>'/webhook/class/webhook_target.class.php', + ), + 't.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'), + 't.fk_user_valid' => array('rule' => 'fetchidfromref', 'file' => '/user/class/user.class.php', 'class' => 'User', 'method' => 'fetch', 'element' => 'user'), + 't.fk_mode_reglement' => array('rule' => 'fetchidfromcodeorlabel', 'file' => '/compta/paiement/class/cpaiement.class.php', 'class' => 'Cpaiement', 'method' => 'fetch', 'element' => 'cpayment'), + ); + $r++; */ + /* END MODULEBUILDER IMPORT WEBHOOK_TARGET */ + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf, $langs; + + $result = $this->_load_tables('/install/mysql/tables/', 'webhook'); + //$result = $this->_load_tables('/webhook/sql/'); + if ($result < 0) { + return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') + } + + // Create extrafields during init + //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + //$extrafields = new ExtraFields($this->db); + //$result1=$extrafields->addExtraField('webhook_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'webhook@webhook', '$conf->webhook->enabled'); + //$result2=$extrafields->addExtraField('webhook_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'webhook@webhook', '$conf->webhook->enabled'); + //$result3=$extrafields->addExtraField('webhook_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'webhook@webhook', '$conf->webhook->enabled'); + //$result4=$extrafields->addExtraField('webhook_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'webhook@webhook', '$conf->webhook->enabled'); + //$result5=$extrafields->addExtraField('webhook_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'webhook@webhook', '$conf->webhook->enabled'); + + // Permissions + $this->remove($options); + + $sql = array(); + + // Document templates + $moduledir = dol_sanitizeFileName('webhook'); + $myTmpObjects = array(); + $myTmpObjects['Webhook_target'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0); + + foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { + if ($myTmpObjectKey == 'Webhook_target') { + continue; + } + if ($myTmpObjectArray['includerefgeneration']) { + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_webhook_targets.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir; + $dest = $dirodt.'/template_webhook_targets.odt'; + + if (file_exists($src) && !file_exists($dest)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result = dol_copy($src, $dest, 0, 0); + if ($result < 0) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); + return 0; + } + } + + $sql = array_merge($sql, array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity), + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")", + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity), + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")" + )); + } + } + + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); + return $this->_remove($sql, $options); + } +} diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index f597f580b47..f83b6efa1ed 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -675,6 +675,9 @@ class pdf_standard extends ModelePDFMovement if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 090a45f4b3f..5d228da7d8c 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -177,7 +177,13 @@ class doc_generic_product_odt extends ModelePDFProduct $texte .= '
    '; } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index bb6eb75bf75..df013a2fad0 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -470,6 +470,9 @@ class pdf_baleine extends ModelePDFProjects if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 4aa6f754ad9..fba5e02b098 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -743,6 +743,9 @@ class pdf_beluga extends ModelePDFProjects if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } } diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 741476de117..9d118b2a555 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -473,6 +473,9 @@ class pdf_timespent extends ModelePDFProjects if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 39ffd92ac5e..6f91d676949 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -211,7 +211,13 @@ class doc_generic_proposal_odt extends ModelePDFPropales } } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 511677d742b..177443153ce 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -726,6 +726,9 @@ class pdf_azur extends ModelePDFPropales if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 47af81d8aa2..1ed76728b92 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -850,6 +850,9 @@ class pdf_cyan extends ModelePDFPropales if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 3e48aaf18bc..1976dea773f 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -173,7 +173,13 @@ class doc_generic_reception_odt extends ModelePdfReception $texte .= '
    '; } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 7d234e6bd95..61fab1ab02d 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -538,6 +538,9 @@ class pdf_squille extends ModelePdfReception $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 3a62eb22937..a19c90215b0 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -169,7 +169,13 @@ class doc_generic_odt extends ModeleThirdPartyDoc $texte .= '
    '; } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index f8733a8a8ff..c54e5f4f02a 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -177,7 +177,13 @@ class doc_generic_stock_odt extends ModelePDFStock $texte .= '
    '; } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index ecbeccb5a61..3fd3917da2d 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -460,6 +460,9 @@ class pdf_standard extends ModelePDFStock if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index da8c1f4ac26..233d18ce229 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -777,6 +777,9 @@ class pdf_cornas extends ModelePDFSuppliersOrders if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == $pageposafter) { diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index c7dc161330c..5498800aefc 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -659,6 +659,9 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 4e1027207a7..6919ffe69aa 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -420,6 +420,9 @@ class pdf_standard extends ModelePDFSuppliersPayments if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 6b47240016f..70ee5d75710 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -659,6 +659,9 @@ class pdf_aurore extends ModelePDFSupplierProposal if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index d69da78aacc..cf358cae606 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -166,7 +166,13 @@ class doc_generic_ticket_odt extends ModelePDFTicket $texte .= '
    '; } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $texte .= ' '; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index a46503b6e2a..0c9f5263e09 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -197,7 +197,13 @@ class doc_generic_user_odt extends ModelePDFUser $texte .= '
    '; } // Add input to upload a new template file. - $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
    '; diff --git a/htdocs/core/tpl/ajax/fileupload_view.tpl.php b/htdocs/core/tpl/ajax/fileupload_view.tpl.php index 70182a17dbc..22f8d687db0 100644 --- a/htdocs/core/tpl/ajax/fileupload_view.tpl.php +++ b/htdocs/core/tpl/ajax/fileupload_view.tpl.php @@ -37,6 +37,13 @@ if (empty($conf) || !is_object($conf)) { trans('AddFiles'); ?> + 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file + } + ?>