From 5099bc5e89538a4f5f4c8c2617ef375191b79523 Mon Sep 17 00:00:00 2001 From: fhenry Date: Sat, 29 Dec 2012 16:06:11 +0100 Subject: [PATCH] Fix [ bug #658 ] Seacrh on bank do not work for description --- htdocs/compta/bank/search.php | 155 ++++++++++++++++++---------------- 1 file changed, 81 insertions(+), 74 deletions(-) diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index 868420a5a6c..923b5a6cb5c 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -117,11 +117,6 @@ if (is_numeric($credit)) { $si++; $sqlw[$si] .= " b.amount = " . $credit; } -// Search criteria description -if ($description) { - $si++; - $sqlw[$si] .= " b.label like '%" . $description . "%'"; -} // Other search criteria for ($i = 1 ; $i <= $si; $i++) { $sql .= " AND " . $sqlw[$i]; @@ -194,76 +189,88 @@ if ($resql) while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); - - $var=!$var; - - print ""; - - // Ref - print ''; - print "rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").' '.$objp->rowid."   "; - print ''; - - // Date ope - print ''.dol_print_date($db->jdate($objp->do),"day")."\n"; - - // Date value - print ''.dol_print_date($db->jdate($objp->dv),"day")."\n"; - - // Payment type - print ""; - $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle'); - if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance"); - else print $labeltype; - print "\n"; - - // Num - print ''.($objp->num_chq?$objp->num_chq:"")."\n"; - - // Description - print ""; - - print "rowid."&account=".$objp->fk_account."\">"; - $reg=array(); - preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthee on tente recherche de traduction - if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); - else print dol_trunc($objp->label,40); - print " "; - - print ''; - - // Third party - print ""; - if ($objp->url_id) - { - $companystatic->id=$objp->url_id; - $companystatic->nom=$objp->labelurl; - print $companystatic->getNomUrl(1); + + $printline=false; + //Search Description + if ($description) { + preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthee on tente recherche de traduction + if ($reg[1]) { + if ($langs->transnoentities($reg[1])==$description) { + $printline=true; + } + }elseif ($objp->label==$description) {$printline=true;} + }else {$printline=true;} + + if ($printline) { + $var=!$var; + + print ""; + + // Ref + print ''; + print "rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").' '.$objp->rowid."   "; + print ''; + + // Date ope + print ''.dol_print_date($db->jdate($objp->do),"day")."\n"; + + // Date value + print ''.dol_print_date($db->jdate($objp->dv),"day")."\n"; + + // Payment type + print ""; + $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle'); + if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance"); + else print $labeltype; + print "\n"; + + // Num + print ''.($objp->num_chq?$objp->num_chq:"")."\n"; + + // Description + print ""; + + print "rowid."&account=".$objp->fk_account."\">"; + $reg=array(); + preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthee on tente recherche de traduction + if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); + else print dol_trunc($objp->label,40); + print " "; + + print ''; + + // Third party + print ""; + if ($objp->url_id) + { + $companystatic->id=$objp->url_id; + $companystatic->nom=$objp->labelurl; + print $companystatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + + // Debit/Credit + if ($objp->amount < 0) + { + print "".price($objp->amount * -1)." \n"; + } + else + { + print " ".price($objp->amount)."\n"; + } + + // Bank account + print ''; + $bankaccountstatic->id=$objp->bankid; + $bankaccountstatic->label=$objp->bankref; + print $bankaccountstatic->getNomUrl(1); + print "\n"; + print ""; } - else - { - print ' '; - } - print ''; - - // Debit/Credit - if ($objp->amount < 0) - { - print "".price($objp->amount * -1)." \n"; - } - else - { - print " ".price($objp->amount)."\n"; - } - - // Bank account - print ''; - $bankaccountstatic->id=$objp->bankid; - $bankaccountstatic->label=$objp->bankref; - print $bankaccountstatic->getNomUrl(1); - print "\n"; - print ""; - $i++; }