2004-10-19 22:35:36 +02:00
|
|
|
|
<?php
|
2003-02-03 13:47:01 +01:00
|
|
|
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2004-02-02 23:55:10 +01:00
|
|
|
|
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
|
|
|
|
|
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
2004-09-27 10:16:22 +02:00
|
|
|
|
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
2002-12-23 15:19:41 +01:00
|
|
|
|
*
|
|
|
|
|
|
* 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$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2004-09-30 21:31:24 +02:00
|
|
|
|
/*!
|
2004-10-13 00:06:55 +02:00
|
|
|
|
\file htdocs/compta/bank/account.class.php
|
|
|
|
|
|
\ingroup banque
|
2004-09-30 21:31:24 +02:00
|
|
|
|
\brief Fichier de la classe des comptes bancaires
|
|
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \class Account
|
|
|
|
|
|
\brief Classe permettant la gestion des comptes bancaires
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2003-06-20 16:30:08 +02:00
|
|
|
|
class Account
|
|
|
|
|
|
{
|
2002-12-23 15:19:41 +01:00
|
|
|
|
var $rowid;
|
2002-12-24 01:08:44 +01:00
|
|
|
|
|
2002-12-23 15:19:41 +01:00
|
|
|
|
var $bank;
|
|
|
|
|
|
var $label;
|
|
|
|
|
|
var $courant;
|
2003-02-03 13:47:01 +01:00
|
|
|
|
var $clos;
|
2002-12-23 15:19:41 +01:00
|
|
|
|
var $code_banque;
|
|
|
|
|
|
var $code_guichet;
|
|
|
|
|
|
var $number;
|
|
|
|
|
|
var $cle_rib;
|
|
|
|
|
|
var $bic;
|
2003-02-03 14:14:38 +01:00
|
|
|
|
var $iban_prefix;
|
2004-02-02 23:51:34 +01:00
|
|
|
|
var $proprio;
|
|
|
|
|
|
var $adresse_proprio;
|
2002-12-23 15:19:41 +01:00
|
|
|
|
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function Account($DB, $rowid=0)
|
2003-06-20 16:30:08 +02:00
|
|
|
|
{
|
2002-12-23 15:19:41 +01:00
|
|
|
|
global $config;
|
2003-06-20 16:30:08 +02:00
|
|
|
|
|
2002-12-23 15:19:41 +01:00
|
|
|
|
$this->db = $DB;
|
|
|
|
|
|
$this->rowid = $rowid;
|
2004-08-03 23:17:01 +02:00
|
|
|
|
|
|
|
|
|
|
$this->clos = 0;
|
2003-09-04 15:09:13 +02:00
|
|
|
|
$this->solde = 0;
|
2004-08-03 23:17:01 +02:00
|
|
|
|
|
2002-12-23 15:19:41 +01:00
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
2003-09-03 16:11:06 +02:00
|
|
|
|
|
2002-12-24 01:08:44 +01:00
|
|
|
|
/*
|
2004-02-01 02:50:21 +01:00
|
|
|
|
* Efface une entree dans la table ".MAIN_DB_PREFIX."bank
|
2003-09-03 16:11:06 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function deleteline($rowid)
|
2003-10-21 18:25:51 +02:00
|
|
|
|
{
|
2004-02-01 02:50:21 +01:00
|
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=$rowid";
|
2003-10-21 18:25:51 +02:00
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
|
2004-02-01 02:50:21 +01:00
|
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=$rowid";
|
2003-09-03 16:11:06 +02:00
|
|
|
|
$result = $this->db->query($sql);
|
2003-10-21 18:25:51 +02:00
|
|
|
|
|
2004-02-01 02:50:21 +01:00
|
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=$rowid";
|
2003-10-21 18:25:51 +02:00
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function add_url_line($line_id, $url_id, $url, $label)
|
2003-10-21 18:25:51 +02:00
|
|
|
|
{
|
2004-02-01 02:50:21 +01:00
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url (fk_bank, url_id, url, label)";
|
2004-01-18 21:29:34 +01:00
|
|
|
|
$sql .= " VALUES ('$line_id', '$url_id', '$url', '$label')";
|
2003-10-21 18:25:51 +02:00
|
|
|
|
|
|
|
|
|
|
if ($this->db->query($sql))
|
|
|
|
|
|
{
|
|
|
|
|
|
$rowid = $this->db->last_insert_id();
|
|
|
|
|
|
|
|
|
|
|
|
return $rowid;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return '';
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
print "<br>$sql";
|
|
|
|
|
|
}
|
2003-09-03 16:11:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
/*
|
2002-12-24 01:08:44 +01:00
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function get_url($line_id)
|
2003-10-21 18:25:51 +02:00
|
|
|
|
{
|
|
|
|
|
|
$lines = array();
|
2004-02-01 02:50:21 +01:00
|
|
|
|
$sql = "SELECT fk_bank, url_id, url, label FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank = $line_id";
|
2003-10-21 18:25:51 +02:00
|
|
|
|
$result = $this->db->query($sql);
|
2003-06-20 16:30:08 +02:00
|
|
|
|
|
2003-10-21 18:25:51 +02:00
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
$num = $this->db->num_rows();
|
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
|
{
|
2004-10-23 18:55:07 +02:00
|
|
|
|
$obj = $this->db->fetch_object($result);
|
2003-10-21 18:25:51 +02:00
|
|
|
|
$lines[$i][0] = $obj->url;
|
|
|
|
|
|
$lines[$i][1] = $obj->url_id;
|
|
|
|
|
|
$lines[$i][2] = $obj->label;
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
return $lines;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2004-11-18 00:15:40 +01:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* \brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank
|
|
|
|
|
|
* \return int rowid de l'entr<EFBFBD>e ajout<EFBFBD>e
|
2003-10-21 18:25:51 +02:00
|
|
|
|
*/
|
2004-11-18 00:15:40 +01:00
|
|
|
|
function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user='')
|
2003-06-20 16:30:08 +02:00
|
|
|
|
{
|
2003-08-04 20:06:12 +02:00
|
|
|
|
if ($this->rowid)
|
2003-07-21 15:04:59 +02:00
|
|
|
|
{
|
2003-08-04 20:06:12 +02:00
|
|
|
|
switch ($oper)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
$oper = 'TIP';
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
$oper = 'VIR';
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
$oper = 'PRE';
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
$oper = 'LIQ';
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 5:
|
2004-09-27 10:16:22 +02:00
|
|
|
|
$oper = 'VAD';
|
2003-08-04 20:06:12 +02:00
|
|
|
|
break;
|
|
|
|
|
|
case 6:
|
|
|
|
|
|
$oper = 'CB';
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 7:
|
|
|
|
|
|
$oper = 'CHQ';
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-04-06 10:29:11 +02:00
|
|
|
|
$datev = $date;
|
|
|
|
|
|
|
2004-05-02 15:42:06 +02:00
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, dateo, datev, label, amount, fk_user_author, num_chq,fk_account, fk_type)";
|
|
|
|
|
|
$sql .= " VALUES (now(), '$date', '$datev', '$label', '" . ereg_replace(",",".",$amount) . "', '$user->id' ,'$num_chq', '$this->rowid', '$oper')";
|
2004-01-18 21:29:34 +01:00
|
|
|
|
|
2003-06-20 16:30:08 +02:00
|
|
|
|
|
2003-08-04 20:06:12 +02:00
|
|
|
|
if ($this->db->query($sql))
|
|
|
|
|
|
{
|
2003-09-03 16:11:06 +02:00
|
|
|
|
$rowid = $this->db->last_insert_id();
|
|
|
|
|
|
if ($categorie)
|
|
|
|
|
|
{
|
2004-02-01 02:50:21 +01:00
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES ('$rowid', '$categorie')";
|
2003-09-03 16:11:06 +02:00
|
|
|
|
$result = $this->db->query($sql);
|
2004-05-25 15:45:14 +02:00
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
return $rowid;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-01-24 15:00:25 +01:00
|
|
|
|
//return ''; On ne quitte pas avec erreur car insertion dans bank_class peut echouer alors que insertion dans bank ok
|
2003-09-03 16:11:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return $rowid;
|
2003-08-04 20:06:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-08-03 23:17:01 +02:00
|
|
|
|
dolibarr_print_error($this->db);
|
2003-09-03 16:11:06 +02:00
|
|
|
|
return '';
|
2003-08-04 20:06:12 +02:00
|
|
|
|
}
|
2003-07-15 13:30:58 +02:00
|
|
|
|
}
|
2003-06-20 16:30:08 +02:00
|
|
|
|
}
|
2004-08-03 21:52:57 +02:00
|
|
|
|
|
2003-09-04 15:09:13 +02:00
|
|
|
|
/*
|
2004-08-03 21:52:57 +02:00
|
|
|
|
* Creation du compte bancaire
|
2003-09-04 15:09:13 +02:00
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function create()
|
2002-12-24 01:08:44 +01:00
|
|
|
|
{
|
2004-08-03 21:52:57 +02:00
|
|
|
|
// Chargement librairie pour acces fonction controle RIB
|
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT . '/compta/bank/bank.lib.php';
|
|
|
|
|
|
|
2004-08-04 09:10:40 +02:00
|
|
|
|
if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix)) {
|
2004-08-03 21:52:57 +02:00
|
|
|
|
$this->error="Le contr<74>le de la cl<63> indique que les informations de votre compte bancaire sont incorrectes.";
|
2004-08-03 23:17:01 +02:00
|
|
|
|
return 0;
|
2004-08-03 21:52:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (! $pcgnumber) {
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
// Prendre comme de numero compte comptable pour le compte bancaire, le numero par defaut pour plan de compte actif
|
|
|
|
|
|
$pcgnumber="51";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account (datec, label, account_number) values (now(),'$this->label','$pcgnumber');";
|
2002-12-24 01:08:44 +01:00
|
|
|
|
if ($this->db->query($sql))
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($this->db->affected_rows())
|
|
|
|
|
|
{
|
|
|
|
|
|
$this->id = $this->db->last_insert_id();
|
2003-09-04 15:09:13 +02:00
|
|
|
|
if ( $this->update() )
|
|
|
|
|
|
{
|
2004-02-01 02:50:21 +01:00
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, label, amount, fk_account,datev,dateo,fk_type,rappro) ";
|
2004-01-18 21:29:34 +01:00
|
|
|
|
$sql .= " VALUES (now(),'Solde','" . ereg_replace(",",".",$this->solde) . "','$this->id','".$this->db->idate($this->date_solde)."','".$this->db->idate($this->date_solde)."','SOLD',1);";
|
2003-09-04 15:09:13 +02:00
|
|
|
|
|
|
|
|
|
|
$this->db->query($sql);
|
|
|
|
|
|
}
|
2002-12-24 01:08:44 +01:00
|
|
|
|
return $this->id;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-08-03 23:17:01 +02:00
|
|
|
|
dolibarr_print_error($this->db);
|
|
|
|
|
|
return 0;
|
2002-12-24 01:08:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2004-08-03 21:52:57 +02:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function update($user='')
|
2004-08-03 21:52:57 +02:00
|
|
|
|
{
|
2004-08-03 23:17:01 +02:00
|
|
|
|
// Chargement librairie pour acces fonction controle RIB
|
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT . '/compta/bank/bank.lib.php';
|
|
|
|
|
|
|
2004-08-04 09:10:40 +02:00
|
|
|
|
if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix)) {
|
2004-08-03 23:17:01 +02:00
|
|
|
|
$this->error="Le contr<74>le de la cl<63> indique que les informations de votre compte bancaire sont incorrectes.";
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (! $this->label) $this->label = "???";
|
2003-09-02 20:53:33 +02:00
|
|
|
|
|
2004-02-01 02:50:21 +01:00
|
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."bank_account SET ";
|
2002-12-24 01:08:44 +01:00
|
|
|
|
|
|
|
|
|
|
$sql .= " bank = '" .$this->bank ."'";
|
|
|
|
|
|
$sql .= ",label = '".$this->label ."'";
|
|
|
|
|
|
|
|
|
|
|
|
$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."'";
|
2004-02-02 23:51:34 +01:00
|
|
|
|
$sql .= ",iban_prefix = '".$this->iban_prefix."'";
|
2003-04-13 20:31:52 +02:00
|
|
|
|
$sql .= ",domiciliation='".$this->domiciliation."'";
|
2004-02-02 23:51:34 +01:00
|
|
|
|
$sql .= ",proprio = '".$this->proprio."'";
|
|
|
|
|
|
$sql .= ",adresse_proprio = '".$this->adresse_proprio."'";
|
2002-12-24 01:08:44 +01:00
|
|
|
|
$sql .= ",courant = ".$this->courant;
|
2003-02-03 13:47:01 +01:00
|
|
|
|
$sql .= ",clos = ".$this->clos;
|
2002-12-24 01:08:44 +01:00
|
|
|
|
|
2004-08-03 23:17:01 +02:00
|
|
|
|
$sql .= " WHERE rowid = ".$this->id;
|
2002-12-24 01:08:44 +01:00
|
|
|
|
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
2004-08-03 23:17:01 +02:00
|
|
|
|
return 1;
|
2002-12-24 01:08:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-08-03 23:17:01 +02:00
|
|
|
|
dolibarr_print_error($this->db);
|
2003-09-04 15:09:13 +02:00
|
|
|
|
return 0;
|
2002-12-24 01:08:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2004-08-03 23:17:01 +02:00
|
|
|
|
|
2002-12-24 01:08:44 +01:00
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function fetch($id)
|
2002-12-24 01:08:44 +01:00
|
|
|
|
{
|
2002-12-23 15:19:41 +01:00
|
|
|
|
$this->id = $id;
|
2004-02-02 23:51:34 +01:00
|
|
|
|
$sql = "SELECT rowid, label, bank, number, courant, clos, code_banque, code_guichet, cle_rib, bic, iban_prefix, domiciliation, proprio, adresse_proprio FROM ".MAIN_DB_PREFIX."bank_account";
|
2002-12-23 15:19:41 +01:00
|
|
|
|
$sql .= " WHERE rowid = ".$id;
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
|
2002-12-24 01:08:44 +01:00
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($this->db->num_rows())
|
|
|
|
|
|
{
|
2004-10-23 18:55:07 +02:00
|
|
|
|
$obj = $this->db->fetch_object($result);
|
2002-12-24 01:08:44 +01:00
|
|
|
|
|
2003-04-13 20:31:52 +02:00
|
|
|
|
$this->bank = $obj->bank;
|
|
|
|
|
|
$this->label = $obj->label;
|
|
|
|
|
|
$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;
|
2004-02-02 23:51:34 +01:00
|
|
|
|
$this->domiciliation = $obj->domiciliation;
|
|
|
|
|
|
$this->proprio = $obj->proprio;
|
|
|
|
|
|
$this->adresse_proprio = $obj->adresse_proprio;
|
2002-12-24 01:08:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
$this->db->free();
|
2002-12-23 15:19:41 +01:00
|
|
|
|
}
|
2003-06-20 16:30:08 +02:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-08-03 23:17:01 +02:00
|
|
|
|
dolibarr_print_error($this->db);
|
2003-06-20 16:30:08 +02:00
|
|
|
|
}
|
2002-12-23 15:19:41 +01:00
|
|
|
|
}
|
2004-08-03 23:17:01 +02:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function error()
|
2004-08-03 23:17:01 +02:00
|
|
|
|
{
|
|
|
|
|
|
return $this->error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2002-12-24 01:08:44 +01:00
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function solde()
|
2002-12-24 01:08:44 +01:00
|
|
|
|
{
|
2004-02-01 02:50:21 +01:00
|
|
|
|
$sql = "SELECT sum(amount) FROM ".MAIN_DB_PREFIX."bank WHERE fk_account=$this->id AND dateo <=" . $this->db->idate(time() );
|
2002-12-23 15:19:41 +01:00
|
|
|
|
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
|
2002-12-24 01:08:44 +01:00
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($this->db->num_rows())
|
|
|
|
|
|
{
|
|
|
|
|
|
$solde = $this->db->result(0,0);
|
2002-12-23 15:19:41 +01:00
|
|
|
|
|
2002-12-24 01:08:44 +01:00
|
|
|
|
return $solde;
|
|
|
|
|
|
}
|
|
|
|
|
|
$this->db->free();
|
2002-12-23 15:19:41 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2004-04-06 09:21:29 +02:00
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function datev_next($rowid)
|
2004-04-06 09:21:29 +02:00
|
|
|
|
{
|
|
|
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."bank SET ";
|
|
|
|
|
|
|
|
|
|
|
|
$sql .= " datev = adddate(datev, interval 1 day)";
|
|
|
|
|
|
|
|
|
|
|
|
$sql .= " WHERE rowid = $rowid";
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($this->db->affected_rows())
|
|
|
|
|
|
{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
print "<p>$sql</p>";
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-08-07 19:14:42 +02:00
|
|
|
|
function datev_previous($rowid)
|
2004-04-06 09:21:29 +02:00
|
|
|
|
{
|
|
|
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."bank SET ";
|
|
|
|
|
|
|
|
|
|
|
|
$sql .= " datev = adddate(datev, interval -1 day)";
|
|
|
|
|
|
|
|
|
|
|
|
$sql .= " WHERE rowid = $rowid";
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($this->db->affected_rows())
|
|
|
|
|
|
{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
print "<p>$sql</p>";
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2002-12-23 15:19:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|