Can reactivate a supplier order not completely received.

This commit is contained in:
Laurent Destailleur 2009-02-18 12:55:33 +00:00
parent c78bd22adc
commit b291f11af0
2 changed files with 24 additions and 23 deletions

View File

@ -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 '<br />';
}
@ -987,7 +987,7 @@ if ($id > 0 || ! empty($ref))
print '</td><td width="50%" valign="top">';
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 '<table class="border" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ToOrder").'</td></tr>';
print '<tr><td>'.$langs->trans("OrderDate").'</td><td>';
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 '</td></tr>';
print '<tr><td>'.$langs->trans("OrderMode").'</td><td>';
$formorder->select_methodes_commande('',"methodecommande",1);
$formorder->select_methodes_commande($_POST["methodecommande"],"methodecommande",1);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Comment").'</td><td><input size="30" type="text" name="comment"></td></tr>';
print '<tr><td>'.$langs->trans("Comment").'</td><td><input size="30" type="text" name="comment" value="'.$_POST["comment"].'"></td></tr>';
print '<tr><td align="center" colspan="2"><input type="submit" class="button" name="'.$langs->trans("Activate").'"></td></tr>';
print '</table>';
print '</form>';

View File

@ -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)
{