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 ''.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).''; // Accounting account affected - print ''; + print ''; print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); print ' '; print img_edit(); diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php index b56271850e5..8f6297e480a 100644 --- a/htdocs/accountancy/journal/variousjournal.php +++ b/htdocs/accountancy/journal/variousjournal.php @@ -290,19 +290,21 @@ print '' . $langs->trans("Debit") . ''; print '' . $langs->trans("Credit") . ''; print "\n"; -foreach ($journal_data as $element_id => $element) { - foreach ($element['blocks'] as $lines) { - foreach ($lines as $line) { - print ''; - print '' . $line['date'] . ''; - print '' . $line['piece'] . ''; - print '' . $line['account_accounting'] . ''; - print '' . $line['subledger_account'] . ''; - print '' . $line['label_operation'] . ''; - if ($object->nature == 4) print '' . $line['payment_mode'] . ''; - print '' . $line['debit'] . ''; - print '' . $line['credit'] . ''; - print ''; +if (is_array($journal_data) && !empty($journal_data)) { + foreach ($journal_data as $element_id => $element) { + foreach ($element['blocks'] as $lines) { + foreach ($lines as $line) { + print ''; + print '' . $line['date'] . ''; + print '' . $line['piece'] . ''; + print '' . $line['account_accounting'] . ''; + print '' . $line['subledger_account'] . ''; + print '' . $line['label_operation'] . ''; + if ($object->nature == 4) print '' . $line['payment_mode'] . ''; + print '' . $line['debit'] . ''; + print '' . $line['credit'] . ''; + print ''; + } } } } diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index b218a91385b..e9ad4a5c53b 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -640,6 +640,7 @@ print ''; /* // Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation. +// TODO Must be implemented by PDF templates // Ask for payment bank during order if ($conf->banque->enabled) { diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 98c72ac68dc..6cc0144471c 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -128,6 +128,8 @@ if ($action == 'updateMask') { if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } +} elseif ($action == 'unsetdoc') { + dolibarr_del_const($db, "CONTRACT_ADDON_PDF", $conf->entity); } elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated @@ -152,9 +154,18 @@ if ($action == 'updateMask') { } else { setEventMessages($langs->trans("Error"), null, 'errors'); } +} elseif ($action == "allowonlinesign") { + if (!dolibarr_set_const($db, "CONTRACT_ALLOW_ONLINESIGN", $value, 0, 'int', $conf->entity)) { + $error++; + } +} elseif ($action == "allowexternaldownload") { + if (!dolibarr_set_const($db, "CONTRACT_ALLOW_EXTERNAL_DOWNLOAD", $value, 0, 'int', $conf->entity)) { + $error++; + } } + /* * View */ @@ -369,9 +380,9 @@ foreach ($dirmodels as $reldir) { // Defaut print ''; if ($conf->global->CONTRACT_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').''; } else { - print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; } print ''; @@ -469,6 +480,37 @@ print $form->selectyesno("activate_hideClosedServiceByDefault", (!empty($conf->g print ''; print ''; +// Allow online signing +print ''; +print ''.$langs->trans("AllowOnlineSign").''; +print ''; +if ($conf->global->CONTRACT_ALLOW_ONLINESIGN) { + print ''; + print img_picto($langs->trans("Activited"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; +print ''; + +// Allow external download +print ''; +print ''.$langs->trans("AllowExternalDownload").''; +print ''; +if ($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD) { + print ''; + print img_picto($langs->trans("Activited"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; +print ''; print ''; print $form->buttonsSaveCancel("Save", ''); diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 3d92dd5023f..c1f31282dcd 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2022 Laurent Destailleur * Copyright (C) 2009-2018 Regis Houssin * Copyright (C) 2010 Juanjo Menent * @@ -30,11 +30,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'products', 'admin')); -if (!$user->admin) { - accessforbidden(); -} - $action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'aZ09'); $currencycode = GETPOST('currencycode', 'alpha'); if (isModEnabled('multicompany') && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { @@ -49,25 +46,36 @@ $mainroundingruletot = 'MAIN_ROUNDING_RULE_TOT'.(!empty($currencycode) ? '_'.$cu $valmainmaxdecimalsunit = GETPOST($mainmaxdecimalsunit, 'int'); $valmainmaxdecimalstot = GETPOST($mainmaxdecimalstot, 'int'); -$valmainmaxdecimalsshown = GETPOST($mainmaxdecimalsshown, 'int'); +$valmainmaxdecimalsshown = GETPOST($mainmaxdecimalsshown, 'alpha'); // Can be 'x.y' but also 'x...' $valmainroundingruletot = price2num(GETPOST($mainroundingruletot, 'alphanohtml'), '', 2); -if ($action == 'update') { +if (!$user->admin) { + accessforbidden(); +} + + +/* + * Actions + */ + +if ($action == 'update' && !$cancel) { $error = 0; $MAXDEC = 8; - if ($_POST[$mainmaxdecimalsunit] > $MAXDEC - || $_POST[$mainmaxdecimalstot] > $MAXDEC - || $_POST[$mainmaxdecimalsshown] > $MAXDEC) { + if ($valmainmaxdecimalsunit > $MAXDEC + || $valmainmaxdecimalstot > $MAXDEC + || $valmainmaxdecimalsshown > $MAXDEC) { $error++; setEventMessages($langs->trans("ErrorDecimalLargerThanAreForbidden", $MAXDEC), null, 'errors'); + $action = 'edit'; } - if ($_POST[$mainmaxdecimalsunit].(!empty($currencycode) ? '_'.$currencycode : '') < 0 - || $_POST[$mainmaxdecimalstot] < 0 - || $_POST[$mainmaxdecimalsshown] < 0) { + if ($valmainmaxdecimalsunit < 0 + || $valmainmaxdecimalstot < 0 + || $valmainmaxdecimalsshown < 0) { $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorNegativeValueNotAllowed"), null, 'errors'); + $action = 'edit'; } if ($valmainroundingruletot) { @@ -75,9 +83,23 @@ if ($action == 'update') { $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT"), null, 'errors'); + $action = 'edit'; } } + if ((float) $valmainmaxdecimalsshown == 0) { + $langs->load("errors"); + $error++; + setEventMessages($langs->trans("ErrorValueCantBeNull", dol_trunc(dol_string_nohtmltag($langs->transnoentitiesnoconv("MAIN_MAX_DECIMALS_SHOWN")), 40)), null, 'errors'); + $action = 'edit'; + } + if (! $error && ((float) $valmainmaxdecimalsshown < $valmainmaxdecimalsunit || (float) $valmainmaxdecimalsshown < $valmainmaxdecimalstot)) { + $langs->load("errors"); + $error++; + setEventMessages($langs->trans("ErrorValueForTooLow", dol_trunc(dol_string_nohtmltag($langs->transnoentitiesnoconv("MAIN_MAX_DECIMALS_SHOWN")), 40)), null, 'errors'); + $action = 'edit'; + } + if (!$error) { dolibarr_set_const($db, $mainmaxdecimalsunit, $valmainmaxdecimalsunit, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $mainmaxdecimalstot, $valmainmaxdecimalstot, 'chaine', 0, '', $conf->entity); @@ -144,24 +166,25 @@ if ($action == 'edit') { print ''; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''; + print ''; print ''; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''; + print ''; print ''.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").''; - print ''; + print ''; print ''; print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''; + print ''; print ''; - print '
'; print '
'; - print ''; + print ''; + print '   '; + print ''; print '
'; print '
'; @@ -170,7 +193,7 @@ if ($action == 'edit') { } else { print '
'; print ''; - print ''; + print ''; 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 ''; } elseif ($value == 'type_template') { // Le type de template 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 ''; + print ''; if ($supported) { diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index fa1fd18f049..f798995d525 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -291,6 +291,14 @@ if ($mode == 'setup' && $user->admin) { print ''; print ''."\n"; + // Scopes + print ''; + print ''; + print ''; + print ''; 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 '"; } else { print '"; } // Default print ''; @@ -425,7 +424,7 @@ foreach ($dirmodels as $reldir) { print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; print ''; print "\n"; diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 0abf864084d..085dd338e69 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -122,7 +122,7 @@ if (empty($conf->global->MAIN_MODULE_API)) { // Test if explorer is not disabled if (preg_match('/api\/index\.php\/explorer/', $url) && !empty($conf->global->API_EXPLORER_DISABLED)) { $langs->load("admin"); - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + dol_syslog("Call Dolibarr API interfaces with module API REST disabled"); print $langs->trans("WarningAPIExplorerDisabled").'.

