+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/modules/bank/modules_bank.php
+ * \ingroup project
+ * \brief File that contain parent class for bank models
+ * and parent class for bank numbering models
+ */
+require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
+
+
+/**
+ * Parent class for bank account models
+ */
+abstract class ModeleBankAccountDoc extends CommonDocGenerator
+{
+ var $error='';
+
+
+ /**
+ * Return list of active generation modules
+ *
+ * @param DoliDB $db Database handler
+ * @param integer $maxfilenamelength Max length of value to show
+ * @return array List of templates
+ */
+ static function liste_modeles($db,$maxfilenamelength=0)
+ {
+ global $conf;
+
+ $type='bankaccount';
+ $liste=array();
+
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+ $liste=getListOfModels($db,$type,$maxfilenamelength);
+
+ return $liste;
+ }
+}
+
diff --git a/htdocs/core/modules/modPrelevement.class.php b/htdocs/core/modules/modPrelevement.class.php
index b2d0589f828..75e8410e19e 100644
--- a/htdocs/core/modules/modPrelevement.class.php
+++ b/htdocs/core/modules/modPrelevement.class.php
@@ -73,7 +73,16 @@ class modPrelevement extends DolibarrModules
// Constants
$this->const = array();
-
+ $r=0;
+
+ $this->const[$r][0] = "BANK_ADDON_PDF";
+ $this->const[$r][1] = "chaine";
+ $this->const[$r][2] = "sepamandate";
+ $this->const[$r][3] = 'Name of manager to generate SEPA mandate';
+ $this->const[$r][4] = 0;
+ $r++;
+
+
// Boxes
$this->boxes = array();
@@ -138,7 +147,10 @@ class modPrelevement extends DolibarrModules
// Permissions
$this->remove($options);
- $sql = array();
+ $sql = array(
+ "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,
+ "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','bankaccount',".$conf->entity.")",
+ );
return $this->_init($sql,$options);
}
diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php
index d31226ac052..395d4b05ec4 100644
--- a/htdocs/societe/rib.php
+++ b/htdocs/societe/rib.php
@@ -49,6 +49,8 @@ $id=GETPOST("id","int");
$ribid=GETPOST("ribid","int");
$action=GETPOST("action");
+$account = new CompanyBankAccount($db);
+
/*
* Actions
@@ -57,9 +59,6 @@ $action=GETPOST("action");
if ($action == 'update' && ! $_POST["cancel"])
{
// Modification
- $account = new CompanyBankAccount($db);
-
-
if (! GETPOST('label'))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
@@ -144,21 +143,6 @@ if ($action == 'add' && ! $_POST["cancel"])
$action='create';
$error++;
}
- if ($account->needIBAN() == 1)
- {
- if (! GETPOST('iban'))
- {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
- $action='create';
- $error++;
- }
- if (! GETPOST('bic'))
- {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
- $action='create';
- $error++;
- }
- }
if (! $error)
{
@@ -182,18 +166,38 @@ if ($action == 'add' && ! $_POST["cancel"])
$account->owner_address = GETPOST('owner_address','alpha');
$account->frstrecur = GETPOST('frstrecur');
- $result = $account->update($user); // TODO Use create and include update into create method
- if (! $result)
- {
- setEventMessages($account->error, $account->errors, 'errors');
- $_GET["action"]='create'; // Force chargement page création
- }
- else
- {
- $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
- header('Location: '.$url);
- exit;
- }
+ // This test can be done only once properties were set
+ if ($account->needIBAN() == 1)
+ {
+ if (! GETPOST('iban'))
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
+ $action='create';
+ $error++;
+ }
+ if (! GETPOST('bic'))
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
+ $action='create';
+ $error++;
+ }
+ }
+
+ if (! $error)
+ {
+ $result = $account->update($user); // TODO Use create and include update into create method
+ if (! $result)
+ {
+ setEventMessages($account->error, $account->errors, 'errors');
+ $_GET["action"]='create'; // Force chargement page création
+ }
+ else
+ {
+ $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
+ header('Location: '.$url);
+ exit;
+ }
+ }
}
}
@@ -248,8 +252,6 @@ llxHeader();
$head=societe_prepare_head2($object);
-
-$account = new CompanyBankAccount($db);
if (! $id)
$account->fetch(0,$object->id);
else
@@ -382,6 +384,7 @@ if ($socid && $action != 'edit' && $action != "create")
{
print '| RUM | ';
print ''.$langs->trans("WithdrawMode").' | ';
+ print ' | ';
}
print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"');
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
@@ -408,6 +411,12 @@ if ($socid && $action != 'edit' && $action != "create")
// FRSTRECUR
print ''.$rib->frstrecur.' | ';
+
+ include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
+ $modellist=ModeleBankAccountDoc::liste_modeles($db);
+ print '';
+ //var_dump($modellist);
+ print ' | '; // TODO Add link to generate doc
}
// Default