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='
| '; + print $langs->trans('Date'); + print ' | '; + + if ($_GET['action'] != 'editdate' && $commande->brouillon) print 'id.'">'.img_edit($langs->trans('SetDate'),1).' | '; + print '