diff --git a/htdocs/fourn/paiement/fiche.php b/htdocs/fourn/paiement/fiche.php
index 8d640d1c006..697c09458ba 100644
--- a/htdocs/fourn/paiement/fiche.php
+++ b/htdocs/fourn/paiement/fiche.php
@@ -89,9 +89,6 @@ if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user-
llxHeader();
-$paiement = new PaiementFourn($db);
-$paiement->fetch($_GET['id']);
-
$html = new Form($db);
$h=0;
@@ -108,246 +105,260 @@ $h++;
dol_fiche_head($head, $hselected, $langs->trans('SupplierPayment'), 0, 'payment');
-/*
- * Confirmation de la suppression du paiement
- */
-if ($_GET['action'] == 'delete')
+$paiement = new PaiementFourn($db);
+$result=$paiement->fetch($_GET['id']);
+if ($result > 0)
{
- $ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete');
- if ($ret == 'html') print '
';
-}
-/*
- * Confirmation de la validation du paiement
- */
-if ($_GET['action'] == 'valide')
-{
- $ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide');
- if ($ret == 'html') print '
';
-}
-
-if (!empty($_POST['action']) && $_POST['action'] == 'update_num' && !empty($_POST['new_num']))
-{
- $res = $paiement->update_num($_POST['new_num']);
- if ($res === 0) {
- $mesg = '
'.$langs->trans('PaymentNumberUpdateSucceeded').'
';
- } else {
- $mesg = ''.$langs->trans('PaymentNumberUpdateFailed').'
';
- }
-}
-
-if (!empty($_POST['action']) && $_POST['action'] == 'update_date' && !empty($_POST['reday']))
-{
- $datepaye = dol_mktime(12, 0 , 0,
- $_POST['remonth'],
- $_POST['reday'],
- $_POST['reyear']);
- $res = $paiement->update_date($datepaye);
- if ($res === 0) {
- $mesg = ''.$langs->trans('PaymentDateUpdateSucceeded').'
';
- } else {
- $mesg = ''.$langs->trans('PaymentDateUpdateFailed').'
';
- }
-}
-
-
-print '';
-
-print '';
-print '| '.$langs->trans('Ref').' | '.$paiement->id.' |
';
-
-//switch through edition options for date (only available when statut is -not 1- (=validated))
-if (empty($_GET['action']) || $_GET['action']!='edit_date')
-{
- print '| ';
- print '';
- print ' | ';
- print ''.dol_print_date($paiement->date,'day').' |
';
-}
-else
-{
- print '';
- print '| '.$langs->trans('Date').' | ';
- print '';
- print '';
- print ' | ';
- print '
';
-}
-
-print '| '.$langs->trans('Type').' | '.$paiement->type_libelle.' |
';
-
-//switch through edition options for number (only available when statut is -not 1- (=validated))
-if (empty($_GET['action']) || $_GET['action'] != 'edit_num')
-{
- print '| ';
- print '';
- print ' | ';
- print ''.$paiement->numero.' |
';
-}
-else
-{
- print '';
- print '| '.$langs->trans('Numero').' | ';
- print '';
- print ' | ';
- print '
';
-}
-print '| '.$langs->trans('Amount').' | '.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).' |
';
-
-if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
-{
- print '| '.$langs->trans('Status').' | '.$paiement->getLibStatut(4).' |
';
-}
-
-print '| '.$langs->trans('Note').' | '.nl2br($paiement->note).' |
';
-
-if ($conf->banque->enabled)
-{
- if ($paiement->bank_account)
+ /*
+ * Confirmation de la suppression du paiement
+ */
+ if ($_GET['action'] == 'delete')
{
- // Si compte renseigne, on affiche libelle
- $bank=new Account($db);
- $bank->fetch($paiement->bank_account);
+ $ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete');
+ if ($ret == 'html') print '
';
+ }
- $bankline=new AccountLine($db);
- $bankline->fetch($paiement->bank_line);
+ /*
+ * Confirmation de la validation du paiement
+ */
+ if ($_GET['action'] == 'valide')
+ {
+ $ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide');
+ if ($ret == 'html') print '
';
+ }
+ if (!empty($_POST['action']) && $_POST['action'] == 'update_num' && !empty($_POST['new_num']))
+ {
+ $res = $paiement->update_num($_POST['new_num']);
+ if ($res === 0) {
+ $mesg = ''.$langs->trans('PaymentNumberUpdateSucceeded').'
';
+ } else {
+ $mesg = ''.$langs->trans('PaymentNumberUpdateFailed').'
';
+ }
+ }
+
+ if (!empty($_POST['action']) && $_POST['action'] == 'update_date' && !empty($_POST['reday']))
+ {
+ $datepaye = dol_mktime(12, 0 , 0,
+ $_POST['remonth'],
+ $_POST['reday'],
+ $_POST['reyear']);
+ $res = $paiement->update_date($datepaye);
+ if ($res === 0) {
+ $mesg = ''.$langs->trans('PaymentDateUpdateSucceeded').'
';
+ } else {
+ $mesg = ''.$langs->trans('PaymentDateUpdateFailed').'
';
+ }
+ }
+
+
+ print '';
+
+ print '';
+ print '| '.$langs->trans('Ref').' | '.$paiement->id.' |
';
+
+ //switch through edition options for date (only available when statut is -not 1- (=validated))
+ if (empty($_GET['action']) || $_GET['action']!='edit_date')
+ {
+ print '| ';
+ print '';
+ print ' | ';
+ print ''.dol_print_date($paiement->date,'day').' |
';
+ }
+ else
+ {
print '';
- print '| '.$langs->trans('BankAccount').' | ';
- print ''.img_object($langs->trans('ShowAccount'),'account').' '.$bank->label.' | ';
- print ''.$langs->trans('BankLineConciliated').' | '.yn($bankline->rappro).' | ';
+ print ''.$langs->trans('Date').' | ';
+ print '';
+ print '';
+ print ' | ';
print '
';
}
-}
-print '
';
+ print '| '.$langs->trans('Type').' | '.$paiement->type_libelle.' |
';
-if ($mesg) print '
'.$mesg;
-
-print '
';
-
-/**
- * Liste des factures
- */
-$allow_delete = 1 ;
-$sql = 'SELECT f.rowid as ref, f.facnumber as ref_supplier, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.rowid as socid';
-$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
-$sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
-$sql .= ' AND pf.fk_paiementfourn = '.$paiement->id;
-$resql=$db->query($sql);
-if ($resql)
-{
- $num = $db->num_rows($resql);
-
- $i = 0;
- $total = 0;
- print ''.$langs->trans("Invoices").'
';
- print '';
- print '';
- 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 "
\n";
-
- if ($num > 0)
+ //switch through edition options for number (only available when statut is -not 1- (=validated))
+ if (empty($_GET['action']) || $_GET['action'] != 'edit_num')
{
- $var=True;
+ print '| ';
+ print '';
+ print ' | ';
+ print ''.$paiement->numero.' |
';
+ }
+ else
+ {
+ print '';
+ print '| '.$langs->trans('Numero').' | ';
+ print '';
+ print ' | ';
+ print '
';
+ }
+ print '| '.$langs->trans('Amount').' | '.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).' |
';
- $facturestatic=new FactureFournisseur($db);
+ if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
+ {
+ print '| '.$langs->trans('Status').' | '.$paiement->getLibStatut(4).' |
';
+ }
- while ($i < $num)
+ print '| '.$langs->trans('Note').' | '.nl2br($paiement->note).' |
';
+
+ if ($conf->banque->enabled)
+ {
+ if ($paiement->bank_account)
{
- $objp = $db->fetch_object($resql);
- $var=!$var;
- print '';
- // Ref
- print '| '.img_object($langs->trans('ShowBill'),'bill').' ';
- print $objp->ref;
- print " | \n";
- // Ref supplier
- print ''.$objp->ref_supplier." | \n";
- // Third party
- print ''.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.' | ';
- // Expected to pay
- print ''.price($objp->total_ttc).' | ';
- // Status
- print ''.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).' | ';
- // Payed
- print ''.price($objp->amount).' | ';
- print "
\n";
- if ($objp->paye == 1)
- {
- $allow_delete = 0;
- }
- $total = $total + $objp->amount;
- $i++;
+ // Si compte renseigne, on affiche libelle
+ $bank=new Account($db);
+ $bank->fetch($paiement->bank_account);
+
+ $bankline=new AccountLine($db);
+ $bankline->fetch($paiement->bank_line);
+
+ print '';
+ print '| '.$langs->trans('BankAccount').' | ';
+ print ''.img_object($langs->trans('ShowAccount'),'account').' '.$bank->label.' | ';
+ print ''.$langs->trans('BankLineConciliated').' | '.yn($bankline->rappro).' | ';
+ print '
';
}
}
- $var=!$var;
- print "
\n";
- $db->free($resql);
+ print '
';
+
+ if ($mesg) print '
'.$mesg;
+
+ print '
';
+
+ /**
+ * Liste des factures
+ */
+ $allow_delete = 1 ;
+ $sql = 'SELECT f.rowid as ref, f.facnumber as ref_supplier, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.rowid as socid';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
+ $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
+ $sql .= ' AND pf.fk_paiementfourn = '.$paiement->id;
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+
+ $i = 0;
+ $total = 0;
+ print ''.$langs->trans("Invoices").'
';
+ print '';
+ print '';
+ 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 "
\n";
+
+ if ($num > 0)
+ {
+ $var=True;
+
+ $facturestatic=new FactureFournisseur($db);
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($resql);
+ $var=!$var;
+ print '';
+ // Ref
+ print '| '.img_object($langs->trans('ShowBill'),'bill').' ';
+ print $objp->ref;
+ print " | \n";
+ // Ref supplier
+ print ''.$objp->ref_supplier." | \n";
+ // Third party
+ print ''.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.' | ';
+ // Expected to pay
+ print ''.price($objp->total_ttc).' | ';
+ // Status
+ print ''.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).' | ';
+ // Payed
+ print ''.price($objp->amount).' | ';
+ print "
\n";
+ if ($objp->paye == 1)
+ {
+ $allow_delete = 0;
+ }
+ $total = $total + $objp->amount;
+ $i++;
+ }
+ }
+ $var=!$var;
+
+ print "
\n";
+ $db->free($resql);
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+
+ print '';
+
+
+ /*
+ * Boutons Actions
+ */
+
+ print '';
+ if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
+ {
+ if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '')
+ {
+ if ($user->rights->fournisseur->facture->valider)
+ {
+ print '
'.$langs->trans('Valid').'';
+
+ }
+ }
+ }
+ if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '')
+ {
+ if ($user->rights->fournisseur->facture->supprimer)
+ {
+ print '
'.$langs->trans('Delete').'';
+
+ }
+ }
+ print '
';
+
}
else
{
- dol_print_error($db);
+ $langs->load("errors");
+ print $langs->trans("ErrorRecordNotFound");
}
-print '';
-
-
-/*
- * Boutons Actions
- */
-
-print '';
-if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
-{
- if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '')
- {
- if ($user->rights->fournisseur->facture->valider)
- {
- print '
'.$langs->trans('Valid').'';
-
- }
- }
-}
-if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '')
-{
- if ($user->rights->fournisseur->facture->supprimer)
- {
- print '
'.$langs->trans('Delete').'';
-
- }
-}
-print '
';
+dol_fiche_end();
$db->close();