[ 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 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> 5 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 * 21 * $Id: propal.php,v 1.134.2.1 2006/01/22 21:08:01 eldy Exp $ 22 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/propal.php,v $ 23 */ 24 25 /** 26 \file htdocs/comm/propal.php 27 \ingroup propale 28 \brief Page liste des propales (vision commercial) 29 */ 30 31 require ("./pre.inc.php"); 32 require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php"); 33 34 $user->getrights('propale'); 35 36 if (!$user->rights->propale->lire) 37 accessforbidden(); 38 39 $langs->load('companies'); 40 $langs->load('propal'); 41 $langs->load('compta'); 42 $langs->load('bills'); 43 44 if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php'); 45 if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php'); 46 require_once(DOL_DOCUMENT_ROOT.'/propal.class.php'); 47 require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php'); 48 require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); 49 50 $sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"]; 51 if (isset($_GET["msg"])) { $msg=urldecode($_GET["msg"]); } 52 $year=isset($_GET["year"])?$_GET["year"]:""; 53 $month=isset($_GET["month"])?$_GET["month"]:""; 54 55 // Sécurité accés client 56 $socidp=''; 57 if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; } 58 if ($user->societe_id > 0) 59 { 60 $action = ''; 61 $socidp = $user->societe_id; 62 } 63 64 // Nombre de ligne pour choix de produit/service prédéfinis 65 $NBLINES=4; 66 67 $form=new Form($db); 68 69 70 /******************************************************************************/ 71 /* Actions */ 72 /******************************************************************************/ 73 74 if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes') 75 { 76 if ($user->rights->propale->supprimer) 77 { 78 $propal = new Propal($db, 0, $_GET['propalid']); 79 $propal->delete($user); 80 $propalid = 0; 81 $brouillon = 1; 82 } 83 Header('Location: propal.php'); 84 exit; 85 } 86 87 if ($_POST['action'] == 'confirm_validate' && $_POST['confirm'] == 'yes') 88 { 89 if ($user->rights->propale->valider) 90 { 91 $propal = new Propal($db); 92 $propal->fetch($_GET['propalid']); 93 $result=$propal->update_price($_GET['propalid']); 94 propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); 95 $result=$propal->valid($user); 96 } 97 Header ('Location: propal.php?propalid='.$_GET['propalid']); 98 exit; 99 } 100 101 if ($_POST['action'] == 'setecheance') 102 { 103 $propal = new Propal($db); 104 $propal->fetch($_GET['propalid']); 105 $result=$propal->set_echeance($user,mktime(12, 1, 1, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); 106 if ($result < 0) dolibarr_print_error($db,$propal->error); 107 } 108 109 if ($_POST['action'] == 'add') 110 { 111 $propal = new Propal($db, $_GET['socidp']); 112 $propal->datep = mktime(12, 1, 1, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); 113 114 $propal->duree_validite = $_POST['duree_validite']; 115 116 $propal->contactid = $_POST['contactidp']; 117 $propal->projetidp = $_POST['projetidp']; 118 $propal->modelpdf = $_POST['model']; 119 $propal->author = $user->id; 120 $propal->note = $_POST['note']; 121 122 $propal->ref = $_POST['ref']; 123 124 for ($i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i++) 125 { 126 $xid = 'idprod'.$i; 127 $xqty = 'qty'.$i; 128 $xremise = 'remise'.$i; 129 $propal->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]); 130 } 131 132 $id = $propal->create(); 133 134 /* 135 * Generation 136 */ 137 if ($id > 0) 138 { 139 propale_pdf_create($db, $id, $_POST['model']); 140 Header ('Location: propal.php?propalid='.$id); 141 exit; 142 } 143 else 144 { 145 dolibarr_print_error($db,$propal->error); 146 exit; 147 } 148 } 149 150 if ($_GET['action'] == 'builddoc') 151 { 152 $propal = new Propal($db); 153 $propal->fetch($_GET['propalid']); 154 propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); 155 } 156 157 /* 158 * Cloture de la propale 159 */ 160 if ($_POST['action'] == 'setstatut' && $user->rights->propale->cloturer) 161 { 162 if (! $_POST['cancel']) 163 { 164 $propal = new Propal($db); 165 $propal->fetch($_GET['propalid']); 166 $propal->cloture($user, $_POST['statut'], $_POST['note']); 167 } 168 } 169 170 /* 171 * Envoi de la propale par mail 172 */ 173 if ($_POST['action'] == 'send') 174 { 175 $langs->load('mails'); 176 $propal= new Propal($db); 177 if ( $propal->fetch($_POST['propalid']) ) 178 { 179 $propalref = sanitize_string($propal->ref); 180 $file = $conf->propal->dir_output . '/' . $propalref . '/' . $propalref . '.pdf'; 181 if (is_readable($file)) 182 { 183 $soc = new Societe($db, $propal->socidp); 184 if ($_POST['sendto']) 185 { 186 // Le destinataire a été fourni via le champ libre 187 $sendto = $_POST['sendto']; 188 $sendtoid = 0; 189 } 190 elseif ($_POST['receiver']) 191 { 192 // Le destinataire a été fourni via la liste déroulante 193 $sendto = $soc->contact_get_email($_POST['receiver']); 194 $sendtoid = $_POST['receiver']; 195 } 196 197 if (strlen($sendto)) 198 { 199 $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; 200 $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; 201 $message = $_POST['message']; 202 if ($_POST['action'] == 'send') 203 { 204 $subject = $langs->trans('Propal').' '.$propal->ref; 205 $actiontypeid=3; 206 $actionmsg ='Mail envoyé par '.$from.' à '.$sendto.'.<br>'; 207 if ($message) 208 { 209 $actionmsg.='Texte utilisé dans le corps du message:<br>'; 210 $actionmsg.=$message; 211 } 212 $actionmsg2='Envoi Propal par mail'; 213 } 214 215 $filepath[0] = $file; 216 $filename[0] = $propal->ref.'.pdf'; 217 $mimetype[0] = 'application/pdf'; 218 if ($_FILES['addedfile']['tmp_name']) 219 { 220 $filepath[1] = $_FILES['addedfile']['tmp_name']; 221 $filename[1] = $_FILES['addedfile']['name']; 222 $mimetype[1] = $_FILES['addedfile']['type']; 223 } 224 // Envoi de la facture 225 $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc); 226 if ($mailfile->sendfile()) 227 { 228 $msg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>'; 229 // Insertion action 230 include_once (DOL_DOCUMENT_ROOT."/contact.class.php"); 231 $actioncomm = new ActionComm($db); 232 $actioncomm->type_id = $actiontypeid; 233 $actioncomm->label = $actionmsg2; 234 $actioncomm->note = $actionmsg; 235 $actioncomm->date = time(); // L'action est faite maintenant 236 $actioncomm->percent = 100; 237 $actioncomm->contact = new Contact($db,$sendtoid); 238 $actioncomm->societe = new Societe($db,$propal->socidp); 239 $actioncomm->user = $user; // User qui a fait l'action 240 $actioncomm->propalrowid = $propal->id; 241 $ret=$actioncomm->add($user); // User qui saisi l'action 242 if ($ret < 0) 243 { 244 dolibarr_print_error($db); 245 } 246 else 247 { 248 // Renvoie sur la fiche 249 Header('Location: propal.php?propalid='.$propal->id.'&msg='.urlencode($msg)); 250 exit; 251 } 252 } 253 else 254 { 255 $msg='<div class="error">'.$langs->trans('ErrorFailedToSendMail',$from,$sendto).' - '.$actioncomm->error.'</div>'; 256 } 257 } 258 else 259 { 260 $msg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>'; 261 dolibarr_syslog('Le mail du destinataire est vide'); 262 } 263 } 264 else 265 { 266 dolibarr_syslog('Impossible de lire :'.$file); 267 } 268 } 269 else 270 { 271 dolibarr_syslog('Impossible de lire les données de la propale. Le fichier propal n\'a peut-être pas été généré.'); 272 } 273 } 274 275 if ($_GET['action'] == 'commande') 276 { 277 /* 278 * Cloture de la propale 279 */ 280 $propal = new Propal($db); 281 $propal->fetch($propalid); 282 $propal->create_commande($user); 283 } 284 285 if ($_GET['action'] == 'modif' && $user->rights->propale->creer) 286 { 287 /* 288 * Repasse la propale en mode brouillon 289 */ 290 $propal = new Propal($db); 291 $propal->fetch($_GET['propalid']); 292 $propal->reopen($user->id); 293 } 294 295 if ($_POST['action'] == "addligne" && $user->rights->propale->creer) 296 { 297 /* 298 * Ajout d'une ligne produit dans la propale 299 */ 300 $propal = new Propal($db); 301 $ret=$propal->fetch($_POST['propalid']); 302 303 if (isset($_POST['np_tva_tx'])) 304 { 305 $propal->insert_product_generic( 306 $_POST['np_desc'], 307 $_POST['np_price'], 308 $_POST['np_qty'], 309 $_POST['np_tva_tx'], 310 $_POST['np_remise']); 311 } 312 else 313 { 314 $propal->insert_product( 315 $_POST['idprod'], 316 $_POST['qty'], 317 $_POST['remise'], 318 $_POST['np_desc']); 319 } 320 propale_pdf_create($db, $_POST['propalid'], $propal->modelpdf); 321 } 322 323 if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save")) 324 { 325 /* 326 * Mise à jour d'une ligne dans la propale 327 */ 328 $propal = new Propal($db); 329 $propal->fetch($_GET['propalid']); 330 $propal->UpdateLigne($_POST['ligne'], $_POST['subprice'], $_POST['qty'], $_POST['remise_percent'], $_POST['tva_tx'], $_POST['desc']); 331 propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); 332 } 333 334 if ($_POST['action'] == 'builddoc' && $user->rights->propale->creer) 335 { 336 $propal = new Propal($db, 0, $_GET['propalid']); 337 $propal->set_pdf_model($user, $_POST['model']); 338 propale_pdf_create($db, $_GET['propalid'], $_POST['model']); 339 } 340 341 342 if ($_GET['action'] == 'del_ligne' && $user->rights->propale->creer) 343 { 344 /* 345 * Supprime une ligne produit dans la propale 346 */ 347 $propal = new Propal($db); 348 $propal->fetch($_GET['propalid']); 349 $propal->delete_product($_GET['ligne']); 350 propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); 351 } 352 353 if ($_POST['action'] == 'setremise' && $user->rights->propale->creer) 354 { 355 $propal = new Propal($db); 356 $propal->fetch($_GET['propalid']); 357 $propal->set_remise($user, $_POST['remise']); 358 propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); 359 } 360 361 if ($_POST['action'] == 'set_project') 362 { 363 $propal = new Propal($db); 364 $propal->fetch($_GET['propalid']); 365 $propal->set_project($user, $_POST['projetidp']); 366 } 367 368 if ($_POST['action'] == 'set_contact') 369 { 370 $propal = new Propal($db); 371 $propal->fetch($_GET['propalid']); 372 $propal->set_contact($user, $_POST['contactidp']); 373 } 374 375 376 llxHeader(); 377 378 $html = new Form($db); 379 380 /* 381 * Affichage fiche propal en mode visu 382 * 383 */ 384 if ($_GET['propalid'] > 0) 385 { 386 if ($msg) print "$msg<br>"; 387 388 $propal = new Propal($db); 389 $propal->fetch($_GET['propalid']); 390 391 $societe = new Societe($db); 392 $societe->fetch($propal->soc_id); 393 $h=0; 394 395 $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; 396 $head[$h][1] = $langs->trans('CommercialCard'); 397 $hselected=$h; 398 $h++; 399 400 $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; 401 $head[$h][1] = $langs->trans('AccountancyCard'); 402 $h++; 403 404 if ($conf->use_preview_tabs) 405 { 406 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; 407 $head[$h][1] = $langs->trans("Preview"); 408 $h++; 409 } 410 411 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; 412 $head[$h][1] = $langs->trans('Note'); 413 $h++; 414 415 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; 416 $head[$h][1] = $langs->trans('Info'); 417 $h++; 418 419 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; 420 $head[$h][1] = $langs->trans('Documents'); 421 $h++; 422 423 dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref); 424 425 /* 426 * Confirmation de la suppression de la propale 427 */ 428 if ($_GET['action'] == 'delete') 429 { 430 $html->form_confirm('propal.php?propalid='.$propal->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete'); 431 print '<br>'; 432 } 433 434 /* 435 * Confirmation de la validation de la propale 436 */ 437 if ($_GET['action'] == 'validate') 438 { 439 $html->form_confirm('propal.php?propalid='.$propal->id, $langs->trans('ValidateProp'), $langs->trans('ConfirmValidateProp'), 'confirm_validate'); 440 print '<br>'; 441 } 442 443 444 /* 445 * Fiche propal 446 * 447 */ 448 $sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref, p.fk_statut, '.$db->pdate('p.datep').' as dp, p.note,'; 449 $sql.= ' x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture'; 450 $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'socpeople as x'; 451 $sql.= ' WHERE p.fk_soc = s.idp AND p.fk_soc_contact = x.idp AND p.rowid = '.$propal->id; 452 if ($socidp) $sql .= ' AND s.idp = '.$socidp; 453 454 $resql = $db->query($sql); 455 if ($resql) 456 { 457 if($db->num_rows($resql)) 458 { 459 $obj = $db->fetch_object($resql); 460 461 $societe = new Societe($db); 462 $societe->fetch($obj->idp); 463 464 print '<table class="border" width="100%">'; 465 $rowspan=6; 466 467 // Société 468 print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'; 469 if ($societe->client == 1) 470 { 471 $url ='fiche.php?socid='.$societe->id; 472 } 473 else 474 { 475 $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; 476 } 477 print '<a href="'.$url.'">'.$societe->nom.'</a></td>'; 478 print '</tr>'; 479 480 // Dates 481 print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'; 482 print dolibarr_print_date($propal->date,'%a %d %B %Y'); 483 print '</td>'; 484 485 print '<td>'; 486 print '<table class="nobordernopadding" width="100%"><tr><td>'; 487 print $langs->trans('DateEndPropal'); 488 print '</td>'; 489 if ($_GET['action'] != 'editecheance' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editecheance&propalid='.$propal->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>'; 490 print '</tr></table>'; 491 print '<td>'; 492 if ($propal->brouillon && $_GET['action'] == 'editecheance') 493 { 494 print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'" method="post">'; 495 print '<input type="hidden" name="action" value="setecheance">'; 496 $html->select_date($propal->fin_validite,'ech'); 497 print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; 498 print '</form>'; 499 } 500 else 501 { 502 if ($propal->fin_validite) 503 { 504 print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y'); 505 if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); 506 } 507 else 508 { 509 print $langs->trans("Unknown"); 510 } 511 } 512 print '</td>'; 513 print '</tr>'; 514 515 // Conditions et modes de réglement 516 print '<tr><td>'; 517 print '<table class="nobordernopadding" width="100%"><tr><td>'; 518 print $langs->trans('PaymentConditions'); 519 print '</td>'; 520 // if ($_GET['action'] != 'editconditions' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&facid='.$propal->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>'; 521 print '</tr></table>'; 522 print '</td><td colspan="3">'; 523 if ($_GET['action'] == 'editconditions') 524 { 525 $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->cond_reglement_id,'cond_reglement_id'); 526 } 527 else 528 { 529 $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->cond_reglement_id,'none'); 530 } 531 print '</td>'; 532 print '<td width="25%">'; 533 print '<table class="nobordernopadding" width="100%"><tr><td>'; 534 print $langs->trans('PaymentMode'); 535 print '</td>'; 536 // if ($_GET['action'] != 'editmode' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&facid='.$propal->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>'; 537 print '</tr></table>'; 538 print '</td><td width="25%">'; 539 if ($_GET['action'] == 'editmode') 540 { 541 $html->form_modes_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->mode_reglement_id,'mode_reglement_id'); 542 } 543 else 544 { 545 $html->form_modes_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->mode_reglement_id,'none'); 546 } 547 print '</td></tr>'; 548 549 // Destinataire 550 $langs->load('mails'); 551 print '<tr>'; 552 print '<td>'.$langs->trans('MailTo').'</td>'; 553 554 $dests=$societe->contact_array($societe->id); 555 $numdest = count($dests); 556 if ($numdest==0) 557 { 558 print '<td colspan="3">'; 559 print '<font class="error">Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale</font><br>'; 560 print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$societe->id.'&action=create&backtoreferer=1">'.$langs->trans('AddContact').'</a>'; 561 print '</td>'; 562 } 563 else 564 { 565 if ($propal->statut == 0 && $user->rights->propale->creer) 566 { 567 print '<td colspan="2">'; 568 print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; 569 print '<input type="hidden" name="action" value="set_contact">'; 570 $html->select_contacts($societe->id, $propal->contactid, 'contactidp'); 571 print '</td><td>'; 572 print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; 573 print '</form>'; 574 print '</td>'; 575 } 576 else 577 { 578 if (!empty($propal->contactid)) 579 { 580 print '<td colspan="3">'; 581 require_once(DOL_DOCUMENT_ROOT.'/contact.class.php'); 582 $contact=new Contact($db); 583 $contact->fetch($propal->contactid); 584 print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$propal->contactid.'" title="'.$langs->trans('ShowContact').'">'; 585 print $contact->firstname.' '.$contact->name; 586 print '</a>'; 587 print '</td>'; 588 } 589 else { 590 print '<td colspan="3"> </td>'; 591 } 592 } 593 } 594 595 if ($conf->projet->enabled) $rowspan++; 596 597 print '<td valign="top" colspan="2" width="50%" rowspan="'.$rowspan.'">'.$langs->trans('Note').' :<br>'. nl2br($propal->note).'</td></tr>'; 598 599 if ($conf->projet->enabled) 600 { 601 $langs->load("projects"); 602 print '<tr><td>'.$langs->trans('Project').'</td>'; 603 $numprojet = $societe->has_projects(); 604 if (! $numprojet) 605 { 606 print '<td colspan="2">'; 607 print $langs->trans("NoProject").'</td><td>'; 608 print '<a href=../projet/fiche.php?socidp='.$societe->id.'&action=create>'.$langs->trans('AddProject').'</a>'; 609 print '</td>'; 610 } 611 else 612 { 613 if ($propal->statut == 0 && $user->rights->propale->creer) 614 { 615 print '<td colspan="2">'; 616 print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; 617 print '<input type="hidden" name="action" value="set_project">'; 618 $form->select_projects($societe->id, $propal->projetidp, 'projetidp'); 619 print '</td><td>'; 620 print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; 621 print '</form>'; 622 print '</td>'; 623 } 624 else 625 { 626 if (!empty($propal->projetidp)) 627 { 628 print '<td colspan="3">'; 629 $proj = new Project($db); 630 $proj->fetch($propal->projetidp); 631 print '<a href="../projet/fiche.php?id='.$propal->projetidp.'" title="'.$langs->trans('ShowProject').'">'; 632 print $proj->title; 633 print '</a>'; 634 print '</td>'; 635 } 636 else { 637 print '<td colspan="3"> </td>'; 638 } 639 } 640 } 641 print '</tr>'; 642 } 643 644 print '<tr><td height="10" nowrap>'.$langs->trans('GlobalDiscount').'</td>'; 645 if ($propal->brouillon == 1 && $user->rights->propale->creer) 646 { 647 print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; 648 print '<input type="hidden" name="action" value="setremise">'; 649 print '<td colspan="2"><input type="text" name="remise" size="3" value="'.$propal->remise_percent.'">% '; 650 print '</td><td>'; 651 print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; 652 print ' <a href="propal/aideremise.php?propalid='.$propal->id.'">?</a>'; 653 print '</td>'; 654 print '</form>'; 655 } 656 else 657 { 658 print '<td colspan="3">'.$propal->remise_percent.'%</td>'; 659 } 660 print '</tr>'; 661 662 print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>'; 663 print '<td align="right" colspan="2"><b>'.price($propal->price).'</b></td>'; 664 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 665 666 print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2">'.price($propal->total_tva).'</td>'; 667 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 668 print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2">'.price($propal->total_ttc).'</td>'; 669 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 670 671 // Statut 672 print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$propal->getLibStatut().'</td></tr>'; 673 print '</table><br>'; 674 if ($propal->brouillon == 1 && $user->rights->propale->creer) 675 { 676 print '</form>'; 677 } 678 679 /* 680 * Lignes de propale 681 * 682 */ 683 $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice,'; 684 $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; 685 $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; 686 $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; 687 $sql.= ' WHERE pt.fk_propal = '.$propal->id; 688 $sql.= ' ORDER BY pt.rowid ASC'; 689 $resql = $db->query($sql); 690 if ($resql) 691 { 692 $num = $db->num_rows($resql); 693 $i = 0; $total = 0; 694 695 print '<table class="noborder" width="100%">'; 696 if ($num) 697 { 698 print '<tr class="liste_titre">'; 699 print '<td>'.$langs->trans('Description').'</td>'; 700 print '<td align="right" width="50">'.$langs->trans('VAT').'</td>'; 701 print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>'; 702 print '<td align="right" width="50">'.$langs->trans('Qty').'</td>'; 703 print '<td align="right" width="50">'.$langs->trans('Discount').'</td>'; 704 print '<td align="right" width="50">'.$langs->trans('AmountHT').'</td>'; 705 print '<td width="16"> </td><td width="16"> </td>'; 706 print "</tr>\n"; 707 } 708 $var=true; 709 while ($i < $num) 710 { 711 $objp = $db->fetch_object($resql); 712 $var=!$var; 713 714 // Ligne en mode visu 715 if ($_GET['action'] != 'editline' || $_GET['ligne'] != $objp->rowid) 716 { 717 print '<tr '.$bc[$var].'>'; 718 if ($objp->fk_product > 0) 719 { 720 print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'; 721 if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); 722 else print img_object($langs->trans('ShowProduct'),'product'); 723 print ' '.$objp->ref.'</a>'; 724 print ' - '.nl2br(stripslashes($objp->product)); 725 if ($objp->date_start && $objp->date_end) 726 { 727 print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; 728 } 729 if ($objp->date_start && ! $objp->date_end) 730 { 731 print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; 732 } 733 if (! $objp->date_start && $objp->date_end) 734 { 735 print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; 736 } 737 print ($objp->description && $objp->description!=$objp->product)?'<br>'.$objp->description:''; 738 print '</td>'; 739 } 740 else 741 { 742 print '<td>'.stripslashes(nl2br($objp->description)); 743 if ($objp->date_start && $objp->date_end) 744 { 745 print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; 746 } 747 if ($objp->date_start && ! $objp->date_end) 748 { 749 print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; 750 } 751 if (! $objp->date_start && $objp->date_end) 752 { 753 print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; 754 } 755 print "</td>\n"; 756 } 757 print '<td align="right">'.$objp->tva_tx.'%</td>'; 758 print '<td align="right">'.price($objp->subprice)."</td>\n"; 759 print '<td align="right">'.$objp->qty.'</td>'; 760 if ($objp->remise_percent > 0) 761 { 762 print '<td align="right">'.$objp->remise_percent."%</td>\n"; 763 } 764 else 765 { 766 print '<td> </td>'; 767 } 768 print '<td align="right">'.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."</td>\n"; 769 770 // Icone d'edition et suppression 771 if ($propal->statut == 0 && $user->rights->propale->creer) 772 { 773 print '<td align="right"><a href="propal.php?propalid='.$propal->id.'&action=editline&ligne='.$objp->rowid.'">'; 774 print img_edit(); 775 print '</a></td>'; 776 print '<td align="right"><a href="propal.php?propalid='.$propal->id.'&action=del_ligne&ligne='.$objp->rowid.'">'; 777 print img_delete(); 778 print '</a></td>'; 779 } 780 else 781 { 782 print '<td> </td><td> </td>'; 783 } 784 print '</tr>'; 785 } 786 787 // Ligne en mode update 788 if ($propal->statut == 0 && $_GET["action"] == 'editline' && $user->rights->propale->creer && $_GET["ligne"] == $objp->rowid) 789 { 790 print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; 791 print '<input type="hidden" name="action" value="updateligne">'; 792 print '<input type="hidden" name="propalid" value="'.$propal->id.'">'; 793 print '<input type="hidden" name="ligne" value="'.$_GET["ligne"].'">'; 794 print '<tr '.$bc[$var].'>'; 795 print '<td>'; 796 if ($objp->fk_product > 0) 797 { 798 print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'; 799 if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); 800 else print img_object($langs->trans('ShowProduct'),'product'); 801 print ' '.$objp->ref.'</a>'; 802 print ' - '.stripslashes(nl2br($objp->product)); 803 print '<br>'; 804 } 805 print '<textarea name="desc" cols="50" rows="'.ROWS_2.'">'.stripslashes($objp->description).'</textarea></td>'; 806 print '<td align="right">'; 807 print $html->select_tva("tva_tx",$objp->tva_tx,$mysoc,$societe); 808 print '</td>'; 809 print '<td align="right"><input size="6" type="text" name="subprice" value="'.price($objp->subprice).'"></td>'; 810 print '<td align="right"><input size="2" type="text" name="qty" value="'.$objp->qty.'"></td>'; 811 print '<td align="right" nowrap><input size="2" type="text" name="remise_percent" value="'.$objp->remise_percent.'">%</td>'; 812 print '<td align="center" colspan="4" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; 813 print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>'; 814 print '</tr>' . "\n"; 815 /* 816 if ($conf->service->enabled) 817 { 818 print "<tr $bc[$var]>"; 819 print '<td colspan="5">Si produit de type service à durée limitée: Du '; 820 print $html->select_date($objp->date_start,"date_start",0,0,$objp->date_start?0:1); 821 print ' au '; 822 print $html->select_date($objp->date_end,"date_end",0,0,$objp->date_end?0:1); 823 print '</td>'; 824 print '</tr>' . "\n"; 825 } 826 */ 827 print "</form>\n"; 828 } 829 830 $total = $total + ($objp->qty * $objp->price); 831 $i++; 832 } 833 834 $db->free($resql); 835 } 836 else 837 { 838 dolibarr_print_error($db); 839 } 840 841 /* 842 * Ajouter une ligne 843 */ 844 if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline') 845 { 846 print '<tr class="liste_titre">'; 847 print '<td>'.$langs->trans('Description').'</td>'; 848 print '<td align="right">'.$langs->trans('VAT').'</td>'; 849 print '<td align="right">'.$langs->trans('PriceUHT').'</td>'; 850 print '<td align="right">'.$langs->trans('Qty').'</td>'; 851 print '<td align="right">'.$langs->trans('Discount').'</td>'; 852 print '<td> </td>'; 853 print '<td> </td>'; 854 print '<td> </td>'; 855 print "</tr>\n"; 856 857 // Ajout produit produits/services personalisés 858 print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; 859 print '<input type="hidden" name="propalid" value="'.$propal->id.'">'; 860 print '<input type="hidden" name="action" value="addligne">'; 861 862 $var=true; 863 print '<tr '.$bc[$var].">\n"; 864 print ' <td><textarea cols="50" name="np_desc" rows="'.ROWS_2.'"></textarea></td>'; 865 print ' <td align="center">'; 866 $html->select_tva('np_tva_tx', $conf->defaulttx, $mysoc, $societe) . "</td>\n"; 867 print ' <td align="right"><input type="text" size="5" name="np_price"></td>'; 868 print ' <td align="right"><input type="text" size="2" value="1" name="np_qty"></td>'; 869 print ' <td align="right" nowrap><input type="text" size="2" value="'.$societe->remise_client.'" name="np_remise">%</td>'; 870 print ' <td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addligne"></td>'; 871 print '</tr>'; 872 873 print '</form>'; 874 875 // Ajout de produits/services prédéfinis 876 if ($conf->produit->enabled) 877 { 878 print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; 879 print '<input type="hidden" name="propalid" value="'.$propal->id.'">'; 880 print '<input type="hidden" name="action" value="addligne">'; 881 882 $var=!$var; 883 print '<tr '.$bc[$var].'>'; 884 print '<td colspan="2">'; 885 $html->select_produits('','idprod','',$conf->produit->limit_size); 886 print '<br>'; 887 print '<textarea cols="50" name="np_desc" rows="'.ROWS_2.'"></textarea>'; 888 print '</td>'; 889 print '<td> </td>'; 890 print '<td align="right"><input type="text" size="2" name="qty" value="1"></td>'; 891 print '<td align="right" nowrap><input type="text" size="2" name="remise" value="'.$societe->remise_client.'">%</td>'; 892 print '<td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans("Add").'" name="addligne"></td>'; 893 print "</tr>\n"; 894 895 print '</form>'; 896 } 897 } 898 899 print '</table>'; 900 901 } 902 } 903 else 904 { 905 dolibarr_print_error($db); 906 } 907 908 print '</div>'; 909 910 /* 911 * Formulaire cloture (signé ou non) 912 */ 913 if ($_GET['action'] == 'statut') 914 { 915 print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; 916 print '<table class="border" width="100%">'; 917 print '<tr><td>'.$langs->trans('Note').'</td><td><textarea cols="60" rows="'.ROWS_3.'" wrap="soft" name="note">'; 918 print $propal->note; 919 print '</textarea></td></tr>'; 920 print '<tr><td>'.$langs->trans("CloseAs").'</td><td>'; 921 print '<input type="hidden" name="action" value="setstatut">'; 922 print '<select name="statut">'; 923 print '<option value="2">'.$propal->labelstatut[2].'</option>'; 924 print '<option value="3">'.$propal->labelstatut[3].'</option>'; 925 print '</select>'; 926 print '</td></tr>'; 927 print '<tr><td align="center" colspan="2">'; 928 print '<input type="submit" class="button" name="validate" value="'.$langs->trans('Validate').'">'; 929 print ' <input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">'; 930 print '</td>'; 931 print '</tr></table></form>'; 932 } 933 934 935 /* 936 * Boutons Actions 937 */ 938 print '<div class="tabsAction">'; 939 940 if ($_GET['action'] != 'statut') 941 { 942 943 // Valid 944 if ($propal->statut == 0) 945 { 946 if ($user->rights->propale->valider) 947 { 948 print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=validate">'.$langs->trans('Validate').'</a>'; 949 } 950 } 951 952 // Save 953 if ($propal->statut == 1) 954 { 955 if ($user->rights->propale->creer) 956 { 957 print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=modif">'.$langs->trans('Edit').'</a>'; 958 } 959 } 960 961 // Build PDF 962 if ($user->rights->propale->creer) 963 { 964 if ($propal->statut < 2) 965 { 966 print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=builddoc">'.$langs->trans("BuildPDF").'</a>'; 967 } 968 else 969 { 970 print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=builddoc">'.$langs->trans("RebuildPDF").'</a>'; 971 } 972 } 973 974 // Send 975 if ($propal->statut == 1) 976 { 977 if ($user->rights->propale->envoyer) 978 { 979 $propref = sanitize_string($propal->ref); 980 $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; 981 if (file_exists($file)) 982 { 983 print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=presend">'.$langs->trans('Send').'</a>'; 984 } 985 } 986 } 987 988 // Close 989 if ($propal->statut != 0) 990 { 991 if ($propal->statut == 1 && $user->rights->propale->cloturer) 992 { 993 print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=statut">'.$langs->trans('Close').'</a>'; 994 } 995 } 996 997 // Delete 998 if ($propal->statut == 0) 999 { 1000 if ($user->rights->propale->supprimer) 1001 { 1002 print '<a class="butActionDelete" href="propal.php?propalid='.$propal->id.'&action=delete">'.$langs->trans('Delete').'</a>'; 1003 } 1004 } 1005 1006 } 1007 1008 print '</div>'; 1009 1010 1011 1012 print '<table width="100%"><tr><td width="50%" valign="top">'; 1013 1014 1015 /* 1016 * Documents générés 1017 */ 1018 $filename=sanitize_string($propal->ref); 1019 $filedir=$conf->propal->dir_output . "/" . sanitize_string($propal->ref); 1020 $urlsource=$_SERVER["PHP_SELF"]."?propalid=".$propal->id; 1021 $genallowed=$user->rights->propale->creer; 1022 $delallowed=$user->rights->propale->supprimer; 1023 1024 $var=true; 1025 1026 $html->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf); 1027 1028 1029 /* 1030 * Commandes rattachées 1031 */ 1032 if($conf->commande->enabled) 1033 { 1034 $coms = $propal->associated_orders(); 1035 if (sizeof($coms) > 0) 1036 { 1037 print '<br>'; 1038 print_titre($langs->trans('RelatedOrders')); 1039 print '<table class="noborder" width="100%">'; 1040 print '<tr class="liste_titre">'; 1041 print '<td>'.$langs->trans("Ref").'</td>'; 1042 print '<td align="center">'.$langs->trans("Date").'</td>'; 1043 print '<td align="right">'.$langs->trans("Price").'</td>'; 1044 print '</tr>'; 1045 $var=true; 1046 for ($i = 0 ; $i < sizeof($coms) ; $i++) 1047 { 1048 $var=!$var; 1049 print '<tr '.$bc[$var].'><td>'; 1050 print '<a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$coms[$i]->id.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."</a></td>\n"; 1051 print '<td align="center">'.dolibarr_print_date($coms[$i]->date).'</td>'; 1052 print '<td align="right">'.$coms[$i]->total_ttc.'</td>'; 1053 print "</tr>\n"; 1054 } 1055 print '</table>'; 1056 } 1057 } 1058 1059 print '</td><td valign="top" width="50%">'; 1060 1061 /* 1062 * Liste des actions propres à la propal 1063 */ 1064 $sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ; 1065 $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; 1066 $sql .= ' WHERE a.propalrowid = '.$propal->id ; 1067 if ($socidp) $sql .= ' AND a.fk_soc = '.$socidp; 1068 $resql = $db->query($sql); 1069 if ($resql) 1070 { 1071 $num = $db->num_rows($resql); 1072 if ($num) 1073 { 1074 print_titre($langs->trans('ActionsOnPropal')); 1075 $i = 0; 1076 $total = 0; 1077 $var=true; 1078 1079 print '<table class="border" width="100%">'; 1080 print '<tr '.$bc[$var].'><td>'.$langs->trans('Ref').'</td><td>'.$langs->trans('Date').'</td><td>'.$langs->trans('Action').'</td><td>'.$langs->trans('By').'</td></tr>'; 1081 print "\n"; 1082 1083 while ($i < $num) 1084 { 1085 $objp = $db->fetch_object($resql); 1086 $var=!$var; 1087 print '<tr '.$bc[$var].'>'; 1088 print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$objp->id.'">'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.'</a></td>'; 1089 print '<td>'.dolibarr_print_date($objp->da)."</td>\n"; 1090 print '<td>'.stripslashes($objp->label).'</td>'; 1091 $authoract = new User($db); 1092 $authoract->id = $objp->fk_user_author; 1093 $authoract->fetch(''); 1094 print '<td>'.$authoract->code.'</td>'; 1095 print "</tr>\n"; 1096 $i++; 1097 } 1098 print '</table>'; 1099 } 1100 } 1101 else 1102 { 1103 dolibarr_print_error($db); 1104 } 1105 1106 print '</td></tr></table>'; 1107 1108 1109 /* 1110 * Action presend 1111 * 1112 */ 1113 if ($_GET['action'] == 'presend') 1114 { 1115 print '<br>'; 1116 print_titre($langs->trans('SendPropalByMail')); 1117 1118 $liste[0]=" "; 1119 foreach ($societe->contact_email_array() as $key=>$value) 1120 { 1121 $liste[$key]=$value; 1122 } 1123 1124 // Créé l'objet formulaire mail 1125 include_once ('../html.formmail.class.php'); 1126 $formmail = new FormMail($db); 1127 $formmail->fromname = $user->fullname; 1128 $formmail->frommail = $user->email; 1129 $formmail->withfrom=1; 1130 $formmail->withto=$liste; 1131 $formmail->withcc=1; 1132 $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); 1133 $formmail->withfile=1; 1134 $formmail->withbody=1; 1135 // Tableau des substitutions 1136 $formmail->substit['__PROPREF__']=$propal->ref; 1137 // Tableau des paramètres complémentaires 1138 $formmail->param['action']='send'; 1139 $formmail->param['models']='propal_send'; 1140 $formmail->param['propalid']=$propal->id; 1141 $formmail->param['returnurl']=DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; 1142 1143 $formmail->show_form(); 1144 } 1145 1146 } 1147 else 1148 { 1149 /**************************************************************************** 1150 * * 1151 * Mode Liste des propales * 1152 * * 1153 ****************************************************************************/ 1154 1155 $sortorder=$_GET['sortorder']; 1156 $sortfield=$_GET['sortfield']; 1157 $page=$_GET['page']; 1158 $viewstatut=$_GET['viewstatut']; 1159 1160 if (! $sortfield) $sortfield='p.datep'; 1161 if (! $sortorder) $sortorder='DESC'; 1162 $limit = $conf->liste_limit; 1163 $offset = $limit * $page ; 1164 $pageprev = $page - 1; 1165 $pagenext = $page + 1; 1166 1167 $sql = 'SELECT s.nom, s.idp, s.client, p.rowid as propalid, p.price, p.ref, p.fk_statut, '.$db->pdate('p.datep').' as dp,'.$db->pdate('p.fin_validite').' as dfv'; 1168 $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p'; 1169 if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; 1170 $sql.= ' WHERE p.fk_soc = s.idp'; 1171 1172 if (!empty($_GET['search_ref'])) 1173 { 1174 $sql .= " AND p.ref LIKE '%".$_GET['search_ref']."%'"; 1175 } 1176 if (!empty($_GET['search_societe'])) 1177 { 1178 $sql .= " AND s.nom LIKE '%".$_GET['search_societe']."%'"; 1179 } 1180 if (!empty($_GET['search_montant_ht'])) 1181 { 1182 $sql .= " AND p.price='".$_GET['search_montant_ht']."'"; 1183 } 1184 if ($sall) $sql.= " AND (s.nom like '%".$sall."%' OR p.note like '%".$sall."%' OR pd.description like '%".$sall."%')"; 1185 if ($socidp) $sql .= ' AND s.idp = '.$socidp; 1186 if ($_GET['viewstatut'] <> '') 1187 { 1188 $sql .= ' AND p.fk_statut in ('.$_GET['viewstatut'].')'; 1189 } 1190 if ($month > 0) 1191 { 1192 $sql .= " AND date_format(p.datep, '%Y-%m') = '$year-$month'"; 1193 } 1194 if ($year > 0) 1195 { 1196 $sql .= " AND date_format(p.datep, '%Y') = $year"; 1197 } 1198 if (strlen($_POST['sf_ref']) > 0) 1199 { 1200 $sql .= " AND p.ref like '%".$_POST["sf_ref"] . "%'"; 1201 } 1202 $sql .= ' ORDER BY '.$sortfield.' '.$sortorder.', p.ref DESC'; 1203 $sql .= $db->plimit($limit + 1,$offset); 1204 $result=$db->query($sql); 1205 1206 if ($result) 1207 { 1208 $num = $db->num_rows($result); 1209 print_barre_liste($langs->trans('ListOfProposals'), $page,'propal.php','&socidp='.$socidp,$sortfield,$sortorder,'',$num); 1210 $i = 0; 1211 print '<table class="liste" width="100%">'; 1212 print '<tr class="liste_titre">'; 1213 print_liste_field_titre($langs->trans('Ref'),'propal.php','p.ref','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'',$sortfield); 1214 print_liste_field_titre($langs->trans('Company'),'propal.php','s.nom','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'',$sortfield); 1215 print_liste_field_titre($langs->trans('Date'),'propal.php','p.datep','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="center"',$sortfield); 1216 print_liste_field_titre($langs->trans('DateEndPropalShort'),'propal.php','dfv','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="center"',$sortfield); 1217 print_liste_field_titre($langs->trans('Price'),'propal.php','p.price','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="right"',$sortfield); 1218 print_liste_field_titre($langs->trans('Status'),'propal.php','p.fk_statut','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'align="center"',$sortfield); 1219 print "</tr>\n"; 1220 // Lignes des champs de filtre 1221 print '<form method="get" action="propal.php">'; 1222 1223 print '<tr class="liste_titre">'; 1224 print '<td class="liste_titre" valign="right">'; 1225 print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET['search_ref'].'">'; 1226 print '</td>'; 1227 print '<td class="liste_titre" align="left">'; 1228 print '<input class="flat" type="text" size="40" name="search_societe" value="'.$_GET['search_societe'].'">'; 1229 print '</td>'; 1230 print '<td class="liste_titre" colspan="2"> </td>'; 1231 print '<td class="liste_titre" align="right">'; 1232 print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$_GET['search_montant_ht'].'">'; 1233 print '</td>'; 1234 print '<td class="liste_titre" align="right"><input class="liste_titre" type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">'; 1235 print '</td>'; 1236 print "</tr>\n"; 1237 print '</form>'; 1238 1239 $var=true; 1240 1241 while ($i < min($num,$limit)) 1242 { 1243 $objp = $db->fetch_object($result); 1244 $now = time(); 1245 $var=!$var; 1246 print '<tr '.$bc[$var].'>'; 1247 print '<td><a href="propal.php?propalid='.$objp->propalid.'">'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref."</a></td>\n"; 1248 1249 if ($objp->client == 1) 1250 { 1251 $url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->idp; 1252 } 1253 else 1254 { 1255 $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$objp->idp; 1256 } 1257 print '<td><a href="'.$url.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.'</a></td>'; 1258 1259 // Date propale 1260 print '<td align="center">'; 1261 $y = strftime('%Y',$objp->dp); 1262 $m = strftime('%m',$objp->dp); 1263 1264 print strftime('%d',$objp->dp)."\n"; 1265 print ' <a href="propal.php?year='.$y.'&month='.$m.'">'; 1266 print dolibarr_print_date($objp->dp,'%b')."</a>\n"; 1267 print ' <a href="propal.php?year='.$y.'">'; 1268 print strftime('%Y',$objp->dp)."</a></td>\n"; 1269 1270 // Date fin validite 1271 if ($objp->dfv) 1272 { 1273 print '<td align="center">'.dolibarr_print_date($objp->dfv); 1274 if ($objp->fk_statut == 1 && $objp->dfv < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); 1275 print '</td>'; 1276 } 1277 else 1278 { 1279 print '<td> </td>'; 1280 } 1281 1282 print '<td align="right">'.price($objp->price)."</td>\n"; 1283 $propal=New Propal($db); 1284 print '<td align="center">'.$propal->LibStatut($objp->fk_statut,0)."</td>\n"; 1285 print "</tr>\n"; 1286 1287 $total = $total + $objp->price; 1288 $subtotal = $subtotal + $objp->price; 1289 1290 $i++; 1291 } 1292 print '</table>'; 1293 $db->free($result); 1294 } 1295 else 1296 { 1297 dolibarr_print_error($db); 1298 } 1299 } 1300 $db->close(); 1301 1302 llxFooter('$Date: 2006/01/22 21:08:01 $ - $Revision: 1.134.2.1 $'); 1303 1304 ?>
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 |
![]() |