Qual: Uniformize code

This commit is contained in:
Laurent Destailleur 2010-06-05 14:34:04 +00:00
parent 8c5df64890
commit 8b77ea2019
4 changed files with 18 additions and 14 deletions

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* *
@ -46,7 +47,7 @@ $result = restrictedArea($user, 'prelevement', '', '', 'bons');
if ($_GET["action"] == 'create') if ($_GET["action"] == 'create')
{ {
$bprev = new BonPrelevement($db); $bprev = new BonPrelevement($db);
$result=$bprev->create(PRELEVEMENT_CODE_BANQUE, PRELEVEMENT_CODE_GUICHET); $result=$bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET);
if ($result < 0) if ($result < 0)
{ {
$mesg='<div class="error">'.$bprev->error.'</div>'; $mesg='<div class="error">'.$bprev->error.'</div>';

View File

@ -133,15 +133,19 @@ class CompanyBankAccount
} }
} }
/* /**
* * Load record from database
* * @param id Id of record
* @param socid Id of company
*/ */
function fetch() function fetch($id,$socid)
{ {
if (empty($id) && empty($socid)) return -1;
$sql = "SELECT rowid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio, adresse_proprio FROM ".MAIN_DB_PREFIX."societe_rib"; $sql = "SELECT rowid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio, adresse_proprio";
$sql.= " WHERE fk_soc = ".$this->socid; $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
if ($id) $sql.= " WHERE rowid = ".$id;
if ($socid) $sql.= " WHERE fk_soc = ".$socid;
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -151,6 +155,7 @@ class CompanyBankAccount
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
$this->bank = $obj->bank; $this->bank = $obj->bank;
$this->courant = $obj->courant; $this->courant = $obj->courant;
$this->clos = $obj->clos; $this->clos = $obj->clos;

View File

@ -1466,8 +1466,7 @@ class Societe extends CommonObject
require_once DOL_DOCUMENT_ROOT . "/societe/class/companybankaccount.class.php"; require_once DOL_DOCUMENT_ROOT . "/societe/class/companybankaccount.class.php";
$bac = new CompanyBankAccount($this->db); $bac = new CompanyBankAccount($this->db);
$bac->socid = $this->id; $bac->fetch(0,$this->id);
$bac->fetch($this->id);
if ($bac->code_banque || $bac->code_guichet || $bac->number || $bac->cle_rib) if ($bac->code_banque || $bac->code_guichet || $bac->number || $bac->cle_rib)
{ {
@ -1488,9 +1487,8 @@ class Societe extends CommonObject
{ {
require_once DOL_DOCUMENT_ROOT . "/societe/class/companybankaccount.class.php"; require_once DOL_DOCUMENT_ROOT . "/societe/class/companybankaccount.class.php";
$bac = new CompanyBankAccount($this->db, $this->id); $bac = new CompanyBankAccount($this->db);
$bac->socid = $this->id; $bac->fetch(0,$this->id);
$bac->fetch();
$this->bank_account = $bac; $this->bank_account = $bac;
return 1; return 1;

View File

@ -95,8 +95,8 @@ $head=societe_prepare_head2($soc);
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
$account = new CompanyBankAccount($db); $account = new CompanyBankAccount($db);
$account->socid=$soc->id; $account->fetch(0,$soc->id);
$account->fetch($soc->id);
/* ************************************************************************** */ /* ************************************************************************** */