'; //session_destroy(); exit(0); @@ -155,6 +155,10 @@ preg_match('/index\.php\/([^\/]+)(.*)$/', $url, $reg); $refreshcache = (empty($conf->global->API_PRODUCTION_DO_NOT_ALWAYS_REFRESH_CACHE) ? true : false); if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { $refreshcache = true; + if (!is_writable($conf->api->dir_temp)) { + print 'Erreur temp dir api/temp not writable'; + exit(0); + } } $api = new DolibarrApi($db, '', $refreshcache); diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 0f19bed4625..b5896f2817e 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -356,7 +356,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send if (empty($user->socid)) { - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init&token=' . newToken() . '#formmailbeforetitle'); + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init&token=' . newToken() . '#formmailbeforetitle'); } if ($object->status == $object::STATUS_DRAFT) { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 1d7901eca3f..e6ed20acb3d 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1673,10 +1673,10 @@ class Categorie extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Deplace fichier uploade sous le nom $files dans le repertoire sdir + * Deplace fichier uploade sous le nom $file dans le repertoire sdir * - * @param string $sdir Repertoire destination finale - * @param string $file Nom du fichier uploade + * @param string $sdir Final destination directory + * @param array $file Uploaded file name * @return void */ public function add_photo($sdir, $file) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index e59389a87b7..2372f24a929 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -227,13 +227,13 @@ if (empty($reshook)) { $substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'&email='.urlencode($obj->email).'&mtid='.$obj->rowid; $onlinepaymentenabled = 0; - if (!empty($conf->paypal->enabled)) { + if (isModEnabled('paypal')) { $onlinepaymentenabled++; } - if (!empty($conf->paybox->enabled)) { + if (isModEnabled('paybox')) { $onlinepaymentenabled++; } - if (!empty($conf->stripe->enabled)) { + if (isModEnabled('stripe')) { $onlinepaymentenabled++; } if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { @@ -263,7 +263,7 @@ if (empty($reshook)) { $substitutionarray['__PUBLICLINK_NEWMEMBERFORM__'] = ''.$langs->trans('BlankSubscriptionForm'). ''; } /* For backward compatibility, deprecated */ - if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) { + if (isModEnabled('paypal') && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) { $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index ea6ec241b16..7b4e06c897f 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -119,13 +119,23 @@ class AdvanceTargetingMailing extends CommonObject '3' => $langs->trans('ThirdParty'), '4' => $langs->trans('ContactsWithThirdpartyFilter') ); - $this->type_statuscommprospect = array( - -1 => $langs->trans("StatusProspect-1"), - 0 => $langs->trans("StatusProspect0"), - 1 => $langs->trans("StatusProspect1"), - 2 => $langs->trans("StatusProspect2"), - 3 => $langs->trans("StatusProspect3") - ); + + require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; + $customerStatic = new Client($this->db); + $customerStatic->loadCacheOfProspStatus(); + if (!empty($customerStatic->cacheprospectstatus)) { + foreach ($customerStatic->cacheprospectstatus as $dataProspectSt) { + $this->type_statuscommprospect[$dataProspectSt['id']]=$dataProspectSt['label']; + } + } else { + $this->type_statuscommprospect = array( + -1 => $langs->trans("StatusProspect-1"), + 0 => $langs->trans("StatusProspect0"), + 1 => $langs->trans("StatusProspect1"), + 2 => $langs->trans("StatusProspect2"), + 3 => $langs->trans("StatusProspect3") + ); + } } /** diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 9e10d51031e..50169438baa 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -355,7 +355,7 @@ class FormAdvTargetEmailing extends Form $out = ''; $sql = "SELECT c.rowid, c.name, c.fk_element"; - $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as c"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_advtarget as c"; $sql .= " WHERE type_element = '".$this->db->escape($type_element)."'"; $sql .= " ORDER BY c.name"; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3c478ff5a2c..76cc9b23f27 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -61,10 +61,10 @@ if (isModEnabled('variants')) { // Load translation files required by the page $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'sendings', 'other')); -if (!empty($conf->incoterm->enabled)) { +if (isModEnabled('incoterm')) { $langs->load('incoterm'); } -if (!empty($conf->margin->enabled)) { +if (isModEnabled('margin')) { $langs->load('margins'); } @@ -375,7 +375,7 @@ if (empty($reshook)) { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled) && $usercancreate) { + } elseif ($action == 'set_incoterms' && isModEnabled('incoterm') && $usercancreate) { // Set incoterm $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } elseif ($action == 'add' && $usercancreate) { @@ -1048,7 +1048,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 there is some prices specific to the customer if (count($prodcustprice->lines) > 0) { @@ -1870,7 +1870,7 @@ if ($action == 'create') { } // Incoterms - if (!empty($conf->incoterm->enabled)) { + if (isModEnabled('incoterm')) { print ''; print ''; print ''; } + // Parent company + if (!empty($arrayfields['s2.nom']['checked'])) { + 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 (!$i) { + $totalarray['nbfield']++; + } + } + // Town if (!empty($arrayfields['s.town']['checked'])) { print ''; } print ''; - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { print ''; } 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 ''; } @@ -1749,7 +1749,7 @@ if ($action == 'create') { print ''; $colspan = 6; - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { $colspan++; } if (!empty($conf->global->PRODUCT_USE_UNITS)) { @@ -2092,9 +2092,9 @@ if ($action == 'create') { if (empty($user->socid)) { if ($object->statut == 1) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->contrat->creer)) { - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle', '', true, $params); + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle', '', true, $params); } else { - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', '#', '', false, $params); + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', '#', '', false, $params); } } } @@ -2206,12 +2206,21 @@ if ($action == 'create') { $linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + // Show online signature link + if ($object->statut != Contrat::STATUS_DRAFT && $conf->global->CONTRACT_ALLOW_ONLINESIGN) { + print '
'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; + + print showOnlineSignatureUrl('contract', $object->ref).'
'; + } + print '
'; $MAXEVENT = 10; $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id); + // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); @@ -2237,7 +2246,7 @@ $db->close(); ?> margin->enabled) && $action == 'editline') { +if (isModEnabled('margin') && $action == 'editline') { // TODO Why this ? To manage margin on contracts ? ?> stripe->enabled) && isset($keyforstripeterminalbank) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { +if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning', 1); } @@ -337,7 +337,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) { function fetchPaymentIntentClientSecret(amount, invoiceid) { const bodyContent = JSON.stringify({ amount : amount, invoiceid : invoiceid }); return fetch('', { @@ -535,7 +535,7 @@ $action_buttons = array( ), ); $numpad = $conf->global->TAKEPOS_NUMPAD; -if (!empty($conf->stripe->enabled) && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) { +if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) { print ''; dol_htmloutput_mesg($langs->trans('ConnectingToStripeTerminal', 'Stripe'), '', 'warning', 1); print ''; @@ -646,7 +646,7 @@ while ($i < count($arrayOfValidPaymentModes)) { $i = $i + 1; } -if (!empty($conf->stripe->enabled) && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) { +if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) { $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$_SESSION["takeposterminal"]; print ''; if (!empty($conf->global->$keyforstripeterminalbank)) { diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 647bf2cec54..841f810e5ec 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -689,7 +689,7 @@ if (empty($reshook)) { $upload_dir = $conf->ticket->dir_output; $permissiontoadd = $user->rights->ticket->write; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; -//var_dump($action);exit; + //var_dump($action);exit; // Actions to send emails $triggersendname = 'TICKET_SENTBYMAIL'; $paramname = 'id'; @@ -1430,12 +1430,6 @@ if ($action == 'create' || $action == 'presend') { print dolGetButtonAction('', $langs->trans('TicketAddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&token='.newToken().'&socid='. $object->fk_soc.'&origin=ticket_ticket&originid='. $object->id, ''); } - /* This is useless. We can already modify each field individually - if ($user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) { - print ''; - } - */ - // Close ticket if statut is read if (isset($object->status) && $object->status > 0 && $object->status < Ticket::STATUS_CLOSED && $user->rights->ticket->write) { print dolGetButtonAction('', $langs->trans('CloseTicket'), 'default', $_SERVER["PHP_SELF"].'?action=close&token='.newToken().'&track_id='.$object->track_id, ''); diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index 0128954989d..243084ec89f 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -109,8 +109,8 @@ if (in_array('DOLUSERCOOKIE_ticket_by_status', $autosetarray)) { } elseif (!empty($_COOKIE['DOLUSERCOOKIE_ticket_by_status'])) { $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_ticket_by_status'], true); $endyear = $tmparray['year']; - $shownb = $tmparray['shownb']; - $showtot = $tmparray['showtot']; + $shownb = empty($tmparray['shownb']) ? 0 : $tmparray['shownb']; + $showtot = empty($tmparray['showtot']) ? 0 : $tmparray['showtot']; } if (empty($shownb) && empty($showtot)) { $showtot = 1; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 9ba58cd069b..3c65d018e6b 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1864,7 +1864,7 @@ if ($action == 'create' || $action == 'adduserldap') { $langs->load("mails"); $params['attr']['title'] = $langs->trans('NoEMail'); } - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle', '', $canSendMail, $params); + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle', '', $canSendMail, $params); } if ($caneditfield && (!isModEnabled('multicompany') || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index b263eeaa666..a3932af045f 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2692,7 +2692,7 @@ class User extends CommonObject } /** - * Return a link to the user card (with optionaly the picto) + * Return a HTML link to the user card (with optionaly the picto) * Use this->id,this->lastname, this->firstname * * @param int $withpictoimg Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) @@ -2720,8 +2720,7 @@ class User extends CommonObject $withpictoimg = 0; } - $result = ''; $label = ''; - $companylink = ''; + $result = ''; $label = ''; $companylink = ''; if (!empty($this->photo)) { $label .= '
'; diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index ab49800a8e4..4c91bd041dd 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -129,7 +129,7 @@ $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, g.tms as datem $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid"; -if (isModEnabled('multicompany') && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) { +if (isModEnabled('multicompany') && $conf->entity == 1 && (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE') || ($user->admin && !$user->entity))) { $sql .= " WHERE g.entity IS NOT NULL"; } else { $sql .= " WHERE g.entity IN (0,".$conf->entity.")"; diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 96ca5428683..c93a22f5cfb 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -224,10 +224,10 @@ if ($canreadperms) { $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec"; $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; - if (isModEnabled('multicompany') && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) { + if (isModEnabled('multicompany') && $conf->entity == 1 && (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE') || ($user->admin && !$user->entity))) { $sql .= " WHERE g.entity IS NOT NULL"; } else { - $sql .= " WHERE g.entity IN (0,".$conf->entity.")"; + $sql .= " WHERE g.entity IN (0, ".$conf->entity.")"; } $sql .= $db->order("g.datec", "DESC"); $sql .= $db->plimit($max); diff --git a/htdocs/webhook/target_card.php b/htdocs/webhook/target_card.php index 83d0d4a1831..f7536cc15b0 100644 --- a/htdocs/webhook/target_card.php +++ b/htdocs/webhook/target_card.php @@ -460,20 +460,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send if (empty($user->socid)) { - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle'); + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle'); } // Back to draft if ($object->status == $object::STATUS_VALIDATED) { - print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd); } - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); // Validate if ($object->status == $object::STATUS_DRAFT) { if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { - print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd); } else { $langs->load("errors"); print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
'.$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 ''; } 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 '
'; print ''; + print ''; print ''; print '
'; @@ -739,7 +740,6 @@ if ($action == 'add') { if ($fieldlist[$field] == 'content_lines') { $valuetoshow = ''; } - if ($valuetoshow != '') { print '
'; if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { @@ -820,16 +820,15 @@ if ($action == 'add') { // Input field if ($tmpfieldlist == 'topic') { - print ''; + print ''; } elseif ($tmpfieldlist == 'joinfiles') { - print ''; + print $form->selectyesno($tmpfieldlist, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, false, 0, 1); } else { - // print ''; $okforextended = true; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $okforextended = false; } - $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 180, 'dolibarr_mailings', 'In', 0, true, $okforextended, ROWS_4, '90%'); + $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : ''), '', 180, 'dolibarr_mailings', 'In', 0, true, $okforextended, ROWS_4, '90%'); print $doleditor->Create(1); } 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 ''; 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 ''; - 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 ''; + + $label = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array); + + print ''; + print img_picto('', 'delete'); + print ''; + + print ''; + print '
'.$langs->trans("Scopes").''; + $currentscopes = getDolGlobalString($key[4]); + print $currentscopes; + 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 "'."\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 "'; 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 ''; - print ''.img_object($langs->trans("Preview"), 'pdf').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; print '
'; @@ -2655,7 +2655,7 @@ if ($action == 'create') { } // Incoterms - if (!empty($conf->incoterm->enabled)) { + if (isModEnabled('incoterm')) { print '
'; print '
'; print $langs->trans('IncotermLabel'); @@ -2737,7 +2737,7 @@ if ($action == 'create') { print '
'; // Margin Infos - if (!empty($conf->margin->enabled)) { + if (isModEnabled('margin')) { $formmargin->displayMarginInfos($object); } @@ -2855,11 +2855,7 @@ if ($action == 'create') { // Send if (empty($user->socid)) { if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED || !empty($conf->global->PROPOSAL_SENDBYEMAIL_FOR_ALL_STATUS)) { - if ($usercansend) { - print ''.$langs->trans('SendMail').''; - } else { - print ''.$langs->trans('SendMail').''; - } + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?action=presend&token='.newToken().'&id='.$object->id.'&mode=init#formmailbeforetitle', '', $usercansend); } } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 46474092448..f9fd5d8ac7e 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1412,7 +1412,7 @@ class Propal extends CommonObject } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $prodcustprice = new Productcustomerprice($this->db); $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $objsoc->id); - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + $result = $prodcustprice->fetchAll('', '', 0, 0, $filter); if ($result) { // If there is some prices specific to the customer if (count($prodcustprice->lines) > 0) { diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 2a9429ffeaa..edb8e48405e 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -312,7 +312,7 @@ if (isModEnabled("propal") && $user->rights->propale->lire) { */ /* -if (!empty($conf->propal->enabled)) +if (isModEnabled('propal')) { $sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as name, s.rowid as socid"; $sql.=" FROM ".MAIN_DB_PREFIX."propal as c"; @@ -387,7 +387,7 @@ if (!empty($conf->propal->enabled)) */ /* -if (!empty($conf->propal->enabled)) +if (isModEnabled('propal')) { $sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index b95d1e5253f..a5d85633bee 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -536,7 +536,7 @@ $formother = new FormOther($db); $formfile = new FormFile($db); $formpropal = new FormPropal($db); $formmargin = null; -if (!empty($conf->margin->enabled)) { +if (isModEnabled('margin')) { $formmargin = new FormMargin($db); } $companystatic = new Societe($db); @@ -1573,7 +1573,7 @@ if ($resql) { $typenArray = null; $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']) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index c41a4d47f76..9428f76dd8e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -790,7 +790,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 >= 0) { if (count($prodcustprice->lines) > 0) { $pu_ht = price($prodcustprice->lines[0]->price); @@ -2793,7 +2793,7 @@ if ($action == 'create' && $usercancreate) { if (empty($user->socid)) { if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { - print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?action=presend&token='.newToken().'&id='.$object->id.'&mode=init#formmailbeforetitle', ''); + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?action=presend&token='.newToken().'&id='.$object->id.'&mode=init#formmailbeforetitle', ''); } else { print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF']. '#', '', false); } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 86bead44380..208889ba1a2 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -42,7 +42,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -if (!empty($conf->margin->enabled)) { +if (isModEnabled('margin')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; } require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -80,6 +80,7 @@ $search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha $search_ref_customer = GETPOST('search_ref_customer', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); $search_company_alias = GETPOST('search_company_alias', 'alpha'); +$search_parent_name = trim(GETPOST('search_parent_name', 'alphanohtml')); $search_town = GETPOST('search_town', 'alpha'); $search_zip = GETPOST('search_zip', 'alpha'); $search_state = GETPOST('search_state', 'alpha'); @@ -178,6 +179,7 @@ $arrayfields = array( 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>25), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1, 'position'=>31), + 's2.nom'=>array('label'=>'ParentCompany', 'position'=>32, 'checked'=>0), 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>35), 's.zip'=>array('label'=>"Zip", 'checked'=>-1, 'position'=>40), 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45), @@ -199,10 +201,10 @@ $arrayfields = array( 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>110), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116), - 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), - 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), - 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$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) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), + 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$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') || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125), 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), @@ -253,6 +255,7 @@ if (empty($reshook)) { $search_ref_customer = ''; $search_company = ''; $search_company_alias = ''; + $search_parent_name = ''; $search_town = ''; $search_zip = ""; $search_state = ""; @@ -778,10 +781,11 @@ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $formmargin = null; -if (!empty($conf->margin->enabled)) { +if (isModEnabled('margin')) { $formmargin = new FormMargin($db); } $companystatic = new Societe($db); +$company_url_list = array(); $formcompany = new FormCompany($db); $projectstatic = new Project($db); @@ -793,6 +797,8 @@ if ($sall || $search_product_category > 0 || $search_user > 0) { $sql = 'SELECT DISTINCT'; } $sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client,'; +$sql .= " s.parent as fk_parent,"; +$sql .= " s2.nom as name2,"; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= " country.code as country_code,"; @@ -820,6 +826,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s2.rowid = s.parent"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; @@ -937,6 +944,9 @@ if ($search_company) { if ($search_company_alias) { $sql .= natural_search('s.name_alias', $search_company_alias); } +if ($search_parent_name) { + $sql .= natural_search('s2.nom', $search_parent_name); +} if ($search_sale > 0) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); } @@ -1121,6 +1131,9 @@ if ($resql) { if ($search_company_alias) { $param .= '&search_company_alias='.urlencode($search_company_alias); } + if ($search_parent_name != '') { + $param .= '&search_parent_name='.urlencode($search_parent_name); + } if ($search_ref_customer) { $param .= '&search_ref_customer='.urlencode($search_ref_customer); } @@ -1451,6 +1464,12 @@ if ($resql) { print ''; print '
'; + print ''; + 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 "'; 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").''.$langs->trans("ReductionShort").''.$langs->trans("BuyingPrice").' '.price($objp->pa_ht).'