diff --git a/htdocs/fourn/fiche-stats.php b/htdocs/fourn/fiche-stats.php new file mode 100644 index 00000000000..147624e90ca --- /dev/null +++ b/htdocs/fourn/fiche-stats.php @@ -0,0 +1,149 @@ + + * Copyright (C) 2003 Éric Seigne + * Copyright (C) 2004-2006 Laurent Destailleur + * + * 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 ''; + print ''; + print '
'; + + print ''; + print ''; + + print ''; + + if ($societe->fournisseur) + { + print ''; + } + + print ''; + + print ''; + print ''; + print ''; + print ''; + print '"; + + // Assujeti à TVA ou pas + print ''; + print ''; + print ''; + + print '
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'; + print $langs->trans('SupplierCode').''; + print $societe->code_fournisseur; + if ($societe->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode"); + print '
'.$langs->trans("Address").''.nl2br($societe->adresse).'
'.$langs->trans("Zip").''.$societe->cp.''.$langs->trans("Town").''.$societe->ville.'
'.$langs->trans("Country").''.$societe->pays.'
'.$langs->trans("Phone").''.dolibarr_print_phone($societe->tel).' '.$langs->trans("Fax").''.dolibarr_print_phone($societe->fax).' 
'.$langs->trans("Web")."url\">$societe->url 
'.$langs->trans('VATIsUsed').''; + print yn($societe->tva_assuj); + print '
'; + + + print '
'; + + $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 'CA genere'; + + + + print '
' . "\n"; + print ''; + + + +} +else +{ + dolibarr_print_error($db); +} +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/scripts/cron/fournisseur-graph.php b/scripts/cron/fournisseur-graph.php new file mode 100644 index 00000000000..4910611696a --- /dev/null +++ b/scripts/cron/fournisseur-graph.php @@ -0,0 +1,162 @@ + + * + * 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); +} +?>