diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index be13100c539..95fd10c7068 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -62,6 +62,8 @@ class FactureRec extends Facture var $rang; var $special_code; + var $usenewprice=0; + var $lines=array(); @@ -114,6 +116,7 @@ class FactureRec extends Facture $sql.= ", fk_projet"; $sql.= ", fk_cond_reglement"; $sql.= ", fk_mode_reglement"; + $sql.= ", usenewprice"; $sql.= ") VALUES ("; $sql.= "'".$this->titre."'"; $sql.= ", '".$facsrc->socid."'"; @@ -126,6 +129,7 @@ class FactureRec extends Facture $sql.= ", ".(! empty($facsrc->fk_project)?"'".$facsrc->fk_project."'":"null"); $sql.= ", '".$facsrc->cond_reglement_id."'"; $sql.= ", '".$facsrc->mode_reglement_id."'"; + $sql.= ", '".$this->usenewprice."'"; $sql.= ")"; if ($this->db->query($sql)) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 461cfaa03c0..1f014a65aaf 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -73,6 +73,7 @@ if ($action == 'add') { $object->titre = GETPOST('titre', 'alpha'); $object->note = GETPOST('comment'); + $object->usenewprice = GETPOST('usenewprice'); if ($object->create($user, $id) > 0) { @@ -122,11 +123,14 @@ if ($action == 'create') print ''; print ''; + $rowspan=4; + if (! empty($conf->projet->enabled) && $invoice->fk_project > 0) $rowspan++; + print ''; $invoice->fetch_thirdparty(); - print ''; + print ''; print ''; @@ -135,7 +139,7 @@ if ($action == 'create') print ''; print ''; - print ''; @@ -149,7 +153,7 @@ if ($action == 'create') $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$invoice->id, $facture->mode_reglement_id, 'none'); print ""; - if (! empty($conf->projet->enabled)) + if (! empty($conf->projet->enabled) && $invoice->fk_project > 0) { print "'; print ''; print ''; - print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print ''; print "\n"; } $var=True; @@ -223,21 +227,19 @@ if ($action == 'create') } $var=!$var; - print ""; + print ""; // Show product and description $type=(isset($objp->product_type)?$objp->product_type:$objp->fk_product_type); - if ($objp->fk_product) + if ($objp->fk_product > 0) { print ''; + print ''; print ''; if ($objp->remise_percent > 0) { @@ -290,14 +292,19 @@ if ($action == 'create') print '\n"; - if ($objp->fk_product > 0 && $objp->subprice <> $product->price) + // Price of product + if (empty($conf->global->PRODUIT_MULTIPRICES)) { - print '\n"; - $flag_different_price++; - } - else - { - print ''; + if ($objp->fk_product > 0) + { + $flag_price_may_change++; + $prodprice=$product_static->price; // price HT + print '\n"; + } + else + { + print ''; + } } print ""; @@ -315,21 +322,13 @@ if ($action == 'create') print "
'.$langs->trans("Customer").''.$invoice->client->getNomUrl(1).'
'.$langs->trans("Customer").''.$invoice->client->getNomUrl(1,'customer').''; //print $langs->trans("NotePrivate"); print '
'; + print ''; print ''; print '
".$langs->trans("Project").""; if ($invoice->fk_project > 0) @@ -208,7 +212,7 @@ if ($action == 'create') print ''.$langs->trans("Qty").''.$langs->trans("ReductionShort").''.$langs->trans("PriceU").'N.P.'.$langs->trans("CurrentProductPrice").'
'; print ''; // ancre pour retourner sur la ligne // Show product and description - $product_static->type=$objp->fk_product_type; - $product_static->id=$objp->fk_product; - $product_static->ref=$objp->ref; + $product_static->fetch($objp->fk_product); // We need all information later $text=$product_static->getNomUrl(1); $text.= ' - '.(! empty($objp->custom_label)?$objp->custom_label:$objp->product_label); $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); @@ -277,7 +279,7 @@ if ($action == 'create') } - print ''.$objp->tva_tx.' %'.vatrate($objp->tva_tx).'%'.$objp->qty.''.price($objp->subprice)."'.price($product->price)." '.price($prodprice)." 
"; print ''; - // TODO not used - if ($flag_different_price) + + if ($flag_price_may_change) { print ''; - print ''; + print ''; + print ''; print ''; print ''; } @@ -340,7 +339,7 @@ if ($action == 'create') } else { - print "Erreur facture $invoice->id inexistante"; + dol_print_error('',"Error, no invoice ".$invoice->id); } } else @@ -348,7 +347,6 @@ else /* * View mode */ - if ($id > 0) { if ($object->fetch($id) > 0) @@ -366,7 +364,7 @@ else print ''.$object->titre.''; print ''.$langs->trans("Customer").''; - print ''.$object->thirdparty->getNomUrl(1).''; + print ''.$object->thirdparty->getNomUrl(1,'customer').''; print "". $langs->trans("PaymentConditions") ." : "; $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'none'); print ""; diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index 2f9e4785c23..bb10f9a7cb7 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -19,6 +19,8 @@ DROP TABLE llx_product_ca; DROP TABLE llx_document; DROP TABLE llx_dolibarr_modules; +ALTER TABLE llx_facture_rec ADD COLUMN usenewprice integer; + ALTER TABLE llx_extrafields MODIFY COLUMN size varchar(8) DEFAULT NULL; ALTER TABLE llx_menu MODIFY COLUMN fk_mainmenu varchar(24); diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index a074c5ea32d..4e187b3153d 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -1,6 +1,6 @@ -- =========================================================================== -- Copyright (C) 2003 Rodolphe Quiedeville --- Copyright (C) 2006 Laurent Destailleur +-- Copyright (C) 2012 Laurent Destailleur -- Copyright (C) 2009 Regis Houssin -- Copyright (C) 2010 Juanjo Menent -- @@ -46,6 +46,7 @@ create table llx_facture_rec note text, note_public text, + usenewprice integer, frequency integer, unit_frequency varchar(2) DEFAULT 'd', date_when datetime DEFAULT NULL, diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 8415609ff9e..d5f67a57d11 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -175,4 +175,7 @@ ServiceCodeModel=Service code model AddThisProductCard=Create product card HelpAddThisProductCard=This option allows you to create or clone a product if it does not exist. AddThisServiceCard=Create service card -HelpAddThisServiceCard=This option allows you to create or clone a service if it does not exist. \ No newline at end of file +HelpAddThisServiceCard=This option allows you to create or clone a service if it does not exist. +CurrentProductPrice=Current price +AlwaysUseNewPrice=Always use current price of product/service +AlwaysUseFixedPrice=Use the fixed price \ No newline at end of file diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 82f5d4cb90e..4f5bb65ad4d 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -175,4 +175,7 @@ ServiceCodeModel=Modèle de code service AddThisProductCard=Créer fiche produit HelpAddThisProductCard=Cette option permet de créer ou de cloner une fiche produit si elle n'existe pas. AddThisServiceCard=Créer fiche service -HelpAddThisServiceCard=Cette option permet de créer ou de cloner une fiche service si elle n'existe pas. \ No newline at end of file +HelpAddThisServiceCard=Cette option permet de créer ou de cloner une fiche service si elle n'existe pas. +CurrentProductPrice=Prix actuel +AlwaysUseNewPrice=Toujours utiliser le prix du jour +AlwaysUseFixedPrice=Utiliser le prix fixé \ No newline at end of file