[ 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/ -> propal.php (source)

   1  <?php
   2  /* Copyright (C) 2004      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: propal.php,v 1.15.2.1 2006/01/28 19:00:42 hregis Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/stats/propal.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/product/stats/propal.php
  25          \ingroup    product, service, propal
  26          \brief      Page des stats des propals pour un produit
  27          \version    $Revision: 1.15.2.1 $
  28  */
  29  
  30  
  31  require ("./pre.inc.php");
  32  require_once (DOL_DOCUMENT_ROOT."/propal.class.php");
  33  require_once(DOL_DOCUMENT_ROOT."/product.class.php");
  34  
  35  $mesg = '';
  36  
  37  $page = $_GET["page"];
  38  $sortfield=$_GET["sortfield"];
  39  $sortorder=$_GET["sortorder"];
  40  if ($page == -1) { $page = 0 ; }
  41  $offset = $conf->liste_limit * $_GET["page"] ;
  42  $pageprev = $_GET["page"] - 1;
  43  $pagenext = $_GET["page"] + 1;
  44  if (! $sortorder) $sortorder="DESC";
  45  if (! $sortfield) $sortfield="p.datec";
  46  
  47  
  48  if ($user->societe_id > 0)
  49  {
  50    $action = '';
  51    $socid = $user->societe_id;
  52  }
  53  else
  54  {
  55    $socid = 0;
  56  }
  57  
  58  
  59  /*
  60   * Affiche fiche
  61   *
  62   */
  63  
  64  llxHeader();
  65  
  66  if ($_GET["id"])
  67  {
  68      $product = new Product($db);
  69      $result = $product->fetch($_GET["id"]);
  70  
  71      if ( $result > 0)
  72      {
  73          /*
  74           *  En mode visu
  75           */
  76          
  77          $h=0;
  78          
  79          $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
  80          $head[$h][1] = $langs->trans("Card");
  81          $h++;
  82          
  83          $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
  84          $head[$h][1] = $langs->trans("Price");
  85          $h++;
  86          
  87          if($product->type == 0)
  88          {
  89              if ($user->rights->barcode->lire)
  90              {
  91                  if ($conf->barcode->enabled)
  92                  {
  93                      $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id;
  94                      $head[$h][1] = $langs->trans("BarCode");
  95                      $h++;
  96                  }
  97              }
  98          }
  99          
 100          
 101          $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
 102          $head[$h][1] = $langs->trans("Photos");
 103          $h++;
 104          
 105          if($product->type == 0)
 106          {
 107              if ($conf->stock->enabled)
 108              {
 109                  $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
 110                  $head[$h][1] = $langs->trans("Stock");
 111                  $h++;
 112              }
 113          }
 114          
 115          if ($conf->fournisseur->enabled)
 116          {
 117              $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
 118              $head[$h][1] = $langs->trans("Suppliers");
 119              $h++;
 120          }
 121          
 122          $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
 123          $head[$h][1] = $langs->trans('Statistics');
 124          $h++;
 125          
 126          //erics: pour créer des produits composés de x 'sous' produits
 127          /*
 128          $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id;
 129          $head[$h][1] = $langs->trans('Packs');
 130          $h++;
 131          */
 132          
 133          $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
 134          $head[$h][1] = $langs->trans('Referers');
 135          $hselected=$h;
 136          $h++;
 137          
 138          $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id;
 139          $head[$h][1] = $langs->trans('Documents');
 140          $h++;
 141          
 142          $titre=$langs->trans("CardProduct".$product->type);
 143          dolibarr_fiche_head($head, $hselected, $titre);
 144  
 145  
 146          print '<table class="border" width="100%">';
 147  
 148          print '<tr>';
 149          print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="3">'.$product->ref.'</td>';
 150          print '</tr>';
 151          print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td>';
 152          print '</tr>';
 153          
 154          // Prix
 155          print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="3">'.price($product->price).'</td></tr>';
 156  
 157          // Statut
 158          print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
 159          if ($product->envente) print $langs->trans("OnSell");
 160          else print $langs->trans("NotOnSell");
 161          print '</td></tr>';
 162  
 163          print '<tr><td valign="top" width="25%">'.$langs->trans("Referers").'</td>';
 164          print '<td align="right" width="25%">'.$langs->trans("NbOfCustomers").'</td>';
 165          print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>';
 166          print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
 167          print '</tr>';
 168  
 169          // Propals
 170          if ($conf->propal->enabled)
 171          {
 172              $ret=$product->load_stats_propale($socid);
 173              if ($ret < 0) dolibarr_print_error($db);
 174              $langs->load("propal");
 175              print '<tr><td>';
 176              print '<a href="propal.php?id='.$product->id.'">'.$langs->trans("Proposals").'</a>';
 177              print '</td><td align="right">';
 178              print $product->stats_propale['customers'];
 179              print '</td><td align="right">';
 180              print $product->stats_propale['nb'];
 181              print '</td><td align="right">';
 182              print $product->stats_propale['qty'];
 183              print '</td>';
 184              print '</tr>';
 185          }
 186          // Commandes
 187          if ($conf->commande->enabled)
 188          {
 189              $ret=$product->load_stats_commande($socid);
 190              if ($ret < 0) dolibarr_print_error($db);
 191              $langs->load("orders");
 192              print '<tr><td>';
 193              print '<a href="commande.php?id='.$product->id.'">'.$langs->trans("Orders").'</a>';
 194              print '</td><td align="right">';
 195              print $product->stats_commande['customers'];
 196              print '</td><td align="right">';
 197              print $product->stats_commande['nb'];
 198              print '</td><td align="right">';
 199              print $product->stats_commande['qty'];
 200              print '</td>';
 201              print '</tr>';
 202          }
 203          // Contrats
 204          if ($conf->contrat->enabled)
 205          {
 206              $ret=$product->load_stats_contrat($socid);
 207              if ($ret < 0) dolibarr_print_error($db);
 208              $langs->load("contracts");
 209              print '<tr><td>';
 210              print '<a href="contrat.php?id='.$product->id.'">'.$langs->trans("Contracts").'</a>';
 211              print '</td><td align="right">';
 212              print $product->stats_contrat['customers'];
 213              print '</td><td align="right">';
 214              print $product->stats_contrat['nb'];
 215              print '</td><td align="right">';
 216              print $product->stats_contrat['qty'];
 217              print '</td>';
 218              print '</tr>';
 219          }
 220          // Factures
 221          if ($conf->facture->enabled)
 222          {
 223              $ret=$product->load_stats_facture($socid);
 224              if ($ret < 0) dolibarr_print_error($db);
 225              $langs->load("bills");
 226              print '<tr><td>';
 227              print '<a href="facture.php?id='.$product->id.'">'.$langs->trans("Bills").'</a>';
 228              print '</td><td align="right">';
 229              print $product->stats_facture['customers'];
 230              print '</td><td align="right">';
 231              print $product->stats_facture['nb'];
 232              print '</td><td align="right">';
 233              print $product->stats_facture['qty'];
 234              print '</td>';
 235              print '</tr>';
 236          }
 237          
 238          print "</table>";
 239  
 240          print '</div>';
 241  
 242  
 243          $sql = "SELECT distinct(s.nom), s.idp, p.rowid as propalid, p.ref, p.total as amount,";
 244          $sql.= $db->pdate("p.datec")." as date, p.fk_statut as statut";
 245          $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."propaldet as d";
 246          $sql.= " WHERE p.fk_soc = s.idp";
 247          $sql.= " AND d.fk_propal = p.rowid AND d.fk_product =".$product->id;
 248          if ($socid)
 249          {
 250              $sql .= " AND p.fk_soc = $socid";
 251          }
 252          $sql .= " ORDER BY $sortfield $sortorder ";
 253          $sql.= $db->plimit($conf->liste_limit +1, $offset);
 254  
 255          $result = $db->query($sql);
 256          if ($result)
 257          {
 258              $num = $db->num_rows($result);
 259  
 260              print_barre_liste($langs->trans("Proposals"),$page,$_SERVER["PHP_SELF"],"&amp;id=$product->id",$sortfield,$sortorder,'',$num);
 261  
 262              $i = 0;
 263              print "<table class=\"noborder\" width=\"100%\">";
 264              print '<tr class="liste_titre">';
 265              print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.rowid","","&amp;id=".$_GET["id"],'',$sortfield);
 266              print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&amp;id=".$_GET["id"],'',$sortfield);
 267              print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"p.datec","","&amp;id=".$_GET["id"],'align="center"',$sortfield);
 268              print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"p.total","","&amp;id=".$_GET["id"],'align="right"',$sortfield);
 269              print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.fk_statut","","&amp;id=".$_GET["id"],'align="center"',$sortfield);
 270              print "</tr>\n";
 271  
 272              if ($num > 0)
 273              {
 274                  $var=True;
 275                  while ($i < $num && $i < $conf->liste_limit)
 276                  {
 277                      $objp = $db->fetch_object($result);
 278                      $var=!$var;
 279  
 280                      print "<tr $bc[$var]>";
 281                      print '<td><a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$objp->propalid.'">'.img_object($langs->trans("ShowPropal"),"propal").' ';
 282                      print $objp->ref;
 283                      print "</a></td>\n";
 284                      print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).'</a></td>';
 285                      print "<td align=\"center\">";
 286                      print dolibarr_print_date($objp->date)."</td>";
 287                      print "<td align=\"right\">".price($objp->amount)."</td>\n";
 288                      $prop=new Propal($db);
 289                      print '<td align="center">'.$prop->LibStatut($objp->statut,1).'</td>';
 290                      print "</tr>\n";
 291                      $i++;
 292                  }
 293              }
 294          }
 295          else
 296          {
 297              dolibarr_print_error($db);
 298          }
 299          print "</table>";
 300          print '<br>';
 301          $db->free($result);
 302      }
 303  }
 304  else
 305  {
 306      dolibarr_print_error();
 307  }
 308  
 309  $db->close();
 310  
 311  llxFooter('$Date: 2006/01/28 19:00:42 $ - $Revision: 1.15.2.1 $');
 312  ?>


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