Ejemplo n.º 1
1
 /**
  * Exclude object from result
  *
  * @param   Cotisation $cotisation Object to remove from the list of results
  *
  * @return CotisationQuery The current query, for fluid interface
  */
 public function prune($cotisation = null)
 {
     if ($cotisation) {
         $this->addUsingAlias(CotisationPeer::ID, $cotisation->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Ejemplo n.º 2
1
 public function addCotisation($login, $debut, $fin, $montant)
 {
     // vérification des droits en écriture et accès aux cotisations
     if (!$this->auth->getDroitEcriture() || !$this->auth->getDroitCotisations()) {
         throw new ApiException(403);
     }
     // récupération de la personne concernée
     $personne = PersonneQuery::create()->findOneByLogin($login);
     if (!$personne) {
         throw new ApiException(404);
     }
     // On récupère toutes les cotisations de ce user
     $cotisations = $personne->getCotisations();
     // Si une de ces cotisations englobe la nouvelle cotisation, on la refuse
     foreach ($cotisations as $cotisation) {
         if ($debut >= strtotime($cotisation->getDebut()) && $fin <= strtotime($cotisation->getFin()) && !$cotisation->getDeletedAt()) {
             throw new ApiException(409);
         }
     }
     // création de la nouvelle cotisation
     $cotisation = new Cotisation();
     $cotisation->setDebut($debut);
     $cotisation->setFin($fin);
     $cotisation->setPersonne($personne);
     $cotisation->setMontant($montant);
     // sauvegarde
     $cotisation->save();
     return $cotisation->getid();
 }
Ejemplo n.º 3
0
 /**
  *	Fonction qui insere la cotisation dans la base de donnees
  *	et eventuellement liens dans banques, mailman, etc...
  *	@param	    date        	Date d'effet de la cotisation
  *	@param	    montant     	Montant cotisation (accepte 0 pour les adherents non soumis e cotisation)
  *	@param		account_id		Id compte bancaire
  *	@param		operation		Type operation (si Id compte bancaire fourni)
  *	@param		label			Label operation (si Id compte bancaire fourni)
  *	@param		num_chq			Numero cheque (si Id compte bancaire fourni)
  *	@param		emetteur_nom	Nom emetteur cheque
  *	@param		emetteur_banque	Nom banque emetteur cheque
  *	@param		datesubend		Date fin adhesion
  *	@return     int         	rowid de l'entree ajoutee, <0 si erreur
  */
 function cotisation($date, $montant, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0)
 {
     global $conf, $langs, $user;
     // Clean parameters
     if (!$montant) {
         $montant = 0;
     }
     $this->db->begin();
     if ($datesubend) {
         $datefin = $datesubend;
     } else {
         // If no end date, end date = date + 1 year - 1 day
         $datefin = dol_time_plus_duree($date, 1, 'y');
         $datefin = dol_time_plus_duree($datefin, -1, 'd');
     }
     // Create subscription
     $cotisation = new Cotisation($this->db);
     $cotisation->fk_adherent = $this->id;
     $cotisation->dateh = $date;
     // Date of new subscription
     $cotisation->datef = $datefin;
     // End data of new subscription
     $cotisation->amount = $montant;
     $cotisation->note = $label;
     $rowid = $cotisation->create($user);
     if ($rowid > 0) {
         // Update denormalized subscription end date (read database subscription to find values)
         // This will also update this->datefin
         $result = $this->update_end_date($user);
         if ($result > 0) {
             // Change properties of object (used by triggers)
             $this->last_subscription_date = $dateop;
             $this->last_subscription_amount = $montant;
             $this->last_subscription_date_start = $date;
             $this->last_subscription_date_end = $datefin;
             $this->use_webcal = $conf->global->PHPWEBCALENDAR_MEMBERSTATUS == 'always' ? 1 : 0;
             // Appel des triggers
             include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
             $interface = new Interfaces($this->db);
             $result = $interface->run_triggers('MEMBER_SUBSCRIPTION', $this, $user, $langs, $conf);
             if ($result < 0) {
                 $error++;
                 $this->errors = $interface->errors;
             }
             // Fin appel triggers
             $this->db->commit();
             return $rowid;
         } else {
             $this->db->rollback();
             return -2;
         }
     } else {
         $this->error = $cotisation->error;
         $this->db->rollback();
         return -1;
     }
 }
Ejemplo n.º 4
0
 if ($action != 'addsubscription' && $action != 'create_thirdparty') {
     $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe,";
     $sql .= " c.rowid as crowid, c.cotisation,";
     $sql .= " c.datec,";
     $sql .= " c.dateadh as dateh,";
     $sql .= " c.datef,";
     $sql .= " 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";
     $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_account as ba ON b.fk_account = ba.rowid";
     $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=" . $rowid;
     $result = $db->query($sql);
     if ($result) {
         $cotisationstatic = new Cotisation($db);
         $accountstatic = new Account($db);
         $num = $db->num_rows($result);
         $i = 0;
         print "<table class=\"noborder\" width=\"100%\">\n";
         print '<tr class="liste_titre">';
         print '<td>' . $langs->trans("Ref") . '</td>';
         print '<td align="center">' . $langs->trans("DateCreation") . '</td>';
         print '<td align="center">' . $langs->trans("DateStart") . '</td>';
         print '<td align="center">' . $langs->trans("DateEnd") . '</td>';
         print '<td align="right">' . $langs->trans("Amount") . '</td>';
         if (!empty($conf->banque->enabled)) {
             print '<td align="right">' . $langs->trans("Account") . '</td>';
         }
         print "</tr>\n";
         $var = True;
Ejemplo n.º 5
0
 /**
  *	Insert subscription into database and eventually add links to banks, mailman, etc...
  *
  *	@param	int	        $date        		Date of effect of subscription
  *	@param	double		$montant     		Amount of subscription (0 accepted for some members)
  *	@param	int			$accountid			Id bank account
  *	@param	string		$operation			Type operation (if Id bank account provided)
  *	@param	string		$label				Label operation (if Id bank account provided)
  *	@param	string		$num_chq			Numero cheque (if Id bank account provided)
  *	@param	string		$emetteur_nom		Name of cheque writer
  *	@param	string		$emetteur_banque	Name of bank of cheque
  *	@param	int     	$datesubend			Date end subscription
  *	@return int         					rowid of record added, <0 if KO
  */
 function cotisation($date, $montant, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0)
 {
     global $conf, $langs, $user;
     require_once DOL_DOCUMENT_ROOT . '/adherents/class/cotisation.class.php';
     $error = 0;
     // Clean parameters
     if (!$montant) {
         $montant = 0;
     }
     $this->db->begin();
     if ($datesubend) {
         $datefin = $datesubend;
     } else {
         // If no end date, end date = date + 1 year - 1 day
         $datefin = dol_time_plus_duree($date, 1, 'y');
         $datefin = dol_time_plus_duree($datefin, -1, 'd');
     }
     // Create subscription
     $cotisation = new Cotisation($this->db);
     $cotisation->fk_adherent = $this->id;
     $cotisation->dateh = $date;
     // Date of new subscription
     $cotisation->datef = $datefin;
     // End data of new subscription
     $cotisation->amount = $montant;
     $cotisation->note = $label;
     $rowid = $cotisation->create($user);
     if ($rowid > 0) {
         // Update denormalized subscription end date (read database subscription to find values)
         // This will also update this->datefin
         $result = $this->update_end_date($user);
         if ($result > 0) {
             // Change properties of object (used by triggers)
             $this->last_subscription_date = dol_now();
             $this->last_subscription_amount = $montant;
             $this->last_subscription_date_start = $date;
             $this->last_subscription_date_end = $datefin;
             // Call trigger
             $result = $this->call_trigger('MEMBER_SUBSCRIPTION', $user);
             if ($result < 0) {
                 $error++;
             }
             // End call triggers
         }
         if (!$error) {
             $this->db->commit();
             return $rowid;
         } else {
             $this->db->rollback();
             return -2;
         }
     } else {
         $this->error = $cotisation->error;
         $this->db->rollback();
         return -1;
     }
 }
require_once DOL_DOCUMENT_ROOT . '/adherents/class/cotisation.class.php';
$langs->load("companies");
$langs->load("bills");
$langs->load("members");
$langs->load("users");
if (!$user->rights->adherent->lire) {
    accessforbidden();
}
$rowid = isset($_GET["rowid"]) ? $_GET["rowid"] : $_POST["rowid"];
/*
 * Visualisation de la fiche
 *
 */
llxHeader();
$form = new Form($db);
$subscription = new Cotisation($db);
$result = $subscription->fetch($rowid);
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT . '/adherents/fiche_subscription.php?rowid=' . $subscription->id;
$head[$h][1] = $langs->trans("SubscriptionCard");
$head[$h][2] = 'general';
$h++;
$head[$h][0] = DOL_URL_ROOT . '/adherents/info_subscription.php?rowid=' . $subscription->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
dol_fiche_head($head, 'info', $langs->trans("Subscription"), '', 'payment');
$subscription->info($rowid);
print '<table width="100%"><tr><td>';
dol_print_object_info($subscription);
Ejemplo n.º 7
0
 */
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT . '/adherents/class/cotisation.class.php';
$langs->load("companies");
$langs->load("members");
// Security check
$result = restrictedArea($user, 'adherent');
/*
 * View
 */
llxHeader('', $langs->trans("Members"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
$staticmember = new Adherent($db);
$statictype = new AdherentType($db);
$subscriptionstatic = new Cotisation($db);
print load_fiche_titre($langs->trans("MembersArea"));
$var = True;
$Adherents = array();
$AdherentsAValider = array();
$MemberUpToDate = array();
$AdherentsResilies = array();
$AdherentType = array();
// Liste les adherents
$sql = "SELECT t.rowid, t.libelle, t.cotisation,";
$sql .= " d.statut, count(d.rowid) as somme";
$sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as t";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "adherent as d";
$sql .= " ON t.rowid = d.fk_adherent_type";
$sql .= " AND d.entity IN (" . getEntity() . ")";
$sql .= " WHERE t.entity IN (" . getEntity() . ")";
Ejemplo n.º 8
0
 /**
  * @param	Cotisation $cotisation The cotisation object to add.
  */
 protected function doAddCotisation($cotisation)
 {
     $this->collCotisations[] = $cotisation;
     $cotisation->setPersonne($this);
 }
Ejemplo n.º 9
0
 /**
  * Filter the query by a related Cotisation object
  *
  * @param   Cotisation|PropelObjectCollection $cotisation  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return   PersonneQuery The current query, for fluid interface
  * @throws   PropelException - if the provided filter is invalid.
  */
 public function filterByCotisation($cotisation, $comparison = null)
 {
     if ($cotisation instanceof Cotisation) {
         return $this->addUsingAlias(PersonnePeer::ID, $cotisation->getPersonneId(), $comparison);
     } elseif ($cotisation instanceof PropelObjectCollection) {
         return $this->useCotisationQuery()->filterByPrimaryKeys($cotisation->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByCotisation() only accepts arguments of type Cotisation or PropelCollection');
     }
 }
Ejemplo n.º 10
0
/**
 *       \file       htdocs/adherents/fiche_subscription.php
 *       \ingroup    member
 *       \brief      Page to add/edit/remove a member subscription
 */
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT . '/adherents/class/cotisation.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
$langs->load("companies");
$langs->load("bills");
$langs->load("members");
$langs->load("users");
$adh = new Adherent($db);
$subscription = new Cotisation($db);
$errmsg = '';
$action = isset($_GET["action"]) ? $_GET["action"] : $_POST["action"];
$rowid = isset($_GET["rowid"]) ? $_GET["rowid"] : $_POST["rowid"];
$typeid = isset($_GET["typeid"]) ? $_GET["typeid"] : $_POST["typeid"];
if (!$user->rights->adherent->cotisation->lire) {
    accessforbidden();
}
/*
 * 	Actions
 */
if ($user->rights->adherent->cotisation->creer && $_REQUEST["action"] == 'update' && !$_POST["cancel"]) {
    // Charge objet actuel
    $result = $subscription->fetch($_POST["rowid"]);
    if ($result > 0) {
        $db->begin();
Ejemplo n.º 11
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Cotisation $obj A Cotisation object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         CotisationPeer::$instances[$key] = $obj;
     }
 }