diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index ffa22983385..ccc7449bd9a 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -171,28 +171,31 @@ if ($_POST['action'] == 'add')
// Si on a selectionné une propal à copier, on réalise la copie
if($_POST['createmode']=='copy' && $_POST['copie_propal'])
{
- if ($propal->load_from($_POST['copie_propal']) == -1)
+ if ($propal->fetch($_POST['copie_propal']) > 0)
+ {
+ $propal->datep = mktime(12, 1, 1, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
+ $propal->date_livraison = mktime(12, 1, 1, $_POST['liv_month']."-".$_POST['liv_day']."-".$_POST['liv_year']);
+ $propal->adresse_livraison_id = $_POST['adresse_livraison_id'];
+ $propal->duree_validite = $_POST['duree_validite'];
+ $propal->cond_reglement_id = $_POST['cond_reglement_id'];
+ $propal->mode_reglement_id = $_POST['mode_reglement_id'];
+ $propal->remise_percent = $_POST['remise_percent'];
+ $propal->remise_absolue = $_POST['remise_absolue'];
+ $propal->socidp = $_POST['socidp'];
+ $propal->contactid = $_POST['contactidp'];
+ $propal->projetidp = $_POST['projetidp'];
+ $propal->modelpdf = $_POST['modelpdf'];
+ $propal->author = $user->id;
+ $propal->note = $_POST['note'];
+ $propal->ref = $_POST['ref'];
+ $propal->statut = 0;
+
+ $id = $propal->create_from();
+ }
+ else
{
$msg = '
'.$langs->trans("ErrorFailedToCopyProposal",$_POST['copie_propal']).'
';
}
- $propal->datep = mktime(12, 1, 1, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
- $propal->date_livraison = mktime(12, 1, 1, $_POST['liv_month']."-".$_POST['liv_day']."-".$_POST['liv_year']);
- $propal->adresse_livraison_id = $_POST['adresse_livraison_id'];
- $propal->duree_validite = $_POST['duree_validite'];
- $propal->cond_reglement_id = $_POST['cond_reglement_id'];
- $propal->mode_reglement_id = $_POST['mode_reglement_id'];
- $propal->remise_percent = $_POST['remise_percent'];
- $propal->remise_absolue = $_POST['remise_absolue'];
- $propal->socidp = $_POST['socidp'];
- $propal->contactid = $_POST['contactidp'];
- $propal->projetidp = $_POST['projetidp'];
- $propal->modelpdf = $_POST['modelpdf'];
- $propal->author = $user->id;
- $propal->note = $_POST['note'];
- $propal->ref = $_POST['ref'];
- $propal->statut = 0;
-
- $id = $propal->create_from();
}
else
{
@@ -641,7 +644,7 @@ if ($_GET['action'] == 'down' && $user->rights->propale->creer)
-llxHeader();
+llxHeader('',$langs->trans('Proposal'),'Proposition');
$html = new Form($db);
@@ -744,9 +747,15 @@ if ($_GET['propalid'] > 0)
print '. ';
if ($absolute_discount)
{
- print '
';
- //print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
- print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?propalid='.$propal->id,0,'remise_id',$societe->id,$absolute_discount);
+ if ($propal->statut > 0)
+ {
+ print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
+ }
+ else
+ {
+ print '
';
+ print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?propalid='.$propal->id,0,'remise_id',$societe->id,$absolute_discount);
+ }
}
else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
print '';
@@ -1004,11 +1013,10 @@ 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($objp->product);
if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC)
{
- print '
'.nl2br(stripslashes($objp->product_desc));
+ print '
'.nl2br($objp->product_desc);
}
if ($objp->date_start && $objp->date_end)
@@ -1029,34 +1037,40 @@ if ($_GET['propalid'] > 0)
else
{
print '';
- if ($objp->info_bits == 2)
+ if (($objp->info_bits & 2) == 2)
{
print '';
- print $langs->trans("Discount");
+ print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
print '';
if ($objp->description) print ': '.nl2br($objp->description);
}
else
{
print nl2br($objp->description);
- }
- 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).')';
+ 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 " | \n";
}
print ''.$objp->tva_tx.'% | ';
print ''.price($objp->subprice)." | \n";
- print ''.$objp->qty.' | ';
+ print '';
+ if (($objp->info_bits & 2) != 2)
+ {
+ print $objp->qty;
+ }
+ else print ' ';
+ print ' | ';
if ($objp->remise_percent > 0)
{
print ''.$objp->remise_percent."% | \n";
@@ -1121,19 +1135,31 @@ 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 ' - '.stripslashes(nl2br($objp->product));
+ print ' - '.nl2br($objp->product);
print '
';
}
- print '';
+ print '';
print '';
if($societe->tva_assuj == "0")
print '0';
else
print $html->select_tva("tva_tx",$objp->tva_tx,$mysoc,$societe);
print ' | ';
- print ' | ';
- print ' | ';
- print '% | ';
+ print ' | ';
+ print '';
+ if (($objp->info_bits & 2) != 2)
+ {
+ print '';
+ }
+ else print ' ';
+ print ' | ';
+ print '';
+ if (($objp->info_bits & 2) != 2)
+ {
+ print '%';
+ }
+ else print ' ';
+ print ' | ';
print '';
print '
| ';
print '' . "\n";
@@ -1436,7 +1462,7 @@ if ($_GET['propalid'] > 0)
$file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf';
if (file_exists($file))
{
- print 'id.'&action=presend">'.$langs->trans('Send').'';
+ print 'id.'&action=presend">'.$langs->trans('SendByMail').'';
}
}
}
diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php
index 9f4b385c8d7..d3b9d7ca35e 100644
--- a/htdocs/commande/commande.class.php
+++ b/htdocs/commande/commande.class.php
@@ -516,22 +516,6 @@ class Commande extends CommonObject
$price = $pu - $remise;
}
- // Récupère rang max de la commande dans $rangmax
- $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.'commandedet';
- $sql.= ' WHERE fk_commande ='.$commandeid;
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $row = $this->db->fetch_row($resql);
- $rangmax = $row[0];
- }
- else
- {
- dolibarr_print_error($this->db);
- $this->db->rollback();
- return -1;
- }
-
// Insertion ligne
$ligne=new CommandeLigne($this->db);
@@ -545,7 +529,7 @@ class Commande extends CommonObject
$ligne->remise_percent=$remise_percent;
$ligne->subprice=$subprice;
$ligne->remise=$remise;
- $ligne->rang=($rangmax+1);
+ $ligne->rang=-1;
$ligne->info_bits=$info_bits;
$ligne->total_ht=$total_ht;
$ligne->total_tva=$total_tva;
@@ -882,6 +866,73 @@ class Commande extends CommonObject
}
+ /**
+ * \brief Ajout d'une ligne remise fixe dans la commande, en base
+ * \param idremise Id de la remise fixe
+ * \return int >0 si ok, <0 si ko
+ */
+ function insert_discount($idremise)
+ {
+ global $langs;
+
+ include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
+ include_once(DOL_DOCUMENT_ROOT.'/discount.class.php');
+
+ $this->db->begin();
+
+ $remise=new DiscountAbsolute($this->db);
+ $result=$remise->fetch($idremise);
+
+ if ($result > 0)
+ {
+ $comligne=new CommandeLigne($this->db);
+ $comligne->fk_commande=$this->id;
+ $comligne->fk_remise_except=$remise->id;
+ $comligne->desc=$remise->description; // Description ligne
+ $comligne->tva_tx=$remise->tva_tx;
+ $comligne->subprice=-$remise->amount_ht;
+ $comligne->price=-$remise->amount_ht;
+ $comligne->fk_product=0; // Id produit prédéfini
+ $comligne->qty=1;
+ $comligne->remise=0;
+ $comligne->remise_percent=0;
+ $comligne->rang=-1;
+ $comligne->info_bits=2;
+
+ $tabprice=calcul_price_total($comligne->qty, $comligne->subprice, 0,$comligne->tva_tx);
+ $comligne->total_ht = $tabprice[0];
+ $comligne->total_tva = $tabprice[1];
+ $comligne->total_ttc = $tabprice[2];
+
+ $result=$comligne->insert();
+ if ($result > 0)
+ {
+ $result=$this->update_price($this->id);
+ if ($result > 0)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=$comligne->error;
+ $this->db->rollback();
+ return -2;
+ }
+ }
+ else
+ {
+ $this->db->rollback();
+ return -2;
+ }
+ }
+
/*
*
*
@@ -2027,8 +2078,29 @@ class CommandeLigne
*/
function insert()
{
+ dolibarr_syslog("CommandeLigne.class::insert rang=".$this->rang);
$this->db->begin();
+ $rangtouse=$this->rang;
+ if ($rangtouse == -1)
+ {
+ // Récupère rang max de la commande dans $rangmax
+ $sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'commandedet';
+ $sql.= ' WHERE fk_commande ='.$this->fk_commande;
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $rangtouse = $obj->max + 1;
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ $this->db->rollback();
+ return -1;
+ }
+ }
+
// Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
$sql.= ' (fk_commande, label, description, price, qty, tva_tx,';
@@ -2048,7 +2120,7 @@ class CommandeLigne
$sql.= " '".price2num($this->remise)."',";
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.",";
else $sql.= 'null,';
- $sql.= ' '.$this->rang.',';
+ $sql.= ' '.$rangtouse.',';
if (isset($this->coef)) $sql.= ' '.$this->coef.',';
else $sql.= ' null,';
$sql.= " '".$this->info_bits."',";
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index b05e76dec22..6824efce96d 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -105,7 +105,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
$commande->contactid = $_POST['contactidp'];
$commande->fetch_client();
-
+
$commande->add_product($_POST['idprod1'],$_POST['qty1'],$_POST['remise_percent1']);
$commande->add_product($_POST['idprod2'],$_POST['qty2'],$_POST['remise_percent2']);
$commande->add_product($_POST['idprod3'],$_POST['qty3'],$_POST['remise_percent3']);
@@ -161,6 +161,24 @@ if ($_POST['action'] == 'setremise' && $user->rights->commande->creer)
$commande->set_remise($user, $_POST['remise']);
}
+if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer)
+{
+ if ($_POST["remise_id"])
+ {
+ $com = new Commande($db);
+ $com->id=$_GET['id'];
+ $ret=$com->fetch($_GET['id']);
+ if ($ret > 0)
+ {
+ $com->insert_discount($_POST["remise_id"]);
+ }
+ else
+ {
+ dolibarr_print_error($db,$com->error);
+ }
+ }
+}
+
if ($_POST['action'] == 'setdate_livraison' && $user->rights->commande->creer)
{
$datelivraison=@mktime(0, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']);
@@ -223,7 +241,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
$ret=$commande->fetch($_POST['id']);
$soc = new Societe($db, $commande->socidp);
$soc->fetch($commande->socidp);
-
+
if ($ret < 0)
{
dolibarr_print_error($db,$commande->error);
@@ -237,9 +255,9 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
{
$prod = new Product($db, $_POST['idprod']);
$prod->fetch($_POST['idprod']);
-
+
$libelle = $prod->libelle;
-
+
// multiprix
if ($conf->global->PRODUIT_MULTIPRICES == 1)
{
@@ -249,7 +267,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
{
$pu=$prod->price;
}
-
+
// La description de la ligne est celle saisie ou
// celle du produit si (non saisi + PRODUIT_CHANGE_PROD_DESC défini)
$desc=$_POST['np_desc'];
@@ -257,7 +275,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
{
$desc = $prod->description;
}
-
+
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
}
else
@@ -266,7 +284,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
$tva_tx=$_POST['tva_tx'];
$desc=$_POST['desc'];
}
-
+
$commande->addline(
$_POST['id'],
$libelle,
@@ -317,7 +335,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
dolibarr_print_error($db,$commande->error);
exit;
}
-
+
$_GET['id']=$_POST['id']; // Pour réaffichage de la fiche en cours d'édition
}
@@ -395,7 +413,7 @@ if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes
exit;
}
-if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
+if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
{
/*
* Repasse la commande en mode brouillon
@@ -446,7 +464,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post
{
dolibarr_print_error($db,$result);
exit;
- }
+ }
}
// Efface les fichiers
@@ -497,25 +515,25 @@ if ($_POST['action'] == 'send')
$message = $_POST['message'];
$sendtocc = $_POST['sendtocc'];
$deliveryreceipt = $_POST['deliveryreceipt'];
-
+
if ($_POST['action'] == 'send')
{
$subject = $_POST['subject'];
-
+
if($subject == '')
{
$subject = $langs->trans('Order').' '.$commande->ref;
}
-
+
$actiontypeid=8;
$actionmsg ='Mail envoyé par '.$from.' à '.$sendto.'.
';
-
+
if ($message)
{
$actionmsg.='Texte utilisé dans le corps du message:
';
$actionmsg.=$message;
}
-
+
$actionmsg2='Envoi commande par mail';
}
@@ -580,7 +598,7 @@ if ($_POST['action'] == 'send')
}
-llxHeader('',$langs->trans('OrderCard'),'Commande');
+llxHeader('',$langs->trans('Order'),'Commande');
$html = new Form($db);
@@ -663,7 +681,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
print '.';
print '';
-
+
// Date
print '| '.$langs->trans('Date').' | ';
$html->select_date('','re','','','',"crea_commande");
@@ -948,7 +966,7 @@ else
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('Cancel'), $langs->trans('ConfirmCancelOrder'), 'confirm_cancel');
print ' ';
}
-
+
/*
* Confirmation de la suppression d'une ligne produit
*/
@@ -1001,14 +1019,24 @@ else
print ' |
';
// Ligne info remises tiers
- print '| '.$langs->trans('Discounts').' | ';
+ print ' |
| '.$langs->trans('Discounts').' | ';
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
else print $langs->trans("CompanyHasNoRelativeDiscount");
$absolute_discount=$soc->getCurrentDiscount();
print '. ';
- if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
- else print $langs->trans("CompanyHasNoAbsoluteDiscount");
- print '.';
+ if ($absolute_discount)
+ {
+ if ($commande->statut > 0)
+ {
+ print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
+ }
+ else
+ {
+ print ' ';
+ print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$commande->id,0,'remise_id',$soc->id,$absolute_discount);
+ }
+ }
+ else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
print ' |
';
// Date
@@ -1133,16 +1161,16 @@ else
// Lignes de 3 colonnes
// Total HT
- print '| '.$langs->trans('TotalHT').' | ';
+ print '
| '.$langs->trans('AmountHT').' | ';
print ''.price($commande->total_ht).' | ';
print ''.$langs->trans('Currency'.$conf->monnaie).' |
';
// Total TVA
- print '| '.$langs->trans('TotalVAT').' | '.price($commande->total_tva).' | ';
+ print '
| '.$langs->trans('AmountVAT').' | '.price($commande->total_tva).' | ';
print ''.$langs->trans('Currency'.$conf->monnaie).' |
';
// Total TTC
- print '| '.$langs->trans('TotalTTC').' | '.price($commande->total_ttc).' | ';
+ print '
| '.$langs->trans('AmountTTC').' | '.price($commande->total_ttc).' | ';
print ''.$langs->trans('Currency'.$conf->monnaie).' |
';
// Statut
@@ -1154,16 +1182,11 @@ else
print "\n";
/*
- * Lignes de commandes
- */
- $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,';
- $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid';
-
- if ($conf->global->COM_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC)
- {
- $sql.= ', p.description as product_desc';
- }
-
+ * Lignes de commandes
+ */
+ $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, l.info_bits,';
+ $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.'commandedet as l';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
$sql.= ' WHERE l.fk_commande = '.$commande->id;
@@ -1188,7 +1211,7 @@ else
print ' | ';
print ' | ';
print ' | ';
- print '';
+ print "\n";
}
$var=true;
while ($i < $num)
@@ -1205,25 +1228,40 @@ else
print '';
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
else print img_object($langs->trans('ShowProduct'),'product');
- print ' '.$objp->ref.' - '.stripslashes(nl2br($objp->product));
- print ($objp->description && $objp->description!=$objp->product)?' '.stripslashes(nl2br($objp->description)):'';
-
+ print ' '.$objp->ref.' - '.nl2br($objp->product);
+ print ($objp->description && $objp->description!=$objp->product)?' '.nl2br($objp->description):'';
if ($conf->global->COM_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC)
{
- print ' '.nl2br(stripslashes($objp->product_desc));
+ print ' '.nl2br($objp->product_desc);
}
-
print ' | ';
}
else
{
- print ''.stripslashes(nl2br($objp->description));
+ print ' | ';
+ if (($objp->info_bits & 2) == 2)
+ {
+ print '';
+ print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
+ print '';
+ if ($objp->description) print ': '.nl2br($objp->description);
+ }
+ else
+ {
+ print nl2br($objp->description);
+ }
print ' | ';
}
print ''.$objp->tva_tx.'% | ';
print ''.price($objp->subprice).' | ';
- print ''.$objp->qty.' | ';
+ print '';
+ if (($objp->info_bits & 2) != 2)
+ {
+ print $objp->qty;
+ }
+ else print ' ';
+ print ' | ';
if ($objp->remise_percent > 0)
{
print ''.$objp->remise_percent.'% | ';
@@ -1287,10 +1325,10 @@ else
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
else print img_object($langs->trans('ShowProduct'),'product');
print ' '.$objp->ref.'';
- print ' - '.stripslashes(nl2br($objp->product));
+ print ' - '.nl2br($objp->product);
print '
';
}
- print '';
+ print '';
print '';
if($soc->tva_assuj == "0")
print '0';
@@ -1298,8 +1336,20 @@ else
print $html->select_tva('tva_tx',$objp->tva_tx,$mysoc,$soc);
print ' | ';
print ' | ';
- print ' | ';
- print '% | ';
+ print '';
+ if (($objp->info_bits & 2) != 2)
+ {
+ print '';
+ }
+ else print ' ';
+ print ' | ';
+ print '';
+ if (($objp->info_bits & 2) != 2)
+ {
+ print '%';
+ }
+ else print ' ';
+ print ' | ';
print '';
print '
| ';
print '';
@@ -1544,7 +1594,7 @@ else
$file = $conf->commande->dir_output . '/'.$comref.'/'.$comref.'.pdf';
if (file_exists($file))
{
- print ''.$langs->trans('Send').'';
+ print ''.$langs->trans('SendByMail').'';
}
}
}
@@ -1764,8 +1814,8 @@ else
{
dolibarr_print_error($db,$result);
exit;
- }
- }
+ }
+ }
print '
';
print_titre($langs->trans('SendOrderByMail'));
diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php
index 1b73725a531..657f1cfce79 100644
--- a/htdocs/compta/commande/fiche.php
+++ b/htdocs/compta/commande/fiche.php
@@ -20,9 +20,9 @@
* $Id$
* $Source$
*/
-
+
/**
- \file htdocs/compta/fiche.php
+ \file htdocs/compta/commande/fiche.php
\ingroup commande
\brief Fiche commande
\version $Revision$
@@ -43,7 +43,7 @@ $user->getrights('commande');
if (! $user->rights->commande->lire) accessforbidden();
// Sécurité accés client
-if ($user->societe_id > 0)
+if ($user->societe_id > 0)
{
$action = '';
$socidp = $user->societe_id;
@@ -52,9 +52,9 @@ if ($user->societe_id > 0)
/*
* Actions
- */
+ */
-if ($_GET["action"] == 'facturee')
+if ($_GET["action"] == 'facturee')
{
$commande = new Commande($db);
$commande->fetch($_GET["id"]);
@@ -73,7 +73,7 @@ $html = new Form($db);
/* Mode vue et edition */
/* */
/* *************************************************************************** */
-
+
if ($_GET["id"] > 0)
{
$commande = new Commande($db);
@@ -123,7 +123,7 @@ if ($_GET["id"] > 0)
}
print '';
print '';
-
+
// Société
print '| '.$langs->trans('Company').' | ';
@@ -136,11 +136,21 @@ if ($_GET["id"] > 0)
else print $langs->trans("CompanyHasNoRelativeDiscount");
$absolute_discount=$soc->getCurrentDiscount();
print '. ';
- if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
- else print $langs->trans("CompanyHasNoAbsoluteDiscount");
- print '.';
+ if ($absolute_discount)
+ {
+ if ($commande->statut > 0)
+ {
+ print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
+ }
+ else
+ {
+ print '
';
+ print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$commande->id,0,'remise_id',$soc->id,$absolute_discount);
+ }
+ }
+ else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
print '
';
-
+
// Date
print '| '.$langs->trans('Date').' | ';
print ''.dolibarr_print_date($commande->date,'%A %d %B %Y').' | ';
@@ -154,13 +164,13 @@ if ($_GET["id"] > 0)
}
print '';
print '
';
-
+
// Date de livraison
print '| ';
print '';
print ' | ';
@@ -178,21 +188,21 @@ if ($_GET["id"] > 0)
}
print ' | ';
print ''.$langs->trans('NotePublic').' : ';
- print nl2br($commande->note_public);
+ print nl2br($commande->note_public);
print ' | ';
print '
';
-
-
+
+
// Adresse de livraison
print '| ';
print '';
print ' | ';
-
+
if ($_GET['action'] == 'editdelivery_adress')
{
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id);
@@ -202,13 +212,13 @@ if ($_GET["id"] > 0)
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id);
}
print ' |
';
-
+
// Conditions et modes de réglement
print '| ';
print '';
print ' | ';
@@ -263,36 +273,36 @@ if ($_GET["id"] > 0)
// Lignes de 3 colonnes
// Total HT
- print ' |
| '.$langs->trans('TotalHT').' | ';
+ print '
| '.$langs->trans('AmountHT').' | ';
print ''.price($commande->total_ht).' | ';
print ''.$langs->trans('Currency'.$conf->monnaie).' |
';
// Total TVA
- print '| '.$langs->trans('TotalVAT').' | '.price($commande->total_tva).' | ';
+ print '
| '.$langs->trans('AmountVAT').' | '.price($commande->total_tva).' | ';
print ''.$langs->trans('Currency'.$conf->monnaie).' |
';
-
+
// Total TTC
- print '| '.$langs->trans('TotalTTC').' | '.price($commande->total_ttc).' | ';
+ print '
| '.$langs->trans('AmountTTC').' | '.price($commande->total_ttc).' | ';
print ''.$langs->trans('Currency'.$conf->monnaie).' |
';
// Statut
print '| '.$langs->trans('Status').' | ';
print ''.$commande->getLibStatut(4).' | ';
print '
';
-
+
print '';
- /*
- * Lignes de commandes
- *
- */
- $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,';
- $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid';
- $sql.= ' FROM '.MAIN_DB_PREFIX."commandedet as l";
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
- $sql.= " WHERE l.fk_commande = ".$commande->id;
- $sql.= " ORDER BY l.rang";
-
+ /*
+ * Lignes de commandes
+ */
+ $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, l.info_bits,';
+ $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."commandedet as l";
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
+ $sql.= " WHERE l.fk_commande = ".$commande->id;
+ $sql.= " ORDER BY l.rang, l.rowid";
+
$resql = $db->query($sql);
if ($resql)
{
@@ -308,8 +318,8 @@ if ($_GET["id"] > 0)
print ''.$langs->trans('VAT').' | ';
print ''.$langs->trans('PriceUHT').' | ';
print ''.$langs->trans('Qty').' | ';
- print ''.$langs->trans('Discount').' | ';
- print ''.$langs->trans('AmountHT').' | ';
+ print ''.$langs->trans('ReductionShort').' | ';
+ print ''.$langs->trans('AmountHT').' | ';
print ' | ';
print ' | ';
print ' | ';
@@ -328,21 +338,38 @@ if ($_GET["id"] > 0)
print '';
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
else print img_object($langs->trans('ShowProduct'),'product');
- print ' '.$objp->ref.' - '.stripslashes(nl2br($objp->product));
+ print ' '.$objp->ref.' - '.nl2br($objp->product);
print ($objp->description && $objp->description!=$objp->product)?' '.stripslashes(nl2br($objp->description)):'';
print ' | ';
}
else
{
- print ''.stripslashes(nl2br($objp->description));
+ print ' | ';
+ if (($objp->info_bits & 2) == 2)
+ {
+ print '';
+ print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
+ print '';
+ if ($objp->description) print ': '.nl2br($objp->description);
+ }
+ else
+ {
+ print nl2br($objp->description);
+ }
print " | \n";
}
print ''.$objp->tva_tx.'% | ';
print ''.price($objp->subprice)." | \n";
- print ''.$objp->qty.' | ';
-
+ print '';
+ if (($objp->info_bits & 2) != 2)
+ {
+ print $objp->qty;
+ }
+ else print ' ';
+ print ' | ';
+
if ($objp->remise_percent > 0)
{
print ''.$objp->remise_percent."% | \n";
@@ -372,7 +399,7 @@ if ($_GET["id"] > 0)
/*
* Lignes de remise
*/
-
+
// Réductions relatives (Remises-Ristournes-Rabbais)
/* Une réduction doit s'appliquer obligatoirement sur des lignes de factures
et non globalement
@@ -431,7 +458,7 @@ if ($_GET["id"] > 0)
print '';
*/
- // Réductions (Remises-Ristournes-Rabbais)
+ // Remises absolue
/* Les remises absolues doivent s'appliquer par ajout de lignes spécialisées
$var=!$var;
print '