diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index c6de90c89f3..22f7e9da50b 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -193,14 +193,16 @@ if ($viewstatut <> '')
}
if ($month > 0)
{
- if ($year > 0)
- $sql.= " AND date_format(p.datep, '%Y-%m') = '".$year."-".$month."'";
- else
- $sql.= " AND date_format(p.datep, '%m') = '".$month."'";
+ if ($year > 0 && empty($day))
+ $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
+ else if ($year > 0 && ! empty($day))
+ $sql.= " AND p.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
+ else
+ $sql.= " AND date_format(p.datep, '%m') = '".$month."'";
}
else if ($year > 0)
{
- $sql.= " AND date_format(p.datep, '%Y') = '".$year."'";
+ $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($search_user > 0)
{
@@ -235,6 +237,7 @@ if ($result)
$i = 0;
print '
';
+
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid)
{
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index b2f625d972e..0a779607eb0 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -3231,6 +3231,7 @@ else
$pageprev = $page - 1;
$pagenext = $page + 1;
+ $search_user = GETPOST('search_user','int');
$day = GETPOST('day','int');
$month = GETPOST('month','int');
$year = GETPOST('year','int');
@@ -3249,6 +3250,11 @@ else
$sql.= ', '.MAIN_DB_PREFIX.'facture as f';
if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
else $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as fd ON fd.fk_facture = f.rowid';
+ if ($search_user > 0)
+ {
+ $sql.=", ".MAIN_DB_PREFIX."element_contact as c";
+ $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
+ }
$sql.= ' WHERE f.fk_soc = s.rowid';
$sql.= " AND f.entity = ".$conf->entity;
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
@@ -3296,6 +3302,10 @@ else
{
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
+ if ($search_user > 0)
+ {
+ $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = f.rowid AND c.fk_socpeople = ".$search_user;
+ }
if (! $sall)
{
$sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.increment, f.total, f.total_ttc,';
@@ -3332,8 +3342,23 @@ else
print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->nom:''),$page,'facture.php',$param,$sortfield,$sortorder,'',$num);
$i = 0;
- print '