[ 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) 2005 Eric Seigne <eric.seigne@ryxeo.com> 5 * Copyright (C) 2005 Régis 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: fiche.php,v 1.112 2005/12/03 20:43:59 eldy Exp $ 22 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/fiche.php,v $ 23 */ 24 25 /** 26 \file htdocs/product/fiche.php 27 \ingroup product 28 \brief Page de la fiche produit 29 \version $Revision: 1.112 $ 30 */ 31 32 require ("./pre.inc.php"); 33 require_once (DOL_DOCUMENT_ROOT."/propal.class.php"); 34 require_once (DOL_DOCUMENT_ROOT."/facture.class.php"); 35 require_once(DOL_DOCUMENT_ROOT."/product.class.php"); 36 37 $langs->load("bills"); 38 39 40 $mesg = ''; 41 42 if (!$user->rights->produit->lire) accessforbidden(); 43 44 $types[0] = $langs->trans("Product"); 45 $types[1] = $langs->trans("Service"); 46 47 48 /* 49 * 50 */ 51 if ($_GET["action"] == 'fastappro') 52 { 53 $product = new Product($db); 54 $product->fetch($_GET["id"]); 55 $result = $product->fastappro($user); 56 Header("Location: fiche.php?id=".$_GET["id"]); 57 exit; 58 } 59 60 61 // Action ajout d'un produit ou service 62 if ($_POST["action"] == 'add' && $user->rights->produit->creer) 63 { 64 $product = new Product($db); 65 66 $product->ref = stripslashes($_POST["ref"]); 67 $product->libelle = stripslashes($_POST["libelle"]); 68 $product->price = stripslashes($_POST["price"]); 69 $product->tva_tx = $_POST["tva_tx"]; 70 $product->type = $_POST["type"]; 71 $product->envente = $_POST["statut"]; 72 $product->description = stripslashes($_POST["desc"]); 73 $product->note = stripslashes($_POST["note"]); 74 $product->duration_value = $_POST["duration_value"]; 75 $product->duration_unit = $_POST["duration_unit"]; 76 $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; 77 78 $e_product = $product; 79 80 $id = $product->create($user); 81 82 if ($id > 0) 83 { 84 Header("Location: fiche.php?id=$id"); 85 exit; 86 } 87 else 88 { 89 if ($id == -3) 90 { 91 $_error = 1; 92 $_GET["action"] = "create"; 93 $_GET["type"] = $_POST["type"]; 94 } 95 } 96 } 97 98 // Action mise a jour d'un produit ou service 99 if ($_POST["action"] == 'update' && 100 $_POST["cancel"] <> $langs->trans("Cancel") && 101 $user->rights->produit->creer) 102 { 103 $product = new Product($db); 104 if ($product->fetch($_POST["id"])) 105 { 106 $product->ref = stripslashes($_POST["ref"]); 107 $product->libelle = stripslashes($_POST["libelle"]); 108 if ( isset( $_POST["price"] ) ) 109 $product->price = stripslashes($_POST["price"]); 110 $product->tva_tx = $_POST["tva_tx"]; 111 $product->description = stripslashes($_POST["desc"]); 112 $product->note = stripslashes($_POST["note"]); 113 $product->envente = $_POST["statut"]; 114 $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; 115 $product->duration_value = $_POST["duration_value"]; 116 $product->duration_unit = $_POST["duration_unit"]; 117 118 if ($product->check()) 119 { 120 if ($product->update($product->id, $user) > 0) 121 { 122 $_GET["action"] = ''; 123 $_GET["id"] = $_POST["id"]; 124 } 125 else 126 { 127 $_GET["action"] = 're-edit'; 128 $_GET["id"] = $_POST["id"]; 129 $mesg = $product->mesg_error; 130 } 131 } 132 else 133 { 134 $_GET["action"] = 're-edit'; 135 $_GET["id"] = $_POST["id"]; 136 $mesg = $langs->trans("ErrorProductBadRefOrLabel"); 137 } 138 } 139 } 140 141 // clone d'un produit 142 if ($_GET["action"] == 'clone' && $user->rights->produit->creer) 143 { 144 $db->begin(); 145 146 $product = new Product($db); 147 $originalId = $_GET["id"]; 148 if ($product->fetch($_GET["id"]) > 0) 149 { 150 $product->ref = "Clone ".$product->ref; 151 $product->envente = 0; 152 $product->id = null; 153 154 if ($product->check()) 155 { 156 $id = $product->create($user); 157 if ($id > 0) 158 { 159 // $product->clone_fournisseurs($originalId, $id); 160 161 $db->commit(); 162 163 Header("Location: fiche.php?id=$id"); 164 $db->close(); 165 exit; 166 } 167 else if ($id == -3) 168 { 169 $db->rollback(); 170 171 $_error = 1; 172 $_GET["action"] = ""; 173 dolibarr_print_error($product->db); 174 } 175 else 176 { 177 $db->rollback(); 178 179 dolibarr_print_error($product->db); 180 } 181 } 182 } 183 else 184 { 185 $db->rollback(); 186 187 dolibarr_print_error($product->db); 188 } 189 } 190 191 if ($_POST["action"] == 'addinpropal') 192 { 193 $propal = New Propal($db); 194 $propal->fetch($_POST["propalid"]); 195 196 $result = $propal->insert_product($_GET["id"], $_POST["qty"], $_POST["remise_percent"]); 197 if ( $result < 0) 198 { 199 $mesg = $langs->trans("ErrorUnknown").": $result"; 200 } 201 202 Header("Location: ../comm/propal.php?propalid=".$propal->id); 203 exit; 204 } 205 206 /* 207 * Ajout du produit dans une facture 208 */ 209 if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer) 210 { 211 $product = new Product($db); 212 $result = $product->fetch($_GET["id"]); 213 214 $facture = New Facture($db); 215 216 $facture->fetch($_POST["factureid"]); 217 218 $facture->addline($_POST["factureid"], 219 addslashes($product->libelle), 220 $product->price, 221 $_POST["qty"], 222 $product->tva_tx, 223 $product->id, 224 $_POST["remise_percent"]); 225 226 Header("Location: ../compta/facture.php?facid=".$facture->id); 227 exit; 228 } 229 230 if ($_POST["action"] == 'add_fourn' && $_POST["cancel"] <> $langs->trans("Cancel")) 231 { 232 233 $product = new Product($db); 234 if( $product->fetch($_GET["id"]) ) 235 { 236 if ($product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]) > 0) 237 { 238 $action = ''; 239 $mesg = $langs->trans("SupplierAdded"); 240 } 241 else 242 { 243 $action = ''; 244 } 245 } 246 } 247 248 if ($_POST["cancel"] == $langs->trans("Cancel")) 249 { 250 $action = ''; 251 Header("Location: fiche.php?id=".$_POST["id"]); 252 exit; 253 } 254 255 256 257 llxHeader("","",$langs->trans("ProductServiceCard")); 258 $html = new Form($db); 259 260 261 /* 262 * Action création du produit 263 */ 264 if ($_GET["action"] == 'create' && $user->rights->produit->creer) 265 { 266 $product = new Product($db); 267 if ($_error == 1) 268 { 269 $product = $e_product; 270 } 271 272 print '<form action="fiche.php" method="post">'; 273 print '<input type="hidden" name="action" value="add">'; 274 print '<input type="hidden" name="type" value="'.$_GET["type"].'">'."\n"; 275 276 if ($_GET["type"]==0) { $title=$langs->trans("NewProduct"); } 277 if ($_GET["type"]==1) { $title=$langs->trans("NewService"); } 278 print_fiche_titre($title); 279 280 print '<table class="border" width="100%">'; 281 print '<tr>'; 282 print '<td>'.$langs->trans("Ref").'</td><td><input name="ref" size="20" value="'.$product->ref.'">'; 283 if ($_error == 1) 284 { 285 print $langs->trans("RefAlreadyExists"); 286 } 287 print '</td></tr>'; 288 print '<tr><td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>'; 289 print '<tr><td>'.$langs->trans("SellingPrice").'</td><td><input name="price" size="10" value="'.$product->price.'"></td></tr>'; 290 291 $langs->load("bills"); 292 print '<tr><td>'.$langs->trans("VATRate").'</td><td>'; 293 print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,''); 294 print '</td></tr>'; 295 296 print '<tr><td>'.$langs->trans("Status").'</td><td>'; 297 print '<select class="flat" name="statut">'; 298 print '<option value="1">'.$langs->trans("OnSell").'</option>'; 299 print '<option value="0" selected="true">'.$langs->trans("NotOnSell").'</option>'; 300 print '</td></tr>'; 301 302 if ($_GET["type"] == 0 && $conf->stick->enabled) 303 { 304 print "<tr>".'<td>Seuil stock</td><td colspan="2">'; 305 print '<input name="seuil_stock_alerte" size="4" value="0">'; 306 print '</td></tr>'; 307 } 308 else 309 { 310 print '<input name="seuil_stock_alerte" type="hidden" value="0">'; 311 } 312 313 // Description 314 print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'; 315 print '<textarea name="desc" rows="4" cols="50">'; 316 print "</textarea></td></tr>"; 317 318 if ($_GET["type"] == 1) 319 { 320 print '<tr><td>'.$langs->trans("Duration").'</td><td><input name="duration_value" size="6" maxlength="5" value="'.$product->duree.'"> '; 321 print '<input name="duration_unit" type="radio" value="d">'.$langs->trans("Day").' '; 322 print '<input name="duration_unit" type="radio" value="w">'.$langs->trans("Week").' '; 323 print '<input name="duration_unit" type="radio" value="m">'.$langs->trans("Month").' '; 324 print '<input name="duration_unit" type="radio" value="y">'.$langs->trans("Year").' '; 325 print '</td></tr>'; 326 } 327 328 // Note 329 print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>'; 330 print '<textarea name="note" rows="8" cols="50">'; 331 print "</textarea></td></tr>"; 332 333 print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>'; 334 print '</table>'; 335 print '</form>'; 336 } 337 338 339 /* 340 * Fiche produit 341 */ 342 if ($_GET["id"] || $_GET["ref"]) 343 { 344 345 if ($_GET["action"] <> 're-edit') 346 { 347 $product = new Product($db); 348 if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); 349 if ($_GET["id"]) $result = $product->fetch($_GET["id"]); 350 } 351 352 if ( $result ) 353 { 354 355 if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') 356 { 357 /* 358 * En mode visu 359 */ 360 361 $h=0; 362 363 $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; 364 $head[$h][1] = $langs->trans("Card"); 365 $hselected = $h; 366 $h++; 367 368 $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; 369 $head[$h][1] = $langs->trans("Price"); 370 $h++; 371 372 if($product->type == 0) 373 { 374 if ($user->rights->barcode->lire) 375 { 376 if ($conf->barcode->enabled) 377 { 378 $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; 379 $head[$h][1] = $langs->trans("BarCode"); 380 $h++; 381 } 382 } 383 } 384 385 $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; 386 $head[$h][1] = $langs->trans("Photos"); 387 $h++; 388 389 if($product->type == 0) 390 { 391 if ($conf->stock->enabled) 392 { 393 $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; 394 $head[$h][1] = $langs->trans("Stock"); 395 $h++; 396 } 397 } 398 399 if ($conf->fournisseur->enabled) 400 { 401 $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; 402 $head[$h][1] = $langs->trans("Suppliers"); 403 $h++; 404 } 405 406 $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; 407 $head[$h][1] = $langs->trans('Statistics'); 408 $h++; 409 410 //erics: pour créer des produits composés de x 'sous' produits 411 /* 412 $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id; 413 $head[$h][1] = $langs->trans('Packs'); 414 $h++; 415 */ 416 417 $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; 418 $head[$h][1] = $langs->trans('Referers'); 419 $h++; 420 421 $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id; 422 $head[$h][1] = $langs->trans('Documents'); 423 $h++; 424 425 426 $titre=$langs->trans("CardProduct".$product->type); 427 dolibarr_fiche_head($head, $hselected, $titre); 428 429 430 print($mesg); 431 432 print '<table class="border" width="100%">'; 433 434 print "<tr>"; 435 436 $nblignes=6; 437 if ($product->type == 0 && $conf->stock->enabled) $nblignes++; 438 if ($product->type == 1) $nblignes++; 439 440 // Reference 441 print '<td width="15%">'.$langs->trans("Ref").'</td><td>'; 442 $product->load_previous_next_ref(); 443 $previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':''; 444 $next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':''; 445 if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">'; 446 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>'; 447 if ($previous_ref || $next_ref) print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table>'; 448 print '</td>'; 449 450 if ($product->is_photo_available($conf->produit->dir_output)) 451 { 452 // Photo 453 print '<td valign="middle" align="center" rowspan="'.$nblignes.'">'; 454 $nbphoto=$product->show_photo($conf->produit->dir_output,1); 455 print '</td>'; 456 } 457 458 print '</tr>'; 459 460 // Libelle 461 print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>'; 462 print '</tr>'; 463 464 // Prix 465 print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>'; 466 print '</tr>'; 467 468 // Statut 469 print '<tr><td>'.$langs->trans("Status").'</td><td>'; 470 if ($product->envente) print $langs->trans("OnSell"); 471 else print $langs->trans("NotOnSell"); 472 print '</td></tr>'; 473 474 // TVA 475 $langs->load("bills"); 476 print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.$product->tva_tx.' %</td></tr>'; 477 478 // Stock 479 if ($product->type == 0 && $conf->stock->enabled) 480 { 481 print '<tr><td><a href="stock/product.php?id='.$product->id.'">'.$langs->trans("Stock").'</a></td>'; 482 if ($product->no_stock) 483 { 484 print "<td>Pas de définition de stock pour ce produit"; 485 } 486 else 487 { 488 if ($product->stock_reel <= $product->seuil_stock_alerte) 489 { 490 print '<td class="alerte">'.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte; 491 } 492 else 493 { 494 print "<td>".$product->stock_reel; 495 } 496 } 497 print '</td></tr>'; 498 } 499 500 // Description 501 print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($product->description).'</td></tr>'; 502 503 // Durée 504 if ($product->type == 1) 505 { 506 print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$product->duration_value.' '; 507 508 if ($product->duration_value > 1) 509 { 510 $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); 511 } 512 else { 513 $dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); 514 } 515 print $langs->trans($dur[$product->duration_unit])." "; 516 517 print '</td></tr>'; 518 } 519 520 // Note 521 print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>'.nl2br($product->note).'</td></tr>'; 522 523 print "</table>\n"; 524 525 print "</div>\n"; 526 } 527 } 528 529 /* 530 * Fiche en mode edition 531 */ 532 if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && $user->rights->produit->creer) 533 { 534 535 print_fiche_titre($langs->trans('Edit').' '.$types[$product->type].' : '.$product->ref, ""); 536 537 if ($mesg) { 538 print '<br><div class="error">'.$mesg.'</div><br>'; 539 } 540 541 print "<form action=\"fiche.php\" method=\"post\">\n"; 542 print '<input type="hidden" name="action" value="update">'; 543 print '<input type="hidden" name="id" value="'.$product->id.'">'; 544 print '<table class="border" width="100%">'; 545 print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" size="20" value="'.$product->ref.'"></td></tr>'; 546 print '<td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>'; 547 548 $langs->load("bills"); 549 print '<tr><td>'.$langs->trans("VATRate").'</td><td colspan="2">'; 550 print $html->select_tva("tva_tx", $product->tva_tx, $mysoc, ''); 551 print '</td></tr>'; 552 print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'; 553 print '<select class="flat" name="statut">'; 554 if ($product->envente) 555 { 556 print '<option value="1" selected="true">'.$langs->trans("OnSell").'</option>'; 557 print '<option value="0">'.$langs->trans("NotOnSell").'</option>'; 558 } 559 else 560 { 561 print '<option value="1">'.$langs->trans("OnSell").'</option>'; 562 print '<option value="0" selected="true">'.$langs->trans("NotOnSell").'</option>'; 563 } 564 print '</td></tr>'; 565 if ($product->type == 0 && $conf->stock->enabled) 566 { 567 print "<tr>".'<td>Seuil stock</td><td colspan="2">'; 568 print '<input name="seuil_stock_alerte" size="4" value="'.$product->seuil_stock_alerte.'">'; 569 print '</td></tr>'; 570 } 571 else 572 { 573 print '<input name="seuil_stock_alerte" type="hidden" value="0">'; 574 } 575 576 // Description 577 print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">'; 578 print '<textarea name="desc" rows="4" cols="50">'; 579 print $product->description; 580 print "</textarea></td></tr>"; 581 582 if ($product->type == 1) 583 { 584 print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="2"><input name="duration_value" size="3" maxlength="5" value="'.$product->duration_value.'">'; 585 print ' '; 586 print '<input name="duration_unit" type="radio" value="d"'.($product->duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); 587 print ' '; 588 print '<input name="duration_unit" type="radio" value="w"'.($product->duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); 589 print ' '; 590 print '<input name="duration_unit" type="radio" value="m"'.($product->duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); 591 print ' '; 592 print '<input name="duration_unit" type="radio" value="y"'.($product->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); 593 594 print '</td></tr>'; 595 } 596 597 // Note 598 print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="2">'; 599 print '<textarea name="note" rows="8" cols="50">'; 600 print $product->note; 601 print "</textarea></td></tr>"; 602 603 print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> '; 604 print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; 605 print '</table>'; 606 print '</form>'; 607 } 608 } 609 610 611 /* ************************************************************************** */ 612 /* */ 613 /* Barre d'action */ 614 /* */ 615 /* ************************************************************************** */ 616 617 print "\n<div class=\"tabsAction\">\n"; 618 619 if ($_GET["action"] == '') 620 { 621 if ($product->type == 0 && $user->rights->produit->commander && $num_fournisseur == 1) 622 { 623 print '<a class="tabAction" href="fiche.php?action=fastappro&id='.$product->id.'">'; 624 print $langs->trans("Order").'</a>'; 625 } 626 627 if ( $user->rights->produit->creer) 628 { 629 print '<a class="tabAction" href="fiche.php?action=edit&id='.$product->id.'">'.$langs->trans("Edit").'</a>'; 630 631 print '<a class="tabAction" href="fiche.php?action=clone&id='.$product->id.'">'.$langs->trans("CreateCopy").'</a>'; 632 } 633 634 } 635 636 print "\n</div><br>\n"; 637 638 639 if ($_GET["id"] && $_GET["action"] == '' && $product->envente) 640 { 641 $propal = New Propal($db); 642 643 print '<table width="100%" class="noborder">'; 644 645 // Propals 646 if($user->rights->propale->creer) 647 { 648 $langs->load("propal"); 649 650 print '<tr><td width="50%" valign="top">'; 651 print_titre($langs->trans("AddToMyProposals")) . '</td>'; 652 print '<td width="50%" valign="top">'; 653 print_titre($langs->trans("AddToOtherProposals")) . '</td>'; 654 print '</tr>'; 655 656 // Liste de "Mes propals" 657 print '<tr><td width="50%" valign="top">'; 658 $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.ref,".$db->pdate("p.datep")." as dp"; 659 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; 660 $sql .=" WHERE p.fk_soc = s.idp AND p.fk_statut = 0 AND p.fk_user_author = ".$user->id; 661 $sql .= " ORDER BY p.datec DESC, tms DESC"; 662 663 $result=$db->query($sql); 664 if ($result) 665 { 666 $num = $db->num_rows($result); 667 if ($num) { 668 $i = 0; 669 print '<table class="noborder" width="100%">'; 670 $var=true; 671 while ($i < $num) 672 { 673 $objp = $db->fetch_object($result); 674 $var=!$var; 675 print '<form method="POST" action="fiche.php?id='.$product->id.'">'; 676 print "<tr $bc[$var]>"; 677 print "<td nowrap><a href=\"../comm/propal.php?propalid=$objp->propalid\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."</a></td>\n"; 678 print "<td><a href=\"../comm/fiche.php?socid=$objp->idp\">".dolibarr_trunc($objp->nom,18)."</a></td>\n"; 679 print "<td>". strftime("%d %b",$objp->dp)."</td>\n"; 680 print '<input type="hidden" name="action" value="addinpropal">'; 681 print '<td><input type="hidden" name="propalid" value="'.$objp->propalid.'">'; 682 print '<input type="text" class="flat" name="qty" size="1" value="1"></td><td nowrap>'.$langs->trans("Discount"); 683 print '<input type="text" class="flat" name="remise_percent" size="1" value="0">%'; 684 print " ".$product->stock_proposition; 685 print '</td><td align="right">'; 686 print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; 687 print '</td>'; 688 print '</tr>'; 689 print '</form>'; 690 $i++; 691 } 692 print "</table>"; 693 } 694 else { 695 print $langs->trans("NoOpenedPropals"); 696 } 697 $db->free($result); 698 } 699 700 print '</td>'; 701 702 // Liste de "Other propals" 703 print '<td width="50%" valign="top">'; 704 705 $otherprop = $propal->liste_array(1, ' <> s'.$user->id); 706 if (is_array($otherprop) && sizeof($otherprop)) 707 { 708 $var=false; 709 print '<form method="POST" action="fiche.php?id='.$product->id.'">'; 710 print '<table class="noborder" width="100%">'.$otherprop; 711 print '<input type="hidden" name="action" value="addinpropal">'; 712 print '<tr '.$bc[$var].'><td colspan="3">'.$langs->trans("OtherPropals").'</td><td>'; 713 $html->select_array("propalid", $otherprop); 714 print '</td></tr>'; 715 print '<tr '.$bc[$var].'><td>'. strftime("%d %b",$objp->dp)."</td><td nowrap>\n"; 716 print '<input type="text" class="flat" name="qty" size="1" value="1"></td><td nowrap>'.$langs->trans("Discount"); 717 print '<input type="text" class="flat" name="remise_percent" size="1" value="0">%'; 718 print '</td><td align="right">'; 719 print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; 720 print '</td></tr>'; 721 print '</table>'; 722 print '</form>'; 723 } 724 else { 725 print $langs->trans("NoOtherOpenedPropals"); 726 } 727 print '</td>'; 728 729 print '</tr>'; 730 } 731 732 // Factures 733 if($user->rights->facture->creer) 734 { 735 $langs->load("bills"); 736 737 print '<tr><td width="50%" valign="top">'; 738 print_titre($langs->trans("AddToMyBills")); 739 print '</td><td width="50%" valign="top">'; 740 print_titre($langs->trans("AddToOtherBills")); 741 print '</td></tr>'; 742 743 // Liste de Mes factures 744 print '<tr><td width="50%" valign="top">'; 745 $sql = "SELECT s.nom, s.idp, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df"; 746 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; 747 $sql .=" WHERE f.fk_soc = s.idp AND f.fk_statut = 0 AND f.fk_user_author = ".$user->id; 748 $sql .= " ORDER BY f.datec DESC, f.rowid DESC"; 749 750 $result=$db->query($sql); 751 if ($result) 752 { 753 $num = $db->num_rows($result); 754 if ($num) { 755 $i = 0; 756 print '<table class="noborder" width="100%">'; 757 $var=true; 758 while ($i < $num) 759 { 760 $objp = $db->fetch_object($result); 761 762 $var=!$var; 763 print '<form method="POST" action="fiche.php?id='.$product->id.'">'; 764 print "<tr $bc[$var]>"; 765 print "<td nowrap><a href=\"../compta/facture.php?facid=$objp->factureid\">".img_object($langs->trans("ShowBills"),"bill")." ".$objp->facnumber."</a></td>\n"; 766 print "<td><a href=\"../comm/fiche.php?socid=$objp->idp\">".dolibarr_trunc($objp->nom,18)."</a></td>\n"; 767 print "<td>". strftime("%d %b",$objp->df)."</td>\n"; 768 print '<input type="hidden" name="action" value="addinfacture">'; 769 print '<td><input type="hidden" name="factureid" value="'.$objp->factureid.'">'; 770 print '<input type="text" class="flat" name="qty" size="1" value="1"></td><td nowrap>'.$langs->trans("Discount"); 771 print '<input type="text" class="flat" name="remise_percent" size="1" value="0">%'; 772 print '</td><td align="right">'; 773 print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; 774 print '</td>'; 775 print '</tr>'; 776 print '</form>'; 777 $i++; 778 } 779 print "</table>"; 780 } 781 else { 782 print $langs->trans("NoDraftBills"); 783 } 784 $db->free($result); 785 } 786 else 787 { 788 dolibarr_print_error($db); 789 } 790 791 print '</td><td width="50%" valign="top">'; 792 793 // Liste de Autres factures 794 $var=true; 795 796 $sql = "SELECT s.nom, s.idp, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df"; 797 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; 798 $sql .=" WHERE f.fk_soc = s.idp AND f.fk_statut = 0 AND f.fk_user_author <> ".$user->id; 799 $sql .= " ORDER BY f.datec DESC, f.rowid DESC"; 800 801 $result=$db->query($sql); 802 if ($result) 803 { 804 $num = $db->num_rows($result); 805 if ($num) { 806 $i = 0; 807 print '<table class="noborder" width="100%">'; 808 $var=true; 809 while ($i < $num) 810 { 811 $objp = $db->fetch_object($result); 812 813 $var=!$var; 814 print '<form method="POST" action="fiche.php?id='.$product->id.'">'; 815 print "<tr $bc[$var]>"; 816 print "<td><a href=\"../compta/facture.php?facid=$objp->factureid\">$objp->facnumber</a></td>\n"; 817 print "<td><a href=\"../comm/fiche.php?socid=$objp->idp\">$objp->nom</a></td>\n"; 818 print "<td>". strftime("%d %b",$objp->df)."</td>\n"; 819 print '<input type="hidden" name="action" value="addinfacture">'; 820 print '<td><input type="hidden" name="factureid" value="'.$objp->factureid.'">'; 821 print '<input type="text" class="flat" name="qty" size="1" value="1"></td><td nowrap>'.$langs->trans("Discount"); 822 print '<input type="text" class="flat" name="remise_percent" size="1" value="0">%'; 823 print '</td><td align="right">'; 824 print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; 825 print '</td>'; 826 print '</tr>'; 827 print '</form>'; 828 $i++; 829 } 830 print "</table>"; 831 } 832 else { 833 print $langs->trans("NoOtherDraftBills"); 834 } 835 $db->free($result); 836 } 837 else 838 { 839 dolibarr_print_error($db); 840 } 841 842 print '</td></tr>'; 843 } 844 845 print '</table>'; 846 } 847 848 849 $db->close(); 850 851 llxFooter('$Date: 2005/12/03 20:43:59 $ - $Revision: 1.112 $'); 852 ?>
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 |
![]() |