diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php
index ea54e66747f..53a5c047790 100644
--- a/htdocs/compta/paiement/card.php
+++ b/htdocs/compta/paiement/card.php
@@ -221,7 +221,12 @@ print '';
// Payment type (VIR, LIQ, ...)
$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle;
-print '
| '.$langs->trans('PaymentMode').' | '.$labeltype.' |
';
+print '| '.$langs->trans('PaymentMode').' | '.$labeltype;
+print $object->num_paiement?' - '.$object->num_paiement:'';
+print ' |
';
+
+// Amount
+print '| '.$langs->trans('Amount').' | '.price($object->amount,'',$langs,0,-1,-1,$conf->currency).' |
';
$disable_delete = 0;
// Bank account
@@ -302,9 +307,6 @@ print '| '.$form->editfieldkey("Comments",'note',$object->no
print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->facture->paiement,'textarea:'.ROWS_3.':90%');
print ' |
';
-// Amount
-print '| '.$langs->trans('Amount').' | '.price($object->amount,'',$langs,0,-1,-1,$conf->currency).' |
';
-
print '';
print '';
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 5fa9f68c454..e17ae65750f 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -804,23 +804,55 @@ class Paiement extends CommonObject
function update_date($date)
{
// phpcs:enable
- if (!empty($date) && $this->statut!=1)
+ $error=0;
+
+ if (!empty($date) && $this->statut != 1)
{
+ $this->db->begin();
+
+ dol_syslog(get_class($this)."::update_date with date = ".$date, LOG_DEBUG);
+
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET datep = '".$this->db->idate($date)."'";
$sql.= " WHERE rowid = ".$this->id;
- dol_syslog(get_class($this)."::update_date", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
+ if (! $result)
{
- $this->datepaye = $date;
+ $error++;
+ $this->error='Error -1 '.$this->db->error();
+ }
+
+ $type = $this->element;
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX.'bank';
+ $sql.= " SET dateo = '".$this->db->idate($date)."', datev = '".$this->db->idate($date)."'";
+ $sql.= " WHERE rowid IN (SELECT fk_bank FROM ".MAIN_DB_PREFIX."bank_url WHERE type = '".$type."' AND url_id = ".$this->id.")";
+ $sql.= " AND rappro = 0";
+
+ $result = $this->db->query($sql);
+ if (! $result)
+ {
+ $error++;
+ $this->error='Error -1 '.$this->db->error();
+ }
+
+ if (! $error)
+ {
+
+ }
+
+ if (! $error)
+ {
+ $this->datepaye = $date;
$this->date = $date;
+
+ $this->db->commit();
return 0;
}
else
{
- $this->error='Error -1 '.$this->db->error();
+ $this->db->rollback();
return -2;
}
}
diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php
index e82c490c885..cac1e092eed 100644
--- a/htdocs/fourn/class/paiementfourn.class.php
+++ b/htdocs/fourn/class/paiementfourn.class.php
@@ -114,6 +114,7 @@ class PaiementFourn extends Paiement
$this->date = $this->db->jdate($obj->dp);
$this->datepaye = $this->db->jdate($obj->dp);
$this->numero = $obj->num_paiement;
+ $this->num_paiement = $obj->num_paiement;
$this->bank_account = $obj->fk_account;
$this->bank_line = $obj->fk_bank;
$this->montant = $obj->amount;
diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php
index bd957503b94..56aa565ee4b 100644
--- a/htdocs/fourn/paiement/card.php
+++ b/htdocs/fourn/paiement/card.php
@@ -198,12 +198,16 @@ if ($result > 0)
// Payment mode
$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle;
- print '| '.$langs->trans('PaymentMode').' | '.$labeltype.' |
';
+ print '| '.$langs->trans('PaymentMode').' | '.$labeltype;
+ print $object->num_paiement?' - '.$object->num_paiement:'';
+ print ' |
';
// Payment numero
- print '| '.$form->editfieldkey("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).' | ';
- print $form->editfieldval("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded'));
+ /* TODO Add field num_payment into payment table and save it
+ print ' |
| '.$form->editfieldkey("Numero",'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).' | ';
+ print $form->editfieldval("Numero",'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded'));
print ' |
';
+ */
// Amount
print '| '.$langs->trans('Amount').' | '.price($object->montant,'',$langs,0,0,-1,$conf->currency).' |
';
@@ -213,11 +217,6 @@ if ($result > 0)
print '| '.$langs->trans('Status').' | '.$object->getLibStatut(4).' |
';
}
- // Note
- print '| '.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer).' | ';
- print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer,'textarea');
- print ' |
';
-
$allow_delete = 1 ;
// Bank account
if (! empty($conf->banque->enabled))
@@ -232,13 +231,6 @@ if ($result > 0)
$title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment"));
}
- print '';
- print '| '.$langs->trans('BankTransactionLine').' | ';
- print '';
- print $bankline->getNomUrl(1,0,'showconciliated');
- print ' | ';
- print '
';
-
print '';
print '| '.$langs->trans('BankAccount').' | ';
print '';
@@ -247,9 +239,21 @@ if ($result > 0)
print $accountstatic->getNomUrl(1);
print ' | ';
print '
';
+
+ print '';
+ print '| '.$langs->trans('BankTransactionLine').' | ';
+ print '';
+ print $bankline->getNomUrl(1,0,'showconciliated');
+ print ' | ';
+ print '
';
}
}
+ // Note
+ print '| '.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer).' | ';
+ print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer,'textarea');
+ print ' |
';
+
print '';
print '';
@@ -276,9 +280,9 @@ if ($result > 0)
print ''.$langs->trans('Ref').' | ';
print ''.$langs->trans('RefSupplier').' | ';
print ''.$langs->trans('Company').' | ';
- print ''.$langs->trans('ExpectedToPay').' | ';
- print ''.$langs->trans('Status').' | ';
- print ''.$langs->trans('PayedByThisPayment').' | ';
+ print ''.$langs->trans('ExpectedToPay').' | ';
+ print ''.$langs->trans('PayedByThisPayment').' | ';
+ print ''.$langs->trans('Status').' | ';
print "\n";
if ($num > 0)
@@ -302,12 +306,13 @@ if ($result > 0)
// Third party
print ''.img_object($langs->trans('ShowCompany'),'company').' '.$objp->name.' | ';
// Expected to pay
- print ''.price($objp->total_ttc).' | ';
- // Status
- print ''.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).' | ';
+ print ''.price($objp->total_ttc).' | ';
// Payed
- print ''.price($objp->amount).' | ';
+ print ''.price($objp->amount).' | ';
+ // Status
+ print ''.$facturestatic->LibStatut($objp->paye, $objp->fk_statut, 6, 1).' | ';
print "\n";
+
if ($objp->paye == 1)
{
$allow_delete = 0;