[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> 5 * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 * 21 * $Id: price.php,v 1.29 2005/12/03 18:13:25 eldy Exp $ 22 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/price.php,v $ 23 */ 24 25 /** 26 \file htdocs/product/price.php 27 \ingroup product 28 \brief Page de la fiche produit 29 \version $Revision: 1.29 $ 30 */ 31 32 require ("./pre.inc.php"); 33 require_once(DOL_DOCUMENT_ROOT."/product.class.php"); 34 35 $langs->load("products"); 36 $langs->load("bills"); 37 38 $user->getrights('produit'); 39 40 if (!$user->rights->produit->lire) 41 accessforbidden(); 42 43 44 $types[0] = $langs->trans("Product"); 45 $types[1] = $langs->trans("Service"); 46 47 48 /* 49 * Actions 50 */ 51 52 if ($_POST["action"] == 'update_price' && 53 $_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->produit->creer) 54 { 55 $product = new Product($db); 56 57 $result = $product->fetch($_GET["id"]); 58 59 $product->price = ereg_replace(" ","",$_POST["price"]); 60 61 if ( $product->update_price($product->id, $user) > 0 ) 62 63 { 64 $_GET["action"] = ''; 65 $mesg = 'Fiche mise à jour'; 66 } 67 else 68 { 69 $_GET["action"] = 'edit_price'; 70 $mesg = 'Fiche non mise à jour !' . "<br>" . $product->mesg_error; 71 } 72 } 73 74 75 76 /* 77 * Affiche historique prix 78 */ 79 80 llxHeader("","",$langs->trans("Price")); 81 82 $product = new Product($db); 83 if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); 84 if ($_GET["id"]) $result = $product->fetch($_GET["id"]); 85 86 87 $h=0; 88 89 $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; 90 $head[$h][1] = $langs->trans("Card"); 91 $h++; 92 93 $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; 94 $head[$h][1] = $langs->trans("Price"); 95 $hselected=$h; 96 $h++; 97 98 if($product->type == 0) 99 { 100 if ($user->rights->barcode->lire) 101 { 102 if ($conf->barcode->enabled) 103 { 104 $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; 105 $head[$h][1] = $langs->trans("BarCode"); 106 $h++; 107 } 108 } 109 } 110 111 $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; 112 $head[$h][1] = $langs->trans("Photos"); 113 $h++; 114 115 if($product->type == 0) 116 { 117 if ($conf->stock->enabled) 118 { 119 $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; 120 $head[$h][1] = $langs->trans("Stock"); 121 $h++; 122 } 123 } 124 125 if ($conf->fournisseur->enabled) { 126 $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; 127 $head[$h][1] = $langs->trans("Suppliers"); 128 $h++; 129 } 130 131 $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; 132 $head[$h][1] = $langs->trans("Statistics"); 133 $h++; 134 135 //erics: pour créer des produits composés de x 'sous' produits 136 /* 137 $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id; 138 $head[$h][1] = $langs->trans('Packs'); 139 $h++; 140 */ 141 142 $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; 143 $head[$h][1] = $langs->trans("Referers"); 144 $h++; 145 146 $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id; 147 $head[$h][1] = $langs->trans('Documents'); 148 $h++; 149 150 $titre=$langs->trans("CardProduct".$product->type); 151 dolibarr_fiche_head($head, $hselected, $titre); 152 153 print '<table class="border" width="100%">'; 154 155 // Reference 156 print '<tr>'; 157 print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">'; 158 $product->load_previous_next_ref(); 159 $previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':''; 160 $next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':''; 161 if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">'; 162 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>'; 163 if ($previous_ref || $next_ref) print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table>'; 164 print '</td>'; 165 print '</tr>'; 166 167 // Libelle 168 print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>'; 169 print '</tr>'; 170 171 // Prix 172 print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>'; 173 174 // Statut 175 print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'; 176 if ($product->envente) print $langs->trans("OnSell"); 177 else print $langs->trans("NotOnSell"); 178 print '</td></tr>'; 179 180 print "</table>\n"; 181 182 print "</div>\n"; 183 184 185 186 /* ************************************************************************** */ 187 /* */ 188 /* Barre d'action */ 189 /* */ 190 /* ************************************************************************** */ 191 192 print "\n<div class=\"tabsAction\">\n"; 193 194 if ($_GET["action"] == '') 195 { 196 if ($user->rights->produit->modifier || $user->rights->produit->creer) 197 { 198 print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/price.php?action=edit_price&id='.$product->id.'">'.$langs->trans("UpdatePrice").'</a>'; 199 } 200 } 201 202 print "\n</div>\n"; 203 204 205 /* 206 * Edition du prix 207 */ 208 if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer) 209 { 210 print_fiche_titre($langs->trans("NewPrice")); 211 212 print '<form action="price.php?id='.$product->id.'" method="post">'; 213 print '<input type="hidden" name="action" value="update_price">'; 214 print '<input type="hidden" name="id" value="'.$product->id.'">'; 215 print '<table class="border" width="100%">'; 216 print '<tr><td width="15%">'.$langs->trans('SellingPrice').'</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>'; 217 print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> '; 218 print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; 219 print '</table>'; 220 print '</form>'; 221 } 222 223 224 // Liste des evolutions du prix 225 $sql = "SELECT p.rowid, p.price, ".$db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login"; 226 $sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u"; 227 $sql .= " WHERE fk_product = ".$product->id; 228 $sql .= " AND p.fk_user_author = u.rowid "; 229 $sql .= " ORDER BY p.date_price DESC "; 230 $sql .= $db->plimit(); 231 $result = $db->query($sql) ; 232 233 if ($result) 234 { 235 $num = $db->num_rows($result); 236 237 if (! $num) 238 { 239 $db->free($result) ; 240 241 // Il doit au moins y avoir la ligne de prix initial. 242 // On l'ajoute donc pour remettre à niveau (pb vieilles versions) 243 $product->update_price($product->id, $user); 244 245 $result = $db->query($sql) ; 246 $num = $db->num_rows($result); 247 } 248 249 if ($num > 0) 250 { 251 print '<br>'; 252 253 print '<table class="noborder" width="100%">'; 254 255 print '<tr class="liste_titre">'; 256 print '<td>'.$langs->trans("AppliedPricesFrom").'</td>'; 257 print '<td>'.$langs->trans("Price").'</td>'; 258 print '<td>'.$langs->trans("ChangedBy").'</td>'; 259 print '</tr>'; 260 261 $var=True; 262 $i = 0; 263 while ($i < $num) 264 { 265 $objp = $db->fetch_object($result); 266 $var=!$var; 267 print "<tr $bc[$var]>"; 268 269 // Date 270 print "<td>".dolibarr_print_date($objp->dp,"%d %b %Y %H:%M:%S")."</td>"; 271 272 // Prix 273 print "<td>".price($objp->price)."</td>"; 274 275 // User 276 print '<td><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objp->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'</a></td>'; 277 print "</tr>\n"; 278 $i++; 279 } 280 $db->free($result); 281 print "</table>"; 282 print "<br>"; 283 } 284 } 285 else 286 { 287 dolibarr_print_error($db); 288 } 289 290 291 $db->close(); 292 293 llxFooter('$Date: 2005/12/03 18:13:25 $ - $Revision: 1.29 $'); 294 ?>
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 |
![]() |