Nouveau fichier

This commit is contained in:
Rodolphe Quiedeville 2006-12-06 10:25:04 +00:00
parent 55af6bdfcf
commit d868049844
3 changed files with 270 additions and 0 deletions

View File

@ -0,0 +1,4 @@
<?php
require_once dirname(__FILE__).'/Artichow.cfg.php';
require_once ARTICHOW.'/LinePlot.class.php';
?>

View File

@ -0,0 +1,128 @@
<?php
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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/stock/fiche.php
\ingroup stock
\brief Page fiche de valorisation du stock dans l'entrepot
\version $Revision$
*/
require("./pre.inc.php");
$langs->load("products");
$langs->load("stocks");
$mesg = '';
llxHeader("","",$langs->trans("WarehouseCard"));
if ($_GET["id"])
{
if ($mesg) print $mesg;
$entrepot = new Entrepot($db);
$result = $entrepot->fetch($_GET["id"]);
if ($result < 0)
{
dolibarr_print_error($db);
}
/*
* Affichage fiche
*/
/*
* Affichage onglets
*/
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("WarehouseCard");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("StockMovements");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("EnhancedValue");
$hselected=$h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("Users");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("Info");
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->libelle);
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$entrepot->libelle.'</td>';
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($entrepot->description).'</td></tr>';
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">';
print $entrepot->address;
print '</td></tr>';
print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$entrepot->cp.'</td>';
print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$entrepot->ville.'</td></tr>';
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
print $entrepot->pays;
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->getLibStatut(4).'</td></tr>';
print '<tr><td valign="top">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
print $entrepot->nb_products();
print "</td></tr>";
print "</table>";
print '</div>';
/* ************************************************************************** */
/* */
/* Graph */
/* */
/* ************************************************************************** */
print "<div class=\"graph\">\n";
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file=entrepot-'.$entrepot->id.'.png';
print '<img src="'.$url.'">';
print "</div>";
}
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -0,0 +1,138 @@
<?PHP
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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$
*
*
* Calcul la valorisation du stock
*
*/
require ("../../htdocs/master.inc.php");
$verbose = 0;
for ($i = 1 ; $i < sizeof($argv) ; $i++)
{
if ($argv[$i] == "-v")
{
$verbose = 1;
}
if ($argv[$i] == "-vv")
{
$verbose = 2;
}
if ($argv[$i] == "-vvv")
{
$verbose = 3;
}
}
/*
*
*/
$sql = "SELECT date_format(date_calcul,'%j'), value, fk_entrepot";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot_valorisation as e";
$sql .= " ORDER BY date_calcul ASC";
$resql = $db->query($sql) ;
for ($i = 0 ; $i < 366 ; $i++)
{
for ($e = 0 ; $e < 8 ; $e++)
{
$values[$e][$i] = 0;
}
$legends[$i] = strftime('%b',mktime(12,12,12,1,1,2006) + ($i * 3600 * 24));
}
if ($resql)
{
$i = 0;
while ($row = $db->fetch_row($resql))
{
$values[$row[2]][$row[0]] = $row[1];
if ($verbose)
print $values[$i]."\n";
$values[0][$row[0]] += $row[1];
$i++;
}
$db->free($resql);
}
else
{
print $sql;
}
require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/LinePlot.class.php";
$file = DOL_DATA_ROOT."/graph/entrepot/entrepot.png";
$title = 'Valorisation du stock (euros HT)';
graph_datas($file, $title, $values[0], $legends);
$file = DOL_DATA_ROOT."/graph/entrepot/entrepot-7.png";
$title = 'Valorisation du stock (euros HT)';
graph_datas($file, $title, $values[7], $legends);
function graph_datas($file, $title, $values, $legends)
{
$graph = new Graph(800, 250);
$graph->title->set($title);
$graph->title->setFont(new Tuffy(10));
$graph->border->hide();
$color = new Color(244,244,244);
$graph->setAntiAliasing(TRUE);
$graph->setBackgroundColor( $color );
//$plot->yAxis->title->set("euros");
$plot = new LinePlot($values);
$plot->setSize(1, 0.96);
$plot->setCenter(0.5, 0.52);
// Change line color
$plot->setColor(new Color(0, 0, 150, 20));
// Set line background gradient
$plot->setFillGradient(
new LinearGradient(
new Color(150, 150, 210),
new Color(230, 230, 255),
90
)
);
$plot->xAxis->setLabelText($legends);
$plot->xAxis->label->setFont(new Tuffy(7));
$plot->grid->hideVertical(TRUE);
$plot->xAxis->setLabelInterval(31);
$graph->add($plot);
$graph->draw($file);
}
?>