[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2005 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: liste.php,v 1.12 2005/08/15 16:24:26 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/fourn/product/liste.php,v $ 21 * 22 */ 23 24 /** 25 \file htdocs/fourn/product/liste.php 26 \ingroup produit 27 \brief Page liste des produits ou services 28 \version $Revision: 1.12 $ 29 */ 30 31 require ("./pre.inc.php"); 32 33 $langs->load("products"); 34 35 $user->getrights('produit'); 36 37 if (!$user->rights->produit->lire) accessforbidden(); 38 39 $sref=isset($_GET["sref"])?$_GET["sref"]:$_POST["sref"]; 40 $snom=isset($_GET["snom"])?$_GET["snom"]:$_POST["snom"]; 41 42 $type=isset($_GET["type"])?$_GET["type"]:$_POST["type"]; 43 44 $sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; 45 $sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; 46 $page = $_GET["page"]; 47 if ($page < 0) { 48 $page = 0 ; } 49 50 $limit = $conf->liste_limit; 51 $offset = $limit * $page ; 52 53 if (! $sortfield) $sortfield="p.ref"; 54 if (! $sortorder) $sortorder="DESC"; 55 56 if ($_POST["button_removefilter"] == $langs->trans("RemoveFilter")) { 57 $sref=""; 58 $snom=""; 59 } 60 61 if ($_GET["fourn_id"] > 0) 62 { 63 $fourn_id = $_GET["fourn_id"]; 64 } 65 66 if (isset($_REQUEST['catid'])) 67 { 68 $catid = $_REQUEST['catid']; 69 } 70 71 /* 72 * Mode Liste 73 * 74 */ 75 76 $title=$langs->trans("ProductsAndServices"); 77 78 $sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type"; 79 $sql .= ", pf.fk_soc"; 80 $sql .= ", min(ppf.price) as price"; 81 $sql .= ", s.nom"; 82 $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; 83 84 if ($catid) 85 { 86 $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; 87 } 88 89 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product"; 90 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.idp = pf.fk_soc"; 91 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON ppf.fk_soc = pf.fk_soc AND ppf.fk_product = p.rowid AND ppf.quantity = 1"; 92 93 if ($_POST["mode"] == 'search') 94 { 95 $sql .= " WHERE p.ref like '%".$_POST["sall"]."%'"; 96 $sql .= " OR p.label like '%".$_POST["sall"]."%'"; 97 } 98 else 99 { 100 $sql .= " WHERE 1=1"; 101 if (isset($_GET["type"]) || isset($_POST["type"])) 102 { 103 $sql .= " AND p.fk_product_type = ".(isset($_GET["type"])?$_GET["type"]:$_POST["type"]); 104 } 105 if ($sref) 106 { 107 $sql .= " AND p.ref like '%".$sref."%'"; 108 } 109 if ($snom) 110 { 111 $sql .= " AND p.label like '%".$snom."%'"; 112 } 113 if($catid) 114 { 115 $sql .= " AND cp.fk_product = p.rowid"; 116 $sql .= " AND cp.fk_categorie = ".$catid; 117 } 118 119 } 120 121 if ($fourn_id > 0) 122 { 123 $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = $fourn_id"; 124 } 125 $sql .= " GROUP BY p.rowid"; 126 $sql .= " ORDER BY $sortfield $sortorder "; 127 $sql .= $db->plimit($limit + 1 ,$offset); 128 129 $resql = $db->query($sql) ; 130 if ($resql) 131 { 132 $num = $db->num_rows($resql); 133 134 $i = 0; 135 136 if ($num == 1 && (isset($_POST["sall"]) or $snom or $sref)) 137 { 138 $objp = $db->fetch_object($resql); 139 Header("Location: fiche.php?id=$objp->rowid"); 140 } 141 142 $texte = $langs->trans("List"); 143 144 145 146 llxHeader("","",$texte); 147 148 if ($sref || $snom || $_POST["sall"] || $_POST["search"]) 149 { 150 print_barre_liste($texte, $page, "liste.php", "&sref=".$sref."&snom=".$snom, $sortfield, $sortorder,'',$num); 151 } 152 else 153 { 154 print_barre_liste($texte, $page, "liste.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num); 155 } 156 157 158 if (isset($catid)) 159 { 160 print "<div id='ways'>"; 161 $c = new Categorie ($db, $catid); 162 $ways = $c->print_all_ways(' > ','fourn/product/liste.php'); 163 print " > ".$ways[0]."<br />\n"; 164 print "</div><br />"; 165 } 166 167 168 print '<table class="liste" width="100%">'; 169 170 // Lignes des titres 171 print "<tr class=\"liste_titre\">"; 172 print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&envente=$envente".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield); 173 print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield); 174 print_liste_field_titre($langs->trans("Supplier"),"liste.php", "pf.fk_soc","","","",$sortfield); 175 print_liste_field_titre($langs->trans("BuyingPrice"),"liste.php", "ppf.price","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield); 176 print "</tr>\n"; 177 178 // Lignes des champs de filtre 179 print '<form action="liste.php" method="post">'; 180 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; 181 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; 182 print '<input type="hidden" name="type" value="'.$type.'">'; 183 print '<tr class="liste_titre">'; 184 print '<td class="liste_titre">'; 185 print '<input class="flat" type="text" name="sref" value="'.$sref.'">'; 186 print '</td>'; 187 print '<td class="liste_titre" valign="right">'; 188 print '<input class="flat" type="text" name="snom" value="'.$snom.'">'; 189 print '</td>'; 190 print '<td class="liste_titre" colspan="2" align="right">'; 191 print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">'; 192 print ' <input type="image" class="liste_titre" name="button_removefilter" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" alt="'.$langs->trans("RemoveFilter").'">'; 193 print '</td>'; 194 print '</tr>'; 195 print '</form>'; 196 197 $oldid = ''; 198 $var=True; 199 while ($i < min($num,$limit)) 200 { 201 $objp = $db->fetch_object( $i); 202 $var=!$var; 203 print "<tr $bc[$var]>"; 204 205 if ($oldid <> $objp->rowid) 206 { 207 $oldid = $objp->rowid; 208 print "<td><a href=\"../../product/fiche.php?id=$objp->rowid\">"; 209 if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service"); 210 else print img_object($langs->trans("ShowProduct"),"product"); 211 print "</a> "; 212 print "<a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></td>\n"; 213 print "<td>$objp->label</td>\n"; 214 } 215 else 216 { 217 print '<td colspan="2"> </td>'; 218 } 219 220 print '<td>'.$objp->nom.'</td>'; 221 print '<td align="right">'.price($objp->price).'</td>'; 222 print "</tr>\n"; 223 $i++; 224 } 225 $db->free($resql); 226 227 print "</table>"; 228 229 230 } 231 else 232 { 233 dolibarr_print_error($db); 234 } 235 236 237 $db->close(); 238 239 llxFooter("<em>Dernière modification $Date: 2005/08/15 16:24:26 $ révision $Revision: 1.12 $</em>"); 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 |
![]() |