| [ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2003,2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Destailleur Laurent <eldy@users.sourceforge.net> 4 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> 5 * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.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.63 2005/11/30 16:44:18 hregis Exp $ 22 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/propal.php,v $ 23 */ 24 25 /** 26 \file htdocs/compta/propal.php 27 \ingroup propale 28 \brief Page liste des propales (vision compta) 29 */ 30 31 require ("./pre.inc.php"); 32 33 $user->getrights('facture'); 34 $user->getrights('propale'); 35 if (!$user->rights->propale->lire) 36 accessforbidden(); 37 38 $langs->load('compta'); 39 40 if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php'); 41 if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php'); 42 require_once (DOL_DOCUMENT_ROOT."/propal.class.php"); 43 require_once (DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php"); 44 45 // Sécurité accés client 46 if ($user->societe_id > 0) 47 { 48 $action = ''; 49 $socidp = $user->societe_id; 50 } 51 52 if ($_GET["action"] == 'setstatut') 53 { 54 /* 55 * Classée la facture comme facturée 56 */ 57 $propal = new Propal($db); 58 $propal->id = $_GET["propalid"]; 59 $propal->cloture($user, $_GET["statut"], $note); 60 61 } 62 63 if ( $action == 'delete' ) 64 { 65 $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = $propalid;"; 66 if ( $db->query($sql) ) 67 { 68 69 $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = $propalid ;"; 70 if ( $db->query($sql) ) 71 { 72 print '<div class="ok">'.$langs->trans("Deleted").'</div>'; 73 } 74 else 75 { 76 dolibarr_print_error($db); 77 } 78 } 79 else 80 { 81 dolibarr_print_error($db); 82 } 83 $propalid = 0; 84 $brouillon = 1; 85 } 86 87 88 llxHeader(); 89 90 $html = new Form($db); 91 92 /* 93 * 94 * Mode fiche 95 * 96 */ 97 if ($_GET["propalid"] > 0) 98 { 99 if ($msg) print "$msg<br>"; 100 101 $propal = new Propal($db); 102 $propal->fetch($_GET["propalid"]); 103 $h=0; 104 105 $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; 106 $head[$h][1] = $langs->trans('CommercialCard'); 107 $h++; 108 109 $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; 110 $head[$h][1] = $langs->trans('AccountancyCard'); 111 $hselected=$h; 112 $h++; 113 114 if ($conf->use_preview_tabs) 115 { 116 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; 117 $head[$h][1] = $langs->trans("Preview"); 118 $h++; 119 } 120 121 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; 122 $head[$h][1] = $langs->trans('Note'); 123 $h++; 124 125 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; 126 $head[$h][1] = $langs->trans('Info'); 127 $h++; 128 129 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; 130 $head[$h][1] = $langs->trans('Documents'); 131 $h++; 132 133 dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref); 134 135 136 /* 137 * Fiche propal 138 * 139 */ 140 $sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref,'.$db->pdate('p.datep').' as dp, c.id as statut, c.label as lst, p.note,'; 141 $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'; 142 $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c, '.MAIN_DB_PREFIX.'socpeople as x'; 143 $sql.= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = '.$propal->id; 144 if ($socidp) $sql .= ' AND s.idp = '.$socidp; 145 146 $resql = $db->query($sql); 147 if ($resql) 148 { 149 if ($db->num_rows($resql)) 150 { 151 $obj = $db->fetch_object($resql); 152 153 $societe = new Societe($db); 154 $societe->fetch($obj->idp); 155 156 print '<table class="border" width="100%">'; 157 $rowspan=6; 158 159 // Société 160 print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'; 161 if ($societe->client == 1) 162 { 163 $url ='fiche.php?socid='.$societe->id; 164 } 165 else 166 { 167 $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; 168 } 169 print '<a href="'.$url.'">'.$societe->nom.'</a></td>'; 170 print '</tr>'; 171 172 // Dates 173 print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'; 174 print dolibarr_print_date($propal->date,'%a %d %B %Y'); 175 print '</td>'; 176 177 print '<td>'.$langs->trans('DateEndPropal').'</td><td>'; 178 if ($propal->fin_validite) 179 { 180 print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y'); 181 if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); 182 } 183 else 184 { 185 print $langs->trans("Unknown"); 186 } 187 print '</td>'; 188 print '</tr>'; 189 190 // Conditions et modes de réglement 191 print '<tr><td>'; 192 print '<table class="nobordernopadding" width="100%"><tr><td>'; 193 print $langs->trans('PaymentConditions'); 194 print '</td>'; 195 if ($_GET['action'] != 'editconditions' && $prop->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&facid='.$prop->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>'; 196 print '</tr></table>'; 197 print '</td><td colspan="3">'; 198 if ($_GET['action'] == 'editconditions') 199 { 200 $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$prop->cond_reglement_id,'cond_reglement_id'); 201 } 202 else 203 { 204 $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$prop->cond_reglement_id,'none'); 205 } 206 print '</td>'; 207 print '<td width="25%">'; 208 print '<table class="nobordernopadding" width="100%"><tr><td>'; 209 print $langs->trans('PaymentMode'); 210 print '</td>'; 211 if ($_GET['action'] != 'editmode' && $prop->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&facid='.$prop->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>'; 212 print '</tr></table>'; 213 print '</td><td width="25%">'; 214 if ($_GET['action'] == 'editmode') 215 { 216 $html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$prop->mode_reglement_id,'mode_reglement_id'); 217 } 218 else 219 { 220 $html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$prop->mode_reglement_id,'none'); 221 } 222 print '</td></tr>'; 223 224 // Destinataire 225 $langs->load('mails'); 226 print '<tr>'; 227 print '<td>'.$langs->trans('MailTo').'</td>'; 228 229 $dests=$societe->contact_array($societe->id); 230 $numdest = count($dests); 231 if ($numdest==0) 232 { 233 print '<td colspan="3">'; 234 print '<font class="error">Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale</font><br>'; 235 print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$societe->id.'&action=create&backtoreferer=1">'.$langs->trans('AddContact').'</a>'; 236 print '</td>'; 237 } 238 else 239 { 240 if ($propal->statut == 0 && $user->rights->propale->creer) 241 { 242 print '<td colspan="2">'; 243 print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; 244 print '<input type="hidden" name="action" value="set_contact">'; 245 $html->select_contacts($societe->id, $propal->contactid, 'contactidp'); 246 print '</td><td>'; 247 print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; 248 print '</form>'; 249 print '</td>'; 250 } 251 else 252 { 253 if (!empty($propal->contactid)) 254 { 255 print '<td colspan="3">'; 256 require_once(DOL_DOCUMENT_ROOT.'/contact.class.php'); 257 $contact=new Contact($db); 258 $contact->fetch($propal->contactid); 259 print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$propal->contactid.'" title="'.$langs->trans('ShowContact').'">'; 260 print $contact->firstname.' '.$contact->name; 261 print '</a>'; 262 print '</td>'; 263 } 264 else { 265 print '<td colspan="3"> </td>'; 266 } 267 } 268 } 269 print '</td>'; 270 271 if ($conf->projet->enabled) 272 $rowspan++; 273 274 print '<td valign="top" colspan="2" width="50%" rowspan="'.$rowspan.'">'.$langs->trans('Note').' :<br>'. nl2br($propal->note).'</td></tr>'; 275 276 if ($conf->projet->enabled) 277 { 278 $langs->load("projects"); 279 print '<tr><td>'.$langs->trans('Project').'</td>'; 280 $numprojet = $societe->has_projects(); 281 if (! $numprojet) 282 { 283 print '<td colspan="2">'; 284 print $langs->trans("NoProject").'</td><td>'; 285 print '<a href=../projet/fiche.php?socidp='.$societe->id.'&action=create>'.$langs->trans('AddProject').'</a>'; 286 print '</td>'; 287 } 288 else 289 { 290 if ($propal->statut == 0 && $user->rights->propale->creer) 291 { 292 print '<td colspan="2">'; 293 print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; 294 print '<input type="hidden" name="action" value="set_project">'; 295 $html->select_projects($societe->id, $propal->projetidp, 'projetidp'); 296 print '</td><td>'; 297 print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; 298 print '</form>'; 299 print '</td>'; 300 } 301 else 302 { 303 if (!empty($propal->projetidp)) 304 { 305 print '<td colspan="3">'; 306 $proj = new Project($db); 307 $proj->fetch($propal->projetidp); 308 print '<a href="../projet/fiche.php?id='.$propal->projetidp.'" title="'.$langs->trans('ShowProject').'">'; 309 print $proj->title; 310 print '</a>'; 311 print '</td>'; 312 } 313 else { 314 print '<td colspan="3"> </td>'; 315 } 316 } 317 } 318 print '</tr>'; 319 } 320 321 print '<tr><td height="10" nowrap>'.$langs->trans('GlobalDiscount').'</td>'; 322 if ($propal->brouillon == 1 && $user->rights->propale->creer) 323 { 324 print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; 325 print '<input type="hidden" name="action" value="setremise">'; 326 print '<td colspan="2"><input type="text" name="remise" size="3" value="'.$propal->remise_percent.'">% '; 327 print '</td><td>'; 328 print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; 329 print ' <a href="propal/aideremise.php?propalid='.$propal->id.'">?</a>'; 330 print '</td>'; 331 print '</form>'; 332 } 333 else 334 { 335 print '<td colspan="3">'.$propal->remise_percent.'%</td>'; 336 } 337 print '</tr>'; 338 339 print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>'; 340 print '<td align="right" colspan="2"><b>'.price($propal->price).'</b></td>'; 341 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 342 343 print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2">'.price($propal->total_tva).'</td>'; 344 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 345 print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2">'.price($propal->total_ttc).'</td>'; 346 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 347 348 // Statut 349 print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$propal->getLibStatut().'</td></tr>'; 350 print '</table><br>'; 351 if ($propal->brouillon == 1 && $user->rights->propale->creer) 352 { 353 print '</form>'; 354 } 355 356 /* 357 * Lignes de propale 358 * 359 */ 360 $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; 361 $sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; 362 $sql .= ' WHERE pt.fk_propal = '.$propal->id; 363 $sql .= ' ORDER BY pt.rowid ASC'; 364 $resql = $db->query($sql); 365 if ($resql) 366 { 367 $num_lignes = $db->num_rows($resql); 368 $i = 0; 369 $total = 0; 370 371 print '<table class="noborder" width="100%">'; 372 if ($num_lignes) 373 { 374 print '<tr class="liste_titre">'; 375 print '<td>'.$langs->trans('Description').'</td>'; 376 print '<td align="right" width="50">'.$langs->trans('VAT').'</td>'; 377 print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>'; 378 print '<td align="right" width="50">'.$langs->trans('Qty').'</td>'; 379 print '<td align="right" width="50">'.$langs->trans('Discount').'</td>'; 380 print '<td align="right" width="50">'.$langs->trans('AmountHT').'</td>'; 381 print '<td> </td><td> </td>'; 382 print "</tr>\n"; 383 } 384 $var=true; 385 while ($i < $num_lignes) 386 { 387 $objp = $db->fetch_object($resql); 388 $var=!$var; 389 if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid) 390 { 391 print '<tr '.$bc[$var].'>'; 392 if ($objp->fk_product > 0) 393 { 394 print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'; 395 if ($objp->fk_product_type) 396 print img_object($langs->trans('ShowService'),'service'); 397 else 398 print img_object($langs->trans('ShowProduct'),'product'); 399 print ' '.$objp->ref.'</a> - '.stripslashes(nl2br($objp->product)); 400 if ($objp->date_start && $objp->date_end) 401 { 402 print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; 403 } 404 if ($objp->date_start && ! $objp->date_end) 405 { 406 print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; 407 } 408 if (! $objp->date_start && $objp->date_end) 409 { 410 print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; 411 } 412 print $objp->description?'<br>'.$objp->description:''; 413 print '</td>'; 414 } 415 else 416 { 417 print '<td>'.stripslashes(nl2br($objp->description)); 418 if ($objp->date_start && $objp->date_end) 419 { 420 print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; 421 } 422 if ($objp->date_start && ! $objp->date_end) 423 { 424 print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; 425 } 426 if (! $objp->date_start && $objp->date_end) 427 { 428 print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; 429 } 430 print "</td>\n"; 431 } 432 print '<td align="right">'.$objp->tva_tx.'%</td>'; 433 print '<td align="right">'.price($objp->subprice)."</td>\n"; 434 print '<td align="right">'.$objp->qty.'</td>'; 435 if ($objp->remise_percent > 0) 436 { 437 print '<td align="right">'.$objp->remise_percent."%</td>\n"; 438 } 439 else 440 { 441 print '<td> </td>'; 442 } 443 print '<td align="right">'.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."</td>\n"; 444 445 print '<td> </td><td> </td>'; 446 447 print '</tr>'; 448 } 449 450 451 452 $total = $total + ($objp->qty * $objp->price); 453 $i++; 454 } 455 $db->free($resql); 456 } 457 else 458 { 459 dolibarr_print_error($db); 460 } 461 462 print '</table>'; 463 464 } 465 } 466 else 467 { 468 dolibarr_print_error($db); 469 } 470 471 print '</div>'; 472 473 474 /* 475 * Boutons Actions 476 */ 477 if ($obj->statut <> 4 && $user->societe_id == 0) 478 { 479 print '<div class="tabsAction">'; 480 481 if ($obj->statut == 2 && $user->rights->facture->creer) 482 { 483 print '<a class="butAction" href="facture.php?propalid='.$propal->id."&action=create\">".$langs->trans("BuildBill")."</a>"; 484 } 485 486 if ($obj->statut == 2 && sizeof($propal->facture_liste_array())) 487 { 488 print '<a class="butAction" href="propal.php?propalid='.$propal->id."&action=setstatut&statut=4\">".$langs->trans("ClassifyBilled")."</a>"; 489 } 490 491 print "</div>"; 492 } 493 494 495 496 print '<table width="100%"><tr><td width="50%" valign="top">'; 497 498 /* 499 * Documents générés 500 */ 501 $filename=sanitize_string($propal->ref); 502 $filedir=$conf->propal->dir_output . "/" . sanitize_string($propal->ref); 503 $urlsource=$_SERVER["PHP_SELF"]."?propalid=".$propal->id; 504 $genallowed=0; 505 $delallowed=0; 506 507 $var=true; 508 509 $html->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed); 510 511 512 /* 513 * Commandes rattachées 514 */ 515 if($conf->commande->enabled) 516 { 517 $coms = $propal->associated_orders(); 518 if (sizeof($coms) > 0) 519 { 520 print '<br>'; 521 print_titre($langs->trans('RelatedOrders')); 522 print '<table class="noborder" width="100%">'; 523 print '<tr class="liste_titre">'; 524 print '<td>'.$langs->trans("Ref").'</td>'; 525 print '<td align="center">'.$langs->trans("Date").'</td>'; 526 print '<td align="right">'.$langs->trans("Price").'</td>'; 527 print '</tr>'; 528 $var=true; 529 for ($i = 0 ; $i < sizeof($coms) ; $i++) 530 { 531 $var=!$var; 532 print '<tr '.$bc[$var].'><td>'; 533 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"; 534 print '<td align="center">'.dolibarr_print_date($coms[$i]->date).'</td>'; 535 print '<td align="right">'.$coms[$i]->total_ttc.'</td>'; 536 print "</tr>\n"; 537 } 538 print '</table>'; 539 } 540 } 541 542 543 /* 544 * Factures associees 545 */ 546 $sql = "SELECT f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.rowid as facid, f.fk_user_author, f.paye"; 547 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_facture = f.rowid AND fp.fk_propal = ".$propal->id; 548 549 $resql = $db->query($sql); 550 if ($resql) 551 { 552 $num_fac_asso = $db->num_rows($resql); 553 $i = 0; $total = 0; 554 print "<br>"; 555 if ($num_fac_asso > 1) print_titre($langs->trans("RelatedBills")); 556 else print_titre($langs->trans("RelatedBill")); 557 print '<table class="noborder" width="100%">'; 558 print "<tr class=\"liste_titre\">"; 559 print '<td>'.$langs->trans("Ref").'</td>'; 560 print '<td align="center">'.$langs->trans("Date").'</td>'; 561 print '<td align="right">'.$langs->trans("Price").'</td>'; 562 print "</tr>\n"; 563 564 $var=True; 565 while ($i < $num_fac_asso) 566 { 567 $objp = $db->fetch_object(); 568 $var=!$var; 569 print "<tr $bc[$var]>"; 570 print '<td><a href="../compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.'</a>'; 571 if ($objp->paye) 572 { 573 print " (<b>payée</b>)"; 574 } 575 print "</td>\n"; 576 print '<td align="center">'.dolibarr_print_date($objp->df).'</td>'; 577 print '<td align="right">'.price($objp->total).'</td>'; 578 print "</tr>"; 579 $total = $total + $objp->total; 580 $i++; 581 } 582 print "<tr class=\"liste_total\"><td align=\"right\" colspan=\"2\">".$langs->trans("TotalHT")."</td><td align=\"right\">".price($total)."</td></tr>\n"; 583 print "</table>"; 584 $db->free(); 585 } 586 587 588 print '</td><td valign="top" width="50%">'; 589 590 591 /* 592 * Liste des actions propres à la propal 593 */ 594 $sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ; 595 $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; 596 $sql .= ' WHERE a.fk_soc = '.$obj->idp.' AND a.propalrowid = '.$propal->id ; 597 $resql = $db->query($sql); 598 if ($resql) 599 { 600 $num = $db->num_rows($resql); 601 if ($num) 602 { 603 print_titre($langs->trans('ActionsOnPropal')); 604 $i = 0; 605 $total = 0; 606 $var=true; 607 608 print '<table class="border" width="100%">'; 609 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>'; 610 print "\n"; 611 612 while ($i < $num) 613 { 614 $objp = $db->fetch_object($resql); 615 $var=!$var; 616 print '<tr '.$bc[$var].'>'; 617 print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$objp->id.'">'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.'</a></td>'; 618 print '<td>'.dolibarr_print_date($objp->da)."</td>\n"; 619 print '<td>'.stripslashes($objp->label).'</td>'; 620 $authoract = new User($db); 621 $authoract->id = $objp->fk_user_author; 622 $authoract->fetch(''); 623 print '<td>'.$authoract->code.'</td>'; 624 print "</tr>\n"; 625 $i++; 626 } 627 print '</table>'; 628 } 629 } 630 else 631 { 632 dolibarr_print_error($db); 633 } 634 635 636 print '</td></tr></table>'; 637 638 639 } else { 640 641 /** 642 * 643 * Mode Liste des propales 644 * 645 */ 646 647 if (! $sortfield) $sortfield="p.datep"; 648 if (! $sortorder) $sortorder="DESC"; 649 if ($page == -1) $page = 0 ; 650 651 $limit = $conf->liste_limit; 652 $offset = $limit * $page ; 653 $pageprev = $page - 1; 654 $pagenext = $page + 1; 655 656 657 $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp"; 658 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p "; 659 $sql.= " WHERE p.fk_soc = s.idp"; 660 if ($socidp) $sql .= " AND s.idp = $socidp"; 661 if ($viewstatut <> '') $sql .= " AND p.fk_statut in ($viewstatut)"; // viewstatut peut etre combinaisons séparé par virgules 662 if ($month > 0) $sql .= " AND date_format(p.datep, '%Y-%m') = '$year-$month'"; 663 if ($year > 0) $sql .= " AND date_format(p.datep, '%Y') = $year"; 664 $sql .= " ORDER BY $sortfield $sortorder, p.rowid DESC "; 665 $sql .= $db->plimit($limit + 1,$offset); 666 667 if ( $db->query($sql) ) 668 { 669 $num = $db->num_rows(); 670 671 $propalstatic=new Propal($db); 672 673 print_barre_liste($langs->trans("Proposals"), $page, "propal.php","&socidp=$socidp",$sortfield,$sortorder,'',$num); 674 675 $i = 0; 676 $var=true; 677 678 print "<table class=\"noborder\" width=\"100%\">"; 679 print '<tr class="liste_titre">'; 680 print_liste_field_titre($langs->trans("Ref"),"propal.php","p.ref","","&year=$year&viewstatut=$viewstatut",'',$sortfield); 681 print_liste_field_titre($langs->trans("Company"),"propal.php","s.nom","&viewstatut=$viewstatut","",'',$sortfield); 682 print_liste_field_titre($langs->trans("Date"),"propal.php","p.datep","&viewstatut=$viewstatut","",'align="right" colspan="2"',$sortfield); 683 print_liste_field_titre($langs->trans("Price"),"propal.php","p.price","&viewstatut=$viewstatut","",'align="right"',$sortfield); 684 print_liste_field_titre($langs->trans("Status"),"propal.php","p.fk_statut","&viewstatut=$viewstatut","",'align="center"',$sortfield); 685 print "</tr>\n"; 686 687 while ($i < min($num, $limit)) 688 { 689 $objp = $db->fetch_object(); 690 691 $var=!$var; 692 print "<tr $bc[$var]>"; 693 694 print '<td><a href="propal.php?propalid='.$objp->propalid.'">'.img_object($langs->trans("ShowPropal"),"propal").' '; 695 print $objp->ref."</a></td>\n"; 696 697 print "<td><a href=\"fiche.php?socid=$objp->idp\">".dolibarr_trunc($objp->nom,44)."</a></td>\n"; 698 699 $now = time(); 700 $lim = 3600 * 24 * 15 ; 701 702 if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) 703 { 704 print "<td><b> > 15 jours</b></td>"; 705 } 706 else 707 { 708 print "<td> </td>"; 709 } 710 711 print "<td align=\"right\">"; 712 $y = strftime("%Y",$objp->dp); 713 $m = strftime("%m",$objp->dp); 714 715 print strftime("%d",$objp->dp)."\n"; 716 print " <a href=\"propal.php?year=$y&month=$m\">"; 717 print strftime("%B",$objp->dp)."</a>\n"; 718 print " <a href=\"propal.php?year=$y\">"; 719 print strftime("%Y",$objp->dp)."</a></td>\n"; 720 721 print "<td align=\"right\">".price($objp->price)."</td>\n"; 722 print "<td align=\"center\">".$propalstatic->LibStatut($objp->fk_statut,0)."</td>\n"; 723 print "</tr>\n"; 724 725 $i++; 726 } 727 728 print "</table>"; 729 $db->free(); 730 } 731 else 732 { 733 dolibarr_print_error($db); 734 } 735 } 736 $db->close(); 737 738 llxFooter('$Date: 2005/11/30 16:44:18 $ - $Revision: 1.63 $'); 739 ?>
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 |
|