diff --git a/htdocs/product/stats/fiche.php b/htdocs/product/stats/fiche.php index c0835008f88..82de4d98517 100644 --- a/htdocs/product/stats/fiche.php +++ b/htdocs/product/stats/fiche.php @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -60,17 +59,17 @@ $html = new Form($db); if ($_GET["id"] || $_GET["ref"]) { - $product = new Product($db); - if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); - if ($_GET["id"]) $result = $product->fetch($_GET["id"]); + $product = new Product($db); + if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); + if ($_GET["id"]) $result = $product->fetch($_GET["id"]); - llxHeader("","",$langs->trans("CardProduct".$product->type)); + llxHeader("","",$langs->trans("CardProduct".$product->type)); - if ($result) - { - // Efface rep obsolete - if(is_dir(DOL_DOCUMENT_ROOT."/document/produits")) - rmdir(DOL_DOCUMENT_ROOT."/document/produits"); + if ($result) + { + // Efface rep obsolete + if(is_dir(DOL_DOCUMENT_ROOT."/document/produits")) + rmdir(DOL_DOCUMENT_ROOT."/document/produits"); $head=product_prepare_head($product, $user); @@ -78,19 +77,19 @@ if ($_GET["id"] || $_GET["ref"]) dolibarr_fiche_head($head, 'stats', $titre); - print ''; + print '
'; - // Reference - print ''; - print ''; + print ''; - print ''; + print ''; + print ''; - // Libelle - print ''; + // Libelle + print ''; - print ''; - // Statut - print ''; + // Statut + print ''; - // Stock - if ($product->isproduct() && $conf->stock->enabled) - { - print ''; - if ($product->no_stock) - { - print "'; - } - //show_stats_for_company($product,$socid); + // Stock + if ($product->isproduct() && $conf->stock->enabled) + { + print ''; + if ($product->no_stock) + { + print "'; + } + //show_stats_for_company($product,$socid); - /* - * Graphs additionels generes pas les cron - * - */ - $year = strftime('%Y',time()); - $file = get_exdir($product->id, 3) . "ventes-".$year."-".$product->id.".png"; + // Graphs additionels generes pas les cron + $year = strftime('%Y',time()); + $file = get_exdir($product->id, 3) . "ventes-".$year."-".$product->id.".png"; + if (file_exists (DOL_DATA_ROOT.'/graph/product/'.$file) ) + { + print ''; + } - if (file_exists (DOL_DATA_ROOT.'/graph/product/'.$file) ) - { - print ''; - } + print '
'.$langs->trans("Ref").''; + // Reference + print '
'.$langs->trans("Ref").''; print $html->showrefnav($product,'ref'); - print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''; + print '
'.$langs->trans("SellingPrice").''; if ($product->price_base_type == 'TTC') { print price($product->price_ttc).' '.$langs->trans($product->price_base_type); @@ -101,190 +100,189 @@ if ($_GET["id"] || $_GET["ref"]) } print '
'.$langs->trans("Status").''; - print $product->getLibStatut(2); - print '
'.$langs->trans("Status").''; + print $product->getLibStatut(2); + print '
'.$langs->trans("Stock").'".$langs->trans("NoStockForThisProduct"); - } - else - { - if ($product->stock_reel <= $product->seuil_stock_alerte) - { - print ''.img_warning().' '.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte; - } - else - { - print "".$product->stock_reel; - } - } - print '
'.$langs->trans("Stock").'".$langs->trans("NoStockForThisProduct"); + } + else + { + if ($product->stock_reel <= $product->seuil_stock_alerte) + { + print ''.img_warning().' '.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte; + } + else + { + print "".$product->stock_reel; + } + } + print '
Ventes'; + + $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_product&file='.$file; + print 'Ventes'; + $file = get_exdir($product->id, 3) . "ventes-".$product->id.".png"; + $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_product&file='.$file; + print 'Ventes'; + print '
Ventes'; - - $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_product&file='.$file; - print 'Ventes'; - $file = get_exdir($product->id, 3) . "ventes-".$product->id.".png"; - $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_product&file='.$file; - print 'Ventes'; - print '
'; + print ''; - print ''; - print ''; - - print ''; - - // Generation des graphs - $WIDTH=380; - $HEIGHT=160; - $dir = $conf->produit->dir_temp; - if (! file_exists($dir.'/'.$product->id)) - { - if (create_exdir($dir.'/'.$product->id) < 0) - { - $mesg = $langs->trans("ErrorCanNotCreateDir",$dir); - } - } - - $graphfiles=array( - 'propal' =>array('modulepart'=>'productstats_proposals', - 'file' => $product->id.'/propal12m.png', - 'label' => $langs->trans("Nombre propal sur les 12 derniers mois")), - 'orders' =>array('modulepart'=>'productstats_orders', - 'file' => $product->id.'/orders12m.png', - 'label' => $langs->trans("Nombre commande clients sur les 12 derniers mois")), - 'invoices' =>array('modulepart'=>'productstats_invoices', - 'file' => $product->id.'/invoices12m.png', - 'label' => $langs->trans("Nombre facture clients sur les 12 derniers mois")), - 'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers', - 'file' => $product->id.'/invoicessuppliers12m.png', - 'label' => $langs->trans("Nombre facture fournisseurs sur les 12 derniers mois")), - - // 'orderssuppliers' =>array('modulepart'=>'productstats_orderssuppliers', 'file' => $product->id.'/orderssuppliers12m.png', 'label' => $langs->trans("Nombre commande fournisseurs sur les 12 derniers mois")), - // 'contracts' =>array('modulepart'=>'productstats_contracts', 'file' => $product->id.'/contracts12m.png', 'label' => $langs->trans("Nombre contrats sur les 12 derniers mois")), - - ); - - $px = new DolGraph(); - $mesg = $px->isGraphKo(); - if (! $mesg) - { - foreach($graphfiles as $key => $val) - { - if (! $graphfiles[$key]['file']) continue; - $graph_data = array(); - // \todo Test si deja existant et recent, on ne genere pas - if ($key == 'propal') $graph_data = $product->get_nb_propal($socid); - if ($key == 'orders') $graph_data = $product->get_nb_order($socid); - if ($key == 'invoices') $graph_data = $product->get_nb_vente($socid); - if ($key == 'invoicessuppliers') $graph_data = $product->get_nb_achat($socid); - if (is_array($graph_data)) - { - $px->SetData($graph_data); - $px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue()); - $px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue()); - $px->SetWidth($WIDTH); - $px->SetHeight($HEIGHT); - $px->SetHorizTickIncrement(1); - $px->SetPrecisionY(0); - $px->SetShading(5); - //print 'x '.$key.' '.$graphfiles[$key]['file']; + print '
'; - $px->draw($dir."/".$graphfiles[$key]['file']); - } - else - { - dolibarr_print_error($db,'Error for calculating graph on key='.$key.' - '.$product->error); - } - } - } - - $mesg = $langs->trans("ChartGenerated"); - - // Affichage graphs - $i=0; - foreach($graphfiles as $key => $val) - { - if (! $graphfiles[$key]['file']) continue; - - if ($graphfiles == 'propal' && ! $user->right->propale->lire) continue; - if ($graphfiles == 'order' && ! $user->right->commande->lire) continue; - if ($graphfiles == 'invoices' && ! $user->right->facture->lire) continue; - if ($graphfiles == 'invoices_suppliers' && ! $user->right->fournisseur->facture->lire) continue; - - - if ($i % 2 == 0) print ''; - - // Show graph - print ''; - - if ($i % 2 == 1) print ''; - - - $i++; - } - - if ($i % 2 == 1) print ''; + // Generation des graphs + $WIDTH=380; + $HEIGHT=160; + $dir = $conf->produit->dir_temp; + if (! file_exists($dir.'/'.$product->id)) + { + if (create_exdir($dir.'/'.$product->id) < 0) + { + $mesg = $langs->trans("ErrorCanNotCreateDir",$dir); + } + } - print '
'; - - print ''; - // Label - print ''; - // Image - print ''; - // Date génération - print ''; - if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file']) && ! $px->isGraphKo()) - { - print ''; - } - else - { - print ''; - } - print ''; - print ''; - print '
'; - print $graphfiles[$key]['label']; - print '
'; - $url=DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&file='.urlencode($graphfiles[$key]['file']); - //print $url; - print ''; - print '
'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($dir."/".$graphfiles[$key]['file']),"dayhour")).''.($mesg?''.$mesg.'':$langs->trans("ChartNotGenerated")).''.img_picto($langs->trans("ReCalculate"),'refresh').'
'; - - print '
 
'; + $graphfiles=array( + 'propal' =>array('modulepart'=>'productstats_proposals', + 'file' => $product->id.'/propal12m.png', + 'label' => $langs->trans("Nombre propal sur les 12 derniers mois")), + 'orders' =>array('modulepart'=>'productstats_orders', + 'file' => $product->id.'/orders12m.png', + 'label' => $langs->trans("Nombre commande clients sur les 12 derniers mois")), + 'invoices' =>array('modulepart'=>'productstats_invoices', + 'file' => $product->id.'/invoices12m.png', + 'label' => $langs->trans("Nombre facture clients sur les 12 derniers mois")), + 'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers', + 'file' => $product->id.'/invoicessuppliers12m.png', + 'label' => $langs->trans("Nombre facture fournisseurs sur les 12 derniers mois")), + + // 'orderssuppliers' =>array('modulepart'=>'productstats_orderssuppliers', 'file' => $product->id.'/orderssuppliers12m.png', 'label' => $langs->trans("Nombre commande fournisseurs sur les 12 derniers mois")), + // 'contracts' =>array('modulepart'=>'productstats_contracts', 'file' => $product->id.'/contracts12m.png', 'label' => $langs->trans("Nombre contrats sur les 12 derniers mois")), + + ); - // Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent en fin de page - print '
'; - print '
'; - - } + $px = new DolGraph(); + $mesg = $px->isGraphKo(); + if (! $mesg) + { + foreach($graphfiles as $key => $val) + { + if (! $graphfiles[$key]['file']) continue; + + $graph_data = array(); + + // \todo Test si deja existant et recent, on ne genere pas + if ($key == 'propal') $graph_data = $product->get_nb_propal($socid); + if ($key == 'orders') $graph_data = $product->get_nb_order($socid); + if ($key == 'invoices') $graph_data = $product->get_nb_vente($socid); + if ($key == 'invoicessuppliers') $graph_data = $product->get_nb_achat($socid); + if (is_array($graph_data)) + { + $px->SetData($graph_data); + $px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue()); + $px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue()); + $px->SetWidth($WIDTH); + $px->SetHeight($HEIGHT); + $px->SetHorizTickIncrement(1); + $px->SetPrecisionY(0); + $px->SetShading(5); + //print 'x '.$key.' '.$graphfiles[$key]['file']; + + $px->draw($dir."/".$graphfiles[$key]['file']); + } + else + { + dolibarr_print_error($db,'Error for calculating graph on key='.$key.' - '.$product->error); + } + } + } + + $mesg = $langs->trans("ChartGenerated"); + + // Affichage graphs + $i=0; + foreach($graphfiles as $key => $val) + { + if (! $graphfiles[$key]['file']) continue; + + if ($graphfiles == 'propal' && ! $user->right->propale->lire) continue; + if ($graphfiles == 'order' && ! $user->right->commande->lire) continue; + if ($graphfiles == 'invoices' && ! $user->right->facture->lire) continue; + if ($graphfiles == 'invoices_suppliers' && ! $user->right->fournisseur->facture->lire) continue; + + + if ($i % 2 == 0) print ''; + + // Show graph + print ''; + + print ''; + // Label + print ''; + // Image + print ''; + // Date génération + print ''; + if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file']) && ! $px->isGraphKo()) + { + print ''; + } + else + { + print ''; + } + print ''; + print ''; + print '
'; + print $graphfiles[$key]['label']; + print '
'; + //print $graphfiles[$key]['modulepart']."x".urlencode($graphfiles[$key]['file']); + $url=DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&file='.urlencode($graphfiles[$key]['file']); + //print $url; + print ''.$graphfiles[$key]['label'].''; + print '
'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($dir."/".$graphfiles[$key]['file']),"dayhour")).''.($mesg?''.$mesg.'':$langs->trans("ChartNotGenerated")).''.img_picto($langs->trans("ReCalculate"),'refresh').'
'; + + print ''; + + if ($i % 2 == 1) print ''; + + + $i++; + } + + if ($i % 2 == 1) print ' '; + + print ''; + + // Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent en fin de page + print '
'; + print '
'; + + } } else { - dolibarr_print_error(); + dolibarr_print_error(); } diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 5968a73164e..77d28427c16 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -18,7 +18,6 @@ * or see http://www.gnu.org/ * * $Id$ - * $Source$ */ /** @@ -37,7 +36,7 @@ function llxHeader() { } $original_file = urldecode($_GET["file"]); $modulepart = urldecode($_GET["modulepart"]); -$type = urldecode($_GET["type"]); +$type = isset($_GET["type"]) ? urldecode($_GET["type"]) : ''; // Protection, on interdit les .. dans les chemins $original_file = eregi_replace('\.\.','',$original_file);