[ 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/product/stats/ -> commande.php (source)

   1  <?php
   2  /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   * Copyright (C) 2005      Regis Houssin        <regis.houssin@cap-networks.com>
   5   *
   6   * This program is free software; you can redistribute it and/or modify
   7   * it under the terms of the GNU General Public License as published by
   8   * the Free Software Foundation; either version 2 of the License, or
   9   * (at your option) any later version.
  10   *
  11   * This program is distributed in the hope that it will be useful,
  12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14   * GNU General Public License for more details.
  15   *
  16   * You should have received a copy of the GNU General Public License
  17   * along with this program; if not, write to the Free Software
  18   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19   *
  20   * $Id: commande.php,v 1.5 2005/12/07 23:41:26 eldy Exp $
  21   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/stats/commande.php,v $
  22   */
  23  
  24  /**
  25          \file       htdocs/product/stats/commande.php
  26          \ingroup    product, service, commande
  27          \brief      Page des stats des commandes pour un produit
  28          \version    $Revision: 1.5 $
  29  */
  30  
  31  
  32  require ("./pre.inc.php");
  33  require_once (DOL_DOCUMENT_ROOT."/commande/commande.class.php");
  34  require_once(DOL_DOCUMENT_ROOT."/product.class.php");
  35  
  36  $langs->load("orders");
  37  
  38  $mesg = '';
  39  
  40  $page = $_GET["page"];
  41  $sortfield=$_GET["sortfield"];
  42  $sortorder=$_GET["sortorder"];
  43  if ($page == -1) { $page = 0 ; }
  44  $offset = $conf->liste_limit * $_GET["page"] ;
  45  $pageprev = $_GET["page"] - 1;
  46  $pagenext = $_GET["page"] + 1;
  47  if (! $sortorder) $sortorder="DESC";
  48  if (! $sortfield) $sortfield="c.date_creation";
  49  
  50  
  51  if ($user->societe_id > 0)
  52  {
  53      $action = '';
  54      $socid = $user->societe_id;
  55  }
  56  else
  57  {
  58    $socid = 0;
  59  }
  60  
  61  
  62  /*
  63   * Affiche fiche
  64   *
  65   */
  66  
  67  llxHeader();
  68  
  69  
  70  if ($_GET["id"])
  71  {
  72      $product = new Product($db);
  73      $result = $product->fetch($_GET["id"]);
  74  
  75      if ($result > 0)
  76      {
  77          /*
  78           *  En mode visu
  79           */
  80  
  81          $h=0;
  82  
  83          $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
  84          $head[$h][1] = $langs->trans("Card");
  85          $h++;
  86  
  87          $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
  88          $head[$h][1] = $langs->trans("Price");
  89          $h++;
  90  
  91          if($product->type == 0)
  92          {
  93              if ($user->rights->barcode->lire)
  94              {
  95                  if ($conf->barcode->enabled)
  96                  {
  97                      $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id;
  98                      $head[$h][1] = $langs->trans("BarCode");
  99                      $h++;
 100                  }
 101              }
 102          }
 103  
 104  
 105          $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
 106          $head[$h][1] = $langs->trans("Photos");
 107          $h++;
 108  
 109          if($product->type == 0)
 110          {
 111              if ($conf->stock->enabled)
 112              {
 113                  $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
 114                  $head[$h][1] = $langs->trans("Stock");
 115                  $h++;
 116              }
 117          }
 118  
 119          if ($conf->fournisseur->enabled)
 120          {
 121              $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
 122              $head[$h][1] = $langs->trans("Suppliers");
 123              $h++;
 124          }
 125  
 126          $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
 127          $head[$h][1] = $langs->trans('Statistics');
 128          $h++;
 129  
 130          //erics: pour créer des produits composés de x 'sous' produits
 131          /*
 132          $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id;
 133          $head[$h][1] = $langs->trans('Packs');
 134          $h++;
 135          */
 136          
 137          $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
 138          $head[$h][1] = $langs->trans('Referers');
 139          $hselected=$h;
 140          $h++;
 141  
 142          $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id;
 143          $head[$h][1] = $langs->trans('Documents');
 144          $h++;
 145  
 146          $titre=$langs->trans("CardProduct".$product->type);
 147          dolibarr_fiche_head($head, $hselected, $titre);
 148  
 149  
 150          print '<table class="border" width="100%">';
 151  
 152          print '<tr>';
 153          print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="3">'.$product->ref.'</td>';
 154          print '</tr>';
 155          print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td>';
 156          print '</tr>';
 157          
 158          // Prix
 159          print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="3">'.price($product->price).'</td></tr>';
 160          
 161          // Statut
 162          print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
 163          if ($product->envente) print $langs->trans("OnSell");
 164          else print $langs->trans("NotOnSell");
 165          print '</td></tr>';
 166  
 167          print '<tr><td valign="top" width="25%">'.$langs->trans("Referers").'</td>';
 168          print '<td align="right" width="25%">'.$langs->trans("NbOfCustomers").'</td>';
 169          print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>';
 170          print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
 171          print '</tr>';
 172  
 173          // Propals
 174          if ($conf->propal->enabled)
 175          {
 176              $ret=$product->load_stats_propale($socid);
 177              if ($ret < 0) dolibarr_print_error($db);
 178              $langs->load("propal");
 179              print '<tr><td>';
 180              print '<a href="propal.php?id='.$product->id.'">'.$langs->trans("Proposals").'</a>';
 181              print '</td><td align="right">';
 182              print $product->stats_propale['customers'];
 183              print '</td><td align="right">';
 184              print $product->stats_propale['nb'];
 185              print '</td><td align="right">';
 186              print $product->stats_propale['qty'];
 187              print '</td>';
 188              print '</tr>';
 189          }
 190          // Commandes
 191          if ($conf->commande->enabled)
 192          {
 193              $ret=$product->load_stats_commande($socid);
 194              if ($ret < 0) dolibarr_print_error($db);
 195              $langs->load("orders");
 196              print '<tr><td>';
 197              print '<a href="commande.php?id='.$product->id.'">'.$langs->trans("Orders").'</a>';
 198              print '</td><td align="right">';
 199              print $product->stats_commande['customers'];
 200              print '</td><td align="right">';
 201              print $product->stats_commande['nb'];
 202              print '</td><td align="right">';
 203              print $product->stats_commande['qty'];
 204              print '</td>';
 205              print '</tr>';
 206          }
 207          // Contrats
 208          if ($conf->contrat->enabled)
 209          {
 210              $ret=$product->load_stats_contrat($socid);
 211              if ($ret < 0) dolibarr_print_error($db);
 212              $langs->load("contracts");
 213              print '<tr><td>';
 214              print '<a href="contrat.php?id='.$product->id.'">'.$langs->trans("Contracts").'</a>';
 215              print '</td><td align="right">';
 216              print $product->stats_contrat['customers'];
 217              print '</td><td align="right">';
 218              print $product->stats_contrat['nb'];
 219              print '</td><td align="right">';
 220              print $product->stats_contrat['qty'];
 221              print '</td>';
 222              print '</tr>';
 223          }
 224          // Factures
 225          if ($conf->facture->enabled)
 226          {
 227              $ret=$product->load_stats_facture($socid);
 228              if ($ret < 0) dolibarr_print_error($db);
 229              $langs->load("bills");
 230              print '<tr><td>';
 231              print '<a href="facture.php?id='.$product->id.'">'.$langs->trans("Bills").'</a>';
 232              print '</td><td align="right">';
 233              print $product->stats_facture['customers'];
 234              print '</td><td align="right">';
 235              print $product->stats_facture['nb'];
 236              print '</td><td align="right">';
 237              print $product->stats_facture['qty'];
 238              print '</td>';
 239              print '</tr>';
 240          }
 241          
 242          print "</table>";
 243  
 244          print '</div>';
 245          
 246  
 247          $sql = "SELECT distinct(s.nom), s.idp, s.code_client, c.rowid, c.total_ht as amount,";
 248          $sql.= " ".$db->pdate("c.date_creation")." as date, c.fk_statut as statut, c.rowid as commandeid";
 249          $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."commandedet as d";
 250          $sql.= " WHERE c.fk_soc = s.idp";
 251          $sql.= " AND d.fk_commande = c.rowid AND d.fk_product =".$product->id;
 252          if ($socid)
 253          {
 254              $sql .= " AND c.fk_soc = $socid";
 255          }
 256          $sql.= " ORDER BY $sortfield $sortorder ";
 257          $sql.= $db->plimit($conf->liste_limit +1, $offset);
 258  
 259          $result = $db->query($sql);
 260          if ($result)
 261          {
 262              $num = $db->num_rows($result);
 263  
 264              print_barre_liste($langs->trans("Orders"),$page,$_SERVER["PHP_SELF"],"&amp;id=$product->id",$sortfield,$sortorder,'',$num);
 265  
 266              $i = 0;
 267              print "<table class=\"noborder\" width=\"100%\">";
 268  
 269              print '<tr class="liste_titre">';
 270              print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid","","&amp;id=".$_GET["id"],'',$sortfield);
 271              print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&amp;id=".$_GET["id"],'',$sortfield);
 272              print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&amp;id=".$_GET["id"],'',$sortfield);
 273              print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"c.date_creation","","&amp;id=".$_GET["id"],'align="center"',$sortfield);
 274              print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.amount_ht","","&amp;id=".$_GET["id"],'align="right"',$sortfield);
 275              print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&amp;id=".$_GET["id"],'align="center"',$sortfield);
 276              print "</tr>\n";
 277  
 278              if ($num > 0)
 279              {
 280                  $var=True;
 281                  while ($i < $num && $i < $conf->liste_limit)
 282                  {
 283                      $objp = $db->fetch_object($result);
 284                      $var=!$var;
 285  
 286                      print "<tr $bc[$var]>";
 287                      print '<td><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$objp->commandeid.'">'.img_object($langs->trans("ShowOrder"),"order").' ';
 288                      print $objp->rowid;
 289                      print "</a></td>\n";
 290                      print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).'</a></td>';
 291                      print "<td>".$objp->code_client."</td>\n";
 292                      print "<td align=\"center\">";
 293                      print dolibarr_print_date($objp->date)."</td>";
 294                      print "<td align=\"right\">".price($objp->amount)."</td>\n";
 295                      $fac=new Commande($db);
 296                      print '<td align="center">'.$fac->LibStatut($objp->statut,1).'</td>';
 297                      print "</tr>\n";
 298                      $i++;
 299                  }
 300              }
 301          }
 302          else
 303          {
 304              dolibarr_print_error($db);
 305          }
 306          print "</table>";
 307          print '<br>';
 308          $db->free($result);
 309      }
 310  }
 311  else
 312  {
 313      dolibarr_print_error();
 314  }
 315  
 316  $db->close();
 317  
 318  llxFooter('$Date: 2005/12/07 23:41:26 $ - $Revision: 1.5 $');
 319  ?>


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