[ bug #512 ] Filter system not working in banks > account > transactions
Conflicts: htdocs/compta/bank/account.php
This commit is contained in:
parent
fe76902342
commit
e121ab8c86
@ -48,6 +48,7 @@ $fieldtype = (! empty($ref) ? 'ref' :'rowid');
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result=restrictedArea($user,'banque',$fieldvalue,'bank_account','','',$fieldtype);
|
||||
|
||||
$paiementtype=GETPOST('paiementtype','alpha',3);
|
||||
$req_nb=GETPOST("req_nb",'',3);
|
||||
$thirdparty=GETPOST("thirdparty",'',3);
|
||||
$vline=GETPOST("vline");
|
||||
@ -78,17 +79,17 @@ if ($action == 'add' && $id && ! isset($_POST["cancel"]) && $user->rights->banqu
|
||||
{
|
||||
$amount = - price2num($_POST["debit"]);
|
||||
}
|
||||
|
||||
|
||||
$dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]);
|
||||
$operation=$_POST["operation"];
|
||||
$num_chq=$_POST["num_chq"];
|
||||
$label=$_POST["label"];
|
||||
$cat1=$_POST["cat1"];
|
||||
|
||||
|
||||
if (! $dateop) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Date"));
|
||||
if (! $operation) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Type"));
|
||||
if (! $amount) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Amount"));
|
||||
|
||||
|
||||
if (! $mesg)
|
||||
{
|
||||
$object->fetch($id);
|
||||
@ -143,15 +144,15 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
$result=$object->fetch($id, $ref);
|
||||
|
||||
|
||||
// Chargement des categories bancaires dans $options
|
||||
$nbcategories=0;
|
||||
|
||||
|
||||
$sql = "SELECT rowid, label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ";
|
||||
$sql.= " WHERE entity = ".$conf->entity;
|
||||
$sql.= " ORDER BY label";
|
||||
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
@ -168,7 +169,7 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
|
||||
|
||||
// Definition de sql_rech et param
|
||||
$param='';
|
||||
$sql_rech='';
|
||||
@ -203,13 +204,13 @@ if ($id > 0 || ! empty($ref))
|
||||
$param.='&thirdparty='.urlencode($thirdparty);
|
||||
$mode_search = 1;
|
||||
}
|
||||
if (GETPOST("paiementtype"))
|
||||
if ($paiementtype)
|
||||
{
|
||||
$sql_rech.=" AND b.fk_type = '".$db->escape(GETPOST("paiementtype"))."'";
|
||||
$param.='&paiementtype='.urlencode(GETPOST("paiementtype"));
|
||||
$sql_rech.=" AND b.fk_type = '".$db->escape($paiementtype)."'";
|
||||
$param.='&paiementtype='.urlencode($paiementtype);
|
||||
$mode_search = 1;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT count(*) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."bank as b";
|
||||
@ -222,7 +223,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$sql.= " AND b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity = ".$conf->entity;
|
||||
$sql.= $sql_rech;
|
||||
|
||||
|
||||
dol_syslog("account.php count transactions - sql=".$sql, LOG_DEBUG);
|
||||
$result=$db->query($sql);
|
||||
if ($result)
|
||||
@ -230,7 +231,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$obj = $db->fetch_object($result);
|
||||
$nbline = $obj->nb;
|
||||
$total_lines = $nbline;
|
||||
|
||||
|
||||
if ($nbline > $viewline ) $limit = $nbline - $viewline ;
|
||||
else $limit = $viewline;
|
||||
|
||||
@ -240,7 +241,7 @@ if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
if ($page > 0)
|
||||
{
|
||||
$limitsql = $nbline - ($page * $viewline);
|
||||
@ -253,34 +254,34 @@ if ($id > 0 || ! empty($ref))
|
||||
$limitsql = $nbline;
|
||||
}
|
||||
//print $limitsql.'-'.$page.'-'.$viewline;
|
||||
|
||||
|
||||
// Onglets
|
||||
$head=bank_prepare_head($object);
|
||||
dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account');
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
|
||||
// Ref
|
||||
print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $form->showrefnav($object,'ref','',1,'ref');
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Label
|
||||
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
|
||||
print '<td colspan="3">'.$object->label.'</td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
|
||||
/**
|
||||
* Search form
|
||||
*/
|
||||
$param.='&account='.$object->id;
|
||||
|
||||
|
||||
// Define transaction list navigation string
|
||||
$navig='';
|
||||
$navig.='<form action="'.$_SERVER["PHP_SELF"].'" name="newpage" method="GET">';
|
||||
@ -289,6 +290,7 @@ if ($id > 0 || ! empty($ref))
|
||||
if ($limitsql > $viewline) $navig.='<a href="account.php?'.$param.'&page='.($page+1).'">'.img_previous().'</a>';
|
||||
$navig.= $langs->trans("Page")." "; // ' Page ';
|
||||
$navig.='<input type="text" name="negpage" size="1" class="flat" value="'.($nbpage-$page).'">';
|
||||
$navig.='<input type="hidden" name="paiementtype" value="'.$paiementtype.'">';
|
||||
$navig.='<input type="hidden" name="req_nb" value="'.$req_nb.'">';
|
||||
$navig.='<input type="hidden" name="req_desc" value="'.GETPOST("req_desc").'">';
|
||||
$navig.='<input type="hidden" name="req_debit" value="'.GETPOST("req_debit").'">';
|
||||
@ -303,7 +305,7 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
$navig.='</form>';
|
||||
//var_dump($navig);
|
||||
|
||||
|
||||
// Confirmation delete
|
||||
if ($action == 'delete')
|
||||
{
|
||||
@ -311,15 +313,15 @@ if ($id > 0 || ! empty($ref))
|
||||
$ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.$_GET["rowid"],$langs->trans('DeleteTransaction'),$text,'confirm_delete');
|
||||
if ($ret == 'html') print '<br>';
|
||||
}
|
||||
|
||||
|
||||
print '<table class="notopnoleftnoright" width="100%">';
|
||||
|
||||
|
||||
// Show title
|
||||
if ($action != 'addline' && $action != 'delete')
|
||||
{
|
||||
print '<tr><td colspan="9" align="right">'.$navig.'</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Form to add a transaction with no invoice
|
||||
if ($user->rights->banque->modifier && $action == 'addline')
|
||||
{
|
||||
@ -328,11 +330,11 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="vline" value="'.$vline.'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
|
||||
|
||||
print '<tr>';
|
||||
print '<td align="left" colspan="10"><b>'.$langs->trans("AddBankRecordLong").'</b></td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td> </td>';
|
||||
@ -343,7 +345,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<td align=right>'.$langs->trans("Credit").'</td>';
|
||||
print '<td colspan="2" align="center"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
print '<tr '.$bc[false].'>';
|
||||
print '<td nowrap="nowrap" colspan="2">';
|
||||
$form->select_date($dateop,'op',0,0,0,'transaction');
|
||||
@ -366,14 +368,14 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
|
||||
print '</td></tr>';
|
||||
print "</form>";
|
||||
|
||||
|
||||
print '<tr class="noborder"><td colspan="8"> </td></tr>'."\n";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Affiche tableau des transactions bancaires
|
||||
*/
|
||||
|
||||
|
||||
// Ligne de titre tableau des ecritures
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
@ -389,19 +391,19 @@ if ($id > 0 || ! empty($ref))
|
||||
if ($object->type != 2 && $object->rappro) print $langs->trans("AccountStatementShort");
|
||||
else print ' ';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?'.$param.'" name="search" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="search">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td>';
|
||||
//$filtertype=array('TIP'=>'TIP','PRE'=>'PRE',...)
|
||||
$filtertype='';
|
||||
print $form->select_types_paiements($_REQUEST['paiementtype'],'paiementtype',$filtertype,2,1,1,8);
|
||||
print $form->select_types_paiements($paiementtype,'paiementtype',$filtertype,2,1,1,8);
|
||||
print '</td>';
|
||||
print '<td><input type="text" class="flat" name="req_nb" value="'.$req_nb.'" size="2"></td>';
|
||||
print '<td><input type="text" class="flat" name="req_desc" value="'.GETPOST("req_desc").'" size="24"></td>';
|
||||
@ -412,13 +414,13 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<td align="center" width="40"><input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>';
|
||||
print "</tr>\n";
|
||||
print "</form>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Another solution
|
||||
* create temporary table solde type=heap select amount from llx_bank limit 100 ;
|
||||
* select sum(amount) from solde ;
|
||||
*/
|
||||
|
||||
|
||||
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,";
|
||||
$sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type";
|
||||
if ($mode_search)
|
||||
@ -428,11 +430,11 @@ if ($id > 0 || ! empty($ref))
|
||||
/*
|
||||
if ($mode_search && $conf->adherent->enabled)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
if ($mode_search && $conf->tax->enabled)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
@ -459,22 +461,22 @@ if ($id > 0 || ! empty($ref))
|
||||
$sql.= $sql_rech;
|
||||
$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
|
||||
$sql.= $db->plimit($limitsql, 0);
|
||||
|
||||
|
||||
dol_syslog("account.php get transactions - sql=".$sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$now=dol_now();
|
||||
$nows=dol_print_date($now,'%Y%m%d');
|
||||
|
||||
|
||||
//$form->load_cache_types_paiements();
|
||||
//$form->cache_types_paiements
|
||||
|
||||
|
||||
$var=true;
|
||||
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0; $total = 0; $sep = 0;
|
||||
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
@ -482,7 +484,7 @@ if ($id > 0 || ! empty($ref))
|
||||
if ($i >= ($nbline - $viewline))
|
||||
{
|
||||
$var=!$var;
|
||||
|
||||
|
||||
// Is it a transaction in future ?
|
||||
$dos=dol_print_date($db->jdate($objp->do),'%Y%m%d');
|
||||
//print "dos=".$dos." nows=".$nows;
|
||||
@ -496,26 +498,26 @@ if ($id > 0 || ! empty($ref))
|
||||
print "<td> </td>";
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
|
||||
print '<td nowrap="nowrap">'.dol_print_date($db->jdate($objp->do),"day")."</td>\n";
|
||||
|
||||
|
||||
print '<td nowrap="nowrap">'.dol_print_date($db->jdate($objp->dv),"day");
|
||||
print "</td>\n";
|
||||
|
||||
|
||||
// Payment type
|
||||
print "<td nowrap>";
|
||||
$label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type;
|
||||
// $label=$langs->getTradFromKey("PaymentTypeShort".$objp->fk_type);
|
||||
|
||||
|
||||
if ($objp->fk_type == 'SOLD') $label=' ';
|
||||
print $label;
|
||||
print "</td>\n";
|
||||
|
||||
|
||||
// Num
|
||||
print '<td nowrap>'.($objp->num_chq?$objp->num_chq:"")."</td>\n";
|
||||
|
||||
|
||||
// Description
|
||||
print '<td>';
|
||||
// Show generic description
|
||||
@ -545,7 +547,7 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
else if ($links[$key]['type']=='company')
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
else if ($links[$key]['type']=='payment_sc')
|
||||
{
|
||||
@ -567,11 +569,11 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
else if ($links[$key]['type']=='member')
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
else if ($links[$key]['type']=='sc')
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -592,7 +594,7 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
||||
// Add third party column
|
||||
print '<td>';
|
||||
foreach($links as $key=>$val)
|
||||
@ -627,7 +629,7 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
||||
// Amount
|
||||
if ($objp->amount < 0)
|
||||
{
|
||||
@ -637,7 +639,7 @@ if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
print '<td> </td><td align="right" nowrap="nowrap"> '.price($objp->amount).'</td>'."\n";
|
||||
}
|
||||
|
||||
|
||||
// Balance
|
||||
if ($action != 'search')
|
||||
{
|
||||
@ -654,7 +656,7 @@ if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
print '<td align="right">-</td>';
|
||||
}
|
||||
|
||||
|
||||
// Transaction reconciliated or edit link
|
||||
if ($objp->rappro && $object->canBeConciliated() > 0) // If line not conciliated and account can be conciliated
|
||||
{
|
||||
@ -697,13 +699,13 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
print "</tr>";
|
||||
}
|
||||
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
// Show total
|
||||
if ($page == 0 && ! $mode_search)
|
||||
{
|
||||
@ -721,19 +723,19 @@ if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
print "\n</div>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Boutons actions
|
||||
*/
|
||||
|
||||
|
||||
if ($action != 'delete')
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
|
||||
if ($object->type != 2 && $object->rappro) // If not cash account and can be reconciliate
|
||||
{
|
||||
if ($user->rights->banque->consolidate)
|
||||
@ -745,7 +747,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($action != 'addline')
|
||||
{
|
||||
if ($user->rights->banque->modifier)
|
||||
@ -757,10 +759,10 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("AddBankRecord").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
else
|
||||
@ -771,4 +773,4 @@ else
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
?>
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user