From 637e1a8d211a65c0c0cee59868df80e40d44ddb0 Mon Sep 17 00:00:00 2001 From: mikee2 Date: Sat, 6 May 2017 10:49:37 +0200 Subject: [PATCH 001/114] Update Segment.php Add additional needed fields so that you can invoice yearly items. Have number and text descriptions to avoid future changes that may break existing invoices. --- htdocs/includes/odtphp/Segment.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/includes/odtphp/Segment.php b/htdocs/includes/odtphp/Segment.php index 81e9dad9f97..4310c716ee7 100644 --- a/htdocs/includes/odtphp/Segment.php +++ b/htdocs/includes/odtphp/Segment.php @@ -170,8 +170,16 @@ class Segment implements IteratorAggregate, Countable { global $langs; - $patterns=array( '__CURRENTDAY__','__CURRENTDAYTEXT__','__CURRENTMONTHSHORT__','__CURRENTMONTH__','__CURRENTYEAR__' ); - $values=array( date('j'), $langs->trans(date('l')), $langs->trans(date('M')), $langs->trans(date('F')), date('Y') ); + $nextMonth = strtotime('+1 month'); + + $patterns=array( '/__CURRENTDAY__/u','/__CURRENTDAYTEXT__/u', + '/__CURRENTMONTH__/u','/__CURRENTMONTHSHORT__/u','/__CURRENTMONTHLONG__/u', + '/__NEXTMONTH__/u','/__NEXTMONTHSHORT__/u','/__NEXTMONTHLONG__/u', + '/__CURRENTYEAR__/u','/__NEXTYEAR__/u' ); + $values=array( date('j'), $langs->trans(date('l')), + $langs->trans(date('n')), $langs->trans(date('M')), $langs->trans(date('F')), + $langs->trans(date('n', $nextMonth)), $langs->trans(date('M', $nextMonth)), $langs->trans(date('F', $nextMonth)), + date('Y'), date('Y', strtotime('+1 year')) ); $text=preg_replace($patterns, $values, $text); From 6a350470200b224261d20817d3a5159095e2f104 Mon Sep 17 00:00:00 2001 From: mikee2 Date: Wed, 14 Jun 2017 12:53:29 +0200 Subject: [PATCH 002/114] Updated to use dolibarr timme functions Redefined macro strings to adapt to dolibarr date functions return values. Keep same macro names when possible to avoid breaking existing code. Some macro holders (not commonly used) have been dropped because non existing values in dolibarr date functions. Per eldy request changed php date functions with dolibarr's internal date functions to match users time zone. Now dates are those of the user's timezone so check that is is correctly defined in user's profile. --- htdocs/includes/odtphp/Segment.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/includes/odtphp/Segment.php b/htdocs/includes/odtphp/Segment.php index 4310c716ee7..d015d6ad263 100644 --- a/htdocs/includes/odtphp/Segment.php +++ b/htdocs/includes/odtphp/Segment.php @@ -170,16 +170,17 @@ class Segment implements IteratorAggregate, Countable { global $langs; - $nextMonth = strtotime('+1 month'); - - $patterns=array( '/__CURRENTDAY__/u','/__CURRENTDAYTEXT__/u', - '/__CURRENTMONTH__/u','/__CURRENTMONTHSHORT__/u','/__CURRENTMONTHLONG__/u', - '/__NEXTMONTH__/u','/__NEXTMONTHSHORT__/u','/__NEXTMONTHLONG__/u', + $hoy = dol_getdate(dol_now('tzuser')); + $nextMonth = dol_get_next_month($hoy['mon'], $hoy['year'])['month']; + + $patterns=array( '/__CURRENTDAY__/u','/__CURENTWEEKDAY__/u', + '/__CURRENTMONTH__/u','/__CURRENTMONTHLONG__/u', + '/__NEXTMONTH__/u','/__NEXTMONTHLONG__/u', '/__CURRENTYEAR__/u','/__NEXTYEAR__/u' ); - $values=array( date('j'), $langs->trans(date('l')), - $langs->trans(date('n')), $langs->trans(date('M')), $langs->trans(date('F')), - $langs->trans(date('n', $nextMonth)), $langs->trans(date('M', $nextMonth)), $langs->trans(date('F', $nextMonth)), - date('Y'), date('Y', strtotime('+1 year')) ); + $values=array( $hoy['mday'], $langs->trans($hoy['weekday']), + $hoy['mon'], $langs->trans($hoy['month']), + $nextMonth, monthArray($langs)[$nextMonth], + $hoy['year'], $hoy['year']+1 ); $text=preg_replace($patterns, $values, $text); From 17da80832513e19d9efc40a4a7eec117aab45de4 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Fri, 8 Sep 2017 14:35:44 +0200 Subject: [PATCH 003/114] FIX wrong basePath in the swagger view Behind a reverse proxy the basePath seems to be in http. Forcing the basePath to DOL_MAIN_URL_ROOT fixes the problem. --- htdocs/api/class/api.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 40e00d01ffd..79793b0f8de 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -56,7 +56,7 @@ class DolibarrApi $this->db = $db; $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true ); $this->r = new Restler($production_mode, $refreshCache); - + $this->r->setBaseUrls(DOL_MAIN_URL_ROOT); $this->r->setAPIVersion(1); } From 681c2a67bd9c7d72554d976bc2d076a19410c4ca Mon Sep 17 00:00:00 2001 From: fappels Date: Mon, 11 Sep 2017 23:22:44 +0200 Subject: [PATCH 004/114] Fix batch required for lot product error message. --- htdocs/langs/en_US/errors.lang | 2 +- htdocs/product/stock/class/mouvementstock.class.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 8dfc02c49f1..47299634de3 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -156,7 +156,7 @@ ErrorPriceExpression22=Negative result '%s' ErrorPriceExpressionInternal=Internal error '%s' ErrorPriceExpressionUnknown=Unknown error '%s' ErrorSrcAndTargetWarehouseMustDiffers=Source and target warehouses must differs -ErrorTryToMakeMoveOnProductRequiringBatchData=Error, trying to make a stock movement without lot/serial information, on a product requiring lot/serial information +ErrorTryToMakeMoveOnProductRequiringBatchData=Error, trying to make a stock movement without lot/serial information, on product '%s' requiring lot/serial information ErrorCantSetReceptionToTotalDoneWithReceptionToApprove=All recorded receptions must first be verified (approved or denied) before being allowed to do this action ErrorCantSetReceptionToTotalDoneWithReceptionDenied=All recorded receptions must first be verified (approved) before being allowed to do this action ErrorGlobalVariableUpdater0=HTTP request failed with error '%s' diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 3e3eb4c28a7..25e0e9e7fce 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -96,6 +96,7 @@ class MouvementStock extends CommonObject require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; + $langs->load("errors"); $error = 0; dol_syslog(get_class($this)."::_create start userid=$user->id, fk_product=$fk_product, warehouse_id=$entrepot_id, qty=$qty, type=$type, price=$price, label=$label, inventorycode=$inventorycode, datem=".$datem.", eatby=".$eatby.", sellby=".$sellby.", batch=".$batch.", skip_batch=".$skip_batch); @@ -141,7 +142,7 @@ class MouvementStock extends CommonObject { if (empty($batch)) { - $this->errors[]=$langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $product->name); + $this->errors[]=$langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $product->ref); dol_syslog("Try to make a movement of a product with status_batch on without any batch data"); $this->db->rollback(); From f68d31d7c591da55f231e16ebdc65d171ea39572 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Tue, 12 Sep 2017 17:45:02 +0200 Subject: [PATCH 005/114] Add of $urlwithroot in the setBaseUrls function, to use Dolibarr external domain name in the configuration file --- htdocs/api/class/api.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 79793b0f8de..36eb7c1d7d2 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -56,7 +56,7 @@ class DolibarrApi $this->db = $db; $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true ); $this->r = new Restler($production_mode, $refreshCache); - $this->r->setBaseUrls(DOL_MAIN_URL_ROOT); + $this->r->setBaseUrls(DOL_MAIN_URL_ROOT, $urlwithroot); $this->r->setAPIVersion(1); } From ff7b542bfad145d7485d920c34b77594d358b556 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 15 Sep 2017 13:25:54 +0200 Subject: [PATCH 006/114] fix : Avoid warning --- .../class/expensereport.class.php | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index f999a93c57f..0ac2ce64062 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -187,20 +187,22 @@ class ExpenseReport extends CommonObject $resql=$this->db->query($sql); if (!$resql) $error++; - foreach ($this->lines as $i => $val) - { - $newndfline=new ExpenseReportLine($this->db); - $newndfline=$this->lines[$i]; - $newndfline->fk_expensereport=$this->id; - if ($result >= 0) - { - $result=$newndfline->insert(); - } - if ($result < 0) - { - $error++; - break; - } + if (is_array($this->lines) && count($this->lines)>0) { + foreach ($this->lines as $i => $val) + { + $newndfline=new ExpenseReportLine($this->db); + $newndfline=$this->lines[$i]; + $newndfline->fk_expensereport=$this->id; + if ($result >= 0) + { + $result=$newndfline->insert(); + } + if ($result < 0) + { + $error++; + break; + } + } } if (! $error) From c2e1e2491d3ebeff0fa77dca79a2f5729bf5865e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 16 Sep 2017 06:53:29 +0200 Subject: [PATCH 007/114] Accountancy - Finish moving admin to specific menu & some cleaning --- htdocs/accountancy/admin/export.php | 23 +---- htdocs/accountancy/admin/index.php | 19 +--- htdocs/core/lib/accounting.lib.php | 36 +------- htdocs/core/menus/init_menu_auguria.sql | 21 +++-- htdocs/core/menus/standard/eldy.lib.php | 61 +++---------- htdocs/core/modules/modAccounting.class.php | 91 ++++--------------- .../install/mysql/migration/6.0.0-7.0.0.sql | 13 +++ 7 files changed, 62 insertions(+), 202 deletions(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 433448fa688..9a8a659db99 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -37,10 +37,10 @@ $langs->load("bills"); $langs->load("admin"); $langs->load("accountancy"); -// Security check -if (empty($user->admin) && empty($user->rights->accounting->chartofaccount)) +// Security access +if (empty($user->rights->accounting->chartofaccount)) { - accessforbidden(); + accessforbidden(); } $action = GETPOST('action', 'alpha'); @@ -53,13 +53,6 @@ $main_option = array ( $model_option = array ( 'ACCOUNTING_EXPORT_SEPARATORCSV', 'ACCOUNTING_EXPORT_DATE' - /* - 'ACCOUNTING_EXPORT_PIECE', - 'ACCOUNTING_EXPORT_GLOBAL_ACCOUNT', - 'ACCOUNTING_EXPORT_LABEL', - 'ACCOUNTING_EXPORT_AMOUNT', - 'ACCOUNTING_EXPORT_DEVISE' - */ ); /* @@ -121,17 +114,13 @@ llxHeader(); $form = new Form($db); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +// $linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); -$head = admin_accounting_prepare_head(); - print '
'; print ''; print ''; -dol_fiche_head($head, 'export', $langs->trans("Configuration"), -1, 'cron'); - $var = true; /* @@ -245,8 +234,6 @@ if ($num2) { print "\n"; } -dol_fiche_end(); - print '
'; print '
'; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index b6aceb52ad4..bc078c062c6 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -37,10 +37,9 @@ $langs->load("compta"); $langs->load("bills"); $langs->load("admin"); $langs->load("accountancy"); -$langs->load("salaries"); -// Security check -if (empty($user->admin)) +// Security access +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -160,18 +159,13 @@ llxHeader(); $form = new Form($db); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +//$linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); -$head = admin_accounting_prepare_head($accounting); - print '
'; print ''; print ''; -dol_fiche_head($head, 'general', $langs->trans("Configuration"), -1, 'cron'); - - // Default mode for calculating turnover (parameter ACCOUNTING_MODE) print ''; @@ -287,18 +281,11 @@ foreach ($list as $key) print '
'; - - - -dol_fiche_end(); - print '
'; print '
'; print '
'; -print '
'.$langs->trans("AccountancySetupDoneFromAccountancyMenu", $langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")).'
'; - print '
'; print '
'; diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 0fccf6ccd9a..b0b6dc6855c 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -23,40 +23,6 @@ * \brief Library of accountancy functions */ -/** - * Prepare array with list of admin tabs - * - * @param AccountingAccount $object Object instance we show card - * @return array Array of tabs to show - */ -function admin_accounting_prepare_head(AccountingAccount $object=null) -{ - global $langs, $conf; - - $h = 0; - $head = array (); - - $head[$h][0] = dol_buildpath('/accountancy/admin/index.php', 1); - $head[$h][1] = $langs->trans("Miscellaneous"); - $head[$h][2] = 'general'; - $h ++; - - $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/export.php'; - $head[$h][1] = $langs->trans("ExportOptions"); - $head[$h][2] = 'export'; - $h ++; - - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin'); - - complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin', 'remove'); - - return $head; -} - /** * Prepare array with list of tabs * diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 47ec0741127..917cfd74891 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -217,18 +217,21 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- Setup insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2454__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2453__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_general', 2451__+MAX_llx_menu__, '/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'General', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2454__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 41, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2458__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_default', 2451__+MAX_llx_menu__, '/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuDefaultAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 50, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2459__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/compta/bank/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuBankAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 52, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2459__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/compta/bank/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuBankAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 51, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/admin/dict.php?id=10&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuVatAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2461__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/admin/dict.php?id=7&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 70, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 80, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2463__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 90, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/admin/dict.php?id=10&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuVatAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 52, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2461__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/admin/dict.php?id=7&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 53, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 54, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2463__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 55, __ENTITY__); + + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2464__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_export', 2451__+MAX_llx_menu__, '/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'ExportOptions', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); -- Accounting period insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin" && $conf->global->MAIN_FEATURES_LEVEL > 0', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_period', 2451__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'FiscalPeriod', 1, 'admin', '', '', 2, 80, __ENTITY__); -- Binding diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 45ac75d5e40..becd3d35905 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -969,37 +969,30 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Chart of account $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 10); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 20); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 30); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 31); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 40); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 20); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 30); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 40); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 41); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); if (! empty($conf->banque->enabled)) { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/compta/bank/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuBankAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 42); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/compta/bank/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuBankAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 51); } if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 52); } if (! empty($conf->tax->enabled)) { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 53); } if (! empty($conf->expensereport->enabled)) { - if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 54); } - /* not required yet, already supported by default account - if (! empty($conf->loan->enabled)) - { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/loan.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuLoanAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_loan', 45); - } - if (! empty($conf->don->enabled)) - { - if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/don/admin/donation.php?from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDonationAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_donation', 47); - }*/ - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 60); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 55); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 60); // Fiscal year if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Not yet used. In a future will lock some periods. @@ -1083,36 +1076,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } else dol_print_error($db); $db->free($resql); - - /* - $sql = "SELECT rowid, label, accountancy_journal"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " AND clos = 0"; - $sql.= " ORDER BY label"; - - $resql = $db->query($sql); - if ($resql) - { - $numr = $db->num_rows($resql); - $i = 0; - - if ($numr > 0) - while ($i < $numr) - { - $objp = $db->fetch_object($resql); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/bankjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_account='.$objp->rowid,$langs->trans("Journal").' - '.dol_trunc($objp->label,10),2,$user->rights->accounting->comptarapport->lire); - $i++; - } - } - else dol_print_error($db); - $db->free($resql); - - // Add other journal - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/sellsjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal",$langs->trans("SellsJournal"),2,$user->rights->accounting->comptarapport->lire); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/purchasesjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal",$langs->trans("PurchasesJournal"),2,$user->rights->accounting->comptarapport->lire); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/expensereportsjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal",$langs->trans("ExpenseReportsJournal"),2,$user->rights->accounting->comptarapport->lire); - */ } // General Ledger diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 496d054d86c..3f8a7c092b8 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -35,12 +35,12 @@ class modAccounting extends DolibarrModules * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ + */ function __construct($db) { global $conf; - $this->db = $db; + $this->db = $db; $this->numero = 50400; $this->family = "financial"; @@ -60,7 +60,7 @@ class modAccounting extends DolibarrModules $this->dirs = array('/accounting/temp'); // Config pages - $this->config_page_url = array('index.php@accountancy'); + $this->config_page_url = array(); // Dependencies $this->depends = array("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled @@ -84,116 +84,57 @@ class modAccounting extends DolibarrModules "1", "With this constants on, bank account number is always required" ); - $this->const[1] = array( - "ACCOUNTING_EXPORT_SEPARATORCSV", - "string", - "," - ); - $this->const[2] = array( + $this->const[3] = array( "ACCOUNTING_ACCOUNT_SUSPENSE", "chaine", "471" ); - $this->const[3] = array( - "ACCOUNTING_SELL_JOURNAL", - "chaine", - "VTE" - ); $this->const[4] = array( - "ACCOUNTING_PURCHASE_JOURNAL", - "chaine", - "ACH" - ); - $this->const[5] = array( - "ACCOUNTING_SOCIAL_JOURNAL", - "chaine", - "SOC" - ); - $this->const[6] = array( - "ACCOUNTING_MISCELLANEOUS_JOURNAL", - "chaine", - "OD" - ); - $this->const[7] = array( "ACCOUNTING_ACCOUNT_TRANSFER_CASH", "chaine", "58" ); - $this->const[8] = array( + $this->const[5] = array( "CHARTOFACCOUNTS", "chaine", "2" ); - $this->const[9] = array( + $this->const[6] = array( "ACCOUNTING_EXPORT_MODELCSV", "chaine", "1" ); - $this->const[10] = array( + $this->const[7] = array( "ACCOUNTING_LENGTH_GACCOUNT", "chaine", "" ); - $this->const[11] = array( + $this->const[8] = array( "ACCOUNTING_LENGTH_AACCOUNT", "chaine", "" ); - $this->const[13] = array( + $this->const[9] = array( "ACCOUNTING_LIST_SORT_VENTILATION_TODO", "yesno", "1" ); - $this->const[14] = array( + $this->const[10] = array( "ACCOUNTING_LIST_SORT_VENTILATION_DONE", "yesno", "1" ); - /* - $this->const[15] = array ( - "ACCOUNTING_GROUPBYACCOUNT", - "yesno", - "1" - ); - */ - $this->const[16] = array ( + $this->const[11] = array ( "ACCOUNTING_EXPORT_DATE", "chaine", "%d%m%Y" ); - /* - $this->const[17] = array ( - "ACCOUNTING_EXPORT_PIECE", - "yesno", - "1" + $this->const[12] = array( + "ACCOUNTING_EXPORT_SEPARATORCSV", + "string", + "," ); - $this->const[18] = array ( - "ACCOUNTING_EXPORT_GLOBAL_ACCOUNT", - "yesno", - "1" - ); - $this->const[19] = array ( - "ACCOUNTING_EXPORT_LABEL", - "yesno", - "1" - ); - $this->const[20] = array ( - "ACCOUNTING_EXPORT_AMOUNT", - "yesno", - "1" - ); - $this->const[21] = array ( - "ACCOUNTING_EXPORT_DEVISE", - "yesno", - "1" - ); - */ - $this->const[22] = array( - "ACCOUNTING_EXPENSEREPORT_JOURNAL", - "chaine", - "ER" - ); - $this->const[23] = array( + $this->const[13] = array( "ACCOUNTING_EXPORT_FORMAT", "chaine", "csv" diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 5af427242f4..79b0bf8d37b 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -274,6 +274,19 @@ CREATE TABLE llx_projet_task_comment ( import_key varchar(125) DEFAULT NULL )ENGINE=innodb; +-- Accountancy - Remove old constants +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_SELL_JOURNAL')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_PURCHASE_JOURNAL')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_SOCIAL_JOURNAL')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_MISCELLANEOUS_JOURNAL')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_GROUPBYACCOUNT')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_GLOBAL_ACCOUNT')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_LABEL')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_AMOUNT')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_DEVISE')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_PIECE')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPENSEREPORT_JOURNAL')__; + -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) CHARACTER SET utf8; From 5fd7cdff5c3178e475cb3dc457ae8e21d41cfb44 Mon Sep 17 00:00:00 2001 From: "Ahmad M. Zawawi" Date: Sat, 16 Sep 2017 10:53:16 +0300 Subject: [PATCH 008/114] Fix example comment typo --- dev/examples/code/create_user.php | 4 ++-- dev/examples/code/get_contracts.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/examples/code/create_user.php b/dev/examples/code/create_user.php index f745032f575..20173eb914a 100755 --- a/dev/examples/code/create_user.php +++ b/dev/examples/code/create_user.php @@ -60,14 +60,14 @@ $db->begin(); require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php"); -// Create invoice object +// Create user object $obj = new User($db); //$obj->initAsSpecimen(); $obj->login = 'ABCDEF'; $obj->nom = 'ABCDEF'; -// Create invoice +// Create user $idobject=$obj->create($user); if ($idobject > 0) { diff --git a/dev/examples/code/get_contracts.php b/dev/examples/code/get_contracts.php index 1262fe3eebd..fbe512300e8 100755 --- a/dev/examples/code/get_contracts.php +++ b/dev/examples/code/get_contracts.php @@ -67,7 +67,7 @@ $db->begin(); require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); -// Create invoice object +// Create contract object $obj = new Contrat($db); $obj->socid=$argv[1]; From 7ee0b1061bb1bf46a1b97cf4477c8d0d3def15e0 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sun, 17 Sep 2017 20:43:42 +0200 Subject: [PATCH 009/114] Link feature on donation --- htdocs/don/tpl/linkedobjectblock.tpl.php | 74 ++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 htdocs/don/tpl/linkedobjectblock.tpl.php diff --git a/htdocs/don/tpl/linkedobjectblock.tpl.php b/htdocs/don/tpl/linkedobjectblock.tpl.php new file mode 100644 index 00000000000..fdf6ae71c2f --- /dev/null +++ b/htdocs/don/tpl/linkedobjectblock.tpl.php @@ -0,0 +1,74 @@ + + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2014 Marcos García + * Copyright (C) 2017 Charlene Benke + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +?> + + + +load("donations"); + +$total=0; $ilink=0; +$var=true; +foreach($linkedObjectBlock as $key => $objectlink) +{ + $ilink++; + + $trclass=($var?'pair':'impair'); + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; +?> + + trans("Donation"); ?> + getNomUrl(1); ?> + ref_client; ?> + date, 'day'); ?> + total_ht; + echo price($objectlink->total_ht); + } ?> + + getLibStatut(3); ?> + + 1) +{ + ?> + + trans("Total"); ?> + + + + + + + + + + From ae2e0a70ae84140ac2eca1493322fff8a59513bf Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sun, 17 Sep 2017 20:45:00 +0200 Subject: [PATCH 010/114] Update card.php --- htdocs/don/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 6f3ab42d7fc..02498009cd9 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -765,6 +765,10 @@ if (! empty($id) && $action != 'edit') print $formfile->showdocuments('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf); + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('don')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + print '
'; print '
'; From 99149b5cfeada8c2062ae969841ef9629c01335c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 21:21:12 +0200 Subject: [PATCH 011/114] Fix box activity again --- htdocs/core/boxes/box_activity.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index a05fcf761b6..7aa5974efbd 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -438,11 +438,6 @@ class box_activity extends ModeleBoxes 'td' => 'align="center"', 'text'=>$langs->trans("NoRecordedInvoices"), ); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql), - ); } } From f76b675e092ba5053ac3dbffe8f4b1ab5d977bea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 21:24:30 +0200 Subject: [PATCH 012/114] Fix box activity again --- htdocs/core/boxes/box_activity.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 7aa5974efbd..2f923855dbb 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -147,7 +147,7 @@ class box_activity extends ModeleBoxes if (! empty($data)) { $j=0; - while ($line < count($data)) + while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -230,7 +230,7 @@ class box_activity extends ModeleBoxes if (! empty($data)) { $j=0; - while ($line < count($data)) { + while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=".$data[$j]->fk_statut, @@ -315,7 +315,7 @@ class box_activity extends ModeleBoxes if (! empty($data)) { $j=0; - while ($line < count($data)) { + while ($j < count($data)) { $billurl="search_status=2&paye=1&year=".$data[$j]->annee; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -400,7 +400,7 @@ class box_activity extends ModeleBoxes $alreadypaid=-1; - while ($line < count($data)) { + while ($j < count($data)) { $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', From eaee8ee5864c0e2b1481adc6530d2a166f885186 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 21:29:25 +0200 Subject: [PATCH 013/114] Fix box activity again --- htdocs/core/boxes/box_activity.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 2f923855dbb..71a9a4e3125 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -77,7 +77,6 @@ class box_activity extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $totalMnt = 0; $totalnb = 0; $line = 0; $cachetime = 3600; @@ -173,7 +172,6 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $data[$j]->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3), @@ -255,7 +253,6 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $data[$j]->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($data[$j]->fk_statut,0,3), @@ -342,10 +339,8 @@ class box_activity extends ModeleBoxes ); // We add only for the current year - if ($data[$j]->annee == date("Y")) { - $totalnb += $data[$j]->nb; - $totalMnt += $data[$j]->Mnttot; - } + $totalnb += $data[$j]->nb; + $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3), @@ -396,10 +391,9 @@ class box_activity extends ModeleBoxes } if (! empty($data)) { - $j=0; - $alreadypaid=-1; + $j=0; while ($j < count($data)) { $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( @@ -425,7 +419,6 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $objp->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3, $alreadypaid), From 8389555882e1aaa09cfa76b1ba5c25fadb67567c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 18 Sep 2017 10:33:54 +0200 Subject: [PATCH 014/114] Fix: wrong image url and file not present --- htdocs/admin/dolistore/class/dolistore.class.php | 4 ++-- htdocs/admin/modules.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index aff21ce58e8..f437dc66975 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -211,11 +211,11 @@ class Dolistore // add image or default ? if ($product->id_default_image != '') { - $image_url = DOL_URL_ROOT.'/dolistore/ajax/image.php?id_product='.$product->id.'&id_image='.$product->id_default_image; + $image_url = DOL_URL_ROOT.'/admin/dolistore/ajax/image.php?id_product='.$product->id.'&id_image='.$product->id_default_image; $images = ''. ''; } else { - $images = ''; + $images = ''; } // free or pay ? diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 6b7d839592c..06f7af5b8d6 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -254,7 +254,7 @@ if ($action == 'reset' && $user->admin) $form = new Form($db); -$morejs = array("/admin/dolistore/js/dolistore.js.php"); +//$morejs = array("/admin/dolistore/js/dolistore.js.php"); $morecss = array("/admin/dolistore/css/dolistore.css"); // Set dir where external modules are installed From dff4249e970ee601a8ab07993e3f206f71f43516 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 10:48:49 +0200 Subject: [PATCH 015/114] NEW Can include extrafields into member card templates --- htdocs/adherents/cartes/carte.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index be11b08c9ee..63fd59f01e9 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -46,6 +46,10 @@ $mesg=''; $adherentstatic=new Adherent($db); +$extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('adherent'); + /* * Actions @@ -65,8 +69,12 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg $sql.= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; $sql.= " t.libelle as type,"; $sql.= " c.code as country_code, c.label as country"; + // Add fields from extrafields + foreach ($extrafields->attribute_label as $key => $val) + $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; $sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; $sql.= " AND d.entity IN (".getEntity('adherent').")"; if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid; @@ -85,9 +93,27 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg if ($objp->country == '-') $objp->country=''; + $adherentstatic->id=$objp->rowid; $adherentstatic->lastname=$objp->lastname; $adherentstatic->firstname=$objp->firstname; + // format extrafiled so they can be parsed in function complete_substitutions_array + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + $adherentstatic->array_options = array(); + foreach($extrafields->attribute_label as $key => $val) + { + $tmpkey='options_'.$key; + if (!empty($objp->$tmpkey)) + { + $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey; + } + //if (!empty($objp->$key)) + // $objp->array_options[$tmpkey] = $objp->$key; + //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey; + } + } + // List of values to scan for a replacement $substitutionarray = array ( '%ID%'=>$objp->rowid, @@ -110,7 +136,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" ); - complete_substitutions_array($substitutionarray, $langs); + complete_substitutions_array($substitutionarray, $langs, $adherentstatic); // For business cards if (empty($mode) || $mode=='card' || $mode=='cardlogin') From bb0cb8adf470bf50848291c855f6b0fd4d5ffc28 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 18 Sep 2017 11:04:55 +0200 Subject: [PATCH 016/114] Fix: remove unused file --- htdocs/admin/dolistore/class/init.php | 72 --------------------------- 1 file changed, 72 deletions(-) delete mode 100644 htdocs/admin/dolistore/class/init.php diff --git a/htdocs/admin/dolistore/class/init.php b/htdocs/admin/dolistore/class/init.php deleted file mode 100644 index 4a94e08002c..00000000000 --- a/htdocs/admin/dolistore/class/init.php +++ /dev/null @@ -1,72 +0,0 @@ -CRUD Tutorial - Customer's list - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -* PrestaShop Webservice Library -* @package PrestaShopWebservice -*/ -// Here we define constants /!\ You need to replace this parameters -//https://dolistorecatalogpublickey1234567@vmdevwww.dolistore.com/api/ -define('DEBUG', true); // Debug mode -define('PS_SHOP_PATH', 'https://www.dolistore.com/'); // Root path of your PrestaShop store -define('PS_WS_AUTH_KEY', 'dolistorecatalogpublickey1234567'); // Auth key (Get it in your Back Office) -require_once('./PSWebServiceLibrary.php'); -// Here we make the WebService Call -try -{ - $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); - - // Here we set the option array for the Webservice : we want customers resources - $opt['resource'] = 'categories'; - $opt['id'] = '1'; - - // Call - $xml = $webService->get($opt); - // Here we get the elements from children of customers markup "customer" - $resources = $xml->categories->children(); -} -catch (PrestaShopWebserviceException $e) -{ - // Here we are dealing with errors - $trace = $e->getTrace(); - if ($trace[0]['args'][0] == 404) echo 'Bad ID'; - else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; - else echo 'Other error'; -} -// We set the Title -echo "

Categories's List

"; -echo ''; -// if $resources is set we can lists element in it otherwise do nothing cause there's an error -if (isset($resources)) -{ - echo ''; - foreach ($resources as $resource) - { - // Iterates on the found IDs - echo ''; - } -} -echo '
Id
'.$resource->attributes().'
'; -?> - \ No newline at end of file From 230644070bac11a568659bc20a8747547dfb392c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 11:42:05 +0200 Subject: [PATCH 017/114] Better detection of log to include merge labels --- build/makepack-dolibarr.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 80cc9b0856c..e0fa89d924d 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -366,7 +366,9 @@ if ($nboftargetok) { } else # For a maintenance release { - print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; + #print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; + print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. | grep -v "Merge branch" | grep -v "Merge pull" | grep "^ " | sed -e "s/^[0-9a-z]* *//" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; + } print "\n"; if (! $ret) From 85d59b32b34ff6afd5eca8c5c9c67a6feaab58a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 13:15:24 +0200 Subject: [PATCH 018/114] Add timespent entry into HR top menu too Faster update of total of timespent --- htdocs/core/lib/project.lib.php | 9 +++++---- htdocs/core/menus/standard/eldy.lib.php | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 0395f9f17ff..f220c2f6542 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -175,7 +175,7 @@ function task_prepare_head($object) // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'task'); - + // Manage discussion if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) { @@ -198,7 +198,7 @@ function task_prepare_head($object) $head[$h][2] = 'task_notes'; $h++; } - + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); $filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -971,8 +971,9 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ } $tableCell.=''; - $tableCell.=''; + $tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"'; + $tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />'; + $tableCell.=''; print $tableCell; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 395c883cbe3..fb503cfea9d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1382,6 +1382,18 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/expensereport/list.php?search_status=2&leftmenu=expensereport&mainmenu=hrm", $langs->trans("ListToApprove"), 2, $user->rights->expensereport->approve); $newmenu->add("/expensereport/stats/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->expensereport->lire); } + + if (! empty($conf->projet->enabled)) + { + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + $langs->load("projects"); + + $search_project_user = GETPOST('search_project_user','int'); + + $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user?'&search_project_user='.$search_project_user:''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire); + } + } } From da6b1e92b2bb59110a3da802fbb85666d6700098 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 14:18:34 +0200 Subject: [PATCH 019/114] NEW Add the total in the perday view of the time spent form. --- htdocs/core/class/html.form.class.php | 4 +-- htdocs/core/js/timesheet.js | 50 +++++++++++++++++++++++++++ htdocs/core/lib/project.lib.php | 11 ++++++ htdocs/projet/activity/perday.php | 19 ++++++++-- htdocs/projet/activity/perweek.php | 1 - 5 files changed, 79 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0260effebc6..bca87c7a65f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5041,7 +5041,7 @@ class Form } elseif ($typehour=='text' || $typehour=='textselect') { - $retstring.=''; + $retstring.=''; } else return 'BadValueForParameterTypeHour'; @@ -5065,7 +5065,7 @@ class Form } elseif ($typehour=='text' ) { - $retstring.=''; + $retstring.=''; } if ($typehour!='text') $retstring.=' '.$langs->trans('MinuteShort'); diff --git a/htdocs/core/js/timesheet.js b/htdocs/core/js/timesheet.js index 5541f348c9f..a55424f8e8c 100644 --- a/htdocs/core/js/timesheet.js +++ b/htdocs/core/js/timesheet.js @@ -163,6 +163,56 @@ function updateTotal(days,mode) } } } + + // Add data on the perday view + jQuery('.inputhour').each(function( index ) { + if (this.value) + { + var taskTime= new Date(0); + /*console.log(total.getHours()) + console.log(this.value) + alert(element.value);*/ + if (this.value) + { + console.log(this.value+':00') + result=parseTime(this.value+':00',taskTime); + } + else + { + result=parseTime(this.innerHTML+':00',taskTime); + } + if (result >= 0) + { + total.setHours(total.getHours()+taskTime.getHours()); + } + console.log(total.getHours()) + } + }); + // Add data on the perday view + jQuery('.inputminute').each(function( index ) { + if (this.value) + { + var taskTime= new Date(0); + /* console.log(total.getHours()) + console.log(this.value) + alert(element.value);*/ + if (this.value) + { + console.log('00:'+this.value) + result=parseTime('00:'+"00".substring(0, 2 - this.value.length) + this.value,taskTime); + } + else + { + result=parseTime('00:'+"00".substring(0, 2 - this.innerHTML) + this.innerHTML,taskTime); + } + if (result >= 0) + { + total.setMinutes(total.getMinutes()+taskTime.getMinutes()); + } + console.log(total.getMinutes()) + } + }); + if (document.getElementById('totalDay['+days+']')) // May be null if no task records to output (nbline is also 0 in this case) { document.getElementById('totalDay['+days+']').innerHTML = pad(total.getHours())+':'+pad(total.getMinutes()); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index f220c2f6542..8233251d815 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -739,6 +739,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $alreadyspent=''; if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); + $idw = 0; + $tableCell=''; $tableCell.=''; $tableCell.=' + '; @@ -746,6 +748,15 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1); //$tableCell.=' '; print $tableCell; + + $modeinput='hours'; + + print ''; + print ''; print ''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 4dff34ad30b..da789675cb8 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -332,8 +332,7 @@ $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($proj //var_dump($projectsrole); //var_dump($taskrole); - -llxHeader("",$title,""); +llxHeader("",$title,"",'','','',array('/core/js/timesheet.js')); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); @@ -489,6 +488,16 @@ if (count($tasksarray) > 0) { $j=0; projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse); + + $colspan = 8; + if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) $colspan++; + + print ' + '.$langs->trans("Total").' +
 
+ + + '; } else { @@ -497,16 +506,20 @@ else print ""; print ''; +print ''."\n"; + print '
'; print ''; print '
'; print ''; +$modeinput='hours'; print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 6ea60f3d76f..c0482967c9e 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -515,7 +515,6 @@ else print ""; print ''; -print ''."\n"; print ''."\n"; print '
'; From 0536d6cbed522893ddbfd3ce7c69847a8eac8fee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 15:46:17 +0200 Subject: [PATCH 020/114] FIX #7330 --- htdocs/contrat/list.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 17246751600..221a4233f5a 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Juanjo Menent @@ -271,11 +271,8 @@ $sql.= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.re $sql.= ' s.rowid, s.nom, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql.= " typent.code,"; $sql.= " state.code_departement, state.nom"; -// Add where from extra fields -foreach ($extrafields->attribute_label as $key => $val) -{ - $sql .= ', ef.'.$key; -} +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook From 6ac1b6e82eed373a7a0d061a3961268f6dd2689d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 15:48:04 +0200 Subject: [PATCH 021/114] Fix template --- htdocs/modulebuilder/template/myobject_list.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 96b7d7ca733..c4e7875e89a 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -237,6 +237,21 @@ foreach ($search_array_options as $key => $val) $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; + +/* If a group by is required +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +*/ + $sql.=$db->order($sortfield,$sortorder); // Count total nb of records From aba907d1a8805e1133f8fe337593674d177a7b93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 15:49:21 +0200 Subject: [PATCH 022/114] FIX #7420 --- htdocs/includes/odtphp/Segment.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/includes/odtphp/Segment.php b/htdocs/includes/odtphp/Segment.php index 40668215647..525cd5b4f3f 100644 --- a/htdocs/includes/odtphp/Segment.php +++ b/htdocs/includes/odtphp/Segment.php @@ -24,7 +24,7 @@ class Segment implements IteratorAggregate, Countable protected $images = array(); protected $odf; protected $file; - + /** * Constructor * @@ -86,15 +86,15 @@ class Segment implements IteratorAggregate, Countable */ public function merge() { - // To provide debug information on line number processed + // To provide debug information on line number processed global $count; if (empty($count)) $count=1; else $count++; - + if (empty($this->savxml)) $this->savxml = $this->xml; // Sav content of line at first line merged, so we will reuse original for next steps $this->xml = $this->savxml; $tmpvars = $this->vars; // Store into $tmpvars so we won't modify this->vars when completing data with empty values - + // Search all tags fou into condition to complete $tmpvars, so we will proceed all tests even if not defined $reg='@\[!--\sIF\s([{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; preg_match_all($reg, $this->xml, $matches, PREG_SET_ORDER); @@ -106,7 +106,7 @@ class Segment implements IteratorAggregate, Countable $tmpvars[$match[1]] = ''; // Not defined, so we set it to '', we just need entry into this->vars for next loop } } - + // Conditionals substitution // Note: must be done before static substitution, else the variable will be replaced by its value and the conditional won't work anymore foreach($tmpvars as $key => $value) @@ -133,7 +133,7 @@ class Segment implements IteratorAggregate, Countable $this->xml = preg_replace($reg, '', $this->xml); } } - + $this->xmlParsed .= str_replace(array_keys($tmpvars), array_values($tmpvars), $this->xml); if ($this->hasChildren()) { foreach ($this->children as $child) { @@ -143,7 +143,7 @@ class Segment implements IteratorAggregate, Countable } $reg = "/\[!--\sBEGIN\s$this->name\s--\](.*)\[!--\sEND\s$this->name\s--\]/sm"; $this->xmlParsed = preg_replace($reg, '$1', $this->xmlParsed); - // Miguel Erill 09704/2017 - Add macro replacement to invoice lines + // Miguel Erill 09704/2017 - Add macro replacement to invoice lines $this->xmlParsed = $this->macroReplace($this->xmlParsed); $this->file->open($this->odf->getTmpfile()); foreach ($this->images as $imageKey => $imageValue) { @@ -155,28 +155,28 @@ class Segment implements IteratorAggregate, Countable } } $this->file->close(); - + return $this->xmlParsed; } /** * Function to replace macros for invoice short and long month, invoice year - * + * * Substitution occur when the invoice is generated, not considering the invoice date * so do not (re)generate in a diferent date than the one that the invoice belongs to * Perhaps it would be better to use the invoice issued date but I still do not know * how to get it here * * Miguel Erill 09/04/2017 - * + * * @param string $value String to convert */ public function macroReplace($text) { global $langs; - $patterns=array( '__CURRENTDAY__','__CURRENTDAYTEXT__','__CURRENTMONTHSHORT__','__CURRENTMONTH__','__CURRENTYEAR__' ); - $values=array( date('j'), $langs->trans(date('l')), $langs->trans(date('M')), $langs->trans(date('F')), date('Y') ); + $patterns=array('/__CURRENTDAY__/','/__CURRENTDAYTEXT__/','/__CURRENTMONTHSHORT__/','/__CURRENTMONTH__/','/__CURRENTYEAR__/'); + $values=array(date('j'), $langs->trans(date('l')), $langs->trans(date('M')), $langs->trans(date('F')), date('Y')); $text=preg_replace($patterns, $values, $text); @@ -203,7 +203,7 @@ class Segment implements IteratorAggregate, Countable } return $this; } - + /** * Assign a template variable to replace * From c11ff4a18c7f488b3588793451165370f28beb4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 15:55:25 +0200 Subject: [PATCH 023/114] FIX #7368 --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 1 + htdocs/install/mysql/migration/repair.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 14990f1bfdc..3a5810d19e4 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -510,6 +510,7 @@ ALTER TABLE llx_user_rights DROP FOREIGN KEY fk_user_rights_fk_user_user; ALTER TABLE llx_user_rights DROP INDEX uk_user_rights; ALTER TABLE llx_user_rights DROP INDEX fk_user; ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (entity, fk_user, fk_id); +DELETE FROM llx_user_rights WHERE fk_user NOT IN (select rowid from llx_user); ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); ALTER TABLE llx_usergroup_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 59be09bcb8b..3a61ef4b216 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -89,6 +89,7 @@ delete from llx_livraison where ref = ''; delete from llx_expeditiondet where fk_expedition in (select rowid from llx_expedition where ref = ''); delete from llx_expedition where ref = ''; delete from llx_holiday_logs where fk_user_update not IN (select rowid from llx_user); +delete from llx_user_rights where fk_user not IN (select rowid from llx_user); update llx_deplacement set dated='2010-01-01' where dated < '2000-01-01'; From 70b11f18b51fac1f679080f832c3931e825468f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 16:06:58 +0200 Subject: [PATCH 024/114] FIX #7367 --- htdocs/core/lib/files.lib.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 9ff9ec0df63..b1031153507 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1559,7 +1559,7 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile= } /** - * Convert an image file into anoher format. + * Convert an image file into another format. * This need Imagick php extension. * * @param string $fileinput Input file name @@ -1567,14 +1567,19 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile= * @param string $fileoutput Output filename * @return int <0 if KO, 0=Nothing done, >0 if OK */ -function dol_convert_file($fileinput,$ext='png',$fileoutput='') +function dol_convert_file($fileinput, $ext='png', $fileoutput='') { global $langs; if (class_exists('Imagick')) { $image=new Imagick(); - $ret = $image->readImage($fileinput); + try { + $ret = $image->readImage($fileinput); + } catch(Exception $e) { + dol_syslog("Failed to read image using Imagick. Try to install package 'apt-get install ghostscript'.", LOG_WARNING); + return 0; + } if ($ret) { $ret = $image->setImageFormat($ext); From cdd1473cfa00a7bc7bed8b767defe36a40fa1436 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 18 Sep 2017 16:30:01 +0200 Subject: [PATCH 025/114] Fix: avoid Warning: A non-numeric value encountered --- htdocs/product/price.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index b03a8763770..7c58069585e 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1,9 +1,9 @@ +/* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2015 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2014 Florian Henry * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2014-2015 Philippe Grand @@ -1171,7 +1171,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) } print ''; print ''; - + $parameters=array('colspan' => 2); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -1493,10 +1493,8 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); - $page = GETPOST("page", 'int'); - if ($page == - 1) { - $page = 0; - } + $page = (GETPOST("page",'int')?GETPOST("page", 'int'):0); + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; From ee99483b0def49e496f7abcf233b8127a51e9385 Mon Sep 17 00:00:00 2001 From: Kjeld Borch Egevang Date: Mon, 18 Sep 2017 22:30:08 +0200 Subject: [PATCH 026/114] Changed "Solde" to "Balance". --- htdocs/accountancy/bookkeeping/balance.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index c6d0d5cf40e..382d0697b6a 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -210,7 +210,7 @@ else { print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $options, "", $sortfield, $sortorder); print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("Solde", $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print "\n"; @@ -280,4 +280,4 @@ else { llxFooter(); } -$db->close(); \ No newline at end of file +$db->close(); From 9838199de148579753f5602dadf6c5924c6827ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 23:31:07 +0200 Subject: [PATCH 027/114] FIX Sign of amount in origin currency on credit note created from lines --- htdocs/compta/facture/card.php | 17 +++++++++++------ htdocs/compta/facture/class/facture.class.php | 7 ++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 82eeb3d49c0..c66285ae0c8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -841,13 +841,18 @@ if (empty($reshook)) $line->fk_facture = $object->id; $line->fk_parent_line = $fk_parent_line; - $line->subprice =-$line->subprice; // invert price for object + $line->subprice = -$line->subprice; // invert price for object $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here - $line->total_ht=-$line->total_ht; - $line->total_tva=-$line->total_tva; - $line->total_ttc=-$line->total_ttc; - $line->total_localtax1=-$line->total_localtax1; - $line->total_localtax2=-$line->total_localtax2; + $line->total_ht = -$line->total_ht; + $line->total_tva = -$line->total_tva; + $line->total_ttc = -$line->total_ttc; + $line->total_localtax1 = -$line->total_localtax1; + $line->total_localtax2 = -$line->total_localtax2; + + $line->multicurrency_subprice = -$line->multicurrency_subprice; + $line->multicurrency_total_ht = -$line->multicurrency_total_ht; + $line->multicurrency_total_tva = -$line->multicurrency_total_tva; + $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9cc9a63f313..c3b58117dd7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1568,7 +1568,7 @@ class Facture extends CommonInvoice $facligne->desc=$remise->description; // Description ligne $facligne->vat_src_code=$remise->vat_src_code; $facligne->tva_tx=$remise->tva_tx; - $facligne->subprice=-$remise->amount_ht; + $facligne->subprice = -$remise->amount_ht; $facligne->fk_product=0; // Id produit predefini $facligne->qty=1; $facligne->remise_percent=0; @@ -1591,6 +1591,11 @@ class Facture extends CommonInvoice $facligne->total_tva = -$remise->amount_tva; $facligne->total_ttc = -$remise->amount_ttc; + $facligne->multicurrency_subprice = -$remise->multicurrency_subprice; + $facligne->multicurrency_total_ht = -$remise->multicurrency_total_ht; + $facligne->multicurrency_total_tva = -$remise->multicurrency_total_tva; + $facligne->multicurrency_total_ttc = -$remise->multicurrency_total_ttc; + $lineid=$facligne->insert(); if ($lineid > 0) { From f936b17d68928caf7c8af9131a2276e837f1faa4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 00:24:52 +0200 Subject: [PATCH 028/114] FIX Protection to avoid to apply credit note discount > remain to pay --- htdocs/comm/remx.php | 24 +++++++++--------- htdocs/compta/facture/card.php | 37 ++++++++++++++++++++-------- htdocs/core/class/discount.class.php | 7 ++++++ htdocs/langs/en_US/bills.lang | 1 + htdocs/langs/en_US/errors.lang | 2 +- 5 files changed, 48 insertions(+), 23 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 9964db9ecde..94142b6ec54 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -125,7 +125,7 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') if ($res > 0 && $newid1 > 0 && $newid2 > 0) { $db->commit(); - header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage?'&backtopage='.urlencode($backtopage):'')); // To avoid pb whith back exit; } else @@ -275,13 +275,13 @@ if ($socid > 0) print ''; print '
'; - + if ($user->rights->societe->creer) { print '
'; - + print load_fiche_titre($langs->trans("NewGlobalDiscount"),'',''); - + print '
'; print ''; print ''; @@ -293,7 +293,7 @@ if ($socid > 0) print ''; print ''; print ''; - + print "
'.$langs->trans("AmountHT").'
'.$langs->trans("NoteReason").'
"; } @@ -362,7 +362,7 @@ if ($socid > 0) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print ''.dol_print_date($db->jdate($obj->dc),'dayhour').''; if (preg_match('/\(CREDIT_NOTE\)/',$obj->description)) @@ -408,14 +408,14 @@ if ($socid > 0) if ($user->rights->societe->creer || $user->rights->facture->creer) { print ''; - print 'rowid.'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_split($langs->trans("SplitDiscount")).''; print '   '; - print 'rowid.'">'.img_delete($langs->trans("RemoveDiscount")).''; + print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ''; } else print ' '; print ''; - + if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid) { $showconfirminfo['rowid']=$obj->rowid; @@ -427,7 +427,7 @@ if ($socid > 0) else { print ''.$langs->trans("None").''; - } + } $db->free($resql); print ""; @@ -441,7 +441,7 @@ if ($socid > 0) array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') ); $langs->load("dict"); - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'], $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount',price($showconfirminfo['amount_ttc']),$langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage?'&backtopage='.urlencode($backtopage):''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount',price($showconfirminfo['amount_ttc']),$langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); } } else @@ -590,7 +590,7 @@ if ($socid > 0) { print ''.$langs->trans("None").''; } - + print ""; } else diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c66285ae0c8..6cfed39a02f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -378,7 +378,9 @@ if (empty($reshook)) else if ($action == "setabsolutediscount" && $user->rights->facture->creer) { - // POST[remise_id] ou POST[remise_id_for_payment] + // POST[remise_id] or POST[remise_id_for_payment] + + // We use the credit to reduce amount of invoice if (! empty($_POST["remise_id"])) { $ret = $object->fetch($id); if ($ret > 0) { @@ -390,14 +392,28 @@ if (empty($reshook)) dol_print_error($db, $object->error); } } - if (! empty($_POST["remise_id_for_payment"])) { + // We use the credit to reduce remain to pay + if (! empty($_POST["remise_id_for_payment"])) + { require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; $discount = new DiscountAbsolute($db); $discount->fetch($_POST["remise_id_for_payment"]); - $result = $discount->link_to_invoice(0, $id); - if ($result < 0) { - setEventMessages($discount->error, $discount->errors, 'errors'); + //var_dump($object->getRemainToPay(0)); + //var_dump($discount->amount_ttc);exit; + if ($discount->amount_ttc > $object->getRemainToPay(0)) + { + // TODO Split the discount in 2 automatically + $error++; + setEventMessages($langs->trans("ErrorDiscountLargerThanRemainToPaySplitItBefore"), null, 'errors'); + } + + if (! $error) + { + $result = $discount->link_to_invoice(0, $id); + if ($result < 0) { + setEventMessages($discount->error, $discount->errors, 'errors'); + } } } } @@ -3175,6 +3191,7 @@ else if ($id > 0 || ! empty($ref)) $addrelativediscount = '' . $langs->trans("EditRelativeDiscounts") . ''; $addabsolutediscount = '' . $langs->trans("EditGlobalDiscounts") . ''; $addcreditnote = '' . $langs->trans("AddCreditNote") . ''; + $viewabsolutediscount = '' . $langs->trans("ViewAvailableGlobalDiscounts") . ''; print '' . $langs->trans('Discounts'); print ''; @@ -3184,7 +3201,7 @@ else if ($id > 0 || ! empty($ref)) print $langs->trans("CompanyHasNoRelativeDiscount"); // print ' ('.$addrelativediscount.')'; - // Is there commercial discount or down payment available ? + // Is there is commercial discount or down payment available ? if ($absolute_discount > 0) { print '. '; if ($object->statut > 0 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { @@ -3209,7 +3226,7 @@ else if ($id > 0 || ! empty($ref)) } else { if ($absolute_creditnote > 0) // If not, link will be added later { - if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) + if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' (' . $addabsolutediscount . ')
'; else print '. '; @@ -3220,7 +3237,7 @@ else if ($id > 0 || ! empty($ref)) if ($absolute_creditnote > 0) { // If validated, we show link "add credit note to payment" - if ($object->statut != 1 || $object->type == Facture::TYPE_CREDIT_NOTE) { + if ($object->statut != Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_CREDIT_NOTE) { if ($object->statut == 0 && $object->type != Facture::TYPE_DEPOSIT) { $text = $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)); print $form->textwithpicto($text, $langs->trans("CreditNoteDepositUse")); @@ -3231,13 +3248,13 @@ else if ($id > 0 || ! empty($ref)) // There is credit notes discounts available if (! $absolute_discount) print '
'; // $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer); - $more=' ('.$addcreditnote.')'; + $more=' ('.$addcreditnote. (($addcreditnote && $viewabsolutediscount) ? ' - ' : '') . $viewabsolutediscount . ')'; $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0, $more); // We allow credit note even if amount is higher } } if (! $absolute_discount && ! $absolute_creditnote) { print $langs->trans("CompanyHasNoAbsoluteDiscount"); - if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) + if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' (' . $addabsolutediscount . ')
'; else print '. '; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 443534eb1b3..89bb230d34f 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -78,6 +78,7 @@ class DiscountAbsolute $sql = "SELECT sr.rowid, sr.fk_soc,"; $sql.= " sr.fk_user,"; $sql.= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx,"; + $sql.= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,"; $sql.= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.description,"; $sql.= " sr.datec,"; $sql.= " f.facnumber as ref_facture_source"; @@ -97,9 +98,15 @@ class DiscountAbsolute $this->id = $obj->rowid; $this->fk_soc = $obj->fk_soc; + $this->amount_ht = $obj->amount_ht; $this->amount_tva = $obj->amount_tva; $this->amount_ttc = $obj->amount_ttc; + + $this->multicurrency_amount_ht = $obj->multicurrency_amount_ht; + $this->multicurrency_amount_tva = $obj->multicurrency_amount_tva; + $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc; + $this->tva_tx = $obj->tva_tx; $this->fk_user = $obj->fk_user; $this->fk_facture_line = $obj->fk_facture_line; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 189ef5c1fe2..df00aec79fe 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -338,6 +338,7 @@ DateIsNotEnough=Date not reached yet InvoiceGeneratedFromTemplate=Invoice %s generated from recurring template invoice %s WarningInvoiceDateInFuture=Warning, the invoice date is higher than current date WarningInvoiceDateTooFarInFuture=Warning, the invoice date is too far from current date +ViewAvailableGlobalDiscounts=View available discounts # PaymentConditions Statut=Status PaymentConditionShortRECEP=Due Upon Receipt diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 8dfc02c49f1..e42e701bb3a 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -196,7 +196,7 @@ ErrorBadLinkSourceSetButBadValueForRef=The link you use is not valid. A 'source' ErrorTooManyErrorsProcessStopped=Too many errors. Process was stopped. ErrorOnlyInvoiceValidatedCanBeSentInMassAction=Only validated invoices can be sent using the "Send by email" mass action. ErrorChooseBetweenFreeEntryOrPredefinedProduct=You must choose if article is a predefined product or not - +ErrorDiscountLargerThanRemainToPaySplitItBefore=The discount you try to apply is larger than remain to pay. Split the discount in 2 smaller discounts before. # Warnings WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. WarningMandatorySetupNotComplete=Mandatory setup parameters are not yet defined From 1e33495f429fb6b346b85a235aa23ecc856ae84a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 00:31:51 +0200 Subject: [PATCH 029/114] Fix remove warnings --- htdocs/accountancy/admin/account.php | 10 ++++------ htdocs/comm/mailing/advtargetemailing.php | 14 +++++++------- htdocs/product/stats/commande_fournisseur.php | 14 +++++++------- htdocs/product/stats/propal.php | 12 +++++++----- htdocs/product/stats/supplier_proposal.php | 12 +++++++----- htdocs/societe/price.php | 4 +--- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 5c4e836986e..fb48bc8094f 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -53,12 +53,10 @@ if (! $user->rights->accounting->chartofaccount) accessforbidden(); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'sortorder'); -$page = GETPOST("page", 'int'); -if ($page == - 1) { - $page = 0; -} +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 39d1b7c8d8d..cfafdaa725b 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -45,13 +45,13 @@ if (! empty($conf->categorie->enabled)) { if (! $user->rights->mailing->lire || $user->societe_id > 0) accessforbidden(); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); -if ($page == - 1) { - $page = 0; -} -$offset = $conf->liste_limit * $page; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 4b9aa67236e..17d4bb5f962 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -51,13 +51,13 @@ $hookmanager->initHooks(array ( $mesg = ''; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); -if ($page == - 1) { - $page = 0; -} -$offset = $conf->liste_limit * $page; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 3f6eae0bfce..aa2c9a8e603 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -48,11 +48,13 @@ $hookmanager->initHooks(array ('productstatspropal')); $mesg = ''; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); -if ($page == - 1) { $page = 0;} -$offset = $conf->liste_limit * $page; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder = "DESC"; diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index 1e0cefc3150..9406ade286f 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -48,11 +48,13 @@ $hookmanager->initHooks(array ('productstatspropal')); $mesg = ''; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); -if ($page == - 1) { $page = 0;} -$offset = $conf->liste_limit * $page; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder = "DESC"; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 515aef60a6a..fc864bd5e01 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -237,9 +237,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $sortorder = GETPOST("sortorder", 'alpha'); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page", 'int'); - if ($page == - 1) { - $page = 0; - } + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; From 89bfb81cc75a196c8af67576d156747fc3d99fec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 01:05:13 +0200 Subject: [PATCH 030/114] Fix repair --- htdocs/install/repair.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 7fc3744e334..a93081cd5b2 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -211,7 +211,8 @@ if ($ok) $extrafields=new ExtraFields($db); $listofmodulesextra=array('societe'=>'societe','adherent'=>'adherent','product'=>'product', 'socpeople'=>'socpeople', 'commande'=>'commande', 'facture'=>'facture', - 'commande_fournisseur'=>'commande_fournisseur', 'actioncomm'=>'actioncomm', + 'supplier_proposal'=>'supplier_proposal', 'commande_fournisseur'=>'commande_fournisseur', 'facture_fourn'=>'facture_fourn', + 'actioncomm'=>'actioncomm', 'adherent_type'=>'adherent_type','user'=>'user','projet'=>'projet', 'projet_task'=>'projet_task'); print '
*** Check fields into extra table structure match table of definition. If not add column into table'; foreach($listofmodulesextra as $tablename => $elementtype) @@ -303,6 +304,10 @@ if ($ok) print " \n"; } + else + { + dol_print_error($db); + } } } From b723d2c2d2604cfd513de68ea8a958f37bbf406d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 01:39:22 +0200 Subject: [PATCH 031/114] Fix scrutinizer bugs --- htdocs/core/actions_massactions.inc.php | 4 ++-- htdocs/core/lib/agenda.lib.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b17c047860a..2ac0b3a5885 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -147,11 +147,11 @@ if (! $error && $massaction == 'confirm_presend') foreach($receiver as $key=>$val) { // Recipient was provided from combo list - if ($val == 'thirdparty') // Id of third party + if ($val == 'thirdparty') // Id of third party or user { $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; } - elseif ($val) // Id du contact + elseif ($val && method_exists($thirdparty, 'contact_get_property')) // Id of contact { $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); $sendtoid[] = $val; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index a1571f7ac08..526e6386f0f 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -54,6 +54,9 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh $langs->load("companies"); + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + // Filters print '
'; print ''; @@ -95,9 +98,6 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; } - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - // Type print ''; print ''; From 978702d04b3ded8ea709f41b45726d65eaa2d046 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 01:41:57 +0200 Subject: [PATCH 032/114] Fix false deprecated warning --- htdocs/core/lib/json.lib.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 55bfcf96061..425b5713565 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -46,7 +46,7 @@ if (! function_exists('json_encode')) */ function dol_json_encode($elements) { - dol_syslog("For better permorfance, enable the native json in your PHP", LOG_WARNING); + dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); $num=0; if (is_object($elements)) // Count number of properties for an object @@ -225,12 +225,11 @@ if (! function_exists('json_decode')) * @param string $json Json encoded to PHP Object or Array * @param bool $assoc False return an object, true return an array. Try to always use it with true ! * @return mixed Object or Array or false on error - * @deprecated PHP >= 5.3 supports native json_decode * @see json_decode() */ function dol_json_decode($json, $assoc=false) { - dol_syslog('dol_json_decode() is deprecated. Please update your code to use native json_decode().', LOG_WARNING); + dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); $comment = false; From 0b67ac36f144ed3ac6320cc2d2ebf2f2cf1316f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 02:01:05 +0200 Subject: [PATCH 033/114] Show image on tool page --- htdocs/core/tools.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tools.php b/htdocs/core/tools.php index 51378c9246a..8010f726c4f 100644 --- a/htdocs/core/tools.php +++ b/htdocs/core/tools.php @@ -49,7 +49,8 @@ print load_fiche_titre($text); print $langs->trans("ToolsDesc").'

