diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index 8a0573855bb..8969545971f 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -45,6 +45,17 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user- Header("Location: liste.php"); } } + +if ($_POST["action"] == 'confirm_valide' && $_POST["confirm"] == 'yes' && $user->rights->facture->creer) +{ + $paiement = new Paiement($db); + $paiement->id = $_GET["id"]; + if ( $paiement->valide() == 0 ) + { + Header("Location: fiche.php?id=".$paiement->id); + } +} + /* * * @@ -68,15 +79,25 @@ $paiement->fetch($_GET["id"]); $html = new Form($db); /* - * Confirmation de la suppression de la facture + * Confirmation de la suppression du paiement * */ if ($_GET["action"] == 'delete') { - print '
'; + print '
'; $html->form_confirm("fiche.php?id=$paiement->id","Supprimer le paiement","Etes-vous sûr de vouloir supprimer ce paiement ?","confirm_delete"); + print '
'; + } + if ($_GET["action"] == 'valide') + { + print '
'; + $html->form_confirm("fiche.php?id=$paiement->id","Valider le paiement","Etes-vous sûr de vouloir valider ce paiment, auncune modification n'est possible une fois le paiement validé ?","confirm_valide"); + print '
'; + + } + print ''; @@ -157,20 +178,22 @@ if ($db->query($sql)) * * */ - print "
"; +print "
"; +print '
'; - if ($user->societe_id == 0 && $allow_delete) - { - print '
'; +if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET["action"] == '') +{ + print ''.$langs->trans("Valider").''; +} - if ($_GET["action"] != 'delete') { - print ''.$langs->trans("Delete").''; - } - - print "
"; - } - $db->close(); +if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET["action"] == '') +{ + print ''.$langs->trans("Delete").''; + +} +print "
"; +$db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?> diff --git a/htdocs/paiement.class.php b/htdocs/paiement.class.php index 24fbcfa131c..f6b3f59815d 100644 --- a/htdocs/paiement.class.php +++ b/htdocs/paiement.class.php @@ -62,13 +62,13 @@ class Paiement } /** - * \brief Recupére l'objet paiement + * \brief Récupère l'objet paiement * \param id id du paiement a récupérer */ function fetch($id) { - $sql = "SELECT p.rowid,".$this->db->pdate("p.datep")." as dp, p.amount"; + $sql = "SELECT p.rowid,".$this->db->pdate("p.datep")." as dp, p.amount, p.statut"; $sql .=", c.libelle as paiement_type, p.num_paiement"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as c"; $sql .= " WHERE p.fk_paiement = c.id"; @@ -87,6 +87,7 @@ class Paiement $this->montant = $obj->amount; $this->note = $obj->note; $this->type_libelle = $obj->paiement_type; + $this->statut = $obj->statut; return 1; } @@ -210,7 +211,7 @@ class Paiement $form->select($name, $sql, $id); } - /* + /** * * * @@ -257,6 +258,24 @@ class Paiement } } + /** + * \brief Valide la paiement + */ + function valide() + { + $sql = "UPDATE ".MAIN_DB_PREFIX."paiement SET statut = 1 WHERE rowid = ".$this->id; + $result = $this->db->query($sql); + if ($result) + { + return 0; + } + else + { + dolibarr_syslog("Paiement::Valide Error -1"); + return -1; + } + } + /* * \brief Information sur l'objet * \param id id du paiement dont il faut afficher les infos