[ 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 * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com> 5 * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.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: fiche.php,v 1.53 2005/12/03 03:54:15 eldy Exp $ 22 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/stats/fiche.php,v $ 23 */ 24 25 /** 26 \file htdocs/product/stats/fiche.php 27 \ingroup product 28 \brief Page des stats produits 29 \version $Revision: 1.53 $ 30 */ 31 32 require ("./pre.inc.php"); 33 require_once (DOL_DOCUMENT_ROOT."/propal.class.php"); 34 require_once(DOL_DOCUMENT_ROOT."/product.class.php"); 35 36 $langs->load("products"); 37 $langs->load("bills"); 38 39 $types[0] = $langs->trans("Product"); 40 $types[1] = $langs->trans("Service"); 41 42 if ($user->societe_id > 0) 43 { 44 $action = ''; 45 $socid = $user->societe_id; 46 } 47 else 48 { 49 $socid = 0; 50 } 51 52 53 llxHeader('',$langs->trans("Statistics")); 54 55 $mesg = ''; 56 57 58 /* 59 * 60 */ 61 if ($_GET["id"] || $_GET["ref"]) 62 { 63 $product = new Product($db); 64 if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); 65 if ($_GET["id"]) $result = $product->fetch($_GET["id"]); 66 67 if ($result) 68 { 69 // Efface rep obsolete 70 if(is_dir(DOL_DOCUMENT_ROOT."/document/produits")) 71 rmdir(DOL_DOCUMENT_ROOT."/document/produits"); 72 73 // Création répertoire pour images générées 74 // $conf->produit->dir_images définit dans master.inc.php 75 76 $dir = $conf->produit->dir_images."/".$product->id; 77 78 if (! file_exists($dir)) 79 { 80 if (create_exdir($dir) < 0) 81 { 82 $mesg = $langs->trans("ErrorCanNotCreateDir",$dir); 83 } 84 } 85 86 $img_propal_name = "propal12mois.png"; 87 $filenbpropal = $dir . "/" . $img_propal_name; 88 $filenbvente = $dir . "/vente12mois.png"; 89 $filenbpiece = $dir . "/vendu12mois.png"; 90 91 $WIDTH=380; 92 $HEIGHT=200; 93 94 $px = new BarGraph(); 95 $mesg = $px->isGraphKo(); 96 if (! $mesg) 97 { 98 $graph_data = $product->get_num_vente($socid); 99 $px->SetData($graph_data); 100 $px->SetMaxValue($px->GetMaxValue()); 101 $px->SetWidth($WIDTH); 102 $px->SetHeight($HEIGHT); 103 $px->draw($filenbvente); 104 105 $px = new BarGraph(); 106 $graph_data = $product->get_nb_vente($socid); 107 $px->SetData($graph_data); 108 $px->SetMaxValue($px->GetMaxValue()); 109 $px->SetWidth($WIDTH); 110 $px->SetHeight($HEIGHT); 111 $px->draw($filenbpiece); 112 113 $px = new BarGraph(); 114 $graph_data = $product->get_num_propal($socid); 115 $px->SetData($graph_data); 116 $px->SetMaxValue($px->GetMaxValue()); 117 $px->SetWidth($WIDTH); 118 $px->SetHeight($HEIGHT); 119 $px->draw($filenbpropal); 120 121 $mesg = $langs->trans("ChartGenerated"); 122 } 123 124 125 $h=0; 126 127 $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; 128 $head[$h][1] = $langs->trans("Card"); 129 $h++; 130 131 $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; 132 $head[$h][1] = $langs->trans("Price"); 133 $h++; 134 135 if($product->type == 0) 136 { 137 if ($user->rights->barcode->lire) 138 { 139 if ($conf->barcode->enabled) 140 { 141 $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; 142 $head[$h][1] = $langs->trans("BarCode"); 143 $h++; 144 } 145 } 146 } 147 148 149 $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; 150 $head[$h][1] = $langs->trans("Photos"); 151 $h++; 152 153 if($product->type == 0) 154 { 155 if ($conf->stock->enabled) 156 { 157 $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; 158 $head[$h][1] = $langs->trans('Stock'); 159 $h++; 160 } 161 } 162 163 if ($conf->fournisseur->enabled) 164 { 165 $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; 166 $head[$h][1] = $langs->trans("Suppliers"); 167 $h++; 168 } 169 170 $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; 171 $head[$h][1] = $langs->trans("Statistics"); 172 $hselected=$h; 173 $h++; 174 175 //erics: pour créer des produits composés de x 'sous' produits 176 /* 177 $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id; 178 $head[$h][1] = $langs->trans('Packs'); 179 $h++; 180 */ 181 182 $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; 183 $head[$h][1] = $langs->trans('Referers'); 184 $h++; 185 186 $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id; 187 $head[$h][1] = $langs->trans('Documents'); 188 $h++; 189 190 $titre=$langs->trans("CardProduct".$product->type); 191 dolibarr_fiche_head($head, $hselected, $titre); 192 193 print '<table class="border" width="100%">'; 194 195 // Reference 196 print '<tr>'; 197 print '<td width="28%">'.$langs->trans("Ref").'</td><td colspan="3">'; 198 $product->load_previous_next_ref(); 199 $previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':''; 200 $next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':''; 201 if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">'; 202 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>'; 203 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>'; 204 print '</td>'; 205 print '</tr>'; 206 207 // Libelle 208 print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td></tr>'; 209 210 print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="3">'.price($product->price).'</td>'; 211 212 // Statut 213 print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'; 214 if ($product->envente) print $langs->trans("OnSell"); 215 else print $langs->trans("NotOnSell"); 216 print '</td></tr>'; 217 218 print '<tr><td valign="top" width="28%">'.$langs->trans("Referers").'</td>'; 219 print '<td align="right" width="24%">'.$langs->trans("NbOfCustomers").'</td>'; 220 print '<td align="right" width="24%">'.$langs->trans("NbOfReferers").'</td>'; 221 print '<td align="right" width="24%">'.$langs->trans("TotalQuantity").'</td>'; 222 print '</tr>'; 223 224 // Propals 225 if ($conf->propal->enabled) 226 { 227 $ret=$product->load_stats_propale($socid); 228 if ($ret < 0) dolibarr_print_error($db); 229 $langs->load("propal"); 230 print '<tr><td>'; 231 print '<a href="propal.php?id='.$product->id.'">'.$langs->trans("Proposals").'</a>'; 232 print '</td><td align="right">'; 233 print $product->stats_propale['customers']; 234 print '</td><td align="right">'; 235 print $product->stats_propale['nb']; 236 print '</td><td align="right">'; 237 print $product->stats_propale['qty']; 238 print '</td>'; 239 print '</tr>'; 240 } 241 // Commandes 242 if ($conf->commande->enabled) 243 { 244 $ret=$product->load_stats_commande($socid); 245 if ($ret < 0) dolibarr_print_error($db); 246 $langs->load("orders"); 247 print '<tr><td>'; 248 print '<a href="commande.php?id='.$product->id.'">'.$langs->trans("Orders").'</a>'; 249 print '</td><td align="right">'; 250 print $product->stats_commande['customers']; 251 print '</td><td align="right">'; 252 print $product->stats_commande['nb']; 253 print '</td><td align="right">'; 254 print $product->stats_commande['qty']; 255 print '</td>'; 256 print '</tr>'; 257 } 258 // Contrats 259 if ($conf->contrat->enabled) 260 { 261 $ret=$product->load_stats_contrat($socid); 262 if ($ret < 0) dolibarr_print_error($db); 263 $langs->load("contracts"); 264 print '<tr><td>'; 265 print '<a href="contrat.php?id='.$product->id.'">'.$langs->trans("Contracts").'</a>'; 266 print '</td><td align="right">'; 267 print $product->stats_contrat['customers']; 268 print '</td><td align="right">'; 269 print $product->stats_contrat['nb']; 270 print '</td><td align="right">'; 271 print $product->stats_contrat['qty']; 272 print '</td>'; 273 print '</tr>'; 274 } 275 // Factures 276 if ($conf->facture->enabled) 277 { 278 $ret=$product->load_stats_facture($socid); 279 if ($ret < 0) dolibarr_print_error($db); 280 $langs->load("bills"); 281 print '<tr><td>'; 282 print '<a href="facture.php?id='.$product->id.'">'.$langs->trans("Bills").'</a>'; 283 print '</td><td align="right">'; 284 print $product->stats_facture['customers']; 285 print '</td><td align="right">'; 286 print $product->stats_facture['nb']; 287 print '</td><td align="right">'; 288 print $product->stats_facture['qty']; 289 print '</td>'; 290 print '</tr>'; 291 } 292 293 print '</table>'; 294 print '</div>'; 295 296 297 print '<table class="border" width="100%">'; 298 299 // Ligne de graph 300 print '<tr class="liste_titre"><td width="50%" colspan="2" align="center">Nombre de propositions commerciales<br>sur les 12 derniers mois</td>'; 301 print '<td align="center" width="50%" colspan="2">-</td></tr>'; 302 // Place pour autre graphique 303 print '<tr><td align="center" colspan="2">'; 304 $file=$product->id.'/'.$img_propal_name; 305 print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file='.urlencode($file).'" alt="Nombre de propales sur les 12 derniers mois">'; 306 print '</td><td align="center" colspan="2"> </td></tr>'; 307 print '<tr>'; 308 if (file_exists($filenbpropal) && filemtime($filenbpropal) && ! $px->isGraphKo()) 309 { 310 print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpropal),"%d %b %Y %H:%M:%S")).'</td>'; 311 } 312 else 313 { 314 print '<td>'.($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated")).'</td>'; 315 } 316 print '<td align="center">[<a href="fiche.php?id='.$product->id.'&action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td>'; 317 if (file_exists($filenbpiece) && filemtime($filenbpiece) && ! $px->isGraphKo()) 318 { 319 print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpiece),"%d %b %Y %H:%M:%S")).'</td>'; 320 } 321 else 322 { 323 print '<td>'.($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated")).'</td>'; 324 } 325 print '<td align="center">[<a href="fiche.php?id='.$product->id.'&action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td></tr>'; 326 327 // Ligne de graph 328 print '<tr class="liste_titre"><td width="50%" colspan="2" align="center">Nombre de ventes<br>sur les 12 derniers mois</td>'; 329 print '<td align="center" width="50%" colspan="2">Nombre de pièces vendues</td></tr>'; 330 print '<tr><td align="center" colspan="2">'; 331 $file=$product->id.'/vente12mois.png'; 332 print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file='.urlencode($file).'" alt="Ventes sur les 12 derniers mois">'; 333 print '</td><td align="center" colspan="2">'; 334 $file=$product->id.'/vendu12mois.png'; 335 print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file='.urlencode($file).'" alt="Nombre de pièces vendues sur les 12 derniers mois">'; 336 print '</td></tr>'; 337 print '<tr>'; 338 if (file_exists($filenbvente) && filemtime($filenbvente) && ! $px->isGraphKo()) 339 { 340 print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbvente),"%d %b %Y %H:%M:%S")).'</td>'; 341 } 342 else 343 { 344 print '<td>'.($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated")).'</td>'; 345 } 346 print '<td align="center">[<a href="fiche.php?id='.$product->id.'&action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td>'; 347 if (file_exists($filenbpiece) && filemtime($filenbpiece) && ! $px->isGraphKo()) 348 { 349 print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpiece),"%d %b %Y %H:%M:%S")).'</td>'; 350 } 351 else 352 { 353 print '<td>'.($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated")).'</td>'; 354 } 355 print '<td align="center">[<a href="fiche.php?id='.$product->id.'&action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td></tr>'; 356 357 358 print '</table>'; 359 360 361 // Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent en fin de page 362 print '<div class="tabsAction">'; 363 print '</div>'; 364 365 } 366 } 367 else 368 { 369 dolibarr_print_error(); 370 } 371 372 373 $db->close(); 374 375 llxFooter('$Date: 2005/12/03 03:54:15 $ - $Revision: 1.53 $'); 376 377 ?>
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 |
![]() |