Fix: uniform code
This commit is contained in:
parent
2f100d0d72
commit
666e850d72
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (c) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (c) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -34,18 +34,17 @@ $langs->load("products");
|
|||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
|
|
||||||
$mode=isset($_GET["mode"])?$_GET["mode"]:'byunit';
|
$id = GETPOST('id');
|
||||||
$error=0;
|
$ref = GETPOST('ref');
|
||||||
$mesg='';
|
$mode = (GETPOST('mode') ? GETPOST('mode') : 'byunit');
|
||||||
|
$error = 0;
|
||||||
|
$mesg = '';
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (isset($_GET["id"]) || isset($_GET["ref"]))
|
$fieldid = (! empty($id) ? $id : $ref);
|
||||||
{
|
$fieldtype = (! empty($ref) ? 'ref' : 'rowid');
|
||||||
$id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:'');
|
|
||||||
}
|
|
||||||
$fieldid = isset($_GET["ref"])?'ref':'rowid';
|
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid);
|
$result=restrictedArea($user,'produit|service',$fieldid,'product','','',$fieldtype);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -53,19 +52,18 @@ $result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid);
|
|||||||
*/
|
*/
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
if ($_GET["id"] || $_GET["ref"])
|
if (! empty($id) || ! empty($ref))
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$object = new Product($db);
|
||||||
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
|
$result = $object->fetch($id,$ref);
|
||||||
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
|
|
||||||
|
|
||||||
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
llxHeader("","",$langs->trans("CardProduct".$object->type));
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$head=product_prepare_head($product, $user);
|
$head=product_prepare_head($object, $user);
|
||||||
$titre=$langs->trans("CardProduct".$product->type);
|
$titre=$langs->trans("CardProduct".$object->type);
|
||||||
$picto=($product->type==1?'service':'product');
|
$picto=($object->type==1?'service':'product');
|
||||||
dol_fiche_head($head, 'stats', $titre, 0, $picto);
|
dol_fiche_head($head, 'stats', $titre, 0, $picto);
|
||||||
|
|
||||||
|
|
||||||
@ -74,34 +72,34 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
// Reference
|
// Reference
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
print '<td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||||
print $form->showrefnav($product,'ref','',1,'ref');
|
print $form->showrefnav($object,'ref','',1,'ref');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td></tr>';
|
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$object->libelle.'</td></tr>';
|
||||||
|
|
||||||
// Status (to sell)
|
// Status (to sell)
|
||||||
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.'</td><td>';
|
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.'</td><td>';
|
||||||
print $product->getLibStatut(2,0);
|
print $object->getLibStatut(2,0);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Status (to buy)
|
// Status (to buy)
|
||||||
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.'</td><td>';
|
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.'</td><td>';
|
||||||
print $product->getLibStatut(2,1);
|
print $object->getLibStatut(2,1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
|
||||||
// Graphs additionels generes pas le script product-graph.php
|
// Graphs additionels generes pas le script product-graph.php
|
||||||
$year = strftime('%Y',time());
|
$year = strftime('%Y',time());
|
||||||
$file = get_exdir($product->id, 3) . "ventes-".$year."-".$product->id.".png";
|
$file = get_exdir($object->id, 3) . "ventes-".$year."-".$object->id.".png";
|
||||||
if (file_exists (DOL_DATA_ROOT.'/product/temp/'.$file) )
|
if (file_exists (DOL_DATA_ROOT.'/product/temp/'.$file) )
|
||||||
{
|
{
|
||||||
print '<tr><td>Ventes</td><td>';
|
print '<tr><td>Ventes</td><td>';
|
||||||
|
|
||||||
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_product&file='.$file;
|
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_product&file='.$file;
|
||||||
print '<img src="'.$url.'" alt="Ventes">';
|
print '<img src="'.$url.'" alt="Ventes">';
|
||||||
$file = get_exdir($product->id, 3) . "ventes-".$product->id.".png";
|
$file = get_exdir($object->id, 3) . "ventes-".$object->id.".png";
|
||||||
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_product&file='.$file;
|
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_product&file='.$file;
|
||||||
print '<img src="'.$url.'" alt="Ventes">';
|
print '<img src="'.$url.'" alt="Ventes">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
@ -113,12 +111,12 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
|
|
||||||
|
|
||||||
// Choice of stats
|
// Choice of stats
|
||||||
if ($mode == 'bynumber') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'&mode=byunit">';
|
if ($mode == 'bynumber') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mode=byunit">';
|
||||||
else print img_picto('','tick').' ';
|
else print img_picto('','tick').' ';
|
||||||
print $langs->trans("StatsByNumberOfUnits");
|
print $langs->trans("StatsByNumberOfUnits");
|
||||||
if ($mode == 'bynumber') print '</a>';
|
if ($mode == 'bynumber') print '</a>';
|
||||||
print ' ';
|
print ' ';
|
||||||
if ($mode == 'byunit') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'&mode=bynumber">';
|
if ($mode == 'byunit') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mode=bynumber">';
|
||||||
else print img_picto('','tick').' ';
|
else print img_picto('','tick').' ';
|
||||||
print $langs->trans("StatsByNumberOfEntities");
|
print $langs->trans("StatsByNumberOfEntities");
|
||||||
if ($mode == 'byunit') print '</a>';
|
if ($mode == 'byunit') print '</a>';
|
||||||
@ -131,9 +129,9 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
$WIDTH=380;
|
$WIDTH=380;
|
||||||
$HEIGHT=160;
|
$HEIGHT=160;
|
||||||
$dir = (!empty($conf->product->dir_temp)?$conf->product->dir_temp:$conf->service->dir_temp);
|
$dir = (!empty($conf->product->dir_temp)?$conf->product->dir_temp:$conf->service->dir_temp);
|
||||||
if (! file_exists($dir.'/'.$product->id))
|
if (! file_exists($dir.'/'.$object->id))
|
||||||
{
|
{
|
||||||
if (dol_mkdir($dir.'/'.$product->id) < 0)
|
if (dol_mkdir($dir.'/'.$object->id) < 0)
|
||||||
{
|
{
|
||||||
$mesg = $langs->trans("ErrorCanNotCreateDir",$dir);
|
$mesg = $langs->trans("ErrorCanNotCreateDir",$dir);
|
||||||
$error++;
|
$error++;
|
||||||
@ -142,20 +140,20 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
|
|
||||||
$graphfiles=array(
|
$graphfiles=array(
|
||||||
'propal' =>array('modulepart'=>'productstats_proposals',
|
'propal' =>array('modulepart'=>'productstats_proposals',
|
||||||
'file' => $product->id.'/propal12m.png',
|
'file' => $object->id.'/propal12m.png',
|
||||||
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsProposals"):$langs->trans("NumberOfProposals"))),
|
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsProposals"):$langs->trans("NumberOfProposals"))),
|
||||||
'orders' =>array('modulepart'=>'productstats_orders',
|
'orders' =>array('modulepart'=>'productstats_orders',
|
||||||
'file' => $product->id.'/orders12m.png',
|
'file' => $object->id.'/orders12m.png',
|
||||||
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsCustomerOrders"):$langs->trans("NumberOfCustomerOrders"))),
|
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsCustomerOrders"):$langs->trans("NumberOfCustomerOrders"))),
|
||||||
'invoices' =>array('modulepart'=>'productstats_invoices',
|
'invoices' =>array('modulepart'=>'productstats_invoices',
|
||||||
'file' => $product->id.'/invoices12m.png',
|
'file' => $object->id.'/invoices12m.png',
|
||||||
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsCustomerInvoices"):$langs->trans("NumberOfCustomerInvoices"))),
|
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsCustomerInvoices"):$langs->trans("NumberOfCustomerInvoices"))),
|
||||||
'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers',
|
'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers',
|
||||||
'file' => $product->id.'/invoicessuppliers12m.png',
|
'file' => $object->id.'/invoicessuppliers12m.png',
|
||||||
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsSupplierInvoices"):$langs->trans("NumberOfSupplierInvoices"))),
|
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsSupplierInvoices"):$langs->trans("NumberOfSupplierInvoices"))),
|
||||||
|
|
||||||
// 'orderssuppliers' =>array('modulepart'=>'productstats_orderssuppliers', 'file' => $product->id.'/orderssuppliers12m.png', 'label' => $langs->trans("Nombre commande fournisseurs sur les 12 derniers mois")),
|
// 'orderssuppliers' =>array('modulepart'=>'productstats_orderssuppliers', 'file' => $object->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")),
|
// 'contracts' =>array('modulepart'=>'productstats_contracts', 'file' => $object->id.'/contracts12m.png', 'label' => $langs->trans("Nombre contrats sur les 12 derniers mois")),
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -173,10 +171,10 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
$graph_data = array();
|
$graph_data = array();
|
||||||
|
|
||||||
// TODO Test si deja existant et recent, on ne genere pas
|
// TODO Test si deja existant et recent, on ne genere pas
|
||||||
if ($key == 'propal') $graph_data = $product->get_nb_propal($socid,$mode);
|
if ($key == 'propal') $graph_data = $object->get_nb_propal($socid,$mode);
|
||||||
if ($key == 'orders') $graph_data = $product->get_nb_order($socid,$mode);
|
if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode);
|
||||||
if ($key == 'invoices') $graph_data = $product->get_nb_vente($socid,$mode);
|
if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode);
|
||||||
if ($key == 'invoicessuppliers') $graph_data = $product->get_nb_achat($socid,$mode);
|
if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode);
|
||||||
if (is_array($graph_data))
|
if (is_array($graph_data))
|
||||||
{
|
{
|
||||||
$px->SetData($graph_data);
|
$px->SetData($graph_data);
|
||||||
@ -193,7 +191,7 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_print_error($db,'Error for calculating graph on key='.$key.' - '.$product->error);
|
dol_print_error($db,'Error for calculating graph on key='.$key.' - '.$object->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +238,7 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
{
|
{
|
||||||
print '<td>'.($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated")).'</td>';
|
print '<td>'.($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated")).'</td>';
|
||||||
}
|
}
|
||||||
print '<td align="center"><a href="fiche.php?id='.$product->id.'&action=recalcul&mode='.$mode.'">'.img_picto($langs->trans("ReCalculate"),'refresh').'</a></td>';
|
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=recalcul&mode='.$mode.'">'.img_picto($langs->trans("ReCalculate"),'refresh').'</a></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user