From b602316c40af4617c0d43216a99a54a5323b7d44 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 27 Dec 2010 20:42:16 +0000 Subject: [PATCH] Fix: Cheque receipt has always a bad date because date of receipt was date of creation --- ChangeLog | 1 + htdocs/commande/class/commande.class.php | 12 ++--- htdocs/commande/fiche.php | 4 +- .../cheque/class/remisecheque.class.php | 40 +++++++++++++- htdocs/compta/paiement/cheque/fiche.php | 52 +++++++++++++++++-- 5 files changed, 96 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3972aca610a..b757d59dd45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.0 compared to 2.9 ***** For users: +- New: Can edit date of cheque receipts. - New: Add Sales journal and Purchase journal report. - New: Can create supplier invoice from supplier order. New: Support login by openid diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d99b6e259d3..43f38c94115 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1066,7 +1066,7 @@ class Commande extends CommonObject $this->date_livraison = $this->db->jdate($obj->date_livraison); $this->fk_delivery_address = $obj->fk_adresse_livraison; $this->propale_id = $obj->fk_source; - + $this->lines = array(); if ($this->statut == 0) $this->brouillon = 1; @@ -1258,7 +1258,7 @@ class Commande extends CommonObject $line->date_end = $this->db->jdate($objp->date_end); $this->lines[$i] = $line; - + $i++; } $this->db->free($result); @@ -1551,10 +1551,10 @@ 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 + * Set the order date + * @param user Object user + * @param date_livraison Date delivery + * @return int <0 if KO, >0 if OK */ function set_date($user, $date) { diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 1586e47b58c..8b6c088735f 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -50,8 +50,8 @@ $langs->load('propal'); $langs->load('deliveries'); $langs->load('products'); -$comid = isset($_GET["id"])?$_GET["id"]:(isset($_POST["id"])?$_POST["id"]:''); -if (empty($comid)) $comid=isset($_GET["orderid"])?$_GET["orderid"]:(isset($_POST["orderid"])?$_POST["orderid"]:''); +$comid = GETPOST("id"); +if (empty($comid)) $comid=GETPOST("orderid"); // Security check $socid=0; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index c54c2c4c57f..2f22a119999 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -60,7 +60,7 @@ class RemiseCheque extends CommonObject * \brief Load record * \param id Id record * \param ref Ref record - * \return int <0 if KO, >= 0 if OK + * \return int <0 if KO, > 0 if OK */ function fetch($id,$ref='') { @@ -103,10 +103,11 @@ class RemiseCheque extends CommonObject } $this->db->free($resql); - return 0; + return 1; } else { + $this->error=$this->db->lasterror(); return -1; } } @@ -656,6 +657,41 @@ class RemiseCheque extends CommonObject } + /** + * Set the creation date + * @param user Object user + * @param date Date creation + * @return int <0 if KO, >0 if OK + */ + function set_date($user, $date) + { + if ($user->rights->banque->cheque) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; + $sql.= " SET date_bordereau = ".($date ? $this->db->idate($date) : 'null'); + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog("RemiseCheque::set_date sql=$sql",LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->date_bordereau = $date; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("RemiseCheque::set_date ".$this->error,LOG_ERR); + return -1; + } + } + else + { + return -2; + } + } + + /** * \brief Renvoie nom clicable (avec eventuellement le picto) * \param withpicto Inclut le picto dans le lien diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php index f39ba87e8a7..28477026a94 100644 --- a/htdocs/compta/paiement/cheque/fiche.php +++ b/htdocs/compta/paiement/cheque/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2007-2008 Laurent Destailleur + * Copyright (C) 2007-2010 Laurent Destailleur * Copyright (C) 2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ /** * \file htdocs/compta/paiement/cheque/fiche.php * \ingroup facture - * \brief Onglet paiement cheque + * \brief Tab cheque deposit * \version $Id$ */ @@ -61,6 +61,27 @@ $dir=$conf->banque->dir_output.'/bordereau/'; * Actions */ +if ($_POST['action'] == 'setdate' && $user->rights->banque->cheque) +{ + $remisecheque = new RemiseCheque($db); + $result = $remisecheque->fetch(GETPOST('id')); + if ($result > 0) + { + //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $date=dol_mktime(0, 0, 0, $_POST['datecreate_month'], $_POST['datecreate_day'], $_POST['datecreate_year']); + + $result=$remisecheque->set_date($user,$date); + if ($result < 0) + { + $mesg='
'.$remisecheque->error.'
'; + } + } + else + { + $mesg='
'.$remisecheque->error.'
'; + } +} + if ($_GET['action'] == 'create' && $_GET["accountid"] > 0 && $user->rights->banque->cheque) { $remisecheque = new RemiseCheque($db); @@ -309,6 +330,8 @@ if ($_GET['action'] == 'new') } else { + $object=$remisecheque; + $paymentstatic=new Paiement($db); $accountlinestatic=new AccountLine($db); $accountstatic=new Account($db); @@ -324,7 +347,30 @@ else print ""; print "\n"; - print ''.$langs->trans('DateCreation').''.dol_print_date($remisecheque->date_bordereau,'day').''; + print ''; + + print ''; + if ($_GET['action'] != 'editdate') 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($object->date_bordereau,'datecreate_','','','',"setdate"); + print ''; + print '
'; + } + else + { + print $object->date_bordereau ? dol_print_date($object->date_bordereau,'day') : ' '; + } + + print ''; + print ''; print ''.$langs->trans('Account').''; print $accountstatic->getNomUrl(1);