[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2003 Éric Seigne <erics@rycks.com> 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: groupart.class.php,v 1.10 2005/07/09 14:34:44 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/groupart/groupart.class.php,v $ 21 * 22 */ 23 24 class Groupart { 25 var $db ; 26 27 var $id ; 28 var $nom ; 29 var $desc ; 30 var $grar ; 31 32 function Groupart($DB, $id=0) { 33 $this->db = $DB; 34 $this->id = $id ; 35 } 36 /* 37 * 38 * 39 * 40 */ 41 function create($user) { 42 43 $sql = "INSERT INTO ".MAIN_DB_PREFIX."groupart (fk_user_author) VALUES (".$user->id.")"; 44 45 if ($this->db->query($sql) ) 46 47 { 48 49 $id = $this->db->last_insert_id(MAIN_DB_PREFIX."groupart"); 50 51 if ( $this->update($id, $user) ) 52 { 53 return $id; 54 } 55 } 56 else 57 { 58 print $this->db->error() . ' in ' . $sql; 59 } 60 } 61 62 /* 63 * 64 * 65 * 66 */ 67 function update($id, $user) 68 { 69 70 $sql = "UPDATE ".MAIN_DB_PREFIX."groupart "; 71 $sql .= " SET nom = '" . trim($this->nom) ."'"; 72 $sql .= " , description = '" . trim($this->desc) ."'"; 73 $sql .= " , groupart = '" . trim($this->grar) ."'"; 74 $sql .= " WHERE rowid = " . $id; 75 76 if ( $this->db->query($sql) ) { 77 return 1; 78 } else { 79 print $this->db->error() . ' in ' . $sql; 80 } 81 } 82 /* 83 * 84 * 85 * 86 */ 87 function fetch ($id) { 88 89 $sql = "SELECT rowid, nom, groupart, description FROM ".MAIN_DB_PREFIX."groupart WHERE rowid = $id"; 90 91 $result = $this->db->query($sql) ; 92 93 if ( $result ) { 94 $result = $this->db->fetch_array(); 95 96 $this->id = $result["rowid"]; 97 $this->nom = $result["nom"]; 98 $this->desc = $result["description"]; 99 $this->grar = $result["groupart"]; 100 101 $this->nom_url = '<a href="'.DOL_URL_ROOT.'/product/groupart/fiche.php?id='.$result["rowid"].'">'.$result["nom"].'</a>'; 102 103 } 104 $this->db->free(); 105 106 return $result; 107 } 108 /* 109 * 110 * 111 */ 112 function liste_albums () 113 { 114 $ga = array(); 115 116 $sql = "SELECT a.rowid, a.title FROM ".MAIN_DB_PREFIX."album as a, ".MAIN_DB_PREFIX."album_to_groupart as l"; 117 $sql .= " WHERE a.rowid = l.fk_album AND l.fk_groupart = ".$this->id; 118 $sql .= " ORDER BY a.title"; 119 120 $result=$this->db->query($sql); 121 if ($result) 122 { 123 $nump = $this->db->num_rows($result); 124 125 if ($nump) 126 { 127 $i = 0; 128 while ($i < $nump) 129 { 130 $obj = $this->db->fetch_object($result); 131 132 $ga[$obj->rowid] = $obj->title; 133 $i++; 134 } 135 } 136 return $ga; 137 } 138 else 139 { 140 print $this->db->error(); 141 return -1; 142 } 143 } 144 /* 145 * 146 * 147 */ 148 function updateosc() 149 { 150 $albs = array(); 151 $albs = $this->liste_albums(); 152 153 foreach($albs as $key => $value) 154 { 155 $alb = new Album($this->db); 156 $alb->fetch($key); 157 $alb->updateosc(); 158 } 159 } 160 /* 161 * 162 * 163 */ 164 function liste_array () 165 { 166 $ga = array(); 167 168 $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."groupart ORDER BY nom"; 169 170 $result=$this->db->query($sql); 171 if ($result) 172 { 173 $nump = $this->db->num_rows($result); 174 175 if ($nump) 176 { 177 $i = 0; 178 while ($i < $nump) 179 { 180 $obj = $this->db->fetch_object($result); 181 182 $ga[$obj->rowid] = $obj->nom; 183 $i++; 184 } 185 } 186 return $ga; 187 } 188 else 189 { 190 print $this->db->error(); 191 return -1; 192 } 193 194 } 195 196 197 198 199 /* 200 * 201 * 202 */ 203 function delete($user) { 204 205 $sql = "DELETE FROM ".OSC_DB_NAME.".products WHERE products_id = $idosc "; 206 207 $sql = "DELETE FROM ".OSC_DB_NAME.".products_to_categories WHERE products_id = $idosc"; 208 209 $sql = "DELETE FROM ".OSC_DB_NAME.".products_description WHERE products_id = $idosc"; 210 211 $sql = "DELETE FROM ".MAIN_DB_PREFIX."album WHERE rowid = $id"; 212 213 214 } 215 216 217 } 218 ?>
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 |
![]() |