diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php
index 6063c21a8d0..fd6e682b0fb 100644
--- a/htdocs/comm/propal/index.php
+++ b/htdocs/comm/propal/index.php
@@ -33,9 +33,8 @@ $langs->load("propal");
$langs->load("companies");
// Security check
-$socid='';
-if ($_GET["socid"]) { $socid=$_GET["socid"]; }
-if ($user->societe_id > 0)
+$socid=GETPOST('socid','int');
+if (isset($user->societe_id) && $user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
@@ -193,7 +192,7 @@ if ($conf->propal->enabled)
$companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas;
print '
'.$companystatic->getNomUrl(1,'customer',24).' | ';
-
+
print '';
$i++;
}
@@ -270,7 +269,7 @@ if ($resql)
$companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas;
print ''.$companystatic->getNomUrl(1,'customer').' | ';
-
+
print ''.dol_print_date($db->jdate($obj->datec),'day').' | ';
print ''.$propalstatic->LibStatut($obj->fk_statut,5).' | ';
print '';
@@ -285,10 +284,12 @@ else dol_print_error($db);
/*
* Opened proposals
*/
-if ($conf->propal->enabled && $user->rights->propale->lire)
+if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
{
$langs->load("propal");
+ $now=dol_now();
+
$sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
@@ -339,7 +340,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
print '';
print "";
-
+
$companystatic->id=$obj->socid;
$companystatic->name=$obj->socname;
$companystatic->client=$obj->client;
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index f8f9f361cd0..8da342ae7d6 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -244,20 +244,22 @@ if ($result)
$i = 0;
print '';
+ $moreforfilter='';
+
// If the user can view prospects other than his'
- if ($user->rights->societe->client->voir || $socid)
+ if ($user->rights->societe->client->voir || $socid) // TODO same of the second !!
{
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
$moreforfilter.=' ';
}
// If the user can view prospects other than his'
- if ($user->rights->societe->client->voir || $socid)
+ if ($user->rights->societe->client->voir || $socid) // TODO same of the first !!
{
$moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
$moreforfilter.=$form->select_dolusers($search_user,'search_user',1);
}
- if ($moreforfilter)
+ if (! empty($moreforfilter))
{
print '';
print '| ';
@@ -306,11 +308,13 @@ if ($result)
print " |
\n";
$var=true;
+ $total=0;
+ $subtotal=0;
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($result);
- $now = time();
+ $now = dol_now();
$var=!$var;
print '';
print '| ';
@@ -394,8 +398,8 @@ if ($result)
print " |
\n";
- $total = $total + $objp->total_ht;
- $subtotal = $subtotal + $objp->total_ht;
+ $total += $objp->total_ht;
+ $subtotal += $objp->total_ht;
$i++;
}
diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php
index c4058efea80..0617a1e5081 100644
--- a/htdocs/comm/propal/stats/index.php
+++ b/htdocs/comm/propal/stats/index.php
@@ -1,7 +1,7 @@
* Copyright (C) 2004-2011 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2005-2012 Regis Houssin
*
* 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
@@ -56,7 +56,7 @@ $langs->load("propal");
llxHeader();
-print_fiche_titre($langs->trans("ProposalsStatistics"), $mesg);
+print_fiche_titre($langs->trans("ProposalsStatistics"));
$dir=$conf->propal->dir_temp;
@@ -159,6 +159,8 @@ for ($i = 1 ; $i < 13 ; $i++)
$data[$i-1] = array(ucfirst(dol_substr(dol_print_date(dol_mktime(12,0,0,$i,1,$year),"%b"),0,3)), $res[$i]);
}
+$fileurl_avg='';
+if (! isset($mode)) $mode=''; // TODO $mode not defined ?
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png';
@@ -211,11 +213,12 @@ if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
$h=0;
$head = array();
-$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php';
+$head[$h][0] = DOL_URL_ROOT . '/comm/propal/stats/index.php';
$head[$h][1] = $langs->trans("ByMonthYear");
$head[$h][2] = 'byyear';
$h++;
+$object=(object) array(); // TODO $object not defined ?
complete_head_from_modules($conf,$langs,$object,$head,$h,'propal_stats');
dol_fiche_head($head,'byyear',$langs->trans("Statistics"));
@@ -261,7 +264,7 @@ $oldyear=0;
foreach ($data as $val)
{
$year = $val['year'];
- print $avg;
+ //print $avg; // TODO $avg not defined ?
while ($oldyear > $year+1)
{ // If we have empty year
$oldyear--;
diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php
index f9a0ef83b66..751102af621 100644
--- a/htdocs/core/class/stats.class.php
+++ b/htdocs/core/class/stats.class.php
@@ -1,6 +1,7 @@
- * Copyright (c) 2008-2012 Laurent Destailleur
+/* Copyright (C) 2003 Rodolphe Quiedeville
+ * Copyright (c) 2008-2012 Laurent Destailleur
+ * Copyright (C) 2012 Regis Houssin
*
* 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
@@ -176,7 +177,8 @@ abstract class Stats
*/
function _getNbByMonth($year, $sql)
{
- $result = array();
+ $result=array();
+ $res=array();
dol_syslog(get_class($this)."::_getNbByMonth sql=".$sql);
$resql=$this->db->query($sql);
@@ -200,7 +202,7 @@ abstract class Stats
for ($i = 1 ; $i < 13 ; $i++)
{
- $res[$i] = $result[$i] + 0;
+ $res[$i] = (isset($result[$i])?$result[$i]:0);
}
$data = array();
@@ -225,7 +227,8 @@ abstract class Stats
*/
function _getAmountByMonth($year, $sql)
{
- $result = array();
+ $result=array();
+ $res=array();
dol_syslog(get_class($this)."::_getAmountByMonth sql=".$sql);
@@ -247,7 +250,7 @@ abstract class Stats
for ($i = 1 ; $i < 13 ; $i++)
{
- $res[$i] = (int) round($result[$i]) + 0;
+ $res[$i] = (int) round((isset($result[$i])?$result[$i]:0));
}
$data = array();
@@ -271,7 +274,8 @@ abstract class Stats
*/
function _getAverageByMonth($year, $sql)
{
- $result = array();
+ $result=array();
+ $res=array();
dol_syslog(get_class($this)."::_getAverageByMonth sql=".$sql);
$resql=$this->db->query($sql);
@@ -292,7 +296,7 @@ abstract class Stats
for ($i = 1 ; $i < 13 ; $i++)
{
- $res[$i] = $result[$i] + 0;
+ $res[$i] = (isset($result[$i])?$result[$i]:0);
}
return $res;
diff --git a/htdocs/societe/societe.php b/htdocs/societe/societe.php
index 2403a204c02..3743efe1264 100644
--- a/htdocs/societe/societe.php
+++ b/htdocs/societe/societe.php
@@ -180,10 +180,13 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = s
if ($socid) $sql.= " AND s.rowid = ".$socid;
if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
if ($search_categ) $sql.= " AND s.rowid = cs.fk_societe"; // Join for the needed table to filter by categ
+// TODO $stcomm is not defined !
+/*
if (dol_strlen($stcomm))
{
$sql.= " AND s.fk_stcomm=".$stcomm;
}
+*/
if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
// Insert sale filter
if ($search_sale)