diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 8cdf538126a..d6fd80e47fe 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -8,6 +8,7 @@ * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2015 Marcos GarcĂ­a * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2017 Alexandre Spangaro * * 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 @@ -33,18 +34,23 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load('companies'); $langs->load('bills'); $langs->load('banks'); $langs->load('compta'); -$action = GETPOST('action','alpha'); +// Security check +$action = GETPOST('action','alpha'); $confirm = GETPOST('confirm'); - -$facid=GETPOST('facid','int'); -$socid=GETPOST('socid','int'); +$facid = GETPOST('facid','int'); +$socid = GETPOST('socid','int'); $accountid = GETPOST('accountid'); +$day = GETPOST('day','int'); +$month = GETPOST('month','int'); +$year = GETPOST('year','int'); $search_ref=GETPOST("search_ref","int"); $search_account=GETPOST("search_account","int"); @@ -316,6 +322,7 @@ $invoicesupplierstatic = new FactureFournisseur($db); llxHeader('',$langs->trans('ListPayment')); $form=new Form($db); +$formother=new FormOther($db); if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') { @@ -747,6 +754,19 @@ if (empty($action)) if (!$user->rights->societe->client->voir) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid > 0) $sql .= ' AND f.fk_soc = '.$socid; // Search criteria + if ($month > 0) + { + 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 p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + } if ($search_ref) $sql .= natural_search('p.rowid', $search_ref); if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($search_paymenttype != "") $sql .=" AND c.code='".$db->escape($search_paymenttype)."'"; @@ -776,6 +796,9 @@ if (empty($action)) $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($day) $param.=($day?"&day=".urlencode($day):""); + if ($month) $param.=($month?"&month=".urlencode($month):""); + if ($year) $param.=($year?"&year=".urlencode($year):""); if ($search_ref) $param.=($search_ref?"&search_ref=".urlencode($search_ref):""); if ($search_company) $param.=($search_company?"&search_company=".urlencode($search_company):""); if ($search_amount != '') $param.=($search_amount?"&search_amount=".urlencode($search_amount):""); @@ -826,7 +849,11 @@ if (empty($action)) print ''; print ''; print ''; - print ' '; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year?$year:-1,'year',1, 20, 5); + print ''; print ''; print ''; print ''; @@ -849,14 +876,14 @@ if (empty($action)) print "\n"; print ''; - print_liste_field_titre('RefPayment',$_SERVER["PHP_SELF"],'p.rowid','',$param,'',$sortfield,$sortorder); - print_liste_field_titre('Date',$_SERVER["PHP_SELF"],'dp','',$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre('ThirdParty',$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder); - print_liste_field_titre('Type',$_SERVER["PHP_SELF"],'c.libelle','',$param,'',$sortfield,$sortorder); + print_liste_field_titre("RefPayment",$_SERVER["PHP_SELF"],'p.rowid','',$param,'',$sortfield,$sortorder); + print_liste_field_titre("Date",$_SERVER["PHP_SELF"],'dp','',$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder); + print_liste_field_titre("Type",$_SERVER["PHP_SELF"],'c.libelle','',$param,'',$sortfield,$sortorder); print_liste_field_titre("Numero",$_SERVER["PHP_SELF"],"p.num_paiement","",$param,"",$sortfield,$sortorder); - print_liste_field_titre('Account',$_SERVER["PHP_SELF"],'ba.label','',$param,'',$sortfield,$sortorder); - print_liste_field_titre('Amount',$_SERVER["PHP_SELF"],'p.amount','',$param,'align="right"',$sortfield,$sortorder); - //print_liste_field_titre('Invoice',$_SERVER["PHP_SELF"],'ref_supplier','',$param,'',$sortfield,$sortorder); + print_liste_field_titre("Account",$_SERVER["PHP_SELF"],'ba.label','',$param,'',$sortfield,$sortorder); + print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],'p.amount','',$param,'align="right"',$sortfield,$sortorder); + //print_liste_field_titre("Invoice",$_SERVER["PHP_SELF"],'ref_supplier','',$param,'',$sortfield,$sortorder); print_liste_field_titre(''); print "\n";