[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * $Id: companybankaccount.class.php,v 1.5.2.1 2005/12/26 13:23:37 hregis Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/companybankaccount.class.php,v $ 20 */ 21 22 class CompanyBankAccount 23 { 24 var $rowid; 25 26 var $bank; 27 var $courant; 28 var $clos; 29 var $code_banque; 30 var $code_guichet; 31 var $number; 32 var $cle_rib; 33 var $bic; 34 var $iban_prefix; 35 var $proprio; 36 var $adresse_proprio; 37 38 function CompanyBankAccount($DB, $soc_id) 39 { 40 global $config; 41 42 $this->db = $DB; 43 $this->soc_id = $soc_id; 44 45 $this->clos = 0; 46 $this->solde = 0; 47 $this->error_number = 0; 48 return 1; 49 } 50 51 52 /* 53 * Creation du compte bancaire 54 * 55 */ 56 function create() 57 { 58 59 $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->soc_id, now());"; 60 if ($this->db->query($sql)) 61 { 62 if ($this->db->affected_rows()) 63 { 64 return 1; 65 } 66 } 67 else 68 { 69 print $this->db->error(); 70 return 0; 71 72 } 73 } 74 /* 75 * 76 * 77 */ 78 function update($user='') 79 { 80 81 $sql = "SELECT fk_soc FROM ".MAIN_DB_PREFIX."societe_rib "; 82 $sql .= " WHERE fk_soc = ".$this->soc_id; 83 84 $result = $this->db->query($sql); 85 86 if ($result) 87 { 88 if ($this->db->num_rows() == 0) 89 { 90 $this->create(); 91 } 92 } 93 else 94 { 95 print $this->db->error(); 96 return 0; 97 } 98 99 if (strlen(trim($this->iban_prefix)) == 0) 100 { 101 // Indispensable de la positionner pour vérifier le RIB 102 $this->iban_prefix = 'FR'; 103 } 104 105 106 $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET "; 107 108 $sql .= " bank = '" .addslashes($this->bank)."'"; 109 $sql .= ",code_banque='".$this->code_banque."'"; 110 $sql .= ",code_guichet='".$this->code_guichet."'"; 111 $sql .= ",number='".$this->number."'"; 112 $sql .= ",cle_rib='".$this->cle_rib."'"; 113 $sql .= ",bic='".$this->bic."'"; 114 $sql .= ",iban_prefix = '".$this->iban_prefix."'"; 115 $sql .= ",domiciliation='".addslashes($this->domiciliation)."'"; 116 $sql .= ",proprio = '".addslashes($this->proprio)."'"; 117 $sql .= ",adresse_proprio = '".addslashes($this->adresse_proprio)."'"; 118 119 $sql .= " WHERE fk_soc = ".$this->soc_id; 120 121 $result = $this->db->query($sql); 122 123 if ($result) 124 { 125 return 1; 126 } 127 else 128 { 129 dolibarr_print_error($this->db); 130 return 0; 131 } 132 } 133 134 /* 135 * 136 * 137 */ 138 function fetch() 139 { 140 141 $sql = "SELECT rowid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix, domiciliation, proprio, adresse_proprio FROM ".MAIN_DB_PREFIX."societe_rib"; 142 $sql .= " WHERE fk_soc = ".$this->soc_id; 143 144 $result = $this->db->query($sql); 145 146 if ($result) 147 { 148 if ($this->db->num_rows()) 149 { 150 $obj = $this->db->fetch_object($result); 151 152 $this->bank = $obj->bank; 153 $this->courant = $obj->courant; 154 $this->clos = $obj->clos; 155 $this->code_banque = $obj->code_banque; 156 $this->code_guichet = $obj->code_guichet; 157 $this->number = $obj->number; 158 $this->cle_rib = $obj->cle_rib; 159 $this->bic = $obj->bic; 160 $this->iban_prefix = $obj->iban_prefix; 161 $this->domiciliation = $obj->domiciliation; 162 $this->proprio = $obj->proprio; 163 $this->adresse_proprio = $obj->adresse_proprio; 164 } 165 $this->db->free(); 166 } 167 else 168 { 169 dolibarr_print_error($this->db); 170 } 171 } 172 173 /* 174 * 175 * 176 */ 177 function error() 178 { 179 return $this->error; 180 } 181 182 /* 183 * 184 * 185 */ 186 function verif() 187 { 188 require_once DOL_DOCUMENT_ROOT . '/compta/bank/bank.lib.php'; 189 190 191 if (strlen(trim($this->code_banque)) == 0) 192 { 193 $this->error_number = 32; 194 $this->error_message = "Le code banque n'est pas renseigné"; 195 } 196 197 if (strlen(trim($this->code_guichet)) == 0) 198 { 199 $this->error_number = 33; 200 $this->error_message = "Le code guichet n'est pas renseigné"; 201 } 202 203 204 if (strlen(trim($this->number)) == 0) 205 { 206 $this->error_number = 34; 207 $this->error_message = "Le numéro de compte n'est pas renseigné"; 208 } 209 210 if (strlen(trim($this->cle_rib)) == 0) 211 { 212 $this->error_number = 35; 213 $this->error_message = "La clé n'est pas renseignée"; 214 } 215 216 if (strlen(trim($this->iban_prefix)) == 0) 217 { 218 $this->error_number = 36; 219 $this->error_message = "La cle IBAN n'est pas renseignée"; 220 } 221 222 223 if (! verif_rib($this->code_banque, $this->code_guichet, $this->number, $this->cle_rib, $this->iban_prefix)) 224 { 225 $this->error_number = 12; 226 $this->error_message = "Le RIB n'est pas valide"; 227 } 228 229 if ($this->error_number == 0) 230 { 231 return 1; 232 } 233 else 234 { 235 return 0; 236 } 237 } 238 } 239 240 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |