[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * $Id: fiche.php,v 1.27 2005/12/12 14:25:41 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/contrat/fiche.php,v $ 20 * 21 */ 22 23 require "./pre.inc.php"; 24 require_once DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php"; 25 26 $mesg = ''; 27 28 if ($_POST["action"] == 'add' && $user->rights->telephonie->ligne->creer) 29 { 30 $contrat = new TelephonieContrat($db); 31 32 $contrat->client_comm = $_POST["client_comm"]; 33 $contrat->client = $_POST["client"]; 34 $contrat->client_facture = $_POST["client_facture"]; 35 $contrat->commercial_sign = $_POST["commercial_sign"]; 36 $contrat->note = $_POST["note"]; 37 38 if ( $contrat->create($user) == 0) 39 { 40 Header("Location: fiche.php?id=".$contrat->id); 41 } 42 else 43 { 44 $_GET["action"] = 'create'; 45 } 46 47 } 48 49 if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->telephonie->ligne->creer) 50 { 51 $contrat = new TelephonieContrat($db); 52 $contrat->id = $_GET["id"]; 53 54 $contrat->client = $_POST["client"]; 55 $contrat->client_facture = $_POST["client_facture"]; 56 $contrat->fournisseur = $_POST["fournisseur"]; 57 $contrat->commercial = $_POST["commercial"]; 58 $contrat->concurrent = $_POST["concurrent"]; 59 $contrat->note = $_POST["note"]; 60 $contrat->mode_paiement = $_POST["mode_paiement"]; 61 62 $contrat->commercial_suiv_id = $_POST["commercial_suiv"]; 63 64 if ( $contrat->update($user) == 0) 65 { 66 $action = ''; 67 $mesg = 'Fiche mise à jour'; 68 Header("Location: fiche.php?id=".$contrat->id); 69 } 70 else 71 { 72 $action = 're-edit'; 73 $mesg = 'Fiche non mise à jour !' . "<br>" . $entrepot->mesg_error; 74 } 75 } 76 77 if ($_POST["action"] == 'addcontact' && $user->rights->telephonie->ligne->creer) 78 { 79 $contrat = new TelephonieContrat($db); 80 $contrat->id = $_GET["id"]; 81 82 if ( $contrat->add_contact_facture($_POST["contact_id"]) ) 83 { 84 Header("Location: fiche.php?id=".$contrat->id); 85 } 86 } 87 88 if ($_POST["action"] == 'addpo' && $user->rights->telephonie->ligne->creer) 89 { 90 $contrat = new TelephonieContrat($db); 91 $contrat->fetch($_GET["id"]); 92 93 $contrat->addpo($_POST["montant"], $user); 94 Header("Location: fiche.php?id=".$contrat->id); 95 } 96 97 98 if ($_GET["action"] == 'delcontact' && $user->rights->telephonie->ligne->creer) 99 { 100 $contrat = new TelephonieContrat($db); 101 $contrat->id = $_GET["id"]; 102 103 if ( $contrat->del_contact_facture($_GET["contact_id"]) ) 104 { 105 Header("Location: fiche.php?id=".$contrat->id); 106 } 107 } 108 109 if ($_GET["action"] == 'delete' && $user->rights->telephonie->ligne->creer) 110 { 111 $contrat = new TelephonieContrat($db); 112 $contrat->id = $_GET["id"]; 113 114 $contrat->delete() ; 115 Header("Location: index.php"); 116 } 117 118 119 120 llxHeader("","","Fiche Contrat"); 121 122 if ($cancel == $langs->trans("Cancel")) 123 { 124 $action = ''; 125 } 126 127 /* 128 * Création en 2 étape 129 * 130 */ 131 if ($_GET["action"] == 'create' && $user->rights->telephonie->ligne->creer) 132 { 133 $form = new Form($db); 134 print_titre("Nouveau contrat"); 135 136 if (is_object($ligne)) 137 { 138 // La création a échouée 139 print $ligne->error_message; 140 } 141 else 142 { 143 $ligne = new LigneTel($db); 144 } 145 146 print '<form action="fiche.php" method="GET">'; 147 print '<input type="hidden" name="action" value="create_line">'; 148 149 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 150 151 print '<tr><td width="20%">Client</td><td >'; 152 $ff = array(); 153 $sql = "SELECT idp, nom, ville FROM ".MAIN_DB_PREFIX."societe WHERE client=1 ORDER BY nom "; 154 if ( $db->query( $sql) ) 155 { 156 $num = $db->num_rows(); 157 if ( $num > 0 ) 158 { 159 $i = 0; 160 while ($i < $num) 161 { 162 $row = $db->fetch_row($i); 163 $ff[$row[0]] = $row[1] . " (".$row[2].")"; 164 165 $i++; 166 } 167 } 168 $db->free(); 169 } 170 $form->select_array("client_comm",$ff,$ligne->client_comm); 171 print '</td></tr>'; 172 173 print '<tr><td> </td><td><input type="submit" value="Créer"></td></tr>'."\n"; 174 print '</table>'."\n"; 175 print '</form>'; 176 } 177 elseif ($_GET["action"] == 'create_line' && $_GET["client_comm"] > 0 && $user->rights->telephonie->ligne->creer) 178 { 179 $form = new Form($db); 180 print_titre("Nouveau contrat"); 181 182 if (is_object($ligne)) 183 { 184 // La création a échouée 185 print $ligne->error_message; 186 } 187 else 188 { 189 $ligne = new LigneTel($db); 190 } 191 192 $socc = new Societe($db); 193 $socc->fetch($_GET["client_comm"]); 194 195 if ( $socc->id > 0) 196 { 197 198 if (strlen($socc->code_client) == 0) 199 { 200 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 201 print '<tr><td width="20%">Client</td><td >'; 202 print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$socc->id.'">'.$socc->nom.'</a>'; 203 print '</td></tr>'; 204 205 print '<tr><td width="20%">Code client</td><td >'; 206 print $socc->code_client; 207 print '</td></tr>'; 208 print '</table><br /><br />'; 209 print 'Impossible de créer un contrat pour cette société, vous devez au préalablement lui affecter un code client.'; 210 } 211 elseif (strlen($socc->code_client) > 0 && $socc->check_codeclient() <> 0) 212 { 213 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 214 print '<tr><td width="20%">Client</td><td >'; 215 print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$socc->id.'">'.$socc->nom.'</a>'; 216 print '</td></tr>'; 217 218 print '<tr><td width="20%">Code client</td><td >'; 219 print $socc->code_client; 220 print '</td></tr>'; 221 print '</table><br /><br />'; 222 print 'Le code client de cette société est incorrect, vous devez lui affecter un code client correct.'; 223 } 224 else 225 { 226 print "<form action=\"fiche.php\" method=\"post\">\n"; 227 print '<input type="hidden" name="action" value="add">'; 228 print '<input type="hidden" name="client_comm" value="'.$socc->id.'">'."\n"; 229 230 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 231 print '<tr><td width="20%">Client</td><td >'; 232 print $socc->nom; 233 print '</td></tr>'; 234 235 print '<tr><td width="20%">Code client</td><td >'; 236 print $socc->code_client; 237 print '</td></tr>'; 238 239 print '<tr><td width="20%">Client (Agence/Filiale)</td><td >'; 240 $ff = array(); 241 $sql = "SELECT idp, nom, ville FROM ".MAIN_DB_PREFIX."societe"; 242 $sql .= " WHERE client=1"; 243 $sql .= " AND (idp = $socc->id OR parent = $socc->id)"; 244 $sql .= " ORDER BY nom "; 245 246 if ( $db->query( $sql) ) 247 { 248 $num = $db->num_rows(); 249 if ( $num > 0 ) 250 { 251 $i = 0; 252 while ($i < $num) 253 { 254 $row = $db->fetch_row(); 255 $ff[$row[0]] = $row[1] . " (".$row[2].")"; 256 $i++; 257 } 258 } 259 $db->free(); 260 } 261 else 262 { 263 print $sql; 264 } 265 $form->select_array("client",$ff,$ligne->client); 266 print '</td></tr>'; 267 268 print '<tr><td width="20%">Client à facturer</td><td >'; 269 $ff = array(); 270 $sql = "SELECT idp, nom, ville FROM ".MAIN_DB_PREFIX."societe WHERE client=1"; 271 $sql .= " AND (idp = $socc->id OR parent = $socc->id)"; 272 $sql .= " ORDER BY nom "; 273 if ( $db->query( $sql) ) 274 { 275 $num = $db->num_rows(); 276 if ( $num > 0 ) 277 { 278 $i = 0; 279 while ($i < $num) 280 { 281 $row = $db->fetch_row(); 282 $ff[$row[0]] = $row[1] . " (".$row[2].")"; 283 $i++; 284 } 285 } 286 $db->free(); 287 } 288 $form->select_array("client_facture",$ff,$ligne->client_facture); 289 print '</td></tr>'; 290 291 /* 292 * Commercial 293 */ 294 295 print '<tr><td width="20%">Commercial Signature</td><td >'; 296 $ff = array(); 297 $sql = "SELECT u.rowid, u.firstname, u.name"; 298 $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."usergroup_user as ug"; 299 $sql .= " WHERE u.rowid = ug.fk_user"; 300 $sql .= " AND ug.fk_usergroup = '".TELEPHONIE_GROUPE_COMMERCIAUX_ID."'"; 301 $sql .= " ORDER BY name "; 302 if ( $db->query( $sql) ) 303 { 304 $num = $db->num_rows(); 305 if ( $num > 0 ) 306 { 307 $i = 0; 308 while ($i < $num) 309 { 310 $row = $db->fetch_row($i); 311 $ff[$row[0]] = $row[1] . " " . $row[2]; 312 $i++; 313 } 314 } 315 $db->free(); 316 317 } 318 319 $form->select_array("commercial_sign",$ff,$ligne->commercial); 320 321 print '</td></tr>'; 322 323 print '<tr><td width="20%" valign="top">Note</td><td>'."\n"; 324 print '<textarea name="note" rows="4" cols="50">'."\n"; 325 print stripslashes($ligne->note); 326 print '</textarea></td></tr>'."\n"; 327 328 print '<tr><td> </td><td><input type="submit" value="Créer"></td></tr>'."\n"; 329 print '</table>'."\n"; 330 print '</form>'; 331 332 /* 333 * Contrats existants 334 */ 335 $sql = "SELECT c.rowid, c.ref, s.idp as socidp, s.nom "; 336 $sql .= ", sf.idp as sfidp, sf.nom as sfnom"; 337 $sql .= ", sa.idp as saidp, sa.nom as sanom"; 338 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; 339 $sql .= " , ".MAIN_DB_PREFIX."societe as sf"; 340 $sql .= " , ".MAIN_DB_PREFIX."societe as sa"; 341 $sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c"; 342 $sql .= " WHERE c.fk_client_comm = s.idp"; 343 $sql .= " AND c.fk_soc = sa.idp"; 344 $sql .= " AND c.fk_soc_facture = sf.idp"; 345 $sql .= " AND s.idp = ".$_GET["client_comm"]; 346 347 $result = $db->query($sql); 348 if ($result) 349 { 350 $num = $db->num_rows(); 351 $i = 0; 352 if ($num > 0) 353 { 354 print"<br />\n<!-- debut table -->\n"; 355 print_titre("Contrats existants"); 356 print '<br /><table class="noborder" width="100%" cellspacing="0" cellpadding="4">'; 357 print '<tr class="liste_titre"><td>Réf</td>'; 358 print '<td>Client</td><td>Client (Agence/Filiale)</td>'; 359 print '<td>Client facturé</td>'; 360 print "</tr>\n"; 361 362 $var=True; 363 364 while ($i < $num) 365 { 366 $obj = $db->fetch_object(); 367 $var=!$var; 368 369 print "<tr $bc[$var]><td>"; 370 print '<a href="'.DOL_URL_ROOT.'/telephonie/contrat/fiche.php?id='.$obj->rowid.'">'; 371 print img_file(); 372 print '</a> '; 373 print '<a href="fiche.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n"; 374 375 print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socidp.'">'.stripslashes($obj->nom).'</a></td>'; 376 377 print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socidp.'">'.stripslashes($obj->sanom).'</a></td>'; 378 print '<td><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$obj->sfidp.'">'.stripslashes($obj->sfnom).'</a></td>'; 379 380 print "</tr>\n"; 381 $i++; 382 } 383 print "</table>"; 384 } 385 386 $db->free(); 387 } 388 else 389 { 390 print $db->error() . ' ' . $sql; 391 } 392 } 393 } 394 else 395 { 396 print "Erreur"; 397 } 398 } 399 else 400 { 401 /* Consultation */ 402 if ($_GET["id"]) 403 { 404 if ($_GET["action"] <> 're-edit') 405 { 406 $contrat = new TelephonieContrat($db); 407 408 if ($contrat->fetch($_GET["id"]) == 0) 409 { 410 $result = 1; 411 } 412 } 413 414 if ($result == 1) 415 { 416 $client_comm = new TelephonieClient($db); 417 $client_comm->fetch($contrat->client_comm_id, $user); 418 } 419 420 if (!$client_comm->perm_read) 421 { 422 print "Lecture non authorisée"; 423 } 424 425 if ( $result && $client_comm->perm_read) 426 { 427 428 $contrat->log_consult($user,'r'); 429 430 if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') 431 { 432 433 $h=0; 434 $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/fiche.php?id=".$contrat->id; 435 $head[$h][1] = $langs->trans("Contrat"); 436 $hselected = $h; 437 $h++; 438 439 $nser = $contrat->count_associated_services(); 440 441 $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/services.php?id=".$contrat->id; 442 if ($nser > 0) 443 { 444 $head[$h][1] = $langs->trans("Services")." (".$nser.")"; 445 } 446 else 447 { 448 $head[$h][1] = $langs->trans("Services"); 449 } 450 $h++; 451 452 $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/stats.php?id=".$contrat->id; 453 $head[$h][1] = $langs->trans("Stats"); 454 $h++; 455 456 $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/info.php?id=".$contrat->id; 457 $head[$h][1] = $langs->trans("Infos"); 458 $h++; 459 460 $contrat->load_previous_next_id(); 461 $previous_ref = $contrat->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?id='.$contrat->ref_previous.'">'.img_previous().'</a>':''; 462 $next_ref = $contrat->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?id='.$contrat->ref_next.'">'.img_next().'</a>':''; 463 dolibarr_fiche_head($head, $hselected, 'Contrat : '.$contrat->ref); 464 465 //print_fiche_titre('Fiche Contrat', $mesg); 466 467 print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">Fiche Contrat</td>'; 468 print '<td class="nobordernopadding"><a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>'; 469 print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table><br />'; 470 471 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 472 473 //$client_comm = new Societe($db); 474 //$client_comm->fetch($contrat->client_comm_id); 475 476 print '<tr><td width="20%">Référence</td><td>'.$contrat->ref.'</td>'; 477 print '<td>Facturé : '.$contrat->facturable.'</td><td align="right">'; 478 print '<img src="statut'.$contrat->statut.'.png"> '; 479 print $contrat->statuts[$contrat->statut].'</td></tr>'; 480 print '<tr><td width="20%">Client</td><td>'; 481 print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$client_comm->id.'">'; 482 483 print $client_comm->nom.'</a></td><td colspan="2">'.$client_comm->code_client; 484 print '</td></tr>'; 485 486 if ($contrat->client_id <> $contrat->client_comm_id) 487 { 488 $client = new Societe($db, $contrat->client_id); 489 $client->fetch($contrat->client_id); 490 491 print '<tr><td width="20%">Client (Agence/Filiale)</td><td>'; 492 print $client->nom.'<br />'; 493 print $client->cp . " " .$client->ville; 494 print '</td><td colspan="2" valign="top">'.$client->code_client; 495 print '</td></tr>'; 496 } 497 498 $client_facture = new Societe($db); 499 $client_facture->fetch($contrat->client_facture_id); 500 501 print '<tr><td width="20%">Client Facturé</td><td>'; 502 print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='; 503 print $client_facture->id.'">'; 504 print $client_facture->nom.'</a><br />'; 505 print $client_facture->cp . " " .$client_facture->ville; 506 507 print '</td><td valign="top">'.$client_facture->code_client; 508 print '</td><td>'; 509 510 511 512 if ($contrat->mode_paiement == 'pre') 513 { 514 print 'RIB : '.$client_facture->display_rib(); 515 } 516 else 517 { 518 print 'Paiement par virement'; 519 } 520 521 print '</td></tr>'; 522 523 $commercial = new User($db, $contrat->commercial_sign_id); 524 $commercial->fetch(); 525 526 print '<tr><td width="20%">Commercial Signature</td>'; 527 print '<td>'.$commercial->fullname.'</td>'; 528 529 print '<td>Grille tarif</td><td>'.$contrat->grille_tarif_nom.'</td></tr>'; 530 531 $commercial_suiv = new User($db, $contrat->commercial_suiv_id); 532 $commercial_suiv->fetch(); 533 534 print '<tr><td width="20%">Commercial Suivi</td>'; 535 print '<td colspan="3">'.$commercial_suiv->fullname.'</td></tr>'; 536 537 /* Prise d'ordre */ 538 print '<tr><td width="20%">Prise d\'ordre mensuelle</td>'; 539 $po = $contrat->priseordre_totale(); 540 print '<td colspan="3">'.$po.' euros HT</td></tr>'; 541 542 /* 543 print '<tr><td width="20%">Statut</td><td colspan="2">'; 544 print '<img src="./graph'.$contrat->statut.'.png"> '; 545 print $contrat->statuts[$contrat->statut]; 546 print '</td></tr>'; 547 */ 548 549 /* Contacts */ 550 print '<tr><td valign="top" width="20%">Contact facture</td>'; 551 print '<td valign="top" colspan="3">'; 552 553 $sql = "SELECT c.idp, c.name, c.firstname, c.email "; 554 $sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c"; 555 $sql .= ",".MAIN_DB_PREFIX."telephonie_contrat_contact_facture as cf"; 556 $sql .= " WHERE c.idp = cf.fk_contact AND cf.fk_contrat = ".$contrat->id." ORDER BY name "; 557 if ( $db->query( $sql) ) 558 { 559 $num = $db->num_rows(); 560 if ( $num > 0 ) 561 { 562 $i = 0; 563 while ($i < $num) 564 { 565 $row = $db->fetch_row($i); 566 567 print $row[1] . " " . $row[2] . " <".$row[3]."><br />"; 568 $i++; 569 } 570 } 571 $db->free(); 572 573 } 574 else 575 { 576 print $sql; 577 } 578 print '</td></tr>'; 579 /* Fin Contacts */ 580 581 print "</table><br />"; 582 583 /* Lignes */ 584 585 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 586 587 $sql = "SELECT l.ligne, l.statut, l.rowid, l.remise, l.techno, f.nom as fournisseur"; 588 $sql .= ", ss.code_client, ss.nom as agence, l.support"; 589 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; 590 $sql .= " , ".MAIN_DB_PREFIX."societe as ss"; 591 $sql .= " , ".MAIN_DB_PREFIX."telephonie_fournisseur as f"; 592 $sql .= " WHERE l.fk_fournisseur = f.rowid"; 593 $sql .= " AND l.fk_soc = ss.idp "; 594 $sql .= " AND l.fk_contrat = ".$contrat->id; 595 $sql .= " ORDER BY l.statut ASC, l.ligne ASC"; 596 597 if ( $db->query( $sql) ) 598 { 599 $numlignes = $db->num_rows(); 600 if ( $numlignes > 0 ) 601 { 602 $i = 0; 603 604 $ligne = new LigneTel($db); 605 606 print '<tr class="liste_titre"><td width="15%" valign="center">Ligne'; 607 print '</td><td>Agence/Filiale</td><td align="center">Statut</td><td align="center">Support'; 608 print '</td><td>Fournisseur</td>'; 609 610 print "</tr>\n"; 611 612 while ($i < $numlignes) 613 { 614 $obj = $db->fetch_object($i); 615 $var=!$var; 616 617 print "<tr $bc[$var]><td>"; 618 619 print '<img src="../graph'.$obj->statut.'.png"> '; 620 621 print '<a href="'.DOL_URL_ROOT.'/telephonie/ligne/fiche.php?id='.$obj->rowid.'">'; 622 print img_file(); 623 624 print '</a> '; 625 626 print '<a href="'.DOL_URL_ROOT.'/telephonie/ligne/fiche.php?id='.$obj->rowid.'">'.dolibarr_print_phone($obj->ligne)."</a></td>\n"; 627 628 print '<td>'.$obj->code_client." ".$obj->agence."</td>\n"; 629 print '<td align="center">'.$ligne->statuts[$obj->statut]."</td>\n"; 630 631 print '<td align="center">'.$obj->support."</td>\n"; 632 print "<td>".$obj->fournisseur." - \n"; 633 print $obj->techno."</td>\n"; 634 print "</tr>\n"; 635 $i++; 636 } 637 } 638 $db->free(); 639 640 } 641 else 642 { 643 print $db->error(); 644 print $sql; 645 } 646 647 print "</table>"; 648 } 649 650 /* 651 * Edition 652 * 653 * 654 * 655 */ 656 657 if ($_GET["action"] == 'edit' || $action == 're-edit') 658 { 659 660 $h=0; 661 $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/fiche.php?id=".$contrat->id; 662 $head[$h][1] = $langs->trans("Contrat"); 663 $hselected = $h; 664 $h++; 665 666 dolibarr_fiche_head($head, $hselected, 'Contrat : '.$contrat->ref); 667 668 print_fiche_titre('Edition du contrat', $mesg); 669 670 print '<form action="fiche.php?id='.$contrat->id.'" method="post">'; 671 print '<input type="hidden" name="action" value="update">'; 672 673 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 674 675 print '<tr><td width="20%">Référence</td><td>'.$contrat->ref.'</td>'; 676 print '<td>Facturé : '.$contrat->facturable.'</td></tr>'; 677 678 $client_comm = new Societe($db, $contrat->client_comm_id); 679 $client_comm->fetch($contrat->client_comm_id); 680 681 print '<tr><td width="20%">Client</td><td>'; 682 print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$client_comm->id.'">'; 683 684 print $client_comm->nom.'</a></td><td>'.$client_comm->code_client; 685 print '</td></tr>'; 686 687 688 print '<tr><td width="20%">Client (Agence/Filiale)</td><td colspan="2">'; 689 print '<select name="client">'; 690 691 $sql = "SELECT idp, nom, ville FROM ".MAIN_DB_PREFIX."societe WHERE client=1"; 692 $sql .= " AND (idp = $client_comm->id OR parent = $client_comm->id)"; 693 $sql .= " ORDER BY nom "; 694 if ( $db->query( $sql) ) 695 { 696 $num = $db->num_rows(); 697 if ( $num > 0 ) 698 { 699 $i = 0; 700 while ($i < $num) 701 { 702 $row = $db->fetch_row($i); 703 print '<option value="'.$row[0] .'"'; 704 if ($row[0] == $contrat->client_id) 705 { 706 print " SELECTED"; 707 } 708 print '>'.stripslashes($row[1]). " (".stripslashes($row[2]).")"; 709 $i++; 710 } 711 } 712 $db->free(); 713 } 714 715 print '</select></td></tr>'; 716 717 print '<tr><td width="20%">Client à facturer</td><td colspan="2">'."\n"; 718 print '<select name="client_facture">'."\n"; 719 720 721 $sql = "SELECT idp, nom,ville FROM ".MAIN_DB_PREFIX."societe WHERE client=1 "; 722 $sql .= " AND (idp = $client_comm->id OR parent = $client_comm->id)"; 723 $sql .= " ORDER BY nom "; 724 if ( $db->query( $sql) ) 725 { 726 $num = $db->num_rows(); 727 if ( $num > 0 ) 728 { 729 $i = 0; 730 while ($i < $num) 731 { 732 $row = $db->fetch_row($i); 733 print '<option value="'.$row[0] .'"'; 734 if ($row[0] == $contrat->client_facture_id) 735 { 736 print " SELECTED"; 737 } 738 print '>'.stripslashes($row[1]). " (".stripslashes($row[2]).")"; 739 740 $i++; 741 } 742 } 743 $db->free(); 744 } 745 746 print '</select></td></tr>'; 747 748 /* 749 * 750 */ 751 print '<tr><td width="20%">Mode de réglement</td>'; 752 print '<td colspan="2">'; 753 754 if ($user->rights->telephonie->contrat->paiement) 755 { 756 print '<select name="mode_paiement">'."\n"; 757 758 if ($contrat->mode_paiement == 'pre') 759 { 760 print '<option value="pre" SELECTED>Prélèvement</option>'; 761 print '<option value="vir">Virement</option>'; 762 } 763 else 764 { 765 print '<option value="pre">Prélèvement</option>'; 766 print '<option value="vir" SELECTED>Virement</option>'; 767 } 768 print '</select>'; 769 } 770 else 771 { 772 print '<input type="hidden" name="mode_paiement" value="'.$contrat->mode_paiement.'">'; 773 774 if ($contrat->mode_paiement == 'pre') 775 { 776 print 'Prélèvement'; 777 } 778 else 779 { 780 print 'Virement'; 781 } 782 } 783 784 785 print '</td></tr>'; 786 787 788 /* 789 * Commercial 790 */ 791 792 $commercial = new User($db, $contrat->commercial_sign_id); 793 $commercial->fetch(); 794 795 print '<tr><td width="20%">Commercial Signature</td>'; 796 print '<td colspan="2">'.$commercial->fullname.'</td></tr>'; 797 798 print "\n".'<tr><td width="20%">Commercial Suivi</td><td colspan="2">'; 799 print '<select name="commercial_suiv">'; 800 801 $sql = "SELECT u.rowid, u.name, u.firstname"; 802 $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."usergroup_user as ug"; 803 $sql .= " WHERE u.rowid = ug.fk_user"; 804 $sql .= " AND ug.fk_usergroup = '".TELEPHONIE_GROUPE_COMMERCIAUX_ID."'"; 805 $sql .= " ORDER BY name "; 806 807 if ( $db->query( $sql) ) 808 { 809 $num = $db->num_rows(); 810 if ( $num > 0 ) 811 { 812 $i = 0; 813 while ($i < $num) 814 { 815 $row = $db->fetch_row($i); 816 print '<option value="'.$row[0] .'"'; 817 if ($row[0] == $contrat->commercial_suiv_id) 818 { 819 print " SELECTED"; 820 } 821 print '>'.$row[2]." ".$row[1]; 822 823 824 $i++; 825 } 826 } 827 $db->free(); 828 } 829 830 print '</select></td></tr>'; 831 832 /* 833 * 834 * 835 */ 836 print '<tr><td width="20%" valign="top">Note</td><td colspan="2">'; 837 print '<textarea name="note" rows="4" cols="50">'; 838 print "</textarea></td></tr>"; 839 840 print '<tr><td align="center" colspan="3"><input type="submit" value="Mettre à jour">'; 841 print '<a class="tabAction" href="fiche.php?id='.$contrat->id.'">Annuler</a></td></tr>'; 842 print '</table>'."\n"; 843 print '</form>'."\n"; 844 845 } 846 847 /* 848 * Contact 849 * 850 * 851 */ 852 if ($_GET["action"] == 'contact') 853 { 854 print_fiche_titre('Ajouter un contact', $mesg); 855 856 print '<form action="fiche.php?id='.$contrat->id.'" method="post">'; 857 print '<input type="hidden" name="action" value="addcontact">'; 858 859 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 860 861 $sql = "SELECT c.idp, c.name, c.firstname, c.email "; 862 $sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c"; 863 $sql .= ",".MAIN_DB_PREFIX."telephonie_contrat_contact_facture as cf"; 864 $sql .= " WHERE c.idp = cf.fk_contact "; 865 $sql .= " AND cf.fk_contrat = ".$contrat->id." ORDER BY name "; 866 867 if ( $db->query( $sql) ) 868 { 869 $num = $db->num_rows(); 870 if ( $num > 0 ) 871 { 872 $i = 0; 873 while ($i < $num) 874 { 875 $row = $db->fetch_row($i); 876 877 print '<tr><td valign="top" width="20%">Contact facture '.$i.'</td>'; 878 print '<td valign="top">'.$row[1] . " " . $row[2] . " <".$row[3].">"; 879 print '</td><td>'; 880 print '<a href="fiche.php?id='.$contrat->id.'&action=delcontact&contact_id='.$row[0].'">'; 881 print img_delete(); 882 print "</a></td></tr>"; 883 $i++; 884 } 885 } 886 $db->free(); 887 888 } 889 else 890 { 891 print $sql; 892 } 893 894 895 print '<tr><td valign="top" width="20%">Contact</td><td valign="top" colspan="2">'; 896 897 $sql = "SELECT idp, name, firstname, email "; 898 $sql .= " FROM ".MAIN_DB_PREFIX."socpeople "; 899 $sql .= " WHERE fk_soc in (".$contrat->client_facture_id.",".$contrat->client_id.")"; 900 $sql .= " ORDER BY name "; 901 902 if ( $db->query( $sql) ) 903 { 904 print '<select name="contact_id">'; 905 $num = $db->num_rows(); 906 if ( $num > 0 ) 907 { 908 $i = 0; 909 while ($i < $num) 910 { 911 $row = $db->fetch_row($i); 912 print '<option value="'.$row[0] .'"'; 913 print '>'.$row[1] . " " . $row[2] . " <".$row[3].">"; 914 $i++; 915 } 916 } 917 $db->free(); 918 print '</select>'; 919 } 920 else 921 { 922 print $sql; 923 } 924 925 print '<p>Contact auquel est envoyé la facture par email</p></td></tr>'; 926 927 print '<tr><td colspan="3" align="center">'; 928 if ($num > 0) 929 { 930 print '<input type="submit" value="Ajouter">'; 931 } 932 print '<a href="fiche.php?id='.$contrat->id.'">Annuler</a></td></tr>'; 933 print '</table>'; 934 print '</form>'; 935 936 } 937 938 /* 939 * Prise d'ordre 940 * 941 * 942 */ 943 if ($_GET["action"] == 'po' && $po == 0) 944 { 945 print_fiche_titre('Ajouter une prise d\'ordre mensuelle'); 946 947 print '<form action="fiche.php?id='.$contrat->id.'" method="post">'; 948 print '<input type="hidden" name="action" value="addpo">'; 949 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 950 print '<tr><td valign="top" width="20%">Montant mensuel</td><td valign="top" colspan="2">'; 951 print '<input name="montant" size="8"> euros HT</td></tr>'; 952 print '</td></tr>'; 953 print '<tr><td colspan="3" align="center">'; 954 print '<input type="submit" value="Ajouter">'; 955 956 print '<a href="fiche.php?id='.$contrat->id.'">Annuler</a></td></tr>'; 957 print '</table>'; 958 print '</form>'; 959 960 } 961 /* 962 * 963 */ 964 print '</div>'; 965 966 /* ************************************************************************** */ 967 /* */ 968 /* Barre d'action */ 969 /* */ 970 /* ************************************************************************** */ 971 972 print "\n<br>\n<div class=\"tabsAction\">\n"; 973 974 if ($_GET["action"] == '') 975 { 976 if ($user->rights->telephonie->ligne->creer && $contrat->statut <> 6) 977 { 978 print '<a class="tabAction" href="'.DOL_URL_ROOT.'/telephonie/ligne/fiche.php?action=create&contratid='.$contrat->id.'">Nouvelle ligne</a>'; 979 } 980 981 if ($user->rights->telephonie->ligne->creer && $contrat->statut <> 6) 982 { 983 print "<a class=\"tabAction\" href=\"fiche.php?action=contact&id=$contrat->id\">".$langs->trans("Contact")."</a>"; 984 } 985 986 if ($user->rights->telephonie->ligne->creer && $po == 0 && $contrat->statut <> 6) 987 { 988 print "<a class=\"tabAction\" href=\"fiche.php?action=po&id=$contrat->id\">Ajouter une prise d'ordre</a>"; 989 } 990 if ($user->rights->telephonie->ligne->creer && $contrat->statut <> 6) 991 { 992 print "<a class=\"tabAction\" href=\"fiche.php?action=edit&id=$contrat->id\">".$langs->trans("Edit")."</a>"; 993 } 994 995 if ($user->rights->telephonie->ligne->creer && $numlignes == 0 && $contrat->statut <> 6) 996 { 997 print "<a class=\"butDelete\" href=\"fiche.php?action=delete&id=$contrat->id\">".$langs->trans("Delete")."</a>"; 998 } 999 } 1000 1001 print "</div>"; 1002 } 1003 } 1004 else 1005 { 1006 print "Error"; 1007 } 1008 } 1009 1010 1011 1012 1013 $db->close(); 1014 1015 llxFooter("<em>Dernière modification $Date: 2005/12/12 14:25:41 $ révision $Revision: 1.27 $</em>"); 1016 ?>
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 |
![]() |