diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 9578bf54c98..7034f765d5f 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2013 Christophe Battarel * * 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 @@ -305,6 +306,13 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $localtax1_tx=get_localtax($tva_tx,1,$object->societe); $localtax2_tx=get_localtax($tva_tx,2,$object->societe); + // ajout prix achat + $fk_fournprice = $_POST['fournprice']; + if ( ! empty($_POST['buying_price']) ) + $pa_ht = $_POST['buying_price']; + else + $pa_ht = null; + $info_bits=0; if ($tva_npr) $info_bits |= 0x01; @@ -329,7 +337,9 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $date_end, $price_base_type, $pu_ttc, - $info_bits + $info_bits, + $fk_fournprice, + $pa_ht ); } @@ -353,13 +363,18 @@ else if ($action == 'addline' && $user->rights->contrat->creer) } */ - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['idprod']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['tva_tx']); - unset($_POST['dp_desc']); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprod']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); } else { @@ -389,6 +404,13 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST( $localtax1_tx=get_localtax(GETPOST('eltva_tx'),1,$object->thirdparty); $localtax2_tx=get_localtax(GETPOST('eltva_tx'),2,$object->thirdparty); + // ajout prix d'achat + $fk_fournprice = $_POST['fournprice']; + if ( ! empty($_POST['buying_price']) ) + $pa_ht = $_POST['buying_price']; + else + $pa_ht = null; + $objectline->description=GETPOST('product_desc'); $objectline->price_ht=GETPOST('elprice'); $objectline->subprice=GETPOST('elprice'); @@ -402,6 +424,8 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST( $objectline->date_fin_validite=$date_end_update; $objectline->date_cloture=$date_end_real_update; $objectline->fk_user_cloture=$user->id; + $objectline->fk_fournprice=$fk_fournprice; + $objectline->pa_ht=$pa_ht; // TODO verifier price_min si fk_product et multiprix @@ -872,7 +896,7 @@ else $sql.= " cd.tva_tx, cd.remise_percent, cd.info_bits, cd.subprice,"; $sql.= " cd.date_ouverture_prevue as date_debut, cd.date_ouverture as date_debut_reelle,"; $sql.= " cd.date_fin_validite as date_fin, cd.date_cloture as date_fin_reelle,"; - $sql.= " cd.commentaire as comment,"; + $sql.= " cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,"; $sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype"; $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; @@ -889,6 +913,8 @@ else print ''.$langs->trans("PriceUHT").''; print ''.$langs->trans("Qty").''; print ''.$langs->trans("ReductionShort").''; + if ($conf->margin->enabled) + print ''.$langs->trans("BuyingPrice").''; print ' '; print "\n"; @@ -932,6 +958,10 @@ else { print ' '; } + + if ($conf->margin->enabled) + print ''.price($objp->pa_ht).''; + // Icon move, update et delete (statut contrat 0=brouillon,1=valide,2=ferme) print ''; if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0)) @@ -967,7 +997,7 @@ else if ($objp->subprice >= 0) { print ''; - print ''; + print ''; // Date planned print $langs->trans("DateStartPlanned").': '; @@ -998,6 +1028,8 @@ else print ''; print ''; print ''; + print ''; + print ''; // Ligne carac print ""; print ''; @@ -1030,12 +1062,18 @@ else print ''; print ''; print '%'; + if ($conf->margin->enabled) { + print ''; + if ($objp->fk_product) + print ''; + print ''; + } print ''; print '
'; print ''; // Ligne dates prevues print ""; - print ''; + print ''; print $langs->trans("DateStartPlanned").' '; $form->select_date($db->jdate($objp->date_debut),"date_start_update",$usehm,$usehm,($db->jdate($objp->date_debut)>0?0:1),"update"); print '
'.$langs->trans("DateEndPlanned").' '; @@ -1056,7 +1094,7 @@ else if ($object->statut > 0) { print ''; - print '
'; + print '
'; print "\n"; } @@ -1213,7 +1251,7 @@ else print ''; - print ''.$langs->trans("Comment").''; + print ''.$langs->trans("Comment").''; print ''; @@ -1395,3 +1433,59 @@ llxFooter(); $db->close(); ?> +margin->enabled) { +?> + +