* Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * \file htdocs/compta/clients.php * \ingroup compta * \brief Show list of customers to add an new invoice * \version $Id$ */ require('../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/comm/action/class/actioncomm.class.php"); // Secrutiy check if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } if (! $user->rights->facture->lire) accessforbidden(); $langs->load("companies"); $page=$_GET["page"]; $sortorder=$_GET["sortorder"]; $sortfield=$_GET["sortfield"]; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="nom"; if ($page == -1) { $page = 0 ; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; /* * View */ llxHeader(); $thirdpartystatic=new Societe($db); if ($action == 'attribute_prefix') { $societe = new Societe($db, $socid); $societe->attribute_prefix($db, $socid); } if ($action == 'note') { $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".$note."' WHERE rowid=".$socid; $result = $db->query($sql); } if ($mode == 'search') { if ($mode-search == 'soc') { $sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s "; $sql.= " WHERE lower(s.nom) like '%".addslashes(strtolower($socname))."%'"; $sql.= " AND s.entity = ".$conf->entity; } $resql=$db->query($sql); if ($resql) { if ( $db->num_rows($resql) == 1) { $obj = $db->fetch_object($resql); $socid = $obj->rowid; } $db->free(); } } /* * Mode Liste * */ $sql = "SELECT s.rowid, s.nom, s.client, s.ville, s.datec, s.datea"; $sql.= ", st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta "; 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 (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_stcomm = st.id AND s.client=1"; $sql.= " AND s.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (dol_strlen($stcomm)) { $sql.= " AND s.fk_stcomm=$stcomm"; } if ($socname) { $sql.= " AND s.nom like '%".addslashes(strtolower($socname))."%'"; $sortfield = "s.nom"; $sortorder = "ASC"; } if ($_GET["search_nom"]) { $sql.= " AND s.nom like '%".addslashes(strtolower($_GET["search_nom"]))."%'"; } if ($_GET["search_compta"]) { $sql.= " AND s.code_compta like '%".addslashes($_GET["search_compta"])."%'"; } if ($_GET["search_code_client"]) { $sql.= " AND s.code_client like '%".addslashes($_GET["search_code_client"])."%'"; } if (dol_strlen($begin)) { $sql.= " AND s.nom like '".addslashes($begin)."'"; } if ($socid) { $sql.= " AND s.rowid = ".$socid; } $sql.= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($action == 'facturer') { print_barre_liste("Liste des clients facturables", $page, "clients.php","",$sortfield,$sortorder,'',$num); } else { print_barre_liste($langs->trans("ListOfCustomers"), $page, "clients.php","",$sortfield,$sortorder,'',$num); } print '
'; print ''; print ''; print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","",'valign="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.ville","","",'valign="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","",'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AccountancyCode"),$_SERVER["PHP_SELF"],"s.code_compta","","",'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"datec",$addu,"",'align="right"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $var=True; while ($i < min($num,$conf->liste_limit)) { $obj = $db->fetch_object($resql); $var=!$var; print ""; print ''; print ''; print ''; print ''; print ''; print "\n"; $i++; } print "
'; print ' '; print ''; print ''; print ''; print ''; print ''; print '
'; $thirdpartystatic->id=$obj->rowid; $thirdpartystatic->nom=$obj->nom; $thirdpartystatic->client=$obj->client; print $thirdpartystatic->getNomUrl(1,'compta'); print ''.$obj->ville.' '.$obj->code_client.' '.$obj->code_compta.' '.dol_print_date($db->jdate($obj->datec)).'
"; print '
'; $db->free($resql); } else { dol_print_error($db); } $db->close(); llxFooter('$Date$ - 1.46 $'); ?>