diff --git a/ChangeLog b/ChangeLog index 4ca56665cee..031e740e008 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,7 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The signature of method getNomUrl() of class ProductFournisseur has been modified to match the signature of method Product * Trigger ORDER_SUPPLIER_DISPATCH is removed, use ORDER_SUPPLIER_RECEIVE and/or LINEORDER_SUPPLIER_DISPATCH instead. +* All functions fetch_all() are deprecated for naming consitency, use fetchAll() instead @@ -79,7 +80,7 @@ NEW: Create contract from invoice NEW: Database: Can store the session into database (instead of beeing managed by PHP) NEW: Database: Some core tables are created only at module activation NEW: Default value for MAIN_SECURITY_CSRF_WITH_TOKEN is now 2 (GET are also protected agains CSRF attacks) -NEW: deposit payment terms: add field into dictionary admin page to define default percentage of deposit. +NEW: deposit payment terms: add field into dictionary admin page to define default percentage of deposit. NEW: Dictionaries - add possibility to manage countries in EEC NEW: Dictionaries - Availibility dictionnary has a new column unit and number NEW: Display errors in a message box after generating documents @@ -187,9 +188,9 @@ NEW: Can update rank of invoice, proposal and order lines with API update NEW: update rank line is possible on API for customer invoices, sales orders and supplier invoice NEW: Add option MAIN_API_DEBUG to save API logs into a file -Hooks: +Hooks: NEW: Hook getNomUrl available everywhere in tooltip of ref links -NEW: Add hooks: selectContactListWhere hook, selectThirdpartyListWhere hook +NEW: Add hooks: selectContactListWhere hook, selectThirdpartyListWhere hook NEW: Add hook before the public ticket list NEW: Add hook for Notif NEW: Add hook for more buttons @@ -221,12 +222,12 @@ NEW: Option INVOICEREC_SET_AUTOFILL_DATE_START/END WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: -* There is a new specific permission to be allowed to enter timesheets. If you use timesheet, don't forget to give the new permission (disable and +* There is a new specific permission to be allowed to enter timesheets. If you use timesheet, don't forget to give the new permission (disable and enable the module project if it is not visible). * The default value for MAIN_SECURITY_CSRF_WITH_TOKEN has been set to 2. It means any POST and any GET request that contains the "action" or "massaction" with a value of a sensitive action must also a valid token parameter (With previous value 1, only POST was concerned). Note: With value 3, any URL with parameter "action" or "massaction" need the token, whatever is the value of the action. -* verifCond('stringtoevaluate') now return false when string contains a bad syntax content instead of true. +* verifCond('stringtoevaluate') now return false when string contains a bad syntax content instead of true. * The deprecated method thirdparty_doc_create() has been removed. You can use the generateDocument() instead. * All triggers with a name XXX_UPDATE have been renamed with name XXX_MODIFY for code consistency purpose. * Rename build_path_from_id_categ() into buildPathFromId() and set method to private. @@ -442,7 +443,7 @@ For users: NEW: Online proposal signature NEW: Can define some max limit on expense report (per period, per type or expense, ...) -NEW: Provide a special pages for bookmarks and multicompany for a better use of some mobile applications (like DoliDroid) +NEW: Provide a special pages for bookmarks and multicompany for a better use of some mobile applications (like DoliDroid) NEW: Allow the use of __NEWREF__ to get for example the new reference a draft order will get after validation. NEW: Add option to disable globaly some notifications emails. NEW: #18401 Add __NEWREF__ subtitute to get new object reference. @@ -491,7 +492,7 @@ NEW: can enable/disable external calendar by default NEW: Can hide sender name on PDF documents NEW: Can select lot from a combo list of existing batch numbers (in MRP consumtion) NEW: Can set the default BOM on a product -NEW: Can set/unset the usual working day of the week (friday, saturday, sunday) +NEW: Can set/unset the usual working day of the week (friday, saturday, sunday) NEW: Can show progression of task into combo list of tasks NEW: can upload the odt file for the product doc template NEW: Contract - Add From/to input on search date @@ -555,7 +556,7 @@ For developers: API: NEW: #18319 REST API - Shipment: Add 'close' action / endpoint / POST method. -NEW: add API /approve and /makeOrder for purchase orders +NEW: add API /approve and /makeOrder for purchase orders NEW: API for knowledgemanagement NEW: API get list of legal form of business NEW: API list of staff units @@ -592,21 +593,21 @@ NEW: Experimental feature to manage user sessions in database WARNING: - + Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: -* ALL EXTERNAL MODULES THAT WERE NOT CORRECTLY DEVELOPPED WILL NOT WORK ON V15 (All modules that forgot to manage the security token field +* ALL EXTERNAL MODULES THAT WERE NOT CORRECTLY DEVELOPPED WILL NOT WORK ON V15 (All modules that forgot to manage the security token field into forms will be broken. The security token field is expected since Dolibarr v9 but a lot of external modules did not implement it). * Update hook 'printOriginObjectLine', removed check on product type and special code. Need now reshook. * Old deprecated module "SimplePOS" has been completely removed. Use module "TakePOS" is you need a Point Of Sale. -* The method static ActionComm::getActions($db, ...) is no more static. Use $actioncomm->getActions(...) instead (without $db param). +* The method static ActionComm::getActions($db, ...) is no more static. Use $actioncomm->getActions(...) instead (without $db param). * The 'action=delete&file=...' has been replaced with 'action=deletefile&file=...' to avoid confusion with deletion of object lines. * Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. -* To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in - method executeCLI() available into core/class/utils.class.php +* To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in + method executeCLI() available into core/class/utils.class.php * Class file expeditionbatch.class.php renamed to expeditionlinebatch.class.php * ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed * ExtraFields->showOutputField parameter 4 'extrafieldsobjectkey' is now required -* CommonObject method add_object_linked now sets targettype to 'mymodule_myobject' instead of 'myobject', +* CommonObject method add_object_linked now sets targettype to 'mymodule_myobject' instead of 'myobject', you can use hook 'setLinkedObjectSourceTargetType' to set your usual targettype @@ -895,10 +896,10 @@ For users: ---------- NEW: Module Recruitment to follow application to job positions is now stable. NEW: Feature to make Stock Inventories -NEW: Several security issues after a second private bug hunting campaign. +NEW: Several security issues after a second private bug hunting campaign. NEW: A lot of fix into english text after a small proofreading campaign (still not perfect, but really better) NEW: All main menu entries are using the picto of the module -NEW: Add a copy to clipboard button on some fields +NEW: Add a copy to clipboard button on some fields NEW: Add an example of scheduled job to send email reminder for unpaid invoices NEW: Add some color and picto for the direction of movement NEW: add the column "Channel" into the list of orders @@ -969,7 +970,7 @@ NEW: can show the leave dates/holidays on the agenda view NEW: Support color for types of event Bank -NEW: Bank Entries : display user linked to a salary or a taxes +NEW: Bank Entries : display user linked to a salary or a taxes NEW: Add bulk actions for Bank Transfer ECM/GED @@ -992,7 +993,7 @@ NEW: option to automatically create a login/user when a new subscription of a me NEW: option to select membership type on the online payment page for membership subscription or renewal Products -NEW: Add price min and price min including tax into product export +NEW: Add price min and price min including tax into product export NEW: Add a ref in product customer price NEW: customer ref for product customer prices NEW: Set status of all variants when changing status of parent @@ -1045,8 +1046,8 @@ NEW: add option in Workflow module to set a shipment as closed for Admins -NEW: Add a security center page with all information and advices related to the security of your instance -NEW: Add a performance center page with all information and advices related to the performance of your instance +NEW: Add a security center page with all information and advices related to the security of your instance +NEW: Add a performance center page with all information and advices related to the performance of your instance Modules NEW: Module Recruitment is now stable @@ -1092,7 +1093,7 @@ NEW: API get the list of product ids only NEW: add link to OpenAPI specifications XML file in REST API module setup: swagger.json file can be included into external tools like redoc NEW: add native compression in REST APIs NEW: Product Variants API, add variant stock to response by parameter -NEW: Product API route added to get product stock and product with or without variants #13739 #17390 +NEW: Product API route added to get product stock and product with or without variants #13739 #17390 Hooks NEW: hook printFieldListTitle for cabyprodserv.php @@ -1117,8 +1118,8 @@ Following changes may create regressions for some external modules, but were nec * Removed deprecated substitution key __REFCLIENT__ (replaced with __REF_CLIENT__) * Removed constant MAIN_COUNTRIES_IN_EEC. You can now set if country is in Europe or not from the dictionary of countries. * v14 seems to work correctly on PHP v8 but it generates a lot of verbose warnings. Currently, v14 i snot yet officialy supported with PHP 8. -* To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in - method executeCLI() available into core/class/utils.class.php +* To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in + method executeCLI() available into core/class/utils.class.php ***** ChangeLog for 13.0.5 compared to 13.0.4 ***** @@ -1345,7 +1346,7 @@ NEW: Module "Credit transfer SEPA" to manage payment of vendors using bank credi NEW: Module Intracomm report NEW: Module Reception (for a more accurate management of your receptions) moved from experimental to stable. NEW: Module Recruitment to manage Job position and applications. -NEW: Several security issues after a private bug bounty campaign. +NEW: Several security issues after a private bug bounty campaign. NEW: Accountancy - add chart of sub accounts NEW: Accountancy - add options to disable binding on sales, purchases & expense reports independently of the modules NEW: Accountancy balance - add a menu entry to show subtotal by group @@ -1481,7 +1482,7 @@ NEW: show user on external calender events (when found) NEW: subject title with company name instead of application title in ticket message NEW: Support for Samba4 AD NEW: TakePOS appearance tab with more visual parameters -NEW: TakePOS add alert before changing thirdparty +NEW: TakePOS add alert before changing thirdparty NEW: TakePOS add third order printer NEW: TakePOS can change thirdparty with barcode scan NEW: TakePOS can create a thirdparty customer from TakePOS frontend @@ -1492,9 +1493,9 @@ NEW: TakePOS display resiliate status for members NEW: TakePOS Gift Receipt NEW: TakePOS multicurrency compatibility NEW: TakePOS multicurrency total -NEW: TakePOS print payment method and change +NEW: TakePOS print payment method and change NEW: TakePOS restrict thirdparty to customer -NEW: TakePOS show available stock +NEW: TakePOS show available stock NEW: TakePOS Weighing Scale compatibility with TakePOS connector #14725 NEW: Thirdparty Import new fields: mother company,outstanding debt limit,bank account,incoterms NEW: Thirdparty module : box on customer/supplier tab for invoice outsantding amount late @@ -1507,8 +1508,8 @@ NEW: VAT report - Invert constant to show by default zero VAT in reports NEW: website page fields selection NEW: website - global header of a website can also have dynamic content NEW: when creating a user from a member linked to a thirdparty, you can choose to create it as external or internal user -NEW: add clone button on miscellaneous payment -NEW: add option to put the product label in bold in the PDF templates if configured #15065 +NEW: add clone button on miscellaneous payment +NEW: add option to put the product label in bold in the PDF templates if configured #15065 NEW: add option "If the feature to manage kits of module Stock is used, show details of subproducts of a kit on PDF." diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 301a3def70e..27226d388f6 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -53,7 +53,7 @@ $langs->loadLangs(array("admin", "compta")); if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->fiscalyear->write)) { // If we can read accounting records, we should be able to see fiscal year. +if (!$user->hasRight('accounting', 'fiscalyear', 'write')) { // If we can read accounting records, we should be able to see fiscal year. accessforbidden(); } diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index d798b6baa5f..89ed7b538ba 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -35,7 +35,7 @@ $langs->loadLangs(array("admin", "compta")); if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->fiscalyear->write)) { +if (!$user->hasRight('accounting', 'fiscalyear', 'write')) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index 1cc6fcba958..bb265c89ecf 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -34,7 +34,7 @@ $langs->loadLangs(array("admin", "compta")); if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->fiscalyear->write)) { +if (!$user->hasRight('accounting', 'fiscalyear', 'write')) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 9f86922aa5c..018a0cfd5e8 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -45,7 +45,7 @@ $langs->loadLangs(array("companies", "compta", "accountancy", "products")); if (!isModEnabled('accounting')) { accessforbidden(); } -if (empty($user->rights->accounting->bind->write)) { +if (!$user->hasRight('accounting', 'bind', 'write')) { accessforbidden(); } diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index cb479a1dc59..d2b1aaa3348 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -150,7 +150,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index e120606b927..692d70f4b68 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -86,7 +86,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 168d8f3ac16..1520897c4f7 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -155,7 +155,7 @@ $hookmanager->initHooks(array('bookkeepinglist')); $formaccounting = new FormAccounting($db); $form = new Form($db); -if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) { +if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->hasRight('accounting', 'mouvements', 'export')) { if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) { $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; @@ -221,7 +221,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -434,7 +434,7 @@ if (empty($reshook)) { $param .= '&search_import_key='.urlencode($search_import_key); } - //if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { + //if ($action == 'delbookkeepingyearconfirm' && !$user->hasRight('accounting', 'mouvements', 'supprimer_tous')) { // $delmonth = GETPOST('delmonth', 'int'); // $delyear = GETPOST('delyear', 'int'); // if ($delyear == -1) { @@ -486,7 +486,7 @@ if (empty($reshook)) { $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - if (!$error && $action == 'deletebookkeepingwritingauto' && $confirm == "yes" && $user->rights->accounting->mouvements->supprimer) { + if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) { $db->begin(); if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { @@ -539,7 +539,7 @@ if (empty($reshook)) { } // others mass actions - if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { + if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) { if ($massaction == 'letteringauto') { $lettering = new Lettering($db); $nb_lettering = $lettering->bookkeepingLetteringAll($toselect); @@ -689,7 +689,7 @@ if (!empty($sortfield)) { // Export into a file with format defined into setup (FEC, CSV, ...) // Must be after definition of $sql -if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->export) { +if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements', 'export')) { // TODO Replace the fetchAll to get all ->line followed by call to ->export(). It consumes too much memory on large export. // Replace this with the query($sql) and loop on each line to export them. $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', (empty($conf->global->ACCOUNTING_REEXPORT) ? 0 : 1)); @@ -889,7 +889,7 @@ if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting- $arrayofmassactions['letteringmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringManual'); $arrayofmassactions['preunletteringmanual'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringManual'); } -if ($user->rights->accounting->mouvements->supprimer) { +if ($user->hasRight('accounting', 'mouvements', 'supprimer')) { $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunletteringauto', 'preunletteringmanual', 'predeletebookkeepingwriting'))) { @@ -925,8 +925,8 @@ if (empty($reshook)) { } $newcardbutton .= ''.$langs->trans("IncludeDocsAlreadyExported").''; - if (!empty($user->rights->accounting->mouvements->export)) { - $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file&token='.newToken().($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); + if ($user->hasRight('accounting', 'mouvements', 'export')) { + $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file&token='.newToken().($param ? '&'.$param : ''), $user->hasRight('accounting', 'mouvements', 'export')); } $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); @@ -937,7 +937,7 @@ if (empty($reshook)) { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->hasRight('accounting', 'mouvements', 'creer')); } print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index b171f6c2c3a..c4b27dce418 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -194,7 +194,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -401,7 +401,7 @@ if (empty($reshook)) { $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->rights->accounting->mouvements->supprimer) { + if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) { $db->begin(); if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { @@ -454,7 +454,7 @@ if (empty($reshook)) { } // others mass actions - if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { + if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) { if ($massaction == 'letteringauto') { $lettering = new Lettering($db); $nb_lettering = $lettering->bookkeepingLetteringAll($toselect); @@ -616,13 +616,13 @@ print $formconfirm; // List of mass actions available $arrayofmassactions = array(); -if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { +if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) { $arrayofmassactions['letteringauto'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringAuto'); $arrayofmassactions['preunletteringauto'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringAuto'); $arrayofmassactions['letteringmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringManual'); $arrayofmassactions['preunletteringmanual'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringManual'); } -if ($user->rights->accounting->mouvements->supprimer) { +if ($user->hasRight('accounting', 'mouvements', 'supprimer')) { $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunletteringauto', 'preunletteringmanual', 'predeletebookkeepingwriting'))) { diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 9720399fb5e..3134dfa95ba 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -441,26 +441,40 @@ class AccountingJournal extends CommonObject $langs->loadLangs(array("assets")); // Clean parameters - if (empty($type)) $type = 'view'; - if (empty($in_bookkeeping)) $in_bookkeeping = 'notyet'; + if (empty($type)) { + $type = 'view'; + } + if (empty($in_bookkeeping)) { + $in_bookkeeping = 'notyet'; + } $sql = ""; - if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { + + // FIXME sql error with Mysql 5.7 + /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { $sql .= "WITH in_accounting_bookkeeping(fk_docdet) AS ("; $sql .= " SELECT DISTINCT fk_docdet"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " WHERE doc_type = 'asset'"; $sql .= ")"; - } + }*/ + $sql .= "SELECT ad.fk_asset AS rowid, a.ref AS asset_ref, a.label AS asset_label, a.acquisition_value_ht AS asset_acquisition_value_ht"; $sql .= ", a.disposal_date AS asset_disposal_date, a.disposal_amount_ht AS asset_disposal_amount_ht, a.disposal_subject_to_vat AS asset_disposal_subject_to_vat"; $sql .= ", ad.rowid AS depreciation_id, ad.depreciation_mode, ad.ref AS depreciation_ref, ad.depreciation_date, ad.depreciation_ht, ad.accountancy_code_debit, ad.accountancy_code_credit"; $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation as ad"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "asset as a ON a.rowid = ad.fk_asset"; - if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { + // FIXME sql error with Mysql 5.7 + /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { $sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid"; - } + }*/ $sql .= " WHERE a.entity IN (" . getEntity('asset', 0) . ')'; // We don't share object for accountancy, we use source object sharing + // Compatibility with Mysql 5.7 + if ($in_bookkeeping == 'already') { + $sql .= " AND EXISTS (SELECT iab.fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS iab WHERE iab.fk_docdet = ad.rowid AND doc_type = 'asset')"; + } elseif ($in_bookkeeping == 'notyet') { + $sql .= " AND NOT EXISTS (SELECT iab.fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS iab WHERE iab.fk_docdet = ad.rowid AND doc_type = 'asset')"; + } $sql .= " AND ad.ref != ''"; // not reversal lines if ($date_start && $date_end) { $sql .= " AND ad.depreciation_date >= '" . $this->db->idate($date_start) . "' AND ad.depreciation_date <= '" . $this->db->idate($date_end) . "'"; @@ -470,9 +484,10 @@ class AccountingJournal extends CommonObject $sql .= " AND ad.depreciation_date >= '" . $this->db->idate($conf->global->ACCOUNTING_DATE_START_BINDING) . "'"; } // Already in bookkeeping or not - if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { + // FIXME sql error with Mysql 5.7 + /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { $sql .= " AND iab.fk_docdet IS" . ($in_bookkeeping == 'already' ? " NOT" : "") . " NULL"; - } + }*/ $sql .= " ORDER BY ad.depreciation_date"; dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index da4f5eecd25..c1dc454b675 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -64,7 +64,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->fiscalyear->write)) { +if (!$user->hasRight('accounting', 'fiscalyear', 'write')) { accessforbidden(); } diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 0b3435ecb92..e867070ed2d 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -44,7 +44,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -54,7 +54,7 @@ if (empty($user->rights->accounting->mouvements->lire)) { * Actions */ -if ($action == 'ventil' && $user->rights->accounting->bind->write) { +if ($action == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) { if (!$cancel) { if ($codeventil < 0) { $codeventil = 0; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 472dce11e37..079e05c406b 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -47,7 +47,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->bind->write)) { +if (!$user->hasRight('accounting', 'bind', 'write')) { accessforbidden(); } @@ -84,7 +84,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -93,7 +93,7 @@ if (empty($user->rights->accounting->mouvements->lire)) { * Actions */ -if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accounting->bind->write) { +if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('accounting', 'bind', 'write')) { // Clean database by removing binding done on non existing or no more existing accounts $db->begin(); $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 469f29ad3c7..65d7ee0bbeb 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -91,7 +91,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -126,7 +126,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_tvaintra = ''; } -if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->accounting->bind->write) { +if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) { $error = 0; if (!(GETPOST('account_parent', 'int') >= 0)) { diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 4038bb4b5bc..9dfd94d5729 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -110,7 +110,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 926d03f9235..aef45ae3ce1 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -417,7 +417,7 @@ if ($result) { print '
| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' | |||||||||
| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' | |||||||||
| ';
print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly"));
@@ -191,7 +214,7 @@ if ($action == 'edit') {
print '';
print ' ';
- print ''.$langs->trans("Modify").'';
+ print ''.$langs->trans("Modify").'';
print ' ';
}
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index 02eef8a00d3..1b5f8353f12 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -56,7 +56,7 @@ if (isModEnabled('eventorganization')) {
$langs->loadLangs($langsArray);
$toselect = GETPOST('toselect', 'array');
-$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
+$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view';
$massaction = GETPOST('massaction', 'alpha');
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
$mode = GETPOST('mode', 'aZ09');
@@ -350,7 +350,7 @@ if (empty($reshook)) {
}
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
- $action = 'add';
+ $action = 'create';
}
}
@@ -424,7 +424,7 @@ if (empty($reshook)) {
} else {
dol_print_error($db);
}
- $action = 'add';
+ $action = 'create';
}
}
@@ -654,7 +654,7 @@ $linkback = '';
$titlepicto = 'title_setup';
-$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=add&token='.newToken();
+$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=create';
$newcardbutton = dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
@@ -685,10 +685,11 @@ if ($action == 'delete') {
$fieldlist = explode(',', $tabfield[$id]);
-if ($action == 'add') {
+if ($action == 'create') {
// Form to add a new line
print ' | ';
@@ -917,7 +916,7 @@ foreach ($fieldlist as $field => $value) {
print '';
} elseif ($value == 'fk_user') {
print ''; - print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth150'); + print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth150', 1); print ' | '; } elseif ($value == 'topic') { print ''; @@ -1024,7 +1023,7 @@ if ($num) { $reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; $errors = $hookmanager->errors; - // Show fields + // Show main fields if (empty($reshook)) { fieldList($fieldlist, $obj, $tabname[$id], 'edit'); } @@ -1045,7 +1044,7 @@ if ($num) { foreach ($fieldsforcontent as $tmpfieldlist) { $showfield = 1; $align = "left"; - $valuetoshow = $obj->{$tmpfieldlist}; + $valuetoshow = $obj->$tmpfieldlist; $class = 'tddict'; // Show value for field @@ -1059,7 +1058,7 @@ if ($num) { } if ($tmpfieldlist == 'joinfiles') { print ''.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; - print ''; + print $form->selectyesno($tmpfieldlist.'-'.$rowid, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, false, 0, 1); } // If $acceptlocallinktomedia is true, we can add link media files int email templates (we already can do this into HTML editor of an email). @@ -1204,7 +1203,7 @@ if ($num) { if ($value == 'joinfiles') { $align = "center"; if ($valuetoshow) { - $valuetoshow = 1; + $valuetoshow = yn(1); } else { $valuetoshow = ''; } @@ -1311,7 +1310,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if ($value == 'fk_user') { print ' | '; if ($user->admin) { - print $form->select_dolusers(empty($obj->{$value}) ? '' : $obj->{$value}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth150 maxwidth300'); + print $form->select_dolusers(empty($obj->{$value}) ? '' : $obj->{$value}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth150 maxwidth200'); } else { if ($context == 'add') { // I am not admin and we show the add form print $user->getNomUrl(1); // Me @@ -1335,29 +1334,29 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if (getDolGlobalInt('MAIN_MULTILANGS')) { $selectedlang = GETPOSTISSET('langcode') ?GETPOST('langcode', 'aZ09') : $langs->defaultlang; if ($context == 'edit') { - $selectedlang = $obj->{$value}; + $selectedlang = $obj->lang; } print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150'); } else { - if (!empty($obj->{$value})) { - print $obj->{$value}.' - '.$langs->trans('Language_'.$obj->{$value}); + if (!empty($obj->lang)) { + print $obj->lang.' - '.$langs->trans('Language_'.$obj->lang); } $keyname = $value; if ($keyname == 'lang') { $keyname = 'langcode'; // Avoid conflict with lang param } - print ''; + print ''; } print ' | '; } elseif ($value == 'type_template') { // Le type de template print ''; - if ($context == 'edit' && !empty($obj->{$value}) && !in_array($obj->{$value}, array_keys($elementList))) { + if ($context == 'edit' && !empty($obj->type_template) && !in_array($obj->type_template, array_keys($elementList))) { // Current template type is an unknown type, so we must keep it as it is. - print ''; - print $obj->{$value}; + print ''; + print $obj->type_template; } else { - print $form->selectarray('type_template', $elementList, (!empty($obj->{$value}) ? $obj->{$value}:''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1); + print $form->selectarray('type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template:''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1); } print ' | '; } elseif ($context == 'add' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { @@ -1378,7 +1377,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $class = 'maxwidth50'; $classtd = 'center'; } if ($value == 'position') { - $class = 'maxwidth50'; $classtd = 'center'; + $class = 'maxwidth50 center'; $classtd = 'center'; } if ($value == 'libelle') { $class = 'quatrevingtpercent'; @@ -1395,7 +1394,6 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if (empty($user->admin)) { print $form->selectyesno($value, '1', 1); } else { - //print ''; print $form->selectyesno($value, (isset($obj->{$value}) ? $obj->{$value}:''), 1); } } else { diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index e50b4f772c6..014d3844368 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -85,7 +85,11 @@ if ($action == 'update') { } } if (GETPOSTISSET($constvalue.'_SCOPE')) { - $scopestring = implode(',', GETPOST($constvalue.'_SCOPE')); + if (is_array(GETPOST($constvalue.'_SCOPE'))) { + $scopestring = implode(',', GETPOST($constvalue.'_SCOPE')); + } else { + $scopestring = GETPOST($constvalue.'_SCOPE'); + } if (!dolibarr_set_const($db, $constvalue.'_SCOPE', $scopestring, 'chaine', 0, '', $conf->entity)) { $error++; } @@ -97,6 +101,7 @@ if ($action == 'update') { } } + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null); } else { @@ -104,6 +109,48 @@ if ($action == 'update') { } } +if ($action == 'confirm_delete') { + $provider = GETPOST('provider', 'aZ09'); + $label = GETPOST('label'); + + $globalkey = empty($provider) ? $label : $label.'-'.$provider; + + if (getDolGlobalString($globalkey.'_ID') && getDolGlobalString($globalkey.'_SECRET')) { // If ID and secret exist, we delete first the token + $backtourl = DOL_URL_ROOT.'/admin/oauth.php?action=delete_entry&provider='.$provider.'&label='.$label.'&token='.newToken(); + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; + $callbacktodel = $urlwithroot; + if ($label == 'OAUTH_GOOGLE') { + $callbacktodel .= '/core/modules/oauth/google_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); + } elseif ($label == 'OAUTH_GITHUB') { + $callbacktodel .= '/core/modules/oauth/github_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); + } elseif ($label == 'OAUTH_STRIPE_LIVE') { + $callbacktodel .= '/core/modules/oauth/stripelive_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); + } elseif ($label == 'OAUTH_STRIPE_TEST') { + $callbacktodel .= '/core/modules/oauth/stripetest_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); + } elseif ($label == 'OAUTH_OTHER') { + $callbacktodel .= '/core/modules/oauth/generic_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); + } + header("Location: ".$callbacktodel); + exit; + } else { + $action = 'delete_entry'; + } +} + +if ($action == 'delete_entry') { + $provider = GETPOST('provider', 'aZ09'); + $label = GETPOST('label'); + + $globalkey = empty($provider) ? $label : $label.'-'.$provider; + + if (!dolibarr_del_const($db, $globalkey.'_NAME', $conf->entity) || !dolibarr_del_const($db, $globalkey.'_ID', $conf->entity) || !dolibarr_del_const($db, $globalkey.'_SECRET', $conf->entity) || !dolibarr_del_const($db, $globalkey.'_URLAUTHORIZE', $conf->entity) || !dolibarr_del_const($db, $globalkey.'_SCOPE', $conf->entity)) { + setEventMessages($langs->trans("ErrorInEntryDeletion"), null, 'errors'); + $error++; + } else { + setEventMessages($langs->trans("EntryDeleted"), null); + } +} /* * View @@ -112,6 +159,13 @@ if ($action == 'update') { llxHeader(); $form = new Form($db); +// Confirmation of action process +if ($action == 'delete') { + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?provider='.GETPOST('provider').'&label='.GETPOST('label'), $langs->trans('OAuthServiceConfirmDeleteTitle'), $langs->trans('OAuthServiceConfirmDeleteMessage'), 'confirm_delete', $formquestion, 0, 1, 220); + print $formconfirm; +} + $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); @@ -227,6 +281,18 @@ if (count($listinsetup) > 0) { print $langs->trans("OAUTH_URL_FOR_CREDENTIAL", $supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials']); } print ''; + + print ''; + + $label = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array); + + print ''; + print img_picto('', 'delete'); + print ''; + + print ''; + print ' | '; + print '|||||
| '.$langs->trans("Scopes").' | '; + print ''; + $currentscopes = getDolGlobalString($key[4]); + print $currentscopes; + print ' | |||||||||
| '; //var_dump($key); diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index fcca4cf2f18..8aaf76d310b 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -445,7 +445,7 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) - || !empty($conf->mrp->enabled)) { + || isModEnabled('mrp')) { $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index b5114314eef..d2fa38c9469 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -388,7 +388,7 @@ foreach ($dirmodels as $reldir) { if (in_array($name, $def)) { print ' | '."\n"; if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") { - print 'scandir).'&label='.urlencode($module->name).'&type=order_supplier">'; + print 'scandir).'&label='.urlencode($module->name).'&type=order_supplier">'; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; } else { @@ -397,17 +397,16 @@ foreach ($dirmodels as $reldir) { print " | "; } else { print ''."\n"; - print 'scandir).'&label='.urlencode($module->name).'&type=order_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir).'&label='.urlencode($module->name).'&type=order_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print " | "; } // Default print ''; if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") { - // print img_picto($langs->trans("Default"), 'on'); - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; + print 'scandir).'&label='.urlencode($module->name).'&type=order_supplier" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; } else { - print 'scandir).'&label='.urlencode($module->name).'&type=order_supplier" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + print 'scandir).'&label='.urlencode($module->name).'&type=order_supplier" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; } print ' | '; @@ -425,7 +424,7 @@ foreach ($dirmodels as $reldir) { print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; print ''; - print ''.img_object($langs->trans("Preview"), 'pdf').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; print ' | '; print "||||||
| '; print ' | '; @@ -2655,7 +2655,7 @@ if ($action == 'create') { } // Incoterms - if (!empty($conf->incoterm->enabled)) { + if (isModEnabled('incoterm')) { print ' | |||||||||
';
print '
| ';
}
+ // Parent company
+ if (!empty($arrayfields['s2.nom']['checked'])) {
+ print ''; + print ''; + print ' | '; + } // Town if (!empty($arrayfields['s.town']['checked'])) { print ''; @@ -1707,6 +1726,9 @@ if ($resql) { if (!empty($arrayfields['s.name_alias']['checked'])) { print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['s2.nom']['checked'])) { + print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER['PHP_SELF'], 's2.nom', '', $param, '', $sortfield, $sortorder, 'center '); + } if (!empty($arrayfields['s.town']['checked'])) { print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); } @@ -1850,7 +1872,7 @@ if ($resql) { $i = 0; $with_margin_info = false; - if (!empty($conf->margin->enabled) && ( + if (isModEnabled('margin') && ( !empty($arrayfields['total_pa']['checked']) || !empty($arrayfields['total_margin']['checked']) || !empty($arrayfields['total_margin_rate']['checked']) @@ -2008,6 +2030,27 @@ if ($resql) { } } + // Parent company + if (!empty($arrayfields['s2.nom']['checked'])) { + print ' | '; + if ($obj->fk_parent > 0) { + if (!isset($company_url_list[$obj->fk_parent])) { + $companyparent = new Societe($db); + $res = $companyparent->fetch($obj->fk_parent); + if ($res > 0) { + $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1); + } + } + if (isset($company_url_list[$obj->fk_parent])) { + print $company_url_list[$obj->fk_parent]; + } + } + print " | "; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town if (!empty($arrayfields['s.town']['checked'])) { print '';
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 072aa9e67b2..8edcb68b2b7 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -1385,6 +1385,7 @@ if (empty($reshook)) {
$object->note_public = trim(GETPOST('note_public', 'restricthtml'));
$object->note_private = trim(GETPOST('note_private', 'restricthtml'));
$object->ref_client = GETPOST('ref_client');
+ $object->ref_customer = GETPOST('ref_client');
$object->model_pdf = GETPOST('model');
$object->fk_project = GETPOST('projectid', 'int');
$object->cond_reglement_id = (GETPOST('type') == 3 ? 1 : GETPOST('cond_reglement_id'));
@@ -5460,7 +5461,6 @@ if ($action == 'create') {
if (empty($reshook)) {
$params = array(
'attr' => array(
- 'title' => '',
'class' => 'classfortooltip'
)
);
@@ -5535,9 +5535,9 @@ if ($action == 'create') {
print ''.$langs->trans('SendMail').'';
} else {
if ($usercansend) {
- print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', true, $params);
+ print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', true, $params);
} else {
- print dolGetButtonAction($langs->trans('SendMail'), '', 'default', '#', '', false, $params);
+ print dolGetButtonAction('', $langs->trans('SendMail'), 'default', '#', '', false, $params);
}
}
}
@@ -5802,7 +5802,7 @@ if ($action == 'create') {
// Show online payment link
- $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
+ $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox'));
if ($object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
print ' '."\n"; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index ddfe7e5429f..1d6dbd9f03b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -245,10 +245,10 @@ $arrayfields = array( 'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled('multicurrency') ? 0 : 1), 'position'=>292), 'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(!isModEnabled('multicurrency') ? 0 : 1), 'position'=>295), 'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(!isModEnabled('multicurrency') ? 0 : 1), 'position'=>296), // Not enabled by default because slow - 'total_pa' => array('label' => ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)), - 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)), - 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), - 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), + 'total_pa' => array('label' => ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || empty($user->rights->margins->liretous) ? 0 : 1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || empty($user->rights->margins->liretous) ? 0 : 1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), + 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>502), 'f.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))), diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index a1dcdba6f58..f6b31386215 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -22,9 +22,9 @@ */ /** - * \file htdocs/compta/prelevement/class/bonprelevement.class.php - * \ingroup prelevement - * \brief File of withdrawal receipts class + * \file htdocs/compta/prelevement/class/bonprelevement.class.php + * \ingroup prelevement + * \brief File of withdrawal receipts class */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; @@ -419,8 +419,8 @@ class BonPrelevement extends CommonObject } else { $paiement = new Paiement($this->db); } - $paiement->datepaye = $date; - $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice + $paiement->datepaye = $date; + $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice if ($this->type == 'bank-transfer') { $paiement->paiementid = 2; @@ -757,14 +757,14 @@ class BonPrelevement extends CommonObject $error = 0; - $datetimeprev = time(); + $datetimeprev = dol_now('gmt'); //Choice the date of the execution direct debit if (!empty($executiondate)) { $datetimeprev = $executiondate; } - $month = strftime("%m", $datetimeprev); - $year = strftime("%Y", $datetimeprev); + $month = dol_print_date($datetimeprev, "%m", 'gmt'); + $year = dol_print_date($datetimeprev, "%Y", 'gmt'); $this->invoice_in_error = array(); $this->thirdparty_in_error = array(); @@ -1709,7 +1709,7 @@ class BonPrelevement extends CommonObject { global $langs; $pre = substr(dol_string_nospecial(dol_string_unaccent($langs->transnoentitiesnoconv('RUM'))), 0, 3); // Must always be on 3 char ('RUM' or 'UMR'. This is a protection against bad translation) - return $pre.'-'.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); + return $pre.($row_code_client ? '-'.$row_code_client : '').'-'.$row_drum.'-'.date('U', $row_datec); } @@ -1743,8 +1743,8 @@ class BonPrelevement extends CommonObject // Date d'echeance C1 fputs($this->file, " "); - fputs($this->file, strftime("%d%m", $this->date_echeance)); - fputs($this->file, substr(strftime("%y", $this->date_echeance), 1)); + fputs($this->file, dol_print_date($this->date_echeance, "%d%m", 'gmt')); + fputs($this->file, substr(dol_print_date($this->date_echeance, "%y", 'gmt'), 1)); // Raison Sociale Destinataire C2 @@ -1823,8 +1823,8 @@ class BonPrelevement extends CommonObject $Rowing = sprintf("%010d", $row_idfac); // Define value for RUM - // Example: RUMCustomerCode-CustomerBankAccountId-01424448606 (note: Date is date of creation of CustomerBankAccountId) - $Rum = empty($row_rum) ? $this->buildRumNumber($row_code_client, $row_datec, $row_drum) : $row_rum; + // Example: RUM-CustomerCode-CustomerBankAccountId-01424448606 (note: Date is the timestamp of the date of creation of CustomerBankAccountId) + $Rum = (empty($row_rum) ? $this->buildRumNumber($row_code_client, $row_datec, $row_drum) : $row_rum); // Define date of RUM signature $DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d'); @@ -1969,8 +1969,8 @@ class BonPrelevement extends CommonObject // Date d'echeance C1 fputs($this->file, " "); - fputs($this->file, strftime("%d%m", $this->date_echeance)); - fputs($this->file, substr(strftime("%y", $this->date_echeance), 1)); + fputs($this->file, dol_print_date($this->date_echeance, "%d%m", 'gmt')); + fputs($this->file, substr(dol_print_date($this->date_echeance, "%y", 'gmt'), 1)); // Raison Sociale C2 diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 638022b855a..d535da76199 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1228,6 +1228,15 @@ class Contact extends CommonObject $this->db->begin(); + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('CONTACT_DELETE', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + if (!$error) { // Get all rowid of element_contact linked to a type that is link to llx_socpeople $sql = "SELECT ec.rowid"; @@ -1318,15 +1327,6 @@ class Contact extends CommonObject } } - if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CONTACT_DELETE', $user); - if ($result < 0) { - $error++; - } - // End call triggers - } - if (!$error) { $this->db->commit(); return 1; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 3509134c70f..93d33565143 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -498,7 +498,7 @@ if (empty($reshook)) { $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + $result = $prodcustprice->fetchAll('', '', 0, 0, $filter); if ($result) { if (count($prodcustprice->lines) > 0) { $pu_ht = price($prodcustprice->lines[0]->price); @@ -1476,7 +1476,7 @@ if ($action == 'create') { $productstatic = new Product($db); $usemargins = 0; - if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'propal', 'commande'))) { + if (isModEnabled('margin') && !empty($object->element) && in_array($object->element, array('facture', 'propal', 'commande'))) { $usemargins = 1; } @@ -1522,7 +1522,7 @@ if ($action == 'create') { print ' | '.$langs->trans("Unit").' | '; } print ''.$langs->trans("ReductionShort").' | '; - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { print ''.$langs->trans("BuyingPrice").' | '; } print ''; @@ -1592,7 +1592,7 @@ if ($action == 'create') { } // Margin - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { print ' | '.price($objp->pa_ht).' | '; } @@ -1749,7 +1749,7 @@ if ($action == 'create') { print '|