[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/fourn/product/ -> fourn.php (source)

   1  <?php
   2  /* Copyright (C) 2005 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: fourn.php,v 1.4 2005/04/14 12:04:53 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/fourn/product/fourn.php,v $
  20   *
  21   */
  22  
  23  /*!
  24    \file       htdocs/fourn/product/fourn.php
  25    \ingroup    product
  26    \brief      Page de la fiche produit fournisseur
  27    \version    $Revision: 1.4 $
  28  */
  29  
  30  require ("./pre.inc.php");
  31  
  32  require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.product.class.php";
  33  
  34  if (!$user->rights->produit->lire) accessforbidden();
  35  
  36  if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
  37  {
  38  
  39    $product = new ProductFournisseur($db);
  40    $result = $product->fetch($_GET["id"], $_GET["id_fourn"]);
  41  
  42    if( $result == 0 )
  43      {
  44        $product->update($_POST["fourn_ref"], '1', $_POST["price"], $user);
  45      }
  46  
  47    Header('Location :fourn.php?id='.$product->id.'&id_fourn='.$_GET["id_fourn"]);
  48  }
  49  
  50  
  51  
  52  llxHeader("","",$langs->trans("CardProduct0"));
  53  
  54  /*
  55   * Fiche produit
  56   */
  57  if ($_GET["id"])
  58  {
  59    if ($_GET["action"] <> 're-edit')
  60      {
  61        $product = new ProductFournisseur($db);
  62        $result = $product->fetch($_GET["id"], $_GET["id_fourn"]);
  63  
  64        $product->get_buyprice(1);
  65      }
  66    
  67    if ( $result == 0)
  68      { 
  69        
  70        
  71        /*
  72         *  En mode visu
  73         */
  74        
  75        $h=0;
  76        
  77        $head[$h][0] = DOL_URL_ROOT."/fourn/product/fiche.php?id=".$product->id;
  78        $head[$h][1] = $langs->trans("ProductCard");
  79        $h++;
  80        
  81        $head[$h][0] = DOL_URL_ROOT."/fourn/product/fourn.php?id=".$product->id.'&amp;id_fourn='.$_GET["id_fourn"];
  82        $head[$h][1] = $langs->trans("SupplierCard");
  83        $hselected = $h;
  84        $h++;
  85        
  86        dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
  87        
  88        print '<table class="border" width="100%">';
  89        
  90        if ($conf->categorie->enabled)
  91      {          
  92        print '<tr id="ways">';
  93        print '<td colspan="3">';
  94        $cat = new Categorie ($db);
  95        $way = $cat->print_primary_way($product->id," &gt; ",'fourn/product/liste.php');
  96        if ($way == "")
  97          {
  98            print "Ce produit n'appartient à aucune catégorie";
  99          }
 100        else
 101          {
 102            print $langs->trans("Categorie")." : ";
 103            print $way;    
 104          }
 105        print '</td></tr>';
 106      }
 107  
 108        print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>';
 109        
 110        print '<tr><td width="20%">'.$langs->trans("InternalRef").'</td><td width="40%">'.$product->ref.'</td>';
 111  
 112        print '<td class="photo" valign="top" rowspan="6">';
 113        $product->show_photo($conf->produit->dir_output);
 114        print '</td></tr>';
 115  
 116        print "<tr>";
 117        print '<td width="20%">'.$langs->trans("Supplier").'</td><td width="40%">'.$product->fourn->nom_url.'</td>';
 118        print '</tr><tr>';
 119        print '<td width="20%">'.$langs->trans("SupplierRef").'</td><td width="40%">'.$product->fourn_ref.'</td>';
 120        print '</tr><tr>';
 121        print '<td width="20%">'.$langs->trans("BuiingPrice").'</td><td width="40%">'.price($product->buyprice).'</td>';
 122        print '</tr>';      
 123              
 124        print '<tr><td colspan="2">'.$langs->trans("Description").'</td></tr>';
 125        print '<tr><td valign="top" colspan="2">'.nl2br($product->description).'&nbsp;</td></tr>';
 126        
 127        print "</table><br>\n";
 128        
 129        print '<table class="border" width="100%">';
 130        print '<tr class="liste_titre"><td>';
 131        print $langs->trans("Date").'</td>';
 132        print '<td align="right">'.$langs->trans("Price").'</td>';
 133        print '<td align="center">'.$langs->trans("Quantity").'</td>';
 134        print '</tr>';
 135        
 136        /*
 137         * Prix
 138         */
 139        
 140        $sql = "SELECT p.price, p.quantity,".$db->pdate("tms") ." as date_releve";
 141        $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p";
 142        $sql .=" WHERE p.fk_soc = ".$product->fourn->id;
 143        $sql .= " AND p.fk_product = ".$product->id;
 144        $sql .= " ORDER BY p.quantity ASC";
 145        $resql= $db->query($sql) ;
 146        if ($resql)
 147      {
 148        $num_fournisseur = $db->num_rows($resql);
 149        $i = 0;
 150        $var=True;      
 151        while ($i < $num_fournisseur)
 152          {
 153            $objp = $db->fetch_object($resql);
 154            $var=!$var;
 155            print "<tr $bc[$var]>";
 156            print '<td>'.dolibarr_print_date($objp->date_releve).'</td>';
 157            print '<td align="right">'.price($objp->price).'</td>';
 158            print '<td align="center">'.$objp->quantity.'</td></tr>';
 159            
 160            $i++;
 161          }
 162        $db->free($resql);
 163      }
 164        print '</table>';
 165             
 166        /*
 167         *
 168         * Fiche en mode edition
 169         *
 170         */
 171        if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && $user->rights->produit->creer)
 172      {
 173  
 174        $action = 'fourn.php?id='.$product->id.'&amp;id_fourn='.$product->fourn->id;
 175  
 176        print '<form action="'.$action.'" method="post">';
 177        print '<input type="hidden" name="action" value="update">';
 178        print '<br /><table class="border" width="100%">';
 179        print '<tr><td width="20%">'.$langs->trans("Price").'</td>';
 180        print '<td><input name="price" size="20" value="'.$product->buyprice.'"></td></tr>';
 181  
 182        print '<tr><td>'.$langs->trans("SupplierRef").'</td>';
 183        print '<td><input name="fourn_ref" size="40" value="'.$product->fourn_ref.'"></td></tr>';
 184  
 185        print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
 186        print '<textarea name="desc" rows="8" cols="50">';
 187        print $product->description;
 188        print "</textarea></td></tr>";
 189  
 190        print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;';
 191        print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
 192        print '</table>';
 193        print '</form>';
 194      }
 195  
 196        print "</div>\n";
 197        /* ************************************************************************** */
 198        /*                                                                            */ 
 199        /* Barre d'action                                                             */ 
 200        /*                                                                            */ 
 201        /* ************************************************************************** */
 202        
 203        print "\n<div class=\"tabsAction\">\n";
 204        
 205        if ($_GET["action"] == '')
 206      {
 207        
 208        if ( $user->rights->produit->creer)
 209          {
 210            print '<a class="tabAction" href="fourn.php?action=edit&amp;id='.$product->id.'&amp;id_fourn='.$product->fourn->id.'">'.$langs->trans("Edit").'</a>';
 211          }
 212      }
 213        
 214        print "\n</div>\n";
 215        
 216      }  
 217  }
 218  else
 219  {
 220    print $langs->trans("ErrorUnknown");
 221  }
 222  $db->close();
 223  
 224  llxFooter("<em>Derni&egrave;re modification $Date: 2005/04/14 12:04:53 $ r&eacute;vision $Revision: 1.4 $</em>");
 225  ?>
 226      


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics