Nouveau fichier
This commit is contained in:
parent
2ad4d3046c
commit
07dbcb3346
201
htdocs/companybankaccount.class.php
Normal file
201
htdocs/companybankaccount.class.php
Normal file
@ -0,0 +1,201 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
class CompanyBankAccount
|
||||
{
|
||||
var $rowid;
|
||||
|
||||
var $bank;
|
||||
var $courant;
|
||||
var $clos;
|
||||
var $code_banque;
|
||||
var $code_guichet;
|
||||
var $number;
|
||||
var $cle_rib;
|
||||
var $bic;
|
||||
var $iban_prefix;
|
||||
var $proprio;
|
||||
var $adresse_proprio;
|
||||
|
||||
function CompanyBankAccount($DB, $soc_id)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$this->db = $DB;
|
||||
$this->soc_id = $soc_id;
|
||||
|
||||
$this->clos = 0;
|
||||
$this->solde = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Creation du compte bancaire
|
||||
*
|
||||
*/
|
||||
function create()
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->soc_id, now());";
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
if ($this->db->affected_rows())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function update($user='')
|
||||
{
|
||||
|
||||
$sql = "SELECT fk_soc FROM ".MAIN_DB_PREFIX."societe_rib ";
|
||||
$sql .= " WHERE fk_soc = ".$this->soc_id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows() == 0)
|
||||
{
|
||||
$this->create();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strlen(trim($this->iban_prefix)) == 0)
|
||||
{
|
||||
// Indispensable de la positionner pour vérifier le RIB
|
||||
$this->iban_prefix = 'FR';
|
||||
}
|
||||
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET ";
|
||||
|
||||
$sql .= " bank = '" .$this->bank ."'";
|
||||
$sql .= ",code_banque='".$this->code_banque."'";
|
||||
$sql .= ",code_guichet='".$this->code_guichet."'";
|
||||
$sql .= ",number='".$this->number."'";
|
||||
$sql .= ",cle_rib='".$this->cle_rib."'";
|
||||
$sql .= ",bic='".$this->bic."'";
|
||||
$sql .= ",iban_prefix = '".$this->iban_prefix."'";
|
||||
$sql .= ",domiciliation='".$this->domiciliation."'";
|
||||
$sql .= ",proprio = '".$this->proprio."'";
|
||||
$sql .= ",adresse_proprio = '".$this->adresse_proprio."'";
|
||||
|
||||
$sql .= " WHERE fk_soc = ".$this->soc_id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function fetch()
|
||||
{
|
||||
|
||||
$sql = "SELECT rowid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix, domiciliation, proprio, adresse_proprio FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
$sql .= " WHERE fk_soc = ".$this->soc_id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows())
|
||||
{
|
||||
$obj = $this->db->fetch_object($result , 0);
|
||||
|
||||
$this->bank = $obj->bank;
|
||||
$this->courant = $obj->courant;
|
||||
$this->clos = $obj->clos;
|
||||
$this->code_banque = $obj->code_banque;
|
||||
$this->code_guichet = $obj->code_guichet;
|
||||
$this->number = $obj->number;
|
||||
$this->cle_rib = $obj->cle_rib;
|
||||
$this->bic = $obj->bic;
|
||||
$this->iban_prefix = $obj->iban_prefix;
|
||||
$this->domiciliation = $obj->domiciliation;
|
||||
$this->proprio = $obj->proprio;
|
||||
$this->adresse_proprio = $obj->adresse_proprio;
|
||||
}
|
||||
$this->db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function error()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function verif()
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/compta/bank/bank.lib.php';
|
||||
if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
227
htdocs/societe/rib.php
Normal file
227
htdocs/societe/rib.php
Normal file
@ -0,0 +1,227 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
require("./pre.inc.php");
|
||||
require_once DOL_DOCUMENT_ROOT . "/companybankaccount.class.php";
|
||||
|
||||
$user->getrights('societe');
|
||||
|
||||
if ( !$user->rights->societe->creer)
|
||||
accessforbidden();
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->id = $_GET["socid"];
|
||||
$soc->fetch($_GET["socid"]);
|
||||
|
||||
if ($_POST["action"] == 'update' && ! $_POST["cancel"])
|
||||
{
|
||||
// Modification
|
||||
$account = new CompanyBankAccount($db, $soc->id);
|
||||
|
||||
$account->bank = $_POST["bank"];
|
||||
$account->label = $_POST["label"];
|
||||
$account->courant = $_POST["courant"];
|
||||
$account->clos = $_POST["clos"];
|
||||
$account->code_banque = $_POST["code_banque"];
|
||||
$account->code_guichet = $_POST["code_guichet"];
|
||||
$account->number = $_POST["number"];
|
||||
$account->cle_rib = $_POST["cle_rib"];
|
||||
$account->bic = $_POST["bic"];
|
||||
$account->iban_prefix = $_POST["iban_prefix"];
|
||||
$account->domiciliation = $_POST["domiciliation"];
|
||||
$account->proprio = $_POST["proprio"];
|
||||
$account->adresse_proprio = $_POST["adresse_proprio"];
|
||||
|
||||
$result = $account->update($user);
|
||||
if (! $result)
|
||||
{
|
||||
$message=$account->error();
|
||||
$_GET["action"]='edit'; // Force chargement page edition
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$h = 0;
|
||||
|
||||
$head[0][0] = DOL_URL_ROOT .'/soc.php?socid='.$soc->id;
|
||||
$head[0][1] = "Fiche société";
|
||||
$h = 1;
|
||||
|
||||
$head[$h][0] = "fiche.php?id=$account->id";
|
||||
$head[$h][1] = "Compte bancaire $account->number";
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, 1);
|
||||
|
||||
$account = new CompanyBankAccount($db, $soc->id);
|
||||
$account->fetch();
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Visu et edition */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($_GET["socid"] && $_GET["action"] != 'edit')
|
||||
{
|
||||
|
||||
if (!$account->verif())
|
||||
{
|
||||
print "Le contrôle de la clé indique que les informations de votre compte bancaire sont incorrectes.";
|
||||
}
|
||||
|
||||
|
||||
|
||||
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
|
||||
|
||||
print '<tr><td valign="top">Banque</td>';
|
||||
print '<td colspan="3">'.$account->bank.'</td></tr>';
|
||||
|
||||
print '<tr><td>Code Banque</td><td>Code Guichet</td><td>Numéro</td><td>Clé RIB</td></tr>';
|
||||
print '<tr><td>'.$account->code_banque.'</td>';
|
||||
print '<td>'.$account->code_guichet.'</td>';
|
||||
print '<td>'.$account->number.'</td>';
|
||||
print '<td>'.$account->cle_rib.'</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">Clé IBAN</td>';
|
||||
print '<td colspan="3">'.$account->iban_prefix.'</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">Identifiant BIC</td>';
|
||||
print '<td colspan="3">'.$account->bic.'</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">Domiciliation</td><td colspan="3">';
|
||||
print $account->domiciliation;
|
||||
print "</td></tr>\n";
|
||||
|
||||
print '<tr><td valign="top">Nom propriétaire du compte</td><td colspan="3">';
|
||||
print $account->proprio;
|
||||
print "</td></tr>\n";
|
||||
|
||||
print '<tr><td valign="top">Adresse propriétaire du compte</td><td colspan="3">';
|
||||
print $account->adresse_proprio;
|
||||
print "</td></tr>\n";
|
||||
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Barre d'actions
|
||||
*
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="rib.php?socid='.$soc->id.'&action=edit">'.$langs->trans("Edit").'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Edition */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($_GET["socid"] && $_GET["action"] == 'edit' && $user->rights->societe->creer)
|
||||
{
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
print_titre("Edition compte bancaire");
|
||||
print "<br>";
|
||||
|
||||
if ($message) { print "$message<br><br>\n"; }
|
||||
|
||||
print '<form action="rib.php?socid='.$soc->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
||||
|
||||
print '<table class="border" cellpadding="3" cellspacing="0">';
|
||||
|
||||
print '<tr><td valign="top">Banque</td>';
|
||||
print '<td colspan="3"><input size="30" type="text" name="bank" value="'.$account->bank.'"></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
|
||||
print '<td colspan="3"><input size="30" type="text" name="label" value="'.$account->label.'"></td></tr>';
|
||||
|
||||
print '<tr><td>Code Banque</td><td>Code Guichet</td><td>Numéro</td><td>Clé RIB</td></tr>';
|
||||
print '<tr><td><input size="8" type="text" name="code_banque" value="'.$account->code_banque.'"></td>';
|
||||
print '<td><input size="8" type="text" name="code_guichet" value="'.$account->code_guichet.'"></td>';
|
||||
print '<td><input size="15" type="text" name="number" value="'.$account->number.'"></td>';
|
||||
print '<td><input size="3" type="text" name="cle_rib" value="'.$account->cle_rib.'"></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">Clé IBAN</td>';
|
||||
print '<td colspan="3"><input size="5" type="text" name="iban_prefix" value="'.$account->iban_prefix.'"></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">Identifiant BIC</td>';
|
||||
print '<td colspan="3"><input size="12" type="text" name="bic" value="'.$account->bic.'"></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">Domiciliation</td><td colspan="3">';
|
||||
print "<textarea name=\"domiciliation\" rows=\"4\" cols=\"40\">";
|
||||
print $account->domiciliation;
|
||||
print "</textarea></td></tr>";
|
||||
|
||||
print '<tr><td valign="top">Nom propriétaire du compte</td>';
|
||||
print '<td colspan="3"><input size="30" type="text" name="proprio" value="'.$account->proprio.'"></td></tr>';
|
||||
print "</td></tr>\n";
|
||||
|
||||
print '<tr><td valign="top">Adresse propriétaire du compte</td><td colspan="3">';
|
||||
print "<textarea name=\"adresse_proprio\" rows=\"4\" cols=\"40\">";
|
||||
print $account->adresse_proprio;
|
||||
print "</textarea></td></tr>";
|
||||
|
||||
print '<tr><td align="center" colspan="4"><input value="'.$langs->trans("Modify").'" type="submit">';
|
||||
print ' <input name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
|
||||
print '</td></tr>';
|
||||
print '</form>';
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user