* Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2006-2010 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/fourn/paiement/fiche.php * \ingroup facture, fournisseur * \brief Tab to show a payment of a supplier invoice * \remarks Fichier presque identique a compta/paiement/fiche.php * \version $Id: fiche.php,v 1.34 2011/07/31 23:57:03 eldy Exp $ */ require("../../main.inc.php"); require(DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'); require(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'); require(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'); $langs->load('bills'); $langs->load('banks'); $langs->load('companies'); $langs->load("suppliers"); $mesg=''; /* * Actions */ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->supprimer) { $db->begin(); $paiement = new PaiementFourn($db); $paiement->fetch($_GET['id']); $result = $paiement->delete(); if ($result > 0) { $db->commit(); Header('Location: '.DOL_URL_ROOT.'/fourn/facture/paiement.php'); exit; } else { $mesg='
'.$paiement->error.'
'; $db->rollback(); } } if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider) { $db->begin(); $paiement = new PaiementFourn($db); $paiement->id = $_GET['id']; if ($paiement->valide() >= 0) { $db->commit(); Header('Location: fiche.php?id='.$paiement->id); exit; } else { $mesg='
'.$paiement->error.'
'; $db->rollback(); } } /* * View */ llxHeader(); $html = new Form($db); $h=0; $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$_GET['id']; $head[$h][1] = $langs->trans('Card'); $hselected = $h; $h++; $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$_GET['id']; $head[$h][1] = $langs->trans('Info'); $h++; dol_fiche_head($head, $hselected, $langs->trans('SupplierPayment'), 0, 'payment'); $paiement = new PaiementFourn($db); $result=$paiement->fetch($_GET['id']); if ($result > 0) { /* * Confirmation de la suppression du paiement */ if ($_GET['action'] == 'delete') { $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 ''; //switch through edition options for date (only available when statut is -not 1- (=validated)) if (empty($_GET['action']) || $_GET['action']!='edit_date') { print ''; print ''; } else { print ''; print ''; print ''; print ''; } print ''; //switch through edition options for number (only available when statut is -not 1- (=validated)) if (empty($_GET['action']) || $_GET['action'] != 'edit_num') { print ''; print ''; } else { print ''; print ''; print ''; print ''; } print ''; if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) { print ''; } print ''; // Bank account if ($conf->banque->enabled) { if ($paiement->bank_account) { $bankline=new AccountLine($db); $bankline->fetch($paiement->bank_line); print ''; print ''; print ''; print ''; } } print '
'.$langs->trans('Ref').''.$paiement->id.'
'; print ''; if ($paiement->statut == 0 && $_GET['action'] != 'edit_date') print ''; print '
'; print $langs->trans('Date'); print ''.img_edit($langs->trans('Modify')).'
'; print '
'.dol_print_date($paiement->date,'day').'
'.$langs->trans('Date').''; print '
'; print ''; if (!empty($_POST['remonth']) && !empty($_POST['reday']) && !empty($_POST['reyear'])) $sel_date=dol_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); else $sel_date=$paiement->date; $html->select_date($sel_date,'','','','',"addpaiement"); print ''; print '
'; print '
'.$langs->trans('Type').''.$paiement->type_libelle.'
'; print ''; if ($paiement->statut == 0 && $_GET['action'] != 'edit_num') print ''; print '
'; print $langs->trans('Numero'); print ''.img_edit($langs->trans('Modify')).'
'; print '
'.$paiement->numero.'
'.$langs->trans('Numero').''; print '
'; print ''; if (!empty($_POST['new_num'])) $num = $this->db->escape($_POST['new_num']); else $num = $paiement->numero; print ''; print ''; print '
'.$langs->trans('Amount').''.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('Status').''.$paiement->getLibStatut(4).'
'.$langs->trans('Note').''.nl2br($paiement->note).'
'.$langs->trans('BankTransactionLine').''; print $bankline->getNomUrl(1,0,'showall'); 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 ''; print ''; print ''; print ''; print ''; print ''; print "\n"; if ($num > 0) { $var=True; $facturestatic=new FactureFournisseur($db); while ($i < $num) { $objp = $db->fetch_object($resql); $var=!$var; print ''; // Ref print '\n"; // Ref supplier print '\n"; // Third party print ''; // Expected to pay print ''; // Status print ''; // Payed print ''; print "\n"; if ($objp->paye == 1) { $allow_delete = 0; } $total = $total + $objp->amount; $i++; } } $var=!$var; print "
'.$langs->trans('Ref').''.$langs->trans('RefSupplier').''.$langs->trans('Company').''.$langs->trans('ExpectedToPay').''.$langs->trans('Status').''.$langs->trans('PayedByThisPayment').'
'.img_object($langs->trans('ShowBill'),'bill').' '; print $objp->ref; print "'.$objp->ref_supplier."'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.''.price($objp->total_ttc).''.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).''.price($objp->amount).'
\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 { $langs->load("errors"); print $langs->trans("ErrorRecordNotFound"); } dol_fiche_end(); $db->close(); llxFooter('$Date: 2011/07/31 23:57:03 $ - $Revision: 1.34 $'); ?>