From c321b972deffbdec40b91faee43dd2870d70f7ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jun 2011 21:53:02 +0000 Subject: [PATCH] New: Add search box for donation and trips/expenses --- htdocs/compta/deplacement/list.php | 37 ++++++++++++++++++++-- htdocs/compta/dons/liste.php | 50 ++++++++++++++++++++++++++++-- htdocs/compta/facture.php | 27 ++++++++-------- htdocs/compta/index.php | 44 +++++++++++++++++++++++--- htdocs/langs/en_US/donations.lang | 3 +- htdocs/langs/en_US/trips.lang | 3 +- htdocs/langs/fr_FR/donations.lang | 3 +- htdocs/langs/fr_FR/trips.lang | 3 +- 8 files changed, 143 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 404e0afb5f4..504eea0ae1d 100755 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -22,7 +22,7 @@ /** * \file htdocs/compta/deplacement/list.php * \brief Page list of expenses - * \version $Id: list.php,v 1.1 2011/06/29 17:55:33 eldy Exp $ + * \version $Id: list.php,v 1.2 2011/06/30 21:53:02 eldy Exp $ */ require("../../main.inc.php"); @@ -49,6 +49,8 @@ if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="d.dated"; $limit = $conf->liste_limit; +$search_ref=GETPOST('search_ref'); + /* * View @@ -59,7 +61,7 @@ $tripandexpense_static=new Deplacement($db); llxHeader(); $sql = "SELECT s.nom, s.rowid as socid,"; // Ou -$sql.= " d.rowid, d.type, d.dated as dd, d.km, "; // Comment +$sql.= " d.rowid, d.type, d.dated as dd, d.km,"; // Comment $sql.= " u.name, u.firstname"; // Qui $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= ", ".MAIN_DB_PREFIX."deplacement as d"; @@ -69,6 +71,10 @@ $sql.= " WHERE d.fk_user = u.rowid"; $sql.= " AND d.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; +if (trim($search_ref) != '') +{ + $sql.= ' AND d.rowid LIKE \'%'.$db->escape(trim($search_ref)) . '%\''; +} $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1 ,$offset); @@ -81,6 +87,7 @@ if ($resql) print_barre_liste($langs->trans("ListOfFees"), $page, $_SERVER["PHP_SELF"],"&socid=$socid",$sortfield,$sortorder,'',$num); $i = 0; + print '
'."\n"; print ''; print ""; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid","","&socid=$socid",'',$sortfield,$sortorder); @@ -92,6 +99,29 @@ if ($resql) print_liste_field_titre('',$_SERVER["PHP_SELF"], ''); print "\n"; + // Filters lines + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '\n"; + $var=true; while ($i < min($num,$limit)) { @@ -117,6 +147,7 @@ if ($resql) } print "
'; + print ''; + print ''; + //print ''; + print ''; + //print ''; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print "
"; + print "
\n"; $db->free($resql); } else @@ -125,5 +156,5 @@ else } $db->close(); -llxFooter('$Date: 2011/06/29 17:55:33 $ - $Revision: 1.1 $'); +llxFooter('$Date: 2011/06/30 21:53:02 $ - $Revision: 1.2 $'); ?> diff --git a/htdocs/compta/dons/liste.php b/htdocs/compta/dons/liste.php index 3f5240adbe3..61f1c321947 100644 --- a/htdocs/compta/dons/liste.php +++ b/htdocs/compta/dons/liste.php @@ -21,7 +21,7 @@ * \file htdocs/compta/dons/liste.php * \ingroup don * \brief Page de liste des dons - * \version $Id$ + * \version $Id: liste.php,v 1.34 2011/06/30 21:53:02 eldy Exp $ */ require("../../main.inc.php"); @@ -43,6 +43,9 @@ if (! $sortfield) $sortfield="d.datedon"; $limit = $conf->liste_limit; $statut=isset($_GET["statut"])?$_GET["statut"]:"-1"; +$search_ref=GETPOST('search_ref'); +$search_company=GETPOST('search_company'); +$search_name=GETPOST('search_name'); @@ -66,6 +69,18 @@ if ($statut >= 0) { $sql .= " AND d.fk_statut = ".$statut; } +if (trim($search_ref) != '') +{ + $sql.= ' AND d.rowid LIKE \'%'.$db->escape(trim($search_ref)) . '%\''; +} +if (trim($search_company) != '') +{ + $sql.= ' AND d.societe LIKE \'%'.$db->escape(trim($search_company)) . '%\''; +} +if (trim($search_name) != '') +{ + $sql.= ' AND d.nom LIKE \'%'.$db->escape(trim($search_name)) . '%\' OR d.prenom LIKE \'%'.$db->escape(trim($search_name)) . '%\''; +} $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1, $offset); @@ -89,6 +104,7 @@ if ($result) } + print '
'."\n"; print ""; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid","&page=$page&statut=$statut","","",$sortfield,$sortorder); @@ -104,12 +120,38 @@ if ($result) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.fk_statut","&page=$page&statut=$statut","",'align="right"',$sortfield,$sortorder); print "\n"; + // Filters lines + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->projet->enabled) + { + print ''; + } + print ''; + print '\n"; + $var=True; while ($i < min($num,$limit)) { $objp = $db->fetch_object($result); $var=!$var; - print ""; + print ""; $donationstatic->id=$objp->rowid; $donationstatic->ref=$objp->rowid; $donationstatic->nom=$objp->nom; @@ -140,6 +182,8 @@ if ($result) $i++; } print "
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print "
"; + print "
\n"; + $db->free($resql); } else { @@ -149,5 +193,5 @@ else $db->close(); -llxFooter('$Date$ - $Revision$'); +llxFooter('$Date: 2011/06/30 21:53:02 $ - $Revision: 1.34 $'); ?> diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 38d3851f5cf..9171c8edc8c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -26,7 +26,7 @@ * \file htdocs/compta/facture.php * \ingroup facture * \brief Page to create/see an invoice - * \version $Id: facture.php,v 1.841 2011/06/30 13:27:21 hregis Exp $ + * \version $Id: facture.php,v 1.842 2011/06/30 21:53:02 eldy Exp $ */ require('../main.inc.php'); @@ -61,6 +61,7 @@ $action=GETPOST('action'); $confirm=GETPOST('confirm'); $lineid=GETPOST('lineid'); $userid=GETPOST('userid'); +$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref'):GETPOST('search_ref'); // Security check $fieldid = isset($_GET["ref"])?'facnumber':'rowid'; @@ -248,8 +249,8 @@ if ($action == 'valid') if ($action == 'set_thirdparty') { - $object->updateObjectField('facture',$id,'fk_soc',$socid); - + $object->updateObjectField('facture',$id,'fk_soc',$socid); + Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit; } @@ -3052,9 +3053,9 @@ else { $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } - if ($_POST['sf_ref']) + if (trim($search_ref) != '') { - $sql.= ' AND f.facnumber LIKE \'%'.$db->escape(trim($_POST['sf_ref'])) . '%\''; + $sql.= ' AND f.facnumber LIKE \'%'.$db->escape(trim($search_ref)) . '%\''; } if ($sall) { @@ -3106,17 +3107,17 @@ else //print ' '; print ''; - // Lignes des champs de filtre - + // Filters lines print ''; print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; - //print ' '.$langs->trans('Year').': '; - $syear = $year; + //print ' '.$langs->trans('Year').': '.$syear; + //print 'xx'.$syear.'zz'; //if ($syear == '') $syear = date("Y"); - $htmlother->select_year($syear,'year',1, 20, 5); + $htmlother->select_year($syear?$syear:-1,'year',1, 20, 5); print ''; print ' '; print ''; @@ -3234,5 +3235,5 @@ else $db->close(); -llxFooter('$Date: 2011/06/30 13:27:21 $ - $Revision: 1.841 $'); +llxFooter('$Date: 2011/06/30 21:53:02 $ - $Revision: 1.842 $'); ?> diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 2b7d3eaa2d2..c6a7474c9b8 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -22,7 +22,7 @@ * \file htdocs/compta/index.php * \ingroup compta * \brief Main page of accountancy area - * \version $Id: index.php,v 1.181 2011/06/29 17:55:34 eldy Exp $ + * \version $Id: index.php,v 1.182 2011/06/30 21:53:02 eldy Exp $ */ require('../main.inc.php'); @@ -111,7 +111,7 @@ $max=3; /* - * Find invoices + * Search invoices */ if ($conf->facture->enabled && $user->rights->facture->lire) { @@ -127,6 +127,9 @@ if ($conf->facture->enabled && $user->rights->facture->lire) print "
"; } +/* + * Search supplier invoices + */ if ($conf->fournisseur->enabled && $user->rights->fournisseur->lire) { print '
'; @@ -141,6 +144,39 @@ if ($conf->fournisseur->enabled && $user->rights->fournisseur->lire) print "

