diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php
index 2c321a0167c..3b296716c44 100644
--- a/htdocs/compta/bank/search.php
+++ b/htdocs/compta/bank/search.php
@@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$langs->load("banks");
+$langs->load("bills");
$langs->load("categories");
$langs->load("companies");
$langs->load("margins");
@@ -42,7 +43,7 @@ $langs->load("margins");
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'banque');
-$search_ref=GETPOST('search_ref','int');
+$search_ref=GETPOST('search_ref','alpha');
$description=GETPOST("description",'alpha');
$debit=GETPOST("debit",'alpha');
$credit=GETPOST("credit",'alpha');
@@ -77,16 +78,16 @@ $extralabels = $extrafields->fetch_name_optionals_label('banktransaction');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
$arrayfields=array(
- 'b.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
- 'b.date_commande'=>array('label'=>$langs->trans("OrderDateShort"), 'checked'=>1),
- 'b.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)),
- 'b.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
- 'b.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
- 'b.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
- 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
- 'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
- 'b.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
- 'b.facture'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
+ 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
+ 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1),
+ 'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1),
+ 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
+ 'b.num_releve'=>array('label'=>$langs->trans("Numero"), 'checked'=>1),
+ 'description'=>array('label'=>$langs->trans("Description"), 'checked'=>1),
+ 'bu.label'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>500),
+ 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600),
+ 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605),
+ 'ba.ref'=>array('label'=>$langs->trans("Account"), 'checked'=>1, 'position'=>1000)
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
@@ -114,6 +115,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
+ $search_dt_start='';
+ $search_dt_end='';
$description="";
$type="";
$debit="";
@@ -249,10 +252,10 @@ if ($resql)
// List of mass actions available
$arrayofmassactions = array(
- 'presend'=>$langs->trans("SendByMail"),
- 'builddoc'=>$langs->trans("PDFMerge"),
+ //'presend'=>$langs->trans("SendByMail"),
+ //'builddoc'=>$langs->trans("PDFMerge"),
);
- if ($user->rights->commande->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
+ //if ($user->rights->bank->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
@@ -310,54 +313,102 @@ if ($resql)
// Fields title
print '
';
- print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans('DateOperationShort'),$_SERVER['PHP_SELF'],'b.dateo','',$param,'align="center"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans('Value'),$_SERVER['PHP_SELF'],'b.datev','',$param,'align="center"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Type"),$_SERVER['PHP_SELF'],'','',$param,'align="center"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Numero"),$_SERVER['PHP_SELF'],'b.num_releve','',$param,'align="center"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Description"),$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER['PHP_SELF'],'bu.label','',$param,'',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Debit"),$_SERVER['PHP_SELF'],'b.amount','',$param,'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Credit"),$_SERVER['PHP_SELF'],'b.amount','',$param,'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Account"),$_SERVER['PHP_SELF'],'ba.ref','',$param,'align="right"',$sortfield,$sortorder);
- print_liste_field_titre('');
+ if (! empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'],$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder);
+ if (! empty($arrayfields['b.dateo']['checked'])) print_liste_field_titre($arrayfields['b.dateo']['label'],$_SERVER['PHP_SELF'],'b.dateo','',$param,'align="center"',$sortfield,$sortorder);
+ if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'],$_SERVER['PHP_SELF'],'b.datev','',$param,'align="center"',$sortfield,$sortorder);
+ if (! empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="center"',$sortfield,$sortorder);
+ if (! empty($arrayfields['b.num_releve']['checked'])) print_liste_field_titre($arrayfields['b.num_releve']['label'],$_SERVER['PHP_SELF'],'b.num_releve','',$param,'align="center"',$sortfield,$sortorder);
+ if (! empty($arrayfields['description']['checked'])) print_liste_field_titre($arrayfields['description']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder);
+ if (! empty($arrayfields['bu.label']['checked'])) print_liste_field_titre($arrayfields['bu.label']['label'],$_SERVER['PHP_SELF'],'bu.label','',$param,'',$sortfield,$sortorder);
+ if (! empty($arrayfields['b.debit']['checked'])) print_liste_field_titre($arrayfields['b.debit']['label'],$_SERVER['PHP_SELF'],'b.amount','',$param,'align="right"',$sortfield,$sortorder);
+ if (! empty($arrayfields['b.credit']['checked'])) print_liste_field_titre($arrayfields['b.credit']['label'],$_SERVER['PHP_SELF'],'b.amount','',$param,'align="right"',$sortfield,$sortorder);
+ if (! empty($arrayfields['ba.ref']['checked'])) print_liste_field_titre($arrayfields['ba.ref']['label'],$_SERVER['PHP_SELF'],'ba.ref','',$param,'align="right"',$sortfield,$sortorder);
+ // Extra fields
+ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
+ {
+ foreach($extrafields->attribute_label as $key => $val)
+ {
+ if (! empty($arrayfields["ef.".$key]['checked']))
+ {
+ $align=$extrafields->getAlignFlag($key);
+ print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
+ }
+ }
+ }
+ // Hook fields
+ $parameters=array('arrayfields'=>$arrayfields);
+ $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print " \n";
print '';
- print '';
- print ' ';
- print ' ';
- print ' ';
- print ' ';
- print '';
- $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1);
- print ' ';
- // Numero
- print ' ';
- print '';
- print ' ';
- print ' ';
- print ' ';
- print '';
- print ' ';
- print ' ';
- print '';
- print ' ';
- print ' ';
- print '';
- $form->select_comptes($account,'account',0,'',1);
- print ' ';
- print '';
- $searchpitco=$form->showFilterAndCheckAddButtons(0);
- print $searchpitco;
+ if (! empty($arrayfields['b.rowid']['checked']))
+ {
+ print ' ';
+ print ' ';
+ print ' ';
+ }
+ if (! empty($arrayfields['b.dateo']['checked']))
+ {
+ print ' ';
+ }
+ if (! empty($arrayfields['b.datev']['checked']))
+ {
+ print ' ';
+ }
+ if (! empty($arrayfields['type']['checked']))
+ {
+ print '';
+ $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1);
+ print ' ';
+ }
+ if (! empty($arrayfields['b.num_releve']['checked']))
+ {
+ // Numero
+ print ' ';
+ }
+ if (! empty($arrayfields['description']['checked']))
+ {
+ print '';
+ print ' ';
+ print ' ';
+ }
+ if (! empty($arrayfields['bu.label']['checked']))
+ {
+ print ' ';
+ }
+ if (! empty($arrayfields['b.debit']['checked']))
+ {
+ print '';
+ print ' ';
+ print ' ';
+ }
+ if (! empty($arrayfields['b.credit']['checked']))
+ {
+ print '';
+ print ' ';
+ print ' ';
+ }
+ if (! empty($arrayfields['ba.ref']['checked']))
+ {
+ print '';
+ $form->select_comptes($account,'account',0,'',1);
+ print ' ';
+ }
+ print '';
+ $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
+ print $searchpitco;
print ' ';
print " \n";
// Loop on each record
- $total_debit=0;
- $total_credit=0;
- while ($i < min($num,$limit)) {
+ $totalarray=array();
+ while ($i < min($num,$limit))
+ {
$objp = $db->fetch_object($resql);
+
+ // Why this ?
$printline=false;
//Search Description
if ($description) {
@@ -372,98 +423,163 @@ if ($resql)
} else {
$printline=true;
}
-
if ($printline) {
+
$var=!$var;
print "";
// Ref
- print '';
- print "rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'payment', 'class="classfortooltip"').' '.$objp->rowid." ";
- print ' ';
-
+ if (! empty($arrayfields['b.rowid']['checked']))
+ {
+ print '';
+ print "rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'payment', 'class="classfortooltip"').' '.$objp->rowid." ";
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
// Date ope
- print ''.dol_print_date($db->jdate($objp->do),"day")." \n";
+ if (! empty($arrayfields['b.dateo']['checked']))
+ {
+ print ''.dol_print_date($db->jdate($objp->do),"day")." \n";
+ if (! $i) $totalarray['nbfield']++;
+ }
// Date value
- print ''.dol_print_date($db->jdate($objp->dv),"day")." \n";
+ if (! empty($arrayfields['b.datev']['checked']))
+ {
+ print ''.dol_print_date($db->jdate($objp->dv),"day")." \n";
+ if (! $i) $totalarray['nbfield']++;
+ }
// 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";
+ if (! empty($arrayfields['type']['checked']))
+ {
+ 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";
+ if (! $i) $totalarray['nbfield']++;
+ }
// Num
- print ''.($objp->num_chq?$objp->num_chq:"")." \n";
+ if (! empty($arrayfields['b.num_releve']['checked']))
+ {
+ print ''.($objp->num_chq?$objp->num_chq:"")." \n";
+ if (! $i) $totalarray['nbfield']++;
+ }
// 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 ' ';
+ if (! empty($arrayfields['description']['checked']))
+ {
+ 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 ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
// Third party
- print "";
- if ($objp->url_id)
- {
- $companystatic->id=$objp->url_id;
- $companystatic->name=$objp->nom;
- $companystatic->name_alias=$objp->name_alias;
- $companystatic->client=$objp->client;
- $companystatic->fournisseur=$objp->fournisseur;
- $companystatic->code_client=$objp->code_client;
- $companystatic->code_fournisseur=$objp->code_fournisseur;
- print $companystatic->getNomUrl(1);
- }
- else
- {
- print ' ';
- }
- print ' ';
-
- // Debit/Credit
- if ($objp->amount < 0)
- {
- print ''.price($objp->amount * -1)." \n";
- $total_debit+=$objp->amount;
- }
- else
- {
- print " ".price($objp->amount)." \n";
- $total_credit+=$objp->amount;
- }
-
+ if (! empty($arrayfields['bu.label']['checked']))
+ {
+ print "";
+ if ($objp->url_id)
+ {
+ $companystatic->id=$objp->url_id;
+ $companystatic->name=$objp->nom;
+ $companystatic->name_alias=$objp->name_alias;
+ $companystatic->client=$objp->client;
+ $companystatic->fournisseur=$objp->fournisseur;
+ $companystatic->code_client=$objp->code_client;
+ $companystatic->code_fournisseur=$objp->code_fournisseur;
+ print $companystatic->getNomUrl(1);
+ }
+ else
+ {
+ print ' ';
+ }
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Debit
+ if (! empty($arrayfields['b.debit']['checked']))
+ {
+ print '';
+ if ($objp->amount < 0)
+ {
+ print price($objp->amount * -1);
+ $totalarray['totaldeb'] += $objp->amount;
+ }
+ print " \n";
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield'];
+ }
+ // Credit
+ if (! empty($arrayfields['b.credit']['checked']))
+ {
+ print '';
+ if ($objp->amount > 0)
+ {
+ print price($objp->amount);
+ $totalarray['totalcred'] += $objp->amount;
+ }
+ print " \n";
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield'];
+ }
+
// Bank account
- print '';
- $bankaccountstatic->id=$objp->bankid;
- $bankaccountstatic->label=$objp->bankref;
- print $bankaccountstatic->getNomUrl(1);
- print " \n";
-
- print ' ';
+ if (! empty($arrayfields['ba.ref']['checked']))
+ {
+ print '';
+ $bankaccountstatic->id=$objp->bankid;
+ $bankaccountstatic->label=$objp->bankref;
+ print $bankaccountstatic->getNomUrl(1);
+ print " \n";
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Action column
+ print '';
+ if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ {
+ $selected=0;
+ if (in_array($obj->rowid, $arrayofselected)) $selected=1;
+ print ' ';
+ }
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
print " ";
}
$i++;
}
- if ($num>0) {
- print '';
- print '' . $langs->trans('Total') . ' ';
- print ' ';
- print '' . price($total_debit * - 1) . ' ';
- print '' . price($total_credit) . ' ';
- print ' ';
- print ' ';
- print ' ';
+
+ // Show total line
+ if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield']))
+ {
+ print '';
+ $i=0;
+ while ($i < $totalarray['nbfield'])
+ {
+ $i++;
+ if ($i == 1)
+ {
+ if ($num < $limit) print ''.$langs->trans("Total").' ';
+ else print ''.$langs->trans("Totalforthispage").' ';
+ }
+ elseif ($totalarray['totaldebfield'] == $i) print ''.price(-1 * $totalarray['totaldeb']).' ';
+ elseif ($totalarray['totalcredfield'] == $i) print ''.price($totalarray['totalcred']).' ';
+ else print ' ';
+ }
+ print ' ';
}
print "";