Possibilité de saisir une adhésion à 0

This commit is contained in:
Laurent Destailleur 2007-05-28 13:14:50 +00:00
parent 0c10226d81
commit 383188362d
6 changed files with 231 additions and 367 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* *
@ -36,6 +36,7 @@
*/ */
require_once(DOL_DOCUMENT_ROOT."/includes/xmlrpc/xmlrpc.php"); require_once(DOL_DOCUMENT_ROOT."/includes/xmlrpc/xmlrpc.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php");
/** /**
@ -946,15 +947,17 @@ class Adherent
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, datec, dateadh, cotisation)"; // Create subscription
$sql .= " VALUES (".$this->id.", now(), ".$this->db->idate($date).", ".$montant.")"; $cotisation=new Cotisation($this->db);
$cotisation->fk_adherent=$this->id;
$cotisation->dateh=$date;
$cotisation->amount=$montant;
$cotisation->note=$label;
dolibarr_syslog("Adherent::cotisation sql=".$sql); $rowid=$cotisation->create($user);
$resql=$this->db->query($sql);
if ($resql) if ($rowid > 0)
{ {
$rowid=$this->db->last_insert_id(MAIN_DB_PREFIX."cotisation");
// datefin = date + 1 an - 1 jour // datefin = date + 1 an - 1 jour
$datefin = dolibarr_time_plus_duree($date,1,'y'); $datefin = dolibarr_time_plus_duree($date,1,'y');
$datefin = dolibarr_time_plus_duree($datefin,-1,'d'); $datefin = dolibarr_time_plus_duree($datefin,-1,'d');
@ -962,7 +965,7 @@ class Adherent
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET datefin = ".$this->db->idate($datefin); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET datefin = ".$this->db->idate($datefin);
$sql.= " WHERE rowid =". $this->id; $sql.= " WHERE rowid =". $this->id;
dolibarr_syslog("Adherent::cotisation sql=".$sql); dolibarr_syslog("Adherent::cotisation update member sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -986,7 +989,9 @@ class Adherent
if ($inserturlid > 0) if ($inserturlid > 0)
{ {
// Met a jour la table cotisation // Met a jour la table cotisation
$sql="UPDATE ".MAIN_DB_PREFIX."cotisation SET fk_bank=".$insertid." WHERE rowid=".$rowid;
$sql="UPDATE ".MAIN_DB_PREFIX."cotisation SET fk_bank=".$insertid." WHERE rowid=".$rowid;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) if (! $resql)
{ {
@ -1037,8 +1042,7 @@ class Adherent
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$cotisation->error;
dolibarr_syslog("Adherent::cotisation error ".$this->error);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }

View File

@ -253,6 +253,7 @@ print '<td valign="top" width="50%">';
*/ */
$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe,"; $sql = "SELECT d.rowid, d.prenom, d.nom, d.societe,";
$sql.= " c.rowid as crowid, c.cotisation, ".$db->pdate("c.dateadh")." as dateadh, c.fk_bank,"; $sql.= " c.rowid as crowid, c.cotisation, ".$db->pdate("c.dateadh")." as dateadh, c.fk_bank,";
$sql.= " b.rowid as bid,";
$sql.= " ba.rowid as baid, ba.label, ba.bank"; $sql.= " ba.rowid as baid, ba.label, ba.bank";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
@ -294,7 +295,7 @@ while ($i < $num)
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE) if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE)
{ {
print '<td align="right">'; print '<td align="right">';
if ($objp->fk_bank) if ($objp->bid)
{ {
$accountstatic->label=$objp->label; $accountstatic->label=$objp->label;
$accountstatic->id=$objp->baid; $accountstatic->id=$objp->baid;

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,191 +18,74 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/*! \file htdocs/adherents/cotisation.class.php /**
\file htdocs/adherents/cotisation.class.php
\ingroup adherent \ingroup adherent
\brief Fichier de la classe permettant de gèrer les cotisations \brief Fichier de la classe permettant de gèrer les cotisations
\author Rodolphe Quiedeville
\version $Revision$ \version $Revision$
*/ */
/*! \class Cotisation
\brief Classe permettant de gèrer les cotisations
*/
/**
\class Cotisation
\brief Classe permettant de gèrer les cotisations
*/
class Cotisation class Cotisation
{ {
var $id; var $id;
var $db; var $db;
var $date;
var $amount;
var $prenom;
var $nom;
var $societe;
var $adresse;
var $cp;
var $ville;
var $pays;
var $email;
var $public;
var $projetid;
var $modepaiement;
var $modepaiementid;
var $commentaire;
var $statut;
var $projet;
var $error; var $error;
var $errors;
var $datec;
var $datem;
var $dateh;
var $fk_adherent;
var $amount;
var $note;
var $fk_bank;
/** /**
\brief Cotisation \brief Cotisation
\param DB Handler base de données \param DB Handler base de données
\param socid ID societe
*/ */
function Cotisation($DB, $socid="") function Cotisation($DB)
{ {
$this->db = $DB ; $this->db = $DB;
$this->modepaiementid = 0;
}
/*
*
*
*/
function print_error_list()
{
$num = sizeof($this->error);
for ($i = 0 ; $i < $num ; $i++)
{
print "<li>" . $this->error[$i];
}
} }
/*
*
*
*/
function check($minimum=0)
{
$err = 0;
if (strlen(trim($this->societe)) == 0)
{
if ((strlen(trim($this->nom)) + strlen(trim($this->prenom))) == 0)
{
$error_string[$err] = "Vous devez saisir vos nom et prénom ou le nom de votre société.";
$err++;
}
}
if (strlen(trim($this->adresse)) == 0)
{
$error_string[$err] = "L'adresse saisie est invalide";
$err++;
}
if (strlen(trim($this->cp)) == 0)
{
$error_string[$err] = "Le code postal saisi est invalide";
$err++;
}
if (strlen(trim($this->ville)) == 0)
{
$error_string[$err] = "La ville saisie est invalide";
$err++;
}
if (strlen(trim($this->email)) == 0)
{
$error_string[$err] = "L'email saisi est invalide";
$err++;
}
$this->amount = trim($this->amount);
$map = range(0,9);
for ($i = 0; $i < strlen($this->amount) ; $i++)
{
if (!isset($map[substr($this->amount, $i, 1)] ))
{
$error_string[$err] = "Le montant du don contient un/des caractère(s) invalide(s)";
$err++;
$amount_invalid = 1;
break;
}
}
if (! $amount_invalid)
{
if ($this->amount == 0)
{
$error_string[$err] = "Le montant du don est null";
$err++;
}
else
{
if ($this->amount < $minimum && $minimum > 0)
{
$error_string[$err] = "Le montant minimum du don est de $minimum";
$err++;
}
}
}
/*
* Return errors
*
*/
if ($err)
{
$this->error = $error_string;
return 0;
}
else
{
return 1;
}
}
/** /**
\brief fonction qui permet de créer le don \brief Fonction qui permet de créer le don
\param userid userid de l'adhérent \param userid userid de celui qui insere
\return int <0 si KO, Id cotisation créé si OK
*/ */
function create($userid) function create($userid)
{ {
/* $sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, datec, dateadh, cotisation, note)";
* Insertion dans la base $sql .= " VALUES (".$this->fk_adherent.", now(), ".$this->db->idate($this->dateh).", ".$this->amount.",'".$this->note."')";
*/
$this->date = $this->db->idate($this->date);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."don (datec, amount, fk_paiement,prenom, nom, societe,adresse, cp, ville, pays, public, fk_don_projet, note, fk_user_author, datedon, email)";
$sql .= " VALUES (now(), $this->amount, $this->modepaiementid,'$this->prenom','$this->nom','$this->societe','$this->adresse', '$this->cp','$this->ville','$this->pays',$this->public, $this->projetid, '$this->commentaire', $userid, '$this->date','$this->email')";
dolibarr_syslog("Cotisation::create sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
return $this->db->last_insert_id(MAIN_DB_PREFIX."don"); return $this->db->last_insert_id(MAIN_DB_PREFIX."cotisation");
} }
else else
{ {
dolibarr_print_error($this->db); $this->error=$this->db->error().' sql='.$sql;
return 0; return -1;
} }
} }
/*! /*!
\TODO A ecrire
\brief fonction qui permet de mettre à jour le don \brief fonction qui permet de mettre à jour le don
\param userid userid de l'adhérent \param userid userid de l'adhérent
*/ */
function update($userid) function update($userid)
{ {
@ -239,20 +123,20 @@ class Cotisation
} }
} }
/*! /**
\brief fonction qui permet de supprimer le don \brief Fonction qui permet de supprimer la cotisation
\param rowid \param rowid Id cotisation
\return int <0 si KO, 0 si OK mais non trouve, >0 si OK
*/ */
function delete($rowid) function delete($rowid)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid = ".$rowid;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;"; dolibarr_syslog("Cotisation::delete sql=".$sql);
$resql=$this->db->query($sql);
if ( $this->db->query( $sql) ) if ($resql)
{ {
if ( $this->db->affected_rows() ) if ( $this->db->affected_rows($resql))
{ {
return 1; return 1;
} }
@ -263,72 +147,39 @@ class Cotisation
} }
else else
{ {
dolibarr_print_error($this->db); $this->error=$this->db->error();
return 0; return -1;
} }
} }
/*!
\brief fonction qui permet de récupèrer le don /**
\param rowid \brief Fonction qui permet de récupèrer une cotisation
\param rowid Id cotisation
\return int <0 si KO, =0 si OK mais non trouve, >0 si OK
*/ */
function fetch($rowid) function fetch($rowid)
{ {
$sql = "SELECT d.rowid, ".$this->db->pdate("d.datedon")." as datedon, d.prenom, d.nom, d.societe, d.amount, p.libelle as projet, d.fk_statut, d.adresse, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.fk_don_projet"; $sql="SELECT fk_adherent, datec, tms, dateadh, cotisation, note, fk_bank";
$sql .= " FROM ".MAIN_DB_PREFIX."don as d, ".MAIN_DB_PREFIX."don_projet as p, ".MAIN_DB_PREFIX."c_paiement as cp"; $sql.=" FROM ".MAIN_DB_PREFIX."cotisation";
$sql.=" WHERE rowid=".$rowid;
$sql .= " WHERE p.rowid = d.fk_don_projet AND cp.id = d.fk_paiement AND d.rowid = $rowid"; dolibarr_syslog("Cotisation::fetch sql=".$sql);
$resql=$this->db->query($sql);
if ( $this->db->query( $sql) ) if ($resql)
{ {
if ($this->db->num_rows()) if ($this->db->num_rows($resql))
{ {
$obj = $this->db->fetch_object($resql);
$obj = $this->db->fetch_object();
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->date = $obj->datedon; $this->fk_adherent = $obj->fk_adherent;
$this->prenom = stripslashes($obj->prenom); $this->datec = $obj->datec;
$this->nom = stripslashes($obj->nom); $this->datem = $obj->tms;
$this->societe = stripslashes($obj->societe); $this->dateh = $obj->dateadh;
$this->statut = $obj->fk_statut; $this->amount = $obj->cotisation;
$this->adresse = stripslashes($obj->adresse); $this->note = $obj->note;
$this->cp = stripslashes($obj->cp); $this->fk_bank = $obj->fk_bank;
$this->ville = stripslashes($obj->ville);
$this->email = stripslashes($obj->email);
$this->pays = stripslashes($obj->pays);
$this->projet = $obj->projet;
$this->projetid = $obj->fk_don_projet;
$this->public = $obj->public;
$this->modepaiementid = $obj->fk_paiement;
$this->modepaiement = $obj->libelle;
$this->amount = $obj->amount;
$this->commentaire = stripslashes($obj->note);
}
}
else
{
print $this->db->error();
}
}
/*!
\brief fonction qui permet de valider la promesse de don
\param rowid
\param userid userid de l'adhérent
*/
function valid_promesse($rowid, $userid)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."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; return 1;
} }
else else
@ -338,51 +189,19 @@ class Cotisation
} }
else else
{ {
dolibarr_print_error($this->db); $this->error=$this->db->error();
return 0; return -1;
} }
} }
/*!
\brief fonction qui permet de définir la cotisation comme payée
\param rowid rowid de la cotisation
\param modepaiement mode de paiement
*/
function set_paye($rowid, $modepaiement='') /**
{ \TODO a ecrire
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2";
if ($modepaiement)
{
$sql .= ", fk_paiement=$modepaiement";
}
$sql .= " WHERE rowid = $rowid AND fk_statut = 1;";
if ( $this->db->query( $sql) )
{
if ( $this->db->affected_rows() )
{
return 1;
}
else
{
return 0;
}
}
else
{
dolibarr_print_error($this->db);
return 0;
}
}
/*!
\brief fonction qui permet de mettre un commentaire sur le don \brief fonction qui permet de mettre un commentaire sur le don
\param rowid \param rowid
\param commentaire \param commentaire
*/ */
function set_commentaire($rowid, $commentaire='') function set_commentaire($rowid, $commentaire='')
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET note = '$commentaire'"; $sql = "UPDATE ".MAIN_DB_PREFIX."don SET note = '$commentaire'";
@ -407,33 +226,6 @@ class Cotisation
} }
} }
/*!
\brief fonction qui permet de mettre le don comme encaiss
\param rowid
*/
function set_encaisse($rowid)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."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
{
dolibarr_print_error($this->db);
return 0;
}
}
/** /**
* \brief Renvoie nom clicable (avec eventuellement le picto) * \brief Renvoie nom clicable (avec eventuellement le picto)

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -33,6 +33,11 @@ require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php");
$user->getrights('adherent');
$user->getrights('banque');
$langs->load("members");
$sortorder=$_GET["sortorder"]; $sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"]; $sortfield=$_GET["sortfield"];
$page=$_GET["page"]; $page=$_GET["page"];
@ -46,74 +51,104 @@ $offset = $conf->liste_limit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
$msg='';
$date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"]; $date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"];
// Desactivation fonctions insertions en banque apres coup
// Cette fonction me semble pas utile. Si on a fait des adhesions alors que module banque
// pas actif c'est qu'on voulait pas d'insertion en banque.
// si on active apres coup, on va pas modifier toutes les adhesions pour avoir une ecriture
// en banque mais on va mettre le solde banque direct a la valeur apres toutes les adhésions.
$allowinsertbankafter=0;
/*
* Actions
*/
// Insertion de la cotisation dans le compte banquaire // Insertion de la cotisation dans le compte banquaire
if ($_POST["action"] == '2bank' && $_POST["rowid"] !='') if ($allowinsertbankafter && $user->rights->banque->modifier && $_POST["action"] == '2bank' && $_POST["rowid"] !='')
{ {
if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0) if (defined("ADHERENT_BANK_USE") && $conf->global->ADHERENT_BANK_USE)
{ {
if (! $_POST["accountid"])
{
$msg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("BankAccount")).'</div>';
}
if (! $_POST["paymenttypeid"])
{
$msg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("OperationType")).'</div>';
}
// \todo Créer une facture et enregistrer son paiement // Créer un tiers + facture et enregistrer son paiement ? -> Non requis avec module compta expert
// Eventuellement offrir option a la creation adhesion
if (! $msg)
{
$db->begin();
$dateop=time();
$cotisation=new Cotisation($db);
$result=$cotisation->fetch($_POST["rowid"]);
$adherent=new Adherent($db);
$result=$adherent->fetch($cotisation->fk_adherent);
if ($result > 0)
{
$amount=$cotisation->amount;
$acct=new Account($db);
$acct->fetch($_POST["accountid"]);
$insertid=$acct->addline($dateop, $_POST["paymenttypeid"], $_POST["label"], $amount, $_POST["num_chq"],ADHERENT_BANK_CATEGORIE,$user);
if ($insertid < 0)
{
dolibarr_print_error($db,$acct->error);
}
else
{
$inserturlid=$acct->add_url_line($insertid, $adherent->rowid, DOL_URL_ROOT.'/adherents/fiche.php?rowid=', $adherent->getFullname(), 'member');
$dateop=time(); // Met a jour la table cotisation
$sql="SELECT cotisation FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid=".$_POST["rowid"]." "; $sql="UPDATE ".MAIN_DB_PREFIX."cotisation";
$result = $db->query($sql); $sql.=" SET fk_bank=".$insertid.",";
if ($result) $sql.=" note='".addslashes($_POST["label"])."'";
{ $sql.=" WHERE rowid=".$_POST["rowid"];
$num = $db->num_rows($result); dolibarr_syslog("cotisations sql=".$sql);
if ($num>0) $result = $db->query($sql);
{ if ($result)
$objp = $db->fetch_object($result); {
$amount=$objp->cotisation; //Header("Location: cotisations.php");
$acct=new Account($db,ADHERENT_BANK_ACCOUNT); $db->commit();
$insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"],ADHERENT_BANK_CATEGORIE,$user); }
if ($insertid == '') else
{ {
dolibarr_print_error($db); $db->rollback();
} dolibarr_print_error($db);
else }
{ }
// met a jour la table cotisation }
$sql="UPDATE ".MAIN_DB_PREFIX."cotisation SET fk_bank=$insertid WHERE rowid=".$_POST["rowid"]." "; else
$result = $db->query($sql); {
if ($result) $db->rollback();
{ dolibarr_print_error($db,$cotisation->error);
//Header("Location: cotisations.php"); }
} }
else
{
dolibarr_print_error($db);
}
}
}
else
{
dolibarr_print_error($db);
}
}
else
{
dolibarr_print_error($db);
}
} }
} }
/* /*
* Affichage liste * Affichage page
*/ */
llxHeader(); llxHeader();
if ($msg) print $msg.'<br>';
// Liste des cotisations // Liste des cotisations
$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe,"; $sql = "SELECT d.rowid, d.prenom, d.nom, d.societe,";
$sql.= " c.cotisation, ".$db->pdate("c.dateadh")." as dateadh, c.fk_bank as bank, c.rowid as crowid,"; $sql.= " c.rowid as crowid, c.cotisation, ".$db->pdate("c.dateadh")." as dateadh, c.fk_bank as bank, c.note,";
$sql.= " b.fk_account"; $sql.= " b.fk_account";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
@ -131,7 +166,6 @@ if ($result)
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
$param.="&amp;statut=$statut&amp;date_select=$date_select"; $param.="&amp;statut=$statut&amp;date_select=$date_select";
print_barre_liste($langs->trans("ListOfSubscriptions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num); print_barre_liste($langs->trans("ListOfSubscriptions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num);
@ -146,34 +180,42 @@ if ($result)
{ {
print_liste_field_titre($langs->trans("Bank"),"cotisations.php","b.fk_account",$pram,"","",$sortfield); print_liste_field_titre($langs->trans("Bank"),"cotisations.php","b.fk_account",$pram,"","",$sortfield);
} }
print_liste_field_titre($langs->trans("Amount"),"cotisations.php","c.cotisation",$param,"","align=\"right\"",$sortfield); print_liste_field_titre($langs->trans("Label"),"cotisations.php","c.note",$param,"",'align="left"',$sortfield);
print_liste_field_titre($langs->trans("Amount"),"cotisations.php","c.cotisation",$param,"",'align="right"',$sortfield);
print "</tr>\n"; print "</tr>\n";
$var=true; // Static objects
$cotisation=new Cotisation($db);
$adherent=new Adherent($db);
$accountstatic=new Account($db);
$var=true;
$total=0; $total=0;
while ($i < $num && $i < $conf->liste_limit) while ($i < $num && $i < $conf->liste_limit)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$total+=price($objp->cotisation); $total+=price($objp->cotisation);
$cotisation=new Cotisation($db);
$cotisation->ref=$objp->crowid; $cotisation->ref=$objp->crowid;
$cotisation->id=$objp->crowid; $cotisation->id=$objp->crowid;
$adherent=new Adherent($db);
$adherent->ref=trim($objp->prenom.' '.$objp->nom); $adherent->ref=trim($objp->prenom.' '.$objp->nom);
$adherent->id=$objp->rowid; $adherent->id=$objp->rowid;
$var=!$var; $var=!$var;
if ($allowinsertbankafter && $user->rights->banque->modifier && ! $objp->fk_account && $conf->banque->enabled && $conf->global->ADHERENT_BANK_USE && $objp->cotisation)
{
print "<form method=\"post\" action=\"cotisations.php\">";
}
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'.$cotisation->getNomUrl(1).'</td>'; print '<td>'.$cotisation->getNomUrl(1).'</td>';
print '<td>'.dolibarr_print_date($objp->dateadh)."</td>\n"; print '<td>'.dolibarr_print_date($objp->dateadh,'day')."</td>\n";
print '<td>'.$adherent->getNomUrl(1).'</td>'; print '<td>'.$adherent->getNomUrl(1).'</td>';
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE) if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE)
{ {
if ($objp->fk_account) if ($objp->fk_account)
{ {
$accountstatic=new Account($db);
$accountstatic->id=$objp->fk_account; $accountstatic->id=$objp->fk_account;
$accountstatic->fetch($objp->fk_account); $accountstatic->fetch($objp->fk_account);
//$accountstatic->label=$objp->label; //$accountstatic->label=$objp->label;
@ -181,24 +223,44 @@ if ($result)
} }
else else
{ {
print "<td>"; print "<td>";
print "<form method=\"post\" action=\"cotisations.php\">"; if ($allowinsertbankafter && $user->rights->banque->modifier && $objp->cotisation)
print '<input type="hidden" name="action" value="2bank">'; {
print '<input type="hidden" name="rowid" value="'.$objp->crowid.'">'; print '<input type="hidden" name="action" value="2bank">';
$html = new Form($db); print '<input type="hidden" name="rowid" value="'.$objp->crowid.'">';
$html->select_types_paiements(); $html = new Form($db);
print '<input name="num_chq" type="text" class="flat" size="6">&nbsp;-&nbsp;'; $html->select_comptes('','accountid',0,'',1);
print "<input name=\"label\" type=\"text\" class=\"flat\" size=\"30\" value=\"".$langs->trans("Subscriptions").' '.stripslashes($objp->prenom)." ".stripslashes($objp->nom)." ".strftime("%Y",$objp->dateadh)."\" >\n"; print '<br>';
// print "<td><input name=\"debit\" type=\"text\" size=8></td>"; $html->select_types_paiements('','paymenttypeid');
// print "<td><input name=\"credit\" type=\"text\" size=8></td>"; print '<input name="num_chq" type="text" class="flat" size="5">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; }
print "</form>\n"; else
print "</td>\n"; {
print '&nbsp;';
}
print "</td>\n";
} }
} }
print '<td align="right">'.price($objp->cotisation).'</td>'; print '<td>';
if ($allowinsertbankafter && $user->rights->banque->modifier && ! $objp->fk_account && $conf->banque->enabled && $conf->global->ADHERENT_BANK_USE && $objp->cotisation)
{
print "<input name=\"label\" type=\"text\" class=\"flat\" size=\"30\" value=\"".$langs->trans("Subscriptions").' '.strftime("%Y",$objp->dateadh)."\" >\n";
// print "<td><input name=\"debit\" type=\"text\" size=8></td>";
// print "<td><input name=\"credit\" type=\"text\" size=8></td>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
}
else
{
print dolibarr_trunc($objp->note,32);
}
print '</td>';
print '<td align="right">'.price($objp->cotisation).'</td>';
print "</tr>"; print "</tr>";
$i++; if ($allowinsertbankafter && $user->rights->banque->modifier && ! $objp->fk_account && $conf->banque->enabled && $conf->global->ADHERENT_BANK_USE && $objp->cotisation)
{
print "</form>\n";
}
$i++;
} }
$var=!$var; $var=!$var;
@ -210,6 +272,7 @@ if ($result)
{ {
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
} }
print '<td>&nbsp;</td>';
print "<td align=\"right\">".price($total)."</td>\n"; print "<td align=\"right\">".price($total)."</td>\n";
print "</tr>\n"; print "</tr>\n";

View File

@ -33,6 +33,7 @@ require(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
require(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); require(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php");
$langs->load("members"); $langs->load("members");
$user->getrights('adherent'); $user->getrights('adherent');
$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"]; $rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"];
@ -41,10 +42,8 @@ $rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"];
/* /*
* Actions * Actions
*/ */
if ($_POST["action"] == 'add') if ($user->rights->adherent->configurer && $_POST["action"] == 'add')
{ {
if (! $user->rights->adherent->configurer) accessforbidden();
if ($_POST["button"] != $langs->trans("Cancel")) if ($_POST["button"] != $langs->trans("Cancel"))
{ {
$adht = new AdherentType($db); $adht = new AdherentType($db);
@ -77,10 +76,8 @@ if ($_POST["action"] == 'add')
} }
} }
if ($_POST["action"] == 'update') if ($user->rights->adherent->configurer && $_POST["action"] == 'update')
{ {
if (! $user->rights->adherent->creer) accessforbidden();
if ($_POST["button"] != $langs->trans("Cancel")) if ($_POST["button"] != $langs->trans("Cancel"))
{ {
$adht = new AdherentType($db); $adht = new AdherentType($db);
@ -98,7 +95,7 @@ if ($_POST["action"] == 'update')
} }
} }
if ($_GET["action"] == 'delete') if ($user->rights->adherent->configurer && $_GET["action"] == 'delete')
{ {
$adht = new AdherentType($db); $adht = new AdherentType($db);
$adht->delete($rowid); $adht->delete($rowid);
@ -106,7 +103,7 @@ if ($_GET["action"] == 'delete')
exit; exit;
} }
if ($_GET["action"] == 'commentaire') if ($user->rights->adherent->configurer && $_GET["action"] == 'commentaire')
{ {
$don = new Don($db); $don = new Don($db);
$don->set_commentaire($rowid,$_POST["commentaire"]); $don->set_commentaire($rowid,$_POST["commentaire"]);

View File

@ -213,7 +213,7 @@ class Account
// Verififcation parametres // Verififcation parametres
if (! $this->rowid) if (! $this->rowid)
{ {
$this->error="Account::addline rowid not defined"; $this->error="Account::addline this->rowid not defined";
return -1; return -1;
} }
@ -462,7 +462,6 @@ class Account
*/ */
function fetch($id) function fetch($id)
{ {
$this->id = $id;
$sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro, url,"; $sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro, url,";
$sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix,"; $sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix,";
$sql.= " domiciliation, proprio, adresse_proprio,"; $sql.= " domiciliation, proprio, adresse_proprio,";
@ -471,15 +470,17 @@ class Account
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql.= " WHERE rowid = ".$id; $sql.= " WHERE rowid = ".$id;
dolibarr_syslog("Account::fetch sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
if ($this->db->num_rows($result)) if ($this->db->num_rows($result))
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->ref = $obj->ref; $this->id = $obj->rowid; // deprecated
$this->rowid = $obj->rowid;
$this->ref = $obj->ref;
$this->label = $obj->label; $this->label = $obj->label;
$this->type = $obj->courant; $this->type = $obj->courant;
$this->courant = $obj->courant; $this->courant = $obj->courant;
@ -504,12 +505,18 @@ class Account
$this->min_allowed = $obj->min_allowed; $this->min_allowed = $obj->min_allowed;
$this->min_desired = $obj->min_desired; $this->min_desired = $obj->min_desired;
$this->comment = $obj->comment; $this->comment = $obj->comment;
return 1;
} }
else
{
return 0;
}
$this->db->free($result); $this->db->free($result);
} }
else else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
return -1;
} }
} }