[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/fourn/facture/ -> fiche.php (source)

   1  <?php
   2  /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   * Copyright (C) 2004      Christophe Combelles <ccomb@free.fr>
   5   * Copyright (C) 2005      Marc Barilley / Ocebo <marc@ocebo.fr>
   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.79 2005/11/23 00:43:19 eldy Exp $
  22   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/fourn/facture/fiche.php,v $
  23   */
  24  
  25  /**
  26      \file       htdocs/fourn/facture/fiche.php
  27      \ingroup    facture
  28      \brief      Page des la fiche facture fournisseur
  29      \version    $Revision: 1.79 $
  30  */
  31  
  32  require ('./pre.inc.php');
  33  require ('./paiementfourn.class.php');
  34  
  35  if (!$user->rights->fournisseur->facture->lire)
  36      accessforbidden();
  37  
  38  $langs->load('bills');
  39  $langs->load('suppliers');
  40  $langs->load('companies');
  41  
  42  // Sécurité accés client
  43  if ($user->societe_id > 0)
  44  {
  45      $action = '';
  46      $socidp = $user->societe_id;
  47  }
  48  
  49  
  50  $html = new Form($db);
  51  $mesg='';
  52  $action=isset($_GET['action'])?$_GET['action']:$_POST['action'];
  53  
  54  if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider)
  55  {
  56      $facturefourn=new FactureFournisseur($db);
  57      $facturefourn->fetch($_GET['facid']);
  58      $facturefourn->set_valid($user);
  59      Header('Location: fiche.php?facid='.$_GET['facid']);
  60      exit;
  61  }
  62  
  63  
  64  if ($_GET['action'] == 'payed')
  65  {
  66      $facturefourn=new FactureFournisseur($db);
  67      $facturefourn->fetch($_GET['facid']);
  68      $facturefourn->set_payed($user);
  69  }
  70  
  71  if($_GET['action'] == 'deletepaiement')
  72  {
  73      $facfou = new FactureFournisseur($db);
  74      $facfou->fetch($_GET['facid']);
  75      if ($facfou->statut == 1 && $facfou->paye == 0 && $user->societe_id == 0)
  76      {
  77          $paiementfourn = new PaiementFourn($db);
  78          $paiementfourn->fetch($_GET['paiement_id']);
  79          $paiementfourn->delete();
  80      }
  81  }
  82  
  83  if ($_POST['action'] == 'modif_libelle')
  84  {
  85      $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn set libelle = \''.$form_libelle.'\' WHERE rowid = '.$_GET['facid'];
  86      $result = $db->query( $sql);
  87  }
  88  
  89  
  90  if ($_POST['action'] == 'update')
  91  {
  92      $datefacture = $db->idate(mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']));
  93      $date_echeance = $db->idate(mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']));
  94  
  95      $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn set ';
  96      $sql .= " facnumber='".trim($_POST['facnumber'])."'";
  97      $sql .= ", libelle='".trim($_POST['libelle'])."'";
  98      $sql .= ", note='".$_POST['note']."'";
  99      $sql .= ", datef = '$datefacture'";
 100      $sql .= ", date_lim_reglement = '$date_echeance'";
 101      $sql .= ' WHERE rowid = '.$_GET['facid'].' ;';
 102      $result = $db->query( $sql);
 103  }
 104  /*
 105   * Action création
 106   */
 107  if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer)
 108  {
 109      if ($_POST['facnumber'])
 110      {
 111          $datefacture = mktime(12,0,0,
 112              $_POST['remonth'],
 113              $_POST['reday'],
 114              $_POST['reyear']);
 115  
 116          $tva = 0;
 117          $amo = price2num($_POST['amount']);
 118          $tva = (price2num($_POST['tva_taux']) * $amo) / 100 ;
 119          $remise = 0;
 120          $total = $tva + $amo;
 121  
 122          $db->begin();
 123  
 124          // Creation facture
 125          $facfou = new FactureFournisseur($db);
 126  
 127          $facfou->ref           = $_POST['facnumber'];
 128          $facfou->socidp        = $_POST['socidp'];
 129          $facfou->libelle       = $_POST['libelle'];
 130          $facfou->date          = $datefacture;
 131          $facfou->date_echeance = mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']);
 132          $facfou->note          = $_POST['note'];
 133  
 134          $facid = $facfou->create($user);
 135  
 136          // Ajout des lignes de factures
 137          if ($facid > 0)
 138          {
 139              for ($i = 1 ; $i < 9 ; $i++)
 140              {
 141                  $label = $_POST['label'.$i];
 142                  $amount = price2num($_POST['amount'.$i]);
 143                  $amountttc = price2num($_POST['amountttc'.$i]);
 144                  $tauxtva = price2num($_POST['tauxtva'.$i]);
 145                  $qty = $_POST['qty'.$i];
 146  
 147                  if (strlen($label) > 0 && !empty($amount))
 148                  {
 149                      $atleastoneline=1;
 150                      $ret=$facfou->addline($label, $amount, $tauxtva, $qty, 1);
 151                      if ($ret < 0) $nberror++;
 152                  }
 153                  else if (strlen($label) > 0 && empty($amount))
 154                  {
 155                      $ht = $amountttc / (1 + ($tauxtva / 100));
 156                      $atleastoneline=1;
 157                      $ret=$facfou->addline($label, $ht, $tauxtva, $qty, 1);
 158                      if ($ret < 0) $nberror++;
 159                  }
 160              }
 161              if ($nberror)
 162              {
 163                  $db->rollback();
 164                  $mesg='<div class="error">'.$facfou->error.'</div>';
 165                  $_GET['action']='create';
 166              }
 167              else
 168              {
 169                  $db->commit();
 170                  header('Location: fiche.php?facid='.$facid);
 171                  exit;
 172              }
 173          }
 174          else
 175          {
 176              $db->rollback();
 177              $mesg='<div class="error">'.$facfou->error.'</div>';
 178              $_GET['action']='create';
 179          }
 180      }
 181      else
 182      {
 183          $mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->trans('Ref')).'</div>';
 184          $_GET['action']='create';
 185      }
 186  }
 187  
 188  if ($_GET['action'] == 'del_ligne')
 189  {
 190      $facfou = new FactureFournisseur($db,'',$_GET['facid']);
 191      $facfou->deleteline($_GET['ligne_id']);
 192      $_GET['action'] = 'edit';
 193  }
 194  
 195  if ($_GET['action'] == 'add_ligne')
 196  {
 197      $facfou = new FactureFournisseur($db, '', $_GET['facid']);
 198      $tauxtva = price2num($_POST['tauxtva']);
 199      if (strlen($_POST['label']) > 0 && !empty($_POST['amount']))
 200      {
 201          $ht = price2num($_POST['amount']);
 202          $facfou->addline($_POST['label'], $ht, $tauxtva, $_POST['qty']);
 203      }
 204      else
 205      {
 206          $ttc = price2num($_POST['amountttc']);
 207          $ht = $ttc / (1 + ($tauxtva / 100));
 208          $facfou->addline($_POST['label'], $ht, $tauxtva, $_POST['qty']);
 209      }
 210      $_GET['action'] = 'edit';
 211  }
 212  
 213  
 214  
 215  /*********************************************************************
 216  *
 217  * Mode creation
 218  *
 219  **********************************************************************/
 220  
 221  if ($_GET['action'] == 'create' or $_GET['action'] == 'copy')
 222  {
 223      llxHeader();
 224  
 225      print_titre($langs->trans('NewBill'));
 226  
 227      if ($mesg) { print $mesg.'<br>'; }
 228  
 229      if ($_GET['action'] == 'copy')
 230      {
 231          $fac_ori = new FactureFournisseur($db);
 232          $fac_ori->fetch($_GET['facid']);
 233      }
 234  
 235      print '<form action="fiche.php" method="post">';
 236      print '<input type="hidden" name="action" value="add">';
 237      print '<table class="border" width="100%">';
 238      print '<tr><td>'.$langs->trans('Company').'</td>';
 239  
 240      print '<td>';
 241      $html->select_societes(empty($_GET['socid'])?'':$_GET['socid'],'socidp','s.fournisseur = 1');
 242      print '</td>';
 243      print '<td width="50%">'.$langs->trans('Comments').'</td></tr>';
 244  
 245      print '<tr><td>'.$langs->trans('Ref').'</td><td><input name="facnumber" type="text"></td>';
 246  
 247      print '<td width="50%" rowspan="4" valign="top"><textarea name="note" wrap="soft" cols="30" rows="6"></textarea></td></tr>';
 248      if ($_GET['action'] == 'copy')
 249      {
 250          print '<tr><td>'.$langs->trans('Label').'</td><td><input size="30" name="libelle" value="'.$fac_ori->libelle.'" type="text"></td></tr>';
 251      }
 252      else
 253      {
 254          print '<tr><td>'.$langs->trans('Label').'</td><td><input size="30" name="libelle" type="text"></td></tr>';
 255      }
 256      print '<tr><td>'.$langs->trans('Date').'</td><td>';
 257      $html->select_date();
 258      print '</td></tr>';
 259  
 260      print '<tr><td>'.$langs->trans('DateEcheance').'</td><td>';
 261      $html->select_date('','ech');
 262      print '</td></tr>';
 263  
 264      print '</table><br>';
 265  
 266      print '<table class="border" width="100%">';
 267      print '<tr class="liste_titre">';
 268      print '<td>&nbsp;</td><td>'.$langs->trans('Label').'</td>';
 269      print '<td align="center">'.$langs->trans('PriceUHT').'</td>';
 270      print '<td align="center">'.$langs->trans('Qty').'</td>';
 271      print '<td align="center">'.$langs->trans('VATRate').'</td>';
 272      print '<td align="center">'.$langs->trans('PriceUTTC').'</td>';
 273      print '</tr>';
 274  
 275      for ($i = 1 ; $i < 9 ; $i++)
 276      {
 277          if ($_GET['action'] == 'copy')
 278          {
 279              $value_label = $fac_ori->lignes[$i-1][0];
 280              $value_pu = $fac_ori->lignes[$i-1][1];
 281              $value_qty = $fac_ori->lignes[$i-1][3];
 282          }
 283          else
 284          {
 285              $value_qty = '1';
 286          }
 287          print '<tr><td>'.$i.'</td>';
 288          print '<td><input size="50" name="label'.$i.'" value="'.$value_label.'" type="text"></td>';
 289          print '<td align="center"><input type="text" size="8" name="amount'.$i.'" value="'.$value_pu.'"></td>';
 290          print '<td align="center"><input type="text" size="3" name="qty'.$i.'" value="'.$value_qty.'"></td>';
 291          print '<td align="center">';
 292          $html->select_tva('tauxtva'.$i,'', '',$mysoc);
 293          print '</td>';
 294          print '<td align="center"><input type="text" size="8" name="amountttc'.$i.'" value=""></td></tr>';
 295      }
 296  
 297      print '</table>';
 298      print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"></center>';
 299      print '</form>';
 300  }
 301  else
 302  {
 303      if ($_GET['facid'] > 0)
 304      {
 305          /* *************************************************************************** */
 306          /*                                                                             */
 307          /* Fiche en mode visu ou edition                                               */
 308          /*                                                                             */
 309          /* *************************************************************************** */
 310  
 311          $fac = new FactureFournisseur($db);
 312          $fac->fetch($_GET['facid']);
 313  
 314          $societe = new Fournisseur($db);
 315  
 316          if ( $societe->fetch($fac->socidp) )
 317          {
 318              $addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$fac->socidp;
 319              $addons[0][1] = $societe->nom;
 320          }
 321          llxHeader('','', $addons);
 322  
 323          if ($mesg) { print '<br>'.$mesg.'<br>'; }
 324  
 325          if ($_GET['action'] == 'edit')
 326          {
 327  
 328              print_titre($langs->trans('Bill').': '.$fac->ref);
 329  
 330              print '<form action="fiche.php?facid='.$fac->id.'" method="post">';
 331              print '<input type="hidden" name="action" value="update">';
 332  
 333              print '<table class="border" width="100%">';
 334              print '<tr><td>'.$langs->trans('Company').'</td>';
 335  
 336              print '<td>'.stripslashes($fac->socnom).'</td>';
 337              print '<td width="50%" valign="top">'.$langs->trans('Comments').'</tr>';
 338  
 339              print '<tr><td valign="top">'.$langs->trans('Ref').'</td><td valign="top">';
 340              print '<input name="facnumber" type="text" value="'.$fac->ref.'"></td>';
 341  
 342              print '<td rowspan="8" valign="top">';
 343              print '<textarea name="note" wrap="soft" cols="60" rows="10">';
 344              print stripslashes($fac->note);
 345              print '</textarea></td></tr>';
 346  
 347              print '<tr><td valign="top">'.$langs->trans('Label').'</td><td>';
 348              print '<input size="30" name="libelle" type="text" value="'.stripslashes($fac->libelle).'"></td></tr>';
 349  
 350              print '<tr><td>'.$langs->trans('AmountHT').' / '.$langs->trans('AmountTTC').'</td>';
 351              print '<td>'.price($fac->total_ht).' / '.price($fac->total_ttc).'</td></tr>';
 352  
 353              print '<tr><td>'.$langs->trans('DateBill').'</td><td>';
 354              $html->select_date($fac->datep);
 355              print '</td></tr>';
 356  
 357              print '<tr><td>'.$langs->trans('DateEcheance').'</td><td>';
 358              $html->select_date($fac->date_echeance,'ech');
 359              print '</td></tr>';
 360  
 361              $authorfullname='&nbsp;';
 362              if ($fac->author)
 363              {
 364                  $author = new User($db, $fac->author);
 365                  $author->fetch('');
 366                  $authorfullname=$author->fullname;
 367              }
 368              print '<tr><td>'.$langs->trans('Author').'</td><td>'.$authorfullname.'</td></tr>';
 369              print '<tr><td>'.$langs->trans('Status').'</td><td>'.$fac->LibStatut($fac->paye,$fac->statut).'</td></tr>';
 370              print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'"></td></tr>';
 371              print '</table>';
 372              print '</form>';
 373  
 374              /*
 375               * Lignes
 376               *
 377               */
 378              print '<br>';
 379              $var=true;
 380  
 381              print '<form action="fiche.php?facid='.$fac->id.'&amp;action=add_ligne" method="post">';
 382              print '<table class="noborder" width="100%">';
 383              print '<tr class="liste_titre"><td>'.$langs->trans('Label').'</td>';
 384              print '<td align="center">'.$langs->trans('PriceUHT').'</td>';
 385              print '<td align="center">'.$langs->trans('PriceUTTC').'</td>';
 386              print '<td align="center">'.$langs->trans('Qty').'</td>';
 387              print '<td align="center">'.$langs->trans('TotalHT').'</td>';
 388              print '<td align="center">'.$langs->trans('VATRate').'</td>';
 389              print '<td align="center">'.$langs->trans('VAT').'</td>';
 390              print '<td align="right">'.$langs->trans('TotalTTC').'</td><td>&nbsp;</td></tr>';
 391              for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
 392              {
 393                  $var=!$var;
 394                  print '<tr '.$bc[$var].'><td>'.$fac->lignes[$i][0].'</td>';
 395                  print '<td align="center">'.price($fac->lignes[$i][1]).'</td>';
 396                  print '<td align="center">'.price($fac->lignes[$i][1] * (1+($fac->lignes[$i][2]/100))).'</td>';
 397                  print '<td align="center">'.$fac->lignes[$i][3].'</td>';
 398                  print '<td align="center">'.price($fac->lignes[$i][4]).'</td>';
 399                  print '<td align="center">'.$fac->lignes[$i][2].'</td>';
 400                  print '<td align="center">'.price($fac->lignes[$i][5]).'</td>';
 401                  print '<td align="right">'.price($fac->lignes[$i][6]).'</td>';
 402                  print '<td align="center">';
 403                  print '<a href="fiche.php?facid='.$fac->id.'&amp;action=del_ligne&amp;ligne_id='.$fac->lignes[$i][7].'">'.img_delete().'</a></td>';
 404                  print '</tr>';
 405              }
 406  
 407              /* Nouvelle ligne */
 408              $var=!$var;
 409              print '<tr '.$bc[$var].'>';
 410              print '<td>';
 411              print '<input size="30" name="label" type="text">';
 412              print '</td>';
 413              print '<td align="center">';
 414              print '<input size="8" name="amount" type="text">';
 415              print '</td>';
 416              print '<td align="center">';
 417              print '<input size="8" name="amountttc" type="text">';
 418              print '</td>';
 419              print '<td align="center">';
 420              print '<input size="2" name="qty" type="text" value="1">';
 421              print '</td>';
 422              print '<td align="center">-</td>';
 423              print '<td align="center">';
 424              $html->select_tva('tauxtva','',$societe,$mysoc);
 425              print '</td><td align="center" colspan="2">';
 426              print '&nbsp;';
 427              print '</td><td align="center"><input type="submit" class="button" value="'.$langs->trans('Add').'"></td></tr>';
 428              print '</table>';
 429              print '</form>';
 430          }
 431          else
 432          {
 433              /*
 434               *
 435               */
 436              $h=0;
 437  
 438              $head[$h][0] = 'fiche.php?facid='.$fac->id;
 439              $head[$h][1] = $langs->trans('Card');
 440              $hselected = $h;
 441              $h++;
 442  
 443              $titre=$langs->trans('SupplierBill').': '.$fac->ref;
 444              dolibarr_fiche_head($head, $hselected, $titre);
 445  
 446  
 447              /*
 448               * Confirmation de la validation
 449               *
 450               */
 451              if ($_GET['action'] == 'valid')
 452              {
 453                  $html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ValidateBill'), $langs->trans('ConfirmValidateBill', $fac->ref), 'confirm_valid');
 454                  print '<br />';
 455              }
 456  
 457              print '<table border="0" width="100%">';
 458              print '<tr><td width="50%" valign="top">';
 459  
 460              /*
 461               *   Facture
 462               */
 463              print '<table class="border" width="100%">';
 464              
 465              // Ref
 466              print "<tr><td>".$langs->trans("Ref")."</td><td colspan=\"3\">".$fac->ref."</td>";
 467              print "</tr>\n";
 468  
 469              // Societe
 470              print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2"><a href="../fiche.php?socid='.$fac->socidp.'">'.dolibarr_trunc($fac->socnom,24).'</a></td>';
 471              print '<td align="right"><a href="index.php?socid='.$fac->socidp.'">'.$langs->trans('OtherBills').'</a></td>';
 472              print '</tr>';
 473  
 474              print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
 475              print dolibarr_print_date($fac->datep,'%A %d %B %Y').'</td></tr>';
 476              print '<tr><td>'.$langs->trans('Label').'</td><td colspan="3">';
 477              print $fac->libelle;
 478              print '</td>';
 479              print '</tr>';
 480  
 481              $authorfullname='&nbsp;';
 482              if ($fac->author)
 483              {
 484                  $author = new User($db, $fac->author);
 485                  $author->fetch('');
 486                  $authorfullname=$author->fullname;
 487              }
 488              print '<tr><td>'.$langs->trans('Author').'</td><td colspan="3">'.$authorfullname.'</td>';
 489              print '<tr><td>'.$langs->trans('Status').'</td><td colspan="3">'.$fac->LibStatut($fac->paye,$fac->statut).'</td></tr>';
 490  
 491              print '<tr><td>'.$langs->trans('AmountHT').'</td><td><b>'.price($fac->total_ht).'</b></td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
 492              print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($fac->total_tva).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
 493              print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($fac->total_ttc).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
 494              if (strlen($fac->note))
 495              {
 496                  print '<tr><td>'.$langs->trans('Comments').'</td><td colspan="3">';
 497                  print nl2br(stripslashes($fac->note));
 498                  print '</td></tr>';
 499              }
 500              print '</table>';
 501  
 502              print '</td><td valign="top">';
 503  
 504  
 505              print '<table class="border" width="100%">';
 506  
 507              print '<tr>';
 508              print '<td>'.$langs->trans('DateEcheance').'</td><td>';
 509              print dolibarr_print_date($fac->date_echeance,'%A %d %B %Y').'</td></tr>';
 510  
 511              /*
 512               * Liste des paiements
 513               */
 514              print '<tr><td colspan="2">';
 515              print $langs->trans('Payments').' :<br>';
 516              $sql  = 'SELECT '.$db->pdate('datep').' as dp, pf.amount,';
 517              $sql .= ' c.libelle as paiement_type, p.num_paiement, p.rowid';
 518              $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p';
 519              $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
 520              $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
 521              $sql .= ' WHERE pf.fk_facturefourn = '.$fac->id;
 522              $sql .= ' ORDER BY dp DESC';
 523  
 524              $result = $db->query($sql);
 525              if ($result)
 526              {
 527                  $num = $db->num_rows($result);
 528                  $i = 0; $totalpaye = 0;
 529                  print '<table class="noborder" width="100%">';
 530                  print '<tr class="liste_titre">';
 531                  print '<td>'.$langs->trans('Date').'</td>';
 532                  print '<td>'.$langs->trans('Type').'</td>';
 533  
 534                  if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0)
 535                  {
 536                      $tdsup=' colspan="2"';
 537                  }
 538                  print '<td align="right">'.$langs->trans('AmountTTC').'</td><td'.$tdsup.'>&nbsp;</td></tr>';
 539  
 540                  $var=True;
 541                  while ($i < $num)
 542                  {
 543                      $objp = $db->fetch_object($result);
 544                      $var=!$var;
 545                      print '<tr '.$bc[$var].'>';
 546                      print '<td nowrap><a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans('Payment'),'payment').'</a> '.dolibarr_print_date($objp->dp)."</td>\n";
 547                      print '<td>'.$objp->paiement_type.' '.$objp->num_paiement.'</td>';
 548                      print '<td align="right">'.price($objp->amount).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td>';
 549  
 550                      if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0)
 551                      {
 552                          print '<td align="center">';
 553                          print '<a href="fiche.php?facid='.$fac->id.'&amp;action=deletepaiement&amp;paiement_id='.$objp->rowid.'">';
 554                          print img_delete();
 555                          print '</a></td>';
 556                      }
 557  
 558                      print '</tr>';
 559                      $totalpaye += $objp->amount;
 560                      $i++;
 561                  }
 562  
 563                  if ($fac->paye == 0)
 564                  {
 565                      print '<tr><td colspan="2" align="right">'.$langs->trans('AlreadyPayed').' :</td><td align="right"><b>'.price($totalpaye).'</b></td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
 566                      print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($fac->total_ttc).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
 567  
 568                      $resteapayer = $fac->total_ttc - $totalpaye;
 569  
 570                      print '<tr><td colspan="2" align="right">'.$langs->trans('RemainderToPay').' :</td>';
 571                      print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price($resteapayer).'</b></td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
 572                  }
 573                  print '</table>';
 574                  $db->free($result);
 575              }
 576              else
 577              {
 578                  dolibarr_print_error($db);
 579              }
 580              print '</td></tr>';
 581              print '</table>';
 582  
 583  
 584  
 585              print '</td></tr>';
 586              print '</table>';
 587  
 588  
 589              /*
 590               * Lignes
 591               *
 592               */
 593              print '<br>';
 594              print '<table class="noborder" width="100%">';
 595              print '<tr class="liste_titre"><td>'.$langs->trans('Label').'</td>';
 596              print '<td align="center">'.$langs->trans('PriceUHT').'</td>';
 597              print '<td align="center">'.$langs->trans('Qty').'</td>';
 598              print '<td align="center">'.$langs->trans('TotalHT').'</td>';
 599              print '<td align="center">'.$langs->trans('VATRate').'</td>';
 600              print '<td align="center">'.$langs->trans('VAT').'</td>';
 601              print '<td align="right">'.$langs->trans('TotalTTC').'</td></tr>';
 602              $var=1;
 603              for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
 604              {
 605                  $var=!$var;
 606                  print '<tr '.$bc[$var].'><td>'.$fac->lignes[$i][0].'</td>';
 607                  print '<td align="center">'.price($fac->lignes[$i][1]).'</td>';
 608                  print '<td align="center">'.$fac->lignes[$i][3].'</td>';
 609                  print '<td align="center">'.price($fac->lignes[$i][4]).'</td>';
 610                  print '<td align="center">'.$fac->lignes[$i][2].' %</td>';
 611                  print '<td align="center">'.price($fac->lignes[$i][5]).'</td>';
 612                  print '<td align="right">'.price($fac->lignes[$i][6]).'</td>';
 613                  print '</tr>';
 614              }
 615              print '</table>';
 616              print '</div>';
 617          }
 618  
 619  
 620          /*
 621           * Boutons actions
 622           */
 623  
 624          print '<div class="tabsAction">';
 625  
 626          if ($fac->statut == 0 && $user->societe_id == 0)
 627          {
 628              if ($_GET['action'] == 'edit')
 629              {
 630                  print '<a class="butAction" href="fiche.php?facid='.$fac->id.'">'.$langs->trans('Cancel').'</a>';
 631              }
 632              else
 633              {
 634                  print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&amp;action=edit">'.$langs->trans('Edit').'</a>';
 635              }
 636          }
 637  
 638          if ($fac->statut == 1 && $fac->paye == 0  && $user->societe_id == 0)
 639          {
 640              print '<a class="butAction" href="paiement.php?facid='.$fac->id.'&amp;action=create">'.$langs->trans('DoPaiement').'</a>';
 641          }
 642  
 643          if ($fac->statut == 1 && price($resteapayer) <= 0 && $fac->paye == 0  && $user->societe_id == 0)
 644          {
 645              print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&amp;action=payed">'.$langs->trans('ClassifyPayed').'</a>';
 646          }
 647  
 648          if ($fac->statut == 0 && $user->rights->fournisseur->facture->valider)
 649          {
 650              if ($_GET['action'] <> 'edit')
 651              print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&amp;action=valid">'.$langs->trans('Valid').'</a>';
 652          }
 653          else
 654              if ($user->rights->fournisseur->facture->creer)
 655              {
 656                  print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&amp;action=copy&amp;socid='.$fac->socidp.'">'.$langs->trans('Copy').'</a>';
 657              }
 658  
 659          if ($_GET['action'] != 'edit' && $fac->statut == 0 && $user->rights->fournisseur->facture->creer)
 660          {
 661              print '<a class="butActionDelete" href="index.php?facid='.$fac->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
 662          }
 663          print '</div>';
 664      }
 665  }
 666  
 667  $db->close();
 668  
 669  llxFooter('$Date: 2005/11/23 00:43:19 $ - $Revision: 1.79 $');
 670  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics