From a88bcb52993a97781502fabe5bdcb1e7ed387417 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 3 Oct 2017 13:49:30 +0200 Subject: [PATCH 01/54] Add detailed menus in HRM module --- htdocs/core/menus/standard/eldy.lib.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 013b6ea74ae..3ae967cdc20 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1357,7 +1357,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm'); $newmenu->add("/holiday/card.php?action=request", $langs->trans("New"), 1,$user->rights->holiday->write); $newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("List"), 1,$user->rights->holiday->read); - $newmenu->add("/holiday/list.php?select_statut=2&leftmenu=hrm", $langs->trans("ListToApprove"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=1&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=2&leftmenu=hrm", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=3&leftmenu=hrm", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read); $newmenu->add("/holiday/define_holiday.php?action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read); $newmenu->add("/holiday/view_log.php?action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday); } @@ -1379,7 +1383,12 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/expensereport/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->expensereport->lire, '', $mainmenu, 'expensereport'); $newmenu->add("/expensereport/card.php?action=create&leftmenu=expensereport&mainmenu=hrm", $langs->trans("New"), 1, $user->rights->expensereport->creer); $newmenu->add("/expensereport/list.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("List"), 1, $user->rights->expensereport->lire); - $newmenu->add("/expensereport/list.php?search_status=2&leftmenu=expensereport&mainmenu=hrm", $langs->trans("ListToApprove"), 2, $user->rights->expensereport->approve); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="expensereport") $newmenu->add("/expensereport/list.php?search_status=0&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Draft"), 2, $user->rights->expensereport->lire); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="expensereport") $newmenu->add("/expensereport/list.php?search_status=2&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Validated"), 2, $user->rights->expensereport->lire); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="expensereport") $newmenu->add("/expensereport/list.php?search_status=5&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Approved"), 2, $user->rights->expensereport->lire); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="expensereport") $newmenu->add("/expensereport/list.php?search_status=6&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Paid"), 2, $user->rights->expensereport->lire); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="expensereport") $newmenu->add("/expensereport/list.php?search_status=4&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Canceled"), 2, $user->rights->expensereport->lire); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="expensereport") $newmenu->add("/expensereport/list.php?search_status=99&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Refused"), 2, $user->rights->expensereport->lire); $newmenu->add("/expensereport/stats/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->expensereport->lire); } From a2df87ab15ff9186d3702ce16998bacd22965efe Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Tue, 5 Dec 2017 11:34:07 +0100 Subject: [PATCH 02/54] NEW warning on module blocked log reset if country code is FR fix wrong paste click --- htdocs/admin/modules.php | 38 +++++++++++++-- htdocs/core/modules/modBlockedLog.class.php | 51 ++++++++++++++++++++- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/blockedlog.lang | 3 +- 4 files changed, 86 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 25352372d8d..82f1df1b7d5 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -94,6 +94,8 @@ $hookmanager->initHooks(array('adminmodules','globaladmin')); * Actions */ +$formconfirm = ''; + $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -236,8 +238,7 @@ if ($action == 'set' && $user->admin) header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); exit; } - -if ($action == 'reset' && $user->admin) +else if ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') { $result=unActivateModule($value); if ($result) setEventMessages($result, null, 'errors'); @@ -423,6 +424,22 @@ foreach ($modulesdir as $dir) } } +if ($action == 'reset_confirm' && $user->admin) +{ + if(!empty($modules[$value])) { + $objMod = $modules[$value]; + + if(!empty($objMod->langfiles)) $langs->loadLangs($objMod->langfiles); + + $form = new Form($db); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmUnactivation'), $langs->trans(GETPOST('confirm_message_code')), 'reset', '', 'no', 1); + + } + +} + +print $formconfirm; + asort($orders); //var_dump($orders); //var_dump($categ); @@ -679,9 +696,20 @@ if ($mode == 'common') } else { - print ''; - print img_picto($langs->trans("Activated"),'switch_on'); - print ''; + if(!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { + print 'warnings_unactivation[$mysoc->country_code].'&value=' . $modName . '&mode=' . $mode . $param . '">'; + print img_picto($langs->trans("Activated"),'switch_on'); + print ''; + + } + else { + + print ''; + print img_picto($langs->trans("Activated"),'switch_on'); + print ''; + + } + } print ''."\n"; diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 6928c6f6f1c..493c0ad513a 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -69,8 +69,10 @@ class modBlockedLog extends DolibarrModules $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with - $this->langfiles = array(); + $this->langfiles = array('blockedlog'); + $this->warnings_unactivation = array('FR'=>'BlockedLogAreRequiredByYourCountryLegislation'); + // Constants //----------- @@ -87,4 +89,51 @@ class modBlockedLog extends DolibarrModules //------------------ $this->menu = array(); } + + /** + * Check if module was already used before unactivation linked to warnings_unactivation property + */ + function alreadyUsed() { + + $res = $this->db->query("SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."blockedlog"); + if($res!==false) { + $obj = $this->db->fetch_object($res); + return ($obj->nb > 0); + } + + return false; + } + + /** + * Function called when module is disabled. + * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function remove($options = '') { + + global $user; + + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + + $object=new stdClass; + $object->id = 1; + $object->element = 'module'; + $object->ref = 'module'; + $object->date = time(); + + $b=new BlockedLog($this->db); + $b->setObjectData($object, 'MODULE_RESET', -1); + + $res = $b->create($user); + if($res<=0) { + $this->error = $b->error; + return $res; + } + + return $this->_remove(array(), $options); + + } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b8673911f7f..fc3caa74657 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1765,3 +1765,4 @@ ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). DisabledResourceLinkUser=Disabled resource link to user DisabledResourceLinkContact=Disabled resource link to contact +ConfirmUnactivation=Confirm module reset diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 9c4edd35a52..5c4c84eb2ab 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -26,4 +26,5 @@ DownloadLogCSV=Download archive logs (CSV) logDOC_PREVIEW=Preview of a validated document in order to print or download logDOC_DOWNLOAD=Download of a validated document in order to print or send DataOfArchivedEvent=Full datas of archived event -ImpossibleToReloadObject=Object (type %s, id %s) removed \ No newline at end of file +ImpossibleToReloadObject=Object (type %s, id %s) removed +BlockedLogAreRequiredByYourCountryLegislation=Unalterable logs are required by the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of non-legal software as it can not be validated by a tax audit. \ No newline at end of file From 365639a6c00422d79db569e75e46014a42e0b5f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Dec 2017 11:54:26 +0100 Subject: [PATCH 03/54] Prepare 6.0.5 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 7e7f2de8492..879205cb491 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.5'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 340287f073686ace946816efe8f89e9cf50654fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Dec 2017 11:53:19 +0100 Subject: [PATCH 04/54] FIX #7903 Conflicts: htdocs/holiday/class/holiday.class.php --- htdocs/holiday/class/holiday.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 6572d1836fa..5020684c8e0 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -989,7 +989,7 @@ class Holiday extends CommonObject while ($i < $nbUser) { $now_holiday = $this->getCPforUser($users[$i]['rowid'], $val['rowid']); - $new_solde = $now_holiday + $this->getConfCP('nbHolidayEveryMonth'); + $new_solde = $now_holiday + $nb_holiday; // We add a log for each user $this->addLogCP($user->id, $users[$i]['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $new_solde, $val['rowid']); From ad46bf9a947ca937eef491d3b7bba7f2f573553c Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 5 Dec 2017 18:30:48 +0100 Subject: [PATCH 05/54] NEW option to avoid countries to disable there blockedlog --- htdocs/blockedlog/admin/blockedlog.php | 34 ++++++++++++++++++++- htdocs/core/modules/modBlockedLog.class.php | 5 ++- htdocs/langs/en_US/blockedlog.lang | 3 +- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php index b3822a9acb7..399ace64ad9 100644 --- a/htdocs/blockedlog/admin/blockedlog.php +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -41,7 +41,10 @@ $action = GETPOST('action','alpha'); if (preg_match('/set_(.*)/',$action,$reg)) { $code=$reg[1]; - if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) + $values = GETPOST($code); + if(is_array($values))$values = implode(',', $values); + + if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -115,6 +118,35 @@ if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { print ''; } +$var=!$var; +print ''; +print ''.$langs->trans("BlockedLogDisableNotAllowedForCountry").''; +print ''; +print '
'; +print ''; +print ''; + +$sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite"; +$sql.= " FROM ".MAIN_DB_PREFIX."c_country"; +$sql.= " WHERE active > 0"; + +$countryArray=array(); +$resql=$db->query($sql); +if ($resql) +{ + while ($obj = $db->fetch_object($resql)) + { + $countryArray[$obj->code_iso] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:'')); + } +} + +$seledted = empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) ? array() : explode(',',$conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); + +print $form->multiselectarray('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', $countryArray, $seledted); +print ''; +print '
'; +print ''; + print ''; dol_fiche_end(); diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 493c0ad513a..5056bdd7a36 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -36,7 +36,7 @@ class modBlockedLog extends DolibarrModules */ function __construct($db) { - global $langs,$conf; + global $langs,$conf,$mysoc; $this->db = $db; $this->numero = 3200; @@ -88,6 +88,9 @@ class modBlockedLog extends DolibarrModules // Main menu entries //------------------ $this->menu = array(); + + $this->always_enabled = !empty($conf->blockedlog->enabled) && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)); + } /** diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 5c4c84eb2ab..46e63f3e6c7 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -27,4 +27,5 @@ logDOC_PREVIEW=Preview of a validated document in order to print or download logDOC_DOWNLOAD=Download of a validated document in order to print or send DataOfArchivedEvent=Full datas of archived event ImpossibleToReloadObject=Object (type %s, id %s) removed -BlockedLogAreRequiredByYourCountryLegislation=Unalterable logs are required by the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of non-legal software as it can not be validated by a tax audit. \ No newline at end of file +BlockedLogAreRequiredByYourCountryLegislation=Unalterable logs are required by the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of non-legal software as it can not be validated by a tax audit. +BlockedLogDisableNotAllowedForCountry=Disable not allowed for this countries \ No newline at end of file From c70dff89dde708b64ab4266754d5562454f75ebb Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 6 Dec 2017 12:13:15 +0100 Subject: [PATCH 06/54] Fix $boad instead of $board --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index ae4ec72a901..195d583046f 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -548,7 +548,7 @@ if (! empty($valid_dashboardlines)) $boxwork.=''; foreach($valid_dashboardlines as $board) { - if (empty($boad->nbtodo)) $nbworkboardempty++; + if (empty($board->nbtodo)) $nbworkboardempty++; $textlate = $langs->trans("NActionsLate",$board->nbtodolate); $textlate.= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')'; From 32d911b1df06598a4ee3261256ecafd66e80f893 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 6 Dec 2017 12:31:00 +0100 Subject: [PATCH 07/54] NEW: hook to enrich homepage open elements dashboard --- htdocs/index.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/index.php b/htdocs/index.php index ae4ec72a901..bc326acfdff 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -499,6 +499,14 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_p $dashboardlines[] = $board->load_board($user,'topay'); } +$object=new stdClass(); +$parameters=array(); +$action=''; +$reshook=$hookmanager->executeHooks('addOpenElementsDashboardLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook == 0) { + $dashboardlines = array_merge($dashboardlines, $hookmanager->resArray); +} + // Calculate total nb of late $totallate=0; $var=true; From 669e0806704d2a48f83a6b6090deb15513ad1afc Mon Sep 17 00:00:00 2001 From: Ion Date: Wed, 6 Dec 2017 14:49:04 +0100 Subject: [PATCH 08/54] More informative error message in dynamics price --- htdocs/langs/en_US/errors.lang | 1 + .../product/dynamic_price/class/price_parser.class.php | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 64dcd06cb65..e51bdfc1be0 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -156,6 +156,7 @@ ErrorPriceExpression20=Empty expression ErrorPriceExpression21=Empty result '%s' ErrorPriceExpression22=Negative result '%s' ErrorPriceExpression23=Unknown or non set variable '%s' in %s +ErrorPriceExpression24=Variable '%s' exists but has no value ErrorPriceExpressionInternal=Internal error '%s' ErrorPriceExpressionUnknown=Unknown error '%s' ErrorSrcAndTargetWarehouseMustDiffers=Source and target warehouses must differs diff --git a/htdocs/product/dynamic_price/class/price_parser.class.php b/htdocs/product/dynamic_price/class/price_parser.class.php index 088c15b02aa..c281816e99b 100644 --- a/htdocs/product/dynamic_price/class/price_parser.class.php +++ b/htdocs/product/dynamic_price/class/price_parser.class.php @@ -82,6 +82,7 @@ class PriceParser 17, undefined variable '%s' 21, empty result '%s' 22, negative result '%s' + 24, variable '%s' exists but has no value -2 Args 6, wrong number of arguments (%s given, %s expected) @@ -192,9 +193,12 @@ class PriceParser $expression = str_replace("\n", $this->separator_chr, $expression); foreach ($values as $key => $value) { - if ($value === null) $value = "NULL"; - $expression = str_replace($this->special_chr.$key.$this->special_chr, strval($value), $expression); - } + if ($value === null && strpos($expression, $key) !== false) { + $this->error_parser = array(24, $key); + return -7; + } + $expression = str_replace($this->special_chr.$key.$this->special_chr, strval($value), $expression); + } //Check if there is unfilled variable if (strpos($expression, $this->special_chr) !== false) From 0fa77160d9c5e6c07e148be91d816f05bb906250 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 6 Dec 2017 23:21:58 +0100 Subject: [PATCH 09/54] Fix scrutinizer --- htdocs/comm/propal/class/propal.class.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 15649f7a627..1b6a98dbdb9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -683,6 +683,7 @@ class Propal extends CommonObject // Anciens indicateurs: $price, $remise (a ne plus utiliser) $price = $pu; + $remise = 0; if ($remise_percent > 0) { $remise = round(($pu * $remise_percent / 100), 2); @@ -1983,7 +1984,7 @@ class Propal extends CommonObject $sql.= " SET fk_availability = '".$id."'"; $sql.= " WHERE rowid = ".$this->id; - dol_syslog(__METHOD__.' availability('.$availability_id.')', LOG_DEBUG); + dol_syslog(__METHOD__.' availability('.$id.')', LOG_DEBUG); $resql=$this->db->query($sql); if (!$resql) { @@ -3103,6 +3104,7 @@ class Propal extends CommonObject global $langs; $langs->load("propal"); + $statuttrans=''; if ($statut==self::STATUS_DRAFT) $statuttrans='statut0'; if ($statut==self::STATUS_VALIDATED) $statuttrans='statut1'; if ($statut==self::STATUS_SIGNED) $statuttrans='statut3'; @@ -3151,6 +3153,9 @@ class Propal extends CommonObject $langs->load("propal"); $now=dol_now(); + $delay_warning = 0; + $statut = 0; + $label = ''; if ($mode == 'opened') { $delay_warning=$conf->propal->cloture->warning_delay; $statut = self::STATUS_VALIDATED; @@ -3981,9 +3986,9 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function delete($user=null, $notrigger=0) + function delete(User $user, $notrigger=0) { - global $conf,$user; + global $conf; $error=0; $this->db->begin(); From 50203cdf016f166868ac0cc4af0d220a57575da7 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 6 Dec 2017 23:41:38 +0100 Subject: [PATCH 10/54] Fix : link to create action is not a button but a top list link --- htdocs/societe/agenda.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index efd0132b8d7..c286ec7e6f7 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -159,16 +159,12 @@ if ($socid > 0) //print ''; - $morehtmlcenter=''; + $buttoncreate=''; if (! empty($conf->agenda->enabled)) { if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) { - $morehtmlcenter.=''.$langs->trans("AddAction").''; - } - else - { - $morehtmlcenter.=''.$langs->trans("AddAction").''; + $buttoncreate.=''.$langs->trans("AddAction").''; } } @@ -180,7 +176,8 @@ if ($socid > 0) if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); + print load_fiche_titre($langs->trans("ActionsOnCompany"), $buttoncreate, ''); + //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $buttoncreate, '', 0, 1, 1); // List of all actions $filters=array(); From fd26d9553343ed704f2ccf8b0181661dd0c985e5 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 6 Dec 2017 23:51:57 +0100 Subject: [PATCH 11/54] Ruleset 250 to 300 cyclomatic complexity --- dev/setup/codesniffer/ruleset.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 32a938662e6..b8cb751fe9e 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -126,7 +126,7 @@ - + From 8a39e2a413d1079f022f5d3333b5b98f6e3f8645 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 7 Dec 2017 00:28:43 +0100 Subject: [PATCH 12/54] Fix : no need for action button on cards, link is now available --- htdocs/comm/propal/card.php | 4 ++-- htdocs/commande/card.php | 4 ++-- htdocs/fourn/commande/card.php | 4 ++-- htdocs/fourn/facture/card.php | 4 ++-- htdocs/projet/card.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 85ba6f56981..50a98fc5e09 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2262,10 +2262,10 @@ if ($action == 'create') print ''; } // Create event - if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. { print ''; - } + }*/ // Edit if ($object->statut == Propal::STATUS_VALIDATED && $user->rights->propal->creer) { print ''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index bf0ee8aa993..304bbd04997 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2465,12 +2465,12 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } // Create event - if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a + /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a // "workflow" action so should appears somewhere else on // page. { print '' . $langs->trans("AddAction") . ''; - } + }*/ // Create intervention if ($conf->ficheinter->enabled) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index c96c42e2297..498d29c6fb4 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2186,10 +2186,10 @@ elseif (! empty($object->id)) } } // Create event - if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. { print ''; - } + }*/ // Modify if ($object->statut == 1) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a3c068e34bf..febfc28a88a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2832,10 +2832,10 @@ else } // Create event - if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. { print ''; - } + }*/ // Clone if ($action != 'edit' && $user->rights->fournisseur->facture->creer) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 4b4e6a0ea58..2b8633ca31f 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1034,12 +1034,12 @@ elseif ($object->id > 0) { // Create event - if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a + /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a // "workflow" action so should appears somewhere else on // page. { print ''; - } + }*/ // Modify if ($object->statut != 2 && $user->rights->projet->creer) From 6b278a674050d2a78eb00bfbe9f18ab6e5f2cd1b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 7 Dec 2017 16:01:52 +0100 Subject: [PATCH 13/54] Add icons on home page menu --- htdocs/core/menus/standard/eldy.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 80e91f9b40d..1ecc84f5c2b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -518,10 +518,10 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $langs->load("users"); // Home - dashboard - $newmenu->add("/index.php?mainmenu=home&leftmenu=home", $langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', ''); + $newmenu->add("/index.php?mainmenu=home&leftmenu=home", $langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', ''); // Setup - $newmenu->add("/admin/index.php?mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup'); + $newmenu->add("/admin/index.php?mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup', 0, '', '', '', ''); if ($usemenuhider || empty($leftmenu) || $leftmenu=="setup") { $langs->load("admin"); @@ -558,7 +558,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } // System tools - $newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=admintools", $langs->trans("AdminTools"), 0, $user->admin, '', $mainmenu, 'admintools'); + $newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=admintools", $langs->trans("AdminTools"), 0, $user->admin, '', $mainmenu, 'admintools', 0, '', '', '', ''); if ($usemenuhider || empty($leftmenu) || preg_match('/^admintools/',$leftmenu)) { $langs->load("admin"); @@ -591,7 +591,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } } - $newmenu->add("/user/home.php?leftmenu=users", $langs->trans("MenuUsersAndGroups"), 0, $user->rights->user->user->lire, '', $mainmenu, 'users'); + $newmenu->add("/user/home.php?leftmenu=users", $langs->trans("MenuUsersAndGroups"), 0, $user->rights->user->user->lire, '', $mainmenu, 'users', 0, '', '', '', ''); if ($user->rights->user->user->lire) { if ($usemenuhider || empty($leftmenu) || $leftmenu=="users") From bfc476a118a40f4d05af7e6b5c5c1aa297c664ec Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 7 Dec 2017 18:44:33 +0100 Subject: [PATCH 14/54] FIX #7379: Compatibility with PRODUCT_USE_OLD_PATH_FOR_PHOTO varieable --- htdocs/core/class/html.formfile.class.php | 6 +++--- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/document.php | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 824b13fd62f..a48ae7477fc 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Bahfir Abbes - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * 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 @@ -938,9 +938,9 @@ class FormFile if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.'; } // For backward compatiblity, we detect file is stored into an old path - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $file['level1name'] == 'photos') + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos') { - $relativepath=preg_replace('/^.*\/produit\//','',$file['path']).'/'; + $relativepath=preg_replace('/^.*\/produit\//','',$filearray[0]['path']).'/'; } // Defined relative dir to DOL_DATA_ROOT $relativedir = ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 05adfc1b5c5..2f8570d6883 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3997,8 +3997,8 @@ class Product extends CommonObject if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $dirold .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; - $pdirold .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; + $dir = $sdir . '/'. get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; + $pdir = '/' . get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; } // Defined relative dir to DOL_DATA_ROOT diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 53bbbfeeabb..814f708a99e 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -6,6 +6,7 @@ * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -75,8 +76,8 @@ if ($id > 0 || ! empty($ref)) if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { - if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; - else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; + if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; + else $upload_dir = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; } } $modulepart='produit'; From 95fa183fac33b7ea8432ae213534b70502e50702 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 08:49:03 +0100 Subject: [PATCH 15/54] Fix: Avoid warning "A non-numeric value encountered" --- htdocs/compta/paiement/cheque/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 01787ca3372..a9810396e0c 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -53,7 +53,7 @@ $sortorder=GETPOST('sortorder', 'alpha'); $page=GETPOST('page', 'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="b.dateo,b.rowid"; -if ($page < 0) { $page = 0 ; } +if (empty($page) || $page == -1) { $page = 0; } $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; From 8e1a9064cb053eebf4db0bacbc47d742c986f62f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 09:00:05 +0100 Subject: [PATCH 16/54] Fix: avoid warning again --- htdocs/compta/paiement/cheque/card.php | 87 +++++++++++++------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index a9810396e0c..7029bd6ec72 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -490,53 +490,54 @@ if ($action == 'new') if (count($lines[$bid])) { - foreach ($lines[$bid] as $lid => $value) - { - $account_id = $bid; - if (! isset($accounts[$bid])) - $accounts[$bid]=0; - $accounts[$bid] += 1; + foreach ($lines[$bid] as $lid => $value) + { + $account_id = $bid; + if (! isset($accounts[$bid]) || $accounts[$bid] == '') { + $accounts[$bid]=0; + } + $accounts[$bid] += 1; - print ''; - print ''.dol_print_date($value["date"],'day').''; - print ''.$value["numero"]."\n"; - print ''.$value["emetteur"]."\n"; - print ''.$value["banque"]."\n"; - print ''.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).''; + print ''; + print ''.dol_print_date($value["date"],'day').''; + print ''.$value["numero"]."\n"; + print ''.$value["emetteur"]."\n"; + print ''.$value["banque"]."\n"; + print ''.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).''; - // Link to payment - print ''; - $paymentstatic->id=$value["paymentid"]; - $paymentstatic->ref=$value["paymentid"]; - if ($paymentstatic->id) - { - print $paymentstatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; - // Link to bank transaction - print ''; - $accountlinestatic->rowid=$value["id"]; - if ($accountlinestatic->rowid) - { - print $accountlinestatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; + // Link to payment + print ''; + $paymentstatic->id=$value["paymentid"]; + $paymentstatic->ref=$value["paymentid"]; + if ($paymentstatic->id) + { + print $paymentstatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + // Link to bank transaction + print ''; + $accountlinestatic->rowid=$value["id"]; + if ($accountlinestatic->rowid) + { + print $accountlinestatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; - print ''; - print ''; - print '' ; - print ''; + print ''; + print ''; + print '' ; + print ''; - $i++; - } + $i++; + } } print ""; print ''; From c4b2c3e6976f98f5f3700ebe3b886f26979e8a04 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 09:16:36 +0100 Subject: [PATCH 17/54] FIXME $accounts[$bid] is a label ! --- htdocs/compta/paiement/cheque/card.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 7029bd6ec72..eb69a386719 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -492,11 +492,12 @@ if ($action == 'new') { foreach ($lines[$bid] as $lid => $value) { - $account_id = $bid; - if (! isset($accounts[$bid]) || $accounts[$bid] == '') { + //$account_id = $bid; FIXME not used + + // FIXME $accounts[$bid] is a label ! + /*if (! isset($accounts[$bid])) $accounts[$bid]=0; - } - $accounts[$bid] += 1; + $accounts[$bid] += 1;*/ print ''; print ''.dol_print_date($value["date"],'day').''; @@ -689,10 +690,12 @@ else { while ($objp = $db->fetch_object($resql)) { - $account_id = $objp->bid; - if (! isset($accounts[$objp->bid])) + //$account_id = $objp->bid; FIXME not used + + // FIXME $accounts[$objp->bid] is a label + /*if (! isset($accounts[$objp->bid])) $accounts[$objp->bid]=0; - $accounts[$objp->bid] += 1; + $accounts[$objp->bid] += 1;*/ print ''; print ''.$i.''; From 04327189f756d476157af50e684679c48507c04e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 09:41:33 +0100 Subject: [PATCH 18/54] Fix: access error when user not right to view all customers --- htdocs/compta/paiement/cheque/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index eb69a386719..c684e041660 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -46,7 +46,7 @@ $confirm=GETPOST('confirm', 'alpha'); // Security check $fieldname = (! empty($ref)?'ref':'rowid'); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque','','',$fieldname); +$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque','','fk_user_author',$fieldname); $sortfield=GETPOST('sortfield', 'alpha'); $sortorder=GETPOST('sortorder', 'alpha'); From 62cd77d999594b5716fbe9b0afb11544ebb0488e Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Fri, 8 Dec 2017 10:13:03 +0100 Subject: [PATCH 19/54] NEW automatic activation of external module on country set --- htdocs/admin/company.php | 1 + htdocs/core/lib/admin.lib.php | 76 +++++++++++++++++++++ htdocs/core/modules/modBlockedLog.class.php | 2 + htdocs/langs/en_US/blockedlog.lang | 1 + 4 files changed, 80 insertions(+) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 517c57c7d0b..ce830646826 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -69,6 +69,7 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) $s=$mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label; dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s,'chaine',0,'',$conf->entity); + module_require_by_country($mysoc->country_code); } dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom",'nohtml'),'chaine',0,'',$conf->entity); diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 422e7be984d..47624b2e05d 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1132,6 +1132,82 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql return 1; } +/** + * Activate external modules for country if neccessary + * + * @param string $country_code CountryCode + * @return int 1 + */ +function module_require_by_country($country_code) +{ + global $db, $conf, $langs; + + $modulesdir = dolGetModulesDirs(); + + foreach ($modulesdir as $dir) + { + // Load modules attributes in arrays (name, numero, orders) from dir directory + dol_syslog("Scan directory ".$dir." for modules"); + $handle=@opendir(dol_osencode($dir)); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + { + $modName = substr($file, 0, dol_strlen($file) - 10); + + if ($modName) + { + include_once $dir.$file; + $objMod = new $modName($db); + + if ($objMod->numero > 0) + { + $j = $objMod->numero; + } + else + { + $j = 1000 + $i; + } + + $modulequalified=1; + + // We discard modules according to features level (PS: if module is activated we always show it) + $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod))); + + if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + if(!empty($conf->global->$const_name)) $modulequalified=0; // already activated + + if ($modulequalified) + { + // Load languages files of module + if (isset($objMod->automatic_activation) && is_array($objMod->automatic_activation) && isset($objMod->automatic_activation[$country_code])) + { + + activateModule($modName); + + setEventMessage($objMod->automatic_activation[$country_code],'warnings'); + + } + + } + else dol_syslog("Module ".get_class($objMod)." not qualified"); + } + } + } + closedir($handle); + } + else + { + dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING); + } + } + + return 1; +} + /** * Add external modules to list of contact element * diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 5056bdd7a36..7c1227e14fe 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -73,6 +73,8 @@ class modBlockedLog extends DolibarrModules $this->warnings_unactivation = array('FR'=>'BlockedLogAreRequiredByYourCountryLegislation'); + $this->automatic_activation = array('FR'=>'BlockedLogActivatedBecauseRequiredByYourCountryLegislation'); + // Constants //----------- diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 46e63f3e6c7..8f3ef9ff22e 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -28,4 +28,5 @@ logDOC_DOWNLOAD=Download of a validated document in order to print or send DataOfArchivedEvent=Full datas of archived event ImpossibleToReloadObject=Object (type %s, id %s) removed BlockedLogAreRequiredByYourCountryLegislation=Unalterable logs are required by the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of non-legal software as it can not be validated by a tax audit. +BlockedLogActivatedBecauseRequiredByYourCountryLegislation=Unalterable logs module was activated because of the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of non-legal software as it can not be validated by a tax audit. BlockedLogDisableNotAllowedForCountry=Disable not allowed for this countries \ No newline at end of file From df5768c176042b6eba2338bf258d481dc0615396 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2017 12:38:22 +0100 Subject: [PATCH 20/54] Fix missing translation --- htdocs/langs/en_US/other.lang | 2 ++ htdocs/user/class/user.class.php | 6 ++++-- htdocs/user/class/usergroup.class.php | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 0d9d1cfbd85..ac937a35918 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -225,6 +225,8 @@ IfAmountHigherThan=If amount higher than %s SourcesRepository=Repository for sources Chart=Chart PassEncoding=Password encoding +PermissionsAdd=Permissions added +PermissionsDelete=Permissions revomed ##### Export ##### ExportsArea=Exports area diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 565e1f014b7..1c6e8f98bf5 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -521,7 +521,8 @@ class User extends CommonObject if (! $error && ! $notrigger) { - $this->context = array('audit'=>$langs->trans("PermissionsAdd")); + $langs->load("other"); + $this->context = array('audit'=>$langs->trans("PermissionsAdd").($rid?' (id='.$rid.')':'')); // Call trigger $result=$this->call_trigger('USER_MODIFY',$user); @@ -632,7 +633,8 @@ class User extends CommonObject if (! $error && ! $notrigger) { - $this->context = array('audit'=>$langs->trans("PermissionsDelete")); + $langs->load("other"); + $this->context = array('audit'=>$langs->trans("PermissionsDelete").($rid?' (id='.$rid.')':'')); // Call trigger $result=$this->call_trigger('USER_MODIFY',$user); diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 7c326097669..f16af4a4c48 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -345,7 +345,8 @@ class UserGroup extends CommonObject if (! $error) { - $this->context = array('audit'=>$langs->trans("PermissionsAdd")); + $langs->load("other"); + $this->context = array('audit'=>$langs->trans("PermissionsAdd").($rid?' (id='.$rid.')':'')); // Call trigger $result=$this->call_trigger('GROUP_MODIFY',$user); @@ -458,7 +459,8 @@ class UserGroup extends CommonObject if (! $error) { - $this->context = array('audit'=>$langs->trans("PermissionsDelete")); + $langs->load("other"); + $this->context = array('audit'=>$langs->trans("PermissionsDelete").($rid?' (id='.$rid.')':'')); // Call trigger $result=$this->call_trigger('GROUP_MODIFY',$user); From 08abb1490a3660fabd7dd632808a5ddd91b20359 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2017 12:54:08 +0100 Subject: [PATCH 21/54] Remove code using not defined var --- htdocs/product/class/product.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2f8570d6883..b533fad3ec2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4018,11 +4018,11 @@ class Product extends CommonObject $filearray=dol_dir_list($dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs + /*if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { $filearrayold=dol_dir_list($dirold,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=array_merge($filearray, $filearrayold); - } + }*/ $filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC); From 9b9b5adf660d47a07191d342e6066046acc3bfe9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2017 13:01:45 +0100 Subject: [PATCH 22/54] Fix must be compatible with old and new storage location --- htdocs/product/document.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 814f708a99e..a3ccbead70a 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -76,8 +76,8 @@ if ($id > 0 || ! empty($ref)) if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; - else $upload_dir = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; + if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; + else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; } } $modulepart='produit'; From eb03f8f08e35e7dfcb75be7f29cfe511ba58ed8b Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 8 Dec 2017 15:03:42 +0100 Subject: [PATCH 23/54] fix MAIN_COPY_FILE_IN_EVENT_AUTO --- htdocs/core/actions_sendmails.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index fca8ac511da..a888e4a7656 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -413,6 +413,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $object->trackid = $trackid; $object->fk_element = $object->id; $object->elementtype = $object->element; + $object->attachedfiles = $attachedfiles; // Call of triggers if (! empty($trigger_name)) From 95cb5025a2c3267600877c2c3b32e930da867056 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2017 16:15:41 +0100 Subject: [PATCH 24/54] Fix length of month too large More complete template --- .../adherents/class/adherentstats.class.php | 12 ++--- htdocs/admin/company.php | 3 +- htdocs/blockedlog/README-fr.md | 10 ++--- htdocs/comm/action/list.php | 3 +- .../comm/propal/class/propalestats.class.php | 24 +++++----- htdocs/commande/class/commandestats.class.php | 22 ++++----- .../class/deplacementstats.class.php | 10 +++-- .../facture/class/facturestats.class.php | 14 +++--- .../boxes/box_graph_invoices_permonth.php | 4 +- .../box_graph_invoices_supplier_permonth.php | 4 +- .../core/boxes/box_graph_orders_permonth.php | 4 +- .../box_graph_orders_supplier_permonth.php | 4 +- .../boxes/box_graph_propales_permonth.php | 4 +- htdocs/core/class/stats.class.php | 44 ++++++++++++------ htdocs/core/lib/admin.lib.php | 26 +++++------ htdocs/core/modules/modBlockedLog.class.php | 45 +++++++++++-------- htdocs/core/modules/modUser.class.php | 14 +++--- htdocs/don/class/donstats.class.php | 15 ++++--- .../class/expeditionstats.class.php | 15 ++++--- .../class/expensereportstats.class.php | 18 ++++---- .../fichinter/class/fichinterstats.class.php | 20 +++++---- htdocs/langs/en_US/blockedlog.lang | 8 ++-- htdocs/langs/en_US/main.lang | 12 +++++ .../core/modules/modMyModule.class.php | 4 +- htdocs/projet/class/projectstats.class.php | 29 ++++++------ htdocs/projet/class/taskstats.class.php | 9 ++-- htdocs/theme/eldy/style.css.php | 6 ++- htdocs/theme/md/style.css.php | 2 +- 28 files changed, 223 insertions(+), 162 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 7fabd2c0ddf..59c51cb1d21 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -79,9 +79,10 @@ class AdherentStats extends Stats * Return the number of proposition by month for a given year * * @param int $year Year + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of nb each month */ - function getNbByMonth($year) + function getNbByMonth($year, $format=0) { global $user; @@ -93,7 +94,7 @@ class AdherentStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - return $this->_getNbByMonth($year, $sql); + return $this->_getNbByMonth($year, $sql, $format); } /** @@ -116,12 +117,13 @@ class AdherentStats extends Stats } /** - * Return the number of subscriptions by month for a given year + * Return the number of subscriptions by month for a given year * * @param int $year Year + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of amount each month */ - function getAmountByMonth($year) + function getAmountByMonth($year, $format=0) { global $user; @@ -133,7 +135,7 @@ class AdherentStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - return $this->_getAmountByMonth($year, $sql); + return $this->_getAmountByMonth($year, $sql, $format); } /** diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index ce830646826..c20dbaffca4 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -69,7 +69,8 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) $s=$mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label; dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s,'chaine',0,'',$conf->entity); - module_require_by_country($mysoc->country_code); + + activateModulesRequiredByCountry($mysoc->country_code); } dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom",'nohtml'),'chaine',0,'',$conf->entity); diff --git a/htdocs/blockedlog/README-fr.md b/htdocs/blockedlog/README-fr.md index 14fe8e104c3..e92bd5a09fe 100644 --- a/htdocs/blockedlog/README-fr.md +++ b/htdocs/blockedlog/README-fr.md @@ -3,7 +3,7 @@ LOG INALTERABLE ## Fonctionnalité -Ce module tace, en temps réel, certains évènements métiers dans une log non reversible (que vous ne pouvez pas modifier une fois enregistré) de type blockchain. +Ce module trace, en temps réel, certains évènements métiers dans une log inaltérable (que vous ne pouvez pas modifier une fois enregistrés) de type blockchain. Ce module est requis pour la compatibilité avec les exigences légales de certains pays (comme la France avec la loi Fincance 2016 - Norme NF535). @@ -15,9 +15,9 @@ Ce module est requis pour la compatibilité avec les exigences légales de certa Remarque: Le type des événements tracés est probablement plus large que la plupart des exigences légales mais permet d'être prêt pour d'éventuel élargissement de ces exigences. -Vous pouvez aussi lire et recherche au sein de la log dédiée. +Vous pouvez aussi lire et faire des recherches au sein de la log inaltérable. -Tous les enregistrements de la logs inaltérable sont liés avec le précédent dnas une Blockchain, et leur contenu fait parti de la signature inclue dans le lien, -aussi, une fois le module activé et le premier enregistrement réalisé, il ne sera plus possible d'effacer ni modifié un enregistrement dans la log -inaltérable sans corrompre la chaine. Dès lors qu'un enregistrement est invalide, tous les suivants seront également considérés invalides. +Tous les enregistrements de la logs inaltérable sont liés avec le précédent dans une Blockchain, et leur contenu fait parti de la signature inclue dans ce lien, +aussi, une fois le module activé et le premier enregistrement réalisé, il ne sera plus possible d'effacer ni modifier un enregistrement dans la log +inaltérable sans corrompre toute la chaine. Dès lors qu'un enregistrement est invalide, tous les suivants pourront également être considérés invalides par votre administration. diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 2061d73be00..b34c5d0e0b7 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -168,10 +168,11 @@ 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 tests are required to be compatible with all browsers { - $actioncode=''; + //$actioncode=''; $search_title=''; $datestart=''; $dateend=''; + $status=''; $search_array_options=array(); } diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 39ef49991b6..d6e9ee3b103 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -64,27 +64,27 @@ class PropaleStats extends Stats if ($mode == 'customer') { $object=new Propal($this->db); - + $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; $this->field_date='p.datep'; $this->field='total_ht'; $this->field_line='total_ht'; - + $this->where.= " p.fk_statut > 0"; } if ($mode == 'supplier') { $object=new SupplierProposal($this->db); - + $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; $this->field_date='p.date_valid'; $this->field='total_ht'; $this->field_line='total_ht'; - + $this->where.= " p.fk_statut > 0"; // Validated, accepted, refused and closed - } + } //$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity; $this->where.= " AND p.entity IN (".getEntity('propal').")"; if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -100,9 +100,10 @@ class PropaleStats extends Stats * Return propals number by month for a year * * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with number by month */ - function getNbByMonth($year) + function getNbByMonth($year, $format=0) { global $user; @@ -114,7 +115,7 @@ class PropaleStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getNbByMonth($year, $sql); + $res=$this->_getNbByMonth($year, $sql, $format); return $res; } @@ -141,10 +142,11 @@ class PropaleStats extends Stats /** * Return the propals amount by month for a year * - * @param int $year Year to scan - * @return array Array with amount by month + * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array with amount by month */ - function getAmountByMonth($year) + function getAmountByMonth($year, $format) { global $user; @@ -156,7 +158,7 @@ class PropaleStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getAmountByMonth($year, $sql); + $res=$this->_getAmountByMonth($year, $sql, $format); return $res; } diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index b0c63625bb9..6d9dde94bc4 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -60,8 +60,8 @@ class CommandeStats extends Stats $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; - $this->cachefilesuffix = $mode; - + $this->cachefilesuffix = $mode; + if ($mode == 'customer') { $object=new Commande($this->db); @@ -82,7 +82,7 @@ class CommandeStats extends Stats } //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; $this->where.= ' AND c.entity IN ('.getEntity('commande').')'; - + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($this->socid) { @@ -95,9 +95,10 @@ class CommandeStats extends Stats * Return orders number by month for a year * * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with number by month */ - function getNbByMonth($year) + function getNbByMonth($year, $format=0) { global $user; @@ -109,7 +110,7 @@ class CommandeStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getNbByMonth($year, $sql); + $res=$this->_getNbByMonth($year, $sql, $format); return $res; } @@ -136,10 +137,11 @@ class CommandeStats extends Stats /** * Return the orders amount by month for a year * - * @param int $year Year to scan - * @return array Array with amount by month + * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array with amount by month */ - function getAmountByMonth($year) + function getAmountByMonth($year, $format=0) { global $user; @@ -151,7 +153,7 @@ class CommandeStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getAmountByMonth($year, $sql); + $res=$this->_getAmountByMonth($year, $sql, $format); return $res; } @@ -217,6 +219,6 @@ class CommandeStats extends Stats return $this->_getAllByProduct($sql); } - + } diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index cf5f7fda45a..942c6c4cafa 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -91,9 +91,10 @@ class DeplacementStats extends Stats * Renvoie le nombre de facture par mois pour une annee donnee * * @param string $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getNbByMonth($year) + function getNbByMonth($year, $format=0) { $sql = "SELECT MONTH(dated) as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -102,7 +103,7 @@ class DeplacementStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getNbByMonth($year, $sql); + $res=$this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } @@ -112,9 +113,10 @@ class DeplacementStats extends Stats * Renvoie le montant de facture par mois pour une annee donnee * * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getAmountByMonth($year) + function getAmountByMonth($year, $format=0) { $sql = "SELECT date_format(dated,'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -123,7 +125,7 @@ class DeplacementStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getAmountByMonth($year, $sql); + $res=$this->_getAmountByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index b6874862286..a23d5bdc2c2 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -93,9 +93,10 @@ class FactureStats extends Stats * Return orders number by month for a year * * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getNbByMonth($year) + function getNbByMonth($year, $format=0) { global $user; @@ -107,7 +108,7 @@ class FactureStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getNbByMonth($year, $sql); + $res=$this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } @@ -136,10 +137,11 @@ class FactureStats extends Stats /** * Return the invoices amount by month for a year * - * @param int $year Year to scan - * @return array Array with amount by month + * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array with amount by month */ - function getAmountByMonth($year) + function getAmountByMonth($year, $format=0) { global $user; @@ -151,7 +153,7 @@ class FactureStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getAmountByMonth($year, $sql); + $res=$this->_getAmountByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 677fcc17ad2..8b5bfbc817d 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -124,7 +124,7 @@ class box_graph_invoices_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24))); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$endyear.'.png'; @@ -164,7 +164,7 @@ class box_graph_invoices_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24))); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$endyear.'.png'; diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index d1a6d2d5436..436343a56dc 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -123,7 +123,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24))); + $data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; @@ -163,7 +163,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24))); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png'; diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 179501e9bf0..7e60e00a2fc 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -126,7 +126,7 @@ class box_graph_orders_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24))); + $data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; @@ -164,7 +164,7 @@ class box_graph_orders_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24))); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 4979ea6f993..6f8ebf39001 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -125,7 +125,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24))); + $data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; @@ -163,7 +163,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24))); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 868ddf60268..690df3d41fa 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -123,7 +123,7 @@ class box_graph_propales_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24))); + $data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $datatype1 = array_pad(array(), ($endyear-$startyear+1), 'bars'); $filenamenb = $dir."/".$prefix."propalsnbinyear-".$endyear.".png"; @@ -162,7 +162,7 @@ class box_graph_propales_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24))); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $datatype2 = array_pad(array(), ($endyear-$startyear+1), 'bars'); //$datatype2 = array('lines','bars'); diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 8e3c70c0829..c90e63e0606 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -39,9 +39,10 @@ abstract class Stats * @param int $endyear Start year * @param int $startyear End year * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getNbByMonthWithPrevYear($endyear,$startyear,$cachedelay=0) + function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay=0, $format=0) { global $conf,$user,$langs; @@ -76,7 +77,6 @@ abstract class Stats dol_syslog(get_class($this).'::'.__FUNCTION__." cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it."); } } - // Load file into $data if ($foundintocache) // Cache file found and is not too old { @@ -88,7 +88,7 @@ abstract class Stats $year=$startyear; while ($year <= $endyear) { - $datay[$year] = $this->getNbByMonth($year); + $datay[$year] = $this->getNbByMonth($year, $format); $year++; } @@ -133,9 +133,10 @@ abstract class Stats * @param int $endyear Start year * @param int $startyear End year * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getAmountByMonthWithPrevYear($endyear,$startyear,$cachedelay=0) + function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay=0, $format=0) { global $conf,$user,$langs; @@ -182,7 +183,7 @@ abstract class Stats $year=$startyear; while($year <= $endyear) { - $datay[$year] = $this->getAmountByMonth($year); + $datay[$year] = $this->getAmountByMonth($year, $format); $year++; } @@ -409,11 +410,13 @@ abstract class Stats * * @param int $year Year * @param string $sql SQL - * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is a number + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of nb each month */ function _getNbByMonth($year, $sql, $format=0) { + global $langs; + $result=array(); $res=array(); @@ -446,8 +449,11 @@ abstract class Stats for ($i = 1 ; $i < 13 ; $i++) { - $month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b")); - $month=dol_substr($month,0,3); + if ($format == 0) $month=$langs->transnoentitiesnoconv('MonthShort'.sprintf("%02d", $i)); + elseif ($format == 1) $month=$i; + elseif ($format == 2) $month=$langs->transnoentitiesnoconv('MonthVeryShort'.sprintf("%02d", $i)); + //$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b")); + //$month=dol_substr($month,0,3); $data[$i-1] = array($month, $res[$i]); } @@ -460,11 +466,13 @@ abstract class Stats * * @param int $year Year * @param string $sql SQL - * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is a number + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array */ function _getAmountByMonth($year, $sql, $format=0) { + global $langs; + $result=array(); $res=array(); @@ -495,8 +503,11 @@ abstract class Stats for ($i = 1 ; $i < 13 ; $i++) { - $month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b")); - $month=dol_substr($month,0,3); + if ($format == 0) $month=$langs->transnoentitiesnoconv('MonthShort'.sprintf("%02d", $i)); + elseif ($format == 1) $month=$i; + elseif ($format == 2) $month=$langs->transnoentitiesnoconv('MonthVeryShort'.sprintf("%02d", $i)); + //$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b")); + //$month=dol_substr($month,0,3); $data[$i-1] = array($month, $res[$i]); } @@ -508,11 +519,13 @@ abstract class Stats * * @param int $year Year * @param string $sql SQL - * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is a number + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array */ function _getAverageByMonth($year, $sql, $format=0) { + global $langs; + $result=array(); $res=array(); @@ -542,8 +555,11 @@ abstract class Stats for ($i = 1 ; $i < 13 ; $i++) { - $month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b")); - $month=dol_substr($month,0,3); + if ($format == 0) $month=$langs->transnoentitiesnoconv('MonthShort'.sprintf("%02d", $i)); + elseif ($format == 1) $month=$i; + elseif ($format == 2) $month=$langs->transnoentitiesnoconv('MonthVeryShort'.sprintf("%02d", $i)); + //$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b")); + //$month=dol_substr($month,0,3); $data[$i-1] = array($month, $res[$i]); } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 47624b2e05d..3f8ee99d432 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1133,17 +1133,17 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql } /** - * Activate external modules for country if neccessary + * Activate external modules mandatroy when country is country_code * * @param string $country_code CountryCode * @return int 1 */ -function module_require_by_country($country_code) +function activateModulesRequiredByCountry($country_code) { global $db, $conf, $langs; $modulesdir = dolGetModulesDirs(); - + foreach ($modulesdir as $dir) { // Load modules attributes in arrays (name, numero, orders) from dir directory @@ -1156,12 +1156,12 @@ function module_require_by_country($country_code) if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { $modName = substr($file, 0, dol_strlen($file) - 10); - + if ($modName) { include_once $dir.$file; $objMod = new $modName($db); - + if ($objMod->numero > 0) { $j = $objMod->numero; @@ -1170,28 +1170,26 @@ function module_require_by_country($country_code) { $j = 1000 + $i; } - + $modulequalified=1; - + // We discard modules according to features level (PS: if module is activated we always show it) $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod))); - + if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; if(!empty($conf->global->$const_name)) $modulequalified=0; // already activated - + if ($modulequalified) { // Load languages files of module if (isset($objMod->automatic_activation) && is_array($objMod->automatic_activation) && isset($objMod->automatic_activation[$country_code])) { - activateModule($modName); - + setEventMessage($objMod->automatic_activation[$country_code],'warnings'); - } - + } else dol_syslog("Module ".get_class($objMod)." not qualified"); } @@ -1204,7 +1202,7 @@ function module_require_by_country($country_code) dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING); } } - + return 1; } diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 7c1227e14fe..a0f53755981 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -71,13 +71,23 @@ class modBlockedLog extends DolibarrModules $this->conflictwith = array(); // List of modules id this module is in conflict with $this->langfiles = array('blockedlog'); + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_unactivation = array('FR'=>'BlockedLogAreRequiredByYourCountryLegislation'); - - $this->automatic_activation = array('FR'=>'BlockedLogActivatedBecauseRequiredByYourCountryLegislation'); - + + // Currently, activation is not automatic because only companies (in France) making invoices to non business customers must + // enable this module. + // It is automatic only if $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY is on. + if (! empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) + { + $this->automatic_activation = array('FR'=>'BlockedLogActivatedBecauseRequiredByYourCountryLegislation'); + } + + $this->always_enabled = !empty($conf->blockedlog->enabled) && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)); + // Constants //----------- - + $this->const = array(); // New pages on tabs // ----------------- @@ -90,25 +100,22 @@ class modBlockedLog extends DolibarrModules // Main menu entries //------------------ $this->menu = array(); - - $this->always_enabled = !empty($conf->blockedlog->enabled) && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)); - } - + /** - * Check if module was already used before unactivation linked to warnings_unactivation property + * Check if module was already used before unactivation linked to warnings_unactivation property */ function alreadyUsed() { - + $res = $this->db->query("SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."blockedlog"); if($res!==false) { $obj = $this->db->fetch_object($res); return ($obj->nb > 0); } - + return false; } - + /** * Function called when module is disabled. * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. @@ -118,27 +125,27 @@ class modBlockedLog extends DolibarrModules * @return int 1 if OK, 0 if KO */ function remove($options = '') { - + global $user; - + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - + $object=new stdClass; $object->id = 1; $object->element = 'module'; $object->ref = 'module'; $object->date = time(); - + $b=new BlockedLog($this->db); $b->setObjectData($object, 'MODULE_RESET', -1); - + $res = $b->create($user); if($res<=0) { $this->error = $b->error; return $res; } - + return $this->_remove(array(), $options); - + } } diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 1bd4281b507..95474ac8921 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -50,7 +50,6 @@ class modUser extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Gestion des utilisateurs (requis)"; - $this->always_enabled = true; // Can't be disabled // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; @@ -69,6 +68,7 @@ class modUser extends DolibarrModules $this->depends = array(); $this->requiredby = array(); $this->langfiles = array("main","users","companies","members",'salaries'); + $this->always_enabled = true; // Can't be disabled // Constants $this->const = array(); @@ -204,13 +204,13 @@ class modUser extends DolibarrModules $this->rights[$r][4] = 'user'; $this->rights[$r][5] = 'export'; - + // Menus //------- - + $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; @@ -230,7 +230,7 @@ class modUser extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; $this->export_sql_end[$r] .=' WHERE u.entity IN ('.getEntity('user').')'; - + // Imports //-------- $r=0; @@ -266,7 +266,7 @@ class modUser extends DolibarrModules $this->import_regex_array[$r]=array('u.employee'=>'^[0|1]','u.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); $this->import_examplevalues_array[$r]=array('u.lastname'=>"Doe",'u.firstname'=>'John','u.login'=>'jdoe','u.employee'=>'0 or 1','u.status'=>"0 (closed) or 1 (active)",'u.fk_soc'=>'0 (internal user) or company name (external user)','u.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'u.address'=>"61 jump street",'u.zip'=>"123456",'u.town'=>"Big town",'u.fk_country'=>'US, FR, DE...','u.office_phone'=>"0101010101",'u.office_fax'=>"0101010102",'u.email'=>"test@mycompany.com",'u.salary'=>"10000",'u.note'=>"This is an example of note for record",'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00"); $this->import_updatekeys_array[$r]=array('u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>'Login'); - + } diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index 63105da07d2..dfe74b7f691 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -42,7 +42,7 @@ class DonationStats extends Stats var $from; var $field; var $where; - + /** * Constructor @@ -55,13 +55,13 @@ class DonationStats extends Stats function __construct($db, $socid, $mode, $userid=0) { global $user, $conf; - + $this->db = $db; - + $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; - $this->cachefilesuffix = $mode; - + $this->cachefilesuffix = $mode; + $object=new Don($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as d"; //$this->from.= ", ".MAIN_DB_PREFIX."societe as s"; @@ -77,9 +77,10 @@ class DonationStats extends Stats * Return shipment number by month for a year * * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with number by month */ - function getNbByMonth($year) + function getNbByMonth($year, $format=0) { global $user; @@ -90,7 +91,7 @@ class DonationStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getNbByMonth($year, $sql); + $res=$this->_getNbByMonth($year, $sql, $format); return $res; } diff --git a/htdocs/expedition/class/expeditionstats.class.php b/htdocs/expedition/class/expeditionstats.class.php index 7fa16f4210f..5303d6d8b7b 100644 --- a/htdocs/expedition/class/expeditionstats.class.php +++ b/htdocs/expedition/class/expeditionstats.class.php @@ -42,7 +42,7 @@ class ExpeditionStats extends Stats var $from; var $field; var $where; - + /** * Constructor @@ -55,13 +55,13 @@ class ExpeditionStats extends Stats function __construct($db, $socid, $mode, $userid=0) { global $user, $conf; - + $this->db = $db; - + $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; - $this->cachefilesuffix = $mode; - + $this->cachefilesuffix = $mode; + $object=new Expedition($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; //$this->from.= ", ".MAIN_DB_PREFIX."societe as s"; @@ -82,9 +82,10 @@ class ExpeditionStats extends Stats * Return shipment number by month for a year * * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with number by month */ - function getNbByMonth($year) + function getNbByMonth($year, $format=0) { global $user; @@ -96,7 +97,7 @@ class ExpeditionStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getNbByMonth($year, $sql); + $res=$this->_getNbByMonth($year, $sql, $format); return $res; } diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index d29e1202bf4..07396663f42 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -60,9 +60,9 @@ class ExpenseReportStats extends Stats $this->field='total_ht'; //$this->where = " e.fk_statut > 0"; - //$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have. + //$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have. $this->where.= ' e.entity IN ('.getEntity('expensereport').')'; - + //$this->where.= " AND entity = ".$conf->entity; if ($this->socid) { @@ -100,10 +100,11 @@ class ExpenseReportStats extends Stats /** * Renvoie le nombre de facture par mois pour une annee donnee * - * @param string $year Year to scan - * @return array Array of values + * @param string $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array of values */ - function getNbByMonth($year) + function getNbByMonth($year, $format=0) { $sql = "SELECT MONTH(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -112,7 +113,7 @@ class ExpenseReportStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getNbByMonth($year, $sql); + $res=$this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } @@ -122,9 +123,10 @@ class ExpenseReportStats extends Stats * Renvoie le montant de facture par mois pour une annee donnee * * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getAmountByMonth($year) + function getAmountByMonth($year, $format=0) { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').",'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -133,7 +135,7 @@ class ExpenseReportStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getAmountByMonth($year, $sql); + $res=$this->_getAmountByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php index 9fb17eb25f2..b435398fec2 100644 --- a/htdocs/fichinter/class/fichinterstats.class.php +++ b/htdocs/fichinter/class/fichinterstats.class.php @@ -59,8 +59,8 @@ class FichinterStats extends Stats $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; - $this->cachefilesuffix = $mode; - + $this->cachefilesuffix = $mode; + $this->where.= " c.entity = ".$conf->entity; if ($mode == 'customer') { @@ -83,9 +83,10 @@ class FichinterStats extends Stats * Return intervention number by month for a year * * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with number by month */ - function getNbByMonth($year) + function getNbByMonth($year, $format=0) { global $user; @@ -97,7 +98,7 @@ class FichinterStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getNbByMonth($year, $sql); + $res=$this->_getNbByMonth($year, $sql, $format); return $res; } @@ -124,10 +125,11 @@ class FichinterStats extends Stats /** * Return the intervention amount by month for a year * - * @param int $year Year to scan - * @return array Array with amount by month + * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array with amount by month */ - function getAmountByMonth($year) + function getAmountByMonth($year, $format=0) { global $user; @@ -139,7 +141,7 @@ class FichinterStats extends Stats $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); - $res=$this->_getAmountByMonth($year, $sql); + $res=$this->_getAmountByMonth($year, $sql, $format); return $res; } @@ -205,6 +207,6 @@ class FichinterStats extends Stats return $this->_getAllByProduct($sql); } - + } diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 8f3ef9ff22e..3e13c97edb6 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -1,6 +1,6 @@ -BlockedLog=Non Reversible Logs +BlockedLog=Unalterable Logs Field=Field -BlockedLogDesc=This module tracks some events into a non reversible log (that you can't modify once recorded) into a block chain, in real time. This module provides compatibility with requirements of laws of some countries (like France with the law Fincance 2016 - Norme NF535). +BlockedLogDesc=This module tracks some events into an unalterable log (that you can't modify once recorded) into a block chain, in real time. This module provides compatibility with requirements of laws of some countries (like France with the law Fincance 2016 - Norme NF535). Fingerprints=Archived events and fingerprints FingerprintsDesc=Archived business events and fingerprints CompanyInitialKey=Company initial key (hash of genesis block) @@ -27,6 +27,6 @@ logDOC_PREVIEW=Preview of a validated document in order to print or download logDOC_DOWNLOAD=Download of a validated document in order to print or send DataOfArchivedEvent=Full datas of archived event ImpossibleToReloadObject=Object (type %s, id %s) removed -BlockedLogAreRequiredByYourCountryLegislation=Unalterable logs are required by the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of non-legal software as it can not be validated by a tax audit. -BlockedLogActivatedBecauseRequiredByYourCountryLegislation=Unalterable logs module was activated because of the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of non-legal software as it can not be validated by a tax audit. +BlockedLogAreRequiredByYourCountryLegislation=Unalterable Logs module may be required by the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of legal software as they can not be validated by a tax audit. +BlockedLogActivatedBecauseRequiredByYourCountryLegislation=Unalterable Logs module was activated because of the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of legal software as they can not be validated by a tax audit. BlockedLogDisableNotAllowedForCountry=Disable not allowed for this countries \ No newline at end of file diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c04ad735721..a9b135e2e1a 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -548,6 +548,18 @@ MonthShort09=Sep MonthShort10=Oct MonthShort11=Nov MonthShort12=Dec +MonthVeryShort01=J +MonthVeryShort02=F +MonthVeryShort03=M +MonthVeryShort04=A +MonthVeryShort05=M +MonthVeryShort06=J +MonthVeryShort07=J +MonthVeryShort08=A +MonthVeryShort09=S +MonthVeryShort10=O +MonthVeryShort11=N +MonthVeryShort12=D AttachedFiles=Attached files and documents JoinMainDoc=Join main document DateFormatYYYYMM=YYYY-MM diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index a9e29a1a0ab..dd489b5b491 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -110,11 +110,13 @@ class modMyModule extends DolibarrModules $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->langfiles = array("mymodule@mymodule"); $this->phpmin = array(5,3); // Minimum version of PHP required by module $this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module - $this->langfiles = array("mymodule@mymodule"); $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + //$this->automatic_activation = array('FR'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled // Constants // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index a47d28d1b43..5643533239f 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -163,10 +163,11 @@ class ProjectStats extends Stats /** * Return Project number by month for a year * - * @param int $year scan - * @return array of values + * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array of values */ - function getNbByMonth($year) + function getNbByMonth($year, $format=0) { global $user; @@ -182,7 +183,7 @@ class ProjectStats extends Stats $this->yearmonth=0; - $res = $this->_getNbByMonth($year, $sql); + $res = $this->_getNbByMonth($year, $sql, $format); // var_dump($res);print '
'; return $res; } @@ -190,10 +191,11 @@ class ProjectStats extends Stats /** * Return the Project amount by month for a year * - * @param int $year scan - * @return array with amount by month + * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array with amount by month */ - function getAmountByMonth($year) + function getAmountByMonth($year, $format=0) { global $user; @@ -208,7 +210,7 @@ class ProjectStats extends Stats $sql .= $this->db->order('dm', 'DESC'); $this->yearmonth=0; - $res = $this->_getAmountByMonth($year, $sql); + $res = $this->_getAmountByMonth($year, $sql, $format); // var_dump($res);print '
'; return $res; } @@ -421,10 +423,11 @@ class ProjectStats extends Stats /** * Return the Project transformation rate by month for a year * - * @param int $year scan - * @return array with amount by month + * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array with amount by month */ - function getTransformRateByMonth($year) + function getTransformRateByMonth($year, $format=0) { global $user; @@ -438,7 +441,7 @@ class ProjectStats extends Stats $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); - $res_total = $this->_getNbByMonth($year, $sql); + $res_total = $this->_getNbByMonth($year, $sql, $format); $this->status=6; @@ -453,7 +456,7 @@ class ProjectStats extends Stats $this->status=0; $this->yearmonth=0; - $res_only_wined = $this->_getNbByMonth($year, $sql); + $res_only_wined = $this->_getNbByMonth($year, $sql, $format); $res=array(); diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index b71c88f3d6b..c3add03828c 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -158,10 +158,11 @@ class TaskStats extends Stats /** * Return Task number by month for a year * - * @param int $year scan - * @return array of values + * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array of values */ - function getNbByMonth($year) + function getNbByMonth($year, $format=0) { global $user; @@ -177,7 +178,7 @@ class TaskStats extends Stats $this->yearmonth=0; - $res = $this->_getNbByMonth($year, $sql); + $res = $this->_getNbByMonth($year, $sql, $format); // var_dump($res);print '
'; return $res; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b0d4fd7de7c..caa055811dd 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1104,6 +1104,10 @@ div.blockvmenuend, div.blockvmenubookmarks { div.vmenu, td.vmenu { padding-right: 10px !important; } +.blockvmenu .menu_titre { + margin-top: 4px; + margin-bottom: 3px; +} /* Try responsive even not on smartphone #id-container { @@ -1798,7 +1802,7 @@ div.login_block { position: absolute; text-align: ; : 0; - top: 0; + top: ; font-weight: bold; max-width: px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index f8bb78159ce..9b68ceca650 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3093,7 +3093,7 @@ span.dashboardlineko { border-bottom-width: 1px; } .boxtablenobottom { - border-bottom-width: 0 !important; + /* border-bottom-width: 0 !important; */ } .boxtable .fichehalfright, .boxtable .fichehalfleft { min-width: 300px; From 9dfe309ef23b202763f5e432ce845e5ca3f4c8fd Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Fri, 8 Dec 2017 17:15:24 +0100 Subject: [PATCH 25/54] NEW filter date for blockedlog --- htdocs/blockedlog/admin/blockedlog_list.php | 32 +++++++++++++++++++- htdocs/blockedlog/class/blockedlog.class.php | 10 ++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index fd963ec6cd1..b1afdd1279d 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -46,6 +46,13 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +$search_start = -1; +if(GETPOST('search_startyear')!='') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear')); + +$search_end = -1; +if(GETPOST('search_endyear')!='') $search_end= dol_mktime(0, 0, 0, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear')); + + if (empty($sortfield)) $sortfield='rowid'; if (empty($sortorder)) $sortorder='DESC'; @@ -128,7 +135,7 @@ else if($action === 'downloadcsv') { * View */ -$blocks = $block_static->getLog('all', 0, GETPOST('all','alpha') ? 0 : 50, $sortfield, $sortorder); +$blocks = $block_static->getLog('all', 0, GETPOST('all','alpha') ? 0 : 50, $sortfield, $sortorder, $search_start, $search_end); $form=new Form($db); @@ -154,7 +161,27 @@ print ' '; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + +print '
'; + print ''; +print ''; +print ''; + +print ''; + +print ''; + +// Action column +print ''; + +print ''; print ''; print getTitleFieldOfList($langs->trans('#'), 0, $_SERVER["PHP_SELF"],'rowid','','','',$sortfield,$sortorder,'minwidth50 ')."\n"; @@ -226,6 +253,9 @@ foreach($blocks as &$block) { } print '
 '; +print $form->select_date($search_start,'search_start'); +print $form->select_date($search_end,'search_end'); +print ' '; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'; + +print '
'; + print '
'; print ''."\n"; diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 55cf8290a89..2a45a71c4c9 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -124,7 +124,7 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea dol_syslog("getURLContent request=".$request); //dol_syslog("getURLContent response =".response); // This may contains binary data, so we dont output it - dol_syslog("getURLContent response size =".strlen($response)); // This may contains binary data, so we dont output it + dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it $rep=array(); if (curl_errno($ch)) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a9b135e2e1a..fd9f637cd0d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -774,7 +774,7 @@ SetBankAccount=Define Bank Account AccountCurrency=Account currency ViewPrivateNote=View notes XMoreLines=%s line(s) hidden -ShowMoreLines=Show more lines +ShowMoreLines=Show more/less lines PublicUrl=Public URL AddBox=Add box SelectElementAndClick=Select an element and click %s diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 4f8c314b25e..742b308c89f 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1901,7 +1901,7 @@ if ($action == 'editmeta' || $action == 'create') print $formadmin->select_language($pagelang?$pagelang:$langs->defaultlang, 'WEBSITE_LANG', 0, null, '1'); print ''; - print ''; + print ''; print $langs->trans('HtmlHeaderPage'); print ''; $doleditor=new DolEditor('htmlheader', $pagehtmlheader, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); From d701a7617b62a13a9527c66528db1183423bcc6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Dec 2017 19:04:21 +0100 Subject: [PATCH 48/54] Fix province nadorgg into nador --- htdocs/install/mysql/data/llx_20_c_departements.sql | 2 +- htdocs/install/mysql/migration/3.4.0-3.5.0.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index b0f90bd96d5..f82f817f5c5 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -370,7 +370,7 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA32', 1204, '', 0, '', 'Province de Driouch', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA33', 1204, '', 0, '', 'Province de Figuig', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA34', 1204, '', 0, '', 'Province de Jerada', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA35', 1204, '', 0, '', 'Province de Nadorgg', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA35', 1204, '', 0, '', 'Province de Nador', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA36', 1204, '', 0, '', 'Province de Taourirt', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA37', 1216, '', 0, '', 'Province d''Aousserd', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA38', 1216, '', 0, '', 'Province d''Oued Ed-Dahab', 1); diff --git a/htdocs/install/mysql/migration/3.4.0-3.5.0.sql b/htdocs/install/mysql/migration/3.4.0-3.5.0.sql index 87579367a8a..c6dc0ff9bd7 100644 --- a/htdocs/install/mysql/migration/3.4.0-3.5.0.sql +++ b/htdocs/install/mysql/migration/3.4.0-3.5.0.sql @@ -248,7 +248,7 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA32', 1204, '', 0, '', 'Province de Driouch', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA33', 1204, '', 0, '', 'Province de Figuig', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA34', 1204, '', 0, '', 'Province de Jerada', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA35', 1204, '', 0, '', 'Province de Nadorgg', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA35', 1204, '', 0, '', 'Province de Nador', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA36', 1204, '', 0, '', 'Province de Taourirt', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA37', 1216, '', 0, '', 'Province d''Aousserd', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA38', 1216, '', 0, '', 'Province d''Oued Ed-Dahab', 1); From 748aee9a54a1fa804d3620cf77ec5bc6f3cdad51 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Dec 2017 19:54:04 +0100 Subject: [PATCH 49/54] Fix javascript error --- htdocs/core/class/doleditor.class.php | 10 +++++----- htdocs/langs/en_US/website.lang | 2 +- htdocs/website/index.php | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 111f5ff9f57..aa500ab64df 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -273,20 +273,20 @@ class DolEditor var statusBar = new StatusBar(aceEditor, document.getElementById("statusBar'.$this->htmlname.'")); // Init status bar. Need lib ext-statusbar var oldNbOfLines = 0 jQuery(".morelines'.$this->htmlname.'").click(function() { - var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); - currentline = aceEditor.getOption("maxLines"); + var aceEditorClicked = window.ace.edit("'.$this->htmlname.'aceeditorid"); + currentline = aceEditorClicked.getOption("maxLines"); if (oldNbOfLines == 0) { oldNbOfLines = currentline; } - console.log("We click on more lines - we have currently "+oldNbOfLines); + console.log("We click on more lines, oldNbOfLines is "+oldNbOfLines+", we have currently "+currentline); if (currentline < 500) { - aceEditor.setOptions({ maxLines: 500 }); + aceEditorClicked.setOptions({ maxLines: 500 }); } else { - aceEditor.setOptions({ maxLines: oldNbOfLines }); + aceEditorClicked.setOptions({ maxLines: oldNbOfLines }); } }); })'; diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index a978fdc4498..739bfd3cf9b 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -5,11 +5,11 @@ DeleteWebsite=Delete website ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed. WEBSITE_TYPE_CONTAINER=Type of page/container WEBSITE_PAGENAME=Page name/alias -WEBSITE_HTML_HEADER=HTML Header (common to all pages) HtmlHeaderPage=HTML specific header for page WEBSITE_CSS_URL=URL of external CSS file WEBSITE_CSS_INLINE=CSS file content (common to all pages) WEBSITE_JS_INLINE=Javascript file content (common to all pages) +WEBSITE_HTML_HEADER=Addition at bottom of HTML Header (common to all pages) WEBSITE_ROBOT=Robot file (robots.txt) WEBSITE_HTACCESS=Web site .htaccess file PageNameAliasHelp=Name or alias of the page.
This alias is also used to forge a SEO URL when website is ran from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias. diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 742b308c89f..16d19907883 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1695,7 +1695,7 @@ if ($action == 'editcss') print ''; $doleditor=new DolEditor('WEBSITE_ROBOT', $robotcontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); - print $doleditor->Create(1, '', true, 'Robot file', 'txt'); + print $doleditor->Create(1, '', true, 'Robot file', 'text'); print ''; @@ -1705,7 +1705,7 @@ if ($action == 'editcss') print ''; $doleditor=new DolEditor('WEBSITE_HTACCESS', $htaccesscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); - print $doleditor->Create(1, '', true, $langs->trans("File").' .htaccess', 'txt'); + print $doleditor->Create(1, '', true, $langs->trans("File").' .htaccess', 'text'); print ''; From 12d09282448bf0eb4dfaf40540e0db89c78e2859 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 10 Dec 2017 19:59:56 +0100 Subject: [PATCH 50/54] Fix display error message when stock not enough on invoice validation --- htdocs/compta/facture/class/facture.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 840bb93a49f..3c35a03f218 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2197,6 +2197,7 @@ class Facture extends CommonInvoice else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); if ($result < 0) { $error++; + $this->error = $mouvP->error; } } } From 033016da7fd5de610089ec59ae18513c9192c66c Mon Sep 17 00:00:00 2001 From: patrick Delcroix Date: Sun, 10 Dec 2017 20:02:26 +0100 Subject: [PATCH 51/54] fix: unable to remove salaries, plus correct default rights management --- htdocs/core/lib/security.lib.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index e799579b181..c7d72e796ea 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -242,17 +242,17 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu { foreach($feature2 as $subfeature) { - if (empty($user->rights->$feature->$subfeature->creer) - && empty($user->rights->$feature->$subfeature->write) - && empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; } + if (empty($user->rights->{$feature}->{$subfeature}->creer) + && empty($user->rights->{$feature}->{$subfeature}->write) + && empty($user->rights->{$feature}->{$subfeature}->create)) { $createok=0; $nbko++; } else { $createok=1; break; } // Break to bypass second test if the first is ok } } else if (! empty($feature)) // This is for old permissions ('creer' or 'write') { //print '
feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; - if (empty($user->rights->$feature->creer) - && empty($user->rights->$feature->write)) { $createok=0; $nbko++; } + if (empty($user->rights->{$feature}->creer) + && empty($user->rights->{$feature}->write)) { $createok=0; $nbko++; } } } @@ -306,21 +306,24 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu else if ($feature == 'ftp') { if (! $user->rights->ftp->write) $deleteok=0; + }else if ($feature == 'salaries') + { + if (! $user->rights->salaries->delete) $deleteok=0; } else if (! empty($feature2)) // This should be used for future changes { foreach($feature2 as $subfeature) { - if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; + if (empty($user->rights->{$feature}->{$subfeature}->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; else { $deleteok=1; break; } // For bypass the second test if the first is ok } } else if (! empty($feature)) // This is for old permissions { //print '
feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; - if (empty($user->rights->$feature->supprimer) - && empty($user->rights->$feature->delete) - && empty($user->rights->$feature->run)) $deleteok=0; + if (empty($user->rights->{$feature}->supprimer) + && empty($user->rights->{$feature}->delete) + && empty($user->rights->{$feature}->run)) $deleteok=0; } } From 7d553f58f56133d77b00a9bde92c18351b80c73a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Dec 2017 20:34:35 +0100 Subject: [PATCH 52/54] Debug website module --- htdocs/core/lib/website.lib.php | 11 ++++++++--- htdocs/website/index.php | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 57ec80e0b71..dce4b158c54 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -29,14 +29,19 @@ * * @param Website $website Web site object * @param string $content Content to replace + * @param int $removephppart 0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections. * @return boolean True if OK */ -function dolWebsiteReplacementOfLinks($website, $content) +function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) { // Replace php code. Note $content may come from database and does not contains body tags. + $replacewith='...php...'; + if ($removephppart) $replacewith=''; + $content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content); - $content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="...php..."', $content); - $content = preg_replace('/<\?php((?!\?>).)*\?>\n*/ims', '...php...', $content); + $replacewith='...php...'; + if ($removephppart) $replacewith=''; + $content = preg_replace('/<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); // Replace relative link / with dolibarr URL $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 16d19907883..220a1e9663d 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2007,9 +2007,9 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa // REPLACEMENT OF LINKS When page called by website editor $out.=''."\n"; From f7b663379af7693298bdd7bbf9211e0287e67ecf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Dec 2017 21:04:59 +0100 Subject: [PATCH 53/54] Fix PHP 7.2 --- htdocs/compta/bank/releve.php | 4 ++-- .../compta/paiement/class/paiement.class.php | 2 +- scripts/bank/export-bank-receipts.php | 24 ++++++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 1c3b835ad83..a1e69cdc651 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -223,7 +223,7 @@ if ($action=="dl" && $numref > 0) $payment = new Paiement($db); $payment->fetch($val['url_id']); $arraybill = $payment->getBillsArray(); - if (count($arraybill) > 0) + if (is_array($arraybill) && count($arraybill) > 0) { foreach ($arraybill as $billid) { @@ -260,7 +260,7 @@ if ($action=="dl" && $numref > 0) $payment = new PaiementFourn($db); $payment->fetch($val['url_id']); $arraybill = $payment->getBillsArray(); - if (count($arraybill) > 0) + if (is_array($arraybill) && count($arraybill) > 0) { foreach ($arraybill as $billid) { diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 4523326424e..f8dd19ae7e5 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1052,7 +1052,7 @@ class Paiement extends CommonObject if ($mode == 'withlistofinvoices') { $arraybill = $this->getBillsArray(); - if (count($arraybill) > 0) + if (is_array($arraybill) && count($arraybill) > 0) { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $facturestatic=new Facture($this->db); diff --git a/scripts/bank/export-bank-receipts.php b/scripts/bank/export-bank-receipts.php index ad70190b689..398ec1d7a19 100755 --- a/scripts/bank/export-bank-receipts.php +++ b/scripts/bank/export-bank-receipts.php @@ -262,7 +262,7 @@ if ($resql) $totalbefore = $total; $total = $total + $objp->amount; - + // Date operation $dateop=$db->jdate($objp->do); @@ -289,22 +289,28 @@ if ($resql) { $paymentstatic->fetch($links[$key]['url_id']); $tmparray=$paymentstatic->getBillsArray(''); - foreach($tmparray as $key => $val) + if (is_array($tmparray)) { - $invoicestatic->fetch($val); - if ($accountelem) $accountelem.= ', '; - $accountelem.=$invoicestatic->ref; + foreach($tmparray as $key => $val) + { + $invoicestatic->fetch($val); + if ($accountelem) $accountelem.= ', '; + $accountelem.=$invoicestatic->ref; + } } } elseif ($links[$key]['type']=='payment_supplier') { $paymentsupplierstatic->fetch($links[$key]['url_id']); $tmparray=$paymentsupplierstatic->getBillsArray(''); - foreach($tmparray as $key => $val) + if (is_array($tmparray)) { - $invoicesupplierstatic->fetch($val); - if ($accountelem) $accountelem.= ', '; - $accountelem.=$invoicesupplierstatic->ref; + foreach($tmparray as $key => $val) + { + $invoicesupplierstatic->fetch($val); + if ($accountelem) $accountelem.= ', '; + $accountelem.=$invoicesupplierstatic->ref; + } } } elseif ($links[$key]['type']=='payment_sc') From f18edd57879c83efee640a91464fe9d917d22eab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Dec 2017 21:08:13 +0100 Subject: [PATCH 54/54] Update security.lib.php --- htdocs/core/lib/security.lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index c7d72e796ea..0632f4d723f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -242,17 +242,17 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu { foreach($feature2 as $subfeature) { - if (empty($user->rights->{$feature}->{$subfeature}->creer) - && empty($user->rights->{$feature}->{$subfeature}->write) - && empty($user->rights->{$feature}->{$subfeature}->create)) { $createok=0; $nbko++; } + if (empty($user->rights->$feature->$subfeature->creer) + && empty($user->rights->$feature->$subfeature->write) + && empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; } else { $createok=1; break; } // Break to bypass second test if the first is ok } } else if (! empty($feature)) // This is for old permissions ('creer' or 'write') { //print '
feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; - if (empty($user->rights->{$feature}->creer) - && empty($user->rights->{$feature}->write)) { $createok=0; $nbko++; } + if (empty($user->rights->$feature->creer) + && empty($user->rights->$feature->write)) { $createok=0; $nbko++; } } } @@ -314,16 +314,16 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu { foreach($feature2 as $subfeature) { - if (empty($user->rights->{$feature}->{$subfeature}->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; + if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; else { $deleteok=1; break; } // For bypass the second test if the first is ok } } else if (! empty($feature)) // This is for old permissions { //print '
feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; - if (empty($user->rights->{$feature}->supprimer) - && empty($user->rights->{$feature}->delete) - && empty($user->rights->{$feature}->run)) $deleteok=0; + if (empty($user->rights->$feature->supprimer) + && empty($user->rights->$feature->delete) + && empty($user->rights->$feature->run)) $deleteok=0; } }