'; - +// Show logo +print '
'; llxFooter(); From 7375afca3ecd6e0916b2905fdd02da84f0b18c91 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 19 Sep 2017 09:03:25 +0200 Subject: [PATCH 034/114] fix : rest API URL --- htdocs/api/admin/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index 218ab58467e..f2c5160db38 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -128,7 +128,7 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain // Show message $message=''; -$url=$urlwithroot.'/api/index.php/login?login=auserlogin&userpassword=thepassword[&reset=1]'; +$url=$urlwithroot.'/api/index.php/login?login=auserlogin&password=thepassword[&reset=1]'; $message.=$langs->trans("UrlToGetKeyToUseAPIs").':
'; $message.=img_picto('','object_globe.png').' '.$url; print $message; From 77d1a150160ac9a1e13cb2b14a314e08d4bac8a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 12:03:48 +0200 Subject: [PATCH 035/114] Activate warning for french "Loi Finance 2016" --- htdocs/core/modules/modCashDesk.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index f153631dc20..33b44297628 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -70,7 +70,7 @@ class modCashDesk extends DolibarrModules $this->phpmin = array(4,1); // Minimum version of PHP required by module $this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module $this->langfiles = array("cashdesk"); - //$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') + $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') //$this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') // Constants From 815d0aff900af35cc5d9e819c143df1862a5ad90 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 19 Sep 2017 15:10:18 +0200 Subject: [PATCH 036/114] FIX for free line select unit was wrong --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a684cff7165..32480e5cf15 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3274,7 +3274,7 @@ class Form $return= ''; @@ -1008,8 +1015,8 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $level++; if ($lines[$i]->id > 0) { - if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $var); - else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $var); + if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable); + else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable); } $level--; } @@ -1163,7 +1170,6 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks= $sql2.= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee"; $sql2.= " ORDER BY p.title, p.ref"; - $var=true; $resql = $db->query($sql2); if ($resql) { diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index ad9ead401dd..10589c9d0b4 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -284,7 +284,7 @@ class Holiday extends CommonObject * @param string $filter SQL Filter * @return int -1 if KO, 1 if OK, 2 if no result */ - function fetchByUser($user_id,$order='',$filter='') + function fetchByUser($user_id, $order='', $filter='') { global $langs, $conf; @@ -692,13 +692,17 @@ class Holiday extends CommonObject } /** - * verifDateHolidayCP + * Check if a user is on holiday (partially or completely) into a period. + * This function can be used to avoid to have 2 leave requests on same period for example. + * Warning: It consumes a lot of memory because it load in ->holiday all holiday of a dedicated user at each call. * * @param int $fk_user Id user - * @param date $dateDebut Start date - * @param date $dateFin End date - * @param int $halfday Tag to define half day when holiday start and end - * @return boolean + * @param date $dateDebut Start date of period to check + * @param date $dateFin End date of period to check + * @param int $halfday Tag to define how start and end the period to check: + * 0:Full days, 2:Sart afternoon end monring, -1:Start afternoon, 1:End morning + * @return boolean False is on holiday at least partially into the period, True is never on holiday during chcked period. + * @see verifDateHolidayForTimestamp */ function verifDateHolidayCP($fk_user, $dateDebut, $dateFin, $halfday=0) { @@ -710,14 +714,103 @@ class Holiday extends CommonObject if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays // TODO Also use halfday for the check - if ($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut']) - { - return false; - } + if ($halfday == 0) + { + if ($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut']) + { + return false; + } + } + elseif ($halfday == -1) + { + if ($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut']) + { + return false; + } + } + elseif ($halfday == 1) + { + if ($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut']) + { + return false; + } + } + elseif ($halfday == 2) + { + if ($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut']) + { + return false; + } + } + else + { + dol_print_error('', 'Bad value of parameter halfday when calling function verifDateHolidayCP'); + } } return true; + } + + /** + * Check a user is not on holiday for a particular timestamp + * + * @param int $fk_user Id user + * @param timestamp $timestamp Time stamp date for a day (YYYY-MM-DD) without hours (= 12:00AM in english and not 12:00PM that is 12:00) + * @return array array('morning'=> ,'afternoon'=> ), Boolean is true if user is available for day timestamp. + * @see verifDateHolidayCP + */ + function verifDateHolidayForTimestamp($fk_user, $timestamp) + { + global $langs, $conf; + + $isavailablemorning=true; + $isavailableafternoon=true; + + $sql = "SELECT cp.rowid, cp.date_debut as date_start, cp.date_fin as date_end, cp.halfday"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; + $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; + $sql.= " AND cp.fk_user = ".(int) $fk_user; + $sql.= " AND date_debut <= '".$this->db->idate($timestamp)."' AND date_fin >= '".$this->db->idate($timestamp)."'"; + + $resql = $this->db->query($sql); + if ($resql) + { + $num_rows = $this->db->num_rows($resql); // Note, we can have 2 records if on is morning and the other one is afternoon + if ($num_rows > 0) + { + $i=0; + while ($i < $num_rows) + { + $obj = $this->db->fetch_object($resql); + + // Note: $obj->halday is 0:Full days, 2:Sart afternoon end morning, -1:Start afternoon, 1:End morning + $arrayofrecord[$obj->rowid]=array('date_start'=>$this->db->jdate($obj->date_start), 'date_end'=>$this->db->jdate($obj->date_end), 'halfday'=>$obj->halfday); + $i++; + } + + // We found a record, user is on holiday by default, so is not available is true. + $isavailablemorning = true; + foreach($arrayofrecord as $record) + { + if ($timestamp == $record['date_start'] && $record['halfday'] == 2) continue; + if ($timestamp == $record['date_start'] && $record['halfday'] == -1) continue; + $isavailablemorning = false; + break; + } + $isavailableafternoon = true; + foreach($arrayofrecord as $record) + { + if ($timestamp == $record['date_end'] && $record['halfday'] == 2) continue; + if ($timestamp == $record['date_end'] && $record['halfday'] == 1) continue; + $isavailableafternoon = false; + break; + } + } + } + else dol_print_error($this->db); + + return array('morning'=>$isavailablemorning, 'afternoon'=>$isavailableafternoon); } diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index da789675cb8..ad1815c5efc 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; $langs->load('projects'); $langs->load('users'); @@ -484,10 +485,17 @@ print "\n"; // By default, we can edit only tasks we are assigned to $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0); +// Get if user is available or not for each day +$holiday = new Holiday($db); +$isavailable=array(); + +$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse); // $daytoparse is a date with hours = 0 +$isavailable[$daytoparse]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day + if (count($tasksarray) > 0) { $j=0; - projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse); + projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse, $isavailable); $colspan = 8; if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) $colspan++; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index c0482967c9e..caf2a3e4e84 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; $langs->load('projects'); $langs->load('users'); @@ -474,9 +475,25 @@ print ''.$langs->trans("TimeSpent").'' $startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); -for($i=0;$i<7;$i++) +// Get if user is available or not for each day +$holiday = new Holiday($db); +$isavailable=array(); + +for ($i=0;$i<7;$i++) { - print ''.dol_print_date($startday + ($i * 3600 * 24), '%a').'
'.dol_print_date($startday + ($i * 3600 * 24), 'dayreduceformat').''; + $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $i, 'd'); // $firstdaytoshow is a date with hours = 0 + $dayinloop = dol_time_plus_duree($startday, $i, 'd'); + + // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow + //$tmparray = dol_getdate($dayinloop); + //$dayinloopwithouthours=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); + //print dol_print_date($dayinloop, 'dayhour').' '; + //print dol_print_date($dayinloopwithouthours, 'dayhour').' '; + //print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'
'; + + $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow); + $isavailable[$dayinloopfromfirstdaytoshow]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day + print ''.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').''; } print ''; print "\n"; @@ -491,7 +508,7 @@ if (count($tasksarray) > 0) $j=0; $level=0; - projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask); + projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable); $colspan=7; if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) $colspan++; From caf4ca74517f1dc0f748bd6df315b2cca7d70c15 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Tue, 19 Sep 2017 16:56:27 +0200 Subject: [PATCH 038/114] FIX Implementation of a Luracast recommandation for the REST api server (#7370) --- htdocs/api/class/api.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 36eb7c1d7d2..d76759532dc 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -48,7 +48,7 @@ class DolibarrApi */ function __construct($db, $cachedir='', $refreshCache=false) { - global $conf; + global $conf, $dolibarr_main_url_root; if (empty($cachedir)) $cachedir = $conf->api->dir_temp; Defaults::$cacheDirectory = $cachedir; @@ -57,6 +57,8 @@ class DolibarrApi $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true ); $this->r = new Restler($production_mode, $refreshCache); $this->r->setBaseUrls(DOL_MAIN_URL_ROOT, $urlwithroot); + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $this->r->setAPIVersion(1); } From d5966f944fac0834fbab0ea1cb561b55d9fa0ebf Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Tue, 19 Sep 2017 16:58:09 +0200 Subject: [PATCH 039/114] FIX Implementation of a Luracast recommandation for the REST api server (#7370) --- htdocs/api/class/api.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index d76759532dc..55b728d2a80 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -56,9 +56,9 @@ class DolibarrApi $this->db = $db; $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true ); $this->r = new Restler($production_mode, $refreshCache); - $this->r->setBaseUrls(DOL_MAIN_URL_ROOT, $urlwithroot); - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $this->r->setBaseUrls($urlwithroot); $this->r->setAPIVersion(1); } From cc7aee6c3e5618855e43f95f38adb3b899c260d1 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Tue, 19 Sep 2017 16:59:19 +0200 Subject: [PATCH 040/114] FIX Implementation of a Luracast recommandation for the REST api server (#7370) --- htdocs/api/class/api.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 55b728d2a80..dcda8255e7c 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -58,7 +58,7 @@ class DolibarrApi $this->r = new Restler($production_mode, $refreshCache); $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - $this->r->setBaseUrls($urlwithroot); + $this->r->setBaseUrls(DOL_MAIN_URL_ROOT, $urlwithroot); $this->r->setAPIVersion(1); } From f4ddce727421d81f85a68111536c1f14bddd6024 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 17:05:50 +0200 Subject: [PATCH 041/114] FIX View of timespent for another user --- htdocs/projet/activity/perday.php | 2 +- htdocs/projet/activity/perweek.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 4dff34ad30b..3dbf7e32650 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -84,7 +84,7 @@ if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) $usertoprocess=$user; $search_usertoprocessid=$usertoprocess->id; } -elseif (search_usertoprocessid > 0) +elseif ($search_usertoprocessid > 0) { $usertoprocess=new User($db); $usertoprocess->fetch($search_usertoprocessid); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 6ea60f3d76f..3b6ce8efd91 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -97,7 +97,7 @@ if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) $usertoprocess=$user; $search_usertoprocessid=$usertoprocess->id; } -elseif (search_usertoprocessid > 0) +elseif ($search_usertoprocessid > 0) { $usertoprocess=new User($db); $usertoprocess->fetch($search_usertoprocessid); From 5f7631a95d83fe0fc26c8750f22ba50b06ef845a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 17:07:39 +0200 Subject: [PATCH 042/114] NEW Days where user is on vacation use different colors in timesheet. --- htdocs/core/lib/project.lib.php | 10 ++++++---- htdocs/projet/activity/perday.php | 2 +- htdocs/projet/activity/perweek.php | 2 +- htdocs/theme/eldy/style.css.php | 8 +++++++- htdocs/theme/md/style.css.php | 7 +++++++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 2e5799f970c..0de84d581f1 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -733,8 +733,9 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print ''; $cssonholiday=''; - if (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; - if (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; + if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; + elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; + elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; // Duration print ''; @@ -970,8 +971,9 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $cssonholiday=''; - if (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; - if (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; + if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; + elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; + elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; $tmparray=dol_getdate($tmpday); $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index ad1815c5efc..c9c577742e6 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -85,7 +85,7 @@ if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) $usertoprocess=$user; $search_usertoprocessid=$usertoprocess->id; } -elseif (search_usertoprocessid > 0) +elseif ($search_usertoprocessid > 0) { $usertoprocess=new User($db); $usertoprocess->fetch($search_usertoprocessid); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index caf2a3e4e84..b808017123d 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -98,7 +98,7 @@ if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) $usertoprocess=$user; $search_usertoprocessid=$usertoprocess->id; } -elseif (search_usertoprocessid > 0) +elseif ($search_usertoprocessid > 0) { $usertoprocess=new User($db); $usertoprocess->fetch($search_usertoprocessid); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 3d58211fbde..a83d2ed9dd8 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -387,12 +387,18 @@ input.buttonpaymentstripe { background-repeat: no-repeat; background-position: 8px 7px; } +/* Used by timesheets */ span.timesheetalreadyrecorded input { border: none; border-bottom: solid 1px rgba(0,0,0,0.4); margin-right: 1px !important; } - +td.onholidaymorning, td.onholidayafternoon { + background-color: #fdf6f2; +} +td.onholidayallday { + background-color: #f4eede; +} select.flat, form.flat select { font-weight: normal; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 36fbd2bdd20..0f3711bf45b 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -384,11 +384,18 @@ input.buttonpaymentstripe { background-repeat: no-repeat; background-position: 8px 7px; } +/* Used for timesheets */ span.timesheetalreadyrecorded input { border: none; border-bottom: solid 1px rgba(0,0,0,0.1); margin-right: 1px !important; } +td.onholidaymorning, td.onholidayafternoon { + background-color: #fdf6f2; +} +td.onholidayallday { + background-color: #f4eede; +} select.flat, form.flat select { font-weight: normal; From 5643d4e867557f134daf56f64564f91203496107 Mon Sep 17 00:00:00 2001 From: tysauron Date: Tue, 19 Sep 2017 17:26:18 +0200 Subject: [PATCH 043/114] Rename "->fk_action" in "->type_id" (is old name) --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index cb6da443404..ec1c84dd652 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -754,7 +754,7 @@ class ActionComm extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; $sql.= " SET percent = '".$this->db->escape($this->percentage)."'"; - if ($this->fk_action > 0) $sql.= ", fk_action = '".$this->db->escape($this->fk_action)."'"; + if ($this->type_id > 0) $sql.= ", fk_action = '".$this->db->escape($this->type_id)."'"; $sql.= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'":"null"); $sql.= ", datep = ".(strval($this->datep)!='' ? "'".$this->db->idate($this->datep)."'" : 'null'); $sql.= ", datep2 = ".(strval($this->datef)!='' ? "'".$this->db->idate($this->datef)."'" : 'null'); From c38ed5499054c0f80fc18231ba649abdf1b501d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 17:31:37 +0200 Subject: [PATCH 044/114] Disable old datepicker --- htdocs/admin/system/perf.php | 2 +- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/lib/project.lib.php | 4 ++-- htdocs/main.inc.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 25079d8f185..3a8e1e42bf4 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -336,7 +336,7 @@ jQuery(document).ready(function() { var compjsphpstring; getjsphpurl = $.ajax({ type: "GET", - url: \''.DOL_URL_ROOT.'/core/js/datepicker.js.php\', + url: \''.DOL_URL_ROOT.'/core/js/lib_head.js.php\', cache: false, /* async: false, */ /* crossDomain: true,*/ diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index bca87c7a65f..628be5660df 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5046,11 +5046,11 @@ class Form else return 'BadValueForParameterTypeHour'; if ($typehour!='text') $retstring.=' '.$langs->trans('HourShort'); - else $retstring.=':'; + else $retstring.=':'; // Minutes if ($minunderhours) $retstring.='
'; - else $retstring.=" "; + else $retstring.=' '; if ($typehour=='select' || $typehour=='textselect') { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 0de84d581f1..af49fa6b27d 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -738,7 +738,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; // Duration - print ''; + print ''; $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; $alreadyspent=''; @@ -748,7 +748,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $tableCell=''; $tableCell.=''; - $tableCell.=' + '; + $tableCell.=' + '; //$tableCell.='   '; $tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1); //$tableCell.=' '; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 06a6b4658ae..675c82aa499 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1322,10 +1322,10 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; // Add datepicker default options - if (! defined('DISABLE_DATE_PICKER')) + /*if (! defined('DISABLE_DATE_PICKER')) { print ''."\n"; - } + }*/ // JS forced by modules (relative url starting with /) if (! empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) From 8123562dedfbc9521b4b903bb451562c0e3cb027 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 19 Sep 2017 18:42:29 +0200 Subject: [PATCH 045/114] Fix extrafield copy next situation invoice --- htdocs/compta/facture/card.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6cfed39a02f..1d621d153f5 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1356,6 +1356,7 @@ if (empty($reshook)) { $line->origin = $object->origin; $line->origin_id = $line->id; + $line->fetch_optionals($line->id); } } @@ -1377,7 +1378,21 @@ if (empty($reshook)) $object->situation_counter = $object->situation_counter + 1; $id = $object->createFromCurrent($user); - if ($id <= 0) $mesg = $object->error; + if ($id <= 0) + { + $mesg = $object->error; + } + else + { + $nextSituationInvoice = new Facture($db); + $nextSituationInvoice->fetch($id); + // create extrafields with data from create form + $extralabels = $extrafields->fetch_name_optionals_label($nextSituationInvoice->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $nextSituationInvoice); + if ($ret > 0) { + $nextSituationInvoice->insertExtraFields(); + } + } } } From 13d5471dd00357a0274cad9aa42fac9978d1031d Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 19 Sep 2017 18:43:00 +0200 Subject: [PATCH 046/114] Fix extrafield copy shipment --- htdocs/expedition/card.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index f15c091263e..4a7df9e73b2 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -780,9 +780,15 @@ if ($action == 'create') $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print $object->showOptionals($extrafields, 'edit'); - } + if (empty($reshook) && ! empty($extrafields->attribute_label)) { + // copy from order + $orderExtrafields = new Extrafields($db); + $orderExtrafieldLabels = $orderExtrafields->fetch_name_optionals_label($object->table_element); + if ($object->fetch_optionals($object->id, $orderExtrafieldLabels) > 0) { + $expe->array_options = array_merge($expe->array_options, $object->array_options); + } + print $object->showOptionals($extrafields, 'edit'); + } // Incoterms @@ -1304,9 +1310,14 @@ if ($action == 'create') if (is_array($extralabelslines) && count($extralabelslines)>0) { $colspan=5; + $orderLineExtrafields = new Extrafields($db); + $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line); + $srcLine = new OrderLine($db); + $srcLine->fetch_optionals($line->id,$orderLineExtrafieldLabels); // fetch extrafields also available in orderline $line = new ExpeditionLigne($db); $line->fetch_optionals($object->id,$extralabelslines); - print ''; + $line->array_options = array_merge($line->array_options, $srcLine->array_options); + print ''; print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); print ''; } From cec91ae837528050908f5506e9d80c8b68689b82 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 19 Sep 2017 18:44:49 +0200 Subject: [PATCH 047/114] Fix extrafield copy receipt --- htdocs/livraison/card.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 02b126306f2..e6d39ec7019 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -565,6 +565,14 @@ else } // Other attributes + if ($action = 'create_delivery') { + // copy from expedition + $expeditionExtrafields = new Extrafields($db); + $expeditionExtrafieldLabels = $expeditionExtrafields->fetch_name_optionals_label($expedition->table_element); + if ($expedition->fetch_optionals($object->origin_id, $expeditionExtrafieldLabels) > 0) { + $object->array_options = array_merge($object->array_options, $expedition->array_options); + } + } $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -665,6 +673,13 @@ else $mode = ($object->statut == 0) ? 'edit' : 'view'; $line = new LivraisonLigne($db); $line->fetch_optionals($object->lines[$i]->id,$extralabelslines); + if ($action = 'create_delivery') { + $srcLine = new ExpeditionLigne($db); + $expeditionLineExtrafields = new Extrafields($db); + $expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element); + $srcLine->fetch_optionals($expedition->lines[$i]->id,$expeditionLineExtrafieldLabels); + $line->array_options = array_merge($line->array_options, $srcLine->array_options); + } print ''; print $line->showOptionals($extrafieldsline, $mode, array('style'=>$bc[$var], 'colspan'=>$colspan),$i); print ''; From ddeca6cc06ade604c2fc374ba5871d53fa253ada Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 19 Sep 2017 18:52:27 +0200 Subject: [PATCH 048/114] fix oddeven revert --- htdocs/expedition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 4a7df9e73b2..728556b3940 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1317,7 +1317,7 @@ if ($action == 'create') $line = new ExpeditionLigne($db); $line->fetch_optionals($object->id,$extralabelslines); $line->array_options = array_merge($line->array_options, $srcLine->array_options); - print ''; + print ''; print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); print ''; } From ffe2ee82324cc266bacd093edcf88cd0e3ca6691 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 19:00:28 +0200 Subject: [PATCH 049/114] Standardize code --- htdocs/compta/bank/index.php | 17 ++++++++--------- htdocs/core/menus/standard/eldy.lib.php | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 80bf9d6f50c..5a0ab062b29 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -46,7 +46,7 @@ $toselect = GETPOST('toselect', 'array'); $search_ref=GETPOST('search_ref','alpha'); $search_label=GETPOST('search_label','alpha'); $search_number=GETPOST('search_number','alpha'); -$statut=GETPOST('statut')?GETPOST('statut', 'alpha'):'opened'; // 'all' or ''='opened' +$search_status=GETPOST('search_status')?GETPOST('search_status', 'alpha'):'opened'; // 'all' or ''='opened' $optioncss = GETPOST('optioncss','alpha'); // Security check @@ -123,11 +123,10 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { - $statut = 'all'; $search_ref=''; $search_label=''; $search_number=''; - $search_statut=''; + $search_status=''; } @@ -153,8 +152,8 @@ $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bankcacount_extrafields as ef on (c.rowid = ef.fk_object)"; $sql.= " WHERE entity IN (".getEntity('bank_account').")"; -if ($statut == 'opened') $sql.= " AND clos = 0"; -if ($statut == 'closed') $sql.= " AND clos = 1"; +if ($search_status == 'opened') $sql.= " AND clos = 0"; +if ($search_status == 'closed') $sql.= " AND clos = 1"; if ($search_ref != '') $sql.=natural_search('b.ref', $search_ref); if ($search_label != '') $sql.=natural_search('b.label', $search_label); if ($search_number != '') $sql.=natural_search('b.number', $search_number); @@ -222,7 +221,7 @@ if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($search_ref != '') $param.='&search_ref='.$search_ref; if ($search_label != '') $param.='&search_label='.$search_label; if ($search_number != '') $param.='&search_number='.$search_number; -if ($statut != '') $param.='&statut='.$statut; +if ($search_status != '') $param.='&search_status='.$search_status; if ($show_files) $param.='&show_files=' .$show_files; if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields @@ -377,7 +376,7 @@ if (! empty($arrayfields['b.tms']['checked'])) print ''; print ''; } -// Statut +// Status if (! empty($arrayfields['b.clos']['checked'])) { print ''; @@ -385,7 +384,7 @@ if (! empty($arrayfields['b.clos']['checked'])) 'opened'=>$langs->trans("Opened"), 'closed'=>$langs->trans("Closed") ); - print $form->selectarray("statut", $array, $statut, 1); + print $form->selectarray("search_status", $array, $search_status, 1); print ''; } // Balance @@ -584,7 +583,7 @@ foreach ($accounts as $key=>$type) if (! $i) $totalarray['nbfield']++; } - // Statut + // Status if (! empty($arrayfields['b.clos']['checked'])) { print ''.$acc->getLibStatut(5).''; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index fb503cfea9d..55d3b75fe13 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -977,7 +977,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); if (! empty($conf->banque->enabled)) { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/compta/bank/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuBankAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 51); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/compta/bank/index.php?mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 51); } if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) { From f87614e2d396cdd4044afdfdb16e3074291ad15d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 19:12:54 +0200 Subject: [PATCH 050/114] Fix missing translation --- htdocs/compta/prelevement/class/bonprelevement.class.php | 1 + htdocs/compta/prelevement/create.php | 2 +- htdocs/langs/en_US/withdrawals.lang | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 0278d97d724..a3d50d58143 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -953,6 +953,7 @@ class BonPrelevement extends CommonObject { $prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons"); $this->id = $prev_id; + $this->ref = $ref; } else { diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 6743ea3098b..09102ec1309 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -80,7 +80,7 @@ if ($action == 'create') } else { - setEventMessages($langs->trans("DirectDebitOrderCreated"), null); + setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null); } } diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 8e80a111516..29b5766215b 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -12,7 +12,7 @@ WithdrawalsLines=Direct debit order lines RequestStandingOrderToTreat=Request for direct debit payment order to process RequestStandingOrderTreated=Request for direct debit payment order processed NotPossibleForThisStatusOfWithdrawReceiptORLine=Not yet possible. Withdraw status must be set to 'credited' before declaring reject on specific lines. -NbOfInvoiceToWithdraw=Nb. of invoice with direct debit order +NbOfInvoiceToWithdraw=Nb. of qualified invoice with waiting direct debit order NbOfInvoiceToWithdrawWithInfo=Nb. of customer invoice with direct debit payment orders having defined bank account information InvoiceWaitingWithdraw=Invoice waiting for direct debit AmountToWithdraw=Amount to withdraw @@ -94,6 +94,7 @@ SEPAFrstOrRecur=Type of payment ModeRECUR=Reccurent payment ModeFRST=One-off payment PleaseCheckOne=Please check one only +DirectDebitOrderCreated=Direct debit order %s created ### Notifications InfoCreditSubject=Payment of direct debit payment order %s by the bank From 6a0ef4b561ab32717f53d1d4528c96fa12a57f10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 19:29:00 +0200 Subject: [PATCH 051/114] Fix info ot total in direct debit page --- htdocs/compta/prelevement/factures.php | 29 ++++++++++++++++---------- htdocs/langs/en_US/withdrawals.lang | 3 ++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index f7e41bdc997..60215005446 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -145,9 +145,9 @@ if ($prev_id > 0 || $ref) // List of invoices -$sql = "SELECT pf.rowid"; -$sql.= ",f.rowid as facid, f.facnumber as ref, f.total_ttc"; -$sql.= ", s.rowid as socid, s.nom as name, pl.statut"; +$sql = "SELECT pf.rowid,"; +$sql.= " f.rowid as facid, f.facnumber as ref, f.total_ttc,"; +$sql.= " s.rowid as socid, s.nom as name, pl.statut, pl.amount as amount_requested"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql.= ", ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql.= ", ".MAIN_DB_PREFIX."prelevement_facture as pf"; @@ -202,14 +202,14 @@ if ($result) print ''; print_liste_field_titre("Bill",$_SERVER["PHP_SELF"],"p.ref",'',$param,'',$sortfield,$sortorder); print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"s.nom",'',$param,'',$sortfield,$sortorder); - print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre("AmountInvoice",$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre("AmountRequested",$_SERVER["PHP_SELF"],"pl.amount_requested","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("StatusDebitCredit",$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); print "\n"; - $var=false; - - $total = 0; + $totalinvoices = 0; + $totalamount_requested = 0; while ($i < min($num, $limit)) { @@ -231,9 +231,12 @@ if ($result) print $thirdpartytmp->getNomUrl(1); print "\n"; - // Amount + // Amount of invoice print ''.price($obj->total_ttc)."\n"; + // Amount requested + print ''.price($obj->amount_requested)."\n"; + // Status of requests print ''; @@ -256,7 +259,8 @@ if ($result) print "\n"; - $total += $obj->total_ttc; + $totalinvoices += $obj->total_ttc; + $totalamount_requested += $obj->amount_requested; $i++; } @@ -267,8 +271,11 @@ if ($result) print ''.$langs->trans("Total").''; print ' '; print ''; - if ($total != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); - print price($total); + //if ($totalinvoices != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); // It is normal to have total that differs. For an amount of invoice of 100, request to pay may be 50 only. + if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); + print "\n"; + print ''; + print price($totalamount_requested); print "\n"; print ' '; print ' '; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 29b5766215b..308987575f5 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -72,7 +72,7 @@ IfInvoiceNeedOnWithdrawPaymentWontBeClosed=However, if invoice has at least one DoStandingOrdersBeforePayments=This tab allows you to request a direct debit payment order. Once done, go into menu Bank->Direct Debit orders to manage the direct debit payment order. When payment order is closed, payment on invoice will be automatically recorded, and invoice closed if remainder to pay is null. WithdrawalFile=Withdrawal file SetToStatusSent=Set to status "File Sent" -ThisWillAlsoAddPaymentOnInvoice=This will also apply payments to invoices and will classify them as "Paid" +ThisWillAlsoAddPaymentOnInvoice=This will also record payments to invoices and will classify them as "Paid" if remain to pay is null StatisticsByLineStatus=Statistics by status of lines RUM=UMR RUMLong=Unique Mandate Reference @@ -95,6 +95,7 @@ ModeRECUR=Reccurent payment ModeFRST=One-off payment PleaseCheckOne=Please check one only DirectDebitOrderCreated=Direct debit order %s created +AmountRequested=Amount requested ### Notifications InfoCreditSubject=Payment of direct debit payment order %s by the bank From 04e1458a3f1e47f7f42831cc4b57af68acbc7dff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 22:03:44 +0200 Subject: [PATCH 052/114] Fix clean parameters --- .../facture/class/facture-rec.class.php | 3 +++ htdocs/contrat/class/contrat.class.php | 27 +++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index b12f848323d..b3a8a68611d 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -715,6 +715,9 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + // Clean parameters + if (empty($remise_percent)) $remise_percent = 0; + // Check parameters if ($type < 0) return -1; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 6e9fc443e03..69bda6f2b1c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -538,11 +538,13 @@ class Contrat extends CommonObject /** * Load a contract from database * - * @param int $id Id of contract to load - * @param string $ref Ref - * @return int <0 if KO, id of contract if OK + * @param int $id Id of contract to load + * @param string $ref Ref + * @param string $ref_customer Customer ref + * @param string $ref_supplier Supplier ref + * @return int <0 if KO, 0 if not found, Id of contract if OK */ - function fetch($id,$ref='') + function fetch($id, $ref='', $ref_customer='', $ref_supplier='') { $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,"; $sql.= " ref_supplier, ref_customer,"; @@ -553,12 +555,20 @@ class Contrat extends CommonObject $sql.= " fk_commercial_signature, fk_commercial_suivi,"; $sql.= " note_private, note_public, model_pdf, extraparams"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; + if (! $id) $sql.=" WHERE entity IN (".getEntity('contract', 0).")"; + else $sql.= " WHERE rowid=".$id; + if ($ref_customer) + { + $sql.= " AND ref_customer = '".$this->db->escape($ref_customer)."'"; + } + if ($ref_supplier) + { + $sql.= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'"; + } if ($ref) { - $sql.= " WHERE ref='".$this->db->escape($ref)."'"; - $sql.= " AND entity IN (".getEntity('contract', 0).")"; + $sql.= " AND ref='".$this->db->escape($ref)."'"; } - else $sql.= " WHERE rowid=".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); @@ -628,7 +638,7 @@ class Contrat extends CommonObject { dol_syslog(get_class($this)."::Fetch Erreur contrat non trouve"); $this->error="Contract not found"; - return -2; + return 0; } } else @@ -2834,6 +2844,7 @@ class ContratLigne extends CommonObjectLine if (empty($this->total_ttc)) $this->total_ttc = 0; if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; + if (empty($this->remise_percent)) $this->remise_percent = 0; // Check parameters // Put here code to add control on parameters values From cfd29841e10117b8c0fda4f9c295d44d2de99436 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 23:42:20 +0200 Subject: [PATCH 053/114] NEW Option STOCK_SUPPORTS_SERVICES become visible. --- htdocs/admin/stock.php | 172 ++++++++++++++++++--------------- htdocs/langs/en_US/stocks.lang | 4 +- 2 files changed, 97 insertions(+), 79 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index f7e18851306..a2f0a4b5346 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -45,6 +45,10 @@ if($action) { $db->begin(); + if ($action == 'STOCK_SUPPORTS_SERVICES') + { + $res = dolibarr_set_const($db, "STOCK_SUPPORTS_SERVICES", GETPOST('STOCK_SUPPORTS_SERVICES','alpha'),'chaine',0,'',$conf->entity); + } if ($action == 'STOCK_USERSTOCK_AUTOCREATE') { $res = dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", GETPOST('STOCK_USERSTOCK_AUTOCREATE','alpha'),'chaine',0,'',$conf->entity); @@ -164,8 +168,8 @@ $found=0; print ''; -print ''.$langs->trans("DeStockOnBill").''; -print ''; +print ''.$langs->trans("DeStockOnBill").''; +print ''; if (! empty($conf->facture->enabled)) { print ""; @@ -184,8 +188,8 @@ $found++; print ''; -print ''.$langs->trans("DeStockOnValidateOrder").''; -print ''; +print ''.$langs->trans("DeStockOnValidateOrder").''; +print ''; if (! empty($conf->commande->enabled)) { print ""; @@ -206,8 +210,8 @@ $found++; //{ print ''; -print ''.$langs->trans("DeStockOnShipment").''; -print ''; +print ''.$langs->trans("DeStockOnShipment").''; +print ''; if (! empty($conf->expedition->enabled)) { print ""; @@ -226,8 +230,8 @@ $found++; print ''; -print ''.$langs->trans("DeStockOnShipmentOnClosing").''; -print ''; +print ''.$langs->trans("DeStockOnShipmentOnClosing").''; +print ''; if (! empty($conf->expedition->enabled)) { print ""; @@ -268,8 +272,8 @@ $found=0; print ''; -print ''.$langs->trans("ReStockOnBill").''; -print ''; +print ''.$langs->trans("ReStockOnBill").''; +print ''; if (! empty($conf->fournisseur->enabled)) { print ""; @@ -289,8 +293,8 @@ $found++; print ''; -print ''.$langs->trans("ReStockOnValidateOrder").''; -print ''; +print ''.$langs->trans("ReStockOnValidateOrder").''; +print ''; if (! empty($conf->fournisseur->enabled)) { print ""; @@ -309,8 +313,8 @@ $found++; print ''; -print ''.$langs->trans("ReStockOnDispatchOrder").''; -print ''; +print ''.$langs->trans("ReStockOnDispatchOrder").''; +print ''; if (! empty($conf->fournisseur->enabled)) { print ""; @@ -346,8 +350,8 @@ print ''."\n"; print ''; -print ''.$langs->trans("WarehouseAllowNegativeTransfer").''; -print ''; +print ''.$langs->trans("WarehouseAllowNegativeTransfer").''; +print ''; print ""; print ''; print ""; @@ -361,8 +365,8 @@ print "\n"; if($conf->invoice->enabled) { $var = !$var; print ''; - print ''.$langs->trans("StockMustBeEnoughForInvoice").''; - print ''; + print ''.$langs->trans("StockMustBeEnoughForInvoice").''; + print ''; print ""; print ''; print ""; @@ -376,8 +380,8 @@ if($conf->invoice->enabled) { if($conf->order->enabled) { $var = !$var; print ''; - print ''.$langs->trans("StockMustBeEnoughForOrder").''; - print ''; + print ''.$langs->trans("StockMustBeEnoughForOrder").''; + print ''; print ""; print ''; print ""; @@ -391,8 +395,8 @@ if($conf->order->enabled) { if($conf->expedition->enabled) { $var = !$var; print ''; - print ''.$langs->trans("StockMustBeEnoughForShipment").''; - print ''; + print ''.$langs->trans("StockMustBeEnoughForShipment").''; + print ''; print ""; print ''; print ""; @@ -404,6 +408,9 @@ if($conf->expedition->enabled) { } print ''; + +print '
'; + $virtualdiffersfromphysical=0; if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) @@ -411,7 +418,6 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) if ($virtualdiffersfromphysical) { - print '
'; print ''; print ''; print " \n"; @@ -419,8 +425,8 @@ if ($virtualdiffersfromphysical) print ''."\n"; $var = !$var; print ''; - print ''; - print ''; + print '\n"; print "\n"; print '
".$langs->trans("RuleForStockReplenishment")." ".img_help('help',$langs->trans("VirtualDiffersFromPhysical"))."
'.$langs->trans("UseVirtualStockByDefault").''; + print ''.$langs->trans("UseVirtualStockByDefault").''; print ""; print ''; print ""; @@ -430,9 +436,70 @@ if ($virtualdiffersfromphysical) print "
'; + print '
'; } +print ''; + +print ''; +print " \n"; +print " \n"; +print ''."\n"; + +print ''; +print ''; +print '\n"; +print "\n"; + +print ''; +print ''; +print '\n"; +print "\n"; + +print ''; +print ''; +print '\n"; +print "\n"; + +if (! empty($conf->fournisseur->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { + + print ''; + print ''; + print '\n\n"; +} + +print '
".$langs->trans("Other")." 
'.$langs->trans("UserWarehouseAutoCreate").''; +print ""; +print ''; +print ""; +print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1); +print ''; +print ''; +print "
'; +print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc")).''; +print "
"; +print ''; +print ""; +print $form->selectyesno("STOCK_SUPPORTS_SERVICES",$conf->global->STOCK_SUPPORTS_SERVICES,1); +print ''; +print '
'; +print "
'.$langs->trans("AllowAddLimitStockByWarehouse").''; +print "
"; +print ''; +print ""; +print $form->selectyesno("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE",$conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE,1); +print ''; +print '
'; +print "
'.$langs->trans("UseDispatchStatus").''; + print "
"; + print ''; + print ""; + print $form->selectyesno("SUPPLIER_ORDER_USE_DISPATCH_STATUS",$conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS,1); + print ''; + print "
\n"; + print "
'; + print '
'; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { @@ -484,54 +551,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; } -print ''; - -print ''; -print " \n"; -print " \n"; -print ''."\n"; - -if (! empty($conf->fournisseur->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { - - print ''; - print ''; - print '\n\n"; -} - -print ''; -print ''; -print '\n"; -print "\n"; - -print ''; -print ''; - -print '\n"; -print "\n"; - -print '
'; - /* I keep the option/feature, but hidden to end users for the moment. If feature is used by module, no need to have users see it. If not used by a module, I still need to understand in which case user may need this now we can set rule on product page. if ($conf->global->PRODUIT_SOUSPRODUITS) @@ -539,9 +558,8 @@ if ($conf->global->PRODUIT_SOUSPRODUITS) print ''; - print ''; - - print ''; + print '
".$langs->trans("Other")." 
'.$langs->trans("UseDispatchStatus").''; - print "
"; - print ''; - print ""; - print $form->selectyesno("SUPPLIER_ORDER_USE_DISPATCH_STATUS",$conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS,1); - print ''; - print "
\n"; - print "
'.$langs->trans("UserWarehouseAutoCreate").''; -print "
"; -print ''; -print ""; -print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1); -print ''; -print '
'; -print "
'.$langs->trans("AllowAddLimitStockByWarehouse").''; -print "
"; -print ''; -print ""; -print $form->selectyesno("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE",$conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE,1); -print ''; -print '
'; -print "
'.$langs->trans("IndependantSubProductStock").''; + print ''.$langs->trans("IndependantSubProductStock").''; print "
"; print ''; print ""; @@ -553,8 +571,6 @@ if ($conf->global->PRODUIT_SOUSPRODUITS) } */ -print '
'; - llxFooter(); diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index cda14147ece..6019977120e 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -195,4 +195,6 @@ InventoryFlushed=Inventory flushed ExitEditMode=Exit edition inventoryDeleteLine=Delete line RegulateStock=Regulate Stock -ListInventory=List \ No newline at end of file +ListInventory=List +StockSupportServices=Stock management support services +StockSupportServicesDesc=By default, you can stock only product with type "product". If on, and if module service is on, you can also stock a product with type "service" \ No newline at end of file From 8bb3130aab8ba7d0ae6600c2efdec472bf8796b4 Mon Sep 17 00:00:00 2001 From: tysauron Date: Wed, 20 Sep 2017 00:35:52 +0200 Subject: [PATCH 054/114] For use ajax select company --- htdocs/projet/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 97f9ff41d54..1146ba49b80 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -528,7 +528,7 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; $filteronlist=''; if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; - $text=$form->select_thirdparty_list(GETPOST('socid','int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), '', 0, 0, 'minwidth300'); + $text=$form->select_company(GETPOST('socid','int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300'); if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { $texthelp=$langs->trans("IfNeedToUseOhterObjectKeepEmpty"); @@ -747,7 +747,7 @@ elseif ($object->id > 0) print ''; $filteronlist=''; if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; - $text=$form->select_thirdparty_list($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), '', 0, 0, 'minwidth300'); + $text=$form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300'); if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { $texthelp=$langs->trans("IfNeedToUseOhterObjectKeepEmpty"); From 3220225af3377ec32ecabcce2da9852cedfffdd0 Mon Sep 17 00:00:00 2001 From: tysauron Date: Wed, 20 Sep 2017 00:53:48 +0200 Subject: [PATCH 055/114] Bug get socid with old object sosciete --- htdocs/projet/tasks/contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 3d834fe28b6..6cdbc204749 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -397,7 +397,7 @@ if ($id > 0 || ! empty($ref)) print ''; $thirdpartyofproject=$projectstatic->getListContactId('thirdparty'); - $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$projectstatic->societe->id; + $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$projectstatic->socid; $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', $thirdpartyofproject, 0, '&withproject='.$withproject); print ''; From 052e025537b33e8bdd57095e23e44a34eb4b0b5a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 11:42:05 +0200 Subject: [PATCH 056/114] Better detection of log to include merge labels --- build/makepack-dolibarr.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 80cc9b0856c..e0fa89d924d 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -366,7 +366,9 @@ if ($nboftargetok) { } else # For a maintenance release { - print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; + #print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; + print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. | grep -v "Merge branch" | grep -v "Merge pull" | grep "^ " | sed -e "s/^[0-9a-z]* *//" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; + } print "\n"; if (! $ret) From 5e2cc050472a98bd3b1517dfd0f896c645966a32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Sep 2017 11:12:47 +0200 Subject: [PATCH 057/114] Prepare 6.0.1 --- ChangeLog | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/ChangeLog b/ChangeLog index aafbbf5ff45..994e1702407 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,48 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 6.0.1 compared to 6.0.* ***** + +FIX: #7000 Dashboard link for late pending payment supplier invoices do not work +FIX: #7325 Default VAT rate when editing template invoices is 0% +FIX: #7330 +FIX: #7359 +FIX: #7367 +FIX: #7368 +FIX: #7391 +FIX: #7420 +FIX: Add some missing attributes in Adherent:makeSubstitution (type, phone… +FIX: Bad const name +FIX: Bad link to unpayed suppliers invoices +FIX: Better protection to no send email when we change limit +FIX: Calculation in the activity box +FIX: Clean bad parameters when inserting line of template invoice +FIX: dateSelector was not taken into account +FIX: hidden option MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN +FIX: journalization for bank journal should not rely on a label. +FIX: menu enty when url is external link +FIX: missing supplier qty and supplier discount in available fields for product export. +FIX: multicompany better accuracy in rounding and with revenue stamp. +FIX: Must use pdf format page as default for merging PDF. +FIX: PDF output was sharing 2 different currencies in same total +FIX: Position of signature on strato template +FIX: Protection to avoid to apply credit note discount > remain to pay +FIX: Remove warning when using log into syslog +FIX: Responsive +FIX: Security fixes (filter onload js, less verbose error message in +FIX: SEPA recording payment must save one payment in bank per customer +FIX: Several problem with the last event box on project/tasks +FIX: Sign of amount in origin currency on credit note created from lines +FIX: Some page of admin were not responsive +FIX: SQL injection +FIX: time.php crashed without project id in param +FIX: transfer of line extrafields from order to invoice +FIX: Upgrade missing on field +FIX: View of timespent for another user +FIX: ODT generation +FIX: CVE-2017-9840, CVE-2017-14238, CVE-2017-14239, CVE-2017-14240, CVE-2017-14241, + CVE-2017-14242 + ***** ChangeLog for 6.0.0 compared to 5.0.* ***** NEW: Add experimental BlockeLog module (to log business events in a non reversible log file). From 1314e00bc642b3085755865b621c7310b0c297d2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 20 Sep 2017 14:46:51 +0200 Subject: [PATCH 058/114] Fix: check if array and check empty value if required --- htdocs/core/class/extrafields.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 12d958b6ebb..53327f67a15 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1708,7 +1708,7 @@ class ExtraFields if (! empty($onlykey) && $key != $onlykey) continue; $key_type = $this->attribute_type[$key]; - if($this->attribute_required[$key] && !GETPOST("options_$key",2)) + if ($this->attribute_required[$key] && empty($_POST["options_".$key])) // Check if empty without GETPOST, value can be alpha, int, array, etc... { $nofillrequired++; $error_field_required[] = $value; @@ -1721,7 +1721,7 @@ class ExtraFields } else if (in_array($key_type,array('checkbox','chkbxlst'))) { - $value_arr=GETPOST("options_".$key); + $value_arr=GETPOST("options_".$key, 'array'); // check if an array if (!empty($value_arr)) { $value_key=implode($value_arr,','); }else { @@ -1740,7 +1740,7 @@ class ExtraFields $object->array_options["options_".$key]=$value_key; } - if($nofillrequired) { + if ($nofillrequired) { $langs->load('errors'); setEventMessages($langs->trans('ErrorFieldsRequired').' : '.implode(', ',$error_field_required), null, 'errors'); return -1; From 1d6213ea7d829767834ebe5486e7ef8422c65546 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Sep 2017 15:29:47 +0200 Subject: [PATCH 059/114] Add picto for cheque payment --- htdocs/public/payment/newpayment.php | 2 +- htdocs/theme/common/cheque.png | Bin 0 -> 2483 bytes htdocs/theme/eldy/style.css.php | 26 +++++++++----------------- htdocs/theme/md/style.css.php | 6 ++++-- 4 files changed, 14 insertions(+), 20 deletions(-) create mode 100644 htdocs/theme/common/cheque.png diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 72ad0390cce..62f82bc33d1 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -602,7 +602,7 @@ print $text; // Output payment summary form print ''; print ''; -print ''."\n"; +print ''."\n"; $found=false; $error=0; diff --git a/htdocs/theme/common/cheque.png b/htdocs/theme/common/cheque.png new file mode 100644 index 0000000000000000000000000000000000000000..34b89a1e1d010a5fc6246970393cecced8228904 GIT binary patch literal 2483 zcmV;k2~75hP)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00|pOL_t(|+U=ct>>O1U$3L^b z<=2*4i@ZcAEttw1g_v0^yyI z5RkXLA%zeWLjkomk%uk){r0!lKkl9U&febHojW_TGdp{~$!2HnJa*=M@44sPbI-jC z0RbtoB@hKM3^zUv`~>(AQ0DVAaBvXK@Zox3y&$q}J_?usE(#(V4$J_au}E}%CV?*o zaaA8@q#!fa)ZYhjRUdCS2vxuaV4ZcW1nLipCn%fv{ z;2pF5u4i{d883K`KtZ{L{!VOv46HTVE#Q35d(8rl4iuD+2ZgiqBT+uj1QXgGpAUjK z%f}*ND>qrq@x2~)G`6MR4I(WUvw_zIA?Jx>hi4%4-5}EPaj76~Eif*Qz2!;j1h6!S zv|P*-q)pN}fPHiZE&X#4Y5Dk-aE|^Y%I5SZskOp>5zJV4EP;a&dwnZauJ_IChsOsZ&gc5(7%aI$=vs73I5R(9)-Z zILpV0g3vcb`8Ya-)7LpVAc(YFY;A%AF(I-~xh#Wo^l}hs`M5=BscbeQbP(T%)J?$W zgGkH8d_mg(fc?a=3o~fxWkICn<1V44zqSGm>j|SULx(R2P26A|Tb02%S{6iFE@lC* z2ts}=j(weMqc9;HSTfEN#I3UkdEJxL7I173Y58aw;#$C0MfsQLoe5}X*{=%XEFYH$ za_$r5TLP~+NNgD==p5iG2dT4yNXx}ert1*TQa0&_0T1Dx z%#`#ZOT_g{@gJJ23!#g6GbKVf;oD-*gc-Eg+po8I0AV-X_ zOwND_waML;=|r-4wG>|sJI90(LC;UUJ7{S+gvKOZD)yfTp73;z<^V@o4p)FdGlQ$F zfWI3Xh83EkOPLI5?ST%|1AGtot7j!V!vrn>{spW+kLDCn0iy)-5hav$>#il4q$r_W z89(GxUC!;>%Uw(I3Mg6ouPRIX0KQyfLY0rXYvir+Ilwpa6VaK^RClx3 z_jsrp@C)3Dj{f-IH1x8rqhLb^Ho%={py5`}mSG(D>4-GB?K}uo1J>FV8D9G5HP+I? zHMD5E`XYKdzt8WC0pA<}4IL^kSK{0ZmF$>Nj}-nw?qbto;Yf{(pcS60UcRFS-a$GoI;E0Q-8? zLw57>Xo91ZLV5;0zXWt9-<~D_;Cirr>}$NpMvU3$6~>gu^*0M!8V!-7G?C!JE;9Z^ zT-go<9`EOeeNfg43m?apsBT==@tB>{Vl@C>nM`H=r}^BM$)_ zSR+E)J~p&UH*?$K;2!2DC`_FYW z!CT{w3Mn>^?AY7gu1k_v2{VDSm>yQU(R|;KveGQ4 z+N+Yy0KR43rX*>80@#S2Dp-_Vj?nQ=iL=mC3s140(@tUe1)b{x4a$l0v40bJbX%G! z1)282S|vCPrvm>3ejrGD((zn_ezwY@=-Fp^5jzhZB7CG~UalRSUpy!qT6Q0GEqWo2 zy1~mSY7kI$c-j6y=S$=+frYwi=<(?I zt`b22nR1%6qDj(zQoPn)WLaJ#_a8y8F4LEWHb=PTuddkh{08`03S}Y>LhEQVuOc~T z7fXYZ%6pC2bX&Vgo;!wK5v}iTOWIg&9c|{hL-L%tr=SFnwpxUSNYN;Hxmmj{0Ylv6 z+BdDMO|2>>ite_|Ku=csK>UE57MP^rip{4FMkG(`vtK}^Xg%ycp=+vNWc59ho|T0A z+POfzDz`10ZYy>wM;~Upszk$7{RUI6J>KX{By? xUmUhJ>D^s_#^>@kVw<{}9P)Pq0s_jw{{h9JxNccM6oLQ%002ovPDHLkV1ffXjZy#r literal 0 HcmV?d00001 diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index a83d2ed9dd8..1c991f9ccd7 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -344,48 +344,40 @@ input.buttongen { vertical-align: middle; } input.buttonpayment { - width: 300px; + min-width: 280px; margin-bottom: 15px; background-image: none; line-height: 24px; padding: 8px; + background: none; + border: 2px solid #666666; } input.buttonpaymentcb { background-image: url(); background-size: 26px; background-repeat: no-repeat; - background-position: 5px 5px; + background-position: 2px 11px; } input.buttonpaymentcheque { background-image: url(); - background-repeat: no-repeat; - background-position: 8px 7px; -} -input.buttonpaymentcb { - background-image: url(); background-size: 24px; background-repeat: no-repeat; - background-position: 5px 4px; -} -input.buttonpaymentcheque { - background-image: url(); - background-repeat: no-repeat; - background-position: 5px 4px; + background-position: 2px 8px; } input.buttonpaymentpaypal { background-image: url(); background-repeat: no-repeat; - background-position: 8px 7px; + background-position: 8px 11px; } input.buttonpaymentpaybox { background-image: url(); background-repeat: no-repeat; - background-position: 8px 7px; + background-position: 8px 11px; } input.buttonpaymentstripe { background-image: url(); background-repeat: no-repeat; - background-position: 8px 7px; + background-position: 8px 11px; } /* Used by timesheets */ span.timesheetalreadyrecorded input { @@ -3147,7 +3139,7 @@ div.titre { /* text-shadow: 1px 1px 2px #FFFFFF; */ } -#dolpaymenttable { width: 600px; font-size: 13px; } +#dolpaymenttable { max-width: 600px; font-size: 16px; } #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } #tablepublicpayment .CTableRow1 { background-color: #F0F0F0 !important; } #tablepublicpayment tr.liste_total { border-bottom: 1px solid #CCCCCC !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 0f3711bf45b..1ed9b433be7 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -341,11 +341,13 @@ input.buttongen { vertical-align: middle; } input.buttonpayment { - width: 300px; + min-width: 280px; margin-bottom: 15px; background-image: none; line-height: 24px; padding: 8px; + background: none; + border: 2px solid #666666; } input.buttonpaymentcb { background-image: url(); @@ -3237,7 +3239,7 @@ div.titre { dol_optimize_smallscreen)?'':'margin-top: 4px;'); ?> } -#dolpaymenttable { width: 600px; font-size: 13px; } +#dolpaymenttable { max-width: 600px; font-size: 16px; } #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } #tablepublicpayment .CTableRow1 { background-color: #F0F0F0 !important; } #tablepublicpayment tr.liste_total { border-bottom: 1px solid #CCCCCC !important; } From 77fea1983c14f3739cc0623472bdde6f52007857 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 20 Sep 2017 16:57:38 +0200 Subject: [PATCH 060/114] Fix: wrong supplier product price id --- htdocs/fourn/class/fournisseur.commande.class.php | 6 +++--- htdocs/fourn/commande/card.php | 2 +- htdocs/product/class/product.class.php | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 0c2c7044e5d..528e32fd4a4 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1414,7 +1414,7 @@ class CommandeFournisseur extends CommonOrder if ($remise_percent == 0 && $prod->remise_percent !=0) $remise_percent =$prod->remise_percent; - + } if ($result == 0) // If result == 0, we failed to found the supplier reference price { @@ -2678,14 +2678,14 @@ class CommandeFournisseur extends CommonOrder if ($db->num_rows($query)) { $obj = $db->fetch_object($query); - + $string = $langs->trans($obj->code); if ($string == $obj->code) { $string = $obj->label != '-' ? $obj->label : ''; } return $string; - } + } } else dol_print_error($db); } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 56566438206..48a2e72661b 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -409,7 +409,7 @@ if (empty($reshook)) $localtax1_tx, $localtax2_tx, $idprod, - $productsupplier->id, + $productsupplier->product_fourn_price_id, $productsupplier->fourn_ref, $remise_percent, 'HT', diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a6a4ef25f09..05adfc1b5c5 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1532,6 +1532,7 @@ class Product extends CommonObject $obj->price = $price_result; } } + $this->product_fourn_price_id = $obj->rowid; $this->buyprice = $obj->price; // deprecated $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product of supplier $this->fourn_price_base_type = 'HT'; // Price base type @@ -1577,6 +1578,7 @@ class Product extends CommonObject $obj->price = $price_result; } } + $this->product_fourn_price_id = $obj->rowid; $this->buyprice = $obj->price; // deprecated $this->fourn_qty = $obj->quantity; // min quantity for price for a virtual supplier $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product for a virtual supplier From 577c64cc3735d6db8f75ee7efbe1767b606b7dfa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Sep 2017 17:23:36 +0200 Subject: [PATCH 061/114] WIP work on param download on payment page --- htdocs/compta/facture/class/facture.class.php | 17 +++++++++++++++++ htdocs/public/payment/newpayment.php | 16 ++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 76b41f3ce86..41cc8042144 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1051,6 +1051,23 @@ class Facture extends CommonInvoice else return -1; } + /** + * Return link to download file from a direct external access + * + * @param int $withpicto Add download picto into link + * @return string HTML link to file + */ + function getDirectExternalLink($withpicto=0) + { + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $url='eee'; + return ''.$this->ref.''; + } + /** * Return clicable link of object (with eventually picto) * diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 62f82bc33d1..0c8fbbc733d 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -808,7 +808,7 @@ if ($source == 'invoice') print ''."\n"; // Debitor @@ -821,8 +821,8 @@ if ($source == 'invoice') $text=''.$langs->trans("PaymentInvoiceRef",$invoice->ref).''; print ''."\n"; // Amount @@ -846,13 +846,21 @@ if ($source == 'invoice') print ''."\n"; // Tag - print ''."\n"; + // Add download link + if (GETPOST('download','int') > 0) + { + print ''."\n"; + } + // Shipping address $shipToName=$invoice->thirdparty->name; $shipToStreet=$invoice->thirdparty->address; From e61032a313ebfef3ed64a4749e9b30dab2d17400 Mon Sep 17 00:00:00 2001 From: tysauron Date: Wed, 20 Sep 2017 00:53:48 +0200 Subject: [PATCH 062/114] Bug get socid with old object sosciete --- htdocs/projet/tasks/contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 3d834fe28b6..6cdbc204749 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -397,7 +397,7 @@ if ($id > 0 || ! empty($ref)) print ''; From 2f317c583400dfeb326364acd530ba9d1a98b117 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Sep 2017 19:34:14 +0200 Subject: [PATCH 063/114] Debug online payment using unique form --- htdocs/public/payment/newpayment.php | 55 ++++++++++++++-------------- htdocs/public/payment/paymentko.php | 2 +- htdocs/public/payment/paymentok.php | 5 +-- htdocs/theme/eldy/style.css.php | 4 +- htdocs/theme/md/style.css.php | 5 ++- 5 files changed, 37 insertions(+), 34 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 0c8fbbc733d..faf40e17067 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -66,21 +66,21 @@ $suffix=GETPOST("suffix",'aZ09'); $amount=price2num(GETPOST("amount",'alpha')); if (! GETPOST("currency",'alpha')) $currency=$conf->currency; else $currency=GETPOST("currency",'alpha'); -$source = GETPOST("source",'alpha'); +$source = GETPOST("s",'alpha')?GETPOST("s",'alpha'):GETPOST("source",'alpha'); if (! $action) { - if (! GETPOST("amount",'alpha') && ! GETPOST("source",'alpha')) + if (! GETPOST("amount",'alpha') && ! $source) { print $langs->trans('ErrorBadParameters')." - amount or source"; exit; } - if (is_numeric($amount) && ! GETPOST("tag",'alpha') && ! GETPOST("source",'alpha')) + if (is_numeric($amount) && ! GETPOST("tag",'alpha') && ! $source) { print $langs->trans('ErrorBadParameters')." - tag or source"; exit; } - if (GETPOST("source",'alpha') && ! GETPOST("ref",'alpha')) + if ($source && ! GETPOST("ref",'alpha')) { print $langs->trans('ErrorBadParameters')." - ref"; exit; @@ -111,7 +111,6 @@ $urlok=$urlwithroot.'/public/payment/paymentok.php?'; $urlko=$urlwithroot.'/public/payment/paymentko.php?'; // Complete urls for post treatment -$SOURCE=GETPOST("source",'alpha'); $ref=$REF=GETPOST('ref','alpha'); $TAG=GETPOST("tag",'alpha'); $FULLTAG=GETPOST("fulltag",'alpha'); // fulltag is tag with more informations @@ -123,10 +122,10 @@ if (! empty($suffix)) $urlok.='suffix='.urlencode($suffix).'&'; $urlko.='suffix='.urlencode($suffix).'&'; } -if (! empty($SOURCE)) +if ($source) { - $urlok.='source='.urlencode($SOURCE).'&'; - $urlko.='source='.urlencode($SOURCE).'&'; + $urlok.='s='.urlencode($source).'&'; + $urlko.='s='.urlencode($source).'&'; } if (! empty($REF)) { @@ -143,15 +142,16 @@ if (! empty($FULLTAG)) $urlok.='fulltag='.urlencode($FULLTAG).'&'; $urlko.='fulltag='.urlencode($FULLTAG).'&'; } +/* This make url too long. Seems not required into the back url if (! empty($SECUREKEY)) { $urlok.='securekey='.urlencode($SECUREKEY).'&'; $urlko.='securekey='.urlencode($SECUREKEY).'&'; -} +}*/ if (! empty($entity)) { - $urlok.='entity='.urlencode($entity).'&'; - $urlko.='entity='.urlencode($entity).'&'; + $urlok.='e='.urlencode($entity).'&'; + $urlko.='e='.urlencode($entity).'&'; } $urlok=preg_replace('/&$/','',$urlok); // Remove last & $urlko=preg_replace('/&$/','',$urlko); // Remove last & @@ -223,7 +223,7 @@ if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - if ($SOURCE && $REF) $token = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $SOURCE . $REF, 2); // Use the source in the hash to avoid duplicates if the references are identical + if ($source && $REF) $token = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $source . $REF, 2); // Use the source in the hash to avoid duplicates if the references are identical else $token = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); } else @@ -340,13 +340,14 @@ if ($action == 'dopayment') elseif (empty($email)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); elseif (! isValidEMail($email)) $mesg=$langs->trans("ErrorBadEMail",$email); elseif (! $origfulltag) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); - elseif (dol_strlen($urlok) > 150) $mesg='Error urlok too long '.$urlok; - elseif (dol_strlen($urlko) > 150) $mesg='Error urlko too long '.$urlko; + elseif (dol_strlen($urlok) > 150) $mesg='Error urlok too long '.$urlok.'( Paybox requires 150, found '.strlen($urlok).')'; + elseif (dol_strlen($urlko) > 150) $mesg='Error urlko too long '.$urlko.'( Paybox requires 150, found '.strlen($urlok).')'; if (empty($mesg)) { dol_syslog("newpayment.php call paybox api and do redirect", LOG_DEBUG); + include_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; print_paybox_redirect($PRICE, $conf->currency, $email, $urlok, $urlko, $FULLTAG); session_destroy(); @@ -499,10 +500,10 @@ $conf->dol_hide_leftmenu=1; llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); // Check link validity -if (! empty($SOURCE) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) +if ($source && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) { $langs->load("errors"); - dol_print_error_email('BADREFINPAYMENTFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $SOURCE, $ref)); + dol_print_error_email('BADREFINPAYMENTFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); llxFooter(); $db->close(); exit; @@ -528,7 +529,7 @@ print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; -print ''; +print ''; print "\n"; print ''."\n"; print ''."\n"; @@ -709,8 +710,8 @@ if ($source == 'order') $text=''.$langs->trans("PaymentOrderRef",$order->ref).''; print ''."\n"; // Amount @@ -821,7 +822,7 @@ if ($source == 'invoice') $text=''.$langs->trans("PaymentInvoiceRef",$invoice->ref).''; print ''."\n"; @@ -1004,8 +1005,8 @@ if ($source == 'contractline') print ''."\n"; // Quantity @@ -1146,8 +1147,8 @@ if ($source == 'membersubscription') $text=''.$langs->trans("PaymentSubscription").''; print ''."\n"; if ($member->last_subscription_date || $member->last_subscription_amount) @@ -1272,7 +1273,7 @@ if ($action != 'dopayment') if (! empty($conf->stripe->enabled)) { // If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of stripe - print '
'; + print '
'; } if (! empty($conf->paypal->enabled)) @@ -1365,12 +1366,12 @@ if (preg_match('/^dopayment/',$action)) print ''."\n"; print ''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; - print ''; + print ''; print ''."\n"; print ''."\n"; diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index cbea7db650f..bdc301a0dce 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -31,7 +31,7 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site. // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php // TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +$entity=(! empty($_GET['e']) ? (int) $_GET['e'] : (! empty($_POST['e']) ? (int) $_POST['e'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 29d2b78d142..7ccd95abcdf 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -31,7 +31,7 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site. // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php // TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +$entity=(! empty($_GET['e']) ? (int) $_GET['e'] : (! empty($_POST['e']) ? (int) $_POST['e'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; @@ -76,7 +76,7 @@ if (! empty($conf->paypal->enabled)) $FULLTAG=GETPOST('FULLTAG'); if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); -$source=GETPOST('source'); +$source=GETPOST('s','alpha')?GETPOST('s','alpha'):GETPOST('source','alpha'); $ref=GETPOST('ref'); $suffix=GETPOST("suffix",'aZ09'); @@ -145,7 +145,6 @@ $conf->dol_hide_leftmenu=1; llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); - // Show message print ''."\n"; print '
'."\n"; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 1c991f9ccd7..e6bf4d8233a 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1084,7 +1084,7 @@ div.fiche { dol_hide_leftmenu)) print 'margin-bottom: 12px;'."\n"; ?> } body.onlinepaymentbody div.fiche { /* For online payment page */ - margin: 40px !important; + margin: 20px !important; } div.fiche>table:first-child { margin-bottom: 15px !important; @@ -3139,7 +3139,7 @@ div.titre { /* text-shadow: 1px 1px 2px #FFFFFF; */ } -#dolpaymenttable { max-width: 600px; font-size: 16px; } +#dolpaymenttable { min-width: 310px; font-size: 16px; } /* Width must have min to make stripe input area visible */ #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } #tablepublicpayment .CTableRow1 { background-color: #F0F0F0 !important; } #tablepublicpayment tr.liste_total { border-bottom: 1px solid #CCCCCC !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 1ed9b433be7..64210218799 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1120,6 +1120,9 @@ div.fiche { dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> margin-bottom: 15px; } +body.onlinepaymentbody div.fiche { /* For online payment page */ + margin: 20px !important; +} div.fichecenter { width: 100%; clear: both; /* This is to have div fichecenter that are true rectangles */ @@ -3239,7 +3242,7 @@ div.titre { dol_optimize_smallscreen)?'':'margin-top: 4px;'); ?> } -#dolpaymenttable { max-width: 600px; font-size: 16px; } +#dolpaymenttable { min-width: 320px; font-size: 16px; } /* Width must have min to make stripe input area visible */ #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } #tablepublicpayment .CTableRow1 { background-color: #F0F0F0 !important; } #tablepublicpayment tr.liste_total { border-bottom: 1px solid #CCCCCC !important; } From 0eb416d4afd3a4aeee16bfae41dea2223e3e5dd1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Sep 2017 20:41:40 +0200 Subject: [PATCH 064/114] Fix removal of a file --- htdocs/ecm/docfile.php | 26 +++++++++++---------- htdocs/ecm/index.php | 34 +++++++++++++--------------- htdocs/langs/en_US/ecm.lang | 3 ++- htdocs/public/payment/newpayment.php | 3 ++- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php index 192240b4943..29f1b21a321 100644 --- a/htdocs/ecm/docfile.php +++ b/htdocs/ecm/docfile.php @@ -19,12 +19,12 @@ * \file htdocs/ecm/docfile.php * \ingroup ecm * \brief Card of a file for ECM module - * \author Laurent Destailleur */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; +require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; @@ -103,11 +103,9 @@ if (! empty($_GET["fileid"])) -/******************************************************************* - * ACTIONS - * - * Put here all code to do according to value of "action" parameter - ********************************************************************/ +/* + * Actions + */ if ($action == 'cancel') { @@ -166,11 +164,9 @@ if ($action == 'update') -/******************************************************************* - * PAGE - * - * Put here all code to do according to value of "action" parameter - ********************************************************************/ +/* + * View + */ llxHeader(); @@ -253,6 +249,13 @@ print dol_print_size($totalsize); print ''; */ +$filepath=$relativepath.$file->label; + +print '
'; + // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file @@ -264,7 +267,6 @@ $forcedownload=1; $rellink='/document.php?modulepart='.$modulepart; if ($forcedownload) $rellink.='&attachment=1'; if (! empty($object->entity)) $rellink.='&entity='.$object->entity; -$filepath=$relativepath.$file->label; $rellink.='&file='.urlencode($filepath); $fulllink=$urlwithroot.$rellink; print img_picto('','object_globe.png').' '; diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 94b1781ab81..77fb16f5afd 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -143,26 +143,24 @@ if ($action == 'confirm_deletefile') { if (GETPOST('confirm') == 'yes') { + // GETPOST('urlfile','alpha') is full relative URL from ecm root dir. Contains path of all sections. + //var_dump(GETPOST('urlfile'));exit; $langs->load("other"); - if ($section) - { - $result=$ecmdir->fetch($section); - if (! ($result > 0)) - { - dol_print_error($db,$ecmdir->error); - exit; - } - $relativepath=$ecmdir->getRelativePath(); - } - else $relativepath=''; + $upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:''); - $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP). + $file = $upload_dir . "/" . GETPOST('urlfile','alpha'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP). + //var_dump($file);exit; - $ret=dol_delete_file($file); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - - $result=$ecmdir->changeNbOfFiles('-'); + $ret=dol_delete_file($file); // This include also the delete from file index in database. + if ($ret) + { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile','alpha')), null, 'mesgs'); + $result=$ecmdir->changeNbOfFiles('-'); + } + else + { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile','alpha')), null, 'errors'); + } clearstatcache(); } @@ -375,7 +373,7 @@ else print ''; } $url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'&section='.$section:''))); -print ''; +print ''; print ''; print ''; diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index 5f651413301..a238a8cd384 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -41,4 +41,5 @@ ECMDirectoryForFiles=Relative directory for files CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files ECMFileManager=File manager ECMSelectASection=Select a directory on left tree... -DirNotSynchronizedSyncFirst=This directory seems to be created or modified outside ECM module. You must click on "Refresh" button first to synchronize disk and database to get content of this directory. +DirNotSynchronizedSyncFirst=This directory seems to be created or modified outside ECM module. You must click on "Resync" button first to synchronize disk and database to get content of this directory. +ReSyncListOfDir=Resync list of directories \ No newline at end of file diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index faf40e17067..52aa5950a92 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -67,6 +67,7 @@ $amount=price2num(GETPOST("amount",'alpha')); if (! GETPOST("currency",'alpha')) $currency=$conf->currency; else $currency=GETPOST("currency",'alpha'); $source = GETPOST("s",'alpha')?GETPOST("s",'alpha'):GETPOST("source",'alpha'); +$download = GETPOST('d','int')?GETPOST('d','int'):GETPOST('download','int'); if (! $action) { @@ -854,7 +855,7 @@ if ($source == 'invoice') print ''."\n"; // Add download link - if (GETPOST('download','int') > 0) + if ($download > 0) { print ''; */ +$relativetodocument = 'ecm/'.$relativepath; // $relativepath is relative to ECM dir, we need relative to document $filepath=$relativepath.$file->label; +$filepathtodocument=$relativetodocument.$file->label; print ''; // Define $urlwithroot @@ -261,6 +273,19 @@ $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current +print ''; + print ''; + print '
'.$langs->trans("ThisIsInformationOnPayment").' :
'.$langs->trans("ThisIsInformationOnPayment").' :
'.$langs->trans("Creditor"); print ''.$creditor.''; - print ''; + print ''; print '
'.$langs->trans("Designation"); print ''.$text; - print ''; - print ''; + print ''; + print ''; print '
'.$langs->trans("PaymentCode"); print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("Document"); + print ''; + print $invoice->getDirectExternalLink(1); + print '
'; $thirdpartyofproject=$projectstatic->getListContactId('thirdparty'); - $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$projectstatic->societe->id; + $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$projectstatic->socid; $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', $thirdpartyofproject, 0, '&withproject='.$withproject); print '
'.$langs->trans("Designation"); print ''.$text; - print ''; - print ''; + print ''; + print ''; print '
'.$langs->trans("Designation"); print ''.$text; - print ''; + print ''; print ''; print '
'.$langs->trans("Designation"); print ''.$text; - print ''; - print ''; + print ''; + print ''; print '
'.$langs->trans("Designation"); print ''.$text; - print ''; - print ''; + print ''; + print ''; print '
'.$langs->trans("HashSaved").''; +$ecmfile = new EcmFiles($db); +print $filepath; +print '
'.$langs->trans("Document"); print ''; From beac7a7439e9aa638c568b658550de4a55063ece Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Sep 2017 21:29:27 +0200 Subject: [PATCH 065/114] Work on direct download links --- htdocs/core/lib/files.lib.php | 2 +- htdocs/ecm/class/ecmfiles.class.php | 2 +- htdocs/ecm/docfile.php | 36 +++++++++++++++++++++++++---- htdocs/langs/en_US/ecm.lang | 4 +++- htdocs/langs/en_US/main.lang | 3 ++- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 238728068c9..83259aa41d2 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1537,7 +1537,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio $ecmfile=new EcmFiles($db); $ecmfile->filepath = $rel_dir; $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($destfull)); + $ecmfile->label = md5_file(dol_osencode($destfull)); // MD5 of file content $ecmfile->fullpath_orig = $TFile['name'][$i]; $ecmfile->gen_or_uploaded = 'uploaded'; $ecmfile->description = ''; // indexed content diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index f1090757dad..abe5c403462 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -46,7 +46,7 @@ class EcmFiles //extends CommonObject /** */ - public $label; + public $label; // hash of file md5_file(dol_osencode($destfull)), so MD5 of file content public $entity; public $filename; public $filepath; diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php index 29f1b21a321..045c3ebda8b 100644 --- a/htdocs/ecm/docfile.php +++ b/htdocs/ecm/docfile.php @@ -249,11 +249,23 @@ print dol_print_size($totalsize); print '
'.$langs->trans("HashSaved").''; $ecmfile = new EcmFiles($db); -print $filepath; +//$filenametosearch=basename($filepath); +//$filedirtosearch=basedir($filepath); +$ecmfile->fetch(0, '', $filepathtodocument); +if (! empty($ecmfile->label)) +{ + print $ecmfile->label; +} +else +{ + print img_warning().' '.$langs->trans("FileNotYetIndexedInDatabase"); +} print '
'.$langs->trans("DirectDownloadInternalLink").''; +$modulepart='ecm'; +$forcedownload=1; +$rellink='/document.php?modulepart='.$modulepart; +if ($forcedownload) $rellink.='&attachment=1'; +if (! empty($object->entity)) $rellink.='&entity='.$object->entity; +$rellink.='&file='.urlencode($filepath); +$fulllink=$urlwithroot.$rellink; +print img_picto('','object_globe.png').' '; +print ''; +print ' '.$langs->trans("Download").''; +print '
'.$langs->trans("DirectDownloadLink").''; $modulepart='ecm'; $forcedownload=1; @@ -269,12 +294,15 @@ if ($forcedownload) $rellink.='&attachment=1'; if (! empty($object->entity)) $rellink.='&entity='.$object->entity; $rellink.='&file='.urlencode($filepath); $fulllink=$urlwithroot.$rellink; -print img_picto('','object_globe.png').' '; -print ''; -print ' '.$langs->trans("Download").''; +// TODO +//print img_picto('','object_globe.png').' '; +//print ''; +//print ' '.$langs->trans("Download").''; print '
'; +print ajax_autoselect('downloadinternallink'); print ajax_autoselect('downloadlink'); dol_fiche_end(); diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index a238a8cd384..f7c0f0ab737 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -42,4 +42,6 @@ CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some ECMFileManager=File manager ECMSelectASection=Select a directory on left tree... DirNotSynchronizedSyncFirst=This directory seems to be created or modified outside ECM module. You must click on "Resync" button first to synchronize disk and database to get content of this directory. -ReSyncListOfDir=Resync list of directories \ No newline at end of file +ReSyncListOfDir=Resync list of directories +HashSaved=Hash of file +FileNotYetIndexedInDatabase=File not yet indexed into database (try to re-upload it) \ No newline at end of file diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 1b92d87e9ba..dfe38b7fe65 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -792,7 +792,8 @@ GroupBy=Group by... ViewFlatList=View flat list RemoveString=Remove string '%s' SomeTranslationAreUncomplete=Some languages may be partially translated or may contains errors. If you detect some, you can fix language files registering to https://transifex.com/projects/p/dolibarr/. -DirectDownloadLink=Direct download link +DirectDownloadLink=Direct download link (public/external) +DirectDownloadInternalLink=Direct download link (need to be logged and permissions) Download=Download ActualizeCurrency=Update currency rate Fiscalyear=Fiscal year From 03ffbe55ce6f6f696f915d770008cc842f3ec46c Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 21 Sep 2017 11:34:19 +0200 Subject: [PATCH 066/114] fix ressource list --- htdocs/resource/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index c4d783739c0..98efb786f72 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -237,7 +237,7 @@ print "\n"; print ''; if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'],$_SERVER["PHP_SELF"],"t.ref","",$param,"",$sortfield,$sortorder); -if (! empty($arrayfields['ty.label']['checked'])) print_liste_field_titre($arrayfields['ty.label']['label'],$_SERVER["PHP_SELF"],"t.code","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['ty.label']['checked'])) print_liste_field_titre($arrayfields['ty.label']['label'],$_SERVER["PHP_SELF"],"ty.label","",$param,"",$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { From e56840b9ec668e95647b707c186b2cc1f073de82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Sep 2017 11:35:18 +0200 Subject: [PATCH 067/114] Clean deprecated code --- htdocs/comm/action/card.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 7b1c81af59c..b491c9007cb 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -397,7 +397,7 @@ if ($action == 'update') $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); - $object->fk_action = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm'); + $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm'); $object->label = GETPOST("label"); $object->datep = $datep; $object->datef = $datef; @@ -407,8 +407,6 @@ if ($action == 'update') $object->location = GETPOST('location'); $object->socid = GETPOST("socid"); $object->contactid = GETPOST("contactid",'int'); - //$object->societe->id = $_POST["socid"]; // deprecated - //$object->contact->id = $_POST["contactid"]; // deprecated $object->fk_project = GETPOST("projectid",'int'); $object->note = GETPOST("note"); $object->pnote = GETPOST("note"); @@ -869,7 +867,7 @@ if ($id > 0) $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); - $object->fk_action = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm'); + $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm'); $object->label = GETPOST("label"); $object->datep = $datep; $object->datef = $datef; @@ -879,8 +877,6 @@ if ($id > 0) $object->location = GETPOST('location'); $object->socid = GETPOST("socid"); $object->contactid = GETPOST("contactid",'int'); - //$object->societe->id = $_POST["socid"]; // deprecated - //$object->contact->id = $_POST["contactid"]; // deprecated $object->fk_project = GETPOST("projectid",'int'); $object->note = GETPOST("note"); From 8a06a1f43372a925e18d6c854395f84212b85254 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Sep 2017 11:50:36 +0200 Subject: [PATCH 068/114] Code comment --- htdocs/projet/document.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 8777d83e419..fbf9574bd75 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -20,7 +20,7 @@ /** * \file htdocs/projet/document.php * \ingroup project - * \brief Page de gestion des documents attachees a un projet + * \brief Page to managed related documents linked to a project */ require '../main.inc.php'; @@ -106,11 +106,11 @@ if ($object->id > 0) $totalsize+=$file['size']; } - + // Project card - + $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
'; // Title $morehtmlref.=$object->title; @@ -120,19 +120,19 @@ if ($object->id > 0) $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref.='
'; - + // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + + print '
'; - print '
'; + print '
'; print ''; @@ -141,10 +141,10 @@ if ($object->id > 0) print ''; print "
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
\n"; - + print '
'; - + dol_fiche_end(); $modulepart = 'project'; From 23604a2b54dd2905885e35099252239d022488dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Sep 2017 11:54:37 +0200 Subject: [PATCH 069/114] NEW Add hidden option PROJECT_DISABLE_UNLINK_FROM_OVERVIEW --- htdocs/projet/element.php | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 1e4d4132944..f76b6f9f0cc 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -643,33 +643,6 @@ foreach ($listofreferent as $key => $value) $total_ttc = -$total_ttc; } - /*switch ($classname) { - case 'FactureFournisseur': - $newclassname = 'SupplierInvoice'; - break; - case 'Facture': - $newclassname = 'Bill'; - break; - case 'Propal': - $newclassname = 'CommercialProposal'; - break; - case 'Commande': - $newclassname = 'Order'; - break; - case 'Expedition': - $newclassname = 'Sending'; - break; - case 'Contrat': - $newclassname = 'Contract'; - break; - case 'MouvementStock': - $newclassname = 'StockMovement'; - break; - default: - $newclassname = $classname; - }*/ - - $var = ! $var; print ''; // Module print ''.$name.''; @@ -693,7 +666,6 @@ print ''; print ""; - print '

'; print '
'; @@ -771,7 +743,7 @@ foreach ($listofreferent as $key => $value) print ''; print ''; - // Remove link + // Remove link column print ''; // Ref print ''.$langs->trans("Ref").''; @@ -862,11 +834,15 @@ foreach ($listofreferent as $key => $value) } print ''; + // Remove link print '\n"; From 296e678c1be26500c87a56bc46fbe0db84573b7b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Sep 2017 12:02:46 +0200 Subject: [PATCH 070/114] Solve url too long with paybox --- htdocs/public/payment/newpayment.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 52aa5950a92..1862a5b8a47 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -143,12 +143,11 @@ if (! empty($FULLTAG)) $urlok.='fulltag='.urlencode($FULLTAG).'&'; $urlko.='fulltag='.urlencode($FULLTAG).'&'; } -/* This make url too long. Seems not required into the back url if (! empty($SECUREKEY)) { $urlok.='securekey='.urlencode($SECUREKEY).'&'; $urlko.='securekey='.urlencode($SECUREKEY).'&'; -}*/ +} if (! empty($entity)) { $urlok.='e='.urlencode($entity).'&'; @@ -336,6 +335,10 @@ if ($action == 'dopayment') $origfulltag=GETPOST("fulltag",'alpha'); + // Securekey into back url useless for back url and we need an url lower than 150. + $urlok = preg_replace('/securekey=[^&]+/', '', $urlok); + $urlko = preg_replace('/securekey=[^&]+/', '', $urlko); + $mesg=''; if (empty($PRICE) || ! is_numeric($PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); elseif (empty($email)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); From 96efe43e3cbcc8c8f7a94b5187be927cbc679068 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Sep 2017 12:48:07 +0200 Subject: [PATCH 071/114] NEW Provide a way to download a file from a public URL. --- htdocs/document.php | 37 ++++++++++++++++++++++++++--- htdocs/ecm/class/ecmfiles.class.php | 15 +++++++++--- htdocs/ecm/docfile.php | 30 ++++++++++++++--------- 3 files changed, 65 insertions(+), 17 deletions(-) diff --git a/htdocs/document.php b/htdocs/document.php index d35021005e6..c09441ea0ed 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -59,24 +59,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $encoding = ''; $action=GETPOST('action','alpha'); -$original_file=GETPOST('file','alpha'); // Do not use urldecode here ($_GET are already decoded by PHP). +$original_file=GETPOST('file','alpha'); // Do not use urldecode here ($_GET are already decoded by PHP). +$hashn=GETPOST('hashn','aZ09'); +$hashc=GETPOST('hashc','aZ09'); $modulepart=GETPOST('modulepart','alpha'); $urlsource=GETPOST('urlsource','alpha'); $entity=GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity; // Security check -if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); +if (empty($modulepart)) accessforbidden('Bad link. Bad value for parameter modulepart',0,0,1); +if (empty($original_file) && empty($hashn) && empty($hashc)) accessforbidden('Bad link. Missing identification to find file (original_file, hasn or hashc)',0,0,1); if ($modulepart == 'fckeditor') $modulepart='medias'; // For backward compatibility $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; // For some module part, dir may be privates -if (in_array($modulepart,array('facture_paiement','unpaid'))) +if (in_array($modulepart, array('facture_paiement','unpaid'))) { if (! $user->rights->societe->client->voir || $socid) $original_file='private/'.$user->id.'/'.$original_file; // If user has no permission to see all, output dir is specific to user } + /* * Action */ @@ -99,6 +103,33 @@ if (preg_match('/\.(html|htm)$/i',$original_file)) $attachment = false; if (isset($_GET["attachment"])) $attachment = GETPOST("attachment",'alpha')?true:false; if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; +// If we have a hash (hashc or hashn), we guess the original_file. Note: using hashn is not reliable. +if (! empty($hashn) || ! empty($hashc)) +{ + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($db); + $result = $ecmfile->fetch(0, $hashn, '', $hashc); + if ($result > 0) + { + $tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepatch is relative to document directory + $moduleparttocheck = $tmp[0]; + if ($moduleparttocheck == $modulepart) + { + $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir + //var_dump($original_file); exit; + } + else + { + accessforbidden('Bad link. File owns to another module part.',0,0,1); + } + } + else + { + accessforbidden('Bad link. File was not found or removed recently.',0,0,1); + } +} + + // Security: Delete string ../ into $original_file $original_file = str_replace("../","/", $original_file); diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index abe5c403462..77fa294aeed 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -157,6 +157,7 @@ class EcmFiles //extends CommonObject // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; + $sql.= 'ref,'; $sql.= 'label,'; $sql.= 'entity,'; $sql.= 'filename,'; @@ -174,6 +175,7 @@ class EcmFiles //extends CommonObject $sql.= 'fk_user_m,'; $sql.= 'acl'; $sql .= ') VALUES ('; + $sql .= " '".dol_hash($this->filepath.'/'.$this->filename, 3)."', "; $sql .= ' '.(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").','; $sql .= ' '.(! isset($this->entity)?$conf->entity:$this->entity).','; $sql .= ' '.(! isset($this->filename)?'NULL':"'".$this->db->escape($this->filename)."'").','; @@ -232,11 +234,12 @@ class EcmFiles //extends CommonObject * Load object in memory from the database * * @param int $id Id object - * @param string $ref Not used yet. Will contains a hash id from filename+filepath + * @param string $ref Hash of file name (filename+filepath). Not always defined on some version. * @param string $relativepath Relative path of file from document directory. Example: path/path2/file + * @param string $hashoffile Hash of file content. Take the first one found if same file is at different places. This hash will also change if file content is changed. * @return int <0 if KO, 0 if not found, >0 if OK */ - public function fetch($id, $ref = null, $relativepath = '') + public function fetch($id, $ref = '', $relativepath = '', $hashoffile='') { dol_syslog(__METHOD__, LOG_DEBUG); @@ -268,11 +271,16 @@ class EcmFiles //extends CommonObject if ($relativepath) { $sql .= " AND t.filepath = '" . $this->db->escape(dirname($relativepath)) . "' AND t.filename = '".$this->db->escape(basename($relativepath))."'"; } - elseif (null !== $ref) { + elseif (! empty($ref)) { $sql .= " AND t.ref = '".$this->db->escape($ref)."'"; + } + elseif (! empty($hashoffile)) { + $sql .= " AND t.label = '".$this->db->escape($hashoffile)."'"; } else { $sql .= ' AND t.rowid = ' . $id; } + $this->db->plimit(1); + $this->db->order('t.rowid', 'ASC'); // When we search on hash of content, we take the first one. $resql = $this->db->query($sql); if ($resql) { @@ -484,6 +492,7 @@ class EcmFiles //extends CommonObject // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; + $sql .= ' ref = '.dol_hash($this->filepath.'/'.$this->filename, 3); $sql .= ' label = '.(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").','; $sql .= ' entity = '.(isset($this->entity)?$this->entity:$conf->entity).','; $sql .= ' filename = '.(isset($this->filename)?"'".$this->db->escape($this->filename)."'":"null").','; diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php index 045c3ebda8b..aa708a85f24 100644 --- a/htdocs/ecm/docfile.php +++ b/htdocs/ecm/docfile.php @@ -287,17 +287,25 @@ print ' '.$langs->trans("Download").''; print ''; print ''; print '
'; if ($tablename != 'projet_task' && $tablename != 'stock_mouvement') { - print '' . img_picto($langs->trans('Unlink'), 'editdelete') . ''; + if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) // PROJECT_DISABLE_UNLINK_FROM_OVERVIEW is empty by defaut, so this test true + { + print '' . img_picto($langs->trans('Unlink'), 'editdelete') . ''; + } } print "
'.$langs->trans("DirectDownloadLink").''; -$modulepart='ecm'; -$forcedownload=1; -$rellink='/document.php?modulepart='.$modulepart; -if ($forcedownload) $rellink.='&attachment=1'; -if (! empty($object->entity)) $rellink.='&entity='.$object->entity; -$rellink.='&file='.urlencode($filepath); -$fulllink=$urlwithroot.$rellink; -// TODO -//print img_picto('','object_globe.png').' '; -//print ''; -//print ' '.$langs->trans("Download").''; +if (! empty($ecmfile->ref) || ! empty($ecmfile->label)) +{ + $modulepart='ecm'; + $forcedownload=1; + $rellink='/document.php?modulepart='.$modulepart; + if ($forcedownload) $rellink.='&attachment=1'; + if (! empty($object->entity)) $rellink.='&entity='.$object->entity; + //$rellink.='&file='.urlencode($filepath); // No need of name of file for public link, we will use the hash + $fulllink=$urlwithroot.$rellink; + if (! empty($ecmfile->ref)) $fulllink.='&hashn='.$ecmfile->ref; // Hash of file path + elseif (! empty($ecmfile->label)) $fulllink.='&hashc='.$ecmfile->label; // Hash of file content + print img_picto('','object_globe.png').' '; + print ''; + print ' '.$langs->trans("Download").''; +} +else +{ + print img_warning().' '.$langs->trans("FileNotYetIndexedInDatabase"); +} print '
'; From 57358f0ce5d5a626f38ae87385c493b5fde641fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Sep 2017 14:02:42 +0200 Subject: [PATCH 072/114] NEW Provide a way to download a file from a public URL for files in ECM --- htdocs/document.php | 11 +- htdocs/ecm/class/ecmfiles.class.php | 43 ++++- htdocs/ecm/docfile.php | 162 +++++++++++------- .../install/mysql/migration/6.0.0-7.0.0.sql | 5 + htdocs/install/mysql/tables/llx_ecm_files.sql | 5 +- htdocs/langs/en_US/ecm.lang | 5 +- htdocs/langs/en_US/main.lang | 3 +- htdocs/langs/en_US/website.lang | 2 +- 8 files changed, 158 insertions(+), 78 deletions(-) diff --git a/htdocs/document.php b/htdocs/document.php index c09441ea0ed..590d47d2c13 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -60,15 +60,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $encoding = ''; $action=GETPOST('action','alpha'); $original_file=GETPOST('file','alpha'); // Do not use urldecode here ($_GET are already decoded by PHP). -$hashn=GETPOST('hashn','aZ09'); -$hashc=GETPOST('hashc','aZ09'); +$hashp=GETPOST('hashp','aZ09'); $modulepart=GETPOST('modulepart','alpha'); $urlsource=GETPOST('urlsource','alpha'); $entity=GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity; // Security check if (empty($modulepart)) accessforbidden('Bad link. Bad value for parameter modulepart',0,0,1); -if (empty($original_file) && empty($hashn) && empty($hashc)) accessforbidden('Bad link. Missing identification to find file (original_file, hasn or hashc)',0,0,1); +if (empty($original_file) && empty($hashp)) accessforbidden('Bad link. Missing identification to find file (original_file or hashp)',0,0,1); if ($modulepart == 'fckeditor') $modulepart='medias'; // For backward compatibility $socid=0; @@ -103,12 +102,12 @@ if (preg_match('/\.(html|htm)$/i',$original_file)) $attachment = false; if (isset($_GET["attachment"])) $attachment = GETPOST("attachment",'alpha')?true:false; if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; -// If we have a hash (hashc or hashn), we guess the original_file. Note: using hashn is not reliable. -if (! empty($hashn) || ! empty($hashc)) +// If we have a hash public (hashp), we guess the original_file. +if (! empty($hashp)) { include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; $ecmfile=new EcmFiles($db); - $result = $ecmfile->fetch(0, $hashn, '', $hashc); + $result = $ecmfile->fetch(0, '', '', '', $hashp); if ($result > 0) { $tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepatch is relative to document directory diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 77fa294aeed..0035b18d3c7 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -46,7 +46,9 @@ class EcmFiles //extends CommonObject /** */ - public $label; // hash of file md5_file(dol_osencode($destfull)), so MD5 of file content + public $ref; // hash of file path + public $label; // hash of file content (md5_file(dol_osencode($destfull)) + public $share; // hash for file sharing. empty by default public $entity; public $filename; public $filepath; @@ -94,10 +96,15 @@ class EcmFiles //extends CommonObject $error = 0; // Clean parameters - + if (isset($this->ref)) { + $this->ref = trim($this->ref); + } if (isset($this->label)) { $this->label = trim($this->label); } + if (isset($this->share)) { + $this->share = trim($this->share); + } if (isset($this->entity)) { $this->entity = trim($this->entity); } @@ -136,6 +143,10 @@ class EcmFiles //extends CommonObject } if (empty($this->date_c)) $this->date_c = dol_now(); + // If ref not defined + if (empty($ref)) $ref = dol_hash($this->filepath.'/'.$this->filename, 3); + + $maxposition=0; if (empty($this->position)) // Get max used { @@ -159,6 +170,7 @@ class EcmFiles //extends CommonObject $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; $sql.= 'ref,'; $sql.= 'label,'; + $sql.= 'share,'; $sql.= 'entity,'; $sql.= 'filename,'; $sql.= 'filepath,'; @@ -175,8 +187,9 @@ class EcmFiles //extends CommonObject $sql.= 'fk_user_m,'; $sql.= 'acl'; $sql .= ') VALUES ('; - $sql .= " '".dol_hash($this->filepath.'/'.$this->filename, 3)."', "; + $sql .= " '".$ref."', "; $sql .= ' '.(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").','; + $sql .= ' '.(! isset($this->share)?'NULL':"'".$this->db->escape($this->share)."'").','; $sql .= ' '.(! isset($this->entity)?$conf->entity:$this->entity).','; $sql .= ' '.(! isset($this->filename)?'NULL':"'".$this->db->escape($this->filename)."'").','; $sql .= ' '.(! isset($this->filepath)?'NULL':"'".$this->db->escape($this->filepath)."'").','; @@ -237,9 +250,10 @@ class EcmFiles //extends CommonObject * @param string $ref Hash of file name (filename+filepath). Not always defined on some version. * @param string $relativepath Relative path of file from document directory. Example: path/path2/file * @param string $hashoffile Hash of file content. Take the first one found if same file is at different places. This hash will also change if file content is changed. + * @param string $hashforshare Hash of file sharing. * @return int <0 if KO, 0 if not found, >0 if OK */ - public function fetch($id, $ref = '', $relativepath = '', $hashoffile='') + public function fetch($id, $ref = '', $relativepath = '', $hashoffile='', $hashforshare='') { dol_syslog(__METHOD__, LOG_DEBUG); @@ -247,6 +261,7 @@ class EcmFiles //extends CommonObject $sql .= ' t.rowid,'; $sql .= " t.ref,"; $sql .= " t.label,"; + $sql .= " t.share,"; $sql .= " t.entity,"; $sql .= " t.filename,"; $sql .= " t.filepath,"; @@ -276,11 +291,15 @@ class EcmFiles //extends CommonObject } elseif (! empty($hashoffile)) { $sql .= " AND t.label = '".$this->db->escape($hashoffile)."'"; + } + elseif (! empty($hashforshare)) { + $sql .= " AND t.share = '".$this->db->escape($hashforshare)."'"; } else { $sql .= ' AND t.rowid = ' . $id; } + // When we search on hash of content, we take the first one. Solve also hash conflict. $this->db->plimit(1); - $this->db->order('t.rowid', 'ASC'); // When we search on hash of content, we take the first one. + $this->db->order('t.rowid', 'ASC'); $resql = $this->db->query($sql); if ($resql) { @@ -291,6 +310,7 @@ class EcmFiles //extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->ref; $this->label = $obj->label; + $this->share = $obj->share; $this->entity = $obj->entity; $this->filename = $obj->filename; $this->filepath = $obj->filepath; @@ -352,6 +372,7 @@ class EcmFiles //extends CommonObject $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.label,"; + $sql .= " t.share,"; $sql .= " t.entity,"; $sql .= " t.filename,"; $sql .= " t.filepath,"; @@ -401,8 +422,9 @@ class EcmFiles //extends CommonObject $line = new EcmfilesLine(); $line->id = $obj->rowid; - + $line->ref = $obj->ref; $line->label = $obj->label; + $line->share = $obj->share; $line->entity = $obj->entity; $line->filename = $obj->filename; $line->filepath = $obj->filepath; @@ -446,9 +468,15 @@ class EcmFiles //extends CommonObject // Clean parameters + if (isset($this->ref)) { + $this->ref = trim($this->ref); + } if (isset($this->label)) { $this->label = trim($this->label); } + if (isset($this->share)) { + $this->share = trim($this->share); + } if (isset($this->entity)) { $this->entity = trim($this->entity); } @@ -492,8 +520,9 @@ class EcmFiles //extends CommonObject // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= ' ref = '.dol_hash($this->filepath.'/'.$this->filename, 3); + $sql .= " ref = '".dol_hash($this->filepath.'/'.$this->filename, 3)."',"; $sql .= ' label = '.(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").','; + $sql .= ' share = '.(! empty($this->share)?"'".$this->db->escape($this->share)."'":"null").','; $sql .= ' entity = '.(isset($this->entity)?$this->entity:$conf->entity).','; $sql .= ' filename = '.(isset($this->filename)?"'".$this->db->escape($this->filename)."'":"null").','; $sql .= ' filepath = '.(isset($this->filepath)?"'".$this->db->escape($this->filepath)."'":"null").','; diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php index aa708a85f24..a856ab22c36 100644 --- a/htdocs/ecm/docfile.php +++ b/htdocs/ecm/docfile.php @@ -39,6 +39,9 @@ $langs->load("bills"); $langs->load("contracts"); $langs->load("categories"); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); + if (!$user->rights->ecm->setup) accessforbidden(); // Get parameters @@ -61,8 +64,6 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="label"; -$cancel=GETPOST('cancel','alpha'); -$action=GETPOST('action','aZ09'); $section=GETPOST("section"); if (! $section) { @@ -87,19 +88,25 @@ if (! $result > 0) $relativepath=$ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; +$fullpath=$conf->ecm->dir_output.'/'.$relativepath.$urlfile; -/* -$ecmfile = new ECMFile($db); -if (! empty($_GET["fileid"])) +$file = new stdClass(); +$file->section_id=$ecmdir->id; +$file->label=$urlfile; + +$relativetodocument = 'ecm/'.$relativepath; // $relativepath is relative to ECM dir, we need relative to document +$filepath=$relativepath.$file->label; +$filepathtodocument=$relativetodocument.$file->label; + +// Try to load object from index +$object = new ECMFiles($db); +$result=$object->fetch(0, '', $filepathtodocument); +if (! ($result >= 0)) { - $result=$ecmfile->fetch($_GET["fileid"]); - if (! $result > 0) - { - dol_print_error($db,$ecmfile->error); - exit; - } + dol_print_error($db, $object->error, $object->errors); + exit; } -*/ + @@ -107,7 +114,7 @@ if (! empty($_GET["fileid"])) * Actions */ -if ($action == 'cancel') +if ($cancel) { $action =''; if ($backtourl) @@ -117,7 +124,7 @@ if ($action == 'cancel') } else { - header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager§ion='.$section); + header("Location: ".DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.$urlfile.'§ion='.$section); exit; } } @@ -127,8 +134,9 @@ if ($action == 'update') { $error=0; - $oldlabel=GETPOST('urlfile'); - $newlabel=GETPOST('label'); + $oldlabel=GETPOST('urlfile', 'alpha'); + $newlabel=GETPOST('label', 'alpha'); + $shareenabled = GETPOST('shareenabled', 'alpha'); //$db->begin(); @@ -142,7 +150,7 @@ if ($action == 'update') //print $oldfile.' - '.$newfile; if ($newlabel != $oldlabel) { - $result=dol_move($oldfile, $newfile); + $result=dol_move($oldfile, $newfile); // This include update of database if (! $result) { $langs->load('errors'); @@ -151,14 +159,39 @@ if ($action == 'update') } } + // Now we update index of file + $db->begin(); + if (! $error) { - //$db->commit(); + if (is_object($object)) + { + if ($shareenabled) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $object->share = getRandomPassword(true); + } + else + { + $object->share = ''; + } + $result = $object->update($user); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if (!$error) + { + $db->commit(); $urlfile=$newlabel; } else { - //$db->rollback(); + $db->rollback(); } } @@ -168,25 +201,20 @@ if ($action == 'update') * View */ -llxHeader(); - $form=new Form($db); -$fullpath=$conf->ecm->dir_output.'/'.$relativepath.$urlfile; - -$file = new stdClass(); -$file->section_id=$ecmdir->id; -$file->label=$urlfile; +llxHeader(); $head = ecm_file_prepare_head($file); -if ($_GET["action"] == 'edit') +if ($action == 'edit') { print ''; print ''; print ''; print ''; print ''; + print ''; } dol_fiche_head($head, 'card', $langs->trans("File"), 0, 'generic'); @@ -217,11 +245,11 @@ while ($tmpecmdir && $result > 0) print img_picto('','object_dir').' '.$langs->trans("ECMRoot").' -> '; print $s; print ' -> '; -if (GETPOST('action','aZ09') == 'edit') print ''; +if ($action == 'edit') print ''; else print $urlfile; print ''; /*print ''.$langs->trans("Description").''; -if ($_GET["action"] == 'edit') +if ($action == 'edit') { print ''; + } + else + { + print ''; + } + print ''; print ''; } print ''."\n"; @@ -292,7 +304,7 @@ if ($action == 'create') // Part to edit record if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("MyModule")); + print load_fiche_titre($langs->trans("MyObject")); print ''; print ''; @@ -308,9 +320,21 @@ if (($id || $ref) && $action == 'edit') print ''.$langs->trans($val['label']).''; - print ''; + print ''; + if ($val['type'] == 'text') + { + print ''; + } + else + { + print ''; + } + print ''; print ''; } print ''; @@ -326,6 +350,7 @@ if (($id || $ref) && $action == 'edit') + // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 35731bc3bb0..96947035113 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -275,11 +275,11 @@ if ($action == 'add') } else { - $objectpage->title = GETPOST('WEBSITE_TITLE'); - $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); - $objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); - $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS'); - $objectpage->lang = GETPOST('WEBSITE_LANG'); + $objectpage->title = GETPOST('WEBSITE_TITLE','alpha'); + $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME','alpha'); + $objectpage->description = GETPOST('WEBSITE_DESCRIPTION','alpha'); + $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS','alpha'); + $objectpage->lang = GETPOST('WEBSITE_LANG','alpha'); } if (! $error) @@ -392,7 +392,7 @@ if ($action == 'updatecss') // $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page $htmlheadercontent.= "// END PHP ?>\n";*/ - $htmlheadercontent.= preg_replace(array('/\n*/ims','/<\/html>\n*/ims'),array('',''),GETPOST('WEBSITE_HTML_HEADER')); + $htmlheadercontent.= preg_replace(array('/\n*/ims','/<\/html>\n*/ims'),array('',''),GETPOST('WEBSITE_HTML_HEADER', 'none')); /*$htmlheadercontent.= "\n".'\n"; - $csscontent.= GETPOST('WEBSITE_CSS_INLINE'); + $csscontent.= GETPOST('WEBSITE_CSS_INLINE', 'none'); $csscontent.= "\n".'\n";*/ - $robotcontent.= GETPOST('WEBSITE_ROBOT'); + $robotcontent.= GETPOST('WEBSITE_ROBOT', 'none'); /*$robotcontent.= "\n".'\n";*/ - $htaccesscontent.= GETPOST('WEBSITE_HTACCESS'); + $htaccesscontent.= GETPOST('WEBSITE_HTACCESS', 'none'); /*$robotcontent.= "\n".'old_object = clone $objectpage; - $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); - $objectpage->title = GETPOST('WEBSITE_TITLE'); - $objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); - $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS'); - $objectpage->lang = GETPOST('WEBSITE_LANG'); + $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); + $objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha'); + $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); + $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); + $objectpage->lang = GETPOST('WEBSITE_LANG', 'alpha'); $res = $objectpage->update($user); if (! $res > 0) From a94f2b07e1c6a759a8888d02c1bccc83a12b8263 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Sep 2017 02:46:33 +0200 Subject: [PATCH 091/114] Fix css --- htdocs/core/boxes/modules_boxes.php | 2 +- htdocs/theme/eldy/style.css.php | 9 +++++---- htdocs/theme/md/style.css.php | 9 +++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 9c496964942..93b8fa3d9d2 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -286,7 +286,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" if (isset($contents[$i])) { // TR - if (isset($contents[$i][0]['tr'])) $out.= ''; + if (isset($contents[$i][0]['tr'])) $out.= ''; else $out.= ''; // Loop on each TD diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index e6bf4d8233a..2cf1f276d24 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -52,7 +52,7 @@ $colortexttitlenotab='100,60,20'; $colortexttitle='0,0,0'; $colortext='0,0,0'; $colortextlink='0,0,100'; -$fontsize='13'; +$fontsize='14'; $fontsizesmaller='12'; if (defined('THEME_ONLY_CONSTANT')) return; @@ -118,7 +118,7 @@ if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) $conf->global->THEME_ELDY_BACKTABCARD1='255,255,255'; // card $conf->global->THEME_ELDY_BACKTABACTIVE='234,234,234'; $conf->global->THEME_ELDY_TEXT='0,0,0'; - $conf->global->THEME_ELDY_FONT_SIZE1='13'; + $conf->global->THEME_ELDY_FONT_SIZE1='14'; $conf->global->THEME_ELDY_FONT_SIZE2='12'; } @@ -3025,11 +3025,12 @@ div.warning { color: #302020; padding: 0.3em 0.3em 0.3em 0.3em; margin: 0.5em 0em 0.5em 0em; - border: 1px solid #e0d0b0; + /* border: 1px solid #e0d0b0; */ + border: 2px solid #805000; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; - background: #EFDF9A; + /* background: #EFDF9A; */ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 64210218799..a3bc638aec1 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -53,7 +53,7 @@ $colortexttitlenotab='90,90,90'; $colortexttitle='20,20,20'; $colortext='0,0,0'; $colortextlink='0,0,120'; -$fontsize='13'; +$fontsize='14'; $fontsizesmaller='11'; if (defined('THEME_ONLY_CONSTANT')) return; @@ -120,7 +120,7 @@ if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) $conf->global->THEME_ELDY_BACKTABCARD1='255,255,255'; // card $conf->global->THEME_ELDY_BACKTABACTIVE='234,234,234'; $conf->global->THEME_ELDY_TEXT='0,0,0'; - $conf->global->THEME_ELDY_FONT_SIZE1='13'; + $conf->global->THEME_ELDY_FONT_SIZE1='14'; $conf->global->THEME_ELDY_FONT_SIZE2='11'; } @@ -3124,11 +3124,12 @@ div.warning { color: #302020; padding: 0.3em 0.3em 0.3em 0.3em; margin: 0.5em 0em 0.5em 0em; - border: 1px solid #e0d0b0; + /* border: 1px solid #e0d0b0; */ + border: 2px solid #805000 -moz-border-radius:3px; -webkit-border-radius: 3px; border-radius: 3px; - background: #EFDF9A; + /* background: #EFDF9A; */ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); } From 839f3ca41dd39d37e870fc2cf57aa810315887fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Sep 2017 03:22:48 +0200 Subject: [PATCH 092/114] NEW Can use an url like $conf->global>-MYPARAM for menu urls --- htdocs/core/menus/standard/auguria.lib.php | 7 +++++++ htdocs/core/menus/standard/eldy.lib.php | 7 +++++++ htdocs/theme/eldy/style.css.php | 4 ++-- htdocs/theme/md/style.css.php | 4 ++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 5fc0ab2c516..9119afc7696 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -73,6 +73,13 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m $showmode=dol_auguria_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal); if ($showmode == 1) { + // $menu_array[$i]['url'] can be a relative url, a full external url or a dynamic value like '$conf->global->APARAM) + if (preg_match('/^\$conf->global->([^\?]+)/', $newTabMenu[$i]['url'], $reg)) + { + $keyforsconst=$reg[1]; + $newTabMenu[$i]['url'] = $conf->global->$keyforsconst; + } + $url = $shorturl = $newTabMenu[$i]['url']; if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 8c03d0c1ffc..013b6ea74ae 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1598,6 +1598,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } } + // $menu_array[$i]['url'] can be a relative url, a full external url or a dynamic value like '$conf->global->APARAM) + if (preg_match('/^\$conf->global->([^\?]+)/', $menu_array[$i]['url'], $reg)) + { + $keyforsconst=$reg[1]; + $menu_array[$i]['url'] = $conf->global->$keyforsconst; + } + $url = $shorturl = $menu_array[$i]['url']; if (! preg_match("/^(http:\/\/|https:\/\/)/i",$menu_array[$i]['url'])) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 2cf1f276d24..5226cb266e5 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -52,7 +52,7 @@ $colortexttitlenotab='100,60,20'; $colortexttitle='0,0,0'; $colortext='0,0,0'; $colortextlink='0,0,100'; -$fontsize='14'; +$fontsize='13'; $fontsizesmaller='12'; if (defined('THEME_ONLY_CONSTANT')) return; @@ -118,7 +118,7 @@ if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) $conf->global->THEME_ELDY_BACKTABCARD1='255,255,255'; // card $conf->global->THEME_ELDY_BACKTABACTIVE='234,234,234'; $conf->global->THEME_ELDY_TEXT='0,0,0'; - $conf->global->THEME_ELDY_FONT_SIZE1='14'; + $conf->global->THEME_ELDY_FONT_SIZE1='13'; $conf->global->THEME_ELDY_FONT_SIZE2='12'; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a3bc638aec1..283f1aad16f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -53,7 +53,7 @@ $colortexttitlenotab='90,90,90'; $colortexttitle='20,20,20'; $colortext='0,0,0'; $colortextlink='0,0,120'; -$fontsize='14'; +$fontsize='13'; $fontsizesmaller='11'; if (defined('THEME_ONLY_CONSTANT')) return; @@ -120,7 +120,7 @@ if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) $conf->global->THEME_ELDY_BACKTABCARD1='255,255,255'; // card $conf->global->THEME_ELDY_BACKTABACTIVE='234,234,234'; $conf->global->THEME_ELDY_TEXT='0,0,0'; - $conf->global->THEME_ELDY_FONT_SIZE1='14'; + $conf->global->THEME_ELDY_FONT_SIZE1='13'; $conf->global->THEME_ELDY_FONT_SIZE2='11'; } From 35d00fd2ec45cf7939eec3ca0da40a00916f4dc0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Sep 2017 09:28:31 +0200 Subject: [PATCH 093/114] Fix wrap on lites_total --- htdocs/core/boxes/box_activity.php | 2 +- htdocs/theme/eldy/style.css.php | 16 +++++++++------- htdocs/theme/md/style.css.php | 21 ++++++++++++--------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 71a9a4e3125..d3059daba53 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -435,7 +435,7 @@ class box_activity extends ModeleBoxes } // Add the sum in the bottom of the boxes - $this->info_box_contents[$line][0] = array('tr' => 'class="liste_total"'); + $this->info_box_contents[$line][0] = array('tr' => 'class="liste_total_wrap"'); $this->info_box_contents[$line][1] = array('td' => 'align="left" class="liste_total" ', 'text' => $langs->trans("Total")." ".$textHead); $this->info_box_contents[$line][2] = array('td' => 'align="right" class="liste_total" ', 'text' => $totalnb); $this->info_box_contents[$line][3] = array('td' => 'align="right" class="liste_total" ', 'text' => ''); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 5226cb266e5..4451135830c 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -863,11 +863,11 @@ div.fiche>form>div.div-table-responsive { .minwidth500imp { min-width: 250px !important; } } -/* Force values for small screen 570 */ +/* Force values for small screen 767 */ @media only screen and (max-width: 767px) { body { - font-size: px; + font-size: px; } } @@ -875,7 +875,7 @@ div.fiche>form>div.div-table-responsive { @media only screen and (max-width: 570px) { body { - font-size: px; + font-size: px; } .divmainbodylarge { margin-left: 20px !important; margin-right: 20px !important; } @@ -2749,14 +2749,16 @@ input.liste_titre { line-height: 24px; } -.noborder tr.liste_total, .noborder tr.liste_total td, tr.liste_total, form.liste_total { - /* height: 32px; */ -} -.noborder tr.liste_total td, tr.liste_total td, form.liste_total div { +.noborder tr.liste_total td, tr.liste_total td, form.liste_total div, .noborder tr.liste_total_wrap td, tr.liste_total_wrap td, form.liste_total_wrap div { color: #551188; font-weight: normal; +} +.noborder tr.liste_total td, tr.liste_total td, form.liste_total div { white-space: nowrap; } +.noborder tr.liste_total_wrap td, tr.liste_total_wrap td, form.liste_total_wrap div { + white-space: normal; +} form.liste_total div { border-top: 1px solid #DDDDDD; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 283f1aad16f..13aca2545dd 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -865,11 +865,11 @@ div.fiche>form>div.div-table-responsive { .minwidth500imp { min-width: 100px !important; } } -/* Force values for small screen 570 */ +/* Force values for small screen 767 */ @media only screen and (max-width: 767px) { body { - font-size: px; + font-size: px; } } @@ -877,7 +877,7 @@ div.fiche>form>div.div-table-responsive { @media only screen and (max-width: 570px) { body { - font-size: px; + font-size: px; } .divmainbodylarge { margin-left: 20px; margin-right: 20px; } @@ -2865,16 +2865,19 @@ input.liste_titre { border: 0px; } -.noborder tr.liste_total, .noborder tr.liste_total td, tr.liste_total, form.liste_total { - /* height: 32px; */ -} -.noborder tr.liste_total td, tr.liste_total td, form.liste_total div { - /* border-top: 1px solid #f4f4f4; */ +.noborder tr.liste_total td, tr.liste_total td, form.liste_total div, .noborder tr.liste_total_wrap td, tr.liste_total_wrap td, form.liste_total_wrap div { color: #332266; font-weight: normal; - white-space: nowrap; padding: 4px; } +.noborder tr.liste_total td, tr.liste_total td, form.liste_total div { + white-space: nowrap; +} +.noborder tr.liste_total_wrap td, tr.liste_total_wrap td, form.liste_total_wrap div { + white-space: normal; +} + + tr.liste_sub_total, tr.liste_sub_total td { border-bottom: 2px solid #aaa; } From 91beb3a4d6fed9dfa6b9faf78e7a72041e0c9ba7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Sep 2017 11:39:09 +0200 Subject: [PATCH 094/114] Debug modulebuilder --- htdocs/modulebuilder/index.php | 193 +++++++++++++++++---------------- 1 file changed, 101 insertions(+), 92 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 43f679541ab..31514435cd7 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -967,12 +967,14 @@ elseif (! empty($module)) $linktoenabledisable.=img_picto($langs->trans("Disabled"),'switch_off'); $linktoenabledisable.="\n"; } - - $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive", $urltomodulesetup); - if (! empty($conf->$module->enabled)) + if (! empty($conf->$modulelowercase->enabled)) { $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); } + else + { + $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive", $urltomodulesetup); + } $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module.($forceddirread?'@'.$dirread:''); $head2[$h][1] = $langs->trans("Description"); @@ -1308,12 +1310,12 @@ elseif (! empty($module)) //$objectname = preg_replace('/\.txt$/', '', $fileobj['name']); $objectname = $reg[1]; if (empty($firstobjectname)) $firstobjectname = $objectname; - } - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname; - $head3[$h][1] = $objectname; - $head3[$h][2] = $objectname; - $h++; + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname; + $head3[$h][1] = $objectname; + $head3[$h][2] = $objectname; + $h++; + } } $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=deleteobject'; @@ -1483,98 +1485,105 @@ elseif (! empty($module)) print ''; print ''; - // Line to add a property - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $properties = dol_sort_array($tmpobjet->fields, 'position'); - foreach($properties as $propkey => $propval) + if (! empty($properties)) { - /* If from Reflection - if ($propval->class == $tabobj) - { - $propname=$propval->getName(); - $comment=$propval->getDocComment(); - $type=gettype($tmpobjet->$propname); - $default=$propdefault[$propname]; - // Discard generic properties - if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'isnolinkedbythird', 'ismultientitymanaged'))) continue; + // Line to add a property + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - // Keep or not lines - if (in_array($propname, array('fk_element', 'lines'))) continue; - }*/ + foreach($properties as $propkey => $propval) + { + /* If from Reflection + if ($propval->class == $tabobj) + { + $propname=$propval->getName(); + $comment=$propval->getDocComment(); + $type=gettype($tmpobjet->$propname); + $default=$propdefault[$propname]; + // Discard generic properties + if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'isnolinkedbythird', 'ismultientitymanaged'))) continue; - $propname=$propkey; - $proplabel=$propval['label']; - $proptype=$propval['type']; - $propnotnull=$propval['notnull']; - $propsearchall=$propval['searchall']; - //$propdefault=$propval['default']; - $propindex=$propval['index']; - $propposition=$propval['position']; - $propenabled=$propval['enabled']; - $propvisible=$propval['visible']; - $propisameasure=$propval['isameasure']; - $propcomment=$propval['comment']; + // Keep or not lines + if (in_array($propname, array('fk_element', 'lines'))) continue; + }*/ - print ''; + $propname=$propkey; + $proplabel=$propval['label']; + $proptype=$propval['type']; + $propnotnull=$propval['notnull']; + $propsearchall=$propval['searchall']; + //$propdefault=$propval['default']; + $propindex=$propval['index']; + $propposition=$propval['position']; + $propenabled=$propval['enabled']; + $propvisible=$propval['visible']; + $propisameasure=$propval['isameasure']; + $propcomment=$propval['comment']; - print ''; - print $propname; - print ''; - print ''; - print $proplabel; - print ''; - print ''; - print $proptype; - print ''; - print ''; - print $propnotnull; - print ''; - /*print ''; - print $propdefault; - print '';*/ - print ''; - print $propindex?'X':''; - print ''; - print ''; - print $propposition; - print ''; - print ''; - print $propenabled?$propenabled:''; - print ''; - print ''; - print $propvisible?$propvisible:''; - print ''; - print ''; - print $propisameasure?$propisameasure:''; - print ''; - print ''; - print $propsearchall?'X':''; - print ''; - print ''; - print $propcomment; - print ''; - print ''; - print ''.img_delete().''; - print ''; + print ''; - print ''; + print ''; + print $propname; + print ''; + print ''; + print $proplabel; + print ''; + print ''; + print $proptype; + print ''; + print ''; + print $propnotnull; + print ''; + /*print ''; + print $propdefault; + print '';*/ + print ''; + print $propindex?'X':''; + print ''; + print ''; + print $propposition; + print ''; + print ''; + print $propenabled?$propenabled:''; + print ''; + print ''; + print $propvisible?$propvisible:''; + print ''; + print ''; + print $propisameasure?$propisameasure:''; + print ''; + print ''; + print $propsearchall?'X':''; + print ''; + print ''; + print $propcomment; + print ''; + print ''; + print ''.img_delete().''; + print ''; + + print ''; + } + } + else + { + print ''.$langs->trans('Property $field not found into the class. The class was probably not generated by modulebuilder.').''; } print ''; print ''; From 414f633e750d892269e4fc027a81d9ff4ce794dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Sep 2017 12:59:49 +0200 Subject: [PATCH 095/114] Fix css --- htdocs/core/class/html.form.class.php | 4 +- htdocs/core/class/html.formactions.class.php | 107 ++++++++++-------- htdocs/langs/en_US/modulebuilder.lang | 10 +- htdocs/modulebuilder/index.php | 32 +++++- .../template/doc/Specifications.asciidoc | 4 +- .../modulebuilder/template/myobject_card.php | 4 +- htdocs/theme/eldy/style.css.php | 4 +- 7 files changed, 103 insertions(+), 62 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ed318bbd900..931c3c5d1ce 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5551,8 +5551,8 @@ class Form { $nbofdifferenttypes = count($object->linkedObjects); - print '
'; - print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, ''); + print ''; + print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, '', 0, 0, 'showlinkedobjectblock'); print '
'; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index b93083d9a9f..84c7ab389f3 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -187,20 +187,22 @@ class FormActions elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); elseif ($typeelement == 'member') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); - else $title=$langs->trans("Actions"); + else $title=$langs->trans("LatestLinkedEvents", $max?$max:''); $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); $buttontoaddnewevent = ''; $buttontoaddnewevent.= $langs->trans("AddEvent"); $buttontoaddnewevent.= ''; + + print ''."\n"; print load_fiche_titre($title, $buttontoaddnewevent, ''); $page=0; $param=''; $total = 0; - print '
'; + print '
'; print ''; print ''; print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); @@ -214,63 +216,70 @@ class FormActions $userstatic = new User($this->db); - $cursorevent = 0; - foreach($listofactions as $action) + if (count($listofactions)) { - if ($max && $cursorevent >= $max) break; + $cursorevent = 0; + foreach($listofactions as $action) + { + if ($max && $cursorevent >= $max) break; - $ref=$action->getNomUrl(1,-1); - $label=$action->getNomUrl(0,38); + $ref=$action->getNomUrl(1,-1); + $label=$action->getNomUrl(0,38); - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; + print $action->type; + print ''; + print ''; + print ''; + print ''; + print ''; - $cursorevent++; + $cursorevent++; + } + } + else + { + print ''; } if ($max && $num > $max) { - print ''; + print ''; } print '
'.$ref.''.$label.''; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($action->type_picto) print img_picto('', $action->type_picto); - else { - if ($action->type_code == 'AC_RDV') print img_picto('', 'object_group').' '; - if ($action->type_code == 'AC_TEL') print img_picto('', 'object_phoning').' '; - if ($action->type_code == 'AC_FAX') print img_picto('', 'object_phoning_fax').' '; - if ($action->type_code == 'AC_EMAIL') print img_picto('', 'object_email').' '; - } - } - print $action->type; - print ''.dol_print_date($action->datep,'dayhour'); - if ($action->datef) - { - $tmpa=dol_getdate($action->datep); - $tmpb=dol_getdate($action->datef); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) + print '
'.$ref.''.$label.''; + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef,'hour'); + if ($action->type_picto) print img_picto('', $action->type_picto); + else { + if ($action->type_code == 'AC_RDV') print img_picto('', 'object_group').' '; + if ($action->type_code == 'AC_TEL') print img_picto('', 'object_phoning').' '; + if ($action->type_code == 'AC_FAX') print img_picto('', 'object_phoning_fax').' '; + if ($action->type_code == 'AC_EMAIL') print img_picto('', 'object_email').' '; + } } - else print '-'.dol_print_date($action->datef,'dayhour'); - } - print ''; - if (! empty($action->userownerid)) - { - $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched - print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); - } - print ''; - if (! empty($action->author->id)) - { - print $action->getLibStatut(3); - } - print '
'.dol_print_date($action->datep,'dayhour'); + if ($action->datef) + { + $tmpa=dol_getdate($action->datep); + $tmpb=dol_getdate($action->datef); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) + { + if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef,'hour'); + } + else print '-'.dol_print_date($action->datef,'dayhour'); + } + print ''; + if (! empty($action->userownerid)) + { + $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched + print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); + } + print ''; + if (! empty($action->author->id)) + { + print $action->getLibStatut(3); + } + print '
'.$langs->trans("None").'
'.$langs->trans("More").'...
'.$langs->trans("More").'...
'; diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 732514de9c1..081f67fb022 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -64,8 +64,14 @@ IsAMeasure=Is a measure DirScanned=Directory scanned NoTrigger=No trigger NoWidget=No widget +ListOfPermissionsDefined=List of defined permissions EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION) -VisibleDesc=Is field is visible in list (-1 means not shown by default but can be added into list to be viewed) +VisibleDesc=Is the field visible into list ? (Examples: 0=not visible, 1=visible by default on list, -1=not shown by default on list but can be added into list to be viewed) +IsAMeasureDesc=Can the value of field be cumulated to get a total into list ? (Examples: 1 or 0) +SearchAllDesc=Is the field used to make a search from the quick search tool ? (Examples: 1 or 0) +SpecDefDesc=Enter here all documentation you want to provide with your module that is not already defined by other tabs. You can use .md or better, the rich .asciidoc syntax. +LanguageDefDesc=Enter in this files, all the key and the translation for each language file. MenusDefDesc=Define here the menus provided by your module (once defined, they are visible into the menu editor %s) PermissionsDefDesc=Define here the new permissions provided by your module (once defined, they are visible into the default permissions setup %s) -ListOfPermissionsDefined=List of defined permissions +HooksDefDesc=Define in the module_parts['hooks'] property in the module descriptor the context of hooks you want to manage (list of contexts can be found by a search on 'initHooks(' in core code).
Edit the hook file to add code of your hooked functions (hookable functions can be found by a search on 'executeHooks' in core code). +TriggerDefDesc=Define in the trigger file the code you want to execute for each business event executed diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 31514435cd7..145d68f7c2f 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1194,6 +1194,9 @@ elseif (! empty($module)) { if ($action != 'editfile' || empty($file)) { + print $langs->trans("SpecDefDesc").'
'; + print '
'; + $specs=dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$'); foreach ($specs as $spec) @@ -1241,6 +1244,9 @@ elseif (! empty($module)) { if ($action != 'editfile' || empty($file)) { + print $langs->trans("LanguageDefDesc").'
'; + print '
'; + $langfiles=dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); foreach ($langfiles as $langfile) @@ -1419,11 +1425,14 @@ elseif (! empty($module)) print '
'; print '
'; + $urloflist = dol_buildpath(strtolower($module).'/'.strtolower($tabobj).'_list.php', 1); + $urlofcard = dol_buildpath(strtolower($module).'/'.strtolower($tabobj).'_card.php', 1); + print '
'; - print ' '.$langs->trans("PageForList").' : '.$pathtolist.''; + print ' '.$langs->trans("PageForList").' : '.$pathtolist.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.''; + print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.'?action=create'; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForAgendaTab").' : '.$pathtoagenda.''; @@ -1479,8 +1488,8 @@ elseif (! empty($module)) print ''.$langs->trans("Position").''; print ''.$form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc")).''; print ''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''; - print ''.$langs->trans("IsAMeasure").''; - print ''.$langs->trans("SearchAll").''; + print ''.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).''; + print ''.$form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")).''; print ''.$langs->trans("Comment").''; print ''; print ''; @@ -1885,8 +1894,16 @@ elseif (! empty($module)) { if ($action != 'editfile' || empty($file)) { - $pathtohook = strtolower($module).'/class/actions_'.strtolower($module).'.class.php'; - print ' '.$langs->trans("HooksFile").' : '.$pathtohook.''; + print $langs->trans("HooksDefDesc").'
'; + print '
'; + + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + + $pathtohook = strtolower($module).'/class/actions_'.strtolower($module).'.class.php'; + print ' '.$langs->trans("HooksFile").' : '.$pathtohook.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; } @@ -1926,6 +1943,9 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { + print $langs->trans("TriggerDefDesc").'
'; + print '
'; + if (! empty($triggers)) { foreach ($triggers as $trigger) diff --git a/htdocs/modulebuilder/template/doc/Specifications.asciidoc b/htdocs/modulebuilder/template/doc/Specifications.asciidoc index 7b1711cf514..d2150c0865d 100644 --- a/htdocs/modulebuilder/template/doc/Specifications.asciidoc +++ b/htdocs/modulebuilder/template/doc/Specifications.asciidoc @@ -1 +1,3 @@ -# SPECIFICATIONS OF MODULE MYMODULE FOR DOLIBARR ERP CRM \ No newline at end of file +# SPECIFICATIONS OF MODULE MYMODULE FOR DOLIBARR ERP CRM + +There is no detailed specification available yet. diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 9aa0f8cd361..97662c150da 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -534,10 +534,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; + $MAXEVENT = 10; + // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'myobject', $socid, 1); + $somethingshown = $formactions->showactions($object, 'myobject', $socid, 1, '', $MAXEVENT); print '
'; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 4451135830c..1fbd4e44037 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -719,7 +719,9 @@ div.myavailability { margin-top: 6px; margin-bottom: 12px; } - +#builddoc_form ~ .showlinkedobjectblock { + margin-top: 20px; +} /* For the long description of module */ .moduledesclong p img, .moduledesclong p a img { From 7d580105c81c4dc65ae9065f3cdac5ad94839654 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Sep 2017 13:02:25 +0200 Subject: [PATCH 096/114] Fix css --- htdocs/theme/md/style.css.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 13aca2545dd..4d46f2e781e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -730,7 +730,9 @@ div.myavailability { margin-top: 6px; margin-bottom: 12px; } - +#builddoc_form ~ .showlinkedobjectblock { + margin-top: 20px; +} /* For the long description of module */ .moduledesclong p img,.moduledesclong p a img { From bee94b32d9c98e14a761eac75522664f3eddca53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Sep 2017 15:12:25 +0200 Subject: [PATCH 097/114] Debug modulebuilder --- htdocs/core/lib/functions.lib.php | 4 +- htdocs/langs/en_US/modulebuilder.lang | 1 + htdocs/modulebuilder/index.php | 325 ++++++++++++++------------ 3 files changed, 180 insertions(+), 150 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c995c1269ad..41cd039d1e6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -601,8 +601,8 @@ function dol_include_once($relpath, $classname='') * * @param string $path Relative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile * @param int $type 0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file) - * @param int $returnemptyifnotfound If file was not found, do not return default path but an empty string - * @return string Full filesystem path (if mode=0), Full url path (if mode=1) + * @param int $returnemptyifnotfound If path==0 and if file was not found, do not return default path but an empty string + * @return string Full filesystem path (if path=0), Full url path (if mode=1) */ function dol_buildpath($path, $type=0, $returnemptyifnotfound=0) { diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 081f67fb022..0f62870b299 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -64,6 +64,7 @@ IsAMeasure=Is a measure DirScanned=Directory scanned NoTrigger=No trigger NoWidget=No widget +GoToApiExplorer=Go to API explorer ListOfPermissionsDefined=List of defined permissions EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION) VisibleDesc=Is the field visible into list ? (Examples: 0=not visible, 1=visible by default on list, -1=not shown by default on list but can be added into list to be viewed) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 145d68f7c2f..48bfb1731ae 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1395,53 +1395,66 @@ elseif (! empty($module)) $pathtosql = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.sql'; $pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($tabobj).'_extrafields.sql'; $pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.key.sql'; + + $realpathtoclass = dol_buildpath($pathtoclass, 0, 1); + $realpathtoapi = dol_buildpath($pathtoapi, 0, 1); + $realpathtoagenda = dol_buildpath($pathtoagenda, 0, 1); + $realpathtocard = dol_buildpath($pathtocard, 0, 1); + $realpathtodocument = dol_buildpath($pathtodocument, 0, 1); + $realpathtolist = dol_buildpath($pathtolist, 0, 1); + $realpathtonote = dol_buildpath($pathtonote, 0, 1); + $realpathtophpunit = dol_buildpath($pathtophpunit, 0, 1); + $realpathtosql = dol_buildpath($pathtosql, 0, 1); + $realpathtosqlextra = dol_buildpath($pathtosqlextra, 0, 1); + $realpathtosqlkey = dol_buildpath($pathtosqlkey, 0, 1); + print '
'; - print ' '.$langs->trans("ClassFile").' : '.$pathtoclass.''; + print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass?'':'').$pathtoclass.($realpathtoclass?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("ApiClassFile").' : '.$pathtoapi.''; + print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi?'':'').$pathtoapi.($realpathtoapi?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '   '.$langs->trans("GoToApiExplorer").''; print '
'; - print ' '.$langs->trans("TestClassFile").' : '.$pathtophpunit.''; + print ' '.$langs->trans("TestClassFile").' : '.($realpathtophpunit?'':'').$pathtophpunit.($realpathtophpunit?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; - print ' '.$langs->trans("SqlFile").' : '.$pathtosql.''; + print ' '.$langs->trans("SqlFile").' : '.($realpathtosql?'':'').$pathtosql.($realpathtosql?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '   '.$langs->trans("DropTableIfEmpty").''; - print '   '.$langs->trans("RunSql").''; + //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileExtraFields").' : '.$pathtosqlextra.''; + print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra?'':'').$pathtosqlextra.($realpathtosqlextra?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '   '.$langs->trans("RunSql").''; + //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileKey").' : '.$pathtosqlkey.''; + print ' '.$langs->trans("SqlFileKey").' : '.($realpathtosqlkey?'':'').$pathtosqlkey.($realpathtosqlkey?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '   '.$langs->trans("RunSql").''; + //print '   '.$langs->trans("RunSql").''; print '
'; print '
'; print '
'; - $urloflist = dol_buildpath(strtolower($module).'/'.strtolower($tabobj).'_list.php', 1); - $urlofcard = dol_buildpath(strtolower($module).'/'.strtolower($tabobj).'_card.php', 1); + $urloflist = dol_buildpath($pathtolist, 1); + $urlofcard = dol_buildpath($pathtocard, 1); print '
'; - print ' '.$langs->trans("PageForList").' : '.$pathtolist.''; + print ' '.$langs->trans("PageForList").' : '.($realpathtosql?'':'').$pathtolist.($realpathtosql?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.'?action=create'; + print ' '.$langs->trans("PageForCreateEditView").' : '.($realpathtocard?'':'').$pathtocard.($realpathtocard?'':'').'?action=create'; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("PageForAgendaTab").' : '.$pathtoagenda.''; + print ' '.$langs->trans("PageForAgendaTab").' : '.($realpathtoagenda?'':'').$pathtoagenda.($realpathtoagenda?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("PageForDocumentTab").' : '.$pathtodocument.''; + print ' '.$langs->trans("PageForDocumentTab").' : '.($realpathtodocument?'':'').$pathtodocument.($realpathtodocument?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("PageForNoteTab").' : '.$pathtonote.''; + print ' '.$langs->trans("PageForNoteTab").' : '.($realpathtonote?'':'').$pathtonote.($realpathtonote?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; @@ -1455,149 +1468,165 @@ elseif (! empty($module)) { $result = @include_once($dirread.'/'.$pathtoclass); } - if (class_exists($tabobj)) $tmpobjet = new $tabobj($db); - - $reflector = new ReflectionClass($tabobj); - $properties = $reflector->getProperties(); // Can also use get_object_vars - $propdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars - //$propstat = $reflector->getStaticProperties(); - - print load_fiche_titre($langs->trans("Properties"), '', ''); - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $properties = dol_sort_array($tmpobjet->fields, 'position'); - - if (! empty($properties)) + if (class_exists($tabobj)) { - // Line to add a property - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + try { + $tmpobjet = @new $tabobj($db); + } + catch(Exception $e) + { + dol_syslog('Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING); + } + } - foreach($properties as $propkey => $propval) + if (! empty($tmpobjet)) + { + $reflector = new ReflectionClass($tabobj); + $properties = $reflector->getProperties(); // Can also use get_object_vars + $propdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars + //$propstat = $reflector->getStaticProperties(); + + print load_fiche_titre($langs->trans("Properties"), '', ''); + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print '
'.$langs->trans("Property"); - print ' ('.$langs->trans("Example").')'; - print ''; - print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); - print ''.$langs->trans("Type").''.$langs->trans("NotNull").''.$langs->trans("DefaultValue").''.$langs->trans("DatabaseIndex").''.$langs->trans("Position").''.$form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc")).''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).''.$form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")).''.$langs->trans("Comment").'
'; - print ''; - print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $properties = dol_sort_array($tmpobjet->fields, 'position'); + + if (! empty($properties)) { - /* If from Reflection - if ($propval->class == $tabobj) - { - $propname=$propval->getName(); - $comment=$propval->getDocComment(); - $type=gettype($tmpobjet->$propname); - $default=$propdefault[$propname]; - // Discard generic properties - if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'isnolinkedbythird', 'ismultientitymanaged'))) continue; + // Line to add a property + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - // Keep or not lines - if (in_array($propname, array('fk_element', 'lines'))) continue; - }*/ + foreach($properties as $propkey => $propval) + { + /* If from Reflection + if ($propval->class == $tabobj) + { + $propname=$propval->getName(); + $comment=$propval->getDocComment(); + $type=gettype($tmpobjet->$propname); + $default=$propdefault[$propname]; + // Discard generic properties + if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'isnolinkedbythird', 'ismultientitymanaged'))) continue; - $propname=$propkey; - $proplabel=$propval['label']; - $proptype=$propval['type']; - $propnotnull=$propval['notnull']; - $propsearchall=$propval['searchall']; - //$propdefault=$propval['default']; - $propindex=$propval['index']; - $propposition=$propval['position']; - $propenabled=$propval['enabled']; - $propvisible=$propval['visible']; - $propisameasure=$propval['isameasure']; - $propcomment=$propval['comment']; + // Keep or not lines + if (in_array($propname, array('fk_element', 'lines'))) continue; + }*/ - print ''; + $propname=$propkey; + $proplabel=$propval['label']; + $proptype=$propval['type']; + $propnotnull=$propval['notnull']; + $propsearchall=$propval['searchall']; + //$propdefault=$propval['default']; + $propindex=$propval['index']; + $propposition=$propval['position']; + $propenabled=$propval['enabled']; + $propvisible=$propval['visible']; + $propisameasure=$propval['isameasure']; + $propcomment=$propval['comment']; - print ''; - print ''; - print ''; - print ''; - /*print '';*/ - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + /*print '';*/ + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + } } + else + { + print ''; + } + print '
'.$langs->trans("Property"); + print ' ('.$langs->trans("Example").')'; + print ''; + print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); + print ''.$langs->trans("Type").''.$langs->trans("NotNull").''.$langs->trans("DefaultValue").''.$langs->trans("DatabaseIndex").''.$langs->trans("Position").''.$form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc")).''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).''.$form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")).''.$langs->trans("Comment").'
'; + print ''; + print '
'; - print $propname; - print ''; - print $proplabel; - print ''; - print $proptype; - print ''; - print $propnotnull; - print ''; - print $propdefault; - print ''; - print $propindex?'X':''; - print ''; - print $propposition; - print ''; - print $propenabled?$propenabled:''; - print ''; - print $propvisible?$propvisible:''; - print ''; - print $propisameasure?$propisameasure:''; - print ''; - print $propsearchall?'X':''; - print ''; - print $propcomment; - print ''; - print ''.img_delete().''; - print '
'; + print $propname; + print ''; + print $proplabel; + print ''; + print $proptype; + print ''; + print $propnotnull; + print ''; + print $propdefault; + print ''; + print $propindex?'X':''; + print ''; + print $propposition; + print ''; + print $propenabled?$propenabled:''; + print ''; + print $propvisible?$propvisible:''; + print ''; + print $propisameasure?$propisameasure:''; + print ''; + print $propsearchall?'X':''; + print ''; + print $propcomment; + print ''; + print ''.img_delete().''; + print '
'.$langs->trans('Property $field not found into the class. The class was probably not generated by modulebuilder.').'
'; + print '
'; + + print ''; } else - { - print ''.$langs->trans('Property $field not found into the class. The class was probably not generated by modulebuilder.').''; - } - print ''; - print '
'; - - print ''; + { + print ''.$langs->trans('Failed to init the object with the new.').''; + } } catch(Exception $e) { From b4e461e7ea9f73fd3687e51d1df8e0a1fbbfe2be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Sep 2017 18:17:34 +0200 Subject: [PATCH 098/114] Debug modulebuilder --- htdocs/core/lib/modulebuilder.lib.php | 67 ++++++++++++--- htdocs/langs/en_US/modulebuilder.lang | 2 + htdocs/modulebuilder/index.php | 85 +++++++++++-------- .../template/class/myobject.class.php | 14 +-- .../modulebuilder/template/myobject_card.php | 21 ++++- 5 files changed, 129 insertions(+), 60 deletions(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 282a02835c3..23d6597b227 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -34,7 +34,7 @@ * @param string $readdir Directory source (use $destdir when not defined) * @param string $addfieldentry Array of the field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure') * @param string $delfieldentry Id of field to remove - * @return int <=0 if KO, >0 if OK + * @return int|object <=0 if KO, Object if OK */ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='', $addfieldentry=array() ,$delfieldentry='') { @@ -43,6 +43,12 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir=' if (empty($objectname)) return -1; if (empty($readdir)) $readdir=$destdir; + if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval'])) + { + dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.'); + return -1; + } + // Check parameters if (count($addfieldentry) > 0) { @@ -92,8 +98,9 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir=' { if (is_array($addfieldentry) && count($addfieldentry)) { - $name=$addfieldentry['name']; + $name=$addfieldentry['name']; unset($addfieldentry['name']); + $object->fields[$name]=$addfieldentry; } if (! empty($delfieldentry)) @@ -114,6 +121,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir=' if (count($object->fields)) { + foreach($object->fields as $key => $val) { $i++; @@ -127,11 +135,24 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir=' if ($val['comment']) $texttoinsert.= " 'comment'=>'".$val['comment']."',"; if ($val['isameasure']) $texttoinsert.= " 'isameasure'=>'".$val['isameasure']."',"; if ($val['help']) $texttoinsert.= " 'help'=>'".$val['help']."',"; + if ($val['arrayofkeyval']) + { + $texttoinsert.= " 'arrayofkeyval'=>array("; + $i=0; + foreach($val['arrayofkeyval'] as $key2 => $val2) + { + if ($i) $texttoinsert.=", "; + $texttoinsert.="'".$key2."'=>'".$val2."'"; + $i++; + } + $texttoinsert.= ")"; + } $texttoinsert.= "),\n"; } } $texttoinsert.= "\t".');'."\n"; + //print ($texttoinsert);exit; if (count($object->fields)) { @@ -162,7 +183,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir=' file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass); @chmod($pathoffiletoedittarget, octdec($newmask)); - return 1; + return $object; } catch(Exception $e) { @@ -179,12 +200,15 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir=' * @param string $objectname Name of object * @param string $newmask New mask * @param string $readdir Directory source (use $destdir when not defined) + * @param Object $object If object was already loaded/known, it is pass to avaoid another include and new. * @return int <=0 if KO, >0 if OK */ -function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='') +function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', $object=null) { global $db, $langs; + $error = 0; + if (empty($objectname)) return -1; if (empty($readdir)) $readdir=$destdir; @@ -200,11 +224,15 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='') return -1; } + // Load object from myobject.class.php try { - include_once $pathoffiletoclasssrc; - if (class_exists($objectname)) $object=new $objectname($db); - else return -1; + if (! is_object($object)) + { + include_once $pathoffiletoclasssrc; + if (class_exists($objectname)) $object=new $objectname($db); + else return -1; + } } catch(Exception $e) { @@ -235,9 +263,15 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='') $contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql); - file_put_contents($pathoffiletoedittarget, $contentsql); - @chmod($pathoffiletoedittarget, octdec($newmask)); - + $result = file_put_contents($pathoffiletoedittarget, $contentsql); + if ($result) + { + @chmod($pathoffiletoedittarget, octdec($newmask)); + } + else + { + $error++; + } // Edit .key.sql file $pathoffiletoeditsrc=$destdir.'/sql/llx_'.strtolower($objectname).'.key.sql'; @@ -265,10 +299,17 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='') dol_mkdir(dirname($pathoffiletoedittarget)); - file_put_contents($pathoffiletoedittarget, $contentsql); - @chmod($pathoffiletoedittarget, octdec($newmask)); + $result2 = file_put_contents($pathoffiletoedittarget, $contentsql); + if ($result) + { + @chmod($pathoffiletoedittarget, octdec($newmask)); + } + else + { + $error++; + } - return 1; + return $error ? -1 : 1; } diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 0f62870b299..891faa8e134 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -51,6 +51,8 @@ DatabaseIndex=Database index FileAlreadyExists=File %s already exists TriggersFile=File for triggers code HooksFile=File for hooks code +ArrayOfKeyValues=Array of key-val +ArrayOfKeyValuesDesc=Array of keys and values if field is a combo list with fixed values WidgetFile=Widget file ReadmeFile=Readme file ChangeLog=ChangeLog file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 48bfb1731ae..5ff69549182 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -337,13 +337,13 @@ if ($dirins && $action == 'initobject' && $module && $objectname) if (! $error) { // Edit the class file to write properties - $result=rebuildObjectClass($destdir, $module, $objectname, $newmask); - if ($result < 0) $error++; + $object=rebuildObjectClass($destdir, $module, $objectname, $newmask); + if (is_numeric($object) && $object < 0) $error++; } if (! $error) { // Edit sql with new properties - $result=rebuildObjectSql($destdir, $module, $objectname, $newmask); + $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, '', $object); if ($result < 0) $error++; } @@ -362,25 +362,28 @@ if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj)) dol_mkdir($destdir); $addfieldentry = array( - 'name'=>GETPOST('propname','aZ09'),'type'=>GETPOST('proptype','alpha'),'label'=>GETPOST('proplabel','alpha'),'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'), + 'name'=>GETPOST('propname','aZ09'),'label'=>GETPOST('proplabel','alpha'),'type'=>GETPOST('proptype','alpha'), + 'arrayofkeyval'=>GETPOST('proparrayofkeyval','none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' + 'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'), 'position'=>GETPOST('propposition','int'),'notnull'=>GETPOST('propnotnull','int'),'index'=>GETPOST('propindex','int'),'searchall'=>GETPOST('propsearchall','int'), 'isameasure'=>GETPOST('propisameasure','int'), 'comment'=>GETPOST('propcomment','alpha'),'help'=>GETPOST('prophelp')); + if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval'])) + { + $addfieldentry['arrayofkeyval'] = dol_json_decode($addfieldentry['arrayofkeyval'], true); + } + // Edit the class file to write properties if (! $error) { - $result=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry); - // var_dump($result);exit; - if ($result <= 0) - { - $error++; - } + $object=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry); + if (is_numeric($result) && $result <= 0) $error++; } // Edit sql with new properties if (! $error) { - $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir); + $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); if ($result <= 0) { $error++; @@ -412,14 +415,14 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) // Edit the class file to write properties if (! $error) { - $result=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, array(), $propertykey); - if ($result <= 0) $error++; + $object=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, array(), $propertykey); + if (is_numeric($object) && $object <= 0) $error++; } // Edit sql with new properties if (! $error) { - $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir); + $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); if ($result <= 0) $error++; } @@ -1410,28 +1413,28 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass?'':'').$pathtoclass.($realpathtoclass?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi?'':'').$pathtoapi.($realpathtoapi?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '   '.$langs->trans("GoToApiExplorer").''; print '
'; print ' '.$langs->trans("TestClassFile").' : '.($realpathtophpunit?'':'').$pathtophpunit.($realpathtophpunit?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; print ' '.$langs->trans("SqlFile").' : '.($realpathtosql?'':'').$pathtosql.($realpathtosql?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '   '.$langs->trans("DropTableIfEmpty").''; //print '   '.$langs->trans("RunSql").''; print '
'; print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra?'':'').$pathtosqlextra.($realpathtosqlextra?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; //print '   '.$langs->trans("RunSql").''; print '
'; print ' '.$langs->trans("SqlFileKey").' : '.($realpathtosqlkey?'':'').$pathtosqlkey.($realpathtosqlkey?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; //print '   '.$langs->trans("RunSql").''; print '
'; @@ -1443,19 +1446,19 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("PageForList").' : '.($realpathtosql?'':'').$pathtolist.($realpathtosql?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForCreateEditView").' : '.($realpathtocard?'':'').$pathtocard.($realpathtocard?'':'').'?action=create'; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForAgendaTab").' : '.($realpathtoagenda?'':'').$pathtoagenda.($realpathtoagenda?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForDocumentTab").' : '.($realpathtodocument?'':'').$pathtodocument.($realpathtodocument?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForNoteTab").' : '.($realpathtonote?'':'').$pathtonote.($realpathtonote?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '


