diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php new file mode 100644 index 00000000000..5c0d3bb6cbb --- /dev/null +++ b/htdocs/compta/dons/fiche.php @@ -0,0 +1,290 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ +require("./pre.inc.php"); +require("../../don.class.php"); +require("../../paiement.class.php"); + +$db = new Db(); + +if ($action == 'add') +{ + + if ($amount > 0) + { + + $don = new Don($db); + + $don->nom = $nom; + $don->adresse = $adresse; + $don->amount = $amount; + $don->cp = $cp; + $don->ville = $ville; + $don->date = $db->idate(mktime(12, 0 , 0, $remonth, $reday, $reyear)); + $don->note = $note; + $don->public = $public; + $don->projetid = $projetid; + $don->modepaiement = $modepaiement; + + if ($don->create($user->id) ) + { + + Header("Location: index.php"); + + } + } + else + { + print "Erreur"; + $action = "create"; + } + +} + +if ($action == 'delete') +{ + $don = new Don($db); + $don->delete($rowid); +} +if ($action == 'valid_promesse') +{ + $don = new Don($db); + if ($don->valid_promesse($rowid, $user->id)) + { + Header("Location: liste.php?statut=0"); + } +} +if ($action == 'set_paye') +{ + $don = new Don($db); + if ($don->set_paye($rowid)) + { + Header("Location: liste.php?statut=1"); + } +} +if ($action == 'set_encaisse') +{ + $don = new Don($db); + if ($don->set_encaisse($rowid)) + { + Header("Location: liste.php?statut=2"); + } +} + + + +llxHeader(); + +if ($action == 'create') { + + $sql = "SELECT s.nom,s.idp, f.amount, f.total, f.facnumber"; + $sql .= " FROM societe as s, llx_facture as f WHERE f.fk_soc = s.idp"; + $sql .= " AND f.rowid = $facid"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows(); + if ($num) { + $obj = $db->fetch_object( 0); + + $total = $obj->total; + } + } + print_titre("Saisir un don"); + print "
"; + print ''; + + print ""; + print ""; + print "facnumber\">"; + print "idp\">"; + print "nom\">"; + + print ""; + + print '"; + + $author = $GLOBALS["REMOTE_USER"]; + print "\n"; + + + print "\n"; + + print "\n"; + + print "\n"; + + + + print ''; + print ''; + print ''; + + print ''; + + print ''; + print "\n"; + print "
Date du don :"; + print_date_select(); + print "Commentaires :
'; + print "
Type :\n"; + + $paiement = new Paiement($db); + + $paiement->select("modepaiement","crédit"); + + print "
Projet :
"; + print "
Don public :
"; + print "
Nom
Adresse
CP Ville
Montant euros
\n"; + + +} +/* ************************************************************************** */ +/* */ +/* */ +/* */ +/* ************************************************************************** */ +if ($rowid > 0 && $action == 'edit') +{ + + $don = new Don($db); + $don->id = $rowid; + $don->fetch($rowid); + + print_titre("Traitement du don"); + + print ''; + + print ""; + + print ''; + + $author = $GLOBALS["REMOTE_USER"]; + print "\n"; + + if ($don->statut > 0) + { + + print "\n"; + } + print ''; + + print "\n"; + + + + print ''; + print ''; + print ''; + + print ''; + + print "
Date du don :"; + print strftime("%d %B %Y",$don->date); + print "Commentaires :
'; + print nl2br($don->note).'
Type :"; + + $paiement = new Paiement($db); + + $paiement->select("modepaiement","crédit", $don->modepaiement); + + print "
Projet :'.$don->projet.'
Don public :"; + + print $yn[$don->public]; + print "
Nom'.$don->nom.' 
Adresse'.$don->adresse.' 
CP Ville'.$don->cp.' '.$don->ville.' 
Montant'.price($don->amount).' euros
\n"; + + + print "

"; + + + if ($don->statut == 0) + { + print ""; + } + else + { + print ""; + } + + if ($don->statut == 1 && $resteapayer > 0) + { + print ""; + } + else + { + print ""; + } + + if ($don->statut == 1 && abs($resteapayer == 0) && $don->paye == 0) + { + print ""; + } + else + { + print ""; + } + + if ($don->statut == 0) + { + print ""; + } + elseif ($don->statut == 2) + { + print ""; + } + else + { + print ""; + } + + print "
[id&action=delete\">Supprimer]-[Emettre un paiement]-[id&action=set_paye\">Classer 'Payé']-[id&action=valid_promesse\">Valider la promesse]id&action=set_encaisse\">Encaissé-

"; + +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/dons/index.php b/htdocs/compta/dons/index.php new file mode 100644 index 00000000000..95edcdf3ed2 --- /dev/null +++ b/htdocs/compta/dons/index.php @@ -0,0 +1,84 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ +require("./pre.inc.php"); + +llxHeader(); + +$db = new Db(); + + +$sql = "SELECT sum(d.amount) as somme , d.fk_statut FROM llx_don as d GROUP BY d.fk_statut"; + +$result = $db->query($sql); + +if ($result) +{ + $num = $db->num_rows(); + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + + $somme[$objp->fk_statut] = $objp->somme; + $i++; + } + $db->free(); +} + +print_barre_liste("Dons", $page, $PHP_SELF); + +$libelle[0] = "Promesses non validées"; +$libelle[1] = "Promesses validées"; +$libelle[2] = "Dons payés"; +$libelle[3] = "Dons encaissés"; + +print ''; +print ''; +print ""; +print ""; +print "\n"; + +$var=True; + +for ($i = 0 ; $i < 4 ; $i++) +{ + $var=!$var; + print ""; + if ($somme[$i]) + { + print ''; + } + else + { + print ''; + } + print ''; + print ""; +} +print "
 Somme
'.$libelle[$i].''.$libelle[$i].''.price($somme[$i]).'
"; + + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/don.class.php b/htdocs/don.class.php index 4196675021a..9702986c734 100644 --- a/htdocs/don.class.php +++ b/htdocs/don.class.php @@ -24,15 +24,26 @@ class Don { var $id; var $db; - var $facid; - var $datepaye; var $amount; - var $author; - var $paiementid; // numero du paiement dans le cas ou une facture paye +ieur fois - var $num_paiement; + var $nom; + var $adresse; + var $cp; + var $ville; + var $date; + var $pays; + var $public; + var $projetid; + var $modepaiement; var $note; + var $statut; + + var $projet; /* - * + * Statut du don + * 0 : promesse non validée + * 1 : promesse validée + * 2 : don validé + * 3 : don payé * * */ @@ -45,29 +56,168 @@ class Don * * */ - Function create() + Function create($userid) { /* * Insertion dans la base */ - $sql = "INSERT INTO llx_paiement (fk_facture, datec, datep, amount, author, fk_paiement, num_paiement, note)"; - $sql .= " VALUES ($this->facid, now(), $this->datepaye,$this->amount,'$this->author', $this->paiementid, '$this->num_paiement', '$this->note')"; + $sql = "INSERT INTO llx_don (datec, amount, fk_paiement, nom, adresse, cp, ville, pays, public, fk_don_projet, note, fk_user_author, datedon)"; + $sql .= " VALUES (now(), $this->amount, $this->modepaiement,'$this->nom','$this->adresse', '$this->cp','$this->ville','$this->pays',$this->public, $this->projetid, '$this->note', $userid, '$this->date')"; $result = $this->db->query($sql); if ($result) { - $label = "Facture $this->facnumber - $this->societe"; - $sql = "INSERT INTO llx_bank (datec, dateo, amount, author, label)"; - $sql .= " VALUES (now(), $this->datepaye, $this->amount,'$this->author', '$this->label')"; - $result = $this->db->query($sql); + return 1; } else { - print "$sql"; + print $this->db->error(); + print "


$sql

"; + return 0; } } + /* + * Suppression du don + * + */ + Function delete($rowid) + { + + $sql = "DELETE FROM llx_don WHERE rowid = $rowid AND fk_statut = 0;"; + + if ( $this->db->query( $sql) ) + { + if ( $this->db->affected_rows() ) + { + return 1; + } + else + { + return 0; + } + } + else + { + print "Err : ".$this->db->error(); + return 0; + } + } + /* + * Fetch + * + * + */ + Function fetch($rowid) + { + $sql = "SELECT d.rowid, ".$this->db->pdate("d.datedon")." as datedon, d.nom, d.amount, p.libelle as projet, d.fk_statut, d.adresse, d.cp, d.ville, d.public, d.amount, d.fk_paiement"; + $sql .= " FROM llx_don as d, llx_don_projet as p"; + $sql .= " WHERE p.rowid = d.fk_don_projet AND d.rowid = $rowid"; + + if ( $this->db->query( $sql) ) + { + if ($this->db->num_rows()) + { + + $obj = $this->db->fetch_object(0); + + $this->date = $obj->datedon; + $this->nom = $obj->nom; + $this->statut = $obj->fk_statut; + $this->adresse = $obj->adresse; + $this->cp = $obj->cp; + $this->ville = $obj->ville; + $this->projet = $obj->projet; + $this->public = $obj->public; + $this->modepaiement = $obj->modepaiement; + $this->amount = $obj->amount; + } + } + else + { + print $this->db->error(); + } + + } + /* + * Suppression du don + * + */ + Function valid_promesse($rowid, $userid) + { + + $sql = "UPDATE llx_don SET fk_statut = 1, fk_user_valid = $userid WHERE rowid = $rowid AND fk_statut = 0;"; + + if ( $this->db->query( $sql) ) + { + if ( $this->db->affected_rows() ) + { + return 1; + } + else + { + return 0; + } + } + else + { + print "Err : ".$this->db->error(); + return 0; + } + } + /* + * Classé comme payé, le don a été recu + * + */ + Function set_paye($rowid) + { + + $sql = "UPDATE llx_don SET fk_statut = 2 WHERE rowid = $rowid AND fk_statut = 1;"; + + if ( $this->db->query( $sql) ) + { + if ( $this->db->affected_rows() ) + { + return 1; + } + else + { + return 0; + } + } + else + { + print "Err : ".$this->db->error(); + return 0; + } + } + /* + * Classé comme encaissé + * + */ + Function set_encaisse($rowid) + { + + $sql = "UPDATE llx_don SET fk_statut = 3 WHERE rowid = $rowid AND fk_statut = 2;"; + + if ( $this->db->query( $sql) ) + { + if ( $this->db->affected_rows() ) + { + return 1; + } + else + { + return 0; + } + } + else + { + print "Err : ".$this->db->error(); + return 0; + } + } } ?> diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php new file mode 100644 index 00000000000..e3d67e837ea --- /dev/null +++ b/htdocs/html.form.class.php @@ -0,0 +1,97 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +class Form { + var $db; + var $errorstr; + + + Function Form($DB) + { + + $this->db = $DB; + + return 1; + } + /* + * + * + * + */ + + Function select($name, $sql, $id='') + { + + $result = $this->db->query($sql); + if ($result) + { + + print '"; + } + else + { + print $this->db->error(); + } + + } + /* + * Renvoie la chaîne de caractère décrivant l'erreur + * + * + */ + Function error() + { + return $this->errorstr; + } + + +} + +?> diff --git a/htdocs/lib/functions.inc.php3 b/htdocs/lib/functions.inc.php3 index 637be7b2eeb..28f093b5301 100644 --- a/htdocs/lib/functions.inc.php3 +++ b/htdocs/lib/functions.inc.php3 @@ -21,6 +21,9 @@ * */ +$yn[0] = "non"; +$yn[1] = "oui"; + function transcoS2L($zonein,$devise) { // Open source offert par alainfloch@free.fr 28/10/2001, sans garantie. @@ -294,28 +297,52 @@ function print_date_select() { $smonth = 1; $syear = date("Y", time()); - + $cday = date("d", time()); + print ""; $cmonth = date("n", time()); print ""; print "\n"; } diff --git a/htdocs/paiement.class.php b/htdocs/paiement.class.php index e9a1abb8a1e..2d26ba558e9 100644 --- a/htdocs/paiement.class.php +++ b/htdocs/paiement.class.php @@ -75,14 +75,23 @@ class Paiement * * */ - Function select($name) + Function select($name, $filtre='', $id='') { $form = new Form($this->db); - $sql = "SELECT id, libelle FROM c_paiement ORDER BY id"; - - $form->select($name, $sql); - + if ($filtre == 'crédit') + { + $sql = "SELECT id, libelle FROM c_paiement WHERE type IN (0,2) ORDER BY libelle"; + } + elseif ($filtre == 'débit') + { + $sql = "SELECT id, libelle FROM c_paiement WHERE type IN (1,2) ORDER BY libelle"; + } + else + { + $sql = "SELECT id, libelle FROM c_paiement ORDER BY libelle"; + } + $form->select($name, $sql, $id); } } diff --git a/htdocs/pre.inc.php3 b/htdocs/pre.inc.php3 index dd7074b9bcf..1215b2275e1 100644 --- a/htdocs/pre.inc.php3 +++ b/htdocs/pre.inc.php3 @@ -22,7 +22,6 @@ require ("./main.inc.php3"); - function llxHeader($head = "") { global $user, $conf; @@ -34,7 +33,8 @@ function llxHeader($head = "") { $menu = new Menu(); - $menu->add("/societe.php", "Sociétés"); + $menu->add("/societe.php", "Sociétés","company"); + $menu->add_submenu("../soc.php3?&action=create", "Nouvelle société"); $menu->add("/comm/index.php3", "Commercial"); @@ -62,17 +62,20 @@ function llxHeader($head = "") { $menu->add("/adherents/", "Adherents"); + $menu->add("/compta/dons/", "Dons"); + $menu->add("/user/", "Utilisateurs"); $menu->add("/info.php3", "Configuration"); - if ($conf->voyage) { + if ($conf->voyage) + { - $menu->add("/compta/voyage/index.php3","Voyages"); + $menu->add("/compta/voyage/index.php3","Voyages"); - $menu->add_submenu("/compta/voyage/index.php3","Voyages"); - $menu->add_submenu("/compta/voyage/reduc.php3","Reduc"); - } + $menu->add_submenu("/compta/voyage/index.php3","Voyages"); + $menu->add_submenu("/compta/voyage/reduc.php3","Reduc"); + } $menu->add("/domain/", "Domaines"); diff --git a/htdocs/user/fiche.php3 b/htdocs/user/fiche.php3 index e9562984822..d93ca9ef604 100644 --- a/htdocs/user/fiche.php3 +++ b/htdocs/user/fiche.php3 @@ -26,7 +26,7 @@ llxHeader(); $db = new Db(); -if ($action == 'add') +if ($action == 'add' && $user->admin) { $service = new Service($db); @@ -37,34 +37,42 @@ if ($action == 'add') $id = $service->create($user->id); - if ($comm_now && $id) { - $service->start_comm($id, $user->id); - } + if ($comm_now && $id) + { + $service->start_comm($id, $user->id); + } } -if ($action == 'set_datedeb') +if ($action == 'update' && $user->admin) { - $service = new Service($db); - $service->start_comm($id, $user->id, $datedeb); -} -if ($action == 'set_datefin') { - $service = new Service($db); - $service->stop_comm($id, $user->id, $datefin); + $edituser = new User($db, $id); + $edituser->fetch(); + + $edituser->nom = $nom; + $edituser->prenom = $prenom; + $edituser->login = $login; + $edituser->email = $email; + + if (! $edituser->update($id, $user)) + { + print $edituser->error(); + } } -if ($action == 'update') { - $service = new Service($db); +if ($action == 'password' && $user->admin) +{ + $edituser = new User($db, $id); + $edituser->fetch(); - $service->ref = $ref; - $service->libelle = $label; - $service->price = $price; - $service->description = $desc; - - $service->update($id, $user); + if ($edituser->password()) + { + print "Mot de passe changé et envoyé à $edituser->email

"; + } } + /* ************************************************************************** */ /* */ /* Nouvel utilisateur */ @@ -107,87 +115,88 @@ if ($action == 'create') } /* ************************************************************************** */ /* */ -/* Visue et edition */ +/* Visu et edition */ /* */ /* ************************************************************************** */ else { - if ($id) { - $fuser = new User($db, $id); - $fuser->fetch(); + if ($id) + { + $fuser = new User($db, $id); + $fuser->fetch(); - print '

Fiche utilisateur

'; + print '
Fiche utilisateur

'; - print ''; + print '
'; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - print '
Nom'.$fuser->nom.'Prénom'.$fuser->prenom.'
Login'.$fuser->login.'Pass'.$fuser->pass.'
Webcal Login'.$fuser->webcal_login.'Pass'.$fuser->pass.'
'; - - - print '
'; - - print ''; - print ''; - print ''; - print ''; - print ''; - - - print '
Barre d\'action[Editer]---

'; - - /* ************************************************************************** */ - /* */ - /* Edition */ - /* */ - /* ************************************************************************** */ - - if ($action == 'edit') { - print '
Edition de l\'utilisateur

'; - print '
'; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - - print ''; - print ''; - + print ''; + print ''; + print ''; + print ''; - print ''; - - + print ''; + print ''; + print ''; - print '"; + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; print '
Nom'.$user->id.'
Nom
Prénom
'.$fuser->nom.'Prénom'.$fuser->prenom.'
Login
'.$fuser->login.'Email'.$fuser->email.'
Description'; - print "
Webcal Login'.$fuser->webcal_login.'Administrateur'.$yn[$fuser->admin].'
'; + + print '
'; + + print ''; + print ''; + print ''; + print ''; + + + print '
[Editer]-[Nouveau mot de passe]-

'; + + /* ************************************************************************** */ + /* */ + /* Edition */ + /* */ + /* ************************************************************************** */ + + if ($action == 'edit' && $user->admin) + { + print '
Edition de l\'utilisateur

'; + print '
'; + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + + print '"; + + print ''; + print ''; + print '
Id'.$fuser->id.'
Nom
Prénom
Login
Email
Description'; + print "
'; + } + } - - - } - + }