diff --git a/external-libs/Artichow/LinePlot.class.php b/external-libs/Artichow/LinePlot.class.php new file mode 100644 index 00000000000..6476e41ffbe --- /dev/null +++ b/external-libs/Artichow/LinePlot.class.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php new file mode 100644 index 00000000000..1ff494b6880 --- /dev/null +++ b/htdocs/product/stock/fiche-valo.php @@ -0,0 +1,128 @@ + + * + * 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 ''; + + // Ref + print ''; + + print ''; + + // Description + print ''; + + print ''; + + print ''; + print ''; + + print ''; + + // Statut + print ''; + + print '"; + print "
'.$langs->trans("Ref").''.$entrepot->libelle.'
'.$langs->trans("LocationSummary").''.$entrepot->lieu.'
'.$langs->trans("Description").''.nl2br($entrepot->description).'
'.$langs->trans('Address').''; + print $entrepot->address; + print '
'.$langs->trans('Zip').''.$entrepot->cp.''.$langs->trans('Town').''.$entrepot->ville.'
'.$langs->trans('Country').''; + print $entrepot->pays; + print '
'.$langs->trans("Status").''.$entrepot->getLibStatut(4).'
'.$langs->trans("NumberOfProducts").''; + print $entrepot->nb_products(); + print "
"; + print ''; + + + /* ************************************************************************** */ + /* */ + /* Graph */ + /* */ + /* ************************************************************************** */ + + print "
\n"; + + $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file=entrepot-'.$entrepot->id.'.png'; + + print ''; + print "
"; +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/scripts/cron/stock-graph.php b/scripts/cron/stock-graph.php new file mode 100644 index 00000000000..eccbe40ce02 --- /dev/null +++ b/scripts/cron/stock-graph.php @@ -0,0 +1,138 @@ + + * + * 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); +} +?>