Possibilit de saisir une adhsion 0
This commit is contained in:
parent
0c10226d81
commit
383188362d
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.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 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
*
|
||||
@ -36,6 +36,7 @@
|
||||
*/
|
||||
|
||||
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();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, datec, dateadh, cotisation)";
|
||||
$sql .= " VALUES (".$this->id.", now(), ".$this->db->idate($date).", ".$montant.")";
|
||||
// Create subscription
|
||||
$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);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
$rowid=$cotisation->create($user);
|
||||
|
||||
if ($rowid > 0)
|
||||
{
|
||||
$rowid=$this->db->last_insert_id(MAIN_DB_PREFIX."cotisation");
|
||||
|
||||
// datefin = date + 1 an - 1 jour
|
||||
$datefin = dolibarr_time_plus_duree($date,1,'y');
|
||||
$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.= " WHERE rowid =". $this->id;
|
||||
|
||||
dolibarr_syslog("Adherent::cotisation sql=".$sql);
|
||||
dolibarr_syslog("Adherent::cotisation update member sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -986,7 +989,9 @@ class Adherent
|
||||
if ($inserturlid > 0)
|
||||
{
|
||||
// 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);
|
||||
if (! $resql)
|
||||
{
|
||||
@ -1037,8 +1042,7 @@ class Adherent
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog("Adherent::cotisation error ".$this->error);
|
||||
$this->error=$cotisation->error;
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -253,6 +253,7 @@ print '<td valign="top" width="50%">';
|
||||
*/
|
||||
$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.= " b.rowid as bid,";
|
||||
$sql.= " ba.rowid as baid, ba.label, ba.bank";
|
||||
$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";
|
||||
@ -294,7 +295,7 @@ while ($i < $num)
|
||||
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE)
|
||||
{
|
||||
print '<td align="right">';
|
||||
if ($objp->fk_bank)
|
||||
if ($objp->bid)
|
||||
{
|
||||
$accountstatic->label=$objp->label;
|
||||
$accountstatic->id=$objp->baid;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -17,191 +18,74 @@
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/*! \file htdocs/adherents/cotisation.class.php
|
||||
/**
|
||||
\file htdocs/adherents/cotisation.class.php
|
||||
\ingroup adherent
|
||||
\brief Fichier de la classe permettant de gèrer les cotisations
|
||||
\author Rodolphe Quiedeville
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
/*! \class Cotisation
|
||||
\brief Classe permettant de gèrer les cotisations
|
||||
*/
|
||||
|
||||
/**
|
||||
\class Cotisation
|
||||
\brief Classe permettant de gèrer les cotisations
|
||||
*/
|
||||
class Cotisation
|
||||
{
|
||||
var $id;
|
||||
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 $errors;
|
||||
|
||||
var $datec;
|
||||
var $datem;
|
||||
var $dateh;
|
||||
var $fk_adherent;
|
||||
var $amount;
|
||||
var $note;
|
||||
var $fk_bank;
|
||||
|
||||
|
||||
/**
|
||||
\brief Cotisation
|
||||
\param DB Handler base de données
|
||||
\param socid ID societe
|
||||
*/
|
||||
function Cotisation($DB, $socid="")
|
||||
function Cotisation($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];
|
||||
}
|
||||
$this->db = $DB;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
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
|
||||
\param userid userid de l'adhérent
|
||||
\brief Fonction qui permet de créer le don
|
||||
\param userid userid de celui qui insere
|
||||
\return int <0 si KO, Id cotisation créé si OK
|
||||
*/
|
||||
function create($userid)
|
||||
{
|
||||
/*
|
||||
* Insertion dans la base
|
||||
*/
|
||||
|
||||
$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')";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, datec, dateadh, cotisation, note)";
|
||||
$sql .= " VALUES (".$this->fk_adherent.", now(), ".$this->db->idate($this->dateh).", ".$this->amount.",'".$this->note."')";
|
||||
|
||||
dolibarr_syslog("Cotisation::create sql=".$sql);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
return $this->db->last_insert_id(MAIN_DB_PREFIX."don");
|
||||
return $this->db->last_insert_id(MAIN_DB_PREFIX."cotisation");
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
$this->error=$this->db->error().' sql='.$sql;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\TODO A ecrire
|
||||
\brief fonction qui permet de mettre à jour le don
|
||||
\param userid userid de l'adhérent
|
||||
*/
|
||||
|
||||
function update($userid)
|
||||
{
|
||||
|
||||
@ -239,20 +123,20 @@ class Cotisation
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief fonction qui permet de supprimer le don
|
||||
\param rowid
|
||||
/**
|
||||
\brief Fonction qui permet de supprimer la cotisation
|
||||
\param rowid Id cotisation
|
||||
\return int <0 si KO, 0 si OK mais non trouve, >0 si OK
|
||||
*/
|
||||
|
||||
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;";
|
||||
|
||||
if ( $this->db->query( $sql) )
|
||||
dolibarr_syslog("Cotisation::delete sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ( $this->db->affected_rows() )
|
||||
if ( $this->db->affected_rows($resql))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@ -263,72 +147,39 @@ class Cotisation
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
$this->error=$this->db->error();
|
||||
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)
|
||||
{
|
||||
$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 .= " FROM ".MAIN_DB_PREFIX."don as d, ".MAIN_DB_PREFIX."don_projet as p, ".MAIN_DB_PREFIX."c_paiement as cp";
|
||||
$sql="SELECT fk_adherent, datec, tms, dateadh, cotisation, note, fk_bank";
|
||||
$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";
|
||||
|
||||
if ( $this->db->query( $sql) )
|
||||
dolibarr_syslog("Cotisation::fetch sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows())
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
|
||||
$obj = $this->db->fetch_object();
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->date = $obj->datedon;
|
||||
$this->prenom = stripslashes($obj->prenom);
|
||||
$this->nom = stripslashes($obj->nom);
|
||||
$this->societe = stripslashes($obj->societe);
|
||||
$this->statut = $obj->fk_statut;
|
||||
$this->adresse = stripslashes($obj->adresse);
|
||||
$this->cp = stripslashes($obj->cp);
|
||||
$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() )
|
||||
{
|
||||
$this->fk_adherent = $obj->fk_adherent;
|
||||
$this->datec = $obj->datec;
|
||||
$this->datem = $obj->tms;
|
||||
$this->dateh = $obj->dateadh;
|
||||
$this->amount = $obj->cotisation;
|
||||
$this->note = $obj->note;
|
||||
$this->fk_bank = $obj->fk_bank;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -338,51 +189,19 @@ class Cotisation
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
$this->error=$this->db->error();
|
||||
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='')
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
/**
|
||||
\TODO a ecrire
|
||||
\brief fonction qui permet de mettre un commentaire sur le don
|
||||
\param rowid
|
||||
\param commentaire
|
||||
*/
|
||||
|
||||
function set_commentaire($rowid, $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)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.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
|
||||
* 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."/compta/bank/account.class.php");
|
||||
|
||||
$user->getrights('adherent');
|
||||
$user->getrights('banque');
|
||||
|
||||
$langs->load("members");
|
||||
|
||||
$sortorder=$_GET["sortorder"];
|
||||
$sortfield=$_GET["sortfield"];
|
||||
$page=$_GET["page"];
|
||||
@ -46,74 +51,104 @@ $offset = $conf->liste_limit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
$msg='';
|
||||
$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
|
||||
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();
|
||||
$sql="SELECT cotisation FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid=".$_POST["rowid"]." ";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
if ($num>0)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$amount=$objp->cotisation;
|
||||
$acct=new Account($db,ADHERENT_BANK_ACCOUNT);
|
||||
$insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"],ADHERENT_BANK_CATEGORIE,$user);
|
||||
if ($insertid == '')
|
||||
{
|
||||
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"]." ";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
//Header("Location: cotisations.php");
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
// Met a jour la table cotisation
|
||||
$sql="UPDATE ".MAIN_DB_PREFIX."cotisation";
|
||||
$sql.=" SET fk_bank=".$insertid.",";
|
||||
$sql.=" note='".addslashes($_POST["label"])."'";
|
||||
$sql.=" WHERE rowid=".$_POST["rowid"];
|
||||
dolibarr_syslog("cotisations sql=".$sql);
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
//Header("Location: cotisations.php");
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
dolibarr_print_error($db,$cotisation->error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Affichage liste
|
||||
* Affichage page
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
if ($msg) print $msg.'<br>';
|
||||
|
||||
// Liste des cotisations
|
||||
$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.= " 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";
|
||||
@ -131,7 +166,6 @@ if ($result)
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
|
||||
$param.="&statut=$statut&date_select=$date_select";
|
||||
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("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";
|
||||
|
||||
$var=true;
|
||||
// Static objects
|
||||
$cotisation=new Cotisation($db);
|
||||
$adherent=new Adherent($db);
|
||||
$accountstatic=new Account($db);
|
||||
|
||||
$var=true;
|
||||
$total=0;
|
||||
while ($i < $num && $i < $conf->liste_limit)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$total+=price($objp->cotisation);
|
||||
|
||||
$cotisation=new Cotisation($db);
|
||||
$cotisation->ref=$objp->crowid;
|
||||
$cotisation->id=$objp->crowid;
|
||||
|
||||
$adherent=new Adherent($db);
|
||||
$adherent->ref=trim($objp->prenom.' '.$objp->nom);
|
||||
$adherent->id=$objp->rowid;
|
||||
|
||||
$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 '<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>';
|
||||
if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE)
|
||||
{
|
||||
if ($objp->fk_account)
|
||||
{
|
||||
$accountstatic=new Account($db);
|
||||
$accountstatic->id=$objp->fk_account;
|
||||
$accountstatic->fetch($objp->fk_account);
|
||||
//$accountstatic->label=$objp->label;
|
||||
@ -181,24 +223,44 @@ if ($result)
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>";
|
||||
print "<form method=\"post\" action=\"cotisations.php\">";
|
||||
print '<input type="hidden" name="action" value="2bank">';
|
||||
print '<input type="hidden" name="rowid" value="'.$objp->crowid.'">';
|
||||
$html = new Form($db);
|
||||
$html->select_types_paiements();
|
||||
print '<input name="num_chq" type="text" class="flat" size="6"> - ';
|
||||
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 "<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").'">';
|
||||
print "</form>\n";
|
||||
print "</td>\n";
|
||||
print "<td>";
|
||||
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.'">';
|
||||
$html = new Form($db);
|
||||
$html->select_comptes('','accountid',0,'',1);
|
||||
print '<br>';
|
||||
$html->select_types_paiements('','paymenttypeid');
|
||||
print '<input name="num_chq" type="text" class="flat" size="5">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
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>";
|
||||
$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;
|
||||
@ -210,6 +272,7 @@ if ($result)
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
print "<td align=\"right\">".price($total)."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ require(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
|
||||
require(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php");
|
||||
|
||||
$langs->load("members");
|
||||
|
||||
$user->getrights('adherent');
|
||||
|
||||
$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"];
|
||||
@ -41,10 +42,8 @@ $rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"];
|
||||
/*
|
||||
* 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"))
|
||||
{
|
||||
$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"))
|
||||
{
|
||||
$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->delete($rowid);
|
||||
@ -106,7 +103,7 @@ if ($_GET["action"] == 'delete')
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'commentaire')
|
||||
if ($user->rights->adherent->configurer && $_GET["action"] == 'commentaire')
|
||||
{
|
||||
$don = new Don($db);
|
||||
$don->set_commentaire($rowid,$_POST["commentaire"]);
|
||||
|
||||
@ -213,7 +213,7 @@ class Account
|
||||
// Verififcation parametres
|
||||
if (! $this->rowid)
|
||||
{
|
||||
$this->error="Account::addline rowid not defined";
|
||||
$this->error="Account::addline this->rowid not defined";
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -462,7 +462,6 @@ class Account
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
$sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro, url,";
|
||||
$sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix,";
|
||||
$sql.= " domiciliation, proprio, adresse_proprio,";
|
||||
@ -471,15 +470,17 @@ class Account
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
|
||||
$sql.= " WHERE rowid = ".$id;
|
||||
|
||||
dolibarr_syslog("Account::fetch sql=".$sql);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($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->type = $obj->courant;
|
||||
$this->courant = $obj->courant;
|
||||
@ -504,12 +505,18 @@ class Account
|
||||
$this->min_allowed = $obj->min_allowed;
|
||||
$this->min_desired = $obj->min_desired;
|
||||
$this->comment = $obj->comment;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user