Ajoute gestion du calcul sur prix TTC

This commit is contained in:
Rodolphe Quiedeville 2006-12-15 12:02:19 +00:00
parent f202e5b7a1
commit fba788844d

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
@ -240,7 +240,7 @@ if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes
{ {
$fac = new Facture($db); $fac = new Facture($db);
$fac->fetch($_GET['facid']); $fac->fetch($_GET['facid']);
$fac->deleteline($_GET['rowid']); $fac->deleteline($_GET['rowid'], $user);
if ($_REQUEST['lang_id']) if ($_REQUEST['lang_id'])
{ {
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs");
@ -267,14 +267,14 @@ if ($_POST['action'] == 'confirm_payed_partially' && $_POST['confirm'] == 'yes'
$close_note=$_POST["close_note"]; $close_note=$_POST["close_note"];
if ($close_code) if ($close_code)
{ {
/* /*
if ($close_code == 'other' && ! $close_note) if ($close_code == 'other' && ! $close_note)
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Comment")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Comment")).'</div>';
} }
else else
{ {
*/ */
if ($close_code == 'abandon') if ($close_code == 'abandon')
{ {
$result = $fac->set_canceled($user,$close_code,$close_note); $result = $fac->set_canceled($user,$close_code,$close_note);
@ -283,7 +283,7 @@ if ($_POST['action'] == 'confirm_payed_partially' && $_POST['confirm'] == 'yes'
{ {
$result = $fac->set_payed($user,$close_code,$close_note); $result = $fac->set_payed($user,$close_code,$close_note);
} }
// } // }
} }
else else
{ {
@ -630,14 +630,19 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
} }
} }
$price_base_type = 'HT';
// Ecrase $pu par celui du produit // Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit // Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit // Ecrase $txtva par celui du produit
// Ecrase $base_price_type par celui du produit
if ($_POST['idprod']) if ($_POST['idprod'])
{ {
$prod = new Product($db, $_POST['idprod']); $prod = new Product($db, $_POST['idprod']);
$prod->fetch($_POST['idprod']); $prod->fetch($_POST['idprod']);
$price_base_type = $prod->price_base_type;
// multiprix // multiprix
if ($conf->global->PRODUIT_MULTIPRICES == 1) if ($conf->global->PRODUIT_MULTIPRICES == 1)
{ {
@ -645,7 +650,8 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
} }
else else
{ {
$pu=$prod->price; $pu = $prod->price;
$pu_ttc = $prod->price_ttc;
} }
// La description de la ligne est celle saisie ou // La description de la ligne est celle saisie ou
@ -676,7 +682,11 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
$_POST['idprod'], $_POST['idprod'],
$_POST['remise_percent'], $_POST['remise_percent'],
$date_start, $date_start,
$date_end $date_end,
0,
'',
'',
$price_base_type, $pu_ttc
); );
} }
@ -727,7 +737,7 @@ if ($_GET['action'] == 'deleteline' && $user->rights->facture->creer && ! $conf-
{ {
$fac = new Facture($db,'',$_GET['facid']); $fac = new Facture($db,'',$_GET['facid']);
$fac->fetch($_GET['facid']); $fac->fetch($_GET['facid']);
$result = $fac->deleteline($_GET['rowid']); $result = $fac->deleteline($_GET['rowid'], $user);
if ($result > 0) if ($result > 0)
{ {
if ($_REQUEST['lang_id']) if ($_REQUEST['lang_id'])
@ -1344,8 +1354,8 @@ if ($_GET['action'] == 'create')
print '<input type="hidden" name="amount" value="'.$propal->price.'">'."\n"; print '<input type="hidden" name="amount" value="'.$propal->price.'">'."\n";
print '<input type="hidden" name="total" value="'.$propal->total.'">'."\n"; print '<input type="hidden" name="total" value="'.$propal->total.'">'."\n";
print '<input type="hidden" name="tva" value="'.$propal->tva.'">'."\n"; print '<input type="hidden" name="tva" value="'.$propal->tva.'">'."\n";
// print '<input type="hidden" name="remise_absolue" value="'.$propal->remise_absolue.'">'."\n"; //print '<input type="hidden" name="remise_absolue" value="'.$propal->remise_absolue.'">'."\n";
// print '<input type="hidden" name="remise_percent" value="'.$propal->remise_percent.'">'."\n"; //print '<input type="hidden" name="remise_percent" value="'.$propal->remise_percent.'">'."\n";
print '<input type="hidden" name="propalid" value="'.$propal->id.'">'; print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
print '<tr><td>'.$langs->trans('Proposal').'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.img_object($langs->trans("ShowPropal"),'propal').' '.$propal->ref.'</a></td></tr>'; print '<tr><td>'.$langs->trans('Proposal').'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.img_object($langs->trans("ShowPropal"),'propal').' '.$propal->ref.'</a></td></tr>';
@ -1358,8 +1368,8 @@ if ($_GET['action'] == 'create')
print '<input type="hidden" name="amount" value="'.$commande->total_ht.'">'."\n"; print '<input type="hidden" name="amount" value="'.$commande->total_ht.'">'."\n";
print '<input type="hidden" name="total" value="'.$commande->total_ttc.'">'."\n"; print '<input type="hidden" name="total" value="'.$commande->total_ttc.'">'."\n";
print '<input type="hidden" name="tva" value="'.$commande->tva.'">'."\n"; print '<input type="hidden" name="tva" value="'.$commande->tva.'">'."\n";
// print '<input type="hidden" name="remise_absolue" value="'.$commande->remise_absolue.'">'."\n"; //print '<input type="hidden" name="remise_absolue" value="'.$commande->remise_absolue.'">'."\n";
// print '<input type="hidden" name="remise_percent" value="'.$commande->remise_percent.'">'."\n"; //print '<input type="hidden" name="remise_percent" value="'.$commande->remise_percent.'">'."\n";
print '<input type="hidden" name="commandeid" value="'.$commande->id.'">'; print '<input type="hidden" name="commandeid" value="'.$commande->id.'">';
print '<tr><td>'.$langs->trans('Order').'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'</a></td></tr>'; print '<tr><td>'.$langs->trans('Order').'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'</a></td></tr>';
@ -2263,7 +2273,7 @@ else
*/ */
// Réductions relatives (Remises-Ristournes-Rabbais) // Réductions relatives (Remises-Ristournes-Rabbais)
/* Une réduction doit s'appliquer obligatoirement sur des lignes de factures /* Une réduction doit s'appliquer obligatoirement sur des lignes de factures
$var=!$var; $var=!$var;
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="action" value="setremisepercent">'; print '<input type="hidden" name="action" value="setremisepercent">';
@ -2317,10 +2327,10 @@ else
} }
print '</tr>'; print '</tr>';
print '</form>'; print '</form>';
*/ */
// Réductions absolues (Remises-Ristournes-Rabbais) // Réductions absolues (Remises-Ristournes-Rabbais)
/* Les remises absolues doivent s'appliquer par ajout de lignes spécialisées /* Les remises absolues doivent s'appliquer par ajout de lignes spécialisées
$var=!$var; $var=!$var;
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="action" value="setremiseabsolue">'; print '<input type="hidden" name="action" value="setremiseabsolue">';
@ -2371,7 +2381,7 @@ else
} }
print '</tr>'; print '</tr>';
print '</form>'; print '</form>';
*/ */
/* /*
* Ajouter une ligne * Ajouter une ligne
@ -3004,8 +3014,7 @@ else
print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_GET['search_montant_ttc'].'">'; print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_GET['search_montant_ttc'].'">';
print '</td><td class="liste_titre" colspan="2" align="right">'; print '</td><td class="liste_titre" colspan="2" align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans('Search').'">'; print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans('Search').'">';
print '</td>'; print "</td></tr>\n";
print '</tr>';
if ($num > 0) if ($num > 0)
{ {
@ -3026,7 +3035,7 @@ else
print $facturestatic->getNomUrl(1); print $facturestatic->getNomUrl(1);
print $objp->increment; print $objp->increment;
if ($objp->datelimite < (time() - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1 && ! $objp->am) print img_warning($langs->trans('Late')); if ($objp->datelimite < (time() - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1 && ! $objp->am) print img_warning($langs->trans('Late'));
print '</td>'; print "</td>\n";
if ($objp->df > 0 ) if ($objp->df > 0 )
{ {
@ -3051,9 +3060,7 @@ else
// Affiche statut de la facture // Affiche statut de la facture
print '<td align="right" nowrap="nowrap">'; print '<td align="right" nowrap="nowrap">';
print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am); print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am);
print '</td>'; print "</td></tr>\n";
print '</tr>';
$total+=$objp->total; $total+=$objp->total;
$total_ttc+=$objp->total_ttc; $total_ttc+=$objp->total_ttc;
$totalrecu+=$objp->am; $totalrecu+=$objp->am;