Fix: bug #28055 : Unable to modify the date of a cloned command

This commit is contained in:
Laurent Destailleur 2009-12-04 19:02:55 +00:00
parent 90e041f404
commit 2931ed08c8
3 changed files with 79 additions and 2 deletions

View File

@ -1468,6 +1468,40 @@ class Commande extends CommonObject
}
/**
* \brief Set the order date
* \param user Objet utilisateur qui modifie
* \param date_livraison Date de livraison
* \return int <0 si ko, >0 si ok
*/
function set_date($user, $date)
{
if ($user->rights->commande->creer)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql.= " SET date_commande = ".($date ? $this->db->idate($date) : 'null');
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
dol_syslog("Commande::set_date sql=$sql",LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->date = $date;
return 1;
}
else
{
$this->error=$this->db->error();
dol_syslog("Commande::set_date ".$this->error,LOG_ERR);
return -1;
}
}
else
{
return -2;
}
}
/**
* \brief Definit une date de livraison
* \param user Objet utilisateur qui modifie

View File

@ -254,6 +254,20 @@ if ($_POST['action'] == "setabsolutediscount" && $user->rights->commande->creer)
}
}
if ($_POST['action'] == 'setdate' && $user->rights->commande->creer)
{
//print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$date=dol_mktime(0, 0, 0, $_POST['order_month'], $_POST['order_day'], $_POST['order_year']);
$commande = new Commande($db);
$commande->fetch($_GET['id']);
$result=$commande->set_date($user,$date);
if ($result < 0)
{
$mesg='<div class="error">'.$commande->error.'</div>';
}
}
if ($_POST['action'] == 'setdate_livraison' && $user->rights->commande->creer)
{
//print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
@ -1352,8 +1366,29 @@ else
print '</td></tr>';
// Date
print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dol_print_date($commande->date,'daytext').'</td>';
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Date');
print '</td>';
if ($_GET['action'] != 'editdate' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'editdate')
{
print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdate">';
$html->select_date($commande->date,'order_','','','',"setdate");
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print $commande->date ? dol_print_date($commande->date,'daytext') : '&nbsp;';
}
print '</td>';
print '<td width="50%">'.$langs->trans('Source').' : '.$commande->getLabelSource();
if ($commande->source == 0 && $conf->propal->enabled && $commande->propale_id)
{

View File

@ -290,7 +290,15 @@ else
if ($_GET["action"] == '')
{
if ($user->rights->stock->creer)
print "<a class=\"butAction\" href=\"fiche.php?action=edit&id=".$entrepot->id."\">".$langs->trans("Modify")."</a>";
else
print "<a class=\"butActionRefused\" href=\"#\">".$langs->trans("Modify")."</a>";
if ($user->rights->stock->supprimer)
print "<a class=\"butActionDelete\" href=\"fiche.php?action=delete&id=".$entrepot->id."\">".$langs->trans("Delete")."</a>";
else
print "<a class=\"butActionRefused\" href=\"#\">".$langs->trans("Delete")."</a>";
}
print "</div>";