Fix update of hours for payment

This commit is contained in:
Laurent Destailleur 2018-11-20 10:03:38 +01:00
parent 4bf5a12f35
commit 4845e90d95
2 changed files with 11 additions and 13 deletions

View File

@ -107,7 +107,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture->
$db->begin();
$object->fetch($id);
if ($object->valide() > 0)
if ($object->valide($user) > 0)
{
$db->commit();
@ -157,7 +157,7 @@ if ($action == 'setnum_paiement' && ! empty($_POST['num_paiement']))
if ($action == 'setdatep' && ! empty($_POST['datepday']))
{
$object->fetch($id);
$datepaye = dol_mktime(12, 0, 0, $_POST['datepmonth'], $_POST['datepday'], $_POST['datepyear']);
$datepaye = dol_mktime(GETPOST('datephour','int'), GETPOST('datepmin','int'), GETPOST('datepsec','int'), GETPOST('datepmonth','int'), GETPOST('datepday','int'), GETPOST('datepyear','int'));
$res = $object->update_date($datepaye);
if ($res === 0)
{
@ -191,17 +191,13 @@ $head = payment_prepare_head($object);
dol_fiche_head($head, 'payment', $langs->trans("PaymentCustomerInvoice"), -1, 'payment');
/*
* Confirmation de la suppression du paiement
*/
// Confirmation de la suppression du paiement
if ($action == 'delete')
{
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2);
}
/*
* Confirmation de la validation du paiement
*/
// Confirmation de la validation du paiement
if ($action == 'valide')
{
$facid = $_GET['facid'];
@ -220,7 +216,7 @@ print '<table class="border centpercent">'."\n";
// Date payment
print '<tr><td class="titlefield">'.$form->editfieldkey("Date",'datep',$object->date,$object,$user->rights->facture->paiement).'</td><td>';
print $form->editfieldval("Date",'datep',$object->date,$object,$user->rights->facture->paiement,'datepicker','',null,$langs->trans('PaymentDateUpdateSucceeded'));
print $form->editfieldval("Date", 'datep', $object->date, $object,$user->rights->facture->paiement, 'datehourpicker', '', null, $langs->trans('PaymentDateUpdateSucceeded'));
print '</td></tr>';
// Payment type (VIR, LIQ, ...)

View File

@ -862,9 +862,10 @@ class Paiement extends CommonObject
/**
* Validate payment
*
* @return int <0 if KO, >0 if OK
* @param User $user User making validation
* @return int <0 if KO, >0 if OK
*/
function valide()
function valide(User $user=null)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 1 WHERE rowid = '.$this->id;
@ -885,9 +886,10 @@ class Paiement extends CommonObject
/**
* Reject payment
*
* @return int <0 if KO, >0 if OK
* @param User $user User making reject
* @return int <0 if KO, >0 if OK
*/
function reject()
function reject(User $user=null)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 2 WHERE rowid = '.$this->id;