[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * $Id: index.php,v 1.81.2.1 2005/12/30 12:02:56 tipaul Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/index.php,v $ 21 */ 22 23 /** 24 \file htdocs/comm/index.php 25 \ingroup commercial 26 \brief Page acceuil de la zone commercial 27 \version $Revision: 1.81.2.1 $ 28 */ 29 30 require ("./pre.inc.php"); 31 32 if (!$user->rights->commercial->main->lire) 33 accessforbidden(); 34 35 if ($conf->contrat->enabled) 36 require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); 37 38 $langs->load("commercial"); 39 $langs->load("orders"); 40 41 // Sécurité accés client 42 $socidp=''; 43 if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; } 44 if ($user->societe_id > 0) 45 { 46 $action = ''; 47 $socidp = $user->societe_id; 48 } 49 50 $max=5; 51 52 llxHeader(); 53 54 /* 55 * Actions 56 */ 57 58 if (isset($_GET["action"]) && $_GET["action"] == 'add_bookmark') 59 { 60 $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$_GET["socidp"]." AND fk_user=".$user->id; 61 if (! $db->query($sql) ) 62 { 63 dolibarr_print_error($db); 64 } 65 $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$_GET["socidp"].", now(),".$user->id.");"; 66 if (! $db->query($sql) ) 67 { 68 dolibarr_print_error($db); 69 } 70 } 71 72 if (isset($_GET["action"]) && $_GET["action"] == 'del_bookmark') 73 { 74 $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=".$_GET["bid"]; 75 $result = $db->query($sql); 76 } 77 78 79 /* 80 * Affichage page 81 */ 82 83 print_fiche_titre($langs->trans("CommercialArea")); 84 85 print '<table border="0" width="100%" class="notopnoleftnoright">'; 86 87 print '<tr><td valign="top" width="30%" class="notopnoleft">'; 88 89 90 /* 91 * Recherche Propal 92 */ 93 if ($conf->propal->enabled && $user->rights->propale->lire) 94 { 95 $var=false; 96 print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal.php">'; 97 print '<table class="noborder" width="100%">'; 98 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAProposal").'</td></tr>'; 99 print '<tr '.$bc[$var].'>'; 100 print '<td nowrap>'.$langs->trans("Ref").':</td><td><input type="text" class="flat" name="sf_ref" size="18"></td>'; 101 print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>'; 102 print '<tr '.$bc[$var].'><td nowrap>'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>'; 103 print '</tr>'; 104 print "</table></form>\n"; 105 print "<br />\n"; 106 } 107 108 /* 109 * Recherche Contrat 110 */ 111 if ($conf->contrat->enabled) 112 { 113 $var=false; 114 print '<form method="post" action="'.DOL_URL_ROOT.'/contrat/liste.php">'; 115 print '<table class="noborder" width="100%">'; 116 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAContract").'</td></tr>'; 117 print '<tr '.$bc[$var].'>'; 118 print '<td nowrap>'.$langs->trans("Ref").':</td><td><input type="text" class="flat" name="search_contract" size="18"></td>'; 119 print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>'; 120 print '<tr '.$bc[$var].'><td nowrap>'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>'; 121 print '</tr>'; 122 print "</table></form>\n"; 123 print "<br>"; 124 } 125 126 /* 127 * Liste des propal brouillons 128 */ 129 if ($conf->propal->enabled && $user->rights->propale->lire) 130 { 131 $sql = "SELECT p.rowid, p.ref, p.price, s.idp, s.nom"; 132 $sql.= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; 133 $sql.= " WHERE p.fk_statut = 0 and p.fk_soc = s.idp"; 134 $sql.= " AND s.idp = ".$socidp; 135 136 $resql=$db->query($sql); 137 if ($resql) 138 { 139 $total = 0; 140 $num = $db->num_rows($resql); 141 if ($num > 0) 142 { 143 print '<table class="noborder" width="100%">'; 144 print "<tr class=\"liste_titre\">"; 145 print "<td colspan=\"3\">".$langs->trans("ProposalsDraft")."</td></tr>"; 146 147 $i = 0; 148 $var=true; 149 while ($i < $num) 150 { 151 $obj = $db->fetch_object($resql); 152 $var=!$var; 153 print '<tr '.$bc[$var].'><td nowrap>'."<a href=\"".DOL_URL_ROOT."/comm/propal.php?propalid=".$obj->rowid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$obj->ref.'</a></td>'; 154 print '<td><a href="fiche.php?socid='.$obj->idp.'">'.dolibarr_trunc($obj->nom,18).'</a></td><td align="right">'.price($obj->price).'</td></tr>'; 155 $i++; 156 $total += $obj->price; 157 } 158 if ($total>0) 159 { 160 $var=!$var; 161 print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>"; 162 } 163 print "</table><br>"; 164 } 165 $db->free($resql); 166 } 167 } 168 169 170 /* 171 * Commandes brouillons 172 */ 173 if ($conf->commande->enabled) 174 { 175 $langs->load("orders"); 176 $sql = "SELECT c.rowid, c.ref, c.total_ttc, s.nom, s.idp"; 177 $sql.= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; 178 $sql.= " WHERE c.fk_soc = s.idp AND c.fk_statut = 0"; 179 if ($socidp) 180 { 181 $sql .= " AND c.fk_soc = $socidp"; 182 } 183 184 $resql = $db->query($sql); 185 if ($resql) 186 { 187 $total = 0; 188 $num = $db->num_rows($resql); 189 if ($num) 190 { 191 print '<table class="noborder" width="100%">'; 192 print '<tr class="liste_titre">'; 193 print '<td colspan="3">'.$langs->trans("DraftOrders").'</td></tr>'; 194 195 $i = 0; 196 $var = true; 197 while ($i < $num) 198 { 199 $var=!$var; 200 $obj = $db->fetch_object($resql); 201 print "<tr $bc[$var]><td nowrap><a href=\"../commande/fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref."</a></td>"; 202 print '<td><a href="fiche.php?socid='.$obj->idp.'">'.dolibarr_trunc($obj->nom,18).'</a></td>'; 203 print '<td align="right" nowrap="nowrap">'.price($obj->total_ttc).'</td></tr>'; 204 $i++; 205 $total += $obj->total_ttc; 206 } 207 if ($total>0) 208 { 209 $var=!$var; 210 print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>"; 211 } 212 print "</table><br>"; 213 } 214 } 215 } 216 217 /* 218 * Bookmark 219 * 220 */ 221 $sql = "SELECT s.idp, s.nom,b.rowid as bid"; 222 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."bookmark as b"; 223 $sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = ".$user->id; 224 if ($socidp) 225 { 226 $sql .= " AND s.idp = $socidp"; 227 } 228 $sql .= " ORDER BY lower(s.nom) ASC"; 229 230 if ( $db->query($sql) ) 231 { 232 $num = $db->num_rows(); 233 234 if ($num) 235 { 236 237 $i = 0; 238 239 print '<table class="noborder" width="100%">'; 240 print "<tr class=\"liste_titre\">"; 241 print "<td colspan=\"2\">".$langs->trans("Bookmarks")."</td>"; 242 print "</tr>\n"; 243 $var=true; 244 245 while ($i < $num) 246 { 247 $obj = $db->fetch_object(); 248 $var = !$var; 249 print "<tr $bc[$var]>"; 250 print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>'; 251 print '<td align="right"><a href="index.php?action=del_bookmark&bid='.$obj->bid.'">'; 252 print img_delete(); 253 print '</a></td>'; 254 print '</tr>'; 255 $i++; 256 } 257 print '</table>'; 258 } 259 } 260 261 print '</td><td valign="top" width="70%" class="notopnoleftnoright">'; 262 263 264 /* 265 * Actions commerciales a faire 266 * 267 */ 268 269 $sql = "SELECT a.id, a.label, ".$db->pdate("a.datea")." as da, c.code, c.libelle, a.fk_user_author, s.nom as sname, s.idp"; 270 $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s"; 271 $sql .= " WHERE c.id=a.fk_action AND a.percent < 100 AND s.idp = a.fk_soc"; 272 if ($socidp) 273 { 274 $sql .= " AND s.idp = $socidp"; 275 } 276 $sql .= " ORDER BY a.datea DESC, a.id DESC"; 277 278 $resql=$db->query($sql); 279 if ($resql) 280 { 281 $num = $db->num_rows($resql); 282 if ($num > 0) 283 { 284 print '<table class="noborder" width="100%">'; 285 print '<tr class="liste_titre"><td colspan="9">'.$langs->trans("ActionsToDo").'</td></tr>'; 286 $var = true; 287 $i = 0; 288 289 while ($i < $num) 290 { 291 $obj = $db->fetch_object($resql); 292 $var=!$var; 293 294 print "<tr $bc[$var]>"; 295 if ($oldyear == strftime("%Y",$obj->da) ) 296 { 297 print '<td width="30" align="center">|</td>'; 298 } 299 else 300 { 301 print '<td width="30" align="center">'.strftime("%Y",$obj->da)."</td>\n"; 302 $oldyear = strftime("%Y",$obj->da); 303 } 304 305 if ($oldmonth == strftime("%Y%b",$obj->da) ) 306 { 307 print '<td width="30" align="center">|</td>'; 308 } 309 else 310 { 311 print '<td width="30" align="center">' .strftime("%b",$obj->da)."</td>\n"; 312 $oldmonth = strftime("%Y%b",$obj->da); 313 } 314 315 print '<td width="20">'.strftime("%d",$obj->da)."</td>\n"; 316 if (date("U",$obj->da) < time()) 317 { 318 print "<td>".img_warning("Late")."</td>"; 319 } else { 320 print "<td> </td>"; 321 } 322 print "<td><a href=\"action/fiche.php?id=$obj->id\">".img_object($langs->trans("ShowTask"),"task"); 323 $transcode=$langs->trans("Action".$obj->code); 324 $libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle); 325 print $libelle; 326 print '</a></td>'; 327 print "<td>$obj->label</td>"; 328 329 print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCustomer"),"company").' '.$obj->sname.'</a></td>'; 330 $i++; 331 } 332 // TODO Ajouter rappel pour "il y a des contrats à mettre en service" 333 // TODO Ajouter rappel pour "il y a des contrats qui arrivent à expiration" 334 print "</table><br>"; 335 } 336 $db->free($resql); 337 } 338 else 339 { 340 dolibarr_print_error($db); 341 } 342 343 344 /* 345 * Derniers clients enregistrés 346 */ 347 if ($user->rights->societe->lire) 348 { 349 $sql = "SELECT s.idp,s.nom,".$db->pdate("datec")." as datec"; 350 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; 351 $sql.= " WHERE s.client = 1"; 352 if ($user->societe_id > 0) 353 { 354 $sql .= " AND s.idp = $user->societe_id"; 355 } 356 $sql .= " ORDER BY s.datec DESC"; 357 $sql .= $db->plimit($max, 0); 358 359 $resql = $db->query($sql); 360 if ($resql) 361 { 362 $num = $db->num_rows($resql); 363 if ($num) 364 { 365 $langs->load("boxes"); 366 367 print '<table class="noborder" width="100%">'; 368 print '<tr class="liste_titre">'; 369 print '<td colspan="2">'.$langs->trans("BoxTitleLastCustomers",$max).'</td></tr>'; 370 371 $i = 0; 372 $var=false; 373 while ($i < $num) 374 { 375 $objp = $db->fetch_object($resql); 376 print "<tr $bc[$var]>"; 377 print "<td nowrap><a href=\"".DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp."\">".img_object($langs->trans("ShowCustomer"),"company")." ".$objp->nom."</a></td>"; 378 print '<td align="right" nowrap>'.dolibarr_print_date($objp->datec)."</td>"; 379 print '</tr>'; 380 $i++; 381 $var=!$var; 382 383 } 384 print "</table><br>"; 385 386 $db->free($resql); 387 } 388 } 389 } 390 391 392 /* 393 * Dernières actions commerciales effectuées 394 */ 395 396 $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.code, c.libelle, a.fk_user_author, s.nom as sname, s.idp"; 397 $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s"; 398 $sql .= " WHERE c.id=a.fk_action AND a.percent >= 100 AND s.idp = a.fk_soc"; 399 if ($socidp) 400 { 401 $sql .= " AND s.idp = $socidp"; 402 } 403 $sql .= " ORDER BY a.datea DESC"; 404 $sql .= $db->plimit($max, 0); 405 406 $resql=$db->query($sql); 407 if ($resql) 408 { 409 $num = $db->num_rows($resql); 410 411 print '<table class="noborder" width="100%">'; 412 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("LastDoneTasks",$max).'</td></tr>'; 413 $var = true; 414 $i = 0; 415 416 while ($i < $num) 417 { 418 $obj = $db->fetch_object($resql); 419 $var=!$var; 420 421 print "<tr $bc[$var]>"; 422 print "<td><a href=\"action/fiche.php?id=$obj->id\">".img_object($langs->trans("ShowTask"),"task"); 423 $transcode=$langs->trans("Action".$obj->code); 424 $libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle); 425 print $libelle; 426 print '</a></td>'; 427 428 print "<td>".dolibarr_print_date($obj->da)."</td>"; 429 print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCustomer"),"company").' '.$obj->sname.'</a></td>'; 430 $i++; 431 } 432 // TODO Ajouter rappel pour "il y a des contrats à mettre en service" 433 // TODO Ajouter rappel pour "il y a des contrats qui arrivent à expiration" 434 print "</table><br>"; 435 436 $db->free($resql); 437 } 438 else 439 { 440 dolibarr_print_error($db); 441 } 442 443 444 /* 445 * Derniers contrat 446 * 447 */ 448 if ($conf->contrat->enabled && 0) // \todo A REFAIRE DEPUIS NOUVEAU CONTRAT 449 { 450 $langs->load("contracts"); 451 452 $sql = "SELECT s.nom, s.idp, c.statut, c.rowid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo"; 453 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."product as p WHERE c.fk_soc = s.idp and c.fk_product = p.rowid"; 454 if ($socidp) 455 { 456 $sql .= " AND s.idp = $socidp"; 457 } 458 $sql .= " ORDER BY c.tms DESC"; 459 $sql .= $db->plimit(5, 0); 460 461 if ( $db->query($sql) ) 462 { 463 $num = $db->num_rows(); 464 465 if ($num > 0) 466 { 467 print '<table class="noborder" width="100%">'; 468 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("LastContracts",5).'</td></tr>'; 469 $i = 0; 470 471 $contrat=new Contrat($db); 472 473 $var=false; 474 while ($i < $num) 475 { 476 $obj = $db->fetch_object(); 477 print "<tr $bc[$var]><td><a href=\"../contrat/fiche.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowContract","contract"))." ".$obj->ref."</a></td>"; 478 print "<td><a href=\"fiche.php?socid=$obj->idp\">".img_object($langs->trans("ShowCompany","company"))." ".$obj->nom."</a></td>\n"; 479 print "<td align=\"right\">".$contrat->LibStatut($obj->enservice)."</td></tr>\n"; 480 $var=!$var; 481 $i++; 482 } 483 print "</table><br>"; 484 } 485 } 486 else 487 { 488 dolibarr_print_error($db); 489 } 490 } 491 492 /* 493 * Propales ouvertes 494 * 495 */ 496 if ($conf->propal->enabled && $user->rights->propale->lire) 497 { 498 $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp"; 499 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; 500 $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = 1"; 501 if ($socidp) $sql .= " AND s.idp = $socidp"; 502 $sql .= " ORDER BY p.rowid DESC"; 503 504 $result=$db->query($sql); 505 if ($result) 506 { 507 $total = 0; 508 $num = $db->num_rows($result); 509 $i = 0; 510 if ($num > 0) 511 { 512 $var=true; 513 514 print '<table class="noborder" width="100%">'; 515 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("ProposalsOpened").'</td></tr>'; 516 while ($i < $num) 517 { 518 $obj = $db->fetch_object($result); 519 $var=!$var; 520 print "<tr $bc[$var]><td width=\"15%\" nowrap><a href=\"propal.php?propalid=".$obj->propalid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$obj->ref."</a>"; 521 if ($obj->dp < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); 522 print "</td>"; 523 print "<td><a href=\"fiche.php?socid=$obj->idp\">".img_object($langs->trans("ShowCompany"),"company")." ".dolibarr_trunc($obj->nom,44)."</a></td>\n"; 524 print "<td align=\"right\">"; 525 print dolibarr_print_date($obj->dp)."</td>\n"; 526 print "<td align=\"right\">".price($obj->price)."</td></tr>\n"; 527 $i++; 528 $total += $obj->price; 529 } 530 if ($total>0) { 531 print '<tr class="liste_total"><td colspan="3" align="right">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td></tr>"; 532 } 533 print "</table><br>"; 534 } 535 } 536 else 537 { 538 dolibarr_print_error($db); 539 } 540 } 541 542 /* 543 * Dernières propales fermées 544 * 545 */ 546 547 if ($conf->propal->enabled && $user->rights->propale->lire) { 548 $NBMAX=5; 549 550 $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp"; 551 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; 552 $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut > 1"; 553 if ($socidp) 554 { 555 $sql .= " AND s.idp = $socidp"; 556 } 557 $sql .= " ORDER BY p.rowid DESC"; 558 $sql .= $db->plimit($NBMAX, 0); 559 560 include_once (DOL_DOCUMENT_ROOT."/propal.class.php"); 561 $propalstatic=new Propal($db); 562 563 if ( $db->query($sql) ) 564 { 565 $num = $db->num_rows(); 566 567 $i = 0; 568 print '<table class="noborder" width="100%">'; 569 print '<tr class="liste_titre"><td colspan="6">'.$langs->trans("LastClosedProposals",$NBMAX).'</td></tr>'; 570 $var=False; 571 while ($i < $num) 572 { 573 $objp = $db->fetch_object(); 574 print "<tr $bc[$var]>"; 575 print '<td nowrap>'; 576 print '<a href="propal.php?propalid='.$objp->propalid.'">'.img_object($langs->trans("ShowPropal"),"propal").' '; 577 print $objp->ref.'</a></td>'; 578 print '<td><a href="fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).'</a></td>'; 579 print "<td> </td>"; 580 print "<td align=\"right\">"; 581 print dolibarr_print_date($objp->dp)."</td>\n"; 582 print "<td align=\"right\">".price($objp->price)."</td>\n"; 583 print "<td align=\"center\">".$propalstatic->LibStatut($objp->fk_statut,0)."</td>\n"; 584 print "</tr>\n"; 585 $i++; 586 $var=!$var; 587 588 } 589 590 print "</table>"; 591 $db->free(); 592 } 593 } 594 595 596 print '</td></tr>'; 597 print '</table>'; 598 599 $db->close(); 600 601 602 llxFooter('$Date: 2005/12/30 12:02:56 $ - $Revision: 1.81.2.1 $'); 603 ?>
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 |
![]() |