Fix search criteria in bookkeeping table
This commit is contained in:
parent
560c84be0d
commit
3d36e3ee49
@ -75,6 +75,8 @@ if ($search_accountancy_aux_code_end == - 1) {
|
||||
}
|
||||
$search_mvt_label = GETPOST('search_mvt_label', 'alpha');
|
||||
$search_direction = GETPOST('search_direction', 'alpha');
|
||||
$search_debit = GETPOST('search_debit', 'alpha');
|
||||
$search_credit = GETPOST('search_credit', 'alpha');
|
||||
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
|
||||
|
||||
// Load variable for pagination
|
||||
@ -98,7 +100,7 @@ $form = new Form($db);
|
||||
|
||||
if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page','int') == '' && ! GETPOST('noreset','int'))
|
||||
{
|
||||
if (empty($search_date_start) && empty($search_date_end))
|
||||
if (empty($search_date_start) && empty($search_date_end) && ! GETPOSTISSET('restore_lastsearch_values'))
|
||||
{
|
||||
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
|
||||
$query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
|
||||
@ -195,51 +197,51 @@ if (! empty($search_doc_date)) {
|
||||
}
|
||||
if (! empty($search_doc_type)) {
|
||||
$filter['t.doc_type'] = $search_doc_type;
|
||||
$param .= '&search_doc_type=' . $search_doc_type;
|
||||
$param .= '&search_doc_type=' . urlencode($search_doc_type);
|
||||
}
|
||||
if (! empty($search_doc_ref)) {
|
||||
$filter['t.doc_ref'] = $search_doc_ref;
|
||||
$param .= '&search_doc_ref=' . $search_doc_ref;
|
||||
$param .= '&search_doc_ref=' . urlencode($search_doc_ref);
|
||||
}
|
||||
if (! empty($search_accountancy_code)) {
|
||||
$filter['t.numero_compte'] = $search_accountancy_code;
|
||||
$param .= '&search_accountancy_code=' . $search_accountancy_code;
|
||||
$param .= '&search_accountancy_code=' . urlencode($search_accountancy_code);
|
||||
}
|
||||
if (! empty($search_accountancy_code_start)) {
|
||||
$filter['t.numero_compte>='] = $search_accountancy_code_start;
|
||||
$param .= '&search_accountancy_code_start=' . $search_accountancy_code_start;
|
||||
$param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start);
|
||||
}
|
||||
if (! empty($search_accountancy_code_end)) {
|
||||
$filter['t.numero_compte<='] = $search_accountancy_code_end;
|
||||
$param .= '&search_accountancy_code_end=' . $search_accountancy_code_end;
|
||||
$param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end);
|
||||
}
|
||||
if (! empty($search_accountancy_aux_code)) {
|
||||
$filter['t.subledger_account'] = $search_accountancy_aux_code;
|
||||
$param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code;
|
||||
$param .= '&search_accountancy_aux_code=' . urlencode($search_accountancy_aux_code);
|
||||
}
|
||||
if (! empty($search_accountancy_aux_code_start)) {
|
||||
$filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
|
||||
$param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start;
|
||||
$param .= '&search_accountancy_aux_code_start=' . urlencode($search_accountancy_aux_code_start);
|
||||
}
|
||||
if (! empty($search_accountancy_aux_code_end)) {
|
||||
$filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
|
||||
$param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end;
|
||||
$param .= '&search_accountancy_aux_code_end=' . urlencode($search_accountancy_aux_code_end);
|
||||
}
|
||||
if (! empty($search_mvt_label)) {
|
||||
$filter['t.label_operation'] = $search_mvt_label;
|
||||
$param .= '&search_mvt_label=' . $search_mvt_label;
|
||||
$param .= '&search_mvt_label=' . urlencode($search_mvt_label);
|
||||
}
|
||||
if (! empty($search_direction)) {
|
||||
$filter['t.sens'] = $search_direction;
|
||||
$param .= '&search_direction=' . $search_direction;
|
||||
$param .= '&search_direction=' . urlencode($search_direction);
|
||||
}
|
||||
if (! empty($search_ledger_code)) {
|
||||
$filter['t.code_journal'] = $search_ledger_code;
|
||||
$param .= '&search_ledger_code=' . $search_ledger_code;
|
||||
$param .= '&search_ledger_code=' . urlencode($search_ledger_code);
|
||||
}
|
||||
if (! empty($search_mvt_num)) {
|
||||
$filter['t.piece_num'] = $search_mvt_num;
|
||||
$param .= '&search_mvt_num=' . $search_mvt_num;
|
||||
$param .= '&search_mvt_num=' . urlencode($search_mvt_num);
|
||||
}
|
||||
if (! empty($search_date_creation_start)) {
|
||||
$filter['t.date_creation>='] = $search_date_creation_start;
|
||||
@ -263,11 +265,11 @@ if (! empty($search_date_modification_end)) {
|
||||
}
|
||||
if (! empty($search_debit)) {
|
||||
$filter['t.debit'] = $search_debit;
|
||||
$param .= '&search_debit=' . $search_debit;
|
||||
$param .= '&search_debit=' . urlencode($search_debit);
|
||||
}
|
||||
if (! empty($search_credit)) {
|
||||
$filter['t.credit'] = $search_credit;
|
||||
$param .= '&search_credit=' . $search_credit;
|
||||
$param .= '&search_credit=' . urlencode($search_credit);
|
||||
}
|
||||
|
||||
if ($action == 'delbookkeeping') {
|
||||
|
||||
@ -865,13 +865,14 @@ class BookKeeping extends CommonObject
|
||||
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
|
||||
} elseif ($key == 't.tms>=' || $key == 't.tms<=') {
|
||||
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
|
||||
} elseif ($key == 't.credit' || $key == 't.debit') {
|
||||
$sqlwhere[] = natural_search($key, $value, 1, 1);
|
||||
} else {
|
||||
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||
$sqlwhere[] = natural_search($key, $value, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql.= ' WHERE 1 = 1';
|
||||
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
|
||||
$sql.= ' WHERE entity IN (' . getEntity('accountancy') . ')';
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user