"; } +/* + * Search donations + */ +if ($conf->don->enabled && $user->rights->don->lire) +{ + print '
'; + print ''; + print ''; + print ''; + print ""; + print "'; + print ''; + //print "'; + print ''; + print "
'.$langs->trans("SearchADonation").'
".$langs->trans("Ref").':
".$langs->trans("Other").':

"; +} + +/* + * Search expenses + */ +if ($conf->deplacement->enabled && $user->rights->deplacement->lire) +{ + print '
'; + print ''; + print ''; + print ''; + print ""; + print "'; + print ''; + //print "'; + print ''; + print "
'.$langs->trans("SearchATripAndExpense").'
".$langs->trans("Ref").':
".$langs->trans("Other").':

"; +} /** * Draft customers invoices @@ -1009,5 +1045,5 @@ print ''; $db->close(); -llxFooter('$Date: 2011/06/29 17:55:34 $ - $Revision: 1.181 $'); +llxFooter('$Date: 2011/06/30 21:53:02 $ - $Revision: 1.182 $'); ?> diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang index bed06b63495..1bfb0a5d084 100644 --- a/htdocs/langs/en_US/donations.lang +++ b/htdocs/langs/en_US/donations.lang @@ -23,4 +23,5 @@ DonationStatusPaidShort=Received ValidPromess=Validate promise BuildDonationReceipt=Build receipt DonationsModels=Documents models for donation receipts -LastModifiedDonations=Last %s modified donations \ No newline at end of file +LastModifiedDonations=Last %s modified donations +SearchADonation=Search a donation \ No newline at end of file diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index c18425bc6e0..af3dad34470 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -18,4 +18,5 @@ TF_OTHER=Other TF_LUNCH=Lunch TF_TRIP=Trip ListTripsAndExpenses=List of trips and expenses -ExpensesArea=Trips and exepenses area \ No newline at end of file +ExpensesArea=Trips and exepenses area +SearchATripAndExpense=Search a trip and expense \ No newline at end of file diff --git a/htdocs/langs/fr_FR/donations.lang b/htdocs/langs/fr_FR/donations.lang index b7e26c7a739..e78e254ae75 100644 --- a/htdocs/langs/fr_FR/donations.lang +++ b/htdocs/langs/fr_FR/donations.lang @@ -23,4 +23,5 @@ DonationStatusPaidShort=Payé ValidPromess=Valider promesse BuildDonationReceipt=Créer reçu DonationsModels=Modèle de document de bon de réception de dons -LastModifiedDonations=Les %s derniers dons modifiés \ No newline at end of file +LastModifiedDonations=Les %s derniers dons modifiés +SearchADonation=Rechercher un don \ No newline at end of file diff --git a/htdocs/langs/fr_FR/trips.lang b/htdocs/langs/fr_FR/trips.lang index 483f99dcea4..2a90974cea5 100644 --- a/htdocs/langs/fr_FR/trips.lang +++ b/htdocs/langs/fr_FR/trips.lang @@ -19,4 +19,5 @@ TF_OTHER=Autre TF_LUNCH=Repas TF_TRIP=Déplacement ListTripsAndExpenses=Liste des notes de frais -ExpensesArea=Espace Notes de frais \ No newline at end of file +ExpensesArea=Espace Notes de frais +SearchATripAndExpense=Rechercher une note de frais \ No newline at end of file