Files
ms1inscription-v5/php/inc_fx_memberships.php
2026-05-13 09:43:32 -04:00

1585 lines
73 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Created by PhpStorm.
* User: jspro
* Date: 2021-02-12
* Time: 12:05
*/
include_once APPLICATION_PATH . 'php/inc_files.php';
// MSIN-3922
// nom de club
function fxSetMembership($intCompte, $intType, $intSousType, $strDateDebut, $strDateFin, $strNoPanier, $no_commande, $intepr_id, $intpec_id, $numero_manuele = 0, $nom_club = "")
{
global $objDatabase;
$arrOutput = array('sate' => false);
switch (intval($intSousType)) {
case 1: // Nouveau Membre
// patch pour mettre sont numero
if ($numero_manuele != 0) {
//trouver le dernier numéro utilisé ainsi que le préfixe
$sqlNumeroMembership = "SELECT mt_prefixe, mt_last_number FROM memberships_types WHERE mt_id = " . intval($intType);
$arrNumeroMembership = $objDatabase->fxGetRow($sqlNumeroMembership);
$intNouveauNumero = $numero_manuele;
$strNouveauNumero = $arrNumeroMembership['mt_prefixe'] . $intNouveauNumero;
// ajouter le nouveau membership
$sqlInsertNumeroMembership = "INSERT INTO memberships SET mem_club_question = '" . $objDatabase->fxEscape($nom_club) . "',pec_id = " . intval($intpec_id) . ", mst_id = " . intval($intSousType) . ", epr_id = " . intval($intepr_id) . ", com_id = " . intval($intCompte) . ", mt_id = " . intval($intType) . ", mem_numero = '" . $strNouveauNumero . "', mem_date_debut = '" . $strDateDebut . "', mem_date_fin = '" . $strDateFin . "', mem_actif = 1, no_panier = '" . $strNoPanier . "', no_commande = '" . $no_commande . "'";
$arrInsertNumeroMembership = $objDatabase->fxQuery($sqlInsertNumeroMembership);
fxcreer_log('Nouveau membre avec num manuel' . $strNouveauNumero, 10, 0, 0, 0, 0, $strNoPanier);
} else {
//trouver le dernier numéro utilisé ainsi que le préfixe
$sqlNumeroMembership = "SELECT mt_prefixe, mt_last_number FROM memberships_types WHERE mt_id = " . intval($intType);
$arrNumeroMembership = $objDatabase->fxGetRow($sqlNumeroMembership);
$intNouveauNumero = intval($arrNumeroMembership['mt_last_number']) + 1;
$strNouveauNumero = $arrNumeroMembership['mt_prefixe'] . $intNouveauNumero;
// ajouter le nouveau membership
$sqlInsertNumeroMembership = "INSERT INTO memberships SET mem_club_question = '" . $objDatabase->fxEscape($nom_club) . "',pec_id = " . $intpec_id . ", mst_id = " . intval($intSousType) . ", epr_id = " . intval($intepr_id) . ", com_id = " . intval($intCompte) . ", mt_id = " . intval($intType) . ", mem_numero = '" . $strNouveauNumero . "', mem_date_debut = '" . $strDateDebut . "', mem_date_fin = '" . $strDateFin . "', mem_actif = 1, no_panier = '" . $strNoPanier . "', no_commande = '" . $no_commande . "'";
$arrInsertNumeroMembership = $objDatabase->fxQuery($sqlInsertNumeroMembership);
fxcreer_log('Nouveau membre ' . $strNouveauNumero, 10, 0, 0, 0, 0, $strNoPanier);
if ($arrInsertNumeroMembership) { // si bien enregistré
$intMembership = $objDatabase->fxGetLastId();
// mettre à jour le dernier nouveau membership
$sqlUpdateNumeroMembership = "UPDATE memberships_types SET mt_last_number = " . intval($intNouveauNumero) . " WHERE mt_id = " . intval($intType);
$arrUpdateNumeroMembership = $objDatabase->fxQuery($sqlUpdateNumeroMembership);
$arrOutput['state'] = true;
$arrOutput['numero'] = $strNouveauNumero;
$arrOutput['mem_id'] = $intMembership;
}
}
break;
case 2: // Renouvellement
//trouver le d numéro de membre
$sqlMembership = "SELECT * FROM memberships WHERE com_id = " . intval($intCompte) . " AND mt_id = " . intval($intType) . " ORDER BY mem_id DESC LIMIT 1";
$arrMembership = $objDatabase->fxGetRow($sqlMembership);
$strNumero = $arrMembership['mem_numero'];
//MSIN-4205
// if ($arrMembership['mem_date_fin'] >= fxGetDate()) {
// $strDateDebut = $arrMembership['mem_date_debut'];
// }
$today = fxGetDate();
// Priorité à la nouvelle date
if ($strDateDebut > $today) {
// Elle ne couvre pas aujourdhui → on cherche une date antérieure valide
if ($arrMembership['mem_date_debut'] <= $today) {
$strDateDebut = $arrMembership['mem_date_debut'];
}
}
// Date de fin : la plus récente (max)
if ($arrMembership['mem_date_fin'] > $strDateFin) {
$strDateFin = $arrMembership['mem_date_fin'];
}
// desactiver les autre abonnement
// mettre à jour le dernier nouveau membership
$sqlUpdateNumeroMembership = "UPDATE memberships SET mem_actif = 0 WHERE com_id = " . intval($intCompte) . " AND mt_id = " . intval($intType);
$arrUpdateNumeroMembership = $objDatabase->fxQuery($sqlUpdateNumeroMembership);
// ajouter le nouveau membership
$sqlInsertNumeroMembership = "INSERT INTO memberships SET mem_club_question = '" . $objDatabase->fxEscape($nom_club) . "',pec_id = " . intval($intpec_id) . ", mst_id = " . intval($intSousType) . ", epr_id = " . intval($intepr_id) . ", com_id = " . intval($intCompte) . ", mt_id = " . intval($intType) . ", mem_numero = '" . $strNumero . "', mem_date_debut = '" . $strDateDebut . "', mem_date_fin = '" . $strDateFin . "', mem_actif = 1, no_panier = '" . $strNoPanier . "', no_commande = '" . $no_commande . "'";
$arrInsertNumeroMembership = $objDatabase->fxQuery($sqlInsertNumeroMembership);
fxcreer_log('renouvellemnt membre ' . $strNumero, 10, 0, 0, 0, 0, $strNoPanier);
break;
}
return $arrOutput;
}
//MSIN-3918
function fxGetMembresClub($club, $excel = 0)
{ // trouver les commandes
global $objDatabase;
$arrRetour = null;
$mem_select = "m.mem_club_question,pe.*,mem_date_debut,mem_date_fin,ic.com_prenom,ic.com_nom, mem_numero,IF(ic.com_affilie is null ,'','oui') as affilie, IF(ic.com_affilie is null , ic.com_courriel, c.com_courriel) AS courriel
";
if ($excel == 1) {
$mem_select = "ic.com_prenom,ic.com_nom,IF(ic.com_affilie is null , ic.com_courriel, c.com_courriel) AS courriel, mem_numero,DATE(mem_date_debut) AS date_debut,DATE(mem_date_fin) AS date_fin,IF(ic.com_affilie is null ,'','oui') as affilie
";
}
$sqlAbonnements = "
SELECT " . $mem_select . "
FROM memberships m
JOIN memberships_types mt ON m.mt_id = mt.mt_id
JOIN inscriptions_comptes ic ON ic.com_id = m.com_id
JOIN inscriptions_panier_epreuves pe ON m.epr_id = pe.epr_id
left JOIN inscriptions_comptes c ON ic.com_affilie = c.com_id
WHERE mem_actif = 1 and m.mem_club_question LIKE '%" . $club . "%'
";
$arrAbonnements = $objDatabase->fxGetResults($sqlAbonnements);
return $arrAbonnements;
}
function fxGetAbonnements($CompteClient = 0, $tep_id = 0, $strLangue = 'fr', $strNumeroMembership = '', $type_adhesion = 0)
{ // trouver les commandes
global $objDatabase;
$arrRetour = null;
$strWhere = '1=1';
if (trim($strNumeroMembership) != '') {
$strWhere = "m.mem_numero = '" . $objDatabase->fxEscape($strNumeroMembership) . "' AND (ic.com_id = " . intval($_SESSION['com_info']['com_id']) . " OR ic.com_affilie = " . intval($_SESSION['com_info']['com_id']) . ")";
} else {
if ($CompteClient != 0) {
$strWhere = "m.com_id = " . intval($CompteClient);
}
}
// MSIN-3918
if ($type_adhesion != 0) {
$strWhere .= " and m.mt_id =" . $type_adhesion;
}
$sqlAbonnements = "
SELECT *
FROM memberships m
JOIN memberships_types mt ON m.mt_id = mt.mt_id
JOIN inscriptions_comptes ic ON ic.com_id = m.com_id
JOIN inscriptions_panier_epreuves pe ON m.epr_id = pe.epr_id
WHERE mem_actif = 1 AND $strWhere
";
$arrAbonnements = $objDatabase->fxGetResults($sqlAbonnements);
return $arrAbonnements;
}
function fxGetAbonnement($mem_id, $intMembershipType, $mem_com_id = 0, $intEpreuve = 0, $mem_pec_id = 0, $que_id = 3702)
{ // trouver labonnement
global $objDatabase;
$arrRetour = null;
if ($mem_pec_id != 0) {
$sqlAbonnements = "
SELECT *
FROM memberships m
JOIN memberships_types mt ON m.mt_id=mt.mt_id
JOIN inscriptions_comptes ic ON ic.com_id=m.com_id
WHERE m.pec_id = " . intval($mem_pec_id) . ' AND m.mem_actif = 1
';
$arrAbonnements = $objDatabase->fxGetRow($sqlAbonnements);
} elseif ($mem_id != 0) {
$sqlAbonnements = "
SELECT * FROM memberships m
JOIN memberships_types mt ON m.mt_id=mt.mt_id
JOIN inscriptions_comptes ic ON ic.com_id=m.com_id
WHERE m.mem_id = " . intval($mem_id) . ' AND m.mem_actif = 1
';
$arrAbonnements = $objDatabase->fxGetRow($sqlAbonnements);
} else {
if (intval($intEpreuve) == 0) {
$sqlAbonnements = "
SELECT *
FROM memberships m
JOIN memberships_types mt ON m.mt_id = mt.mt_id
JOIN inscriptions_comptes ic ON ic.com_id = m.com_id
WHERE m.mt_id = " . intval($intMembershipType) . " AND m.com_id = " . intval($mem_com_id) . " AND m.mem_actif = 1
ORDER BY mem_actif desc limit 1";
} else {
$sqlAbonnements = "
SELECT *
FROM memberships m
JOIN memberships_types mt ON m.mt_id = mt.mt_id
JOIN inscriptions_comptes ic ON ic.com_id = m.com_id
WHERE m.epr_id = " . intval($intEpreuve) . " AND m.mt_id = " . intval($intMembershipType) . " AND m.com_id = " . intval($mem_com_id) . " AND m.mem_actif = 1
ORDER BY mem_actif desc limit 1";
}
$arrAbonnements = $objDatabase->fxGetRow($sqlAbonnements);
}
return $arrAbonnements;
}
function fxGetAbonnementactive($mem_com_id, $mem_date, $intMembershipType = 1)
{ // trouver labonnement et valider si valide
global $objDatabase;
$sqlAbonnements = "SELECT mem_date_debut,mem_date_fin,mem_numero FROM memberships m JOIN memberships_types mt ON m.mt_id=mt.mt_id JOIN inscriptions_comptes ic ON ic.com_id=m.com_id JOIN inscriptions_panier_epreuves_commandees ipec ON m.pec_id=ipec.pec_id WHERE m.mt_id=" . intval($intMembershipType) . " and m.com_id=" . intval($mem_com_id) . " ORDER BY mem_actif desc limit 1";
$arrAbonnements = $objDatabase->fxGetRow($sqlAbonnements);
if ($arrAbonnements == null) {
$arrAbonnements['statut'] = 'pas_membre';
} else {
if ($mem_date >= $arrAbonnements['mem_date_debut'] && $mem_date <= $arrAbonnements['mem_date_fin']) {
$arrAbonnements['statut'] = 'ok_membre';
} else {
$arrAbonnements['statut'] = 'abbonement_nonvalide';
}
}
$arrAbonnements['date_epr'] = $mem_date;
return $arrAbonnements;
}
// MSIN-3918
function fxGetAbonnementsaffilie($CompteClient = 0, $tep_id = 0, $strLangue = 'fr', $type_adhesion = 0)
{ // trouver les commandes
global $objDatabase;
$arrAbonnements = array();
require_once('inc_fx_affilies.php');
$arrAffilie = fxGetInfosAffilies($CompteClient);
$mem_list = "";
if ($arrAffilie != null) {
foreach ($arrAffilie as $intCtr => $arrAff) {
$mem_list = $mem_list . $arrAff['com_id'] . ",";
}
}
$mem_list = substr($mem_list, 0, -1);
// MSIN-3918
$strWhere = "";
if ($type_adhesion != 0) {
$strWhere = " and m.mt_id =" . $type_adhesion;
}
if ($mem_list != "") {
$arrRetour = null;
//$sqlAbonnements = "SELECT * FROM memberships m JOIN memberships_types mt ON m.mt_id=mt.mt_id JOIN inscriptions_comptes ic ON ic.com_id=m.com_id JOIN inscriptions_panier_epreuves_commandees ipec ON m.pec_id=ipec.pec_id WHERE m.com_id in(" .$mem_list . ") and mem_actif=1";
$sqlAbonnements = "
SELECT *
FROM memberships m
JOIN memberships_types mt ON m.mt_id = mt.mt_id
JOIN inscriptions_comptes ic ON ic.com_id = m.com_id
JOIN inscriptions_panier_epreuves pe ON m.epr_id = pe.epr_id
WHERE m.com_id IN(" . $mem_list . ") AND mem_actif = 1" . $strWhere . "
";
$arrAbonnements = $objDatabase->fxGetResults($sqlAbonnements);
}
return $arrAbonnements;
}
function fxShowAbonnements($arrAbonnements, $arrCompteClient, $tep_id, $strLangue, $type)
{ // afficher les commandes
global $objDatabase, $strEveModifiable, $vDomaine, $arrFormsTransfert, $arrFormsObjectifsDons, $arrFormsLogSettings, $arrFormsAddLogs, $vblnEnvironementDev, $strPage;
$strCode = (!empty($_GET['code'])) ? trim($_GET['code']) : '';
$strRetour = '';
if ($arrAbonnements != null) {
?>
<input type="hidden" id="partComId" value="<?php echo $arrAbonnements['com_id']; ?>">
<div class="table-responsive">
<table class="table" id="table_liste_commandes">
<thead>
<tr>
<th><?php afficheTexte('memberships_nom') ?></th>
<th><?php afficheTexte('memberships_nom_eve') ?></th>
<th class="text-left"><?php afficheTexte('memberships_type'); ?></th>
<th class="text-left"><?php afficheTexte('memberships_no') ?></th>
<th class="text-left"><?php afficheTexte('memberships_date_de') ?></th>
<th class="text-left"><?php afficheTexte('memberships_a') ?></th>
<th class="text-center"><?php afficheTexte('modifier_inscriptions_facture') ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($arrAbonnements as $intCtr => $arrAbon) {
$strClasse = ($intCtr & 1) ? '' : 'table-secondary';
?>
<tr class="<?php echo $strClasse; ?>">
<td>
<?php echo fxUnescape($arrAbon['com_prenom']) . ' ' . fxUnescape($arrAbon['com_nom']); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon['epr_type_' . $strLangue]); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon['mt_nom_' . $strLangue]); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon['mem_numero']); ?>
</td>
<td>
<?php echo fxShowDate($arrAbon['mem_date_debut'], $GLOBALS['strLangue']); ?>
</td>
<td>
<?php echo fxShowDate($arrAbon['mem_date_fin'], $GLOBALS['strLangue']); ?>
</td>
<td>
<a class="btn btn-primary rounded-pill btn-sm mb-1"
href="<?php echo $vDomaine; ?>/compte/affichecarte?mem_id=<?php echo urlencode(base64_encode($arrAbon['mem_id'])); ?>&amp;lang=<?php echo $strLangue; ?>"
target="_blank">carte </a>
<a class="btn btn-primary rounded-pill btn-sm"
href="<?php echo $vDomaine; ?>/facture.php?no_panier=<?php echo $arrAbon['no_panier']; ?>&amp;lang=<?php echo $strLangue; ?>"
target="_blank"><?php echo $arrAbon['no_commande']; ?></a>
</td>
</tr>
<?php
// a remetre si on veux modifier
if (intval($arrAbon['mt_id']) == 3 || intval($arrAbon['mt_id']) == 4) {
echo '
<tr class="' . $strClasse . '">
<td colspan="7">
<a class="btn btn-primary mb-2 rounded-pill" href="' . $vDomaine . '/' . $strPage . '/' . $strCode . '?no=' . $arrAbon['mem_numero'] . '">
' . afficheTexte('btn_modifier_adhesion', 0) . '
</a>
';
if (!fxCheckMembershipComplete(array(0 => $arrAbon))) {
// afficher une note pour compléter l'adhésion
$strText = afficheTexte('texte_compléter_adhésion2', 0);
echo fxShowMembershipWarning($strText, '', $strLangue);
} else {
$arrReturn = fxCheckMembershipValidDate(array(0 => $arrAbon));
if (!($arrReturn['valid'])) {
// afficher une note pour compléter l'adhésion
$strText = afficheTexte('texte_adhésion_date_question2', 0, 1, 1);
echo fxShowMembershipWarning($strText, $arrReturn, $strLangue);
}
}
echo '
</td>
</tr>
';
}
}
?>
</tbody>
</table>
</div>
<?php
}
return $strRetour;
}
// nouvelle fonction msin-3918
function fxShowAbonnementspartype($arrAbonnements, $arrCompteClient, $tep_id, $strLangue, $type)
{ // afficher les commandes
global $objDatabase, $strEveModifiable, $vDomaine, $arrFormsTransfert, $arrFormsObjectifsDons, $arrFormsLogSettings, $arrFormsAddLogs, $vblnEnvironementDev, $strPage;
$strCode = (!empty($_GET['code'])) ? trim($_GET['code']) : '';
$strRetour = '';
if ($arrAbonnements != null) {
?>
<input type="hidden" id="partComId" value="<?php echo $arrAbonnements['com_id']; ?>">
<div class="table-responsive">
<table class="table" id="table_liste_commandes">
<thead>
<tr>
<th><?php afficheTexte('memberships_nom') ?></th>
<th><?php afficheTexte('memberships_nom_eve') ?></th>
<th class="text-left"><?php afficheTexte('memberships_type'); ?></th>
<th class="text-left"><?php afficheTexte('memberships_no') ?></th>
<th class="text-left"><?php afficheTexte('memberships_date_de') ?></th>
<th class="text-left"><?php afficheTexte('memberships_a') ?></th>
<th class="text-center"><?php afficheTexte('modifier_inscriptions_facture') ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($arrAbonnements as $intCtr => $arrAbon) {
$strClasse = ($intCtr & 1) ? '' : 'table-secondary';
?>
<tr class="<?php echo $strClasse; ?>">
<td>
<?php echo fxUnescape($arrAbon['com_prenom']) . ' ' . fxUnescape($arrAbon['com_nom']); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon['epr_type_' . $strLangue]); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon['mt_nom_' . $strLangue]); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon['mem_numero']); ?>
</td>
<td>
<?php echo fxShowDate($arrAbon['mem_date_debut'], $GLOBALS['strLangue']); ?>
</td>
<td>
<?php echo fxShowDate($arrAbon['mem_date_fin'], $GLOBALS['strLangue']); ?>
</td>
<td>
<?php
if (intval($arrAbon['mt_id']) != 2) {
if(1==3){
?>
<a class="btn btn-primary rounded-pill btn-sm"
href="<?php echo $vDomaine . '/' . $strPage . '/' . $strCode . '?no=' . $arrAbon['mem_numero'] ?>">
<?php echo afficheTexte('btn_modifier_adhesion', 0); ?>
</a>
<?php
}
}
?>
<a class="btn btn-primary rounded-pill btn-sm"
href="<?php echo $vDomaine; ?>/compte/affichecarte?mem_id=<?php echo urlencode(base64_encode($arrAbon['mem_id'])); ?>&amp;lang=<?php echo $strLangue; ?>"
target="_blank">carte </a>
<a class="btn btn-primary rounded-pill btn-sm"
href="<?php echo $vDomaine; ?>/facture.php?no_panier=<?php echo $arrAbon['no_panier']; ?>&amp;lang=<?php echo $strLangue; ?>"
target="_blank"><?php echo $arrAbon['no_commande']; ?></a>
</td>
</tr>
<?php
//MSIN-3918
// liste des membres club
if (intval($arrAbon['mt_id']) == 4) {
$arrMembres = fxGetMembresClub($arrAbon['mem_numero']);
if ($arrMembres != "") {
?>
<tr class="<?php echo $strClasse; ?>">
<td colspan="7">
<h4> <?php echo afficheTexte('liste_membres_club', 0) . ' ' . $arrMembres[1]['mem_club_question']; ?>
</h4></td>
<tr>
<thead>
<tr>
<th colspan="9">
<form action="/compte/mes_adhesions" method="post">
<input type="hidden" name="mem_numero"
value="<?php echo $arrAbon['mem_numero']; ?>">
<button type="submit" class="btn btn-light rounded-0" id="btn_excel_top"
name="btn_excel_top">
<img width="16" class="mr-2" src="/images/ico_excel.png" alt="">
Exportation excel
</button>
</form>
</tr>
<th><?php afficheTexte('memberships_nom') ?></th>
<th><?php afficheTexte('memberships_courriel') ?></th>
<th><?php afficheTexte('memberships_nom_eve') ?></th>
<th class="text-left"><?php afficheTexte('memberships_no') ?></th>
<th class="text-left"><?php afficheTexte('memberships_date_de') ?></th>
<th class="text-left"><?php afficheTexte('memberships_a') ?></th>
<th width="50" class="text-left"><?php afficheTexte('memberships_affilie') ?></th>
<th></th>
</tr>
</thead>
<?php
foreach ($arrMembres as $intCtr => $arrAbon2) {
$strClasse = ($intCtr & 1) ? '' : 'table-secondary';
?>
<tr class="<?php echo $strClasse; ?>">
<td>
<?php echo fxUnescape($arrAbon2['com_prenom']) . ' ' . fxUnescape($arrAbon2['com_nom']); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon2['courriel']); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon2['epr_type_' . $strLangue]); ?>
</td>
<td colspan="1">
<?php echo fxUnescape($arrAbon2['mem_numero']); ?>
</td>
<td>
<?php echo fxShowDate($arrAbon2['mem_date_debut'], $GLOBALS['strLangue']); ?>
</td>
<td>
<?php echo fxShowDate($arrAbon2['mem_date_fin'], $GLOBALS['strLangue']); ?>
</td>
<td>
<?php echo $arrAbon2['affilie']; ?>
</td>
<td>
</td>
</tr>
<?php
}
?>
<?php
}
}
// a remetre si on veux modifier
if (intval($arrAbon['mt_id']) == 3 || intval($arrAbon['mt_id']) == 4) {
echo '
<tr class="' . $strClasse . '">
<td colspan="7">
<a class="btn btn-primary mb-2 rounded-pill" href="' . $vDomaine . '/' . $strPage . '/' . $strCode . '?no=' . $arrAbon['mem_numero'] . '">
' . afficheTexte('btn_modifier_adhesion', 0) . '
</a>
';
if (!fxCheckMembershipComplete(array(0 => $arrAbon))) {
// afficher une note pour compléter l'adhésion
$strText = afficheTexte('texte_compléter_adhésion2', 0);
echo fxShowMembershipWarning($strText, '', $strLangue);
} else {
$arrReturn = fxCheckMembershipValidDate(array(0 => $arrAbon));
if (!($arrReturn['valid'])) {
// afficher une note pour compléter l'adhésion
$strText = afficheTexte('texte_adhésion_date_question2', 0, 1, 1);
echo fxShowMembershipWarning($strText, $arrReturn, $strLangue);
}
}
echo '
</td>
</tr>
';
}
}
?>
</tbody>
</table>
</div>
<?php
}
return $strRetour;
}
function fxShowAbonnementsmail($arrAbonnements, $arrCompteClient, $tep_id, $strLangue, $type)
{ // afficher les commandes
global $objDatabase, $strEveModifiable, $vDomaine, $arrFormsTransfert, $arrFormsObjectifsDons, $arrFormsLogSettings, $arrFormsAddLogs, $vblnEnvironementDev, $strPage;
$strCode = (!empty($_GET['code'])) ? trim($_GET['code']) : '';
$strRetour = '';
if ($arrAbonnements != null) {
?>
<input type="hidden" id="partComId" value="<?php echo $arrAbonnements['com_id']; ?>">
<div class="table-responsive">
<table class="table" id="table_liste_commandes">
<thead>
<tr>
<th><?php afficheTexte('memberships_nom') ?></th>
<th><?php afficheTexte('memberships_nom_eve') ?></th>
<th class="text-left"><?php afficheTexte('memberships_type'); ?></th>
<th class="text-left"><?php afficheTexte('memberships_no') ?></th>
<th class="text-left"><?php afficheTexte('memberships_date_de') ?></th>
<th class="text-left"><?php afficheTexte('memberships_a') ?></th>
<th class="text-center"><?php afficheTexte('modifier_inscriptions_facture') ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($arrAbonnements as $intCtr => $arrAbon) {
$strClasse = ($intCtr & 1) ? '' : 'table-secondary';
?>
<tr class="<?php echo $strClasse; ?>">
<td>
<?php echo fxUnescape($arrAbon['com_prenom']) . ' ' . fxUnescape($arrAbon['com_nom']); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon['epr_type_' . $strLangue]); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon['mt_nom_' . $strLangue]); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon['mem_numero']); ?>
</td>
<td>
<?php echo fxShowDate($arrAbon['mem_date_debut'], $GLOBALS['strLangue']); ?>
</td>
<td>
<?php echo fxShowDate($arrAbon['mem_date_fin'], $GLOBALS['strLangue']); ?>
</td>
<td>
</td>
</tr>
<?php
//MSIN-3918
// liste des membres club
// a remetre si on veux modifier
}
?>
</tbody>
</table>
</div>
<?php
}
return $strRetour;
}
function fxquestionechusql($mem_order, $mem_excel = 0)
{
global $objDatabase;
if ($mem_excel == 1) {
$sqlQuestions_select = "
SELECT
m.mem_numero,
CONCAT(c.com_nom, ' ', c.com_prenom) AS nom_complet,
IF(c.com_affilie is null , c.com_courriel, ic.com_courriel) AS courriel,
IF(mq_validation='datep2',DATE_ADD(mr_reponse, INTERVAL 2 YEAR),mr_reponse) as dateech,
mq_colonne_rapport_fr,
c.com_telephone1,
m.mem_date_fin,
mr_valider_date,
mr_date_last_email,
IF(c.com_affilie is null ,'','-Mem.Affilié') as affilie,
IF(c.com_affilie is null , c.com_id, ic.com_id) AS com_id_mail";
} else {
$sqlQuestions_select = "
SELECT IF(mq_validation='datep2',DATE_ADD(mr_reponse, INTERVAL 2 YEAR),mr_reponse) as dateech,CONCAT(c.com_nom, ' ', c.com_prenom) AS nom_complet,c.*,m.*,r.*,q.*,IF(c.com_affilie is null ,'','-Mem.Affilié') as affilie, IF(c.com_affilie is null , c.com_courriel, ic.com_courriel) AS courriel,
IF(c.com_affilie is null , c.com_id, ic.com_id) AS com_id_mail";
}
$sqlQuestions_from = " FROM memberships_reponses r
join memberships_questions q on r.mq_id=q.mq_id
join memberships m on m.mem_numero=r.mem_numero
join inscriptions_comptes c on c.com_id=m.com_id
left join inscriptions_comptes ic ON ic.com_id = c.com_affilie
where q.mq_required=1 AND m.mt_id=3 and (q.mq_validation='datef' or q.mq_validation='datep2') and m.mem_actif and m.mem_date_fin>now() and r.mr_reponse <now()+ INTERVAL 30 DAY
" . $mem_order;
$sqlQuestions = $sqlQuestions_select . $sqlQuestions_from;
$mem_sqlQuestions = $objDatabase->fxGetResults($sqlQuestions);
return $mem_sqlQuestions;
}
function fxShowQuestionsmail($arrAbonnements, $strLangue, $intEveId, $sort = "asc")
{ // afficher les commandes
global $objDatabase, $strEveModifiable, $vDomaine, $arrFormsTransfert, $arrFormsObjectifsDons, $arrFormsLogSettings, $arrFormsAddLogs, $vblnEnvironementDev, $strPage;
$strCode = (!empty($_GET['code'])) ? trim($_GET['code']) : '';
$strRetour = '';
$mem_sort = "";
if ($arrAbonnements != null) {
?>
<input type="hidden" id="partComId" value="<?php echo $arrAbonnements['com_id']; ?>">
<form action="<?php echo $vDomaine . $strPage . "/inc_tableau_mail_questions?promoteur_eve_id=" . urlencode(base64_encode($intEveId)) . $mem_sort; ?>"
method="post">
<button type="submit" class="btn btn-light rounded-0" id="btn_excel_top_echues"
name="btn_excel_top_echues">
<img width="16" class="mr-2" src="/images/ico_excel.png" alt="">
Exportation excel
</button>
</form>
<div class="table-responsive">
<table class="table" id="table_liste_commandes" style="font-size: 12px;">
<thead>
<tr>
<th><?php afficheTexte('questions_mail_tq') ?></th>
<th>
<?php
$mem_sort = "&o=nom_complet&" . $sort;
?>
<a href="<?php echo $vDomaine . $strPage . "/inc_tableau_mail_questions?promoteur_eve_id=" . urlencode(base64_encode($intEveId)) . $mem_sort; ?>">
<?php afficheTexte('questions_mail_nom'); ?>
<a>
</th>
<th class="text-left"><?php afficheTexte('questions_mail_courriel') ?></th>
<th class="text-left">
<?php
$mem_sort = "&o=dateech&" . $sort;
?>
<a href="<?php echo $vDomaine . $strPage . "/inc_tableau_mail_questions?promoteur_eve_id=" . urlencode(base64_encode($intEveId)) . $mem_sort; ?>">
<?php afficheTexte('questions_mail_question_echue') ?>
<a>
</th>
<th class="text-left">
<?php
$mem_sort = "&o=mq_colonne_rapport_" . $strLangue . "&" . $sort;
?>
<a href="<?php echo $vDomaine . $strPage . "/inc_tableau_mail_questions?promoteur_eve_id=" . urlencode(base64_encode($intEveId)) . $mem_sort; ?>">
<?php afficheTexte('questions_mail') ?>
<a>
</th>
<th class="text-center"><?php afficheTexte('questions_mail_tel') ?></th>
<th class="text-center">
<?php
$mem_sort = "&o=mem_date_fin&" . $sort;
?>
<a href="<?php echo $vDomaine . $strPage . "/inc_tableau_mail_questions?promoteur_eve_id=" . urlencode(base64_encode($intEveId)) . $mem_sort; ?>">
<?php afficheTexte('questions_mail_eche_adh') ?>
<a>
</th>
<th class="text-center">
<?php
$mem_sort = "&o=mr_date_last_email&" . $sort;
?>
<a href="<?php echo $vDomaine . $strPage . "/inc_tableau_mail_questions?promoteur_eve_id=" . urlencode(base64_encode($intEveId)) . $mem_sort; ?>">
<?php afficheTexte('questions_mail_datedernierrap') ?>
<a>
</th>
<th class="text-center"><?php afficheTexte('questions_valider') ?> </th>
<th class="text-center"><?php afficheTexte('questions_mail_rappel') ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($arrAbonnements as $intCtr => $arrAbon) {
$strClasse = ($intCtr & 1) ? '' : 'table-secondary';
if (strtotime(date('Y-m-d')) < strtotime($arrAbon['dateech'])) {
} else {
$strClasse = "color-yellow";
}
?>
<tr class="<?php echo $strClasse; ?>">
<td>
<?php echo fxUnescape($arrAbon['mem_numero']);?>
</td>
<td>
<?php echo fxUnescape($arrAbon['com_prenom']) . ' ' . fxUnescape($arrAbon['com_nom']); ?>
<td>
<?php echo fxUnescape($arrAbon['courriel'])." ".fxUnescape($arrAbon['affilie']) ; ?>
</td>
<td>
<?php echo fxShowDate($arrAbon['dateech'], $GLOBALS['strLangue']); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon['mq_colonne_rapport_' . $strLangue]); ?>
</td>
<td>
<?php echo fxUnescape($arrAbon['com_telephone1']); ?>
</td>
<td>
<?php echo fxShowDate($arrAbon['mem_date_fin'], $GLOBALS['strLangue']); ?>
</td>
<td>
<?php echo (is_null($arrAbon['mr_date_last_email']) ? " " : $arrAbon['mr_date_last_email']); ?>
</td>
<td>
<input class="btn_valider"
data-key="<?php echo $arrAbon['mr_id']; ?>"
type="checkbox"
name="mr_valider"
<?= !empty($arrAbon['mr_valider']) ? 'checked' : ''; ?>>
<?php echo(is_null($arrAbon['mr_valider_date']) ? " " : fxShowDate($arrAbon['mr_valider_date'], $GLOBALS['strLangue'])); ?>
</td>
<td>
<a style="font-size: 18px;" id="link_back" href="<?php echo $vDomaine . $strPage . "/inc_tableau_mail_questions?promoteur_eve_id=" . urlencode(base64_encode($intEveId))."&mr_id=" . urlencode(base64_encode($arrAbon['mr_id']))."&com_id=" . urlencode(base64_encode($arrAbon['com_id_mail'])); ?>"
<i class="fa fa-paper-plane" aria-hidden="true"></i>
</a>
</td>
</tr>
<?php
//MSIN-3918
// liste des membres club
// a remetre si on veux modifier
}
?>
</tbody>
</table>
</div>
<?php
}
return $strRetour;
}
use setasign\Fpdi\Fpdi;
function fxCarteAbonnements($mem_id, $strLangue = "fr", $pec_id = 0)
{
global $vPage, $vDomaine, $vRepertoireFichiers;
//$mem_id = (is_integer($mem_id)) ? urlencode(base64_encode($mem_id)) : $mem_id;
//$pec_id = (is_integer($pec_id)) ? urlencode(base64_encode($pec_id)) : $pec_id;
$membre = fxGetAbonnement(base64_decode(urldecode($mem_id)), 0, 0, 0, base64_decode(urldecode($pec_id)));
if ($membre["mt_id"] != 4) {
$arrAbonnements["nom"] = $membre["com_prenom"] . " " . $membre["com_nom"];
$arrAbonnements["type"] = $membre["mt_nom_" . $strLangue];
$arrAbonnements["expiration"] = "Expiration " . fxShowDatesl($membre['mem_date_fin']);;
$arrAbonnements["numero"] = $membre["mem_numero"];
$arrAbonnements["cat"] = $membre["que_choix_" . $strLangue];
$eve_id = $membre["eve_id"];
$mt_id = $membre["mt_id"];
} else {
$membre = fxGetAbonnement(base64_decode(urldecode($mem_id)), 0, 0, 0, base64_decode(urldecode($pec_id)), 3726);
$arrAbonnements["nom"] = $membre["que_choix_" . $strLangue];
$arrAbonnements["type"] = $membre["mt_nom_" . $strLangue];
$arrAbonnements["expiration"] = "Expiration " . fxShowDatesl($membre['mem_date_fin']);;
$arrAbonnements["numero"] = $membre["mem_numero"];
$arrAbonnements["cat"] = '';
$eve_id = $membre["eve_id"];
$mt_id = $membre["mt_id"];
}
$strEvenementURL = fxGetEvenementsUrl($eve_id);
//echo($_SERVER['DOCUMENT_ROOT'] . $vRepertoireFichiers . '/pdf/template_carte/carte_'.$eve_id.'_'.$mt_id.'.pdf');
require_once($_SERVER['DOCUMENT_ROOT'] . '/fpdf182/fpdf.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/fpdi2/src/autoload.php');
$strNomFichier = "test.pdf";
$offsetx = -20;
$offsety = -14;
ob_end_clean();
// initiate FPDI
$pdf = new Fpdi();
$pdf->AddPage();
$pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . $vRepertoireFichiers . '/pdf/template_carte/carte_' . $eve_id . '_' . $mt_id . '.pdf');
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useTemplate($tplIdx, 0, 0);
// now write some text above the imported page
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetXY(73.5 + $offsetx, 46.5 + $offsety);
$pdf->Cell(40, 5.05, utf8_decode($arrAbonnements['type']), 0, 1, "R");
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetXY(42 + $offsetx, 51.5 + $offsety);
$pdf->MultiCell(75, 4, utf8_decode($arrAbonnements['nom']), 0, "L");
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetXY(42 + $offsetx, 60 + $offsety);
$pdf->SetTextColor(136, 136, 136);
$pdf->Cell(20, 5.05, utf8_decode($arrAbonnements['numero']), 0, 1, "L");
$pdf->SetXY(75 + $offsetx, 60 + $offsety);
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(40, 5.05, utf8_decode($arrAbonnements['expiration']), 0, 1, "R");
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('Arial', 'B', 10);
$pdf->SetXY(42 + $offsetx, 65 + $offsety);
$pdf->Cell(60, 5.05, utf8_decode($arrAbonnements['cat']), 0, 1, "L");
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('Arial', '', 8);
$pdf->SetXY(42 + $offsetx, 70 + $offsety);
$pdf->Cell(60, 5.05, utf8_decode("Pour connaître tous vos avantages :"), 0, 1, "L");
$pdf->SetFont('Arial', 'B', 8);
$pdf->SetTextColor(0, 93, 168);
$pdf->SetXY(88 + $offsetx, 70 + $offsety);
$pdf->Cell(50, 5.05, utf8_decode("triathlonquebec.org"), 0, 1, "L");
$pdf->Output('carte.pdf', 'I');
// $data=$pdf->Output("carte.pdf", "S");
// echo "<script type=\"text/javascript\">
// window.open('$data', '_blank')
// </script>";
// enregister le pdf
// if ($eve_id!=0)
// $pdf->Output($_SERVER['DOCUMENT_ROOT'] . $vRepertoireFichiers . '/pdf/cartes/' . $strNomFichier, 'F');
}
function fxtypemembership($intMembershipType)
{
global $objDatabase;
$sqltypemembership = "SELECT * FROM memberships_types WHERE mt_id = " . intval($intMembershipType);
$arrtypemembership = $objDatabase->fxGetRow($sqltypemembership);
return $arrtypemembership;
}
function fxIfMembership($intMembershipType, $mem_numero)
{
global $objDatabase;
$sqltypemembership = "SELECT COUNT(mem_numero) FROM memberships WHERE mem_actif = 1 AND mem_numero = '" . $mem_numero . "' AND mt_id = " . intval($intMembershipType);
$arrtypemembership = $objDatabase->fxGetVar($sqltypemembership);
return $arrtypemembership;
}
function fxIfMembershipDate($intMembershipType, $mem_numero, $strNaissance, $strDateEpreuve)
{
global $objDatabase;
$sqltypemembership = "
SELECT COUNT(mem_numero)
FROM memberships m
JOIN inscriptions_comptes c ON m.com_id = c.com_id
WHERE m.mem_actif = 1 AND m.mem_numero = '" . $objDatabase->fxEscape($mem_numero) . "' AND c.com_naissance= '" . $objDatabase->fxEscape($strNaissance) . "' AND m.mt_id = " . intval($intMembershipType) . " AND DATE(m.mem_date_debut) <= '" . $objDatabase->fxEscape($strDateEpreuve) . "' AND DATE(m.mem_date_fin) >= '" . $objDatabase->fxEscape($strDateEpreuve) . "'
";
$arrtypemembership = $objDatabase->fxGetVar($sqltypemembership);
return $arrtypemembership;
}
function fxIfRenouvellementMembership($intMembershipType, $intCompte)
{
global $objDatabase;
$sqlNbMembership = "SELECT COUNT(mem_id) FROM memberships WHERE mem_actif = 1 AND com_id = " . intval($intCompte) . " AND mt_id = " . intval($intMembershipType);
$intNbMembership = $objDatabase->fxGetVar($sqlNbMembership);
return $intNbMembership;
}
function fxGetQuestionsMembership($intTypeMembership, $blnMandatory = false)
{
global $objDatabase;
$strWhere = '';
if ($blnMandatory) {
$strWhere = " AND mq_required = 1";
}
// Récupérsr les questions à poer pour ce type de membership
$sqlQuestions = "
SELECT
mq_id, mq_type, mq_question_fr, mq_question_en, mq_placeholder_fr, mq_placeholder_en, mq_validation, mq_validate_message_fr, mq_validate_message_en, mq_id_validate, mq_required
FROM memberships_questions
WHERE mt_id = " . intval($intTypeMembership) . " AND mq_actif = 1 $strWhere
ORDER BY mq_ordre, mq_id
";
$arrQuestions = $objDatabase->fxGetResults($sqlQuestions);
return $arrQuestions;
}
function fxGetReponsesMembership($strNumeroMembership, $blnMandatory = false)
{
global $objDatabase;
$strWhere = '';
if ($blnMandatory) {
$strWhere = " AND mq_id IN(SELECT mq_id FROM memberships_questions WHERE mt_id = " . intval(fxGetTypxeMembership($strNumeroMembership)) . " AND mq_actif = 1 AND mq_required = 1)";
}
// Récupérer les réponses pour ce membership
$sqlReponses = "
SELECT r.mq_id, r.mr_id, r.mr_reponse
FROM memberships_reponses r
JOIN memberships m ON m.mem_numero = r.mem_numero
WHERE r.mem_numero = '" . $objDatabase->fxEscape($strNumeroMembership) . "' AND r.mr_actif = 1 AND m.mem_actif = 1 $strWhere
";
$arrReponses = $objDatabase->fxGetResultsKey($sqlReponses);
return $arrReponses;
}
function fxGetTypxeMembership($strNumeroMembership)
{
global $objDatabase;
// Récupérer les réponses pour ce membership
$sqlTypeMembership = "SELECT mt_id FROM memberships WHERE mem_numero = '" . $objDatabase->fxEscape($strNumeroMembership) . "' AND mem_actif = 1";
$intTypeMembership = $objDatabase->fxGetVar($sqlTypeMembership);
return $intTypeMembership;
}
function fxShowQuestionsAdhesion($strNumeroMembership, $strLangue)
{
global $objDatabase, $vDomaine, $arrCalMembership, $arrFormsMembership, $arrTelMembership, $strValidationMembership;
$strOutput = $strMesage = '';
$arrReturn = null;
$arrAbonnement = fxGetAbonnements(0, 0, $strLangue, $strNumeroMembership);
$intTypeMembership = fxGetTypxeMembership($strNumeroMembership); // Récupérer les questions à poer pour ce type de membership
$arrQuestions = fxGetQuestionsMembership($intTypeMembership); // Récupérer les questions à poer pour ce type de membership
$arrReponses = fxGetReponsesMembership($strNumeroMembership); // Récupérer les réponses pour ce membership
if ($arrReponses != null) {
$arrReturn = fxCheckMembershipValidDate($arrAbonnement);
}
if ($arrQuestions != null) {
$arrFormsMembership[] = $strNumeroMembership;
if (isset($_SESSION['msg']))
$strMesage = fxMessage($_SESSION['msg']);
$strOutput .= '
<div class="msg_' . $strNumeroMembership . '">
' . $strMesage . '
</div>
<form action="' . $vDomaine . '/ajax_compte.php" id="frm_membership_' . $strNumeroMembership . '" enctype="multipart/form-data" method="post">
<input type="hidden" name="a" value="membership">
<input type="hidden" name="mem_numero" value="' . $strNumeroMembership . '">
<input type="hidden" name="mt_id" value="' . $intTypeMembership . '">
<input type="hidden" name="lng" value="' . $strLangue . '">
<div class="card mb-3">
<h3 class="bg-primary card-header">' . afficheTexte('adhesions_titre_card', 0) . ' - ' . fxUnescape($arrAbonnement[1]['mt_nom_' . $strLangue]) . '</h3>
<div class="card-body">
<h4 class="card-title">' . afficheTexte('adhesions_titre_quuestions', 0) . '</h4>
<div class="card-text">
<dl class="row">
<dt class="col-sm-3">' . afficheTexte('adhesions_description_numero', 0) . '</dt>
<dd class="col-sm-9">#' . fxUnescape($arrAbonnement[1]['mem_numero']) . '</dd>
<dt class="col-sm-3">' . afficheTexte('adhesions_description_dates_valides', 0) . '</dt>
<dd class="col-sm-9">' . fxShowDate($arrAbonnement[1]['mem_date_debut'], $strLangue) . ' ' . afficheTexte('interval_dates_au', 0, 1, 1) . ' ' . fxShowDate($arrAbonnement[1]['mem_date_fin'], $strLangue) . '</dd>
</dl>
</div>
<div class="card-text">' . afficheTexte('adhesions_description_quuestions', 0) . '</div>
<hr class="my-5">
';
for ($intCtr = 1; $intCtr <= count($arrQuestions); $intCtr++) {
$strAsterix = $strValidation = $strInput = $strDataTarget = $strInputGroupIconBefore = $strInputGroupIconAfter = $strInputGroupId = $strValue = $strChecked0 = $strChecked1 = '';
$tabParam = array();
$blnInputGroup = false;
if ($arrReponses != null && isset($arrReponses[$arrQuestions[$intCtr]['mq_id']])) {
if ($arrReturn != null && in_array($arrQuestions[$intCtr]['mq_id'], $arrReturn['questions'])) {
$strValue = '';
} else {
$strValue = trim($arrReponses[$arrQuestions[$intCtr]['mq_id']]['mr_reponse']);
}
}
if (intval($arrQuestions[$intCtr]['mq_required']) == 1) {
$strValidation = ' required';
$strAsterix = '
<small class="col text-muted">
*
</small>
';
}
if (in_array(trim($arrQuestions[$intCtr]['mq_validation']), array('date', 'datef', 'datep', 'datep2'))) {
$blnInputGroup = true;
$strInputGroupIconAfter = '<i class="fa fa-calendar"></i>';
$strValidation .= ' data-rule-dateCA="true"';
$tabParam['dateFormat'] = "'Y-m-d'";
$tabParam['onChange'] = "
function() {
validator_" . $strNumeroMembership . ".element('#que_" . $arrQuestions[$intCtr]['mq_id'] . "_" . $strNumeroMembership . "');
}
";
switch (trim($arrQuestions[$intCtr]['mq_validation'])) {
case 'datef':
$tabParam['minDate'] = "'" . date('Y-m-d', strtotime('+1 day')) . "'";
break;
case 'datep':
$tabParam['maxDate'] = "'" . date('Y-m-d', strtotime('-1 day')) . "'";
break;
case 'datep2':
$tabParam['minDate'] = "'" . date('Y-m-d', strtotime('-2 year')) . "'";
$tabParam['maxDate'] = "'" . date('Y-m-d', strtotime('-1 day')) . "'";
break;
}
$strInputGroupId = 'cal_que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership;
$arrCalMembership[] = array($strInputGroupId, $tabParam);
if ($arrReturn != null && in_array($arrQuestions[$intCtr]['mq_id'], $arrReturn['questions'])) { // si date invalide, vider case
$strValidationMembership .= '
$("#' . $strInputGroupId . '").datetimepicker("clear");
';
}
$strInputGroupId = ' id="' . $strInputGroupId . '"';
}
if (trim($arrQuestions[$intCtr]['mq_validation']) == 'facebook') {
$blnInputGroup = true;
$strInputGroupIconBefore = 'https://facebook.com/';
}
if (trim($arrQuestions[$intCtr]['mq_validation']) == 'instagram') {
$blnInputGroup = true;
$strInputGroupIconBefore = 'https://instagram.com/';
}
if (trim($arrQuestions[$intCtr]['mq_validation']) == 'telephone') {
$strValidation .= ' data-rule-phoneUS="true"';
$arrTelMembership[] = 'que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership;
}
switch (trim($arrQuestions[$intCtr]['mq_type'])) {
case 'file':
if (trim($strValue) != '') {
$strInput .= '
<a class="btn btn-primary mb-3 rounded-pill" id="que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership . '" href="' . $vDomaine . '/membership/' . $strNumeroMembership . '/' . $strValue . '" target="_blank">
' . $strValue . '
</a>
<br>
<button class="btn btn-danger rounded-0 btn_delete_file_membership" type="button" data-no="' . $strNumeroMembership . '" data-mq="' . $arrQuestions[$intCtr]['mq_id'] . '" data-mr="' . $arrReponses[$arrQuestions[$intCtr]['mq_id']]['mr_id'] . '">
<i class="fa fa-times mr-2" aria-hidden="true"></i>
' . afficheTexte('btn_supprimer', 0, 1, 1) . '
</button>
';
} else {
$strInput .= '
<div class="custom-file" id="que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership . '">
<input type="file" class="custom-file-input rounded-0" id="que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership . '_file" name="que_' . $arrQuestions[$intCtr]['mq_id'] . '"' . $strValidation . '>
<label class="custom-file-label rounded-0" for="que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership . '_file" data-browse="' . afficheTexte('btn-input-file', 0, 1, 1) . '">' . afficheTexte('label-input-file', 0, 1, 1) . '</label>
</div>
';
}
break;
case 'textarea':
$strInput .= '
<textarea class="form-control rounded-0" id="que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership . '" name="que_' . $arrQuestions[$intCtr]['mq_id'] . '" placeholder="' . trim($arrQuestions[$intCtr]['mq_placeholder_' . $strLangue]) . '"' . $strValidation . '>
' . $strValue . '
</textarea>
';
break;
case 'radio':
if (intval($strValue) == 1) {
$strChecked1 = ' checked';
} elseif (intval($strValue) == 0) {
$strChecked0 = ' checked';
}
$strInput .= '
<div id="que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership . '">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="que_' . $arrQuestions[$intCtr]['mq_id'] . '" id="que_' . $arrQuestions[$intCtr]['mq_id'] . '_1" value="1"' . $strChecked1 . '>
<label class="form-check-label" for="que_' . $arrQuestions[$intCtr]['mq_id'] . '_1">' . afficheTexte('radio-yes', 0, 1, 1) . '</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="que_' . $arrQuestions[$intCtr]['mq_id'] . '" id="que_' . $arrQuestions[$intCtr]['mq_id'] . '_0" value="0"' . $strChecked0 . '>
<label class="form-check-label" for="que_' . $arrQuestions[$intCtr]['mq_id'] . '_0">' . afficheTexte('radio-no', 0, 1, 1) . '</label>
</div>
</div>
';
break;
default:
if (trim($arrQuestions[$intCtr]['mq_validation']) == 'coach') {
$arrPlaceholder = explode(',', trim($arrQuestions[$intCtr]['mq_placeholder_' . $strLangue]));
if (trim($strValue) != '') {
$arrValue = explode(';', $strValue);
} else {
$arrValue = array(0 => '', 1 => '');
}
$strInput .= '
<div class="row" id="que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership . '">
<div class="col-md-6">
<input class="form-control rounded-0" type="' . $arrQuestions[$intCtr]['mq_type'] . '" id="que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership . '_0" name="que_' . $arrQuestions[$intCtr]['mq_id'] . '_0" value="' . $arrValue[0] . '" maxlength="100" placeholder="' . $arrPlaceholder[0] . '"' . $strValidation . '>
</div>
<div class="col-md-6">
<input class="form-control rounded-0" type="' . $arrQuestions[$intCtr]['mq_type'] . '" id="que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership . '_1" name="que_' . $arrQuestions[$intCtr]['mq_id'] . '_1" value="' . $arrValue[1] . '" maxlength="100" placeholder="' . $arrPlaceholder[1] . '"' . $strValidation . '>
</div>
</div>
';
} else {
if ($blnInputGroup) {
$strInput .= '
<div class="input-group"' . $strInputGroupId . '">
';
if ($strInputGroupIconBefore != '') {
$strInput .= '
<div class="input-group-append rounded-0" data-toggle>
<span class="input-group-text rounded-0">
' . $strInputGroupIconBefore . '
</span>
</div>
';
}
}
$strInput .= '
<input class="form-control rounded-0" type="' . $arrQuestions[$intCtr]['mq_type'] . '" id="que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership . '" name="que_' . $arrQuestions[$intCtr]['mq_id'] . '" value="' . $strValue . '" maxlength="100" placeholder="' . trim($arrQuestions[$intCtr]['mq_placeholder_' . $strLangue]) . '"' . $strValidation . ' data-input>
';
if ($blnInputGroup) {
if ($strInputGroupIconAfter != '') {
$strInput .= '
<div class="input-group-append rounded-0" data-toggle>
<span class="input-group-text rounded-0">
' . $strInputGroupIconAfter . '
</span>
</div>
';
}
$strInput .= '
</div>
';
}
}
}
$strOutput .= '
<div class="form-group row">
<label for="que_' . $arrQuestions[$intCtr]['mq_id'] . '_' . $strNumeroMembership . '" class="control-label col-12 col-lg-3 text-lg-right">
' . fxUnescape($arrQuestions[$intCtr]['mq_question_' . $strLangue]) . '
<span class="d-inline-block d-lg-none">
' . $strAsterix . '
</span>
</label>
<div class="col-12 col-lg-7">
' . $strInput . '
</div>
<div class="col-lg-2 d-none d-lg-inline-block">
' . $strAsterix . '
</div>
</div>
';
}
if (trim($strValidationMembership) != '') {
$strValidationMembership .= '
$("#frm_membership_' . $strNumeroMembership . '").valid();
';
}
$strOutput .= '
<div class="alert alert-warning my-3">
<strong>' . afficheTexte('alert-mandatory-field', 0, 1, 1) . '</strong>
</div>
</div>
<div class="card-footer text-center">
<button class="btn btn-primary rounded-0" type="submit">
<i class="fa fa-check mr-2" aria-hidden="true"></i>
' . afficheTexte('btn_enregistrer', 0, 1, 1) . '
</button>
</div>
</div>
</form>
<div class="mb-5">
<a class="btn btn-primary btn-sm rounded-pill" href="' . $vDomaine . '/' . afficheTexte('adhesions_link_retour_url', 0) . '">
<i class="fa fa-chevron-left mr-2" aria-hidden="true"></i>
' . afficheTexte('adhesions_link_retour_texte', 0) . '
</a>
</div>
';
}
return $strOutput;
}
function fxSetReponsesMembership($arrData, $arrFichiers, $strLangue)
{
global $objDatabase, $arrConFTP;
$blnUpdate = $blnInsert = false;
$intUpdte = $intInsert = 0;
$arrOutput = array(
'state' => 'error',
'message' => '0'
);
if (!empty($arrData)) { // vérifier s'il y a des données
$intTypeMembership = $arrData['mt_id'];
$strNumeroMembership = $arrData['mem_numero'];
$arrQuestions = fxGetQuestionsMembership($intTypeMembership); // Récupérer les questions à poer pour ce type de membership
$arrReponses = fxGetReponsesMembership($strNumeroMembership); // Récupérer les réponses pour ce membership
if ($arrQuestions != null) {
for ($intCtr = 1; $intCtr <= count($arrQuestions); $intCtr++) { // boucle parmi les questions
$strReponse = $strFileName = $strFileTmp = '';
$blnUpload = false;
$intQuestionMembership = $arrQuestions[$intCtr]['mq_id'];
if (trim($arrQuestions[$intCtr]['mq_validation']) == 'coach') {
if (isset($arrData['que_' . $arrQuestions[$intCtr]['mq_id'] . '_0']) && isset($arrData['que_' . $arrQuestions[$intCtr]['mq_id'] . '_1'])) { // vérifier si on a la réponse à la question
if (trim($arrData['que_' . $arrQuestions[$intCtr]['mq_id'] . '_0']) != '' && trim($arrData['que_' . $arrQuestions[$intCtr]['mq_id'] . '_1']) != '') { // vérifier si on a la réponse à la question
$strReponse = trim($arrData['que_' . $arrQuestions[$intCtr]['mq_id'] . '_0']) . ';' . trim($arrData['que_' . $arrQuestions[$intCtr]['mq_id'] . '_1']);
}
}
} elseif (trim($arrQuestions[$intCtr]['mq_type']) == 'file') {
if (!empty($arrFichiers['que_' . $arrQuestions[$intCtr]['mq_id']]['name'])) { // vérifier si on a le fichier
// UPLOAD ICI
$strFileName = trim($arrFichiers['que_' . $arrQuestions[$intCtr]['mq_id']]['name']);
$strFileTmp = trim($arrFichiers['que_' . $arrQuestions[$intCtr]['mq_id']]['tmp_name']);
$strPath = $arrConFTP['path_prod'] . '/membership/' . $objDatabase->fxEscape($strNumeroMembership);
if (!file_exists($strPath)) {
mkdir($strPath, 0777, true);
}
$strPath .= '/';
$strExtension = pathinfo($strPath . $strFileName, PATHINFO_EXTENSION);
$strExtension = strtolower($strExtension);
if (trim($arrQuestions[$intCtr]['mq_validation']) == 'image') {
$tabParam1 = explode(',', '800,800,0,100');
$arrValidExtensions = array("jpg", "jpeg", "png"); /* Valid extensions */
if (in_array(strtolower($strExtension), $arrValidExtensions)) { /* Check file extension */
$strImageOriginale = fxUploadFilesl($strFileName, $strFileTmp, $strPath);
$strReponse = fxResizeImage($strImageOriginale, $strPath, $tabParam1[0], $tabParam1[1], $tabParam1[2], $tabParam1[3], '');
// effacer l'image originale
// if ($strImageOriginale != $strFileName && file_exists($strPath . $strImageOriginale))
// unlink($strPath . $strImageOriginale);
}
} else {
$strReponse = fxUploadFilesl($strFileName, $strFileTmp, $strPath); // UPLOAD
if ($strReponse === false) {
$strReponse = '';
}
}
}
} else {
if (isset($arrData['que_' . $arrQuestions[$intCtr]['mq_id']])) { // vérifier si on a la réponse à la question
$strReponse = trim($arrData['que_' . $arrQuestions[$intCtr]['mq_id']]);
}
}
if (trim($strReponse) != '') { // vérifier si on a la réponse à la question
if (isset($arrReponses[$arrQuestions[$intCtr]['mq_id']])) { // vérifier si on doit faire INSERT ou UPDATE
// UPDATE
$sqlUpdate = "UPDATE memberships_reponses SET mr_reponse = '" . $objDatabase->fxEscape($strReponse) . "', mr_timestamp = '" . fxGetDateTime() . "' WHERE mem_numero = '" . $objDatabase->fxEscape($strNumeroMembership) . "' AND mq_id = " . intval($intQuestionMembership);
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
if ($qryUpdate != false) {
$blnUpdate = true;
}
} else { // INSERT
$sqlInsert = "INSERT INTO memberships_reponses SET mq_id = " . intval($intQuestionMembership) . ", mr_reponse = '" . $objDatabase->fxEscape($strReponse) . "', mem_numero = '" . $objDatabase->fxEscape($strNumeroMembership) . "', mr_timestamp = '" . fxGetDateTime() . "'";
$qryInsert = $objDatabase->fxQuery($sqlInsert);
if ($qryInsert != false) {
$blnInsert = true;
}
}
if ($blnUpdate) {
$intUpdte++;
}
if ($blnInsert) {
$intInsert++;
}
}
$arrOutput['state'] = 'success';
$arrOutput['message'] = fxMessage('p', 'UPDATE: ' . $intUpdte . ' - INSERT: ' . $intInsert);
$_SESSION['msg'] = 'p231';
}
} else {
$arrOutput['message'] = 'Aucune question trouvée';
$_SESSION['msg'] = 'e230';
}
} else {
$arrOutut['message'] = 'Aucune question trouvée';
$_SESSION['msg'] = 'e230';
}
return $arrOutput;
}
function fxSetFileMembership($strNumero, $intQuestion, $intReponse, $strLangue)
{
global $objDatabase, $arrConFTP;
$arrOutput = array(
'state' => 'error',
'message' => '0'
);
// UPDATE
$sqlUpdate = "UPDATE memberships_reponses SET mr_actif = 0, mr_timestamp = '" . fxGetDateTime() . "' WHERE mem_numero = '" . $objDatabase->fxEscape($strNumero) . "' AND mq_id = " . intval($intQuestion) . " AND mr_id = " . intval($intReponse);
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
if ($qryUpdate !== false) {
$arrOutput['state'] = 'success';
$arrOutput['message'] = $sqlUpdate;
$_SESSION['msg'] = 'p233';
} else {
$arrOutput['message'] = fxMessage('e232', '', $strLangue);
$_SESSION['msg'] = 'e232';
}
return $arrOutput;
}
function fxCheckMembershipComplete($arrMemberhips)
{
$blnValid = true;
if ($arrMemberhips != null) {
foreach ($arrMemberhips as $intCtr => $arrAbon) {
$arrQuestions = fxGetQuestionsMembership($arrAbon['mt_id'], true);
$intNbQuestions = count((array)$arrQuestions);
if ($intNbQuestions > 0) {
$blnValid = false;
$arrReponses = fxGetReponsesMembership($arrAbon['mem_numero'], true);
$intNbReponses = count((array)$arrReponses);
if ($intNbQuestions == $intNbReponses) {
$blnValid = true;
}
}
}
}
return $blnValid;
}
function fxCheckMembershipValidDate($arrMemberhips)
{
$arrReturn = $arrRaisons = $arrQuestionsErreur = array();
$blnValid = true;
if ($arrMemberhips != null) {
foreach ($arrMemberhips as $intCtr => $arrAbon) {
$arrQuestions = fxGetQuestionsMembership($arrAbon['mt_id'], true);
if ($arrQuestions != null) {
$arrReponses = fxGetReponsesMembership($arrAbon['mem_numero'], true);
if ($arrReponses != null) {
foreach ($arrQuestions as $intCtrQ => $arrQ) {
if ($arrQ['mq_validation'] == 'datef' && isset($arrReponses[$arrQ['mq_id']]['mr_reponse'])) { // date future
if (trim($arrReponses[$arrQ['mq_id']]['mr_reponse']) <= fxGetDate()) {
$blnValid = false;
$arrRaisons[] = array(
'fr' => $arrQ['mq_validate_message_fr'],
'en' => $arrQ['mq_validate_message_en']
);
array_push($arrQuestionsErreur, $arrQ['mq_id']);
}
}
if ($arrQ['mq_validation'] == 'datep2' && isset($arrReponses[$arrQ['mq_id']]['mr_reponse'])) { // date passée 2 ans max
if ((trim($arrReponses[$arrQ['mq_id']]['mr_reponse']) >= fxGetDate()) || (trim($arrReponses[$arrQ['mq_id']]['mr_reponse']) <= date('Y-m-d', strtotime('-2 year')))) {
$blnValid = false;
$arrRaisons[] = array(
'fr' => $arrQ['mq_validate_message_fr'],
'en' => $arrQ['mq_validate_message_en']
);
array_push($arrQuestionsErreur, $arrQ['mq_id']);
}
}
}
}
}
}
}
$arrReturn = array(
'valid' => $blnValid,
'raisons' => $arrRaisons,
'questions' => $arrQuestionsErreur
);
return $arrReturn;
}
function fxShowMembershipWarning($strText, $arrReturn, $strLangue)
{
$strOutput = '
<div class="alert alert-warning m-0" role="alert">
<i class="fa fa-exclamation-triangle mr-2" aria-hidden="true"></i>
' . $strText . '
';
if (isset($arrReturn) && isset($arrReturn['raisons']) && count($arrReturn['raisons']) > 0) {
$strOutput .= '
<ul class="mt-3 pl-5">
';
foreach ($arrReturn['raisons'] as $raison) {
$strOutput .= '
<li>
' . $raison[$strLangue] . '
</li>
';
}
$strOutput .= '
</ul>
';
}
$strOutput .= '
</div>
';
return $strOutput;
}
function fxSendQuestionpasserdate($tabCompte, $strmr_id){
global $objDatabase,$vDomaine;
// envoyer un courriel de confirmation
// FRAN<41>AIS
$strCourriel=$tabCompte['com_courriel'];
//$strCourriel="stephan@va-voir.com";
$mem_info = fxGetPage("mail_echue_tq");
if ($tabCompte['com_langue'] == 'fr'){
//if (1==1){
$subject = $mem_info["pag_titre_fr"];
$ms1 = '<a href="' . $vDomaine . '/compte" target="_blank">Connexion</a>';
$body = $mem_info["pag_texte_fr"];
$body = str_replace('%linkcompte%', $ms1, $body);
}
// ANGLAIS
else {
$subject = $mem_info["pag_titre_en"];
$ms1 = '<a href="' . $vDomaine . '/compte" target="_blank">Connexion</a>';
$body = $mem_info["pag_texte_en"];
$body = str_replace('%linkcompte%', $ms1, $body);
}
if( fxSendMail($subject, $body, $strCourriel, $tabCompte['com_prenom'] . ' ' . $tabCompte['com_nom'], $GLOBALS['vEmail'], $GLOBALS['vClient'], 1, 0)){
$sqlUpdatequestion= "UPDATE memberships_reponses SET mr_date_last_email = now() WHERE mr_id = " . intval($strmr_id);
$arrUpdateNumeroMembership = $objDatabase->fxQuery($sqlUpdatequestion);
}else{
};
}