Merge pull request #11897 from aspangaro/11.0_colorization

NEW Bank Add an option for colorize background color of debit or credit movement
This commit is contained in:
Laurent Destailleur 2019-09-15 10:40:34 +02:00 committed by GitHub
commit 477c0e2aa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 143 additions and 7 deletions

View File

@ -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');

View File

@ -1,5 +1,4 @@
<?php
/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013-2018 Philippe Grand <philippe.grand@atoo-net.com>
@ -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 = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup');
print '<form name="bankmovementcolorconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="save">';
$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 '</table>';
//}
print '<br><br>';
print load_fiche_titre($langs->trans("BankColorizeMovement"), '', '');
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">\n";
print '<td colspan="4">' . $langs->trans("Name") . '</td>';
print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
print "</tr>\n";
print '<tr class="oddeven"><td colspan="4" width="100">';
print $langs->trans('BankColorizeMovementDesc');
print "</td>";
// Active
if ($conf->global->BANK_COLORIZE_MOVEMENT) {
print '<td align="center">' . "\n";
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=unsetbankcolorizemovement">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
print '</td>';
}
else
{
print '<td align="center">' . "\n";
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setbankcolorizemovement">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';
print "</td>";
}
print "</tr>\n";
if(! empty($conf->global->BANK_COLORIZE_MOVEMENT))
{
$i=1;
while ($i <= 2)
{
$key=$i;
$color='BANK_COLORIZE_MOVEMENT_COLOR'.$key;
print '<tr class="oddeven">';
// Label
print '<td colspan="4" width="180" class="nowrap">'.$langs->trans("BankColorizeMovementName".$key)."</td>";
// Color
print '<td class="nowrap right">';
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 '</td>';
print "</tr>";
$i++;
}
}
print '</table>';
print '<br><br>';
@ -384,7 +491,6 @@ print '<br><br>';
//{
print load_fiche_titre($langs->trans("Other"), '', '');
print "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
print '<td>' . $langs->trans("Name") . '</td>';
@ -416,6 +522,12 @@ print "</tr>\n";
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" id="save" name="save" class="button hideifnotset" value="'.$langs->trans("Save").'">';
print '</div>';
print "</form>\n";
// End of page
llxFooter();
$db->close();

View File

@ -6,7 +6,7 @@
* Copyright (C) 2014 Florian Henry <florian.henry@open-cooncept.pro>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
@ -1110,7 +1110,27 @@ if ($resql)
$bankaccount = $cachebankaccount[$objp->bankid];
}
print '<tr class="oddeven">';
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 '<tr class="oddeven" '.$backgroundcolor.'>';
// Ref
if (! empty($arrayfields['b.rowid']['checked']))

View File

@ -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