diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index a35c03076cb..6183207e115 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -35,7 +35,33 @@ $socid = isset($_GET["socid"])?$_GET["socid"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +$limit = $conf->liste_limit; +if (! $sortfield) $sortfield="t.datev"; +if (! $sortorder) $sortorder="DESC"; +$filtre=$_GET["filtre"]; + +if (empty($_REQUEST['typeid'])) +{ + $newfiltre=str_replace('filtre=','',$filtre); + $filterarray=explode('-',$newfiltre); + foreach($filterarray as $val) + { + $part=explode(':',$val); + if ($part[0] == 't.fk_typepayment') $typeid=$part[1]; + } +} +else +{ + $typeid=$_REQUEST['typeid']; +} /* * View @@ -43,15 +69,25 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); llxHeader(); +$form = new Form($db); $tva_static = new Tva($db); -print_fiche_titre($langs->trans("VATPayments")); - -$sql = "SELECT t.rowid, t.amount, t.label, t.datev as dm, t.num_payment, pst.code as payment_code"; +$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"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id"; $sql.= " WHERE t.entity = ".$conf->entity; -$sql.= " ORDER BY dm DESC"; +if (GETPOST("search_label")) $sql.=" AND t.label LIKE '%".$db->escape(GETPOST("search_label"))."%'"; +if (GETPOST("search_amount")) $sql.=" AND t.amount = ".price2num(GETPOST("search_amount")); +if ($filtre) { + $filtre=str_replace(":","=",$filtre); + $sql .= " AND ".$filtre; +} +if ($typeid) { + $sql .= " AND t.fk_typepayment=".$typeid; +} +$sql.= " GROUP BY t.rowid, t.fk_typepayment, t.amount, t.datev, t.label"; +$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->plimit($limit+1,$offset); $result = $db->query($sql); if ($result) @@ -59,20 +95,55 @@ if ($result) $num = $db->num_rows($result); $i = 0; $total = 0 ; + $var=true; + + $param=''; + if ($typeid) $param.='&typeid='.$typeid; + + print_barre_liste($langs->trans("VATPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines); + + dol_htmloutput_mesg($mesg); + + print '
'; print ''; print ''; - print ''; - print ""; - print ''; - print ''; - print ""; - print "\n"; - $var=1; - while ($i < $num) + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"t.rowid","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"t.label","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"dm","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"t.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre(""); + print "\n"; + + print ''; + print ''; + print ''; + print ''; + // Type + print ''; + print ''; + print ''; + print "\n"; + + while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); $var=!$var; + + if ($obj->payment_code <> '') + { + $type = ''; + } + else + { + $type = ''; + } + print ""; $tva_static->id=$obj->rowid; @@ -81,18 +152,23 @@ if ($result) print "\n"; print '\n"; // Type - print ''; + print $type; // Amount $total = $total + $obj->amount; print ""; + print ""; print "\n"; $i++; } print ''; - print ""; + print ""; + print ""; print "
'.$langs->trans("Ref").'".$langs->trans("Label")."'.$langs->trans("DatePayment").''.$langs->trans("Type").'".$langs->trans("PayedByThisPayment")."
  '; + $form->select_types_paiements($typeid,'typeid','',0,0,1,16); + print ''; + print ''; + print '
'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.' 
".dol_trunc($obj->label,40)."'.dol_print_date($db->jdate($obj->dm),'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'".price($obj->amount)." 
'.$langs->trans("Total").'".price($total)."
".price($total)." 
"; + + print '
'; + $db->free($result); } else