[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2003 Éric Seigne <erics@rycks.com> 4 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * 20 * $Id: index.php,v 1.36 2005/10/16 02:09:54 eldy Exp $ 21 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/contact/index.php,v $ 22 */ 23 24 /** 25 \file htdocs/contact/index.php 26 \ingroup societe 27 \brief Page liste des contacts 28 \version $Revision: 1.36 $ 29 */ 30 31 require ("./pre.inc.php"); 32 33 $langs->load("companies"); 34 $langs->load("suppliers"); 35 36 37 /* 38 * Sécurité accés client 39 */ 40 if ($user->societe_id > 0) 41 { 42 $action = ''; 43 $socid = $user->societe_id; 44 } 45 46 llxHeader(); 47 48 49 $search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"]; 50 $search_prenom=isset($_GET["search_prenom"])?$_GET["search_prenom"]:$_POST["search_prenom"]; 51 $search_societe=isset($_GET["search_societe"])?$_GET["search_societe"]:$_POST["search_societe"]; 52 $search_email=isset($_GET["search_email"])?$_GET["search_email"]:$_POST["search_email"]; 53 54 $type = isset($_GET["type"])?$_GET["type"]:$_POST["type"]; 55 $view=isset($_GET["view"])?$_GET["view"]:$_POST["view"]; 56 57 $sall=isset($_GET["contactname"])?$_GET["contactname"]:$_POST["contactname"]; 58 $sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; 59 $sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; 60 $page = isset($_GET["page"])?$_GET["page"]:$_POST["page"]; 61 62 if (! $sortorder) $sortorder="ASC"; 63 if (! $sortfield) $sortfield="p.name"; 64 if ($page < 0) { $page = 0 ; } 65 $limit = $conf->liste_limit; 66 $offset = $limit * $page ; 67 68 $titre=$langs->trans("ListOfContacts"); 69 if ($type == "c") { $titre=$langs->trans("ListOfCustomersContacts"); } 70 if ($type == "f") { $titre=$langs->trans("ListOfSuppliersContacts"); } 71 if ($view == 'phone') { $text="(Vue Téléphones)"; } 72 if ($view == 'mail') { $text="(Vue EMail)"; } 73 if ($view == 'recent') { $text="(Récents)"; } 74 $titre = $titre." $text"; 75 76 if ($_POST["button_removefilter"]) 77 { 78 $search_nom=""; 79 $search_prenom=""; 80 $search_societe=""; 81 $search_email=""; 82 $sall=""; 83 } 84 85 86 /* 87 * Mode liste 88 * 89 */ 90 91 $sql = "SELECT s.idp, s.nom, p.idp as cidp, p.name, p.firstname, p.email, p.phone, p.phone_mobile, p.fax "; 92 $sql .= "FROM ".MAIN_DB_PREFIX."socpeople as p "; 93 $sql .= "LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (s.idp = p.fk_soc) "; 94 $sql .= "WHERE 1=1 "; 95 96 if ($_GET["userid"]) // statut commercial 97 { 98 $sql .= " AND p.fk_user=".$_GET["userid"]; 99 } 100 if ($search_nom) // filtre sur le nom 101 { 102 $sql .= " AND p.name like '%".$search_nom."%'"; 103 } 104 if ($search_prenom) // filtre sur le prenom 105 { 106 $sql .= " AND p.firstname like '%".$search_prenom."%'"; 107 } 108 if ($search_societe) // filtre sur la societe 109 { 110 $sql .= " AND s.nom like '%".$search_societe."%'"; 111 } 112 if ($search_email) // filtre sur l'email 113 { 114 $sql .= " AND p.email like '%".$search_email."%'"; 115 } 116 if ($type == "f") // filtre sur type 117 { 118 $sql .= " AND fournisseur = 1"; 119 } 120 if ($type == "c") // filtre sur type 121 { 122 $sql .= " AND client = 1"; 123 } 124 if ($sall) 125 { 126 $sql .= " AND (p.name like '%".$sall."%' OR p.firstname like '%".$sall."%' OR p.email like '%".$sall."%') "; 127 } 128 if ($socid) 129 { 130 $sql .= " AND s.idp = $socid"; 131 } 132 133 if($_GET["view"] == "recent") 134 { 135 $sql .= " ORDER BY p.datec DESC " . $db->plimit( $limit + 1, $offset); 136 } 137 else 138 { 139 $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1, $offset); 140 } 141 142 $result = $db->query($sql); 143 144 if ($result) 145 { 146 $begin=$_GET["begin"]; 147 148 $num = $db->num_rows($result); 149 $i = 0; 150 151 print_barre_liste($titre ,$page, "index.php", '&begin='.$begin.'&view='.$_GET["view"].'&userid='.$_GET["userid"], $sortfield, $sortorder,'',$num); 152 153 print '<form method="post" action="index.php">'; 154 print '<input type="hidden" name="view" value="'.$view.'">'; 155 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; 156 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; 157 158 print '<table class="liste" width="100%">'; 159 160 if ($sall) 161 { 162 print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname")." ".$langs->trans("or")." ".$langs->trans("EMail")."): ".$sall; 163 } 164 165 // Ligne des titres 166 print '<tr class="liste_titre">'; 167 print_liste_field_titre($langs->trans("Lastname"),"index.php","p.name", $begin, "&type=$type&view=$view&search_nom=$search_nom&search_prenom=$search_prenom&search_societe=$search_societe&search_email=$search_email", "", $sortfield); 168 print_liste_field_titre($langs->trans("Firstname"),"index.php","p.firstname", $begin, "&type=$type&view=$view&search_nom=$search_nom&search_prenom=$search_prenom&search_societe=$search_societe&search_email=$search_email", "", $sortfield); 169 print_liste_field_titre($langs->trans("Company"),"index.php","s.nom", $begin, "&type=$type&view=$view&search_nom=$search_nom&search_prenom=$search_prenom&search_societe=$search_societe&search_email=$search_email", "", $sortfield); 170 print '<td class="liste_titre">'.$langs->trans("Phone").'</td>'; 171 172 if ($_GET["view"] == 'phone') 173 { 174 print '<td class="liste_titre">'.$langs->trans("Mobile").'</td>'; 175 print '<td class="liste_titre">'.$langs->trans("Fax").'</td>'; 176 } 177 else 178 { 179 print_liste_field_titre($langs->trans("EMail"),"index.php","p.email", $begin, "&type=$type&view=$view&search_nom=$search_nom&search_prenom=$search_prenom&search_societe=$search_societe&search_email=$search_email", "", $sortfield); 180 } 181 print '<td class="liste_titre"> </td>'; 182 print "</tr>\n"; 183 184 // Ligne des champs de filtres 185 print '<tr class="liste_titre">'; 186 print '<td class="liste_titre">'; 187 print '<input class="flat" type="text" name="search_nom" size="12" value="'.$search_nom.'">'; 188 print '</td>'; 189 print '<td class="liste_titre">'; 190 print '<input class="flat" type="text" name="search_prenom" size="10" value="'.$search_prenom.'">'; 191 print '</td>'; 192 print '<td class="liste_titre">'; 193 print '<input class="flat" type="text" name="search_societe" size="14" value="'.$search_societe.'">'; 194 print '</td>'; 195 print '<td class="liste_titre">'; 196 print ' '; 197 print '</td>'; 198 199 if ($_GET["view"] == 'phone') 200 { 201 print '<td class="liste_titre">'; 202 print ' '; 203 print '</td>'; 204 print '<td class="liste_titre">'; 205 print ' '; 206 print '</td>'; 207 } 208 else 209 { 210 print '<td class="liste_titre">'; 211 print '<input class="flat" type="text" name="search_email" size="12" value="'.$search_email.'">'; 212 print '</td>'; 213 } 214 215 print '<td class="liste_titre" align="right">'; 216 print '<input type="image" value="button_search" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">'; 217 print ' <input type="image" value="button_removefilter" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" alt="'.$langs->trans("RemoveFilter").'">'; 218 print '</td>'; 219 print '</tr>'; 220 221 $var=True; 222 while ($i < min($num,$limit)) 223 { 224 $obj = $db->fetch_object($result); 225 226 $var=!$var; 227 228 print "<tr $bc[$var]>"; 229 230 print '<td valign="center">'; 231 print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'">'; 232 print img_object($langs->trans("ShowContact"),"contact"); 233 print ' '.$obj->name.'</a></td>'; 234 print '<td>'.$obj->firstname.'</td>'; 235 print '<td>'; 236 if ($obj->idp) 237 { 238 print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'; 239 print img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,40).'</a>'; 240 } 241 else 242 { 243 print ' '; 244 } 245 print '</td>'; 246 print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actionid=1&contactid='.$obj->cidp.'&socid='.$obj->idp.'">'.dolibarr_print_phone($obj->phone).'</a> </td>'; 247 248 if ($_GET["view"] == 'phone') 249 { 250 print '<td>'.dolibarr_print_phone($obj->phone_mobile,$obj->fp_pays).' </td>'; 251 252 print '<td colspan="2">'.dolibarr_print_phone($obj->fax,$obj->fp_pays).' </td>'; 253 } 254 else 255 { 256 print '<td colspan="2">'; 257 if (! $obj->email) { 258 print ' '; 259 } 260 elseif (! ValidEmail($obj->email)) 261 { 262 print "Email Invalide !"; 263 } 264 else { 265 print '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>'; 266 } 267 print '</td>'; 268 } 269 270 print "</tr>\n"; 271 $i++; 272 } 273 print "</table>"; 274 275 print '</form>'; 276 277 $db->free($result); 278 } 279 else 280 { 281 dolibarr_print_error($db); 282 } 283 284 print '<br>'; 285 286 287 /* 288 * TODO A virer ? 289 * PhProjekt 290 */ 291 292 if (2==1 && (strlen($_GET["search_nom"]) OR strlen($_GET["search_prenom"]))) 293 { 294 295 296 $sortfield = "p.nachname"; 297 $sortorder = "ASC"; 298 299 $sql = "SELECT p.vorname, p.nachname, p.firma, p.email"; 300 $sql .= " FROM phprojekt.contacts as p"; 301 $sql .= " WHERE upper(p.nachname) like '%".$_GET["search_nom"]."%'"; 302 303 $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1, $offset); 304 305 306 $result = $db->query($sql); 307 308 if ($result) 309 { 310 $num = $db->num_rows($result); 311 $i = 0; 312 313 print '<table class="noborder" width="100%">'; 314 print '<tr class="liste_titre"><td>'; 315 print_liste_field_titre($langs->trans("Name"),"projekt.php","lower(p.name)", $begin); 316 print "</td><td>"; 317 print_liste_field_titre($langs->trans("Fristname"),"projekt.php","lower(p.firstname)", $begin); 318 print "</td><td>"; 319 print_liste_field_titre($langs->trans("Company"),"projekt.php","lower(s.nom)", $begin); 320 print '</td>'; 321 print '<td>'.$langs->trans("Phone").'</td>'; 322 323 if ($_GET["view"] == 'phone') 324 { 325 print '<td>'.$langs->trans("Mobile").'</td>'; 326 print '<td>'.$langs->trans("Fax").'</td>'; 327 } 328 else 329 { 330 print '<td>'.$langs->trans("Email").'</td>'; 331 } 332 333 print "</tr>\n"; 334 $var=True; 335 while ($i < min($num,$limit)) 336 { 337 $obj = $db->fetch_object( $i); 338 339 $var=!$var; 340 341 print "<tr $bc[$var]>"; 342 343 // Nom 344 print '<td valign="center">'; 345 print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'">'.img_file().' '.$obj->nachname.'</a></td>'; 346 print '<td>'.$obj->vorname.'</td>'; 347 348 print '<td>'; 349 print "<a href=\"".DOL_URL_ROOT."/comm/fiche.php?socid=$obj->idp\">$obj->firma</a></td>\n"; 350 351 352 print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actionid=1&contactid='.$obj->cidp.'&socid='.$obj->idp.'">'.dolibarr_print_phone($obj->phone).'</a> </td>'; 353 354 if ($_GET["view"] == 'phone') 355 { 356 print '<td>'.dolibarr_print_phone($obj->phone_mobile).' </td>'; 357 358 print '<td>'.dolibarr_print_phone($obj->fax).' </td>'; 359 } 360 else 361 { 362 print '<td><a href="mailto:'.$obj->email.'">'.$obj->email.'</a> '; 363 if (!valid_email($obj->email)) 364 { 365 print "Email Invalide !"; 366 } 367 print '</td>'; 368 } 369 370 print "</tr>\n"; 371 $i++; 372 } 373 print "</table>"; 374 $db->free(); 375 } 376 else 377 { 378 dolibarr_print_error($db); 379 } 380 381 } 382 383 384 385 $db->close(); 386 387 llxFooter('$Date: 2005/10/16 02:09:54 $ - $Revision: 1.36 $'); 388 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |