From 21e27389d411b3fc9ba3556282ca25f095038c9b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 14 Sep 2019 20:58:12 +0200 Subject: [PATCH] NEW Bank Add an option for colorize background color of debit or credit movement --- htdocs/admin/agenda_extsites.php | 2 +- htdocs/admin/bank.php | 120 +++++++++++++++++++++++- htdocs/compta/bank/bankentries_list.php | 24 ++++- htdocs/langs/en_US/banks.lang | 4 + 4 files changed, 143 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 6979c49aabc..b59c311eb2f 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -44,7 +44,7 @@ $actionsave=GETPOST('save', 'alpha'); if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; $MAXAGENDA=$conf->global->AGENDA_EXT_NB; -// List of aviable colors +// List of available colors $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 2a0a66fe269..44cdd5e611b 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -1,5 +1,4 @@ * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2013-2018 Philippe Grand @@ -28,6 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; @@ -38,6 +38,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); +$actionsave=GETPOST('save', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); @@ -60,7 +61,7 @@ if ($action == 'setbankorder') { } } -//Auto report last num releve on conciliate +// Auto report last num releve on conciliate if ($action == 'setreportlastnumreleve') { if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) { @@ -82,6 +83,58 @@ elseif ($action == 'unsetreportlastnumreleve') { } } +// Colorize movements +if ($action == 'setbankcolorizemovement') { + if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} +elseif ($action == 'unsetbankcolorizemovement') { + if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} + +if ($actionsave) +{ + $db->begin(); + + $i=1; $errorsaved=0; + $error=0; + + // Save colors + while ($i <= 2) + { + $color=trim(GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha')); + if ($color=='-1') $color=''; + + $res=dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); + if (! $res > 0) $error++; + $i++; + } + + if (! $error) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + $db->rollback(); + if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + if ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); @@ -157,10 +210,11 @@ elseif ($action == 'setdoc') { /* - * view + * View */ $form = new Form($db); +$formother=new FormOther($db); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -169,6 +223,10 @@ llxHeader("", $langs->trans("BankSetupModule")); $linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup'); +print '
'; +print ''; +print ''; + $head = bank_admin_prepare_head(null); dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account'); @@ -372,7 +430,56 @@ foreach ($dirmodels as $reldir) { print ''; //} +print '

'; +print load_fiche_titre($langs->trans("BankColorizeMovement"), '', ''); +print ''; +print "\n"; +print ''; +print ''."\n"; +print "\n"; + +print '"; +// Active +if ($conf->global->BANK_COLORIZE_MOVEMENT) { + print ''; +} +else +{ + print '"; +} + +print "\n"; + +if(! empty($conf->global->BANK_COLORIZE_MOVEMENT)) +{ + $i=1; + while ($i <= 2) + { + $key=$i; + $color='BANK_COLORIZE_MOVEMENT_COLOR'.$key; + + print ''; + + // Label + print '"; + // Color + print ''; + print ""; + $i++; + } +} +print '
' . $langs->trans("Name") . ''.$langs->trans("Value").'
'; +print $langs->trans('BankColorizeMovementDesc'); +print "' . "\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print '' . "\n"; + print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print "
'.$langs->trans("BankColorizeMovementName".$key)."'; + print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key)?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key):$conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); + print '
'; print '

'; @@ -384,7 +491,6 @@ print '

'; //{ print load_fiche_titre($langs->trans("Other"), '', ''); - print "\n"; print "\n"; print ''; @@ -416,6 +522,12 @@ print "\n"; print '
' . $langs->trans("Name") . '
'; dol_fiche_end(); +print '
'; +print ''; +print '
'; + +print "
\n"; + // End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index a8002c179be..3522d8b6c9d 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -6,7 +6,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Juanjo Menent - * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2017-2019 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018 Frédéric France * @@ -1110,7 +1110,27 @@ if ($resql) $bankaccount = $cachebankaccount[$objp->bankid]; } - print ''; + if (empty($conf->global->BANK_COLORIZE_MOVEMENT)) { + $backgroundcolor = "class='oddeven'"; + } else { + if ($objp->amount < 0) + { + if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR1)) { + $color = '#fca955'; + } else { + $color = '#' . $conf->global->BANK_COLORIZE_MOVEMENT_COLOR1; + } + $backgroundcolor = 'style="background-color: ' . $color . ';"'; + } else { + if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR2)) { + $color = '#7fdb86'; + } else { + $color = '#' . $conf->global->BANK_COLORIZE_MOVEMENT_COLOR2; + } + $backgroundcolor = 'style="background-color: ' . $color . ';"'; + } + } + print ''; // Ref if (! empty($arrayfields['b.rowid']['checked'])) diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 47295ec7e31..44f80c7c3b7 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -169,3 +169,7 @@ FindYourSEPAMandate=This is your SEPA mandate to authorize our company to make d AutoReportLastAccountStatement=Automatically fill the field 'number of bank statement' with last statement number when making reconciliation CashControl=POS cash fence NewCashFence=New cash fence +BankColorizeMovement=Colorize movements +BankColorizeMovementDesc=If this function is enable, you can choose specific background color for debit or credit movements +BankColorizeMovementName1=Background color for debit movement +BankColorizeMovementName2=Background color for credit movement