Skip to content
Snippets Groups Projects
Commit b602316c authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Cheque receipt has always a bad date because date of receipt was date of creation

parent a14298cf
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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)
{
......
......@@ -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;
......
......@@ -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
......
<?php
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
*
* 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='<div class="error">'.$remisecheque->error.'</div>';
}
}
else
{
$mesg='<div class="error">'.$remisecheque->error.'</div>';
}
}
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 "</td>";
print "</tr>\n";
print '<tr><td>'.$langs->trans('DateCreation').'</td><td colspan="2">'.dol_print_date($remisecheque->date_bordereau,'day').'</td></tr>';
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Date');
print '</td>';
if ($_GET['action'] != 'editdate') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;id='.$object->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='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdate">';
$html->select_date($object->date_bordereau,'datecreate_','','','',"setdate");
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print $object->date_bordereau ? dol_print_date($object->date_bordereau,'day') : '&nbsp;';
}
print '</td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Account').'</td><td colspan="2">';
print $accountstatic->getNomUrl(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment