diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index c4decbd5657..9c510564598 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -288,7 +288,7 @@ if ($_POST['action'] == 'confirm_commande' && $_POST['confirm'] == 'yes' && $use
{
$commande = new CommandeFournisseur($db);
$commande->fetch($id);
- $result = $commande->commande($user, $_GET["datecommande"], $_GET["methode"]);
+ $result = $commande->commande($user, $_GET["datecommande"], $_GET["methode"], $_GET['comment']);
}
@@ -567,7 +567,7 @@ if ($id > 0 || ! empty($ref))
if ($_GET["action"] == 'commande')
{
$date_com = dolibarr_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
- $html->form_confirm("fiche.php?id=".$commande->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"],
+ $html->form_confirm("fiche.php?id=".$commande->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]),
$langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dolibarr_print_date($date_com,'day')),"confirm_commande");
print '
';
}
@@ -987,7 +987,7 @@ if ($id > 0 || ! empty($ref))
print '
';
- if ( $user->rights->fournisseur->commande->commander && $commande->statut == 2)
+ if ( $user->rights->fournisseur->commande->commander && ($commande->statut == 2 || $commande->statut == 6))
{
/**
* Commander (action=commande)
@@ -998,14 +998,15 @@ if ($id > 0 || ! empty($ref))
print '';
print '| '.$langs->trans("ToOrder").' | ';
print '| '.$langs->trans("OrderDate").' | ';
- print $html->select_date('','','','','',"commande");
+ $date_com = dolibarr_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
+ print $html->select_date($date_com,'','','','',"commande");
print ' | ';
print '| '.$langs->trans("OrderMode").' | ';
- $formorder->select_methodes_commande('',"methodecommande",1);
+ $formorder->select_methodes_commande($_POST["methodecommande"],"methodecommande",1);
print ' | ';
- print '| '.$langs->trans("Comment").' | | ';
+ print '| '.$langs->trans("Comment").' | | ';
print ' | ';
print ' ';
print '';
diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php
index f3f39a2ad09..6ffd04dbb99 100644
--- a/htdocs/fourn/fournisseur.commande.class.php
+++ b/htdocs/fourn/fournisseur.commande.class.php
@@ -192,6 +192,7 @@ class CommandeFournisseur extends Commande
* \param user User making action
* \param statut Status of order
* \param datelog Date of change
+ * \param comment Comment
* \return int <0 if KO, >0 if OK
*/
function log($user, $statut, $datelog, $comment='')
@@ -652,33 +653,32 @@ class CommandeFournisseur extends Commande
}
/**
- * Envoie la commande au fournisseur
- *
- *
+ * Send a supplier order to supplier
*/
- function commande($user, $date, $methode)
+ function commande($user, $date, $methode, $comment='')
{
dolibarr_syslog("CommandeFournisseur::Commande");
$result = 0;
if ($user->rights->fournisseur->commande->commander)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 3, fk_methode_commande=".$methode.",date_commande=".$this->db->idate("$date");
- $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 2 ;";
+ $sql .= " WHERE rowid = ".$this->id;
- if ($this->db->query($sql) )
- {
- $result = 0;
- $this->log($user, 3, $date);
- }
- else
- {
- dolibarr_syslog("CommandeFournisseur::Commande Error -1");
- $result = -1;
- }
+ dol_syslog("CommandeFournisseur::Commande sql=".$sql, LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $result = 0;
+ $this->log($user, 3, $date, $comment);
+ }
+ else
+ {
+ dolibarr_syslog("CommandeFournisseur::Commande Error -1", LOG_ERR);
+ $result = -1;
+ }
}
else
{
- dolibarr_syslog("CommandeFournisseur::Commande Not Authorized");
+ dolibarr_syslog("CommandeFournisseur::Commande User not Authorized", LOG_ERR);
}
return $result ;
}
@@ -926,7 +926,7 @@ class CommandeFournisseur extends Commande
if (!$error && $conf->stock->enabled && $entrepot)
{
$mouv = new MouvementStock($this->db);
- // TODO Add price of product in method or '' to update PMP
+ // TODO Add price of product in method or '' to update PMP
$result=$mouv->reception($user, $product, $entrepot, $qty, $price);
if ($result < 0)
{
|