[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * $Id: cactioncomm.class.php,v 1.13 2005/07/10 02:05:09 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/cactioncomm.class.php,v $ 21 * 22 */ 23 24 /** 25 \file htdocs/cactioncomm.class.php 26 \ingroup commercial 27 \brief Fichier de la classe des types d'actions commerciales 28 \version $Revision: 1.13 $ 29 */ 30 31 32 /** \class CActioncomm 33 \brief Classe permettant la gestion des différents types d'actions commerciales 34 */ 35 36 class CActioncomm { 37 var $db; 38 39 var $id; 40 41 var $code; 42 var $type; 43 var $libelle; 44 var $active; 45 46 var $error; 47 48 var $type_actions=array(); 49 50 51 /** 52 * \brief Constructeur 53 * \param DB Handler d'accès base de donnée 54 */ 55 function CActioncomm($DB) 56 { 57 $this->db = $DB; 58 } 59 60 /** 61 * \brief Charge l'objet type d'action depuis la base 62 * \param id id du type d'action à récupérer 63 * \return int 1=ok, 0=aucune action, -1=erreur 64 */ 65 function fetch($id) 66 { 67 68 $sql = "SELECT code, type, libelle, active"; 69 $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; 70 $sql.= " WHERE id=$id"; 71 72 $resql=$this->db->query($sql); 73 if ($resql) 74 { 75 if ($this->db->num_rows($resql)) 76 { 77 $obj = $this->db->fetch_object($resql); 78 79 $this->id = $id; 80 $this->code = $obj->code; 81 $this->type = $obj->type; 82 $this->libelle = $obj->libelle; 83 $this->active = $obj->active; 84 85 return 1; 86 } 87 else 88 { 89 return 0; 90 } 91 92 $this->db->free($resql); 93 } 94 else 95 { 96 $this->error=$this->db->error(); 97 return -1; 98 } 99 } 100 101 /* 102 * \brief Renvoi la liste des types d'actions existant 103 * \param active 1 ou 0 pour un filtre sur l'etat actif ou non ('' par defaut = pas de filtre) 104 * \return array tableau des types d'actions actifs si ok, <0 si erreur 105 */ 106 function liste_array($active='') 107 { 108 global $langs; 109 $langs->load("commercial"); 110 111 $ga = array(); 112 113 $sql = "SELECT id, code, libelle"; 114 $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; 115 if ($active != '') { 116 $sql.=" WHERE active=$active"; 117 } 118 $sql .= " ORDER BY id"; 119 120 $resql=$this->db->query($sql); 121 if ($resql) 122 { 123 $nump = $this->db->num_rows($resql); 124 125 if ($nump) 126 { 127 $i = 0; 128 while ($i < $nump) 129 { 130 $obj = $this->db->fetch_object($resql); 131 132 $transcode=$langs->trans("Action".$obj->code); 133 $ga[$obj->id] = ($transcode!="Action".$obj->code?$transcode:$obj->libelle); 134 $i++; 135 } 136 } 137 $this->liste_array=$ga; 138 return $ga; 139 } 140 else 141 { 142 return -1; 143 } 144 } 145 146 147 /* 148 * \brief Renvoie le nom sous forme d'un libellé traduit d'un type d'action 149 * \param id id du type d'action 150 * \return string libelle du type d'action 151 */ 152 function get_nom($id) 153 { 154 global $langs; 155 156 if (! isset($this->type_actions[$id])) 157 { 158 // Si valeur non disponible en cache 159 $sql = 'SELECT code, libelle'; 160 $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm'; 161 $sql.= " WHERE id='".$id."'"; 162 163 $result = $this->db->query($sql); 164 if ($result) 165 { 166 if ($this->db->num_rows($result)) 167 { 168 $obj = $this->db->fetch_object($result); 169 170 $transcode=$langs->trans("Action".$obj->code); 171 $libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle); 172 173 $this->type_actions[$id]=$libelle; // Met en cache 174 return $libelle; 175 } 176 $this->db->free($result); 177 } 178 else { 179 dolibarr_print_error($db); 180 } 181 182 } 183 else { 184 // Si valeur disponible en cache 185 return $this->type_actions[$id]; 186 } 187 } 188 189 } 190 ?>
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 |
![]() |