diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index 45a69076492..14cdedc821c 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -26,6 +26,8 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load("compta"); $langs->load("bills"); @@ -38,6 +40,8 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); $search_ref = GETPOST('search_ref','int'); $search_label = GETPOST('search_label','alpha'); $search_amount = GETPOST('search_amount','alpha'); +$month = GETPOST("month","int"); +$year = GETPOST("year","int"); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -71,6 +75,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_ref=""; $search_label=""; $search_amount=""; + $year=""; + $month=""; $typeid=""; } @@ -81,6 +87,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both llxHeader(); $form = new Form($db); +$formother=new FormOther($db); $tva_static = new Tva($db); $sql = "SELECT t.rowid, t.amount, t.label, t.datev as dm, t.fk_typepayment as type, t.num_payment, pst.code as payment_code"; @@ -90,6 +97,17 @@ $sql.= " WHERE t.entity = ".$conf->entity; if ($search_ref) $sql.=" AND t.rowid=".$search_ref; if ($search_label) $sql.=" AND t.label LIKE '%".$db->escape($search_label)."%'"; if ($search_amount) $sql.=" AND t.amount='".$db->escape(price2num(trim($search_amount)))."'"; +if ($month > 0) +{ + if ($year > 0) + $sql.= " AND t.datev 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(t.datev, '%m') = '$month'"; +} +else if ($year > 0) +{ + $sql.= " AND t.datev BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; +} if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; @@ -119,7 +137,7 @@ if ($result) print '