Nouveau fichier
This commit is contained in:
parent
c9740c42f8
commit
5594613e4c
149
htdocs/fourn/fiche-stats.php
Normal file
149
htdocs/fourn/fiche-stats.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Éric Seigne <erics@rycks.com>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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/fourn/fiche.php
|
||||
\ingroup fournisseur, facture
|
||||
\brief Page de fiche fournisseur
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require('./pre.inc.php');
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
||||
|
||||
$langs->load('suppliers');
|
||||
$langs->load('products');
|
||||
$langs->load('bills');
|
||||
$langs->load('orders');
|
||||
$langs->load('companies');
|
||||
$langs->load('commercial');
|
||||
|
||||
// Sécurité accés client
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
if (! $socid) accessforbidden();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// Protection restriction commercial
|
||||
if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0)
|
||||
{
|
||||
$sql = "SELECT sc.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_soc = s.idp AND sc.fk_user = ".$user->id." AND s.fournisseur = 1";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
if ( $db->num_rows() == 0) accessforbidden();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Mode fiche
|
||||
*/
|
||||
$societe = new Fournisseur($db);
|
||||
|
||||
if ( $societe->fetch($socid) )
|
||||
{
|
||||
$addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid;
|
||||
$addons[0][1] = $societe->nom;
|
||||
|
||||
llxHeader('',$langs->trans('SupplierCard').' : '.$societe->nom, $addons);
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = societe_prepare_head($societe);
|
||||
|
||||
dolibarr_fiche_head($head, 'supplierstat', $societe->nom);
|
||||
|
||||
|
||||
print '<table width="100%">';
|
||||
print '<tr><td valign="top" width="50%">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans("Name").'</td><td width="80%" colspan="3">'.$societe->nom.'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$societe->prefix_comm.'</td></tr>';
|
||||
|
||||
if ($societe->fournisseur)
|
||||
{
|
||||
print '<tr><td nowrap="nowrap">';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
print $societe->code_fournisseur;
|
||||
if ($societe->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode");
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">'.nl2br($societe->adresse).'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Zip").'</td><td>'.$societe->cp.'</td>';
|
||||
print '<td>'.$langs->trans("Town").'</td><td>'.$societe->ville.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'.$societe->pays.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Phone").'</td><td>'.dolibarr_print_phone($societe->tel).' </td><td>'.$langs->trans("Fax").'</td><td>'.dolibarr_print_phone($societe->fax).' </td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\"><a href=\"http://$societe->url\">$societe->url</a> </td></tr>";
|
||||
|
||||
// Assujeti à TVA ou pas
|
||||
print '<tr>';
|
||||
print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">';
|
||||
print yn($societe->tva_assuj);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
$file = get_exdir($societe->id, 3) . "ca_genere-".$societe->id.".png";
|
||||
$year = strftime("%Y",time());
|
||||
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_fourn&file='.$file;
|
||||
print '<img src="'.$url.'" alt="CA genere">';
|
||||
|
||||
|
||||
|
||||
print '</td></tr>';
|
||||
print '</table>' . "\n";
|
||||
print '</div>';
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
162
scripts/cron/fournisseur-graph.php
Normal file
162
scripts/cron/fournisseur-graph.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?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$
|
||||
*
|
||||
*
|
||||
* Crée les graphiques pour les fournisseurs
|
||||
*
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
$dir = DOL_DATA_ROOT."/graph/fournisseur";
|
||||
if (!is_dir($dir) )
|
||||
{
|
||||
if (! @mkdir($dir,0755))
|
||||
{
|
||||
die ("Can't create $dir\n");
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
$sql = "SELECT distinct(fk_societe)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."fournisseur_ca";
|
||||
|
||||
$resql = $db->query($sql) ;
|
||||
$fournisseurs = array();
|
||||
if ($resql)
|
||||
{
|
||||
while ($row = $db->fetch_row($resql))
|
||||
{
|
||||
$fdir = $dir.'/'.get_exdir($row[0],3);
|
||||
print $fdir."\n";
|
||||
create_exdir($fdir);
|
||||
$fournisseurs[$row[0]] = $fdir;
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $sql;
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
foreach ($fournisseurs as $id => $fdir)
|
||||
{
|
||||
$values = array();
|
||||
$legends = array();
|
||||
$sql = "SELECT year, ca_genere";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."fournisseur_ca";
|
||||
$sql .= " WHERE fk_societe = $id";
|
||||
$sql .= " ORDER BY year ASC";
|
||||
|
||||
$resql = $db->query($sql) ;
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
while ($row = $db->fetch_row($resql))
|
||||
{
|
||||
$values[$i] = $row[1];
|
||||
$legends[$i] = $row[0];
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $sql;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/BarPlot.class.php";
|
||||
|
||||
$file = $fdir ."ca_genere-".$id.".png";
|
||||
$title = "CA généré en euros HT";
|
||||
|
||||
graph_datas($file, $title, $values, $legends);
|
||||
if ($verbose)
|
||||
print "$file\n";
|
||||
}
|
||||
|
||||
function graph_datas($file, $title, $values, $legends)
|
||||
{
|
||||
|
||||
$graph = new Graph(500, 200);
|
||||
$graph->title->set($title);
|
||||
$graph->title->setFont(new Tuffy(10));
|
||||
|
||||
$graph->border->hide();
|
||||
|
||||
$color = new Color(222,231,236);
|
||||
|
||||
$graph->setAntiAliasing(TRUE);
|
||||
$graph->setBackgroundColor( $color );
|
||||
|
||||
//$plot->yAxis->title->set("euros");
|
||||
|
||||
$plot = new BarPlot($values);
|
||||
|
||||
|
||||
$plot->setBarGradient(
|
||||
new LinearGradient(
|
||||
new Color(244,244,244),
|
||||
new Color(222,231,236),
|
||||
90
|
||||
)
|
||||
);
|
||||
|
||||
$plot->setSpace(5, 5, NULL, NULL);
|
||||
|
||||
$plot->barShadow->setSize(4);
|
||||
$plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
|
||||
$plot->barShadow->setColor(new Color(180, 180, 180, 10));
|
||||
$plot->barShadow->smooth(TRUE);
|
||||
|
||||
|
||||
$plot->xAxis->setLabelText($legends);
|
||||
$plot->xAxis->label->setFont(new Tuffy(7));
|
||||
|
||||
$graph->add($plot);
|
||||
|
||||
$graph->draw($file);
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user