From 10a895f1bddba186933398d587333e5a95593552 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 5 May 2015 22:36:48 +0200 Subject: [PATCH] Accountancy: add a button to purge search criteria on list --- htdocs/accountancy/customer/lines.php | 73 +++++++++++++++----------- htdocs/accountancy/supplier/lines.php | 74 ++++++++++++++++----------- 2 files changed, 86 insertions(+), 61 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 01806db8332..bc50d33695c 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014 Ari Elbaz (elarifr) * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent @@ -27,19 +27,23 @@ */ require '../../main.inc.php'; - -// Class require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -// langs $langs->load("bills"); $langs->load("compta"); $langs->load("main"); $langs->load("accountancy"); $account_parent = GETPOST('account_parent'); +$changeaccount = GETPOST('changeaccount'); +$search_ref = GETPOST('search_ref','alpha'); +$search_facture = GETPOST('search_facture','alpha'); +$search_label = GETPOST('search_label','alpha'); +$search_desc = GETPOST('search_desc','alpha'); +$search_amount = GETPOST('search_amount','alpha'); +$search_acount = GETPOST('search_account','alpha'); // Security check if ($user->societe_id > 0) @@ -49,13 +53,18 @@ if (! $user->rights->accounting->ventilation->dispatch) $formventilation = new FormVentilation($db); -// change account +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_ref=''; + $search_facture=''; + $search_label=''; + $search_desc=''; + $search_amount=''; + $search_account=''; +} -$changeaccount = GETPOST('changeaccount'); - -$is_search = GETPOST('button_search_x'); - -if (is_array($changeaccount) && count($changeaccount) > 0 && empty($is_search)) { +if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; $db->begin(); @@ -110,17 +119,20 @@ $sql .= " AND aa.rowid = l.fk_code_ventilation"; if (strlen(trim(GETPOST("search_facture")))) { $sql .= " AND f.facnumber like '%" . GETPOST("search_facture") . "%'"; } -if (strlen(trim(GETPOST("search_ref")))) { - $sql .= " AND p.ref like '%" . GETPOST("search_ref") . "%'"; +if (strlen(trim($search_ref))) { + $sql .= " AND p.ref like '%" . $search_ref . "%'"; } -if (strlen(trim(GETPOST("search_label")))) { - $sql .= " AND p.label like '%" . GETPOST("search_label") . "%'"; +if (strlen(trim($search_label))) { + $sql .= " AND p.label like '%" . $search_label . "%'"; } -if (strlen(trim(GETPOST("search_desc")))) { - $sql .= " AND l.description like '%" . GETPOST("search_desc") . "%'"; +if (strlen(trim($search_desc))) { + $sql .= " AND l.description like '%" . $search_desc . "%'"; } -if (strlen(trim(GETPOST("search_account")))) { - $sql .= " AND aa.account_number like '%" . GETPOST("search_account") . "%'"; +if (strlen(trim($search_amount))) { + $sql .= " AND l.total_ht like '%" . $search_amount . "%'"; +} +if (strlen(trim($search_account))) { + $sql .= " AND aa.account_number like '%" . $search_account . "%'"; } if (! empty($conf->multicompany->enabled)) { @@ -161,18 +173,17 @@ if ($result) { print ' '; print "\n"; - print ''; - print ''; - print ''; - print ''; - print ' '; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ' '; - print ''; - print ''; - print ''; print ' '; - print "\n"; + print ''; + print ''; + print "\n"; $facture_static = new Facture($db); $product_static = new Product($db); @@ -180,7 +191,7 @@ if ($result) { $var = True; while ( $objp = $db->fetch_object($result) ) { $var = ! $var; - $codeCompta = $objp->account_number . ' ' . $objp->label; + $codecompta = $objp->account_number . ' ' . $objp->label; print ""; @@ -202,8 +213,8 @@ if ($result) { print '' . dol_trunc($objp->product_label, 24) . ''; print '' . nl2br(dol_trunc($objp->description, 32)) . ''; - print '' . price($objp->total_ht) . ''; - print '' . $codeCompta . ''; + print '' . price($objp->total_ht) . ''; + print '' . $codecompta . ''; print '' . $objp->rowid . ''; print ''; print img_edit(); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 5df5ee0c06f..dd6319e7c43 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent @@ -26,34 +26,46 @@ */ require '../../main.inc.php'; - -// Class require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -// Langs $langs->load("compta"); $langs->load("bills"); $langs->load("other"); $langs->load("main"); $langs->load("accountancy"); +$account_parent = GETPOST('account_parent'); +$changeaccount = GETPOST('changeaccount'); +$search_ref = GETPOST('search_ref','alpha'); +$search_facture = GETPOST('search_facture','alpha'); +$search_label = GETPOST('search_label','alpha'); +$search_desc = GETPOST('search_desc','alpha'); +$search_amount = GETPOST('search_amount','alpha'); +$search_acount = GETPOST('search_account','alpha'); + // Security check if ($user->societe_id > 0) accessforbidden(); if (! $user->rights->accounting->ventilation->dispatch) accessforbidden(); - $formventilation = new FormVentilation($db); -$changeaccount = GETPOST('changeaccount'); +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_ref=''; + $search_facture=''; + $search_label=''; + $search_desc=''; + $search_amount=''; + $search_account=''; +} -$is_search = GETPOST('button_search_x'); - -if (is_array($changeaccount) && count($changeaccount) > 0 && empty($is_search)) { +if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; $db->begin(); @@ -83,7 +95,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && empty($is_search)) llxHeader('', $langs->trans("SuppliersVentilation") . ' - ' . $langs->trans("Dispatched")); -$page = $_GET["page"]; +$page = GETPOST("page"); if ($page < 0) $page = 0; @@ -105,20 +117,23 @@ $sql .= " , " . MAIN_DB_PREFIX . "facture_fourn_det as l"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; $sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 "; $sql .= " AND aa.rowid = l.fk_code_ventilation"; -if (strlen(trim($_GET["search_facture"]))) { - $sql .= " AND f.ref like '%" . $_GET["search_facture"] . "%'"; +if (strlen(trim($search_facture))) { + $sql .= " AND f.ref like '%" . $search_facture . "%'"; } -if (strlen(trim($_GET["search_ref"]))) { - $sql .= " AND p.ref like '%" . $_GET["search_ref"] . "%'"; +if (strlen(trim($search_ref))) { + $sql .= " AND p.ref like '%" . $search_ref . "%'"; } -if (strlen(trim($_GET["search_label"]))) { - $sql .= " AND p.label like '%" . $_GET["search_label"] . "%'"; +if (strlen(trim($search_label))) { + $sql .= " AND p.label like '%" . $search_label . "%'"; } -if (strlen(trim($_GET["search_desc"]))) { - $sql .= " AND l.description like '%" . $_GET["search_desc"] . "%'"; +if (strlen(trim($search_desc))) { + $sql .= " AND l.description like '%" . $search_desc . "%'"; } -if (strlen(trim($_GET["search_account"]))) { - $sql .= " AND aa.account_number like '%" . $_GET["search_account"] . "%'"; +if (strlen(trim($search_amount))) { + $sql .= " AND l.total_ht like '%" . $search_amount . "%'"; +} +if (strlen(trim($search_account))) { + $sql .= " AND aa.account_number like '%" . $search_account . "%'"; } if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity = '" . $conf->entity . "'"; @@ -159,18 +174,17 @@ if ($result) { print ' '; print "\n"; - print ''; - print ''; - print ''; - print ''; - print ' '; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ' '; - print ''; - print ''; - print ''; print ' '; - print "\n"; + print ''; + print ''; + print "\n"; $facturefournisseur_static = new FactureFournisseur($db); $product_static = new Product($db);