diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index c9732bf454d..75d7e19370e 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -37,6 +37,7 @@ require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php');
require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php');
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php');
+require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php');
@@ -3548,13 +3549,13 @@ else
if ($month > 0)
{
if ($year > 0)
- $sql.= " AND date_format(f.datef, '%Y-%m') = '$year-$month'";
+ $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
else
$sql.= " AND date_format(f.datef, '%m') = '$month'";
}
- if ($year > 0)
+ else if ($year > 0)
{
- $sql.= ' AND date_format(f.datef, \'%Y\') = '.$year;
+ $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 ($_POST['sf_ref'])
{
@@ -3567,10 +3568,8 @@ else
$sql.= ' ORDER BY ';
$listfield=explode(',',$sortfield);
- foreach ($listfield as $key => $value)
- $sql.= $listfield[$key].' '.$sortorder.',';
+ foreach ($listfield as $key => $value) $sql.= $listfield[$key].' '.$sortorder.',';
$sql.= ' f.rowid DESC ';
-
$sql.= $db->plimit($limit+1,$offset);
$resql = $db->query($sql);
@@ -3671,23 +3670,9 @@ else
print "\n";
// Date
- if ($objp->df > 0)
- {
- $y = dol_print_date($db->jdate($objp->df),'%Y');
- $m = dol_print_date($db->jdate($objp->df),'%m');
- $mt = dol_print_date($db->jdate($objp->df),'%b');
- $d = dol_print_date($db->jdate($objp->df),'%d');
- print '
';
- print $d;
- print ' ';
- print $mt.'';
- print ' ';
- print $y.' | ';
- }
- else
- {
- print '!!! | ';
- }
+ print '';
+ print dol_print_date($db->jdate($objp->df),'day');
+ print ' | ';
// Date limit
print ''.dol_print_date($datelimit,'day');
diff --git a/htdocs/compta/paiement/liste.php b/htdocs/compta/paiement/liste.php
index 519d0a743f2..80cd3f142dd 100644
--- a/htdocs/compta/paiement/liste.php
+++ b/htdocs/compta/paiement/liste.php
@@ -36,18 +36,10 @@ $facid = isset($_GET["facid"])?$_GET["facid"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'facture',$facid,'');
-
$paymentstatic=new Paiement($db);
$accountstatic=new Account($db);
$companystatic=new Societe($db);
-
-/*
-* View
-*/
-
-llxHeader('',$langs->trans("ListPayment"));
-
$page=$_GET["page"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
@@ -57,7 +49,16 @@ $offset = $limit * $page ;
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="p.rowid";
-$sql = "SELECT DISTINCT p.rowid,".$db->pdate("p.datep")." as dp, p.amount,";
+
+
+
+/*
+* View
+*/
+
+llxHeader('',$langs->trans("ListPayment"));
+
+$sql = "SELECT DISTINCT p.rowid, p.datep as dp, p.amount,";
$sql.= " p.statut, p.num_paiement,";
//$sql.= " c.libelle as paiement_type,";
$sql.= " c.code as paiement_code,";
@@ -84,15 +85,24 @@ if ($socid)
{
$sql.= " AND f.fk_soc = ".$socid;
}
-if ($_GET["search_montant"])
+// Search criteria
+if ($_REQUEST["search_ref"])
{
- $sql .=" AND p.amount=".price2num($_GET["search_montant"]);
+ $sql .=" AND p.rowid=".$_REQUEST["search_ref"];
+}
+if ($_REQUEST["search_amount"])
+{
+ $sql .=" AND p.amount=".price2num($_REQUEST["search_amount"]);
+}
+if ($_REQUEST["search_company"])
+{
+ $sql .=" AND s.nom like '%".addslashes($_REQUEST["search_company"])."%'";
}
if ($_GET["orphelins"]) // Option for debugging purpose only
{
- // Paiements li�s � aucune facture (pour aide au diagnostic)
- $sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, p.amount,";
+ // Paiements lies a aucune facture (pour aide au diagnostic)
+ $sql = "SELECT p.rowid, p.datep as dp, p.amount,";
$sql.= " p.statut, p.num_paiement,";
//$sql.= " c.libelle as paiement_type";
$sql.= " c.code as paiement_code,";
@@ -105,8 +115,7 @@ if ($_GET["orphelins"]) // Option for debugging purpose only
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND pf.rowid IS NULL";
}
-$sql.= " ORDER BY ".$sortfield." ".$sortorder;
-//$sql.= ", facnumber ASC";
+$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit( $limit+1 ,$offset);
//print "$sql";
@@ -117,10 +126,15 @@ if ($resql)
$num = $db->num_rows($resql);
$i = 0;
- $paramlist=($_GET["orphelins"]?"&orphelins=1":"");
+ $paramlist='';
+ $paramlist.=($_REQUEST["orphelins"]?"&orphelins=1":"");
+ $paramlist.=($_REQUEST["search_ref"]?"&search_ref=".$_REQUEST["search_ref"]:"");
+ $paramlist.=($_REQUEST["search_company"]?"&search_company=".$_REQUEST["search_company"]:"");
+ $paramlist.=($_REQUEST["search_amount"]?"&search_amount=".$_REQUEST["search_amount"]:"");
+
print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, "liste.php",$paramlist,$sortfield,$sortorder,'',$num);
- print ' |