diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index c4a6dea0742..97d7cdae40f 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -273,18 +273,32 @@ if ($_GET['action'] == 'modif' && $user->rights->propale->creer)
$propal->reopen($user->id);
}
-if ($_POST['addligne'] == $langs->trans('Add') && $user->rights->propale->creer)
+if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
{
- /*
- * Ajout d'une ligne produit dans la propale
- */
- if ($_POST['idprod'])
+ /*
+ * Ajout d'une ligne produit dans la propale
+ */
+ $propal = new Propal($db);
+ $propal->fetch($_POST['propalid']);
+
+ if (isset($_POST['np_tva_tx']))
{
- $propal = new Propal($db);
- $propal->fetch($_GET['propalid']);
- $propal->insert_product($_POST['idprod'], $_POST['qty'], $_POST['remise']);
- propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
+ $propal->insert_product_generic(
+ $_POST['np_desc'],
+ $_POST['np_price'],
+ $_POST['np_qty'],
+ $_POST['np_tva_tx'],
+ $_POST['np_remise']);
}
+ else
+ {
+ $propal->insert_product(
+ $_POST['idprod'],
+ $_POST['qty'],
+ $_POST['remise'],
+ $_POST['np_desc']);
+ }
+ propale_pdf_create($db, $_POST['propalid'], $propal->modelpdf);
}
if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer)
@@ -300,25 +314,6 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer)
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
}
-if ($_POST['addproduct'] == $langs->trans('Add') && $user->rights->propale->creer)
-{
- /*
- * Ajout d'une ligne produit dans la propale
- */
- if (strlen($_POST['np_desc']) && strlen($_POST['np_price']))
- {
- $propal = new Propal($db);
- $propal->fetch($_GET['propalid']);
- $propal->insert_product_generic(
- $_POST['np_desc'],
- $_POST['np_price'],
- $_POST['np_qty'],
- $_POST['np_tva_tx'],
- $_POST['np_remise']);
- }
-}
-
-
if ($_POST['action'] == 'setpdfmodel' && $user->rights->propale->creer)
{
$propal = new Propal($db, 0, $_GET['propalid']);
@@ -628,12 +623,12 @@ if ($_GET['propalid'])
if ($num_lignes)
{
print '
';
- print '| '.$langs->trans('Description').' | ';
- print ''.$langs->trans('VAT').' | ';
- print ''.$langs->trans('PriceUHT').' | ';
- print ''.$langs->trans('Qty').' | ';
- print ''.$langs->trans('Discount').' | ';
- print ''.$langs->trans('AmountHT').' | ';
+ print ''.$langs->trans('Description').' | ';
+ print ''.$langs->trans('VAT').' | ';
+ print ''.$langs->trans('PriceUHT').' | ';
+ print ''.$langs->trans('Qty').' | ';
+ print ''.$langs->trans('Discount').' | ';
+ print ''.$langs->trans('AmountHT').' | ';
print ' | | ';
print "
\n";
}
@@ -646,27 +641,28 @@ if ($_GET['propalid'])
{
print '';
if ($objp->fk_product > 0)
- {
- print '| ';
- if ($objp->fk_product_type)
- print img_object($langs->trans('ShowService'),'service');
- else
- print img_object($langs->trans('ShowProduct'),'product');
- print ' '.stripslashes(nl2br($objp->description?$objp->description:$objp->product)).'';
- if ($objp->date_start && $objp->date_end)
- {
- print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
- }
- if ($objp->date_start && ! $objp->date_end)
- {
- print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
- }
- if (! $objp->date_start && $objp->date_end)
- {
- print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
- }
- print ' | ';
- }
+ {
+ print '';
+ if ($objp->fk_product_type)
+ print img_object($langs->trans('ShowService'),'service');
+ else
+ print img_object($langs->trans('ShowProduct'),'product');
+ print ' '.stripslashes(nl2br($objp->product)).'';
+ if ($objp->date_start && $objp->date_end)
+ {
+ print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
+ }
+ if ($objp->date_start && ! $objp->date_end)
+ {
+ print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
+ }
+ if (! $objp->date_start && $objp->date_end)
+ {
+ print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
+ }
+ print $objp->description?' '.$objp->description:'';
+ print ' | ';
+ }
else
{
print ''.stripslashes(nl2br($objp->description));
@@ -684,12 +680,12 @@ if ($_GET['propalid'])
}
print " | \n";
}
- print ''.$objp->tva_tx.' % | ';
+ print ''.$objp->tva_tx.'% | ';
print ''.price($objp->subprice)." | \n";
print ''.$objp->qty.' | ';
if ($objp->remise_percent > 0)
{
- print ''.$objp->remise_percent." % | \n";
+ print ''.$objp->remise_percent."% | \n";
}
else
{
@@ -714,8 +710,6 @@ if ($_GET['propalid'])
print '
';
}
// Update ligne de propal
- // \todo
-
if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] == 'editline' && $_GET["ligne"] == $objp->rowid)
{
print '';
}
@@ -749,21 +742,22 @@ if ($_GET['propalid'])
*/
if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline')
{
- print '';
+
// Ajout de produits/services prédéfinis
+ print '';
}
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index fd2aa34ca06..0436cb2873a 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -907,11 +907,11 @@ class Form
print '';
+ print ' selected>'.$txtva[$i].'%';
}
else
{
- print '>'.$txtva[$i].' %';
+ print '>'.$txtva[$i].'%';
}
}
print '';
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index fdfe5081b03..87a34bd097a 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -20,7 +20,6 @@
*
* $Id$
* $Source$
- *
*/
@@ -118,16 +117,18 @@ class Propal
}
}
- /**
- * \brief Ajout d'un produit dans la proposition, en base
- * \param idproduct id du produit à ajouter
- * \param qty quantité
- * \param remise_percent remise effectuée sur le produit
- * \return int >0 si ok, <0 si ko
- * \see add_product
- */
- function insert_product($idproduct, $qty, $remise_percent=0)
+ /**
+ * \brief Ajout d'un produit dans la proposition, en base
+ * \param idproduct Id du produit à ajouter
+ * \param qty Quantité
+ * \param remise_percent Remise effectuée sur le produit
+ * \param p_desc Descriptif optionnel
+ * \return int >0 si ok, <0 si ko
+ * \see add_product
+ */
+ function insert_product($idproduct, $qty, $remise_percent=0, $p_desc='')
{
+ dolibarr_syslog("propal.class.php::insert_product $idproduct, $qty, $remise_percent, $p_desc");
if ($this->statut == 0)
{
$prod = new Product($this->db, $idproduct);
@@ -143,7 +144,7 @@ class Propal
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
- $sql .= " (".$this->id.",". $idproduct.",'". $qty."','". ereg_replace(",",".",$price)."','".$prod->tva_tx."','".addslashes($prod->label)."','".ereg_replace(",",".",$remise_percent)."','".ereg_replace(",",".",$subprice)."')";
+ $sql .= " (".$this->id.",". $idproduct.",'". $qty."','". ereg_replace(",",".",$price)."','".$prod->tva_tx."','".addslashes($p_desc?$p_desc:$prod->label)."','".ereg_replace(",",".",$remise_percent)."','".ereg_replace(",",".",$subprice)."')";
if ($this->db->query($sql) )
{
@@ -162,6 +163,62 @@ class Propal
}
}
+
+ /**
+ * \brief Ajout d'un produit dans la proposition, en base
+ * \param p_desc Descriptif optionnel
+ * \param p_price Prix
+ * \param p_qty Quantité
+ * \param p_tva_tx Taux tva
+ * \param remise_percent Remise effectuée sur le produit
+ * \return int >0 si ok, <0 si ko
+ * \see add_product
+ */
+ function insert_product_generic($p_desc, $p_price, $p_qty, $p_tva_tx, $remise_percent=0)
+ {
+ dolibarr_syslog("propal.class.php::insert_product_generic $p_desc, $p_price, $p_qty, $p_tva_tx, $remise_percent");
+ if ($this->statut == 0)
+ {
+ if (strlen(trim($p_qty)) == 0)
+ {
+ $p_qty = 1;
+ }
+
+ $p_price = ereg_replace(",",".",$p_price);
+
+ $price = $p_price;
+ $subprice = $p_price;
+
+ if ($remise_percent > 0)
+ {
+ $remise = round(($p_price * $remise_percent / 100), 2);
+ $price = $p_price - $remise;
+ }
+
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
+ $sql .= " (".$this->id.", 0,'". $p_qty."','". ereg_replace(",",".",$price)."','".$p_tva_tx."','".addslashes($p_desc)."','$remise_percent', '".ereg_replace(",",".",$subprice)."') ; ";
+
+
+ if ($this->db->query($sql) )
+ {
+
+ if ($this->update_price() > 0)
+ {
+ return 1;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ return -2;
+ }
+ }
+ }
+
+
/**
* \brief Mise à jour d'une ligne de produit
* \param id id de la ligne
@@ -207,53 +264,6 @@ class Propal
}
}
- /**
- *
- *
- */
-
- function insert_product_generic($p_desc, $p_price, $p_qty, $p_tva_tx=19.6, $remise_percent=0)
- {
- if ($this->statut == 0)
- {
- if (strlen(trim($p_qty)) == 0)
- {
- $p_qty = 1;
- }
-
- $p_price = ereg_replace(",",".",$p_price);
-
- $price = $p_price;
- $subprice = $p_price;
-
- if ($remise_percent > 0)
- {
- $remise = round(($p_price * $remise_percent / 100), 2);
- $price = $p_price - $remise;
- }
-
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
- $sql .= " (".$this->id.", 0,'". $p_qty."','". ereg_replace(",",".",$price)."','".$p_tva_tx."','".$p_desc."','$remise_percent', '".ereg_replace(",",".",$subprice)."') ; ";
-
-
- if ($this->db->query($sql) )
- {
-
- if ($this->update_price() > 0)
- {
- return 1;
- }
- else
- {
- return -1;
- }
- }
- else
- {
- return -2;
- }
- }
- }
/**
*