forked from Wavyzz/dolibarr
New: Ajout rfrence et code compta sur comptes financiers (bancaires ou caisses). Requis pour faire de la compta double partie.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -39,6 +39,7 @@ class Account
|
||||
{
|
||||
var $rowid;
|
||||
|
||||
var $ref;
|
||||
var $label;
|
||||
var $type;
|
||||
var $bank;
|
||||
@@ -55,6 +56,9 @@ class Account
|
||||
var $adresse_proprio;
|
||||
var $type_lib=array();
|
||||
|
||||
var $account_number;
|
||||
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*/
|
||||
@@ -264,9 +268,13 @@ class Account
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! $pcgnumber) $pcgnumber="51";
|
||||
if (! $this->ref)
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account (datec, label, account_number) values (now(),'" . addslashes($this->label) . "','$pcgnumber');";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account (datec, ref, label, account_number) values (now(),'" . addslashes($this->ref) . "', '" . addslashes($this->label) . "','" . addslashes($this->account_number) . "');";
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -298,22 +306,34 @@ class Account
|
||||
/*
|
||||
* \brief Mise a jour compte
|
||||
* \param user Object utilisateur qui modifie
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function update($user='')
|
||||
{
|
||||
// Chargement librairie pour acces fonction controle RIB
|
||||
require_once DOL_DOCUMENT_ROOT . '/compta/bank/bank.lib.php';
|
||||
global $langs;
|
||||
|
||||
// Chargement librairie pour acces fonction controle RIB
|
||||
require_once(DOL_DOCUMENT_ROOT . '/compta/bank/bank.lib.php');
|
||||
|
||||
// Verification parametres
|
||||
if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix)) {
|
||||
$this->error="Le contr<74>le de la cl<63> indique que les informations de votre compte bancaire sont incorrectes.";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! $this->ref)
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref"));
|
||||
return -1;
|
||||
}
|
||||
if (! $this->label) $this->label = "???";
|
||||
$this->account_number=trim($this->account_number);
|
||||
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."bank_account SET ";
|
||||
|
||||
$sql .= " bank = '" .addslashes($this->bank)."'";
|
||||
$sql .= " bank = '".addslashes($this->bank)."'";
|
||||
$sql .= ",ref = '".addslashes($this->ref)."'";
|
||||
$sql .= ",label = '".addslashes($this->label)."'";
|
||||
|
||||
$sql .= ",code_banque='".$this->code_banque."'";
|
||||
@@ -328,6 +348,7 @@ class Account
|
||||
$sql .= ",courant = ".$this->courant;
|
||||
$sql .= ",clos = ".$this->clos;
|
||||
$sql .= ",rappro = ".$this->rappro;
|
||||
$sql .= ",account_number = '".$this->account_number."'";
|
||||
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
@@ -351,8 +372,11 @@ class Account
|
||||
function fetch($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
$sql = "SELECT rowid, label, bank, number, courant, clos, rappro,";
|
||||
$sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix, domiciliation, proprio, adresse_proprio FROM ".MAIN_DB_PREFIX."bank_account";
|
||||
$sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro,";
|
||||
$sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix,";
|
||||
$sql.= " domiciliation, proprio, adresse_proprio,";
|
||||
$sql.= " account_number";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
|
||||
$sql.= " WHERE rowid = ".$id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
@@ -363,6 +387,7 @@ class Account
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$this->ref = $obj->ref;
|
||||
$this->label = $obj->label;
|
||||
$this->type = $obj->courant;
|
||||
$this->courant = $obj->courant;
|
||||
@@ -379,6 +404,8 @@ class Account
|
||||
$this->domiciliation = $obj->domiciliation;
|
||||
$this->proprio = $obj->proprio;
|
||||
$this->adresse_proprio = $obj->adresse_proprio;
|
||||
|
||||
$this->account_number = $obj->account_number;
|
||||
}
|
||||
$this->db->free($result);
|
||||
}
|
||||
@@ -407,6 +434,60 @@ class Account
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne le libell<6C> du statut d'une facture (brouillon, valid<69>e, abandonn<6E>e, pay<61>e)
|
||||
* \param mode 0=libell<6C> long, 1=libell<6C> court, 2=Picto + Libell<6C> court, 3=Picto, 4=Picto + Libell<6C> long
|
||||
* \return string Libelle
|
||||
*/
|
||||
function getLibStatut($mode=0)
|
||||
{
|
||||
return $this->LibStatut($this->clos,$mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi le libell<6C> d'un statut donn<6E>
|
||||
* \param statut Id statut
|
||||
* \param mode 0=libell<6C> long, 1=libell<6C> court, 2=Picto + Libell<6C> court, 3=Picto, 4=Picto + Libell<6C> long, 5=Libell<6C> court + Picto
|
||||
* \return string Libell<6C> du statut
|
||||
*/
|
||||
function LibStatut($statut,$mode=0)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load('banks');
|
||||
|
||||
if ($mode == 0)
|
||||
{
|
||||
if ($statut==0) return $langs->trans("StatusAccountOpened");
|
||||
if ($statut==1) return $langs->trans("StatusAccountClosed");
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
if ($statut==0) return $langs->trans("StatusAccountOpened");
|
||||
if ($statut==1) return $langs->trans("StatusAccountClosed");
|
||||
}
|
||||
if ($mode == 2)
|
||||
{
|
||||
if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4').' '.$langs->trans("StatusAccountOpened");
|
||||
if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5').' '.$langs->trans("StatusAccountClosed");
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4');
|
||||
if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5');
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4').' '.$langs->trans("StatusAccountOpened");
|
||||
if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5').' '.$langs->trans("StatusAccountClosed");
|
||||
}
|
||||
if ($mode == 5)
|
||||
{
|
||||
if ($statut==0) return $langs->trans("StatusAccountOpened").' '.img_picto($langs->trans("StatusAccountOpened"),'statut4');
|
||||
if ($statut==1) return $langs->trans("StatusAccountClosed").' '.img_picto($langs->trans("StatusAccountClosed"),'statut5');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* \brief Renvoi si un compte peut etre supprimer ou non (sans mouvements)
|
||||
* \return boolean vrai si peut etre supprim<69>, faux sinon
|
||||
@@ -443,7 +524,8 @@ class Account
|
||||
*/
|
||||
function solde()
|
||||
{
|
||||
$sql = "SELECT sum(amount) FROM ".MAIN_DB_PREFIX."bank WHERE fk_account=$this->id AND dateo <=" . $this->db->idate(time() );
|
||||
$sql = "SELECT sum(amount) FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql.= " WHERE fk_account=$this->id AND dateo <=" . $this->db->idate(time() );
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2006 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
|
||||
@@ -46,6 +46,7 @@ if ($_POST["action"] == 'add')
|
||||
// Creation compte
|
||||
$account = new Account($db,0);
|
||||
|
||||
$account->ref = ereg_replace(' ','',trim($_POST["ref"]));
|
||||
$account->label = trim($_POST["label"]);
|
||||
$account->courant = $_POST["type"];
|
||||
$account->clos = $_POST["clos"];
|
||||
@@ -58,10 +59,12 @@ if ($_POST["action"] == 'add')
|
||||
$account->cle_rib = $_POST["cle_rib"];
|
||||
$account->bic = $_POST["bic"];
|
||||
$account->iban_prefix = $_POST["iban_prefix"];
|
||||
$account->domiciliation = $_POST["domiciliation"];
|
||||
$account->domiciliation = trim($_POST["domiciliation"]);
|
||||
|
||||
$account->proprio = $_POST["proprio"];
|
||||
$account->adresse_proprio = $_POST["adresse_proprio"];
|
||||
$account->proprio = trim($_POST["proprio"]);
|
||||
$account->adresse_proprio = trim($_POST["adresse_proprio"]);
|
||||
|
||||
$account->account_number = trim($_POST["account_number"]);
|
||||
|
||||
$account->solde = $_POST["solde"];
|
||||
$account->date_solde = mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
|
||||
@@ -87,12 +90,13 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
|
||||
$account = new Account($db, $_POST["id"]);
|
||||
$account->fetch($_POST["id"]);
|
||||
|
||||
$account->ref = ereg_replace(' ','',trim($_POST["ref"]));
|
||||
$account->label = trim($_POST["label"]);
|
||||
$account->courant = $_POST["type"];
|
||||
$account->clos = $_POST["clos"];
|
||||
$account->rappro = (isset($_POST["norappro"]) && $_POST["norappro"]=='on')?0:1;
|
||||
|
||||
$account->bank = $_POST["bank"];
|
||||
$account->bank = trim($_POST["bank"]);
|
||||
$account->code_banque = $_POST["code_banque"];
|
||||
$account->code_guichet = $_POST["code_guichet"];
|
||||
$account->number = $_POST["number"];
|
||||
@@ -100,9 +104,12 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
|
||||
$account->bic = $_POST["bic"];
|
||||
$account->iban_prefix = $_POST["iban_prefix"];
|
||||
$account->domiciliation = $_POST["domiciliation"];
|
||||
|
||||
$account->proprio = $_POST["proprio"];
|
||||
$account->adresse_proprio = $_POST["adresse_proprio"];
|
||||
|
||||
$account->account_number = trim($_POST["account_number"]);
|
||||
|
||||
if ($account->label)
|
||||
{
|
||||
$result = $account->update($user);
|
||||
@@ -164,6 +171,17 @@ if ($_GET["action"] == 'create')
|
||||
print $form->select_type_comptes_financiers(isset($_POST["type"])?$_POST["type"]:1,"type");
|
||||
print '</td></tr>';
|
||||
|
||||
// Code compta
|
||||
if ($conf->comptaexpert->enabled)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("AccountancyCode").'</td>';
|
||||
print '<td colspan="3"><input type="text" name="account_number" value="'.$account->account_number.'"></td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="account_number" value="'.$account->account_number.'">';
|
||||
}
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("InitialBankBalance").'</td>';
|
||||
print '<td colspan="3"><input size="12" type="text" class="flat" name="solde" value="0.00"></td></tr>';
|
||||
|
||||
@@ -230,7 +248,7 @@ else
|
||||
$head[$h][1] = $langs->trans("AccountCard");
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("FinancialAccount")." ".($account->number?$account->number:$account->label));
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("FinancialAccount"));
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression
|
||||
@@ -243,6 +261,10 @@ else
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td valign="top">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="3">'.$account->ref.'</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
|
||||
print '<td colspan="3">'.$account->label.'</td></tr>';
|
||||
|
||||
@@ -250,7 +272,7 @@ else
|
||||
print '<td colspan="3">'.$account->type_lib[$account->type].'</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Status").'</td>';
|
||||
print '<td colspan="3">'.$account->status[$account->clos].'</td></tr>';
|
||||
print '<td colspan="3">'.$account->getLibStatut(4).'</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Conciliable").'</td>';
|
||||
print '<td colspan="3">';
|
||||
@@ -258,6 +280,13 @@ else
|
||||
if ($account->type == 2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
|
||||
print '</td></tr>';
|
||||
|
||||
// Code compta
|
||||
if ($conf->comptaexpert->enabled)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("AccountancyCode").'</td>';
|
||||
print '<td colspan="3">'.$account->account_number.'</td></tr>';
|
||||
}
|
||||
|
||||
if ($account->type == 0 || $account->type == 1)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("Bank").'</td>';
|
||||
@@ -336,6 +365,10 @@ else
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td valign="top">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="3"><input size="8" type="text" class="flat" name="ref" value="'.$account->ref.'"></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
|
||||
print '<td colspan="3"><input size="30" type="text" class="flat" name="label" value="'.$account->label.'"></td></tr>';
|
||||
|
||||
@@ -355,6 +388,17 @@ else
|
||||
if ($account->type == 2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
|
||||
print '</td></tr>';
|
||||
|
||||
// Code compta
|
||||
if ($conf->comptaexpert->enabled)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("AccountancyCode").'</td>';
|
||||
print '<td colspan="3"><input type="text" name="account_number" value="'.$account->account_number.'"></td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="account_number" value="'.$account->account_number.'">';
|
||||
}
|
||||
|
||||
if ($account->type == 0 || $account->type == 1)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("Bank").'</td>';
|
||||
|
||||
@@ -103,6 +103,9 @@ update llx_const set name='SOCIETE_FISCAL_MONTH_START' where name='FISCAL_MONTH_
|
||||
update llx_const set visible=0 where name='FACTURE_DISABLE_RECUR';
|
||||
update llx_const set visible=0 where name='MAILING_EMAIL_FROM';
|
||||
|
||||
insert into llx_const(name,value,type,visible,note) values('MAIN_SHOW_DEVELOPMENT_MODULES','0','yesno',1,'Make development modules visible');
|
||||
|
||||
|
||||
alter table llx_paiementfourn add statut smallint(6) NOT NULL DEFAULT 0;
|
||||
|
||||
|
||||
@@ -225,3 +228,6 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v
|
||||
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (101, 'commande', 'external', 'CUSTOMER', 'Contact client suivi commande', 1);
|
||||
|
||||
insert into llx_c_pays (rowid,code,libelle) values (30, 'SG', 'Singapoure');
|
||||
|
||||
|
||||
alter table llx_bank_account add column ref varchar(12) NOT NULL;
|
||||
|
||||
@@ -30,7 +30,8 @@ create table llx_bank_account
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
datec datetime,
|
||||
tms timestamp,
|
||||
label varchar(30),
|
||||
ref varchar(12) NOT NULL,
|
||||
label varchar(30) NOT NULL,
|
||||
bank varchar(60),
|
||||
code_banque varchar(7),
|
||||
code_guichet varchar(6),
|
||||
|
||||
Reference in New Issue
Block a user