'; @@ -1506,6 +1509,7 @@ elseif (! empty($module)) print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); print ''; print ''.$langs->trans("Type").''; + print ''.$form->textwithpicto($langs->trans("ArrayOfKeyValues"), $langs->trans("ArrayOfKeyValuesDesc")).''; print ''.$langs->trans("NotNull").''; //print ''.$langs->trans("DefaultValue").''; print ''.$langs->trans("DatabaseIndex").''; @@ -1524,18 +1528,19 @@ elseif (! empty($module)) { // Line to add a property print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; //print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -1559,6 +1564,7 @@ elseif (! empty($module)) $propname=$propkey; $proplabel=$propval['label']; $proptype=$propval['type']; + $proparrayofkeyval=$propval['arrayofkeyval']; $propnotnull=$propval['notnull']; $propsearchall=$propval['searchall']; //$propdefault=$propval['default']; @@ -1580,6 +1586,12 @@ elseif (! empty($module)) print ''; print $proptype; print ''; + print ''; + if ($proparrayofkeyval) + { + print json_encode($proparrayofkeyval); + } + print ''; print ''; print $propnotnull; print ''; @@ -1652,6 +1664,7 @@ elseif (! empty($module)) print ''; print ''; print ''; + print ''; print ''; $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 546c404eb49..259db698024 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -78,19 +78,19 @@ class MyObject extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'index'=>1, 'position'=>20), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Amount'), - 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>1000), - 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>500), - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'position'=>500), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValid', 'enabled'=>1, 'visible'=>-1, 'position'=>500), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>1, 'position'=>1000), + 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), ); public $rowid; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 97662c150da..c4826cf2792 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -270,22 +270,30 @@ if ($action == 'create') foreach($object->fields as $key => $val) { if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; - print ''; + print ''.$langs->trans($val['label']).''; + print '>'; + print $langs->trans($val['label']); + print ''; print ''; if ($val['type'] == 'text') { print ''; + } + elseif (is_array($val['arrayofkeyval'])) + { + print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')); } else { - print ''; + $cssforinput = 'minwidth100'; + print ''; } print ''; print ''; @@ -329,10 +337,15 @@ if (($id || $ref) && $action == 'edit') print ''; + } + elseif (is_array($val['arrayofkeyval'])) + { + print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')); } else { - print ''; + $cssforinput = 'minwidth100'; + print ''; } print ''; print ''; From b9f2a53b3672eb80815fc29813c7445f3a8cb53e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Sep 2017 23:51:49 +0200 Subject: [PATCH 099/114] Debug modulebuilder --- htdocs/modulebuilder/index.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 5ff69549182..02150274fda 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1398,6 +1398,8 @@ elseif (! empty($module)) $pathtosql = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.sql'; $pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($tabobj).'_extrafields.sql'; $pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.key.sql'; + $pathtolib = strtolower($module).'/lib/'.strtolower($tabobj).'.lib.php'; + $pathtopicto = strtolower($module).'/img/object_'.strtolower($tabobj).'.png'; $realpathtoclass = dol_buildpath($pathtoclass, 0, 1); $realpathtoapi = dol_buildpath($pathtoapi, 0, 1); @@ -1410,6 +1412,8 @@ elseif (! empty($module)) $realpathtosql = dol_buildpath($pathtosql, 0, 1); $realpathtosqlextra = dol_buildpath($pathtosqlextra, 0, 1); $realpathtosqlkey = dol_buildpath($pathtosqlkey, 0, 1); + $realpathtolib = dol_buildpath($pathtolib, 0, 1); + $realpathtopicto = dol_buildpath($pathtopicto, 0, 1); print '
'; print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass?'':'').$pathtoclass.($realpathtoclass?'':'').''; @@ -1459,6 +1463,16 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("PageForNoteTab").' : '.($realpathtonote?'':'').$pathtonote.($realpathtonote?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + + print '
'; + + print ' '.$langs->trans("PageForLib").' : '.($realpathtolib?'':'').$pathtolib.($realpathtodocument?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("PageForPicto").' : '.($realpathtopicto?'':'').$pathtopicto.($realpathtopicto?'':'').''; + //print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; print '


'; From 91d303465dca47d1f2ca67f23ed6b0122aa15786 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 01:36:20 +0200 Subject: [PATCH 100/114] NEW Can add html content on right of tabs --- htdocs/admin/dolistore/ajax/image.php | 3 ++- htdocs/admin/ihm.php | 14 ++++++------- htdocs/compta/bank/bankentries.php | 2 +- htdocs/compta/facture/card.php | 4 ++-- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/lib/functions.lib.php | 19 +++++++++++------- htdocs/core/search_page.php | 2 +- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/core/tpl/objectline_edit.tpl.php | 8 ++++---- htdocs/fourn/facture/card.php | 4 ++-- htdocs/langs/en_US/modulebuilder.lang | 3 ++- htdocs/modulebuilder/index.php | 20 +++++++++++-------- .../product/class/html.formproduct.class.php | 3 +-- htdocs/projet/element.php | 2 -- htdocs/theme/eldy/style.css.php | 4 +++- htdocs/theme/md/style.css.php | 8 ++++++-- 16 files changed, 57 insertions(+), 45 deletions(-) diff --git a/htdocs/admin/dolistore/ajax/image.php b/htdocs/admin/dolistore/ajax/image.php index 6d63dd3e08b..14d05a036e8 100644 --- a/htdocs/admin/dolistore/ajax/image.php +++ b/htdocs/admin/dolistore/ajax/image.php @@ -64,4 +64,5 @@ try { if ($trace[0]['args'][0] == 404) die('Bad ID'); else if ($trace[0]['args'][0] == 401) die('Bad auth key'); else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV); -} \ No newline at end of file +} + diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 7a336e6d4e7..2322ae7a057 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -230,14 +230,14 @@ if ($action == 'edit') // Edit print ''; // Default language - print ''.$langs->trans("DefaultLanguage").''; + print ''.$langs->trans("DefaultLanguage").''; print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300'); print ''; print ' '; print ''; // Multilingual GUI - print ''.$langs->trans("EnableMultilangInterface").''; + print ''.$langs->trans("EnableMultilangInterface").''; print $form->selectyesno('MAIN_MULTILANGS',$conf->global->MAIN_MULTILANGS,1); print ''; print ' '; @@ -349,9 +349,8 @@ if ($action == 'edit') // Edit print ''; // Message of the day on home page - $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); + $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount')); complete_substitutions_array($substitutionarray, $langs); - $substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey'); print ''; $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; @@ -359,7 +358,7 @@ if ($action == 'edit') // Edit { $texthelp.=$key.'
'; } - print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, ''); + print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday'); print ''; @@ -379,16 +378,15 @@ if ($action == 'edit') // Edit print ''; // Message on login page - $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','user')); + $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount','user')); complete_substitutions_array($substitutionarray, $langs); - $substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey'); print ''; $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; foreach($substitutionarray as $key => $val) { $texthelp.=$key.'
'; } - print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, ''); + print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin'); print ''; $doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); $doleditor->Create(); diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index cd4d659d743..40d2f5c8ffc 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -743,7 +743,7 @@ if ($resql) // Title $bankcateg=new BankCateg($db); - $morehtml='
'; + $morehtml='
'; $morehtml.= ' "; // ' Page '; $morehtml.=''; $morehtml.='/'.$nbtotalofpages.' '; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b3a21f9af31..8006a120996 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2550,8 +2550,8 @@ if ($action == 'create') print $desc; print '
'; - print '    0 ? 'checked':'').' /> "; - print '
    0 ? 'checked':'').' /> "; + print '    0 ? 'checked':'').' /> "; + print '
    0 ? 'checked':'').' /> "; print '
