diff --git a/htdocs/product/stats/fiche.php b/htdocs/product/stats/fiche.php index b1693a79918..d503024affd 100644 --- a/htdocs/product/stats/fiche.php +++ b/htdocs/product/stats/fiche.php @@ -59,127 +59,123 @@ $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"); + $product = new Product($db); + $result = $product->fetch($_GET["id"]); - // Création répertoire pour images générées - // $conf->produit->dir_images définit dans master.inc.php + if ($result) + { + // Efface rep obsolete + if(is_dir(DOL_DOCUMENT_ROOT."/document/produits")) + rmdir(DOL_DOCUMENT_ROOT."/document/produits"); - $dir = $conf->produit->dir_images."/".$product->id; + // Création répertoire pour images générées + // $conf->produit->dir_images définit dans master.inc.php - 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); + $dir = $conf->produit->dir_images."/".$product->id; - $mesg = $langs->trans("ChartGenerated"); - } - - - $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++; - - $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; - $head[$h][1] = $langs->trans("Photos"); - $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] = $langs->trans('Stock'); - $h++; - } - } - - if ($conf->fournisseur->enabled) + if (! file_exists($dir)) { - $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; - $head[$h][1] = $langs->trans("Suppliers"); - $h++; + if (! create_exdir($dir)) + { + $mesg = $langs->trans("ErrorCanNotCreateDir",$dir); + } } - - $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; - $head[$h][1] = $langs->trans("Statistics"); - $hselected=$h; - $h++; - + + $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"); + } + + + $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++; + + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; + $head[$h][1] = $langs->trans("Photos"); + $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] = $langs->trans('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++; + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; $head[$h][1] = $langs->trans('Bills'); $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); - - - print ''; + + dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); + + + print '
'; print ''; print ''; print ''; - print ''; + print ''; - print ''; - print ''; + print ''; + print ''; // Statut print ''; - print "
'.$langs->trans("Ref").''.$product->ref.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''.price($product->price).''; - // 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("SellingPrice").''.price($product->price).''; + // 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("Status").''; @@ -187,71 +183,71 @@ if ($_GET["id"]) else print $langs->trans("NotOnSell"); print '
"; + print ""; - print '
'; - print ''; - print ''; + print '
Nombre de ventes
sur les 12 derniers mois
Nombre de pièces vendues
'; + 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
'; - $file=$product->id.'/vente12mois.png'; - print 'Ventes sur les 12 derniers mois'; - - print ''; - $file=$product->id.'/vendu12mois.png'; - print 'Nombre de pièces vendues 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
-
'; + $file=$product->id.'/vente12mois.png'; + print 'Ventes sur les 12 derniers mois'; - print '
'; - $file=$product->id.'/'.$img_propal_name; - print 'Nombre de 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").']
'; + $file=$product->id.'/vendu12mois.png'; + print 'Nombre de pièces vendues sur les 12 derniers mois'; - print '

'; + print ''; + if (file_exists($filenbvente) && filemtime($filenbvente)) + { + print ''.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbvente),"%d %b %Y %H:%M:%S")).''; + } + else + { + print ''.$langs->trans("ChartNotGenerated").''; + } + print '['.$langs->trans("ReCalculate").']'; + if (file_exists($filenbpiece) && filemtime($filenbpiece)) + { + print ''.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpiece),"%d %b %Y %H:%M:%S")).''; + } + else + { + print ''.$langs->trans("ChartNotGenerated").''; + } + print '['.$langs->trans("ReCalculate").']'; + print 'Statistiques effectuées sur les factures payées uniquement'; + + print 'Nombre de propositions commerciales
sur les 12 derniers mois'; + print '-'; + + print ''; + $file=$product->id.'/'.$img_propal_name; + print 'Nombre de propales sur les 12 derniers mois'; + + print 'TODO AUTRE GRAPHIQUE'; + + print ''; + if (file_exists($filenbpropal) && filemtime($filenbpropal)) + { + print ''.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpropal),"%d %b %Y %H:%M:%S")).''; + } + else + { + print ''.$langs->trans("ChartNotGenerated").''; + } + print '['.$langs->trans("ReCalculate").']'; + if (file_exists($filenbpiece) && filemtime($filenbpiece33)) + { + print ''.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpiece),"%d %b %Y %H:%M:%S")).''; + } + else + { + print ''.$langs->trans("ChartNotGenerated").''; + } + print '['.$langs->trans("ReCalculate").']'; + + print '
'; } }