[ 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.26 2005/12/01 09:53:08 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/ligne/fiche.php,v $ 20 * 21 */ 22 23 require "./pre.inc.php"; 24 require_once DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php"; 25 require_once DOL_DOCUMENT_ROOT.'/telephonie/telephonie.contrat.class.php'; 26 27 $mesg = ''; 28 29 $dt = time(); 30 31 $h = strftime("%H",$dt); 32 $m = strftime("%M",$dt); 33 $s = strftime("%S",$dt); 34 35 if ($_POST["action"] == 'add' && $user->rights->telephonie->ligne->creer) 36 { 37 $ligne = new LigneTel($db); 38 $ligne->contrat = $_POST["contrat"]; 39 $ligne->numero = $_POST["numero"]; 40 $ligne->client_comm = $_POST["client_comm"]; 41 $ligne->client = $_POST["client"]; 42 $ligne->client_facture = $_POST["client_facture"]; 43 $ligne->fournisseur = $_POST["fournisseur"]; 44 $ligne->commercial_sign = $_POST["commercial_sign"]; 45 $ligne->commercial_suiv = $_POST["commercial_suiv"]; 46 $ligne->concurrent = $_POST["concurrent"]; 47 $ligne->remise = $_POST["remise"]; 48 $ligne->note = $_POST["note"]; 49 $ligne->techno = $_POST["techno"]; 50 51 if ( $ligne->create($user) == 0) 52 { 53 Header("Location: fiche.php?id=".$ligne->id); 54 } 55 else 56 { 57 $_GET["action"] = 'create'; 58 $_GET["contratid"] = $_POST["contrat"]; 59 } 60 } 61 62 if ($_GET["action"] == 'transfer' && $user->rights->telephonie->ligne->creer) 63 { 64 $ligne = new LigneTel($db); 65 $ligne->fetch_by_id($_GET["id"]); 66 67 if ( $ligne->transfer($user,$_POST["fournisseur"]) == 0) 68 { 69 Header("Location: fiche.php?id=".$ligne->id); 70 } 71 } 72 73 if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->telephonie->ligne->creer) 74 { 75 $ligne = new LigneTel($db); 76 $ligne->fetch_by_id($_GET["id"]); 77 78 if ( $ligne->delete($user) == 0) 79 { 80 Header("Location: index.php"); 81 } 82 } 83 84 if ($_POST["action"] == 'updateremise' && $user->rights->telephonie->ligne->creer) 85 { 86 $ligne = new LigneTel($db); 87 $ligne->id = $_GET["id"]; 88 89 if ( $ligne->SetRemise($user, $_POST["remise"], $_POST["comment"]) == 0) 90 { 91 Header("Location: fiche.php?id=".$ligne->id); 92 } 93 else 94 { 95 $_GET["action"] = 'editremise'; 96 } 97 } 98 99 if ($_POST["action"] == 'changecontrat' && $user->rights->telephonie->ligne->creer) 100 { 101 $ligne = new LigneTel($db); 102 $ligne->id = $_GET["id"]; 103 104 if ( $ligne->ChangeContrat($user, $_POST["contrat"]) == 0) 105 { 106 Header("Location: fiche.php?id=".$ligne->id); 107 } 108 } 109 110 if ($_POST["action"] == 'addcontact' && $user->rights->telephonie->ligne->creer) 111 { 112 $ligne = new LigneTel($db); 113 $ligne->id = $_GET["id"]; 114 115 if ( $ligne->add_contact($_POST["contact_id"]) ) 116 { 117 Header("Location: fiche.php?id=".$ligne->id); 118 } 119 120 } 121 122 123 if ($_GET["action"] == 'delcontact' && $user->rights->telephonie->ligne->creer) 124 { 125 $ligne = new LigneTel($db); 126 $ligne->id = $_GET["id"]; 127 128 if ( $ligne->del_contact($_GET["contact_id"]) ) 129 { 130 Header("Location: fiche.php?id=".$ligne->id); 131 } 132 133 } 134 135 if ($_GET["action"] == 'active' && $user->rights->telephonie->ligne->creer) 136 { 137 $ligne = new LigneTel($db); 138 $ligne->fetch_by_id($_GET["id"]); 139 140 $datea = $db->idate(mktime($h, $m , $s, 141 $_POST["remonth"], 142 $_POST["reday"], 143 $_POST["reyear"])); 144 145 if ( $ligne->set_statut($user, 3, $datea) == 0) 146 { 147 Header("Location: fiche.php?id=".$ligne->id); 148 } 149 150 } 151 152 if ($_GET["action"] == 'refuse' && $user->rights->telephonie->ligne->creer) 153 { 154 $ligne = new LigneTel($db); 155 $ligne->fetch_by_id($_GET["id"]); 156 157 $datea = $db->idate(mktime($h, $m , $s, 158 $_POST["remonth"], 159 $_POST["reday"], 160 $_POST["reyear"])); 161 162 if ( $ligne->set_statut($user, 7, $datea, $_POST["commentaire"]) == 0) 163 { 164 Header("Location: fiche.php?id=".$ligne->id); 165 } 166 } 167 168 if ($_GET["action"] == 'resilier' && $user->rights->telephonie->ligne->creer) 169 { 170 $ligne = new LigneTel($db); 171 $ligne->fetch_by_id($_GET["id"]); 172 173 if ( $ligne->set_statut($user, 4) == 0) 174 { 175 Header("Location: fiche.php?id=".$ligne->id); 176 } 177 } 178 179 if ($_GET["action"] == 'annuleresilier' && $user->rights->telephonie->ligne->creer) 180 { 181 $ligne = new LigneTel($db); 182 $ligne->fetch_by_id($_GET["id"]); 183 184 if ( $ligne->set_statut($user, 3) == 0) 185 { 186 Header("Location: fiche.php?id=".$ligne->id); 187 } 188 } 189 190 if ($_GET["action"] == 'confirmresilier' && $user->rights->telephonie->ligne->creer) 191 { 192 $ligne = new LigneTel($db); 193 $ligne->fetch_by_id($_GET["id"]); 194 195 $datea = $db->idate(mktime($h, $m , $s, 196 $_POST["remonth"], 197 $_POST["reday"], 198 $_POST["reyear"])); 199 200 $comm = new User($db,$ligne->commercial_id); 201 $comm->fetch(); 202 203 $soc = new Societe($db); 204 $soc->fetch($ligne->socid); 205 206 if ( $ligne->set_statut($user, 6, $datea, $_POST["commentaire"]) == 0) 207 { 208 Header("Location: fiche.php?id=".$ligne->id); 209 } 210 } 211 212 if ($_GET["action"] == 'acommander' && $user->rights->telephonie->ligne->creer) 213 { 214 $ligne = new LigneTel($db); 215 $ligne->fetch_by_id($_GET["id"]); 216 217 if ( $ligne->set_statut($user, 1, '', $_POST["commentaire"]) == 0) 218 { 219 Header("Location: fiche.php?id=".$ligne->id); 220 } 221 } 222 223 224 if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->telephonie->ligne->creer) 225 { 226 $ligne = new LigneTel($db); 227 $ligne->id = $_GET["id"]; 228 229 $ligne->numero = $_POST["numero"]; 230 $ligne->fournisseur = $_POST["fournisseur"]; 231 $ligne->concurrent = $_POST["concurrent"]; 232 $ligne->note = $_POST["note"]; 233 234 if ( $ligne->update($user) ) 235 236 { 237 $action = ''; 238 $mesg = 'Fiche mise à jour'; 239 } 240 else 241 { 242 $action = 're-edit'; 243 $mesg = 'Fiche non mise à jour !' . "<br>" . $entrepot->mesg_error; 244 } 245 } 246 247 248 llxHeader("","","Fiche Ligne"); 249 250 if ($cancel == $langs->trans("Cancel")) 251 { 252 $action = ''; 253 } 254 255 /* 256 * Création en 2 étape 257 * 258 */ 259 if ($_GET["action"] == 'create1') 260 { 261 $form = new Form($db); 262 print_titre("Nouvelle ligne"); 263 264 if (is_object($ligne)) 265 { 266 // La création a échouée 267 print $ligne->error_message; 268 } 269 else 270 { 271 $ligne = new LigneTel($db); 272 } 273 274 print '<form action="fiche.php" method="GET">'; 275 print '<input type="hidden" name="action" value="create_line">'; 276 277 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 278 279 print '<tr><td width="20%">Client</td><td >'; 280 $ff = array(); 281 $sql = "SELECT idp, nom, ville FROM ".MAIN_DB_PREFIX."societe WHERE client=1 ORDER BY nom "; 282 if ( $db->query( $sql) ) 283 { 284 $num = $db->num_rows(); 285 if ( $num > 0 ) 286 { 287 $i = 0; 288 while ($i < $num) 289 { 290 $row = $db->fetch_row($i); 291 $ff[$row[0]] = $row[1] . " (".$row[2].")"; 292 293 $i++; 294 } 295 } 296 $db->free(); 297 } 298 $form->select_array("client_comm",$ff,$ligne->client_comm); 299 print '</td></tr>'; 300 301 print '<tr><td> </td><td><input type="submit" value="Créer"></td></tr>'."\n"; 302 print '</table>'."\n"; 303 print '</form>'; 304 } 305 elseif ($_GET["action"] == 'create' && $_GET["contratid"] > 0) 306 { 307 308 $contrat = new TelephonieContrat($db); 309 $contrat->fetch($_GET["contratid"]); 310 311 312 $form = new Form($db); 313 print_titre("Nouvelle ligne sur le contrat : ".$contrat->ref); 314 315 if (is_object($ligne)) 316 { 317 // La création a échouée 318 print $ligne->error_message; 319 } 320 else 321 { 322 $ligne = new LigneTel($db); 323 } 324 325 326 $socc = new Societe($db); 327 //if ( $socc->fetch($_GET["client_comm"]) == 1) 328 if ( $socc->fetch($contrat->client_comm_id) == 1) 329 { 330 331 if (strlen($socc->code_client) == 0) 332 { 333 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 334 print '<tr><td width="20%">Client</td><td >'; 335 print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$socc->id.'">'.$socc->nom.'</a>'; 336 print '</td></tr>'; 337 338 print '<tr><td width="20%">Code client</td><td >'; 339 print $socc->code_client; 340 print '</td></tr>'; 341 print '</table><br /><br />'; 342 print 'Impossible de créer une ligne pour cette société, vous devez au préalablement lui affecter un code client.'; 343 } 344 elseif (strlen($socc->code_client) > 0 && $socc->check_codeclient() <> 0) 345 { 346 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 347 print '<tr><td width="20%">Client</td><td >'; 348 print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$socc->id.'">'.$socc->nom.'</a>'; 349 print '</td></tr>'; 350 351 print '<tr><td width="20%">Code client</td><td >'; 352 print $socc->code_client; 353 print '</td></tr>'; 354 print '</table><br /><br />'; 355 print 'Le code client de cette société est incorrect, vous devez lui affecter un code client correct.'; 356 } 357 else 358 { 359 print '<form action="fiche.php" method="post">'; 360 print '<input type="hidden" name="action" value="add">'; 361 print '<input type="hidden" name="contrat" value="'.$contrat->id.'">'."\n"; 362 print '<input type="hidden" name="client_comm" value="'.$socc->id.'">'."\n"; 363 print '<input type="hidden" name="commercial_suiv" value="'.$contrat->commercial_suiv_id.'">'."\n"; 364 print '<input type="hidden" name="commercial_sign" value="'.$contrat->commercial_sign_id.'">'."\n"; 365 366 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 367 368 print '<tr><td width="20%">Contrat</td><td colspan="2">'.$contrat->ref_url.'</a></td></tr>'; 369 370 print '<tr><td width="20%">Client</td><td >'; 371 print $socc->nom; 372 print '</td></tr>'; 373 374 print '<tr><td width="20%">Code client</td><td >'; 375 print $socc->code_client; 376 print '</td></tr>'; 377 378 379 print '<tr><td width="20%">Numéro</td><td><input name="numero" size="11" maxlength="10" value="'.$ligne->numero.'"></td></tr>'; 380 381 $client = new Societe($db, $contrat->client_id); 382 $client->fetch($contrat->client_id); 383 384 print '<tr><td width="20%">Client (Agence/Filiale)</td><td colspan="2">'; 385 print $client->nom.'<br />'; 386 387 print $client->cp . " " .$client->ville; 388 print '</td></tr>'; 389 print '<input type="hidden" name="client" value="'.$contrat->client_id.'">'; 390 391 $client_facture = new Societe($db); 392 $client_facture->fetch($contrat->client_facture_id); 393 394 print '<tr><td width="20%">Client Facturé</td><td>'; 395 print $client_facture->nom.'<br />'; 396 print $client_facture->cp . " " .$client_facture->ville; 397 398 print '</td><td>'; 399 print '<input type="hidden" name="client_facture" value="'.$contrat->client_facture_id.'">'; 400 401 print '<tr><td width="20%">Fournisseur</td><td >'; 402 $ff = array(); 403 $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur WHERE commande_active = 1 ORDER BY nom "; 404 if ( $db->query( $sql) ) 405 { 406 $num = $db->num_rows(); 407 if ( $num > 0 ) 408 { 409 $i = 0; 410 while ($i < $num) 411 { 412 $row = $db->fetch_row(); 413 $ff[$row[0]] = $row[1]; 414 $i++; 415 } 416 } 417 $db->free(); 418 419 } 420 $form->select_array("fournisseur",$ff,$ligne->fournisseur); 421 422 $tech = array(); 423 $tech["presel"] = "Présélection"; 424 $tech["voip"] = "VoIP"; 425 print " Technologie : "; 426 $form->select_array("techno",$tech,"presel"); 427 428 print '</td></tr>'; 429 430 /* 431 * Concurrents 432 */ 433 434 print '<tr><td width="20%">Fournisseur précédent</td><td >'; 435 $ff = array(); 436 $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_concurrents ORDER BY rowid "; 437 if ( $db->query( $sql) ) 438 { 439 $num = $db->num_rows(); 440 if ( $num > 0 ) 441 { 442 $i = 0; 443 while ($i < $num) 444 { 445 $row = $db->fetch_row($i); 446 $ff[$row[0]] = $row[1]; 447 $i++; 448 } 449 } 450 $db->free(); 451 452 } 453 $form->select_array("concurrent",$ff,$ligne->concurrent); 454 print '</td></tr>'; 455 456 print '<tr><td width="20%">Remise LMN</td><td><input name="remise" size="3" maxlength="2" value="'.$ligne->remise.'"> %</td></tr>'."\n"; 457 458 print '<tr><td width="20%" valign="top">Note</td><td>'."\n"; 459 print '<textarea name="note" rows="4" cols="50">'."\n"; 460 print stripslashes($ligne->note); 461 print '</textarea></td></tr>'."\n"; 462 463 print '<tr><td> </td><td><input type="submit" value="Créer"></td></tr>'."\n"; 464 print '</table>'."\n"; 465 print '</form>'; 466 467 } 468 469 } 470 else 471 { 472 print "Erreur"; 473 } 474 475 } 476 else 477 { 478 /* 479 * Mode Visualisation 480 * 481 * 482 */ 483 if ($_GET["id"] or $_GET["numero"]) 484 { 485 if ($_GET["action"] <> 're-edit') 486 { 487 $ligne = new LigneTel($db); 488 if ($_GET["id"]) 489 { 490 $result = $ligne->fetch_by_id($_GET["id"]); 491 } 492 if ($_GET["numero"]) 493 { 494 $result = $ligne->fetch($_GET["numero"]); 495 } 496 } 497 498 if ($result == 1) 499 { 500 $client_comm = new Societe($db); 501 $client_comm->fetch($ligne->client_comm_id, $user); 502 } 503 504 if (!$client_comm->perm_read) 505 { 506 print "Lecture non authorisée"; 507 } 508 509 510 if ($result == 1 && $client_comm->perm_read) 511 { 512 if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') 513 { 514 515 $h=0; 516 $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/fiche.php?id=".$ligne->id; 517 $head[$h][1] = $langs->trans("Ligne"); 518 $hselected = $h; 519 $h++; 520 521 if ($ligne->statut == -1) 522 { 523 if ($user->rights->telephonie->ligne->creer) 524 { 525 $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/commande.php?id=".$ligne->id; 526 $head[$h][1] = $langs->trans('Commande'); 527 $h++; 528 } 529 } 530 else 531 { 532 if ($user->rights->telephonie->facture->lire) 533 { 534 $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/factures.php?id=".$ligne->id; 535 $head[$h][1] = $langs->trans('Factures'); 536 $h++; 537 } 538 } 539 540 $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/infoc.php?id=".$ligne->id; 541 $head[$h][1] = $langs->trans('Infos'); 542 $h++; 543 544 $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/history.php?id=".$ligne->id; 545 $head[$h][1] = $langs->trans('Historique'); 546 $h++; 547 548 $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/conso.php?id=".$ligne->id; 549 $head[$h][1] = $langs->trans('Conso'); 550 $h++; 551 552 $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/stat.php?id=".$ligne->id; 553 $head[$h][1] = $langs->trans('Stats'); 554 $h++; 555 556 dolibarr_fiche_head($head, $hselected, 'Ligne : '.$ligne->numero); 557 558 print_fiche_titre('Fiche Ligne', $mesg); 559 560 /* 561 * 562 */ 563 if ($_GET["action"] == 'delete' && $ligne->statut == -1) 564 { 565 $html = new Form($db); 566 567 $html->form_confirm("fiche.php"."?id=".$_GET["id"],"Suppression de ligne","Etes-vous sûr de vouloir supprimer la ligne : ".dolibarr_print_phone($ligne->numero)." ?","confirm_delete"); 568 print '<br />'; 569 } 570 571 /* 572 * 573 */ 574 575 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 576 577 if ($ligne->contrat) 578 { 579 $contrat = new TelephonieContrat($db); 580 $contrat->fetch($ligne->contrat); 581 582 print '<tr><td width="20%">Contrat</td><td>'.$contrat->ref_url.'</a></td><td>'; 583 print '<img src="./graph'.$ligne->statut.'.png"> '; 584 print $ligne->statuts[$ligne->statut]; 585 print '</td></tr>'; 586 } 587 588 print '<tr><td width="20%">Client</td><td>'; 589 print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$client_comm->id.'">'; 590 591 print $client_comm->nom.'</a></td><td>'.$client_comm->code_client; 592 print '</td></tr>'; 593 594 print '<tr><td width="20%">Numéro</td><td>'.dolibarr_print_phone($ligne->numero); 595 print " ".$ligne->support.'</td>'; 596 print '<td>Facturée : '.$ligne->facturable.'</td></tr>'; 597 598 $client = new Societe($db, $ligne->client_id); 599 $client->fetch($ligne->client_id); 600 601 print '<tr><td width="20%">Client (Agence/Filiale)</td><td colspan="2">'; 602 print $client->nom.'<br />'; 603 604 print $client->cp . " " .$client->ville; 605 print '</td></tr>'; 606 607 $client_facture = new Societe($db); 608 $client_facture->fetch($ligne->client_facture_id); 609 610 print '<tr><td width="20%">Client Facturé</td><td>'; 611 print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$client_facture->id.'">'; 612 print $client_facture->nom.'</a><br />'; 613 print $client_facture->cp . " " .$client_facture->ville; 614 615 print '</td><td valign="top" rowspan="8">'; 616 617 /* Historique */ 618 619 print '<table width="100%" class="border">'; 620 print '<tr class="liste_titre">'; 621 print '<td>Date</td>'; 622 print '<td>Statut</td>'; 623 if ($user->rights->telephonie->fournisseur->lire) 624 print '<td>Fournisseur</td>'; 625 print '<td>Rapporteur</td>'; 626 print '</tr>'; 627 $ff = array(); 628 $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur"; 629 $sql .= " ORDER BY nom "; 630 631 $resql = $db->query($sql); 632 if ($resql) 633 { 634 $num = $db->num_rows($resql); 635 if ( $num > 0 ) 636 { 637 $i = 0; 638 while ($i < $num) 639 { 640 $row = $db->fetch_row($resql); 641 $ff[$row[0]] = $row[1]; 642 $i++; 643 } 644 } 645 $db->free($resql); 646 } 647 648 $sql = "SELECT ".$db->pdate("l.tms").", l.statut, l.fk_user"; 649 $sql .= ", u.code, u.code, l.comment, l.fk_fournisseur"; 650 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne_statut as l"; 651 $sql .= ",".MAIN_DB_PREFIX."user as u"; 652 $sql .= " WHERE u.rowid = l.fk_user AND l.fk_ligne = ".$ligne->id; 653 $sql .= " ORDER BY l.tms DESC "; 654 if ( $db->query( $sql) ) 655 { 656 $num = $db->num_rows(); 657 if ( $num > 0 ) 658 { 659 $i = 0; 660 while ($i < $num) 661 { 662 $row = $db->fetch_row($i); 663 664 print '<tr><td valign="top" width="20%">'.strftime("%d/%m/%y",$row[0]).'</td>'; 665 print '<td><img src="./graph'.$row[1].'.png"> '; 666 print $ligne->statuts[$row[1]]; 667 if ($row[5]) 668 { 669 print '<br />'.$row[5]; 670 } 671 672 print '</td>'; 673 674 if ($user->rights->telephonie->fournisseur->lire) 675 print '<td>'.$ff[$row[6]].'</td>'; 676 677 print '<td>'. $row[3] . "</td></tr>"; 678 $i++; 679 } 680 } 681 $db->free(); 682 } 683 else 684 { 685 print $sql; 686 } 687 688 print "</table>"; 689 690 691 /* Fin historique */ 692 693 694 695 print '</td></tr>'; 696 697 print '<tr><td width="20%">Fournisseur</td><td>'; 698 if ($user->rights->telephonie->fournisseur->lire) 699 { 700 $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur"; 701 $sql .= " WHERE rowid = ".$ligne->fournisseur_id; 702 703 if ( $db->query( $sql) ) 704 { 705 $num = $db->num_rows(); 706 if ( $num > 0 ) 707 { 708 $row = $db->fetch_row(); 709 print $row[1]; 710 } 711 $db->free(); 712 } 713 714 print " - ".$ligne->techno; 715 716 } 717 else 718 { 719 print '-'; 720 } 721 print '</td></tr>'; 722 723 724 725 726 print '<tr><td>PDF détail</td><td>'.$ligne->pdfdetail.'</td></tr>'; 727 728 729 730 print '<tr><td width="20%">Remise LMN</td><td>'.$ligne->remise.' % '; 731 print '(<a href="remises.php?id='.$ligne->id.'">historique</a>)</td></tr>'; 732 733 $commercial_suiv = new User($db, $ligne->commercial_suiv_id); 734 $commercial_suiv->fetch(); 735 736 print '<tr><td width="20%">Commercial</td>'; 737 print '<td>'.$commercial_suiv->fullname.'</td></tr>'; 738 print '<tr><td>Signé par</td><td>'; 739 740 741 if ($ligne->commercial_suiv_id <> $ligne->commercial_sign_id) 742 { 743 $commercial_sign = new User($db, $ligne->commercial_sign_id); 744 $commercial_sign->fetch(); 745 746 print $commercial_sign->fullname.'</td></tr>'; 747 } 748 else 749 { 750 print $commercial_suiv->fullname.'</td></tr>'; 751 } 752 753 754 print '<tr><td width="20%">Concurrent précédent</td>'; 755 print '<td>'.$ligne->print_concurrent_nom().'</td></tr>'; 756 757 print '<tr><td width="20%">Factures</td><td>'; 758 print '<a href="'.DOL_URL_ROOT.'/telephonie/facture/liste.php?search_ligne='.$ligne->numero.'">liste</a>'; 759 print '</td></tr>'; 760 761 762 763 /* Contacts */ 764 765 $sql = "SELECT c.idp, c.name, c.firstname, c.email "; 766 $sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c"; 767 $sql .= ",".MAIN_DB_PREFIX."telephonie_contact_facture as cf"; 768 $sql .= " WHERE c.idp = cf.fk_contact AND cf.fk_ligne = ".$ligne->id." ORDER BY name "; 769 if ( $db->query( $sql) ) 770 { 771 $num = $db->num_rows(); 772 if ( $num > 0 ) 773 { 774 $i = 0; 775 while ($i < $num) 776 { 777 $row = $db->fetch_row($i); 778 779 print '<tr><td valign="top" width="20%">Contact facture '.$i.'</td>'; 780 print '<td valign="top" colspan="2">'.$row[1] . " " . $row[2] . " <".$row[3]."></td></tr>"; 781 $i++; 782 } 783 } 784 $db->free(); 785 786 } 787 else 788 { 789 print $sql; 790 } 791 792 /* Fin Contacts */ 793 if ($ligne->note) 794 { 795 print '<tr><td width="20%" valign="top">Note</td><td colspan="2">'."\n"; 796 print nl2br($ligne->note); 797 print '</td></tr>'."\n"; 798 } 799 800 print "</table><br />"; 801 802 if ($_GET["action"] == "editremise" && $ligne->statut <> 6 && $user->rights->telephonie->ligne->creer) 803 { 804 /** 805 * Edition de la remise 806 */ 807 808 print '<form action="fiche.php?id='.$ligne->id.'" method="POST">'; 809 print '<input type="hidden" name="action" value="updateremise">'; 810 print '<table class="border" width="100%" cellpadding="4" cellspacing="0">'; 811 print '<tr class="liste_titre"><td colspan="2">Modification de la remise Local/Mobile/National</td></tr>'; 812 print '<tr><td>Nouvelle remise LMN</td><td>'; 813 print '<input size="4" type="text" name="remise" value="'.$ligne->remise.'" maxlength="3"> %'; 814 print '</td></tr>'; 815 816 print '<tr><td width="20%">Commentaire</td><td><input size="40" type="text" name="comment"></td></tr>'; 817 818 print '<tr><td align="center" colspan="2"><input type="submit" name="Activer"></td></tr>'; 819 820 print '</table><br />'; 821 822 print '</form>'; 823 } 824 825 if ($_GET["action"] == "chgcontrat" && $user->rights->telephonie->ligne->creer) 826 { 827 /** 828 * Edition de la remise 829 */ 830 831 print '<form action="fiche.php?id='.$ligne->id.'" method="POST">'; 832 print '<input type="hidden" name="action" value="changecontrat">'; 833 print '<table class="border" width="100%" cellpadding="4" cellspacing="0">'; 834 print '<tr class="liste_titre"><td colspan="2">Migrer vers un autre contrat</td></tr>'; 835 print '<tr><td width="20%">Nouveau contrat</td><td>'; 836 837 838 $sql = "SELECT c.rowid, c.ref "; 839 $sql .= "FROM ".MAIN_DB_PREFIX."telephonie_contrat as c"; 840 $sql .= " WHERE c.rowid <> ".$ligne->contrat; 841 $sql .= " AND c.fk_client_comm = ".$ligne->client_comm_id; 842 $sql .= " AND c.statut <> 6"; // contrat non résilié 843 844 $resql = $db->query($sql); 845 if ($resql) 846 { 847 $num = $db->num_rows($resql); 848 849 if ($num > 0) 850 { 851 852 print '<select name="contrat">'; 853 854 $i = 0; 855 while ($i < $num) 856 { 857 $row = $db->fetch_row($resql); 858 859 print '<option value="'.$row[0].'">'.$row[1]; 860 $i++; 861 } 862 print '</select>'; 863 } 864 else 865 { 866 print "Aucun contrat éligible"; 867 } 868 869 $db->free(); 870 } 871 else 872 { 873 print $sql; 874 } 875 876 print '</td></tr>'; 877 if ($num > 0) 878 { 879 print '<tr><td align="center" colspan="2"><input type="submit" value="Migrer"></td></tr>'; 880 } 881 882 print '</table><br />'; 883 print '</form>'; 884 } 885 } 886 887 /* 888 * Edition 889 * 890 * 891 * 892 */ 893 894 if ($_GET["action"] == 'edit' || $action == 're-edit') 895 { 896 897 $h=0; 898 $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/fiche.php?id=".$ligne->id; 899 $head[$h][1] = $langs->trans("Ligne"); 900 $hselected = $h; 901 $h++; 902 903 $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/infoc.php?id=".$ligne->id; 904 $head[$h][1] = $langs->trans('Infos'); 905 $h++; 906 907 $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/history.php?id=".$ligne->id; 908 $head[$h][1] = $langs->trans('Historique'); 909 $h++; 910 911 $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/conso.php?id=".$ligne->id; 912 $head[$h][1] = $langs->trans('Conso'); 913 $h++; 914 915 dolibarr_fiche_head($head, $hselected, 'Ligne : '.$ligne->numero); 916 917 print_fiche_titre('Edition de la ligne', $mesg); 918 919 print "<form action=\"fiche.php?id=$ligne->id\" method=\"post\">\n"; 920 print '<input type="hidden" name="action" value="update">'; 921 922 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 923 924 $client_comm = new Societe($db, $ligne->client_comm_id); 925 $client_comm->fetch($ligne->client_comm_id); 926 927 print '<tr><td width="20%">Client</td><td>'; 928 print $client_comm->nom; 929 print '</td></tr>'; 930 print '<input type="hidden" name="client_comm" value="'.$client_comm->id.'">'."\n"; 931 932 print '<tr><td width="20%">Numéro</td><td>'; 933 if ($ligne->statut == -1) 934 { 935 print '<input name="numero" size="12" value="'.$ligne->numero.'">'; 936 } 937 else 938 { 939 print '<input type="hidden" name="numero" value="'.$ligne->numero.'">'; 940 print dolibarr_print_phone($ligne->numero); 941 } 942 print '</td></tr>'; 943 944 $client = new Societe($db, $ligne->client_id); 945 $client->fetch($ligne->client_id); 946 947 print '<tr><td width="20%">Client (Agence/Filiale)</td><td>'; 948 print $client->nom.'<br />'; 949 950 print $client->cp . " " .$client->ville; 951 print '</td></tr>'; 952 print '<input type="hidden" name="client" value="'.$ligne->client_id.'">'; 953 954 $client_facture = new Societe($db); 955 $client_facture->fetch($ligne->client_facture_id); 956 957 print '<tr><td width="20%">Client Facturé</td><td>'; 958 print $client_facture->nom.'<br />'; 959 print $client_facture->cp . " " .$client_facture->ville; 960 961 print '</td></tr>'; 962 print '<input type="hidden" name="client_facture" value="'.$ligne->client_facture_id.'">'; 963 964 print '<tr><td width="20%">Fournisseur</td><td>'; 965 966 if ($ligne->statut == -1) 967 { 968 print '<select name="fournisseur">'; 969 970 $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur WHERE commande_active = 1 ORDER BY nom "; 971 if ( $db->query( $sql) ) 972 { 973 $num = $db->num_rows(); 974 if ( $num > 0 ) 975 { 976 $i = 0; 977 while ($i < $num) 978 { 979 $row = $db->fetch_row($i); 980 print '<option value="'.$row[0] .'"'; 981 if ($row[0] == $ligne->fournisseur_id) 982 { 983 print " SELECTED"; 984 } 985 print '>'.$row[1]; 986 $i++; 987 } 988 } 989 $db->free(); 990 } 991 992 print '</select>'; 993 } 994 else 995 { 996 print '<input type="hidden" name="fournisseur" value="'.$ligne->fournisseur_id.'">'; 997 998 $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur"; 999 $sql .= " WHERE commande_active = 1 AND rowid = ".$ligne->fournisseur_id; 1000 1001 if ( $db->query( $sql) ) 1002 { 1003 $num = $db->num_rows(); 1004 if ( $num > 0 ) 1005 { 1006 $row = $db->fetch_row(); 1007 print $row[1]; 1008 } 1009 $db->free(); 1010 } 1011 } 1012 1013 print '</td></tr>'; 1014 1015 /* 1016 * Commercial 1017 */ 1018 1019 print '<tr><td width="20%">Fournisseur précédent</td><td>'; 1020 print '<select name="concurrent">'; 1021 1022 $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_concurrents ORDER BY nom "; 1023 if ( $db->query( $sql) ) 1024 { 1025 $num = $db->num_rows(); 1026 if ( $num > 0 ) 1027 { 1028 $i = 0; 1029 while ($i < $num) 1030 { 1031 $row = $db->fetch_row($i); 1032 print '<option value="'.$row[0].'"'; 1033 if ($row[0] == $ligne->concurrent_id) 1034 { 1035 print " SELECTED"; 1036 } 1037 print '>'.$row[1]; 1038 $i++; 1039 } 1040 } 1041 $db->free(); 1042 1043 } 1044 print '</select></td></tr>'."\n"; 1045 /* 1046 * 1047 * 1048 */ 1049 print '<tr><td width="20%">Remise LMN</td><td>'.$ligne->remise.' %</td></tr>'; 1050 1051 print '<tr><td width="20%" valign="top">Note</td><td>'; 1052 print '<textarea name="note" rows="4" cols="50">'; 1053 print nl2br($ligne->note); 1054 print "</textarea></td></tr>"; 1055 1056 print '<tr><td align="center" colspan="2"><input type="submit" value="Mettre à jour">'; 1057 print '<a href="fiche.php?id='.$ligne->id.'">Annuler</a></td></tr>'; 1058 print '</table>'."\n"; 1059 print '</form>'."\n"; 1060 1061 } 1062 1063 /* 1064 * Contact 1065 * 1066 * 1067 */ 1068 if ($_GET["action"] == 'contact') 1069 { 1070 print_fiche_titre('Ajouter un contact', $mesg); 1071 1072 print "<form action=\"fiche.php?id=$ligne->id\" method=\"post\">\n"; 1073 print '<input type="hidden" name="action" value="addcontact">'; 1074 1075 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 1076 1077 1078 $sql = "SELECT c.idp, c.name, c.firstname, c.email "; 1079 $sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c"; 1080 $sql .= ",".MAIN_DB_PREFIX."telephonie_contact_facture as cf"; 1081 $sql .= " WHERE c.idp = cf.fk_contact AND cf.fk_ligne = ".$ligne->id." ORDER BY name "; 1082 if ( $db->query( $sql) ) 1083 { 1084 $num = $db->num_rows(); 1085 if ( $num > 0 ) 1086 { 1087 $i = 0; 1088 while ($i < $num) 1089 { 1090 $row = $db->fetch_row($i); 1091 1092 print '<tr><td valign="top" width="20%">Contact facture '.$i.'</td>'; 1093 print '<td valign="top">'.$row[1] . " " . $row[2] . " <".$row[3].">"; 1094 print '</td><td>'; 1095 print '<a href="fiche.php?id='.$ligne->id.'&action=delcontact&contact_id='.$row[0].'">'; 1096 print img_delete(); 1097 print "</a></td></tr>"; 1098 $i++; 1099 } 1100 } 1101 $db->free(); 1102 1103 } 1104 else 1105 { 1106 print $sql; 1107 } 1108 1109 1110 print '<tr><td valign="top" width="20%">Contact</td><td valign="top" colspan="2">'; 1111 1112 $sql = "SELECT idp, name, firstname, email FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$ligne->client_facture_id." ORDER BY name "; 1113 if ( $db->query( $sql) ) 1114 { 1115 print '<select name="contact_id">'; 1116 $num = $db->num_rows(); 1117 if ( $num > 0 ) 1118 { 1119 $i = 0; 1120 while ($i < $num) 1121 { 1122 $row = $db->fetch_row($i); 1123 print '<option value="'.$row[0] .'"'; 1124 print '>'.$row[1] . " " . $row[2] . " <".$row[3].">"; 1125 $i++; 1126 } 1127 } 1128 $db->free(); 1129 print '</select>'; 1130 } 1131 else 1132 { 1133 print $sql; 1134 } 1135 1136 print '<p>Contact auquel est envoyé la facture par email</p></td></tr>'; 1137 1138 print '<tr><td> </td><td>'; 1139 if ($num > 0) 1140 { 1141 print '<input type="submit" value="Ajouter">'; 1142 } 1143 print '<a href="fiche.php?id='.$ligne->id.'">Annuler</a></td></tr>'; 1144 print '</table>'; 1145 print '</form>'; 1146 1147 } 1148 1149 1150 /* 1151 * 1152 * 1153 * 1154 */ 1155 1156 print '</div>'; 1157 1158 } 1159 } 1160 else 1161 { 1162 print "Error"; 1163 } 1164 } 1165 1166 if ( $user->rights->telephonie->ligne_commander && $ligne->statut == 3 ) 1167 { 1168 $ff = array(); 1169 $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur WHERE commande_active = 1 ORDER BY nom "; 1170 if ( $db->query( $sql) ) 1171 { 1172 $num = $db->num_rows(); 1173 if ( $num > 0 ) 1174 { 1175 $i = 0; 1176 while ($i < $num) 1177 { 1178 $row = $db->fetch_row(); 1179 if ($row[0] <> $ligne->fournisseur_id) 1180 { 1181 $ff[$row[0]] = $row[1]; 1182 } 1183 $i++; 1184 } 1185 } 1186 $db->free(); 1187 } 1188 1189 if (sizeof($ff) > 0 && $ligne->techno == 'presel') 1190 { 1191 /** 1192 * Transférer chez un autre fournisseur 1193 */ 1194 $form = new Form($db); 1195 print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td>'; 1196 print '<form action="fiche.php?id='.$ligne->id.'&action=transfer" method="post">'; 1197 print '<table class="noborder" cellpadding="2" cellspacing="0">'; 1198 print '<tr class="liste_titre">'; 1199 print '<td colspan="2">Commander la ligne chez un autre fournisseur</td></tr>'; 1200 print '<tr><td width="20%">Fournisseur</td><td >'; 1201 $form->select_array("fournisseur",$ff,$ligne->fournisseur); 1202 print '</td></tr>'; 1203 1204 print '<tr><td colspan="2"align="center"><input type="submit" name="Activer"></td></tr>'; 1205 print '</table>'; 1206 print '</form></td><td>'; 1207 print ' </td></tr></table>'; 1208 } 1209 } 1210 1211 1212 1213 if ( $user->rights->telephonie->ligne_activer && $ligne->statut == 2 && $ligne->techno == 'presel') 1214 { 1215 $form = new Form($db); 1216 1217 print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td valign="top">'; 1218 1219 print '<form action="fiche.php?id='.$ligne->id.'&action=active" method="post">'; 1220 print '<table class="noborder" cellpadding="2" cellspacing="0">'; 1221 print '<tr class="liste_titre"><td colspan="2">Activer</td><td>'; 1222 print '<tr><td>Date</td><td>'; 1223 print $form->select_date(); 1224 print '</td>'; 1225 print '<td colspan="2"><input type="submit" name="Activer"></td></tr>'; 1226 print '</table>'; 1227 1228 print '</form></td><td>'; 1229 1230 1231 print '<form action="fiche.php?id='.$ligne->id.'&action=refuse" method="post">'; 1232 print '<table class="noborder" cellpadding="2" cellspacing="0">'; 1233 print '<tr class="liste_titre"><td colspan="2">Refuser</td><td>'; 1234 print '<tr><td>Date</td><td>'; 1235 print $form->select_date(); 1236 print '</td>'; 1237 print '<td colspan="2"><input type="submit" name="Activer"></td></tr>'; 1238 print '<tr><td colspan="3">Commentaire <input size="30" type="text" name="commentaire"></td></tr>'; 1239 print '</table>'; 1240 1241 print '</form></td></tr></table>'; 1242 } 1243 1244 if ( $user->rights->telephonie->ligne_activer && ( $ligne->statut == 5 || $ligne->statut == 3) && $ligne->techno == 'presel') 1245 { 1246 /** 1247 * Résiliation demandée 1248 */ 1249 $form = new Form($db); 1250 1251 print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td>'; 1252 1253 print '<form action="fiche.php?id='.$ligne->id.'&action=confirmresilier" method="post">'; 1254 print '<table class="noborder" cellpadding="2" cellspacing="0">'; 1255 print '<tr class="liste_titre"><td colspan="2">Confirmation de la résiliation</td><td>'; 1256 print '<tr><td>Date</td><td>'; 1257 print $form->select_date(); 1258 print '</td>'; 1259 print '<td colspan="2"><input type="submit" name="Activer"></td></tr>'; 1260 print '<tr><td colspan="3">Commentaire <input size="30" type="text" name="commentaire"></td></tr>'; 1261 print '</table>'; 1262 1263 print '</form></td><td>'; 1264 1265 print ' </td></tr></table>'; 1266 } 1267 1268 1269 if ( $user->rights->telephonie->ligne->creer && $ligne->statut == 6 && $ligne->techno == 'presel') 1270 { 1271 /** 1272 * A commander 1273 */ 1274 $form = new Form($db); 1275 1276 print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td>'; 1277 1278 print '<form action="fiche.php?id='.$ligne->id.'&action=acommander" method="post">'; 1279 print '<table class="noborder" cellpadding="2" cellspacing="0">'; 1280 print '<tr class="liste_titre"><td colspan="2">Recommander la ligne</td><td>'; 1281 print '<tr><td>Date</td><td>'; 1282 print strftime("%e %B %Y", time()); 1283 print '</td>'; 1284 print '<td colspan="2"><input type="submit" value="Commander"></td></tr>'; 1285 print '<tr><td colspan="3">Commentaire <input size="30" type="text" name="commentaire"></td></tr>'; 1286 print '</table>'; 1287 1288 print '</form></td><td>'; 1289 1290 print ' </td></tr></table>'; 1291 } 1292 1293 /* ************************************************************************** */ 1294 /* */ 1295 /* Barre d'action */ 1296 /* */ 1297 /* ************************************************************************** */ 1298 1299 print "\n<br>\n<div class=\"tabsAction\">\n"; 1300 1301 if ($_GET["action"] == '' && $result == 1 && $client_comm->perm_read) 1302 { 1303 1304 if ( $user->rights->telephonie->ligne->resilier && $ligne->statut == 3 && $ligne->techno == 'presel') 1305 { 1306 print "<a class=\"tabAction\" href=\"fiche.php?action=resilier&id=$ligne->id\">".$langs->trans("Demander la résiliation")."</a>"; 1307 } 1308 1309 if ( $user->rights->telephonie->ligne->resilier && $ligne->statut == 4 && $ligne->techno == 'presel') 1310 { 1311 print "<a class=\"tabAction\" href=\"fiche.php?action=annuleresilier&id=$ligne->id\">".$langs->trans("Annuler la demande de résiliation")."</a>"; 1312 } 1313 1314 if ( $user->rights->telephonie->ligne_activer && $ligne->statut <> 6) 1315 { 1316 print "<a class=\"tabAction\" href=\"fiche.php?action=contact&id=$ligne->id\">".$langs->trans("Contact")."</a>"; 1317 } 1318 1319 if ( $user->rights->telephonie->ligne->creer && $ligne->statut < 4) 1320 { 1321 print "<a class=\"tabAction\" href=\"fiche.php?action=chgcontrat&id=$ligne->id\">".$langs->trans("Changer de contrat")."</a>"; 1322 } 1323 1324 if ( $user->rights->telephonie->ligne->creer && $ligne->statut < 4) 1325 { 1326 print "<a class=\"tabAction\" href=\"fiche.php?action=editremise&id=$ligne->id\">".$langs->trans("Changer la remise")."</a>"; 1327 } 1328 1329 if ( $user->rights->telephonie->ligne_activer && $ligne->statut == -1) 1330 { 1331 print "<a class=\"tabAction\" href=\"fiche.php?action=edit&id=$ligne->id\">".$langs->trans("Edit")."</a>"; 1332 } 1333 1334 if ( $user->rights->telephonie->ligne->creer && $ligne->statut == -1) 1335 { 1336 print "<a class=\"butDelete\" href=\"fiche.php?action=delete&id=$ligne->id\">".$langs->trans("Delete")."</a>"; 1337 } 1338 1339 } 1340 1341 print "</div>"; 1342 1343 $db->close(); 1344 1345 llxFooter("<em>Dernière modification $Date: 2005/12/01 09:53:08 $ révision $Revision: 1.26 $</em>"); 1346 ?>
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 |
![]() |