diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index 3aee8a79e45..c9a45e37bd7 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -22,6 +22,17 @@ require("./pre.inc.php"); require("../../paiement.class.php"); +$user->getrights('facture'); + +if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"] == 'yes' && $user->rights->facture->creer) +{ + $paiement = new Paiement($db); + $paiement->id = $_GET["id"]; + if ( $paiement->delete() ) + { + Header("Location: liste.php"); + } +} /* * * @@ -31,39 +42,107 @@ llxHeader(); print '
'; print 'Paiement'; -//print 'Info'; +print 'Info'; print '
'; print '
'; - /* - * Visualisation de la fiche - * - */ - - $paiement = new Paiement($db); - $paiement->fetch($_GET["id"]); +/* + * Visualisation de la fiche + * + */ - print ''; +$paiement = new Paiement($db); +$paiement->fetch($_GET["id"]); +$html = new Form($db); - print ''; +print "
Numéro : '.$paiement->numero."
"; +/* + * Confirmation de la suppression de la facture + * + */ + if ($_GET["action"] == 'delete') + { + $html->form_confirm("$PHP_SELF?id=$paiement->id","Supprimer le paiement","Etes-vous sûr de vouloir supprimer ce paiement ?","confirm_delete"); + } + - print 'Montant : '.$paiement->montant." ".MAIN_MONNAIE."
"; +print ''; - print ''; - print "
"; +print '
Numéro : '.$paiement->numero."
"; - print nl2br($paiement->note); +print 'Date : '.strftime("%d %B %Y",$paiement->date)." 
"; +print 'Type : '.$paiement->type_libelle." 
"; + +print 'Montant : '.$paiement->montant." ".MAIN_MONNAIE."
"; + +print '
"; + +print nl2br($paiement->note); + +/* + * + * + */ +$allow_delete = 1 ; +$sql = "SELECT f.facnumber, f.total_ttc, pf.amount, f.rowid as facid, f.paye, s.nom, s.idp"; +$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf,".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."societe as s"; +$sql .= " WHERE pf.fk_facture = f.rowid AND f.fk_soc = s.idp"; +$sql .= " AND pf.fk_paiement = ".$paiement->id; + +if ($db->query($sql)) +{ + $num = $db->num_rows(); + + $i = 0; + + print '
'; + print ''; + print ''; + print ''; + print "\n"; + + if ($num > 0) + { + $var=True; + + while ($i < $num) + { + $objp = $db->fetch_object($i); + $var=!$var; + + print ""; + print '\n"; + print ''; + print ""; + print "\n"; + if ($objp->paye == 1) + { + $allow_delete = 0; + } + $i++; + } + } + print "
FactureSociétéMontant TTC
' . $objp->facnumber; + print "' . $objp->nom.'".price($objp->amount)."
\n"; + $db->free(); +} + + +/* + * + * + */ print "
"; - if ($user->societe_id == 0) + if ($user->societe_id == 0 && $allow_delete) { print '
'; - - print 'Editer'; + // L'edition est pour l'instant inutile + //print 'Editer'; - print 'Supprimer'; + print 'Supprimer'; print "
"; }