diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 854f9201601..c277d8f926b 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -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 diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 2772f2ecea7..5e0ed9ccf11 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -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='
'.$commande->error.'
'; + } +} + 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 ''; // Date - print ''.$langs->trans('Date').''; - print ''.dol_print_date($commande->date,'daytext').''; + print ''; + print ''; + + if ($_GET['action'] != 'editdate' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('Date'); + print 'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; + print ''; + if ($_GET['action'] == 'editdate') + { + print '
'; + print ''; + print ''; + $html->select_date($commande->date,'order_','','','',"setdate"); + print ''; + print '
'; + } + else + { + print $commande->date ? dol_print_date($commande->date,'daytext') : ' '; + } + print ''; + print ''.$langs->trans('Source').' : '.$commande->getLabelSource(); if ($commande->source == 0 && $conf->propal->enabled && $commande->propale_id) { diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php index 0eab8d19f58..d038b2be978 100644 --- a/htdocs/product/stock/fiche.php +++ b/htdocs/product/stock/fiche.php @@ -290,7 +290,15 @@ else if ($_GET["action"] == '') { + if ($user->rights->stock->creer) print "id."\">".$langs->trans("Modify").""; + else + print "".$langs->trans("Modify").""; + + if ($user->rights->stock->supprimer) + print "id."\">".$langs->trans("Delete").""; + else + print "".$langs->trans("Delete").""; } print "";