'; print '
'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 931c3c5d1ce..f2427056fb5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -544,7 +544,7 @@ class Form $disabled=0; $ret='
'; - $ret.=''; // Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks. $parameters=array(); @@ -561,7 +561,7 @@ class Form $ret.=''; // Warning: if you set submit button to disabled, post using 'Enter' will no more work. - $ret.=''; + $ret.=''; $ret.='
'; if (! empty($conf->use_javascript_ajax)) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 41cd039d1e6..f5b4b755b8d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1016,11 +1016,12 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename=' * @param int $notab -1 or 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required. * @param string $picto Add a picto on tab title * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. + * @param string $morehtmlright Add more html content on right of tabs title * @return void */ -function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0) +function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='') { - print dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath); + print dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright); } /** @@ -1032,14 +1033,17 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto * @param int $notab -1 or 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required. * @param string $picto Add a picto on tab title * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. + * @param string $morehtmlright Add more html content on right of tabs title * @return string */ -function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0) +function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='') { global $conf, $langs, $hookmanager; $out="\n".'
'."\n"; + if ($morehtmlright) $out.='
'.$morehtmlright.'
'; // Output right area first so when space is missing, text is in front of tabs and not under. + // Show title $showtitle=1; if (! empty($conf->dol_optimize_smallscreen)) $showtitle=0; @@ -1060,6 +1064,8 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi if (count($keys)) $maxkey=max($keys); } + //$conf->global->MAIN_MAXTABS_IN_CARD=3; + // Show tabs $bactive=false; // if =0 we don't use the feature @@ -1147,7 +1153,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi { $tabsname=str_replace("@", "", $picto); $out.='\n"; @@ -5213,9 +5219,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob if (empty($exclude) || ! in_array('system', $exclude)) { - $substitutionarray=array_merge($substitutionarray, array( - '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT - )); + $substitutionarray['__(AnyTranslationKey)__']=$outputlangs->trans('TranslationKey'); + $substitutionarray['__DOL_MAIN_URL_ROOT__']=DOL_MAIN_URL_ROOT; } if (empty($exclude) || ! in_array('mycompany', $exclude)) { diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index 494dddbdff3..61d39af045e 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -73,7 +73,7 @@ if ($conf->use_javascript_ajax && 1 == 2) // select2 is ko with jmobile { if (! is_object($form)) $form=new Form($db); $selected=-1; - $searchform.='

'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, 'data-role="none"', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0); + $searchform.='

'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0); } else { diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 9969740ff35..84b2413f396 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -317,7 +317,7 @@ else { product->enabled) || ! empty($conf->service->enabled)) { ?> - + "> diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 2f839e06281..de1649225ee 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -179,7 +179,7 @@ $coldisplay=-1; // We remove first td product->enabled) || ! empty($conf->service->enabled)) { ?> - + @@ -266,21 +266,21 @@ jQuery(document).ready(function() if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { jQuery("#price_ttc").val(''); jQuery("#multicurrency_subprice").val(''); - } + } }); jQuery("#price_ttc").keyup(function(event) { // console.log(event.which); // discard event tag and arrows if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { jQuery("#price_ht").val(''); jQuery("#multicurrency_subprice").val(''); - } + } }); jQuery("#multicurrency_subprice").keyup(function(event) { // console.log(event.which); // discard event tag and arrows if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { jQuery("#price_ht").val(''); jQuery("#price_ttc").val(''); - } + } }); '; - print '    0 ? 'checked':'').' /> "; - print '
    0 ? 'checked':'').' /> "; + print '    0 ? 'checked':'').' /> "; + print '
    0 ? 'checked':'').' /> "; print '
