TVA :: Add sortfield & search
This commit is contained in:
parent
c6e2afb11e
commit
3b265c8d53
@ -35,7 +35,33 @@ $socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
|||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
$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
|
* View
|
||||||
@ -43,15 +69,25 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
|
|||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
$tva_static = new Tva($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.fk_typepayment as type, t.num_payment, pst.code as payment_code";
|
||||||
|
|
||||||
$sql = "SELECT t.rowid, t.amount, t.label, t.datev as dm, t.num_payment, pst.code as payment_code";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
|
$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.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id";
|
||||||
$sql.= " WHERE t.entity = ".$conf->entity;
|
$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);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
@ -59,20 +95,55 @@ if ($result)
|
|||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$total = 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 '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td class="nowrap" align="left">'.$langs->trans("Ref").'</td>';
|
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"t.rowid","",$param,"",$sortfield,$sortorder);
|
||||||
print "<td>".$langs->trans("Label")."</td>";
|
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"t.label","",$param,'align="left"',$sortfield,$sortorder);
|
||||||
print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>';
|
print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"dm","",$param,'align="left"',$sortfield,$sortorder);
|
||||||
print '<td class="nowrap" align="left">'.$langs->trans("Type").'</td>';
|
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder);
|
||||||
print "<td align=\"right\">".$langs->trans("PayedByThisPayment")."</td>";
|
print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"t.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre("");
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$var=1;
|
|
||||||
while ($i < $num)
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td class="liste_titre"> </td>';
|
||||||
|
print '<td class="liste_titre"><input type="text" class="flat" size="14" name="search_label" value="'.GETPOST("search_label").'"></td>';
|
||||||
|
print '<td class="liste_titre"> </td>';
|
||||||
|
// Type
|
||||||
|
print '<td class="liste_titre" align="left">';
|
||||||
|
$form->select_types_paiements($typeid,'typeid','',0,0,1,16);
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="liste_titre" align="right"><input name="search_amount" class="flat" type="text" size="8" value="'.GETPOST("search_amount").'"></td>';
|
||||||
|
print '<td class="liste_titre" align="right">';
|
||||||
|
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||||
|
print '</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
while ($i < min($num,$limit))
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
|
if ($obj->payment_code <> '')
|
||||||
|
{
|
||||||
|
$type = '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$type = '<td> </td>';
|
||||||
|
}
|
||||||
|
|
||||||
print "<tr ".$bc[$var].">";
|
print "<tr ".$bc[$var].">";
|
||||||
|
|
||||||
$tva_static->id=$obj->rowid;
|
$tva_static->id=$obj->rowid;
|
||||||
@ -81,18 +152,23 @@ if ($result)
|
|||||||
print "<td>".dol_trunc($obj->label,40)."</td>\n";
|
print "<td>".dol_trunc($obj->label,40)."</td>\n";
|
||||||
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
|
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
|
||||||
// Type
|
// Type
|
||||||
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
|
print $type;
|
||||||
// Amount
|
// Amount
|
||||||
$total = $total + $obj->amount;
|
$total = $total + $obj->amount;
|
||||||
print "<td align=\"right\">".price($obj->amount)."</td>";
|
print "<td align=\"right\">".price($obj->amount)."</td>";
|
||||||
|
print "<td> </td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Total").'</td>';
|
print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Total").'</td>';
|
||||||
print "<td align=\"right\"><b>".price($total)."</b></td></tr>";
|
print "<td align=\"right\"><b>".price($total)."</b></td>";
|
||||||
|
print "<td> </td></tr>";
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
|
print '</form>';
|
||||||
|
|
||||||
$db->free($result);
|
$db->free($result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user