diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 3fdc965575f..6f66c017c28 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -361,7 +361,7 @@ if ($_GET['action'] == 'del_ligne' && $user->rights->propale->creer)
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
}
-if ($_POST['action'] == 'setremise' && $user->rights->propale->creer)
+if ($_POST['action'] == 'set_discount' && $user->rights->propale->creer)
{
$propal = new Propal($db);
$propal->fetch($_GET['propalid']);
@@ -383,22 +383,29 @@ if ($_POST['action'] == 'set_contact')
$propal->set_contact($user, $_POST['contactidp']);
}
-// conditions de règlement
+// Conditions de règlement
if ($_POST["action"] == 'setconditions')
{
$propal = new Propal($db, $_GET["propalid"]);
- $propal->cond_reglement_id = $_POST['cond_reglement_id'];
- $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_cond_reglement='".$_POST['cond_reglement_id']."' WHERE rowid='".$propalid."'";
- $result = $db->query($sql);
+ $propal->cond_reglement_id = $_POST['cond_reglement_id'];
+ $sql = "UPDATE ".MAIN_DB_PREFIX."propal";
+ $sql.= " SET fk_cond_reglement='".$_POST['cond_reglement_id']."'";
+ $sql.= " WHERE rowid='".$_GET["propalid"]."'";
+ $resql = $db->query($sql);
+ if ($resql < 0) dolibarr_print_error($db);
}
-// mode de règlement
+// Mode de règlement
if ($_POST["action"] == 'setmode')
{
- $propal = new Propal($db, $_GET["propalid"]);
- $propal->mode_reglement_id = $_POST['mode_reglement_id'];
- $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_mode_reglement='".$_POST['mode_reglement_id']."' WHERE rowid='".$propalid."'";
- $result = $db->query($sql);
+ $propal = new Propal($db, $_GET["propalid"]);
+ $propal->mode_reglement_id = $_POST['mode_reglement_id'];
+ // \todo Créer une methode propal->cond_reglement
+ $sql = "UPDATE ".MAIN_DB_PREFIX."propal";
+ $sql.= " SET fk_mode_reglement='".$_POST['mode_reglement_id']."'";
+ $sql.= " WHERE rowid='".$_GET["propalid"]."'";
+ $resql = $db->query($sql);
+ if ($resql < 0) dolibarr_print_error($db);
}
@@ -483,7 +490,7 @@ if ($_GET['propalid'] > 0)
$resql = $db->query($sql);
if ($resql)
{
- if($db->num_rows($resql))
+ if ($db->num_rows($resql))
{
$obj = $db->fetch_object($resql);
@@ -561,6 +568,7 @@ if ($_GET['propalid'] > 0)
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->cond_reglement_id,'none');
}
print '';
+
print '
';
print '';
print $langs->trans('PaymentMode');
@@ -580,54 +588,28 @@ if ($_GET['propalid'] > 0)
// Destinataire
$langs->load('mails');
- print ' ';
- print ''.$langs->trans('MailTo').' ';
-
- $dests=$societe->contact_array($societe->id);
- $numdest = count($dests);
- if ($numdest==0)
- {
- print '';
- print 'Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale ';
- print ''.$langs->trans('AddContact').' ';
- print ' ';
- }
- else
- {
- if ($propal->statut == 0 && $user->rights->propale->creer)
- {
- print '';
- print ' ';
- print ' ';
- print '';
- print ' ';
- }
- else
- {
- if (!empty($propal->contactid))
- {
- print '';
- require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
- $contact=new Contact($db);
- $contact->fetch($propal->contactid);
- print '';
- print $contact->firstname.' '.$contact->name;
- print ' ';
- print ' ';
- }
- else {
- print ' ';
- }
- }
- }
-
+ print ' ';
+ print '';
+ print ' ';
+ if ($_GET['action'] == 'editcontact')
+ {
+ $html->form_contacts($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$societe,$propal->contactid,'contactidp');
+ }
+ else
+ {
+ $html->form_contacts($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$societe,$propal->contactid,'none');
+ }
+ print ' ';
+
if ($conf->projet->enabled) $rowspan++;
print ''.$langs->trans('Note').' : '. nl2br($propal->note).' ';
+ // Projet
if ($conf->projet->enabled)
{
$langs->load("projects");
@@ -673,24 +655,30 @@ if ($_GET['propalid'] > 0)
print '';
}
- print ''.$langs->trans('GlobalDiscount').' ';
- if ($propal->brouillon == 1 && $user->rights->propale->creer)
- {
+ // Remise globale
+ print '';
+ print '';
+ print ' ';
+ if ($_GET['action'] == 'editdiscount' && $propal->brouillon == 1 && $user->rights->propale->creer)
+ {
print '';
- }
- else
- {
- print ' '.$propal->remise_percent.'% ';
- }
- print ' ';
-
+ }
+ else
+ {
+ print $propal->remise_percent.'%';
+ }
+ print '';
+
+ // Amount
print ''.$langs->trans('AmountHT').' ';
print ''.price($propal->price).' ';
print ''.$langs->trans("Currency".$conf->monnaie).' ';
@@ -703,23 +691,16 @@ if ($_GET['propalid'] > 0)
// Statut
print ''.$langs->trans('Status').' '.$propal->getLibStatut().' ';
print '
';
- if ($propal->brouillon == 1 && $user->rights->propale->creer)
- {
- print '';
- }
/*
* Lignes de propale
*
*/
+ print '';
+
$sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice,';
- $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid';
-
- if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->CHANGE_PROD_DESC)
- {
- $sql.= ', p.description as product_desc';
- }
-
+ $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
+ $sql.= ' p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
$sql.= ' WHERE pt.fk_propal = '.$propal->id;
@@ -730,7 +711,6 @@ if ($_GET['propalid'] > 0)
$num = $db->num_rows($resql);
$i = 0; $total = 0;
- print '';
if ($num)
{
print '';
@@ -740,7 +720,8 @@ if ($_GET['propalid'] > 0)
print ''.$langs->trans('Qty').' ';
print ''.$langs->trans('Discount').' ';
print ''.$langs->trans('AmountHT').' ';
- print ' ';
+ print ' ';
+ print ' ';
print " \n";
}
$var=true;
@@ -759,9 +740,9 @@ if ($_GET['propalid'] > 0)
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
else print img_object($langs->trans('ShowProduct'),'product');
print ' '.$objp->ref.'';
- print ' - '.nl2br(stripslashes($objp->product));
+ print ' - '.nl2br(stripslashes($objp->product));
- if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->CHANGE_PROD_DESC)
+ if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->CHANGE_PROD_DESC)
{
print ' '.nl2br(stripslashes($objp->product_desc));
}
@@ -883,8 +864,9 @@ if ($_GET['propalid'] > 0)
}
/*
- * Ajouter une ligne
- */
+ * Ajouter une ligne
+ */
+
if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline')
{
print '';
@@ -902,20 +884,22 @@ if ($_GET['propalid'] > 0)
print '';
-
+
// Ajout de produits/services prédéfinis
if ($conf->produit->enabled)
{
@@ -924,6 +908,7 @@ if ($_GET['propalid'] > 0)
print ' ';
$var=!$var;
+
print ' ';
print '';
// multiprix
@@ -939,11 +924,11 @@ if ($_GET['propalid'] > 0)
print ' % ';
print ' ';
print " \n";
-
+
print '';
}
}
-
+
print '
';
}
diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php
index 0383b2f3a21..ca499f44667 100644
--- a/htdocs/compta/propal.php
+++ b/htdocs/compta/propal.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2005 Destailleur Laurent
+ * Copyright (C) 2004-2006 Destailleur Laurent
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2005-2006 Regis Houssin
*
@@ -43,12 +43,19 @@ require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
// Sécurité accés client
+$socidp='';
+if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; }
if ($user->societe_id > 0)
{
$action = '';
$socidp = $user->societe_id;
}
+
+/******************************************************************************/
+/* Actions */
+/******************************************************************************/
+
if ($_GET["action"] == 'setstatut')
{
/*
@@ -195,32 +202,32 @@ if ($_GET["propalid"] > 0)
print '';
print '';
if ($_GET['action'] == 'editconditions')
{
- $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$propal->cond_reglement_id,'cond_reglement_id');
+ $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$propal->id,$propal->cond_reglement_id,'cond_reglement_id');
}
else
{
- $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$propal->cond_reglement_id,'none');
+ $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->cond_reglement_id,'none');
}
print ' ';
print '';
print '';
print ' ';
if ($_GET['action'] == 'editmode')
{
- $html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$propal->mode_reglement_id,'mode_reglement_id');
+ $html->form_modes_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->mode_reglement_id,'mode_reglement_id');
}
else
{
- $html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$propal->mode_reglement_id,'none');
+ $html->form_modes_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->mode_reglement_id,'none');
}
print ' ';
@@ -242,13 +249,13 @@ if ($_GET["propalid"] > 0)
{
if ($propal->statut == 0 && $user->rights->propale->creer)
{
- print '';
- print '';
- print ' ';
- $html->select_contacts($societe->id, $propal->contactid, 'contactidp');
- print ' ';
- print ' ';
- print '';
+ print ' ';
+// print '';
+// print ' ';
+ $html->select_contacts($societe->id, $propal->contactid, 'none');
+// print ' ';
+// print ' ';
+// print '';
print ' ';
}
else
@@ -269,13 +276,12 @@ if ($_GET["propalid"] > 0)
}
}
}
- print '';
- if ($conf->projet->enabled)
- $rowspan++;
+ if ($conf->projet->enabled) $rowspan++;
print ''.$langs->trans('Note').' : '. nl2br($propal->note).' ';
+ // Projet
if ($conf->projet->enabled)
{
$langs->load("projects");
@@ -292,13 +298,13 @@ if ($_GET["propalid"] > 0)
{
if ($propal->statut == 0 && $user->rights->propale->creer)
{
- print '';
- print '';
- print ' ';
+ print '';
+// print '';
+// print ' ';
$html->select_projects($societe->id, $propal->projetidp, 'projetidp');
- print ' ';
- print ' ';
- print '';
+// print ' ';
+// print ' ';
+// print '';
print ' ';
}
else
@@ -321,17 +327,18 @@ if ($_GET["propalid"] > 0)
print '';
}
+ // Remise globale
print ''.$langs->trans('GlobalDiscount').' ';
if ($propal->brouillon == 1 && $user->rights->propale->creer)
{
- print '';
- print ' ';
- print ' % ';
- print '';
- print ' ';
- print ' ? ';
+// print '';
+// print ' ';
+ print ''.$propal->remise_percent.'%';
+// print ' ';
+// print ' ';
+// print ' ? ';
print ' ';
- print ' ';
+// print '';
}
else
{
@@ -351,10 +358,6 @@ if ($_GET["propalid"] > 0)
// Statut
print ' '.$langs->trans('Status').' '.$propal->getLibStatut().' ';
print '
';
- if ($propal->brouillon == 1 && $user->rights->propale->creer)
- {
- print '';
- }
/*
* Lignes de propale