From ad46bf9a947ca937eef491d3b7bba7f2f573553c Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 5 Dec 2017 18:30:48 +0100 Subject: [PATCH] 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