Fix: Suppression champ "price" obsolete et correction du pdf

This commit is contained in:
Regis Houssin 2008-05-09 09:08:41 +00:00
parent 22924961f9
commit 74ea13b439
6 changed files with 98 additions and 104 deletions

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -44,6 +44,7 @@ $langs->load('stocks');
if (!$user->rights->fournisseur->commande->lire) accessforbidden(); if (!$user->rights->fournisseur->commande->lire) accessforbidden();
$comclientid = isset($_GET["comid"])?$_GET["comid"]:''; $comclientid = isset($_GET["comid"])?$_GET["comid"]:'';
$id = isset($_GET["id"])?$_GET["id"]:$_POST["id"];
// Securite acces client // Securite acces client
$socid=0; $socid=0;
@ -71,7 +72,7 @@ $mesg='';
if ($_POST['action'] == 'classin') if ($_POST['action'] == 'classin')
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($_GET["id"]); $commande->fetch($id);
$commande->setProject($_POST["projetid"]); $commande->setProject($_POST["projetid"]);
} }
@ -80,7 +81,7 @@ if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->fournisseur->com
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($_REQUEST['id']); $commande->fetch($_REQUEST['id']);
$result = $commande->set_remise($user, $_POST['remise_percent']); $result = $commande->set_remise($user, $_POST['remise_percent']);
$_GET['id']=$_REQUEST['id']; $id=$_REQUEST['id'];
} }
/* /*
@ -91,7 +92,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree
if ($_POST['qty'] && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice'])) if ($_POST['qty'] && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice']))
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$ret=$commande->fetch($_POST["id"]); $ret=$commande->fetch($id);
if ($ret < 0) if ($ret < 0)
{ {
dolibarr_print_error($db,$commande->error); dolibarr_print_error($db,$commande->error);
@ -162,8 +163,8 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree
*/ */
if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->creer && $_POST['save'] == $langs->trans('Save')) if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->creer && $_POST['save'] == $langs->trans('Save'))
{ {
$commande = new CommandeFournisseur($db,"",$_POST["id"]); $commande = new CommandeFournisseur($db,"",$id);
if ($commande->fetch($_POST['id']) < 0) dolibarr_print_error($db); if ($commande->fetch($id) < 0) dolibarr_print_error($db);
$result = $commande->updateline($_POST['elrowid'], $result = $commande->updateline($_POST['elrowid'],
$_POST['eldesc'], $_POST['eldesc'],
@ -187,13 +188,11 @@ if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->c
dolibarr_print_error($db,$commande->error); dolibarr_print_error($db,$commande->error);
exit; exit;
} }
$_GET['id']=$_POST['id']; // Pour reaffichage de la fiche en cours d'edition
} }
if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->creer && $_POST['cancel'] == $langs->trans('Cancel')) if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->creer && $_POST['cancel'] == $langs->trans('Cancel'))
{ {
Header('Location: fiche.php?id='.$_POST['id']); // Pour reaffichage de la fiche en cours d'edition Header('Location: fiche.php?id='.$id); // Pour reaffichage de la fiche en cours d'edition
exit; exit;
} }
@ -202,23 +201,23 @@ if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes
if ($user->rights->fournisseur->commande->creer) if ($user->rights->fournisseur->commande->creer)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($_GET['id']); $commande->fetch($id);
$result = $commande->delete_line($_GET['lineid']); $result = $commande->delete_line($_GET['lineid']);
if ($_REQUEST['lang_id']) if ($_REQUEST['lang_id'])
{ {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang($_REQUEST['lang_id']);
} }
supplier_order_pdf_create($db, $_GET['id'], $commande->modelpdf, $outputlangs); supplier_order_pdf_create($db, $id, $commande->modelpdf, $outputlangs);
} }
Header('Location: fiche.php?id='.$_GET['id']); Header('Location: fiche.php?id='.$id);
exit; exit;
} }
if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->valider) if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->valider)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($_GET['id']); $commande->fetch($id);
$result = $commande->valid($user); $result = $commande->valid($user);
if ($result >= 0) if ($result >= 0)
@ -235,21 +234,21 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->
if ($_POST['action'] == 'confirm_approve' && $_POST["confirm"] == 'yes' && $user->rights->fournisseur->commande->approuver) if ($_POST['action'] == 'confirm_approve' && $_POST["confirm"] == 'yes' && $user->rights->fournisseur->commande->approuver)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($_GET['id']); $commande->fetch($id);
$result = $commande->approve($user); $result = $commande->approve($user);
} }
if ($_POST['action'] == 'confirm_refuse' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->approuver) if ($_POST['action'] == 'confirm_refuse' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->approuver)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($_GET['id']); $commande->fetch($id);
$result = $commande->refuse($user); $result = $commande->refuse($user);
} }
if ($_POST['action'] == 'confirm_commande' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->commander) if ($_POST['action'] == 'confirm_commande' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->commander)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($_GET["id"]); $commande->fetch($id);
$result = $commande->commande($user, $_GET["datecommande"], $_GET["methode"]); $result = $commande->commande($user, $_GET["datecommande"], $_GET["methode"]);
} }
@ -257,7 +256,7 @@ if ($_POST['action'] == 'confirm_commande' && $_POST['confirm'] == 'yes' && $use
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->creer) if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->creer)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->id = $_GET['id']; $commande->id = $id;
$commande->delete(); $commande->delete();
Header('Location: index.php'); Header('Location: index.php');
exit; exit;
@ -266,7 +265,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user-
if ($_POST["action"] == 'livraison' && $user->rights->fournisseur->commande->receptionner) if ($_POST["action"] == 'livraison' && $user->rights->fournisseur->commande->receptionner)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($_GET["id"]); $commande->fetch($id);
if ($_POST["type"]) if ($_POST["type"])
{ {
@ -275,7 +274,7 @@ if ($_POST["action"] == 'livraison' && $user->rights->fournisseur->commande->rec
$result = $commande->Livraison($user, $date_liv, $_POST["type"]); $result = $commande->Livraison($user, $date_liv, $_POST["type"]);
if ($result > 0) if ($result > 0)
{ {
Header("Location: fiche.php?id=".$_GET["id"]); Header("Location: fiche.php?id=".$id);
exit; exit;
} }
else else
@ -294,9 +293,9 @@ if ($_POST["action"] == 'livraison' && $user->rights->fournisseur->commande->rec
if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->rights->fournisseur->commande->annuler) if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->rights->fournisseur->commande->annuler)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($_GET["id"]); $commande->fetch($id);
$result = $commande->cancel($user); $result = $commande->cancel($user);
Header("Location: fiche.php?id=".$_GET["id"]); Header("Location: fiche.php?id=".$id);
exit; exit;
} }
@ -306,8 +305,8 @@ if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->r
if ($_GET['action'] == 'up' && $user->rights->fournisseur->commande->creer) if ($_GET['action'] == 'up' && $user->rights->fournisseur->commande->creer)
{ {
$commande = new CommandeFournisseur($db,'',$_GET['id']); $commande = new CommandeFournisseur($db,'',$id);
$commande->fetch($_GET['id']); $commande->fetch($id);
$commande->line_up($_GET['rowid']); $commande->line_up($_GET['rowid']);
if ($_REQUEST['lang_id']) if ($_REQUEST['lang_id'])
{ {
@ -315,14 +314,14 @@ if ($_GET['action'] == 'up' && $user->rights->fournisseur->commande->creer)
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang($_REQUEST['lang_id']);
} }
supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']); Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.$_GET['rowid']);
exit; exit;
} }
if ($_GET['action'] == 'down' && $user->rights->fournisseur->commande->creer) if ($_GET['action'] == 'down' && $user->rights->fournisseur->commande->creer)
{ {
$commande = new CommandeFournisseur($db,'',$_GET['id']); $commande = new CommandeFournisseur($db,'',$id);
$commande->fetch($_GET['id']); $commande->fetch($id);
$commande->line_down($_GET['rowid']); $commande->line_down($_GET['rowid']);
if ($_REQUEST['lang_id']) if ($_REQUEST['lang_id'])
{ {
@ -330,7 +329,7 @@ if ($_GET['action'] == 'down' && $user->rights->fournisseur->commande->creer)
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang($_REQUEST['lang_id']);
} }
supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']); Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.$_GET['rowid']);
exit; exit;
} }
@ -404,7 +403,7 @@ if ($_GET["action"] == 'create')
} }
$_GET['id']=$orderid; $id=$orderid;
$_GET['action']='edit'; $_GET['action']='edit';
$db->commit(); $db->commit();
} }
@ -422,31 +421,18 @@ llxHeader('',$langs->trans("OrderCard"),"CommandeFournisseur");
$html = new Form($db); $html = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
/********************************************************************* /* *************************************************************************** */
* /* */
* Mode creation /* Mode vue et edition */
* /* */
*********************************************************************/ /* *************************************************************************** */
if ($_GET['action'] == 'create' && $user->rights->fournisseur->commande->creer)
{
// Gerer par autre page
}
else
{
/* *************************************************************************** */ if ($id > 0)
/* */ {
/* Mode vue et edition */
/* */
/* *************************************************************************** */
$id = $_GET['id'];
if ($id > 0)
{
//if ($mesg) print $mesg.'<br>'; //if ($mesg) print $mesg.'<br>';
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
if ( $commande->fetch($_GET['id']) >= 0) if ( $commande->fetch($id) >= 0)
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->socid); $soc->fetch($commande->socid);
@ -653,7 +639,7 @@ else
*/ */
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
$sql = "SELECT l.ref as ref_fourn, l.fk_product, l.description, l.price, l.qty"; $sql = "SELECT l.ref as ref_fourn, l.fk_product, l.description, l.qty";
$sql.= ", l.rowid, l.tva_tx, l.remise_percent, l.subprice"; $sql.= ", l.rowid, l.tva_tx, l.remise_percent, l.subprice";
$sql.= ", l.total_ht, l.total_tva, l.total_ttc"; $sql.= ", l.total_ht, l.total_tva, l.total_ttc";
$sql.= ", p.rowid as product_id, p.label as product, p.ref"; $sql.= ", p.rowid as product_id, p.label as product, p.ref";
@ -817,7 +803,7 @@ else
// Ajout produit produits/services personnalises // Ajout produit produits/services personnalises
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'#add" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'#add" method="post">';
print '<input type="hidden" name="action" value="addligne">'; print '<input type="hidden" name="action" value="addligne">';
print '<input type="hidden" name="id" value="'.$_REQUEST["id"].'">'; print '<input type="hidden" name="id" value="'.$comid.'">';
$var=true; $var=true;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
@ -1043,7 +1029,6 @@ else
// Commande non trouvee // Commande non trouvee
dolibarr_print_error($db); dolibarr_print_error($db);
} }
}
} }
$db->close(); $db->close();

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -285,14 +285,15 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
// Total HT ligne // Total HT ligne
$pdf->SetXY ($this->postotalht, $curY); $pdf->SetXY ($this->postotalht, $curY);
$total = price($com->lignes[$i]->price * $com->lignes[$i]->qty); $total = price($com->lignes[$i]->total_ht);
$pdf->MultiCell(23, 4, $total, 0, 'R', 0); $pdf->MultiCell(23, 4, $total, 0, 'R', 0);
// Collecte des totaux par valeur de tva // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
// dans le tableau tva["taux"]=total_tva $tvaligne=$com->lignes[$i]->total_tva;
$tvaligne=$com->lignes[$i]->price * $com->lignes[$i]->qty;
if ($com->remise_percent) $tvaligne-=($tvaligne*$com->remise_percent)/100; if ($com->remise_percent) $tvaligne-=($tvaligne*$com->remise_percent)/100;
$this->tva[ (string)$com->lignes[$i]->tva_tx ] += $tvaligne; $vatrate=(string) $com->lignes[$i]->tva_tx;
if ($com->lignes[$i]->info_bits & 0x01 == 0x01) $vatrate.='*';
$this->tva[$vatrate] += $tvaligne;
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
@ -517,6 +518,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
// Affichage des totaux de TVA par taux (conformément à réglementation) // Affichage des totaux de TVA par taux (conformément à réglementation)
$pdf->SetFillColor(248,248,248); $pdf->SetFillColor(248,248,248);
foreach( $this->tva as $tvakey => $tvaval ) foreach( $this->tva as $tvakey => $tvaval )
{ {
if ($tvakey) // On affiche pas taux 0 if ($tvakey) // On affiche pas taux 0
@ -525,21 +527,30 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$index++; $index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$tvacompl = ( (float)$tvakey < 0 ) ? " (".$outputlangs->transnoentities("NonPercuRecuperable").")" : '' ;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1); $tvacompl='';
if (eregi('\*',$tvakey))
{
$tvakey=eregi_replace('\*','',$tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
$totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval * abs((float)$tvakey) / 100 ), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
} }
} }
if (! $this->atleastoneratenotnull) if (! $this->atleastoneratenotnull) // If not vat at all
{ {
$index++; $index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($com->total_tva), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
} }
$useborder=0; $useborder=0;

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Eric Seigne <erics@rycks.com> * Copyright (C) 2003 Eric Seigne <erics@rycks.com>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -95,7 +96,7 @@ if ( $societe->fetch($socid) )
print '<tr><td>'.$langs->trans("Phone").'</td><td>'.dolibarr_print_phone($societe->tel,$societe->pays_code).'&nbsp;</td><td>'.$langs->trans("Fax").'</td><td>'.dolibarr_print_phone($societe->fax,$societe->pays_code).'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Phone").'</td><td>'.dolibarr_print_phone($societe->tel,$societe->pays_code).'&nbsp;</td><td>'.$langs->trans("Fax").'</td><td>'.dolibarr_print_phone($societe->fax,$societe->pays_code).'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\"><a href=\"http://$societe->url\">$societe->url</a>&nbsp;</td></tr>"; print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\"><a href=\"http://$societe->url\">$societe->url</a>&nbsp;</td></tr>";
// Assujeti <20> TVA ou pas // Assujetti a TVA ou pas
print '<tr>'; print '<tr>';
print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">'; print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">';
print yn($societe->tva_assuj); print yn($societe->tva_assuj);
@ -120,7 +121,7 @@ if ( $societe->fetch($socid) )
print '<br>'; print '<br>';
/* /*
* Liste des commandes associ<EFBFBD>es * Liste des commandes associees
*/ */
$orderstatic = new CommandeFournisseur($db); $orderstatic = new CommandeFournisseur($db);
@ -177,7 +178,7 @@ if ( $societe->fetch($socid) )
/* /*
* Liste des factures associ<EFBFBD>es * Liste des factures associees
*/ */
$MAXLIST=5; $MAXLIST=5;

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -118,7 +119,7 @@ class CommandeFournisseur extends Commande
// export pdf ----------- // export pdf -----------
$this->lignes = array(); $this->lignes = array();
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice'; $sql = 'SELECT l.fk_product, l.description, l.total_ht, l.total_tva, l.total_ttc, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice';
$sql.= ', p.label, p.description as product_desc, p.rowid as prodid'; $sql.= ', p.label, p.description as product_desc, p.rowid as prodid';
$sql.= ', pf.ref_fourn'; $sql.= ', pf.ref_fourn';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as l'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as l';
@ -146,7 +147,9 @@ class CommandeFournisseur extends Commande
$ligne->tva_tx = $objp->tva_tx; $ligne->tva_tx = $objp->tva_tx;
$ligne->subprice = $objp->subprice; $ligne->subprice = $objp->subprice;
$ligne->remise_percent = $objp->remise_percent; $ligne->remise_percent = $objp->remise_percent;
$ligne->price = $objp->price; $ligne->total_ht = $objp->total_ht;
$ligne->total_tva = $objp->total_tva;
$ligne->total_ttc = $objp->total_ttc;
$ligne->fk_product = $objp->fk_product; // Id du produit $ligne->fk_product = $objp->fk_product; // Id du produit
$ligne->libelle = $objp->label; // Label produit $ligne->libelle = $objp->label; // Label produit
@ -618,8 +621,8 @@ class CommandeFournisseur extends Commande
/* On positionne en mode brouillon la commande */ /* On positionne en mode brouillon la commande */
$this->brouillon = 1; $this->brouillon = 1;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur (ref, fk_soc, date_creation, fk_user_author, fk_statut, source) "; $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur (ref, fk_soc, date_creation, fk_user_author, fk_statut, source, model_pdf) ";
$sql .= " VALUES ('',".$this->socid.", now(), ".$user->id.",0,0)"; $sql .= " VALUES ('',".$this->socid.", now(), ".$user->id.",0,0,'".$conf->global->COMMANDE_SUPPLIER_ADDON_PDF."')";
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
@ -755,23 +758,21 @@ class CommandeFournisseur extends Commande
// \TODO A virer // \TODO A virer
// Anciens indicateurs: $price, $remise (a ne plus utiliser) // Anciens indicateurs: $price, $remise (a ne plus utiliser)
$remise = 0; $remise = 0;
$price = $subprice;
if ($remise_percent > 0) if ($remise_percent > 0)
{ {
$remise = round(($pu * $remise_percent / 100), 2); $remise = round(($pu * $remise_percent / 100), 2);
$price = $pu - $remise;
} }
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet";
$sql.= " (fk_commande,label, description,"; $sql.= " (fk_commande,label, description,";
$sql.= " fk_product,"; $sql.= " fk_product,";
$sql.= " price, qty, tva_tx, remise_percent, subprice, remise, ref,"; $sql.= " qty, tva_tx, remise_percent, subprice, remise, ref,";
$sql.= " total_ht, total_tva, total_ttc"; $sql.= " total_ht, total_tva, total_ttc";
$sql.= ")"; $sql.= ")";
$sql.= " VALUES (".$this->id.", '" . addslashes($label) . "','" . addslashes($desc) . "',"; $sql.= " VALUES (".$this->id.", '" . addslashes($label) . "','" . addslashes($desc) . "',";
if ($fk_product) { $sql.= $fk_product.","; } if ($fk_product) { $sql.= $fk_product.","; }
else { $sql.= "null,"; } else { $sql.= "null,"; }
$sql.= price2num($price,'MU').", '$qty', $txtva, $remise_percent,'".price2num($subprice,'MU')."','".price2num($remise)."','".$ref."',"; $sql.= "'".$qty."', ".$txtva.", ".$remise_percent.",'".price2num($subprice,'MU')."','".price2num($remise)."','".$ref."',";
$sql.= "'".price2num($total_ht)."',"; $sql.= "'".price2num($total_ht)."',";
$sql.= "'".price2num($total_tva)."',"; $sql.= "'".price2num($total_tva)."',";
$sql.= "'".price2num($total_ttc)."'"; $sql.= "'".price2num($total_ttc)."'";
@ -1237,21 +1238,17 @@ class CommandeFournisseur extends Commande
$total_ttc = $tabprice[2]; $total_ttc = $tabprice[2];
// Anciens indicateurs: $price, $subprice, $remise (a ne plus utiliser) // Anciens indicateurs: $price, $subprice, $remise (a ne plus utiliser)
$price = $pu;
$subprice = $pu; $subprice = $pu;
$remise = 0; $remise = 0;
if ($remise_percent > 0) if ($remise_percent > 0)
{ {
$remise = round(($pu * $remise_percent / 100),2); $remise = round(($pu * $remise_percent / 100),2);
$price = ($pu - $remise);
} }
$price = price2num($price);
$subprice = price2num($subprice); $subprice = price2num($subprice);
// Mise a jour ligne en base // Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseurdet SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseurdet SET";
$sql.= " description='".addslashes($desc)."'"; $sql.= " description='".addslashes($desc)."'";
$sql.= ",price='".price2num($price)."'";
$sql.= ",subprice='".price2num($subprice)."'"; $sql.= ",subprice='".price2num($subprice)."'";
$sql.= ",remise='".price2num($remise)."'"; $sql.= ",remise='".price2num($remise)."'";
$sql.= ",remise_percent='".price2num($remise_percent)."'"; $sql.= ",remise_percent='".price2num($remise_percent)."'";
@ -1354,7 +1351,6 @@ class CommandeFournisseur extends Commande
$ligne->desc=$langs->trans("Description")." ".$xnbp; $ligne->desc=$langs->trans("Description")." ".$xnbp;
$ligne->qty=1; $ligne->qty=1;
$ligne->subprice=100; $ligne->subprice=100;
$ligne->price=100;
$ligne->tva_tx=19.6; $ligne->tva_tx=19.6;
$prodid = rand(1, $num_prods); $prodid = rand(1, $num_prods);
$ligne->produit_id=$prodids[$prodid]; $ligne->produit_id=$prodids[$prodid];
@ -1381,7 +1377,9 @@ class CommandeFournisseurLigne extends CommandeLigne
var $tva_tx; var $tva_tx;
var $subprice; var $subprice;
var $remise_percent; var $remise_percent;
var $price; var $total_ht;
var $total_tva;
var $total_ttc;
var $fk_product; var $fk_product;
var $desc; // Description ligne var $desc; // Description ligne
@ -1403,7 +1401,7 @@ class CommandeFournisseurLigne extends CommandeLigne
*/ */
function fetch($rowid) function fetch($rowid)
{ {
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.description, cd.price, cd.qty, cd.tva_tx,'; $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.description, cd.qty, cd.tva_tx,';
$sql.= ' cd.remise, cd.remise_percent, cd.subprice,'; $sql.= ' cd.remise, cd.remise_percent, cd.subprice,';
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,';
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
@ -1418,7 +1416,6 @@ class CommandeFournisseurLigne extends CommandeLigne
$this->fk_commande = $objp->fk_commande; $this->fk_commande = $objp->fk_commande;
$this->desc = $objp->description; $this->desc = $objp->description;
$this->qty = $objp->qty; $this->qty = $objp->qty;
$this->price = $objp->price;
$this->subprice = $objp->subprice; $this->subprice = $objp->subprice;
$this->tva_tx = $objp->tva_tx; $this->tva_tx = $objp->tva_tx;
$this->remise = $objp->remise; $this->remise = $objp->remise;

View File

@ -306,3 +306,4 @@ INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active)
INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (220, 'Canadian P5', 'Format Canadian P5', '140', '215', 'mm', 0); INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (220, 'Canadian P5', 'Format Canadian P5', '140', '215', 'mm', 0);
INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (225, 'Canadian P6', 'Format Canadian P6', '107', '140', 'mm', 0); INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (225, 'Canadian P6', 'Format Canadian P6', '107', '140', 'mm', 0);
ALTER TABLE llx_commande_fournisseurdet DROP COLUMN price;

View File

@ -31,7 +31,6 @@ create table llx_commande_fournisseurdet
qty real, -- quantité qty real, -- quantité
remise_percent real DEFAULT 0, -- pourcentage de remise remise_percent real DEFAULT 0, -- pourcentage de remise
remise real DEFAULT 0, -- montant de la remise remise real DEFAULT 0, -- montant de la remise
price real, -- prix final
subprice double(24,8) DEFAULT 0, -- prix unitaire subprice double(24,8) DEFAULT 0, -- prix unitaire
total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantité et incluant remise ligne et globale total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantité et incluant remise ligne et globale
total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale