New: Can filter on categories for third parties list

This commit is contained in:
Laurent Destailleur 2010-03-16 19:50:07 +00:00
parent 9f722f671e
commit f1216bfe4c
7 changed files with 263 additions and 171 deletions

View File

@ -3,6 +3,7 @@ English Dolibarr ChangeLog
***** ChangeLog for 2.9 compared to 2.8 *****
For users:
- New: Can filter third parties lists on categories.
- New: Can build documents for third parties (Use ODT templates, need PHP 5.2+).
- New: Support products property length and area.
- New: Add "payment due before" field in invoice exports

View File

@ -529,8 +529,8 @@ class Categorie
* label = nom de la categorie
* fulllabel = nom avec chemin complet de la categorie
* fullpath = chemin complet compose des id
* \param type Type de categories (0=produit, 1=fournisseur, 2=client)
* \return array Tableau de array
* \param type Type of categories (0=product, 1=suppliers, 2=customers, 3=members)
* \return array Array of categories
*/
function get_full_arbo($type)
{

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -26,6 +26,7 @@
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/html.formother.class.php");
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
@ -46,29 +47,53 @@ $search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"];
$search_ville=isset($_GET["search_ville"])?$_GET["search_ville"]:$_POST["search_ville"];
$search_code=isset($_GET["search_code"])?$_GET["search_code"]:$_POST["search_code"];
// Load sale and categ filters
$search_sale = isset($_GET["search_sale"])?$_GET["search_sale"]:$_POST["search_sale"];
$search_categ = isset($_GET["search_categ"])?$_GET["search_categ"]:$_POST["search_categ"];
/*
* view
*/
$htmlother=new FormOther($db);
llxHeader();
$sql = "SELECT s.rowid, s.nom, s.ville, st.libelle as stcomm, s.prefix_comm, s.code_client";
$sql.= ", ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea";
$sql.= ",s.datec, s.datea";
// We'll need these fields in order to filter by sale (including the case where the user can only see his prospects)
if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user";
// We'll need these fields in order to filter by categ
if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_societe";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
if (!$user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
// We'll need this table joined to the select in order to filter by sale
if ($search_sale || !$user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
// We'll need this table joined to the select in order to filter by categ
if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as cs";
$sql.= " WHERE s.fk_stcomm = st.id";
$sql.= " AND s.client IN (1, 3)";
$sql.= " AND s.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
if ($search_categ) $sql.= " AND s.rowid = cs.fk_societe"; // Join for the needed table to filter by categ
if ($search_nom) $sql.= " AND s.nom like '%".addslashes(strtolower($search_nom))."%'";
if ($search_ville) $sql.= " AND s.ville like '%".addslashes(strtolower($search_ville))."%'";
if ($search_code) $sql.= " AND s.code_client like '%".addslashes(strtolower($search_code))."%'";
// Insert sale filter
if ($search_sale)
{
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Insert categ filter
if ($search_categ)
{
$sql .= " AND cs.fk_categorie = ".$search_categ;
}
if ($socname)
{
$sql.= " AND s.nom like '%".addslashes(strtolower($socname))."%'";
@ -93,6 +118,8 @@ if ($result)
$num = $db->num_rows($result);
$param = "&amp;search_nom=".$search_nom."&amp;search_code=".$search_code."&amp;search_ville=".$search_ville;
if ($search_categ != '') $param.='&amp;search_categ='.$search_categ;
if ($search_sale != '') $param.='&amp;search_sale='.$search_sale;
print_barre_liste($langs->trans("ListOfCustomers"), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
@ -100,6 +127,29 @@ if ($result)
print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">'."\n";
print '<table class="liste">'."\n";
// Filter on categories
$moreforfilter='';
if ($conf->categorie->enabled)
{
$moreforfilter.=$langs->trans('Categories'). ': ';
$moreforfilter.=$htmlother->select_categories(2,$search_categ,'search_categ');
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
}
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid)
{
$moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
$moreforfilter.=$htmlother->select_salesrepresentatives($search_sale,'search_sale');
}
if ($moreforfilter)
{
print '<tr class="liste_titre">';
print '<td class="liste_titre" colspan="9">';
print $moreforfilter;
print '</td></tr>';
}
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Company"),"clients.php","s.nom","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Town"),"clients.php","s.ville","",$param,"",$sortfield,$sortorder);
@ -132,7 +182,7 @@ if ($result)
print '</a>&nbsp;<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->rowid.'">'.stripslashes($obj->nom).'</a></td>';
print '<td>'.$obj->ville.'</td>';
print '<td>'.$obj->code_client.'</td>';
print '<td align="right">'.dol_print_date($obj->datec).'</td>';
print '<td align="right">'.dol_print_date($db->jdate($obj->datec)).'</td>';
print "</tr>\n";
$i++;
}

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -21,12 +21,13 @@
/**
* \file htdocs/comm/prospect/prospects.php
* \ingroup prospect
* \brief Page de la liste des prospects
* \brief Page to list prospects
* \version $Id$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/prospect.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formother.class.php");
$langs->load("propal");
$langs->load("companies");
@ -102,6 +103,7 @@ $sql = "SELECT code, label, sortorder, ".$sortwhere;
$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
$sql.= " WHERE active > 0";
$sql.= " ORDER BY sortorder";
$resql = $db->query($sql);
if ($resql)
{
@ -156,7 +158,9 @@ if ($_GET["action"] == 'cstc')
* View
*/
$sql = "SELECT s.rowid, s.nom, s.ville, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea,";
$htmlother=new FormOther($db);
$sql = "SELECT s.rowid, s.nom, s.ville, s.datec, s.datea,";
$sql.= " st.libelle as stcomm, s.prefix_comm, s.fk_stcomm, s.fk_prospectlevel,";
$sql.= " d.nom as departement";
// Updated by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/enhance-prospect-searching.html)
@ -166,7 +170,7 @@ if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user";
if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_societe";
$sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st";
// We'll need this table joined to the select in order to filter by sale
if ($search_sale) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if ($search_sale || !$user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
// We'll need this table joined to the select in order to filter by categ
if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as cs";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
@ -175,10 +179,8 @@ $sql.= " WHERE s.fk_stcomm = st.id";
$sql.= " AND s.client in (2, 3)";
$sql.= " AND s.entity = ".$conf->entity;
if ($user->societe_id) $sql.= " AND s.rowid = " .$user->societe_id;
// Join for the needed table to filter by sale
if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc";
// Join for the needed table to filter by categ
if ($search_categ) $sql.= " AND s.rowid = cs.fk_societe";
if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
if ($search_categ) $sql.= " AND s.rowid = cs.fk_societe"; // Join for the needed table to filter by categ
if (isset($stcomm) && $stcomm != '') $sql.= " AND s.fk_stcomm=".$stcomm;
if ($_GET["search_nom"]) $sql .= " AND s.nom like '%".addslashes(strtolower($_GET["search_nom"]))."%'";
@ -188,20 +190,19 @@ if ($search_levels)
{
$sql .= " AND s.fk_prospectlevel IN (".$search_levels.')';
}
// Insert salee filter
// Insert sale filter
if ($search_sale)
{
$sql .= " AND sc.fk_user = ".$search_sale;
$sql .= " AND sc.fk_user = ".addslashes($search_sale);
}
// Insert categ filter
if ($search_categ)
{
$sql .= " AND cs.fk_categorie = ".$search_categ;
$sql .= " AND cs.fk_categorie = ".addslashes($search_categ);
}
if ($socname)
{
$sql .= " AND s.nom like '%".addslashes(strtolower($socname))."%'";
$sql .= " AND s.nom like '%".addslashes($socname)."%'";
$sortfield = "s.nom";
$sortorder = "ASC";
}
@ -214,8 +215,8 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$nbtotalofrecords = $db->num_rows($result);
}
$sql .= " ORDER BY $sortfield $sortorder, s.nom ASC";
$sql .= $db->plimit($conf->liste_limit+1, $offset);
$sql.= " ORDER BY $sortfield $sortorder, s.nom ASC";
$sql.= $db->plimit($conf->liste_limit+1, $offset);
$resql = $db->query($sql);
if ($resql)
@ -246,25 +247,10 @@ if ($resql)
$param.='&amp;search_cstc['.((int) $key).']=false';
}
}
// Store the potentiels filters in the URL
if ($search_level_from != '')
{
$param.='&amp;search_level_from='.$search_level_from;
}
if ($search_level_to != '')
{
$param.='&amp;search_level_to='.$search_level_to;
}
// Store the categ filter in the URL
if ($search_categ != '')
{
$param.='&amp;search_categ='.$search_categ;
}
// Store the sale filter in the URL
if ($search_sale != '')
{
$param.='&amp;search_sale='.$search_sale;
}
if ($search_level_from != '') $param.='&amp;search_level_from='.$search_level_from;
if ($search_level_to != '') $param.='&amp;search_level_to='.$search_level_to;
if ($search_categ != '') $param.='&amp;search_categ='.$search_categ;
if ($search_sale != '') $param.='&amp;search_sale='.$search_sale;
// $param and $urladd should have the same value
$urladd = $param;
@ -274,73 +260,30 @@ if ($resql)
// Print the search-by-sale and search-by-categ filters
print '<form method="get" action="prospects.php" id="formulaire_recherche">';
$moreforfilter='';
print '<table class="liste" width="100%">';
// Filter on categories
$moreforfilter='';
if ($conf->categorie->enabled)
{
$moreforfilter.=$langs->trans('Categories'). ': ';
$moreforfilter.=$htmlother->select_categories(2,$search_categ,'search_categ');
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
}
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid)
{
// Select each sales and print them in a select input
$moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
$moreforfilter.='<select class="flat" name="search_sale">';
$moreforfilter.='<option value="">'.$langs->trans('All').'</option>';
$sql_usr = "SELECT u.rowid, u.name, u.firstname, u.login";
$sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql_usr.= " WHERE u.entity IN (0,".$conf->entity.")";
$sql_usr.= " ORDER BY u.name ASC ";
$resql_usr = $db->query($sql_usr);
if ($resql_usr)
{
while ($obj_usr = $db->fetch_object($resql_usr))
{
$moreforfilter.='<option value="'.$obj_usr->rowid.'"';
if ($obj_usr->rowid == $search_sale)
$moreforfilter.=' selected="true"';
$moreforfilter.='>';
$moreforfilter.=stripslashes($obj_usr->firstname)." ".stripslashes($obj_usr->name)." (".$obj_usr->login.')';
$moreforfilter.='</option>';
$i++;
}
$db->free($resql_usr);
}
else
{
dol_print_error($db);
}
$moreforfilter.='</select> &nbsp; &nbsp; &nbsp; ';
$moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
$moreforfilter.=$htmlother->select_salesrepresentatives($search_sale,'search_sale');
}
// Include Categorie class
if ($conf->categorie->enabled)
if ($moreforfilter)
{
require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
// Load list of "categories"
$static_categs = new Categorie($db);
$tab_categs = $static_categs->get_full_arbo(2);
// Print a select with each of them
$moreforfilter.=$langs->trans('Categories'). ': ';
$moreforfilter.='<select class="flat" name="search_categ">';
$moreforfilter.='<option value="">'.$langs->trans('All').'</option>';
if (is_array($tab_categs))
{
foreach ($tab_categs as $categ)
{
$moreforfilter.='<option value="'.$categ['id'].'"';
if ($categ['id'] == $search_categ)
$moreforfilter.=' selected="true"';
$moreforfilter.='>'.dol_trunc($categ['fulllabel'],50,'middle').'</option>';
}
}
$moreforfilter.='</select><br/>';
print '<tr class="liste_titre">';
print '<td class="liste_titre" colspan="9">';
print $moreforfilter;
print '</td></tr>';
}
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Company"),"prospects.php","s.nom","",$param,"valign=\"center\"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Town"),"prospects.php","s.ville","",$param,"",$sortfield,$sortorder);
@ -404,12 +347,6 @@ if ($resql)
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre" colspan="9">';
print $moreforfilter;
print '</td></tr>';
$i = 0;
$var=true;
@ -431,7 +368,7 @@ if ($resql)
print "<td>".$obj->ville."&nbsp;</td>";
print "<td align=\"center\">$obj->departement</td>";
// Creation date
print "<td align=\"center\">".dol_print_date($obj->datec)."</td>";
print "<td align=\"center\">".dol_print_date($db->jdate($obj->datec))."</td>";
// Level
print "<td align=\"center\">";
print $prospectstatic->LibLevel($obj->fk_prospectlevel);

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -26,6 +26,7 @@
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/html.formother.class.php");
$langs->load("suppliers");
$langs->load("orders");
@ -54,39 +55,45 @@ $pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="nom";
// Load categ filters
$search_categ = isset($_GET["search_categ"])?$_GET["search_categ"]:$_POST["search_categ"];
/*
* View
*/
* View
*/
$htmlother=new FormOther($db);
llxHeader();
/*
* Mode Liste
*
*/
$sql = "SELECT s.rowid as socid, s.nom, s.ville,".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm";
$sql.= " , code_fournisseur, code_compta_fournisseur";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st";
if ($_GET["cat"]) $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cf";
if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cf";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.fk_stcomm = st.id AND s.fournisseur=1";
if ($_GET["cat"]) $sql .= " AND cf.fk_societe = s.rowid AND cf.fk_categorie='".$_GET["cat"]."'";
if ($search_categ) $sql.= " AND s.rowid = cf.fk_societe"; // Join for the needed table to filter by categ
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
if ($socname) {
$sql .= " AND lower(s.nom) like '%".strtolower($socname)."%'";
$sortfield = "lower(s.nom)";
$sortorder = "ASC";
$sql .= " AND s.nom like '%".addslashes($socname)."%'";
$sortfield = "s.nom";
$sortorder = "ASC";
}
if ($search_nom)
{
$sql .= " AND s.nom LIKE '%".$search_nom."%'";
$sql .= " AND s.nom LIKE '%".addslashes($search_nom)."%'";
}
if ($search_ville)
{
$sql .= " AND s.ville LIKE '%".$search_ville."%'";
$sql .= " AND s.ville LIKE '%".addslashes($search_ville)."%'";
}
// Insert categ filter
if ($search_categ)
{
$sql .= " AND cf.fk_categorie = ".addslashes($search_categ);
}
// Count total nb of records
@ -97,73 +104,91 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($conf->liste_limit+1, $offset);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$num = $db->num_rows($resql);
$i = 0;
$param = "&amp;search_nom=".$search_nom."&amp;search_code=".$search_code."&amp;search_ville=".$search_ville;
print_barre_liste($langs->trans("ListOfSuppliers"), $page, "liste.php", $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
$param = "&amp;search_nom=".$search_nom."&amp;search_code=".$search_code."&amp;search_ville=".$search_ville;
if ($search_categ != '') $param.='&amp;search_categ='.$search_categ;
print '<form action="liste.php?cat='.$_GET["cat"].'" method="GET">';
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,'valign="middle"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.ville","",$param,'valign="middle"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AccountancyCode"),$_SERVER["PHP_SELF"],"s.code_compta","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"datec","",$param,'align="center"',$sortfield,$sortorder);
print '<td class="liste_titre">&nbsp;</td>';
print "</tr>\n";
print_barre_liste($langs->trans("ListOfSuppliers"), $page, "liste.php", $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
print '<tr class="liste_titre">';
print '<form action="liste.php?cat='.$_GET["cat"].'" method="GET">';
print '<table class="liste" width="100%">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_nom" value="'.$search_nom.'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_ville" value="'.$search_ville.'"></td>';
// Filter on categories
$moreforfilter='';
if ($conf->categorie->enabled)
{
$moreforfilter.=$langs->trans('Categories'). ': ';
$moreforfilter.=$htmlother->select_categories(1,$search_categ,'search_categ');
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
}
if ($moreforfilter)
{
print '<tr class="liste_titre">';
print '<td class="liste_titre" colspan="9">';
print $moreforfilter;
print '</td></tr>';
}
print '<td align="left" class="liste_titre">';
print '<input class="flat" type="text" size="10" name="search_code_fournisseur" value="'.$_GET["search_code_fournisseur"].'">';
print '</td>';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,'valign="middle"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.ville","",$param,'valign="middle"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AccountancyCode"),$_SERVER["PHP_SELF"],"s.code_compta","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"datec","",$param,'align="center"',$sortfield,$sortorder);
print '<td class="liste_titre">&nbsp;</td>';
print "</tr>\n";
print '<td align="left" class="liste_titre">';
print '<input class="flat" type="text" size="10" name="search_compta" value="'.$_GET["search_compta"].'">';
print '</td>';
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_nom" value="'.$search_nom.'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_ville" value="'.$search_ville.'"></td>';
print '<td align="left" class="liste_titre">';
print '<input class="flat" type="text" size="10" name="search_code_fournisseur" value="'.$_GET["search_code_fournisseur"].'">';
print '</td>';
print '<td align="left" class="liste_titre">';
print '<input class="flat" type="text" size="10" name="search_compta" value="'.$_GET["search_compta"].'">';
print '</td>';
print '<td class="liste_titre" colspan="2" align="right"><input class="liste_titre" type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'"></td>';
print '<td class="liste_titre" colspan="2" align="right"><input class="liste_titre" type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'"></td>';
print '</tr>';
print '</tr>';
$var=True;
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);
$var=!$var;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").'</a>';
print "&nbsp;<a href=\"fiche.php?socid=".$obj->socid."\">".$obj->nom."</a></td>\n";
print "<td>".$obj->ville."</td>\n";
print '<td align="left">'.$obj->code_fournisseur.'&nbsp;</td>';
print '<td align="left">'.$obj->code_compta_fournisseur.'&nbsp;</td>';
print '<td align="center">'.dol_print_date($obj->datec).'</td>';
print "<td>&nbsp;</td>\n";
print "</tr>\n";
$i++;
}
print "</table>\n";
print "</form>\n";
$db->free($resql);
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").'</a>';
print "&nbsp;<a href=\"fiche.php?socid=".$obj->socid."\">".$obj->nom."</a></td>\n";
print "<td>".$obj->ville."</td>\n";
print '<td align="left">'.$obj->code_fournisseur.'&nbsp;</td>';
print '<td align="left">'.$obj->code_compta_fournisseur.'&nbsp;</td>';
print '<td align="center">'.dol_print_date($obj->datec).'</td>';
print "<td>&nbsp;</td>\n";
print "</tr>\n";
$i++;
}
print "</table>\n";
print "</form>\n";
$db->free($resql);
}
else
else
{
dol_print_error($db);
dol_print_error($db);
}
$db->close();

View File

@ -232,6 +232,85 @@ class FormOther
return $return;
}
/**
* \brief Return select list for categories (to use in form search selectors)
* \param type Type of categories (0=product, 1=suppliers, 2=customers, 3=members)
* \param selected Preselected value
* \param htmlname Name of combo list
* \return return Html combo list code
*/
function select_categories($type,$selected=0,$htmlname='search_categ')
{
global $langs;
require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
// Load list of "categories"
$static_categs = new Categorie($this->db);
$tab_categs = $static_categs->get_full_arbo($type);
// Print a select with each of them
$moreforfilter ='<select class="flat" name="'.$htmlname.'">';
$moreforfilter.='<option value="">&nbsp;</option>';
if (is_array($tab_categs))
{
foreach ($tab_categs as $categ)
{
$moreforfilter.='<option value="'.$categ['id'].'"';
if ($categ['id'] == $selected) $moreforfilter.=' selected="true"';
$moreforfilter.='>'.dol_trunc($categ['fulllabel'],50,'middle').'</option>';
}
}
$moreforfilter.='</select>';
return $moreforfilter;
}
/**
* \brief Return select list for categories (to use in form search selectors)
* \param selected Preselected value
* \param htmlname Name of combo list
* \return return Html combo list code
*/
function select_salesrepresentatives($selected=0,$htmlname='search_sale')
{
global $conf;
// Select each sales and print them in a select input
$moreforfilter ='<select class="flat" name="'.$htmlname.'">';
$moreforfilter.='<option value="">&nbsp;</option>';
$sql_usr = "SELECT u.rowid, u.name, u.firstname, u.login";
$sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql_usr.= " WHERE u.entity IN (0,".$conf->entity.")";
$sql_usr.= " ORDER BY u.name ASC";
$resql_usr = $this->db->query($sql_usr);
if ($resql_usr)
{
while ($obj_usr = $this->db->fetch_object($resql_usr))
{
$moreforfilter.='<option value="'.$obj_usr->rowid.'"';
if ($obj_usr->rowid == $selected) $moreforfilter.=' selected="true"';
$moreforfilter.='>';
$moreforfilter.=$obj_usr->firstname." ".$obj_usr->name." (".$obj_usr->login.')';
$moreforfilter.='</option>';
$i++;
}
$this->db->free($resql_usr);
}
else
{
dol_print_error($db);
}
$moreforfilter.='</select>';
return $moreforfilter;
}
/**
* \brief Retourn list of project and tasks
* \param selected Pre-selected value

View File

@ -245,7 +245,7 @@ if ($resql)
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label",$param,"","",$sortfield,$sortorder);
if ($conf->barcode->enabled) print_liste_field_titre($langs->trans("BarCode"),"liste.php", "p.barcode",$param,"",'align="right"',$sortfield,$sortorder);
if ($conf->barcode->enabled) print_liste_field_titre($langs->trans("BarCode"),"liste.php", "p.barcode",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateModification"),"liste.php", "p.tms",$param,"",'align="center"',$sortfield,$sortorder);
if ($conf->service->enabled && $type != 0) print_liste_field_titre($langs->trans("Duration"),"liste.php", "p.duration",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SellingPrice"),"liste.php", "p.price",$param,"",'align="right"',$sortfield,$sortorder);
@ -263,7 +263,7 @@ if ($resql)
print '</td>';
if ($conf->barcode->enabled)
{
print '<td class="liste_titre" align="right">';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="sbarcode" size="6" value="'.$sbarcode.'">';
print '</td>';
}