diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index 8860fa7c4ab..406ea1efbd3 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -42,11 +42,12 @@ $langs->load("margins"); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'banque'); +$search_ref=GETPOST('search_ref','int'); $description=GETPOST("description",'alpha'); $debit=GETPOST("debit",'alpha'); $credit=GETPOST("credit",'alpha'); $type=GETPOST("type",'alpha'); -$account=GETPOST("account",'alpha'); +$account=GETPOST("account",'int'); $bid=GETPOST("bid","int"); $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); @@ -64,28 +65,12 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder='DESC'; if (! $sortfield) $sortfield='b.dateo'; -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if (!empty($description)) $param.='&description='.$description; -if (!empty($type)) $param.='&type='.$type; -if (!empty($debit)) $param.='&debit='.$debit; -if (!empty($credit)) $param.='&credit='.$credit; -if (!empty($account)) $param.='&account='.$account; -if (!empty($bid)) $param.='&bid='.$bid; -if (dol_strlen($search_dt_start) > 0) - $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); -if (dol_strlen($search_dt_end) > 0) - $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); -if (GETPOST("req_nb")) $param.='&req_nb='.urlencode(GETPOST("req_nb")); -if (GETPOST("thirdparty")) $param.='&thirdparty='.urlencode(GETPOST("thirdparty")); - /* * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $description=""; $type=""; @@ -93,6 +78,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $credit=""; $account=""; $bid=""; + $search_ref=""; $search_req_nb=''; $search_thirdparty=''; $thirdparty=''; @@ -127,29 +113,15 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; $sql.= " WHERE b.fk_account = ba.rowid"; $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; -if ($search_req_nb) -{ - $sql.= " AND b.num_chq LIKE '%".$db->escape($search_req_nb)."%'"; -} -if ($search_thirdparty) -{ - $sql.=" AND s.nom LIKE '%".$db->escape($search_thirdparty)."%'"; -} -if ($bid) -{ - $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$bid; -} -if (! empty($type)) -{ - $sql.= " AND b.fk_type = '".$db->escape($type)."' "; -} +if ($search_ref) $sql.=natural_search("b.rowid", $search_ref); +if ($account > 0) $sql.=" AND b.fk_account = ".$account; +if ($search_req_nb) $sql.= " AND b.num_chq LIKE '%".$db->escape($search_req_nb)."%'"; +if ($search_thirdparty) $sql.=" AND s.nom LIKE '%".$db->escape($search_thirdparty)."%'"; +if ($bid) $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$bid; +if (! empty($type)) $sql.= " AND b.fk_type = '".$db->escape($type)."' "; // Search period criteria -if (dol_strlen($search_dt_start)>0) { - $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'"; -} -if (dol_strlen($search_dt_end)>0) { - $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'"; -} +if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'"; +if (dol_strlen($search_dt_end)>0) $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'"; // Search criteria amount $debit = price2num(str_replace('-','',$debit)); $credit = price2num(str_replace('-','',$credit)); @@ -165,7 +137,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } $sql.= $db->plimit($limit+1,$offset); - +print $sql; dol_syslog('compta/bank/search.php::', LOG_DEBUG); $resql = $db->query($sql); if ($resql) @@ -174,6 +146,23 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; + $param=''; + if (!empty($search_ref)) $param.='&search_ref='.$search_ref; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if (!empty($description)) $param.='&description='.$description; + if (!empty($type)) $param.='&type='.$type; + if (!empty($debit)) $param.='&debit='.$debit; + if (!empty($credit)) $param.='&credit='.$credit; + if (!empty($account)) $param.='&account='.$account; + if (!empty($bid)) $param.='&bid='.$bid; + if (dol_strlen($search_dt_start) > 0) + $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); + if (dol_strlen($search_dt_end) > 0) + $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); + if (GETPOST("req_nb")) $param.='&req_nb='.urlencode(GETPOST("req_nb")); + if (GETPOST("thirdparty")) $param.='&thirdparty='.urlencode(GETPOST("thirdparty")); + print '
'."\n"; if ($optioncss != '') print ''; print ''; @@ -199,10 +188,11 @@ if ($resql) $moreforfilter = ''; $moreforfilter.='
'; - $moreforfilter .= $langs->trans('Period') . ' ('.$langs->trans('DateOperationShort').') : ' . $langs->trans('DateStart') . ' '; - $moreforfilter .= $form->select_date($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 1); + $moreforfilter .= $langs->trans('Period') . ' ('.$langs->trans('DateOperationShort').') : '; + $moreforfilter .= '
'.$langs->trans('DateStart') . ' '; + $moreforfilter .= $form->select_date($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 1).'
'; $moreforfilter .= ' - '; - $moreforfilter .= $langs->trans('DateEnd') . ' ' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 1); + $moreforfilter .= '
'.$langs->trans('DateEnd') . ' ' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 1).'
'; $moreforfilter .= '
'; if ($moreforfilter) @@ -223,12 +213,14 @@ if ($resql) 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'],'','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Credit"),$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Account"),$_SERVER['PHP_SELF'],'','',$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(''); print "\n"; print ''; - print ' '; + print ''; + print ''; + print ''; print ' '; print ' '; print ''; @@ -246,7 +238,9 @@ if ($resql) print ''; print ''; print ''; - print ''; + print ''; + $form->select_comptes($account,'account',0,'',1); + print ''; print ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/virement.php index 78950923b34..abb06d17d76 100644 --- a/htdocs/compta/bank/virement.php +++ b/htdocs/compta/bank/virement.php @@ -179,8 +179,8 @@ print "\n"; print ""; $form->select_date((! empty($dateo)?$dateo:''),'','','','','add'); print "\n"; -print ''; -print ''; +print ''; +print ''; print "";