From ded6b40489e6755c93816a89159c07324280cba3 Mon Sep 17 00:00:00 2001 From: GUERRIER Kevin Date: Sat, 29 Jul 2017 14:21:58 +0200 Subject: [PATCH 1/2] Add possibility to propose last num releve in conciliation --- htdocs/admin/bank.php | 372 +++++++++++++++++------------ htdocs/compta/bank/bankentries.php | 12 +- htdocs/langs/en_GB/banks.lang | 2 + htdocs/langs/fr_FR/banks.lang | 3 + 4 files changed, 234 insertions(+), 155 deletions(-) diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index afe60acff2e3d..c8162c5229f46 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -1,4 +1,5 @@ * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2013-2014 Philippe Grand @@ -21,15 +22,14 @@ /** * \file htdocs/admin/bank.php - * \ingroup bank - * \brief Page to setup the bank module + * \ingroup bank + * \brief Page to setup the bank module */ - 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.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.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 . '/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; $langs->load("admin"); $langs->load("companies"); @@ -38,12 +38,12 @@ $langs->load("banks"); if (!$user->admin) - accessforbidden(); + accessforbidden(); -$action = GETPOST('action','alpha'); -$value = GETPOST('value','alpha'); -$label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$action = GETPOST('action', 'alpha'); +$value = GETPOST('value', 'alpha'); +$label = GETPOST('label', 'alpha'); +$scandir = GETPOST('scandir', 'alpha'); $type = 'bankaccount'; @@ -52,100 +52,109 @@ */ //Order display of bank account -if ($action == 'setbankorder') -{ - if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION",GETPOST('value','alpha'),'chaine',0,'',$conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } - else - { - dol_print_error($db); - } +if ($action == 'setbankorder') { + if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", + GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} + +//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) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } } +elseif ($action == 'unsetreportlastnumreleve') { + if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, + '', $conf->entity) > 0) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} + +if ($action == 'specimen') { + $modele = GETPOST('module', 'alpha'); -if ($action == 'specimen') -{ - $modele=GETPOST('module','alpha'); - - if ($modele == 'sepamandate') - { + if ($modele == 'sepamandate') { $object = new CompanyBankAccount($db); } - else - { + else { $object = new Account($db); } $object->initAsSpecimen(); - + // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) - { - $file=dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php",0); - if (file_exists($file)) - { - $filefound=1; - $classname = "pdf_".$modele; + $file = ''; + $classname = ''; + $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir . "core/modules/bank/doc/pdf_" . $modele . ".modules.php", + 0); + if (file_exists($file)) { + $filefound = 1; + $classname = "pdf_" . $modele; break; } } - - if ($filefound) - { + + if ($filefound) { require_once $file; - + $module = new $classname($db); - - if ($module->write_file($object,$langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf"); + + if ($module->write_file($object, $langs) > 0) { + header("Location: " . DOL_URL_ROOT . "/document.php?modulepart=bank&file=SPECIMEN.pdf"); return; } - else - { + else { setEventMessages($module->error, null, 'errors'); dol_syslog($module->error, LOG_ERR); } } - else - { + else { setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } // Activate a model -if ($action == 'set') -{ - $ret = addDocumentModel($value, $type, $label, $scandir); +if ($action == 'set') { + $ret = addDocumentModel($value, $type, $label, $scandir); } - -else if ($action == 'del') -{ - $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->BANKADDON_PDF == "$value") dolibarr_del_const($db, 'BANKADDON_PDF',$conf->entity); - } +else if ($action == 'del') { + $ret = delDocumentModel($value, $type); + if ($ret > 0) { + if ($conf->global->BANKADDON_PDF == "$value") + dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity); + } } // Set default model -else if ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "BANKADDON_PDF",$value,'chaine',0,'',$conf->entity)) - { +else if ($action == 'setdoc') { + if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', + $conf->entity)) { // The constant that was read before the new set // We therefore requires a variable to have a coherent view $conf->global->BANKADDON_PDF = $value; } - + // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } } @@ -156,80 +165,78 @@ * view */ -$form=new Form($db); +$form = new Form($db); -$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); -llxHeader("",$langs->trans("BankSetupModule")); +llxHeader("", $langs->trans("BankSetupModule")); -$linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("BankSetupModule"),$linkback,'title_setup'); +$linkback = '' . $langs->trans("BackToModuleList") . ''; +print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, + 'title_setup'); $head = bank_admin_prepare_head(null); dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account'); -$var=true; +$var = true; -$var=! $var; +$var = !$var; //Show bank account order print load_fiche_titre($langs->trans("BankOrderShow"), '', ''); print ''; print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; print ''; print "\n"; -$bankorder[0][0]=$langs->trans("BankOrderGlobal"); -$bankorder[0][1]=$langs->trans("BankOrderGlobalDesc"); -$bankorder[0][2]='BankCode DeskCode BankAccountNumber BankAccountNumberKey'; -$bankorder[1][0]=$langs->trans("BankOrderES"); -$bankorder[1][1]=$langs->trans("BankOrderESDesc"); -$bankorder[1][2]='BankCode DeskCode BankAccountNumberKey BankAccountNumber'; +$bankorder[0][0] = $langs->trans("BankOrderGlobal"); +$bankorder[0][1] = $langs->trans("BankOrderGlobalDesc"); +$bankorder[0][2] = 'BankCode DeskCode BankAccountNumber BankAccountNumberKey'; +$bankorder[1][0] = $langs->trans("BankOrderES"); +$bankorder[1][1] = $langs->trans("BankOrderESDesc"); +$bankorder[1][2] = 'BankCode DeskCode BankAccountNumberKey BankAccountNumber'; $var = true; -$i=0; - -$nbofbank=count($bankorder); -while ($i < $nbofbank) -{ - $var = !$var; - - print ''; - print ''; - print '\n"; - - if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) - { - print ''; - } - else - { - print ''; - } - print ''; - print ''."\n"; - $i++; +$i = 0; + +$nbofbank = count($bankorder); +while ($i < $nbofbank) { + $var = !$var; + + print ''; + print ''; + print '\n"; + + if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) { + print ''; + } + else { + print ''; + } + print ''; + print '' . "\n"; + $i++; } -print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").'' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Example") . '' . $langs->trans("Status") . ' 
'.$bankorder[$i][0]."\n"; - print $bankorder[$i][1]; - print ''; - $tmparray=explode(' ',$bankorder[$i][2]); - foreach($tmparray as $key => $val) - { - if ($key > 0) print ', '; - print $langs->trans($val); - } - print "'; - print img_picto($langs->trans("Activated"),'on'); - print ''; - print img_picto($langs->trans("Disabled"),'off'); - print ' 
' . $bankorder[$i][0] . "\n"; + print $bankorder[$i][1]; + print ''; + $tmparray = explode(' ', $bankorder[$i][2]); + foreach ($tmparray as $key => $val) { + if ($key > 0) + print ', '; + print $langs->trans($val); + } + print "'; + print img_picto($langs->trans("Activated"), 'on'); + print ''; + print img_picto($langs->trans("Disabled"), 'off'); + print ' 
'."\n"; +print '' . "\n"; print '

'; @@ -257,7 +264,8 @@ array_push($def, $array[0]); $i ++; } -} else { +} +else { dol_print_error($db); } @@ -273,11 +281,10 @@ clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir . "core/modules/bank" . $valdir); - + if (is_dir($dir)) { $handle = opendir($dir); if (is_resource($handle)) { @@ -286,23 +293,26 @@ } closedir($handle); arsort($filelist); - + foreach ($filelist as $file) { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', + $file)) { + if (file_exists($dir . '/' . $file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); - + require_once $dir . '/' . $file; $module = new $classname($db); - + $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL + < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL + < 1) $modulequalified = 0; - + if ($modulequalified) { print ''; print(empty($module->name) ? $name : $module->name); @@ -312,29 +322,35 @@ else print $module->description; print ''; - + // Active if (in_array($name, $def)) { print '' . "\n"; print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); + print img_picto($langs->trans("Enabled"), + 'switch_on'); print ''; print ''; - } else { + } + else { print '' . "\n"; - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print '' . img_picto($langs->trans("Disabled"), + 'switch_off') . ''; print ""; } - + // Default print ''; if ($conf->global->BANKADDON_PDF == $name) { - print img_picto($langs->trans("Default"), 'on'); - } else { - print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + print img_picto($langs->trans("Default"), + 'on'); + } + else { + print '' . img_picto($langs->trans("Disabled"), + 'off') . ''; } print ''; - + // Info $htmltooltip = '' . $langs->trans("Name") . ': ' . $module->name; $htmltooltip .= '
' . $langs->trans("Type") . ': ' . ($module->type ? $module->type : $langs->trans("Unknown")); @@ -342,27 +358,33 @@ $htmltooltip .= '
' . $langs->trans("Width") . '/' . $langs->trans("Height") . ': ' . $module->page_largeur . '/' . $module->page_hauteur; } $htmltooltip .= '

' . $langs->trans("FeaturesSupported") . ':'; - $htmltooltip .= '
' . $langs->trans("Logo") . ': ' . yn($module->option_logo, 1, 1); + $htmltooltip .= '
' . $langs->trans("Logo") . ': ' . yn($module->option_logo, + 1, 1); //$htmltooltip .= '
' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); //$htmltooltip .= '
' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); - $htmltooltip .= '
' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, 1, 1); + $htmltooltip .= '
' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, + 1, 1); // $htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); // $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); //$htmltooltip .= '
' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); - + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print $form->textwithpicto('', $htmltooltip, 1, + 0); print ''; - + // Preview print ''; if ($module->type == 'pdf') { - print '' . img_object($langs->trans("Preview"), 'bill') . ''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + print '' . img_object($langs->trans("Preview"), + 'bill') . ''; + } + else { + print img_object($langs->trans("PreviewNotAvailable"), + 'generic'); } print ''; - + print "\n"; } } @@ -372,9 +394,51 @@ } } } +print ''; //} + +print '

'; + + +/* + * Document templates generators + */ +//if (! empty($conf->global->MAIN_FEATURES_LEVEL)) +//{ +print load_fiche_titre($langs->trans("BankAccountReleveModule"), '', ''); + + +print "\n"; +print "\n"; +print ''; +print ''; +print '\n"; +print "\n"; + +print ''; +// Active +if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { + print ''; +} +else { + print '"; +} + +print "\n"; +print '
' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Status") . "
'; +print $langs->trans('AccountStatement'); +print "\n"; +print $langs->trans('AutoReportLastAccountStatement'); +print '' . "\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print '' . "\n"; + print '' . img_picto($langs->trans("Disabled"), + 'switch_off') . ''; + print "
'; dol_fiche_end(); llxFooter(); diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index a19ccbb6b7ca5..42c295b360059 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -605,7 +605,7 @@ // print ''; print '
'; print ''.$langs->trans("InputReceiptNumber").': '; - print ''; // The only default value is value we just entered + print ''; // The only default value is value we just entered print '
'; if ($options) { print $langs->trans("EventualyAddCategory").': '; @@ -649,6 +649,16 @@ { dol_print_error($db); } + /** + * Using BANK_REPORT_LAST_NUM_RELEVE to automatically report last num (or not) + */ + if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE == 1) { + print ' + + '; + } print '

'; // print ''; } diff --git a/htdocs/langs/en_GB/banks.lang b/htdocs/langs/en_GB/banks.lang index 6bc449c586427..71e43f01f8e41 100644 --- a/htdocs/langs/en_GB/banks.lang +++ b/htdocs/langs/en_GB/banks.lang @@ -18,3 +18,5 @@ RejectCheck=Cheque returned RejectCheckDate=Date the cheque was returned CheckRejected=Cheque returned CheckRejectedAndInvoicesReopened=Cheque returned and invoices reopened +AutoReportLastAccountStatement=Use automatically last account statement to reconcile +BankAccountReleveModule=Bank Statement \ No newline at end of file diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index c28a15a6e1625..bf481e5c8e4c8 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -38,6 +38,9 @@ AccountStatement=Relevé AccountStatementShort=Relevé AccountStatements=Relevés LastAccountStatements=Derniers relevés bancaires +AutoReportLastAccountStatement=Proposer automatiquement le dernier relevé bancaire rapproché +BankAccountReleveModule=Rapprochement relevés bancaires +Conciliated=Rapproché IOMonthlyReporting=Rapport mensuel E/S BankAccountDomiciliation=Domiciliation du compte BankAccountCountry=Pays du compte From b6b3ab3f1bf062bf957518ff779cec822f29cc14 Mon Sep 17 00:00:00 2001 From: GUERRIER Kevin Date: Sat, 29 Jul 2017 15:07:27 +0200 Subject: [PATCH 2/2] NEW Add Next/Previous button on operation date of bank line Operation date has to be frequently updated because some bank change them in many case. With this feature, this value can be updated simply like the value date. --- htdocs/compta/bank/bankentries.php | 11 +++- htdocs/compta/bank/class/account.class.php | 61 ++++++++++++++++++++++ htdocs/compta/bank/ligne.php | 23 ++++++-- htdocs/core/ajax/bankconciliate.php | 24 +++++++++ 4 files changed, 114 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 42c295b360059..559e16627f892 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -1127,7 +1127,16 @@ // Date ope if (! empty($arrayfields['b.dateo']['checked'])) { - print ''.dol_print_date($db->jdate($objp->do),"day")."\n"; + print ''; + print ''.dol_print_date($db->jdate($objp->do),"day").""; + print ' '; + print ''; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + print ''; + print "\n"; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 08631abec79b7..47c3e5122ff36 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1959,6 +1959,67 @@ function datev_previous($id) } + /** + * Increase/decrease operation date of a rowid + * + * @param int $rowid Id of line + * @param int $sign 1 or -1 + * @return int >0 if OK, 0 if KO + */ + function dateo_change($rowid,$sign=1) + { + $sql = "SELECT dateo FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; + $resql = $this->db->query($sql); + if ($resql) + { + $obj=$this->db->fetch_object($resql); + $newdate=$this->db->jdate($obj->dateo)+(3600*24*$sign); + + $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; + $sql.= " dateo = '".$this->db->idate($newdate)."'"; + $sql.= " WHERE rowid = ".$rowid; + + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->affected_rows($result)) + { + return 1; + } + } + else + { + dol_print_error($this->db); + return 0; + } + } + else dol_print_error($this->db); + return 0; + } + + /** + * Increase operation date of a rowid + * + * @param int $id Id of line to change + * @return int >0 if OK, 0 if KO + */ + function dateo_next($id) + { + return $this->dateo_change($id,1); + } + + /** + * Decrease operation date of a rowid + * + * @param int $id Id of line to change + * @return int >0 if OK, 0 if KO + */ + function dateo_previous($id) + { + return $this->dateo_change($id,-1); + } + + /** * Load miscellaneous information for tab "Info" * diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 99362167a0701..525b7a72e1279 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -71,13 +71,20 @@ } } -if ($user->rights->banque->consolidate && $action == 'dvnext') + +if ($user->rights->banque->consolidate && $action == 'donext') +{ + $al = new AccountLine($db); + $al->dateo_next($_GET["rowid"]); +}elseif ($user->rights->banque->consolidate && $action == 'doprev') +{ + $al = new AccountLine($db); + $al->dateo_previous($_GET["rowid"]); +}elseif ($user->rights->banque->consolidate && $action == 'dvnext') { $al = new AccountLine($db); $al->datev_next($_GET["rowid"]); -} - -if ($user->rights->banque->consolidate && $action == 'dvprev') +}elseif ($user->rights->banque->consolidate && $action == 'dvprev') { $al = new AccountLine($db); $al->datev_previous($_GET["rowid"]); @@ -479,6 +486,14 @@ { print ''; print $form->select_date($db->jdate($objp->do),'dateo','','','','update',1,0,1,$objp->rappro); + if (! $objp->rappro) + { + print '   '; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + } print ''; } else diff --git a/htdocs/core/ajax/bankconciliate.php b/htdocs/core/ajax/bankconciliate.php index 65620c5429c12..e5bfb674e8f8d 100644 --- a/htdocs/core/ajax/bankconciliate.php +++ b/htdocs/core/ajax/bankconciliate.php @@ -71,3 +71,27 @@ exit; } +if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'donext') +{ + // Increase date + $al = new AccountLine($db); + $al->dateo_next(GETPOST('rowid','int')); + $al->fetch(GETPOST('rowid','int')); + + print ''.dol_print_date($db->jdate($al->dateo),"day").''; + + exit; +} + +if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') +{ + // Decrease date + $al =new AccountLine($db); + $al->dateo_previous(GETPOST('rowid','int')); + $al->fetch(GETPOST('rowid','int')); + + print ''.dol_print_date($db->jdate($al->dateo),"day").''; + + exit; +} +