* Copyright (c) 2004 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ * */ /*! \file htdocs/product/stats/fiche.php \ingroup product \brief Page des stats produits \version $Revision$ */ require("./pre.inc.php"); require("../../propal.class.php"); $langs->load("products"); $langs->load("bills"); $types[0] = $langs->trans("Product"); $types[1] = $langs->trans("Service"); if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } else { $socid = 0; } llxHeader(); $mesg = ''; /* * * */ if ($_GET["id"]) { $product = new Product($db); $result = $product->fetch($_GET["id"]); if ( $result ) { // Efface rep obsolete if(is_dir(DOL_DOCUMENT_ROOT."/document/produits")) rmdir(DOL_DOCUMENT_ROOT."/document/produits"); // Création répertoire pour images générées $dir = $conf->produit->dir_images."/".$product->id; if (! file_exists($dir)) { umask(0); if(!file_exists($conf->produit->dir_images)) { mkdir($conf->produit->dir_images); } if (! mkdir($dir, 0755)) { $mesg = $langs->trans("ErrorCanNotCreateDir",$dir); } } $img_propal_name = "propal12mois.png"; $filenbpropal = $dir . "/" . $img_propal_name; $filenbvente = $dir . "/vente12mois.png"; $filenbpiece = $dir . "/vendu12mois.png"; $px = new BarGraph(); $mesg = $px->isGraphKo(); if (! $mesg) { $graph_data = $product->get_num_vente($socid); $px->draw($filenbvente, $graph_data); $px = new BarGraph(); $graph_data = $product->get_nb_vente($socid); $px->draw($filenbpiece, $graph_data); $px = new BarGraph(); $graph_data = $product->get_num_propal($socid); $px->draw($filenbpropal, $graph_data); $mesg = $langs->trans("ChartGenerated"); } // Zone recherche print '
'; print '
'; print ''; print $langs->trans("Ref").':    '; print $langs->trans("Label").':  '; print '
'; $h=0; $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; $head[$h][1] = $langs->trans("Card"); $h++; $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; $head[$h][1] = $langs->trans("Price"); $h++; if($product->type == 0) { if ($conf->stock->enabled) { $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; $head[$h][1] = 'Stock'; $h++; } if ($conf->fournisseur->enabled) { $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; $head[$h][1] = $langs->trans("Suppliers"); $h++; } } $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; $head[$h][1] = $langs->trans("Statistics"); $hselected=$h; $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); print ''; print ''; print ''; print ""; print ''; print ''; print "
'.$langs->trans("Ref").''.$product->ref.''.$langs->trans("Statistics").'
".$langs->trans("Label")."$product->libelle'; // Propals if ($conf->propal->enabled) { $langs->load("propal"); print ''.$langs->trans("Proposals").' : '.$product->count_propale($socid); print " (Proposé à ".$product->count_propale_client($socid)." clients)
"; } // Commande if ($conf->commande->enabled) { $langs->load("orders"); print ''.$langs->trans("Orders").' : '.$product->count_facture($socid)."
"; } // Factures if ($conf->facture->enabled) { $langs->load("bills"); print ''.$langs->trans("Bills").' : '.$product->count_facture($socid); } print '
'.$langs->trans("CurrentPrice").''.price($product->price).'
"; print '
'; print ''; print ''; print ''; if (file_exists($filenbvente) && filemtime($filenbvente)) { print ''; } else { print ''; } print ''; if (file_exists($filenbpiece) && filemtime($filenbpiece)) { print ''; } else { print ''; } print ''; print ''; print ''; print ''; print ''; if (file_exists($filenbpropal) && filemtime($filenbpropal)) { print ''; } else { print ''; } print ''; if (file_exists($filenbpiece) && filemtime($filenbpiece33)) { print ''; } else { print ''; } print ''; print '
Nombre de ventes
sur les 12 derniers mois
Nombre de pièces vendues
'; print 'id.'/vente12mois.png" alt="Ventes sur les 12 derniers mois">'; print ''; print 'id.'/vendu12mois.png" alt="Ventes sur les 12 derniers mois">'; print '
'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbvente),"%d %b %Y %H:%M:%S")).''.$langs->trans("ChartNotGenerated").'['.$langs->trans("ReCalculate").']'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpiece),"%d %b %Y %H:%M:%S")).''.$langs->trans("ChartNotGenerated").'['.$langs->trans("ReCalculate").']
Statistiques effectuées sur les factures payées uniquement
Nombre de propositions commerciales
sur les 12 derniers mois
-
'; print 'id.'/'.$img_propal_name.'" alt="Propales sur les 12 derniers mois">'; print 'TODO AUTRE GRAPHIQUE'; print '
'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpropal),"%d %b %Y %H:%M:%S")).''.$langs->trans("ChartNotGenerated").'['.$langs->trans("ReCalculate").']'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpiece),"%d %b %Y %H:%M:%S")).''.$langs->trans("ChartNotGenerated").'['.$langs->trans("ReCalculate").']

'; } } else { dolibarr_print_error(); } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>