'; print '
'; diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 891faa8e134..e5e662a7852 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -3,7 +3,8 @@ ModuleBuilderDesc=This tools must be used by experienced users or developers. It EnterNameOfModuleDesc=Enter name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) EnterNameOfObjectDesc=Enter name of the object to create with no spaces. Use uppercase to separate words (For example: MyObject, Student, Teacher...). The CRUD class file, but also API file, pages to list/add/edit/delete object and SQL files will be generated. ModuleBuilderDesc2=Path where modules are generated/edited (first alternative directory defined into %s): %s -ModuleBuilderDesc3=Generated/editable modules found: %s (they are detected as editable when the file %s exists in root of module directory). +ModuleBuilderDesc3=Generated/editable modules found: %s +ModuleBuilderDesc4=A module is detected as 'editable' when the file %s exists in root of module directory NewModule=New module NewObject=New object ModuleKey=Module key diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 02150274fda..da5bbfaf1cd 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -851,7 +851,8 @@ if ($message) print $message; } -print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'
'; +//print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'
'; +$infomodulesfound = '
'.$form->textwithpicto($langs->trans("ModuleBuilderDesc3", count($listofmodules)), $langs->trans("ModuleBuilderDesc4", $FILEFLAG)).'
'; // Load module descriptor @@ -911,7 +912,7 @@ $head[$h][2] = 'deletemodule'; $h++; -dol_fiche_head($head, $module, $langs->trans("Modules"), -1, 'generic'); // Modules +dol_fiche_head($head, $module, $langs->trans("Modules"), -1, 'generic', 0, $infomodulesfound); // Modules if ($module == 'initmodule') { @@ -1427,6 +1428,15 @@ elseif (! empty($module)) print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; + print '
'; + + print ' '.$langs->trans("PageForLib").' : '.($realpathtolib?'':'').$pathtolib.($realpathtodocument?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("PageForPicto").' : '.($realpathtopicto?'':'').$pathtopicto.($realpathtopicto?'':'').''; + //print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print '
'; print ' '.$langs->trans("SqlFile").' : '.($realpathtosql?'':'').$pathtosql.($realpathtosql?'':'').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; @@ -1467,12 +1477,6 @@ elseif (! empty($module)) print '
'; - print ' '.$langs->trans("PageForLib").' : '.($realpathtolib?'':'').$pathtolib.($realpathtodocument?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - print ' '.$langs->trans("PageForPicto").' : '.($realpathtopicto?'':'').$pathtopicto.($realpathtopicto?'':'').''; - //print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print ''; print '


'; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 1c4c3249791..8d4ddc4705d 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -219,10 +219,9 @@ class FormProduct include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox($htmlname, $events); $out.= $comboenhancement; - $nodatarole=($comboenhancement?' data-role="none"':''); } - $out.=''; if ($empty) $out.=''; foreach($this->cache_warehouses as $id => $arraytypes) { diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index f76b6f9f0cc..8dd7f6bbed5 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -1133,13 +1133,11 @@ foreach ($listofreferent as $key => $value) } // Enhance with select2 -$nodatarole=''; if ($conf->use_javascript_ajax) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox('.elementselect'); $out.=$comboenhancement; - $nodatarole=($comboenhancement?' data-role="none"':''); print $comboenhancement; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 1fbd4e44037..fa85d0825e7 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2039,7 +2039,9 @@ div.tabs { div.tabsElem { margin-top: 1px; } /* To avoid overlap of tabs when not browser */ - +div.tabsElem a { + font-weight: normal !important; +} div.tabBar { color: #; padding-top: 16px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 4d46f2e781e..1273d819f3c 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2064,8 +2064,12 @@ div.tabs { clear:both; height:100%; } -div.tabsElem { margin-top: 6px; } /* To avoid overlap of tabs when not browser */ - +div.tabsElem { + margin-top: 6px; +} /* To avoid overlap of tabs when not browser */ +div.tabsElem a { + font-weight: normal !important; +} div.tabBar { color: #; padding-top: 16px; From 87a75a0ad73b4c5436eccda96a0ff32dd187c62c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 01:46:00 +0200 Subject: [PATCH 101/114] CSS not bold on jnotify messages --- htdocs/theme/eldy/style.css.php | 6 ++++++ htdocs/theme/md/style.css.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index fa85d0825e7..505038023ca 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3991,6 +3991,12 @@ div#ecm-layout-center { padding-left: 10px !important; padding-right: 10px !important; } +.jnotify-container .jnotify-notification .jnotify-message { + font-weight: normal; +} +.jnotify-container .jnotify-notification-warning .jnotify-close, .jnotify-container .jnotify-notification-warning .jnotify-message { + color: #a28918 !important; +} /* use or not ? */ div.jnotify-background { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 1273d819f3c..64d852b0395 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4043,6 +4043,12 @@ div#ecm-layout-center { padding-left: 10px !important; padding-right: 10px !important; } +.jnotify-container .jnotify-notification .jnotify-message { + font-weight: normal; +} +.jnotify-container .jnotify-notification-warning .jnotify-close, .jnotify-container .jnotify-notification-warning .jnotify-message { + color: #a28918 !important; +} /* use or not ? */ div.jnotify-background { From 97ece5fda949292c37f438e3df9ea82895fd7a15 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 01:49:59 +0200 Subject: [PATCH 102/114] CSS --- htdocs/theme/eldy/style.css.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 505038023ca..c1841f6cb9a 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3138,12 +3138,11 @@ td.legendLabel { padding: 2px 2px 2px 0 !important; } div.titre { font-family: ; font-size: 14px; - font-weight: bold; + /* font-weight: bold; */ color: rgb(); text-decoration: none; padding-top: 5px; padding-bottom: 5px; - /* text-shadow: 1px 1px 2px #FFFFFF; */ } #dolpaymenttable { min-width: 310px; font-size: 16px; } /* Width must have min to make stripe input area visible */ From f4b35a304b4d552be8607e7425e3650dea83507c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 02:32:21 +0200 Subject: [PATCH 103/114] Update doc --- .../template/doc/Specifications.asciidoc | 128 +++++++++++++++++- 1 file changed, 126 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/doc/Specifications.asciidoc b/htdocs/modulebuilder/template/doc/Specifications.asciidoc index d2150c0865d..adfaeb4e9b5 100644 --- a/htdocs/modulebuilder/template/doc/Specifications.asciidoc +++ b/htdocs/modulebuilder/template/doc/Specifications.asciidoc @@ -1,3 +1,127 @@ -# SPECIFICATIONS OF MODULE MYMODULE FOR DOLIBARR ERP CRM += MYMODULE = +Copyright (C) ---Put here your own copyright and developer email--- +:subtitle: MYMODULE SPECIFICATIONS + + + +== Topic of document + +This document was build from following input: + +* Date 1 +... + +* Date 2 +... + + +The document includes an introductory chapter of functional specifications, presenting the different actors involved in the rebuild of the definitions +of business terms that will be used (some of which may be new or different). +The main following chapter will present the entire process, also known as *uses cases*, according to a principle of a description, in chronological sequence if possible, +to present the actor and the action performed, as in the following example: + +* *X* Actor realizes Action A. +* *Y* Actor communicates Info B to Actor *Z* +* *Automaton* performs update of data for... +* Etc ... + +Functional requirements are complemented by a chapter of technical requirements. +The chapter on data lists key information specific to Presto that were identified at the time of writing specification. It will be enriched as +iterations occurs. + +Finally, in the Appendix, the documents known when writing this document are centralized to illustrate the existing document or inspire the new expected one. +These documents have their content directly integrated in this specification or have a reference to +external documents stored in the *Appendices* directory accompanying this document. + + + +*Log of versions* + +[options="header",format="csv"] +|=== +Author, Date, Version +John Doe, Date YYY-MM-DD, Version 1.0 +|=== + + + +<<< + + +== BUSINESS SPECIFICATIONS - INTRODUCTION + +=== List of actors [[actors]] + +Actors are physical people or moral entities working on at least one process. +The following chart prensts list of actors or partners identified by the project for the defined scope of project. We will use then the name defined into first column to speak about roles in the rest of documents. + +[options="header",format="csv"] +|=== +Actor/profil/role, Description of role, Access to system or not, Example of actor +Customer Service, Receive and create Sales orders (SO), Yes, Mr Smith +Purchase, Make puchase order (PO), Yes, 5 people +Administrator - IT, Administration of users/groups and IT services, Yes, John Doe +Automaton, Execute automatic data processing, Yes, NA +|=== + + +=== Definitions [[definitions]] + +To understand the descriptions of the target process, it was necessary to define or redefine some vocabulary concepts. We must see these definitions as defined in the +new system. Indeed, some terms are already being used but have either not a definition in line with standards, or even differs between services. To bring everyone, +and to consolidate the process, these terms are redefined here, and with their definition in the target objective. + +*Definition ABC* + +... + +*Definition DEF* + +... + + +[NOTE] +============== +Important information will be noticed with a notice like this one. + +* Main information 1 +* Main information 2 +============== + + + +== BUSINESS SPECIFICATION - PROCESS + +Specifications were cut into different business process. We call a business process a workflow with a starting situation and ending situation. Between start and end, we will find actions +done by actors to bring the value of the company. This actions are described using the syntax rule: +*Actor X* do action Y, *Actor Z* do action W. + +_Each process/use case is described into a separate chapter._ + + +=== Use case / Process 1 [[process_1]] + +==== Title and goals + +... + +==== Actors or roles + +* Members of group *...* + +==== Standard flow + +* Members of Groupe *...*: Do ... +* Members of Groupe *...*: Do ... +* Members of Groupe *...*: Do ... + +==== Alternative flow + +* A user without role *...*: Can't do ... + +==== Business rules + +* Business rule 1 +* Business rule 2 + -There is no detailed specification available yet. From fac4ebec22bad9b7f550e72f5bb6ff7f4e404008 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 10:26:43 +0200 Subject: [PATCH 104/114] Code comment --- htdocs/modulebuilder/template/myobject_card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index c4826cf2792..515768b8011 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -27,8 +27,8 @@ //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu From c65f794f87b8804d57a7eafdc4a20b391aef59d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 10:29:48 +0200 Subject: [PATCH 105/114] Code comment --- htdocs/modulebuilder/index.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index da5bbfaf1cd..dade8847aa6 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -23,7 +23,7 @@ * \brief Home page for module builder module */ -if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test +if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti SQL+XSS injection attack test require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index ad8c8b317eb..475716114fa 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -27,8 +27,8 @@ //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu From 0cdca6f3ebae336a29398e463856529ba9c6d910 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 24 Sep 2017 11:10:33 +0200 Subject: [PATCH 106/114] Fix: phpcs error --- htdocs/core/class/html.form.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f2427056fb5..dd9e643e74c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2987,12 +2987,12 @@ class Form * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want. * See instead to force the default value by the caller. * - * @param int $selected Id of payment term to preselect by default - * @param string $htmlname Nom de la zone select - * @param int $filtertype Not used + * @param int $selected Id of payment term to preselect by default + * @param string $htmlname Nom de la zone select + * @param int $filtertype Not used * @param int $addempty Add an empty entry - * @param int $noadmininfo 0=Add admin info, 1=Disable admin info - * @param string $morecss Add more CSS on select tag + * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info + * @param string $morecss Add more CSS on select tag * @return void */ function select_conditions_paiements($selected=0, $htmlname='condid', $filtertype=-1, $addempty=0, $noinfoadmin=0, $morecss='') From 49e9326a6d4b81e446b40b2143b47af145b23145 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 19:50:32 +0200 Subject: [PATCH 107/114] Code comment --- htdocs/core/lib/security2.lib.php | 2 +- htdocs/main.inc.php | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 3876dc0e2cd..4d79b87122e 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -184,7 +184,7 @@ function dol_loginfunction($langs,$conf,$mysoc) // Set cookie for timeout management $prefix=dol_getprefix(); $sessiontimeout='DOLSESSTIMEOUT_'.$prefix; - if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0); + if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, false, true); if (GETPOST('urlfrom','alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom','alpha'); else unset($_SESSION["urlfrom"]); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 675c82aa499..27168349f22 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -179,7 +179,9 @@ if (! empty($_SERVER['DOCUMENT_ROOT']) && substr($_SERVER['DOCUMENT_ROOT'], -6) // Include the conf.php and functions.lib.php require_once 'filefunc.inc.php'; -// If there is a POST parameter to tell to save automatically some POST parameters into cookies, we do it +// If there is a POST parameter to tell to save automatically some POST parameters into cookies, we do it. +// This is used for example by form of boxes to save personalization of some options. +// DOL_AUTOSET_COOKIE=cookiename:val1,val2 and cookiename_val1=aaa cookiename_val2=bbb will set cookie_name with value json_encode(array('val1'=> , )) if (! empty($_POST["DOL_AUTOSET_COOKIE"])) { $tmpautoset=explode(':',$_POST["DOL_AUTOSET_COOKIE"],2); @@ -194,7 +196,7 @@ if (! empty($_POST["DOL_AUTOSET_COOKIE"])) $cookiename=$tmpautoset[0]; $cookievalue=json_encode($cookiearrayvalue); //var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue); - setcookie($cookiename, empty($cookievalue)?'':$cookievalue, empty($cookievalue)?0:(time()+(86400*354)), '/'); // keep cookie 1 year + setcookie($cookiename, empty($cookievalue)?'':$cookievalue, empty($cookievalue)?0:(time()+(86400*354)), '/', null, false, true); // keep cookie 1 year and add tag httponly if (empty($cookievalue)) unset($_COOKIE[$cookiename]); } @@ -204,7 +206,7 @@ $sessionname='DOLSESSID_'.$prefix; $sessiontimeout='DOLSESSTIMEOUT_'.$prefix; if (! empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime',$_COOKIE[$sessiontimeout]); session_name($sessionname); -session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie +session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. // This create lock released until session_write_close() or end of page. // We need this lock as long as we read/write $_SESSION ['vars']. We can close released when finished. if (! defined('NOSESSION')) From 4246cf24f3ea4b296647f57267dbd5b417691d57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 20:36:27 +0200 Subject: [PATCH 108/114] Perf enhancement: Remove one include of js. --- htdocs/core/class/html.form.class.php | 11 +++-- htdocs/core/js/lib_head.js.php | 29 ++++++++++++ htdocs/core/js/select2_locale.js.php | 67 --------------------------- htdocs/core/lib/ajax.lib.php | 5 +- htdocs/main.inc.php | 3 +- 5 files changed, 39 insertions(+), 76 deletions(-) delete mode 100644 htdocs/core/js/select2_locale.js.php diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f2427056fb5..d5ada748c1f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5215,15 +5215,16 @@ class Form */ static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0) { - global $langs; + global $conf, $langs; global $delayedhtmlcontent; - $tmpplugin='select2'; + // TODO Use an internal dolibarr component instead of select2 + if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return ''; $out=''; - // TODO Use an internal dolibarr component instead of select2 - $outdelayed=' + $tmpplugin='select2'; + $outdelayed="\n".' '."\n"; - print ''."\n"; } } @@ -1321,7 +1320,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs // Global js function print ''."\n"; - print ''."\n"; + print ''."\n"; // Add datepicker default options /*if (! defined('DISABLE_DATE_PICKER')) From 3482b1293321e134a7b45afdab6ad5a9fae7cf3f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 20:55:48 +0200 Subject: [PATCH 109/114] Comment deprecated js code --- htdocs/core/js/lib_head.js.php | 157 +++++++++++++++++---------------- 1 file changed, 81 insertions(+), 76 deletions(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 46219f1b50e..57a6c4f7005 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -82,6 +82,7 @@ else header('Cache-Control: no-cache'); * SimpleDateFormat a utiliser pour retour * ================================================================== */ + /* function showDP(base,dateFieldID,format,codelang) { // check to see if another box is already showing @@ -165,7 +166,7 @@ function resetDP(base,dateFieldID,format,codelang) function loadMonth(base,month,year,ymd,codelang) { - /* showDP.box.innerHTML="Loading..."; */ + // showDP.box.innerHTML="Loading..."; // alert(codelang); var theURL=base+"datepicker.php?cm=shw&lang="+codelang; theURL+="&m="+encodeURIComponent(month); @@ -192,37 +193,6 @@ function closeDPBox() showDP.datefieldID=null; } -function dpChangeDay(dateFieldID,format) -{ - showDP.datefieldID=dateFieldID; - console.log("Call dpChangeDay, we save date into detailed fields."); - - var thefield=getObjectFromID(showDP.datefieldID); - var thefieldday=getObjectFromID(showDP.datefieldID+"day"); - var thefieldmonth=getObjectFromID(showDP.datefieldID+"month"); - var thefieldyear=getObjectFromID(showDP.datefieldID+"year"); - - var date=getDateFromFormat(thefield.value,format); - if (date) - { - thefieldday.value=date.getDate(); - if(thefieldday.onchange) thefieldday.onchange.call(thefieldday); - thefieldmonth.value=date.getMonth()+1; - if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth); - thefieldyear.value=date.getFullYear(); - if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear); - } - else - { - thefieldday.value=''; - if(thefieldday.onchange) thefieldday.onchange.call(thefieldday); - thefieldmonth.value=''; - if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth); - thefieldyear.value=''; - if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear); - } -} - function dpClickDay(year,month,day,format) { var thefield=getObjectFromID(showDP.datefieldID); @@ -250,16 +220,6 @@ function dpHighlightDay(year,month,day,months){ displayinfo.innerHTML=months[month-1]+" "+day+", "+year; } -// Returns an object given an id -function getObjectFromID(id){ - var theObject; - if(document.getElementById) - theObject=document.getElementById(id); - else - theObject=document.all[id]; - return theObject; -} - // This Function returns the top position of an object function getTop(theitem){ var offsetTrail = theitem; @@ -286,6 +246,85 @@ function getLeft(theitem){ return offsetLeft; } +// To hide/show select Boxes with IE6 (and only IE6 because IE6 has a bug and +// not put popup completely on the front) +// Used only bu popup calendar +function hideSelectBoxes() { + var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10); + if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1) + { + for(var i = 0; i < document.all.length; i++) + { + if(document.all[i].tagName) + if(document.all[i].tagName == "SELECT") + document.all[i].style.visibility="hidden"; + } + } +} +// To hide/show select Boxes with IE6 (and only IE6 because IE6 has a bug and +// not put popup completely on the front) +// Used only bu popup calendar +function displaySelectBoxes() { + var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10); + if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1) + { + for(var i = 0; i < document.all.length; i++) + { + if(document.all[i].tagName) + if(document.all[i].tagName == "SELECT") + document.all[i].style.visibility="visible"; + } + } +} + +*/ + + +// Returns an object given an id +function getObjectFromID(id){ + var theObject; + if(document.getElementById) + theObject=document.getElementById(id); + else + theObject=document.all[id]; + return theObject; +} + +// Called after selection of a date to save details into detailed fields +function dpChangeDay(dateFieldID,format) +{ + //showDP.datefieldID=dateFieldID; + console.log("Call dpChangeDay, we save date into detailed fields."); + + var thefield=getObjectFromID(dateFieldID); + var thefieldday=getObjectFromID(dateFieldID+"day"); + var thefieldmonth=getObjectFromID(dateFieldID+"month"); + var thefieldyear=getObjectFromID(dateFieldID+"year"); + + var date=getDateFromFormat(thefield.value,format); + if (date) + { + thefieldday.value=date.getDate(); + if(thefieldday.onchange) thefieldday.onchange.call(thefieldday); + thefieldmonth.value=date.getMonth()+1; + if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth); + thefieldyear.value=date.getFullYear(); + if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear); + } + else + { + thefieldday.value=''; + if(thefieldday.onchange) thefieldday.onchange.call(thefieldday); + thefieldmonth.value=''; + if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth); + thefieldyear.value=''; + if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear); + } +} + + + + // Create XMLHttpRequest object and load url // Used by calendar or other ajax processes @@ -345,40 +384,6 @@ function loadXMLDoc(url,readyStateFunction,async) return req; } -/* To hide/show select Boxes with IE6 (and only IE6 because IE6 has a bug and - * not put popup completely on the front) - * Used only bu popup calendar - */ -function hideSelectBoxes() { - var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10); - if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1) - { - for(var i = 0; i < document.all.length; i++) - { - if(document.all[i].tagName) - if(document.all[i].tagName == "SELECT") - document.all[i].style.visibility="hidden"; - } - } -} -/* To hide/show select Boxes with IE6 (and only IE6 because IE6 has a bug and - * not put popup completely on the front) - * Used only bu popup calendar - */ -function displaySelectBoxes() { - var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10); - if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1) - { - for(var i = 0; i < document.all.length; i++) - { - if(document.all[i].tagName) - if(document.all[i].tagName == "SELECT") - document.all[i].style.visibility="visible"; - } - } -} - - /* * ================================================================= From 2e511badf99f321ecd1a9c86b0dbb05662cb3fd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 21:02:20 +0200 Subject: [PATCH 110/114] Code comment --- htdocs/core/js/lib_head.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 57a6c4f7005..7ed49d004d2 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -44,7 +44,7 @@ top_httphead('text/javascript; charset=UTF-8'); if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); else header('Cache-Control: no-cache'); ?> - +// Javascript libraries for Dolibarr ERP CRM (https://www.dolibarr.org) /** From 7a6180858e9d37a2d8442a9a72d9428554b95514 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 21:12:50 +0200 Subject: [PATCH 111/114] Fix phpunit --- test/phpunit/AdherentTest.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index 34ec0a80917..b29f8508a8e 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -196,7 +196,6 @@ class AdherentTest extends PHPUnit_Framework_TestCase $result=$localobject->fetch($id); print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0); - return $localobject; } @@ -318,14 +317,13 @@ class AdherentTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $template = '%DOL_MAIN_URL_ROOT%,%ID%,%CIVILITY%,%FIRSTNAME%,%LASTNAME%,%FULLNAME%,%COMPANY%,'. - '%ADDRESS%,%ZIP%,%TOWN%,%COUNTRY%,%EMAIL%,%BIRTH%,%PHOTO%,%LOGIN%,%PASSWORD%,%PRENOM%,'. - '%NOM%,%SOCIETE%,%ADDRESS%,%ZIP%,%TOWN%,%COUNTRY%'; + $template = '__CIVILITY__,__FIRSTNAME__,__LASTNAME__,__FULLNAME__,__COMPANY__,'. + '__ADDRESS__,__ZIP__,__TOWN__,__COUNTRY__,__EMAIL__,__BIRTH__,__PHOTO__,__LOGIN__'; // If option to store clear password has been set, we get 'dolibspec' into PASSWORD field. - $expected = DOL_MAIN_URL_ROOT.','.$localobject->id.',,New firstname,New name,New firstname New name,'. + $expected = ',New firstname,New name,New firstname New name,'. 'New company,New address,New zip,New town,Belgium,newemail@newemail.com,'.dol_print_date($localobject->birth,'day').',,'. - 'newlogin,dolibspec,New firstname,New name,New company,New address,New zip,New town,Belgium'; + 'newlogin'; $result = $localobject->makeSubstitution($template); print __METHOD__." result=".$result."\n"; From 971e59395c78e2527510d35d76627a50e917eebf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 21:46:14 +0200 Subject: [PATCH 112/114] Fix phpcs --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d5ada748c1f..b75cde6d9e3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2991,7 +2991,7 @@ class Form * @param string $htmlname Nom de la zone select * @param int $filtertype Not used * @param int $addempty Add an empty entry - * @param int $noadmininfo 0=Add admin info, 1=Disable admin info + * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info * @param string $morecss Add more CSS on select tag * @return void */ From af384f14ae5833b1cb914d740dd0ce963f009727 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Sep 2017 23:40:42 +0200 Subject: [PATCH 113/114] FIX #7477 --- htdocs/compta/facture/fiche-rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 58fed19d103..66c964212db 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -360,7 +360,7 @@ if (empty($reshook)) // For triggers $line->id = $lineid; - if ($line->delete() > 0) + if ($line->delete($user) > 0) { $result=$object->update_price(1); From e3da4188e2fabb92b8e3302f081aab275aa86ff0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Sep 2017 00:16:52 +0200 Subject: [PATCH 114/114] GETPOST must not clean data for text input. --- htdocs/comm/action/card.php | 2 +- htdocs/comm/propal/card.php | 10 +++++----- htdocs/comm/remx.php | 2 +- htdocs/commande/card.php | 6 +++--- htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/class/facture.class.php | 4 ++-- htdocs/compta/facture/fiche-rec.php | 10 +++++----- htdocs/compta/paiement/card.php | 2 +- htdocs/contrat/card.php | 2 +- htdocs/cron/card.php | 4 ++-- htdocs/expedition/card.php | 4 ++-- htdocs/expensereport/card.php | 8 ++++---- htdocs/fichinter/card.php | 10 +++++----- htdocs/fourn/commande/card.php | 8 ++++---- htdocs/fourn/commande/orderstoinvoice.php | 4 ++-- htdocs/fourn/facture/card.php | 12 ++++++------ htdocs/fourn/paiement/card.php | 2 +- htdocs/loan/card.php | 4 ++-- htdocs/loan/payment/payment.php | 4 ++-- htdocs/product/card.php | 12 ++++++------ htdocs/public/members/new.php | 2 +- htdocs/supplier_proposal/card.php | 8 ++++---- htdocs/user/note.php | 2 +- 23 files changed, 62 insertions(+), 62 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index b491c9007cb..02a16af3c17 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -824,7 +824,7 @@ if ($action == 'create') // Description print ''.$langs->trans("Description").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note',(GETPOST('note')?GETPOST('note'):$object->note),'',180,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,'90%'); + $doleditor=new DolEditor('note',(GETPOST('note','none')?GETPOST('note','none'):$object->note),'',180,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,'90%'); $doleditor->Create(); print ''; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8fb2a102c22..4fc1eebb66d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -358,8 +358,8 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private','none'); + $object->note_public = GETPOST('note_public','none'); $object->statut = Propal::STATUS_DRAFT; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); @@ -386,8 +386,8 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private','none'); + $object->note_public = GETPOST('note_public','none'); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); @@ -979,7 +979,7 @@ if (empty($reshook)) $info_bits |= 0x01; // Clean parameters - $description = dol_htmlcleanlastbr(GETPOST('product_desc')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc','none')); // Define vat_rate $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 332181922d2..7a34d1a3a76 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -292,7 +292,7 @@ if ($socid > 0) print $form->load_tva('tva_tx',GETPOST('tva_tx'),$mysoc,$object); print ''; print ''.$langs->trans("NoteReason").''; - print ''; + print ''; print ""; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index eb510b53333..53082499a9a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -256,8 +256,8 @@ if (empty($reshook)) $db->begin(); $object->date_commande = $datecommande; - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private','none'); + $object->note_public = GETPOST('note_public','none'); $object->source = GETPOST('source_id'); $object->fk_project = GETPOST('projectid'); $object->ref_client = GETPOST('ref_client'); @@ -927,7 +927,7 @@ if (empty($reshook)) $date_end=''; $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $description=dol_htmlcleanlastbr(GETPOST('product_desc')); + $description=dol_htmlcleanlastbr(GETPOST('product_desc','none')); $pu_ht=GETPOST('price_ht'); $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); $pu_ht_devise = GETPOST('multicurrency_subprice'); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 949e36f8ec3..2535d8e7442 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1816,7 +1816,7 @@ if (empty($reshook)) $date_end = ''; $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $description = dol_htmlcleanlastbr(GETPOST('product_desc') ? GETPOST('product_desc') : GETPOST('desc')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc','none') ? GETPOST('product_desc','none') : GETPOST('desc','none')); $pu_ht = GETPOST('price_ht'); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $qty = GETPOST('qty'); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 41cc8042144..b6d294c6e18 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -293,8 +293,8 @@ class Facture extends CommonInvoice // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI $this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project; - $this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public; - $this->note_private = GETPOST('note_private') ? GETPOST('note_private') : $_facrec->note_private; + $this->note_public = GETPOST('note_public','none') ? GETPOST('note_public','none') : $_facrec->note_public; + $this->note_private = GETPOST('note_private','none') ? GETPOST('note_private','none') : $_facrec->note_private; $this->modelpdf = GETPOST('model') ? GETPOST('model') : $_facrec->modelpdf; $this->cond_reglement_id = GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $_facrec->cond_reglement_id; $this->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id; diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 66c964212db..80912bffbad 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -209,8 +209,8 @@ if (empty($reshook)) if (! $error) { $object->titre = GETPOST('titre', 'alpha'); - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private','none'); + $object->note_public = GETPOST('note_public','none'); $object->usenewprice = GETPOST('usenewprice'); $object->frequency = $frequency; @@ -723,7 +723,7 @@ if (empty($reshook)) $date_end = ''; //$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); //$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $description = dol_htmlcleanlastbr(GETPOST('product_desc') ? GETPOST('product_desc') : GETPOST('desc')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc','none') ? GETPOST('product_desc','none') : GETPOST('desc','none')); $pu_ht = GETPOST('price_ht'); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $qty = GETPOST('qty'); @@ -965,8 +965,8 @@ if ($action == 'create') print ''.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1,'customer').''; print ''; - $note_public=GETPOST('note_public')?GETPOST('note_public'):$object->note_public; - $note_private=GETPOST('note_private')?GETPOST('note_private'):$object->note_private; + $note_public=GETPOST('note_public','none')?GETPOST('note_public','none'):$object->note_public; + $note_private=GETPOST('note_private','none')?GETPOST('note_private','none'):$object->note_private; // Help of substitution key $substitutionarray=array( diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 523d5256816..da38e9fb47a 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -60,7 +60,7 @@ if ($action == 'setnote' && $user->rights->facture->paiement) $db->begin(); $object->fetch($id); - $result = $object->update_note(GETPOST('note')); + $result = $object->update_note(GETPOST('note','none')); if ($result > 0) { $db->commit(); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 6d2181886a0..46fa2b3ca87 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -676,7 +676,7 @@ if (empty($reshook)) $fk_unit = GETPOST('unit', 'alpha'); - $objectline->description=GETPOST('product_desc'); + $objectline->description=GETPOST('product_desc','none'); $objectline->price_ht=GETPOST('elprice'); $objectline->subprice=GETPOST('elprice'); $objectline->qty=GETPOST('elqty'); diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index a1255954014..8e540c799fe 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -148,7 +148,7 @@ if ($action=='add') $object->params=GETPOST('params'); $object->md5params=GETPOST('md5params'); $object->module_name=GETPOST('module_name','alpha'); - $object->note=GETPOST('note'); + $object->note=GETPOST('note','none'); $object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int')); $object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int')); $object->datenextrun=dol_mktime(GETPOST('datenextrunhour','int'), GETPOST('datenextrunmin','int'), 0, GETPOST('datenextrunmonth','int'), GETPOST('datenextrunday','int'), GETPOST('datenextrunyear','int')); @@ -184,7 +184,7 @@ if ($action=='update') $object->params=GETPOST('params'); $object->md5params=GETPOST('md5params'); $object->module_name=GETPOST('module_name','alpha'); - $object->note=GETPOST('note'); + $object->note=GETPOST('note','none'); $object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int')); $object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int')); $object->datenextrun=dol_mktime(GETPOST('datenextrunhour','int'), GETPOST('datenextrunmin','int'), 0, GETPOST('datenextrunmonth','int'), GETPOST('datenextrunday','int'), GETPOST('datenextrunyear','int')); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index e8748d3a9af..17777e6e228 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -219,8 +219,8 @@ if (empty($reshook)) $object->shipping_method_id = GETPOST('shipping_method_id','int'); $object->tracking_number = GETPOST('tracking_number','alpha'); $object->ref_int = GETPOST('ref_int','alpha'); - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private','none'); + $object->note_public = GETPOST('note_public','none'); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 561f1ecd082..1460d97323c 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -213,8 +213,8 @@ if (empty($reshook)) $object->fk_statut = 1; $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); $object->fk_user_validator = GETPOST('fk_user_validator','int'); - $object->note_public = GETPOST('note_public'); - $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public','none'); + $object->note_private = GETPOST('note_private','none'); // Fill array 'array_options' with data from add form if (! $error) { @@ -264,8 +264,8 @@ if (empty($reshook)) } $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); - $object->note_public = GETPOST('note_public'); - $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public','none'); + $object->note_private = GETPOST('note_private','none'); $object->fk_user_modif = $user->id; $result = $object->update($user); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 32fcf3c9973..680ab2b6a7e 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -64,7 +64,7 @@ $confirm = GETPOST('confirm','alpha'); $mesg = GETPOST('msg','alpha'); $origin=GETPOST('origin','alpha'); $originid=(GETPOST('originid','int')?GETPOST('originid','int'):GETPOST('origin_id','int')); // For backward compatibility -$note_public = GETPOST('note_public'); +$note_public = GETPOST('note_public','none'); $lineid = GETPOST('line_id','int'); //PDF @@ -208,8 +208,8 @@ if (empty($reshook)) $object->description = GETPOST('description'); $object->ref = $ref; $object->modelpdf = GETPOST('model','alpha'); - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private','none'); + $object->note_public = GETPOST('note_public','none'); if ($object->socid > 0) { @@ -877,8 +877,8 @@ if ($action == 'create') $soc = $objectsrc->client; - $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private'))); - $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public')); + $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private','none'))); + $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public','none')); // Object source contacts list $srccontactslist = $objectsrc->liste_contact(-1,'external',1); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index ffe55f1315e..210e93adf14 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -988,8 +988,8 @@ if (empty($reshook)) $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private','none'); + $object->note_public = GETPOST('note_public','none'); $object->date_livraison = $datelivraison; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); @@ -1534,7 +1534,7 @@ if ($action=='create') print ''.$langs->trans('NotePublic').''; print ''; - $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public','none'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; //print ''; @@ -1542,7 +1542,7 @@ if ($action=='create') print ''.$langs->trans('NotePrivate').''; print ''; - $doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private','none'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; //print ''; diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index b1a8c0c08c1..012574915ab 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -155,8 +155,8 @@ if (($action == 'create' || $action == 'add') && ! $error) { $object->libelle = GETPOST('libelle'); $object->date = $datefacture; $object->date_echeance = $datedue; - $object->note_public = GETPOST('note_public'); - $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public','none'); + $object->note_private = GETPOST('note_private','none'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $projectid = GETPOST('projectid'); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d632081fd9e..9f747b07197 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -443,8 +443,8 @@ if (empty($reshook)) $object->libelle = GETPOST('label'); $object->date = $datefacture; $object->date_echeance = $datedue; - $object->note_public = GETPOST('note_public'); - $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public','none'); + $object->note_private = GETPOST('note_private','none'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); @@ -507,8 +507,8 @@ if (empty($reshook)) $object->libelle = $_POST['label']; $object->date = $datefacture; $object->date_echeance = $datedue; - $object->note_public = GETPOST('note_public'); - $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public','none'); + $object->note_private = GETPOST('note_private','none'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); @@ -616,8 +616,8 @@ if (empty($reshook)) $object->libelle = $_POST['label']; $object->date = $datefacture; $object->date_echeance = $datedue; - $object->note_public = GETPOST('note_public'); - $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public','none'); + $object->note_private = GETPOST('note_private','none'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index f42cc1db110..a1104eeaceb 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -57,7 +57,7 @@ if ($action == 'setnote' && $user->rights->fournisseur->facture->creer) $db->begin(); $object->fetch($id); - $result = $object->update_note(GETPOST('note')); + $result = $object->update_note(GETPOST('note','none')); if ($result > 0) { $db->commit(); diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 4f61aa833bf..1f76d705305 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -133,8 +133,8 @@ if (empty($reshook)) $object->dateend = $dateend; $object->nbterm = GETPOST('nbterm'); $object->rate = $rate; - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private','none'); + $object->note_public = GETPOST('note_public','none'); $object->fk_project = GETPOST('projectid','int'); $accountancy_account_capital = GETPOST('accountancy_account_capital'); diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index dc927035954..bea15f288a0 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -101,8 +101,8 @@ if ($action == 'add_payment') $payment->amount_interest = GETPOST('amount_interest'); $payment->paymenttype = GETPOST('paymenttype'); $payment->num_payment = GETPOST('num_payment'); - $payment->note_private = GETPOST('note_private'); - $payment->note_public = GETPOST('note_public'); + $payment->note_private = GETPOST('note_private','none'); + $payment->note_public = GETPOST('note_public','none'); if (! $error) { diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 143b375f5b3..f5e6c906e7d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -281,9 +281,9 @@ if (empty($reshook)) $object->barcode_type_coder = $stdobject->barcode_type_coder; $object->barcode_type_label = $stdobject->barcode_type_label; - $object->description = dol_htmlcleanlastbr(GETPOST('desc')); + $object->description = dol_htmlcleanlastbr(GETPOST('desc','none')); $object->url = GETPOST('url'); - $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private')); + $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private','none')); $object->note = $object->note_private; // deprecated $object->customcode = GETPOST('customcode'); $object->country_id = GETPOST('country_id'); @@ -370,11 +370,11 @@ if (empty($reshook)) $object->ref = $ref; $object->label = GETPOST('label'); - $object->description = dol_htmlcleanlastbr(GETPOST('desc')); + $object->description = dol_htmlcleanlastbr(GETPOST('desc','none')); $object->url = GETPOST('url'); if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private')); + $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private','none')); $object->note = $object->note_private; } $object->customcode = GETPOST('customcode'); @@ -977,7 +977,7 @@ else // Description (used in invoice, propal...) print ''.$langs->trans("Description").''; - $doleditor = new DolEditor('desc', GETPOST('desc'), '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); + $doleditor = new DolEditor('desc', GETPOST('desc','none'), '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); $doleditor->Create(); print ""; @@ -1092,7 +1092,7 @@ else print ''.$langs->trans("NoteNotVisibleOnBill").''; // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. - $doleditor = new DolEditor('note_private', GETPOST('note_private'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_8, '90%'); + $doleditor = new DolEditor('note_private', GETPOST('note_private','none'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_8, '90%'); $doleditor->Create(); print ""; diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 2869d2254e7..6a5fcbdfc62 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -572,7 +572,7 @@ foreach($extrafields->attribute_label as $key=>$value) // Comments print ''; print ''.$langs->trans("Comments").''; -print ''; +print ''; print ''."\n"; // Add specific fields used by Dolibarr foundation for example diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 1b3857fdbf1..a997b5f4b96 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -268,7 +268,7 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); + $object->note = GETPOST('note','none'); $object->statut = SupplierProposal::STATUS_DRAFT; $id = $object->create_from($user); @@ -286,7 +286,7 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); + $object->note = GETPOST('note','none'); $object->origin = GETPOST('origin'); $object->origin_id = GETPOST('originid'); @@ -465,7 +465,7 @@ if (empty($reshook)) } else { // prevent browser refresh from closing proposal several times if ($object->statut == SupplierProposal::STATUS_VALIDATED) { - $object->cloture($user, GETPOST('statut'), GETPOST('note')); + $object->cloture($user, GETPOST('statut'), GETPOST('note','none')); } } } @@ -774,7 +774,7 @@ if (empty($reshook)) $info_bits |= 0x01; // Clean parameters - $description = dol_htmlcleanlastbr(GETPOST('product_desc')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc','none')); // Define vat_rate $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); diff --git a/htdocs/user/note.php b/htdocs/user/note.php index 1734e7286d4..78fe25adfe9 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -65,7 +65,7 @@ if (empty($reshook)) { if ($action == 'update' && $user->rights->user->user->creer && !$_POST["cancel"]) { $db->begin(); - $res = $object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES)); + $res = $object->update_note(dol_html_entity_decode(GETPOST('note_private','none'), ENT_QUOTES)); if ($res < 0) { $mesg = '
'.$adh->error.'
'; $db->rollback();