This commit introduces new functions for permission inspection, allowing super admins to toggle and manage access rights more effectively. It adds visual elements for permission badges in the admin interface and updates the sidebar navigation to include a migration section for legacy accounts. Additionally, CSS styles are enhanced for better user experience and clarity. The version code is updated to reflect these changes.
1620 lines
63 KiB
PHP
1620 lines
63 KiB
PHP
<?php
|
|
/**
|
|
* Description : retourner le texte correspondan a la clef si il a été mis en mémoire
|
|
* Parametres : clef
|
|
* mem_echo =1 fait un echo sinon la valeur est retourné
|
|
* $mem_trduction lest admin on un bouton pour correction
|
|
* $mem_global=0 si 1 vas créér la variable avec global pas le nom de la page
|
|
* Créateur : stephan
|
|
* Date : 13-03-17
|
|
*/
|
|
function afficheTexte($clef, $mem_echo = 1, $mem_trduction = 1, $mem_global = 0) {
|
|
global $vtexte_page, $vPage;
|
|
$mem_id = "";
|
|
|
|
if (isset($vtexte_page[$clef]['info_texte']))
|
|
$mem_texte = $vtexte_page[$clef]['info_texte'];
|
|
else {
|
|
$mem_texte = '*' . $clef . '*';
|
|
|
|
if ($mem_global == 0)
|
|
$mem_page = $vPage;
|
|
else
|
|
$mem_page = "global";
|
|
|
|
// creation dans la bd info
|
|
$info1 = array("info_clef" => $clef, "info_langue" => "fr", "info_texte" => $clef, "info_aide" => '', "info_prg" => $mem_page, "info_actif" => 1);
|
|
fxSetInfo('add', $info1, '', $mem_id);
|
|
|
|
$info1 = array("info_clef" => $clef, "info_langue" => "en", "info_texte" => $clef, "info_aide" => '', "info_prg" => $mem_page, "info_actif" => 1);
|
|
fxSetInfo('add', $info1, '', $mem_id);
|
|
}
|
|
|
|
$strOut = $mem_texte . fxAdminTradMarker($clef, $mem_global);
|
|
|
|
if ($mem_echo == 1) {
|
|
echo $strOut;
|
|
}
|
|
|
|
return $strOut;
|
|
}
|
|
|
|
/**
|
|
* Libellé info_texte en contexte HTML (crayon via afficheTexte en mode Textes).
|
|
*/
|
|
function afficheTextePage($clef, $mem_global = 0) {
|
|
afficheTexte($clef, 1, 0, $mem_global);
|
|
}
|
|
|
|
/**
|
|
* Texte d'aide long (pop-up Tippy sur le bouton ?) — colonne info_aide.
|
|
* info_texte = libellé / tip court ; info_aide = contenu long éditable via traduction.php.
|
|
* Créateur : stephan (refonte dossards v4)
|
|
*/
|
|
function afficheAide($clef, $mem_echo = 1, $mem_global = 0) {
|
|
global $vtexte_page, $vPage;
|
|
$mem_id = "";
|
|
|
|
if (isset($vtexte_page[$clef])) {
|
|
$mem_aide = isset($vtexte_page[$clef]['info_aide']) ? $vtexte_page[$clef]['info_aide'] : '';
|
|
} else {
|
|
$mem_aide = '';
|
|
|
|
if ($mem_global == 0) {
|
|
$mem_page = $vPage;
|
|
} else {
|
|
$mem_page = "global";
|
|
}
|
|
|
|
$info1 = array(
|
|
"info_clef" => $clef,
|
|
"info_langue" => "fr",
|
|
"info_texte" => $clef,
|
|
"info_aide" => '',
|
|
"info_prg" => $mem_page,
|
|
"info_actif" => 1
|
|
);
|
|
fxSetInfo('add', $info1, '', $mem_id);
|
|
|
|
$info1['info_langue'] = 'en';
|
|
fxSetInfo('add', $info1, '', $mem_id);
|
|
}
|
|
|
|
if ($mem_echo == 1) {
|
|
echo $mem_aide;
|
|
}
|
|
|
|
return $mem_aide;
|
|
}
|
|
|
|
/**
|
|
* Description : lire le text dans la bd info
|
|
* Parametres : 1 - page
|
|
* 2 - langue A,F
|
|
* optionelle 3- 1 va chercher bd client en premier et centrale en deuxiemme (default)
|
|
* 2 jutse bd client
|
|
* 3 juste bd centrale
|
|
* Créateur : stephan
|
|
* Date : 13-03-15
|
|
*/
|
|
function obtenirTextepage() {
|
|
global $objDatabase;
|
|
|
|
$numargs = func_num_args();
|
|
$arg_list = func_get_args();
|
|
$page = $arg_list[0];
|
|
$Langue = $arg_list[1];
|
|
$centrale = $mem_corr = "";
|
|
$info = null;
|
|
|
|
if (array_key_exists(2, $arg_list)) {
|
|
$centrale = $arg_list[2];
|
|
}
|
|
|
|
|
|
switch ($centrale) {
|
|
case 3:
|
|
$sql_info = "SELECT info_clef,info_texte,info_aide,pk_info,info_prg,'centrale' as bd FROM info where info_prg='" . $page . "' and info_langue='" . $Langue . "'";
|
|
$info = $GLOBALS['dbcentrale']->fxFetchArray(3, $sql_info);
|
|
break;
|
|
case 2:
|
|
/* MSIN-4379 — info_aide : texte long pop-up bib v4 (Tippy). */
|
|
$sql_info = "SELECT info_clef,info_texte,info_aide,pk_info,info_prg,'client' as bd FROM info where (info_prg='" . $page . "' or info_prg='global') and info_langue='" . $Langue . "'";
|
|
|
|
$info = $objDatabase->fxFetchArray(3, $sql_info);
|
|
|
|
break;
|
|
case 1:
|
|
$sql_info = "SELECT info_clef,info_texte,info_aide,pk_info,'client' as bd FROM info where info_prg='" . $page . "' and info_langue='" . $Langue . "'";
|
|
$info2 = $objDatabase->fxFetchArray(3, $sql_info);
|
|
|
|
$sql_info = "SELECT info_clef,info_texte,info_aide,'centrale' as bd FROM info where info_prg='" . $page . "' and info_langue='" . $Langue . "'";
|
|
$info1 = $objDatabase->fxFetchArray(3, $sql_info);
|
|
$info = array_merge($info1, $info2);
|
|
break;
|
|
}
|
|
|
|
return $info;
|
|
}
|
|
|
|
/**
|
|
* Description : affiche le bouton modi texte et hide les textclef
|
|
* Parametres :
|
|
* Créateur : stephan
|
|
* Date : 13-03-22
|
|
*/
|
|
function modif_texte_bt() {
|
|
global $vadmin_texte;
|
|
if ($vadmin_texte == true)
|
|
echo "<button onclick=" . chr(34) . "toggle_hideme('modif_texte','text');" . chr(34) . ">changer texte</button>";
|
|
}
|
|
|
|
/**
|
|
* MSIN-4379 — Édition textes (crayons, traduction.php) : serveur dev + sous-domaine preprod seulement.
|
|
* Pas la préprod client (preprod.ms1inscription.com) — même code, autre rôle (BD inscription test).
|
|
* Superadm uniquement ; défaut = aperçu (crayons masqués).
|
|
*/
|
|
function fxAdminIsDevPreprod() {
|
|
global $vblnEnvironementDev, $vblnEnvironementPreProd, $strHost;
|
|
|
|
if (empty($vblnEnvironementDev) || empty($vblnEnvironementPreProd)) {
|
|
return false;
|
|
}
|
|
|
|
return stripos((string)$strHost, 'ms1inscriptiondev') !== false;
|
|
}
|
|
|
|
function fxAdminCanUseTextEditTools() {
|
|
return !empty($_SESSION['usa_id']) && fxAdminIsDevPreprod();
|
|
}
|
|
|
|
/** Sync tables statiques (sync_static_db.php) — superadm, préprod dev seulement. */
|
|
function fxAdminStaticSyncAllowed() {
|
|
return !empty($_SESSION['usa_id']) && fxAdminIsDevPreprod();
|
|
}
|
|
|
|
function fxAdminTextEditModeActive() {
|
|
return fxAdminCanUseTextEditTools() && !empty($_SESSION['ms1_text_edit_mode']);
|
|
}
|
|
|
|
/** Mode inspecteur droits v2 (cadenas) — super admin connecte uniquement. */
|
|
function fxAdminCanUsePermInspectTools() {
|
|
return !empty($_SESSION['usa_id']);
|
|
}
|
|
|
|
function fxAdminPermInspectModeActive() {
|
|
return fxAdminCanUsePermInspectTools() && !empty($_SESSION['ms1_perm_inspect_mode']);
|
|
}
|
|
|
|
function fxAdminPermInspectModeHandleRequest() {
|
|
if (!fxAdminCanUsePermInspectTools() || !isset($_GET['ms1_perm_inspect'])) {
|
|
return;
|
|
}
|
|
|
|
$_SESSION['ms1_perm_inspect_mode'] = ($_GET['ms1_perm_inspect'] === '1') ? 1 : 0;
|
|
|
|
$strPath = strtok($_SERVER['REQUEST_URI'], '?');
|
|
$tabParams = $_GET;
|
|
unset($tabParams['ms1_perm_inspect']);
|
|
$strQuery = http_build_query($tabParams);
|
|
|
|
header('Location: ' . $strPath . ($strQuery !== '' ? '?' . $strQuery : ''));
|
|
exit;
|
|
}
|
|
|
|
function fxAdminPermInspectSwitchHtml() {
|
|
$blnOn = fxAdminPermInspectModeActive();
|
|
|
|
return '
|
|
<span class="ms1-env-text-edit ms1-env-perm-inspect">
|
|
<label class="ms1-env-text-edit-label mb-0" for="ms1-perm-inspect-mode">
|
|
<span class="ms1-env-text-edit-opt' . ($blnOn ? '' : ' is-active') . '">'
|
|
. '<i class="fa fa-eye" aria-hidden="true"></i> Aperçu'
|
|
. '</span>
|
|
<input type="checkbox" id="ms1-perm-inspect-mode" class="ms1-env-text-edit-switch"'
|
|
. ($blnOn ? ' checked' : '')
|
|
. ' aria-label="Afficher les cadenas droits v2">
|
|
<span class="ms1-env-text-edit-opt' . ($blnOn ? ' is-active' : '') . '">'
|
|
. '<i class="fa fa-lock" aria-hidden="true"></i> Droits'
|
|
. '</span>
|
|
</label>
|
|
</span>
|
|
<script>
|
|
(function () {
|
|
var el = document.getElementById("ms1-perm-inspect-mode");
|
|
if (!el || el.dataset.ms1Bound) return;
|
|
el.dataset.ms1Bound = "1";
|
|
el.addEventListener("change", function () {
|
|
var url = new URL(window.location.href);
|
|
url.searchParams.set("ms1_perm_inspect", this.checked ? "1" : "0");
|
|
window.location.href = url.toString();
|
|
});
|
|
})();
|
|
</script>';
|
|
}
|
|
|
|
/** Échappement HTML — outils admin traduction. */
|
|
function fxAdminEsc($str) {
|
|
return htmlspecialchars((string)$str, ENT_QUOTES, 'UTF-8');
|
|
}
|
|
|
|
/** info_prg pour traduction.php — depuis $vtexte_page ou repli page / global. */
|
|
function fxAdminTradInfoPrg($clef, $strDefaultPrg = '', $mem_global = 0) {
|
|
global $vtexte_page, $vPage;
|
|
|
|
if (!empty($vtexte_page[$clef]['info_prg'])) {
|
|
return $vtexte_page[$clef]['info_prg'];
|
|
}
|
|
if ($strDefaultPrg !== '') {
|
|
return $strDefaultPrg;
|
|
}
|
|
if ($mem_global == 1) {
|
|
return 'global';
|
|
}
|
|
return !empty($vPage) ? $vPage : 'compte.php';
|
|
}
|
|
|
|
/** URL pop-up traduction.php — toute clé info (site entier). */
|
|
function fxAdminTradUrl($clef, $strInfoPrg = null, $mem_global = 0) {
|
|
global $vDomaine, $vPage;
|
|
|
|
if ($strInfoPrg === null || $strInfoPrg === '') {
|
|
$strInfoPrg = fxAdminTradInfoPrg($clef, '', $mem_global);
|
|
}
|
|
$strPage = !empty($vPage) ? $vPage : $strInfoPrg;
|
|
|
|
return $vDomaine . '/php/traduction.php?' . http_build_query(array(
|
|
'clef' => $clef,
|
|
'pk_prg' => $strInfoPrg,
|
|
'bd' => 'client',
|
|
'page' => $strPage,
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Marqueur invisible (ZWSP) — sûr dans le JS ; remplacé par un lien traduction.php au chargement.
|
|
*/
|
|
function fxAdminTradMarker($clef, $mem_global = 0) {
|
|
if (!fxAdminTextEditModeActive() || trim($clef) === '') {
|
|
return '';
|
|
}
|
|
|
|
$strPayload = base64_encode(json_encode(array(
|
|
'k' => $clef,
|
|
'p' => fxAdminTradInfoPrg($clef, '', $mem_global),
|
|
'g' => (int)$mem_global,
|
|
), JSON_UNESCAPED_UNICODE));
|
|
|
|
return "\xE2\x80\x8B\xE2\x80\x8C" . $strPayload . "\xE2\x80\x8C\xE2\x80\x8B";
|
|
}
|
|
|
|
/** Classes CSS crayon traduction (sans btn-admin-trad — évite le handler bib sur data-trad-url). */
|
|
function fxAdminTradLinkClass() {
|
|
return 'btn-aide-bib btn-aide-trad ms1-trad-link';
|
|
}
|
|
|
|
/** Lien crayon traduction.php — superadm dev/préprod + switch « Textes » ON. */
|
|
function fxAdminTradButton($clef, $strInfoPrg = null, $mem_global = 0) {
|
|
if (!fxAdminTextEditModeActive() || trim($clef) === '') {
|
|
return '';
|
|
}
|
|
|
|
return '<a href="' . fxAdminEsc(fxAdminTradUrl($clef, $strInfoPrg, $mem_global)) . '"'
|
|
. ' class="' . fxAdminTradLinkClass() . '"'
|
|
. ' title="Modifier textes FR/EN"'
|
|
. ' aria-label="Modifier textes">'
|
|
. '<i class="fa fa-pencil" aria-hidden="true"></i>'
|
|
. '</a>';
|
|
}
|
|
|
|
/** Remplace les marqueurs afficheTexte() par des liens crayon (mode Textes). */
|
|
function fxAdminTradMarkerScriptHtml() {
|
|
global $vDomaine, $vPage;
|
|
static $blnRendered = false;
|
|
|
|
if ($blnRendered || !fxAdminTextEditModeActive()) {
|
|
return '';
|
|
}
|
|
$blnRendered = true;
|
|
|
|
return '
|
|
<script>
|
|
(function () {
|
|
var re = /\u200B\u200C([A-Za-z0-9+/=]+)\u200C\u200B/g;
|
|
var tradBase = ' . json_encode($vDomaine . '/php/traduction.php') . ';
|
|
var pageDefault = ' . json_encode(!empty($vPage) ? $vPage : 'compte.php') . ';
|
|
var tradLinkClass = ' . json_encode(fxAdminTradLinkClass()) . ';
|
|
|
|
function openTradPopup(url) {
|
|
var w = window.open(
|
|
url,
|
|
"ms1Trad" + Date.now(),
|
|
"width=960,height=640,scrollbars=yes,resizable=yes"
|
|
);
|
|
if (w) {
|
|
var timer = setInterval(function () {
|
|
if (w.closed) {
|
|
clearInterval(timer);
|
|
window.location.reload();
|
|
}
|
|
}, 400);
|
|
}
|
|
}
|
|
|
|
document.addEventListener("click", function (e) {
|
|
var link = e.target.closest("a.ms1-trad-link");
|
|
if (!link || !link.href) {
|
|
return;
|
|
}
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
openTradPopup(link.href);
|
|
}, true);
|
|
|
|
function skipParent(node) {
|
|
var p = node.parentNode;
|
|
while (p) {
|
|
var tag = p.nodeName;
|
|
if (tag === "SCRIPT" || tag === "STYLE") {
|
|
return true;
|
|
}
|
|
p = p.parentNode;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function buildUrl(o) {
|
|
return tradBase + "?clef=" + encodeURIComponent(o.k)
|
|
+ "&pk_prg=" + encodeURIComponent(o.p)
|
|
+ "&bd=client"
|
|
+ "&page=" + encodeURIComponent(pageDefault);
|
|
}
|
|
|
|
function replaceMarkers(textNode) {
|
|
if (skipParent(textNode)) {
|
|
return;
|
|
}
|
|
var text = textNode.nodeValue;
|
|
if (text.indexOf("\u200C") === -1) {
|
|
return;
|
|
}
|
|
re.lastIndex = 0;
|
|
if (!re.test(text)) {
|
|
return;
|
|
}
|
|
re.lastIndex = 0;
|
|
|
|
var frag = document.createDocumentFragment();
|
|
var last = 0;
|
|
var m;
|
|
while ((m = re.exec(text)) !== null) {
|
|
if (m.index > last) {
|
|
frag.appendChild(document.createTextNode(text.slice(last, m.index)));
|
|
}
|
|
try {
|
|
var o = JSON.parse(atob(m[1]));
|
|
var a = document.createElement("a");
|
|
a.href = buildUrl(o);
|
|
a.className = tradLinkClass;
|
|
a.title = "Modifier textes FR/EN";
|
|
a.setAttribute("aria-label", "Modifier textes");
|
|
a.innerHTML = \'<i class="fa fa-pencil" aria-hidden="true"></i>\';
|
|
frag.appendChild(a);
|
|
} catch (e) {}
|
|
last = m.index + m[0].length;
|
|
}
|
|
if (last < text.length) {
|
|
frag.appendChild(document.createTextNode(text.slice(last)));
|
|
}
|
|
textNode.parentNode.replaceChild(frag, textNode);
|
|
}
|
|
|
|
function scan() {
|
|
if (!document.body) {
|
|
return;
|
|
}
|
|
var walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null);
|
|
var nodes = [];
|
|
while (walker.nextNode()) {
|
|
nodes.push(walker.currentNode);
|
|
}
|
|
nodes.forEach(replaceMarkers);
|
|
}
|
|
|
|
if (document.readyState === "loading") {
|
|
document.addEventListener("DOMContentLoaded", scan);
|
|
} else {
|
|
scan();
|
|
}
|
|
})();
|
|
</script>';
|
|
}
|
|
|
|
function fxAdminTextEditModeHandleRequest() {
|
|
if (!fxAdminCanUseTextEditTools() || !isset($_GET['ms1_text_edit'])) {
|
|
return;
|
|
}
|
|
|
|
$_SESSION['ms1_text_edit_mode'] = ($_GET['ms1_text_edit'] === '1') ? 1 : 0;
|
|
|
|
$strPath = strtok($_SERVER['REQUEST_URI'], '?');
|
|
$tabParams = $_GET;
|
|
unset($tabParams['ms1_text_edit']);
|
|
$strQuery = http_build_query($tabParams);
|
|
|
|
header('Location: ' . $strPath . ($strQuery !== '' ? '?' . $strQuery : ''));
|
|
exit;
|
|
}
|
|
|
|
function fxAdminTextEditSwitchHtml() {
|
|
$blnEdit = fxAdminTextEditModeActive();
|
|
|
|
return '
|
|
<span class="ms1-env-text-edit">
|
|
<label class="ms1-env-text-edit-label mb-0" for="ms1-text-edit-mode">
|
|
<span class="ms1-env-text-edit-opt' . ($blnEdit ? '' : ' is-active') . '">'
|
|
. '<i class="fa fa-eye" aria-hidden="true"></i> Aperçu'
|
|
. '</span>
|
|
<input type="checkbox" id="ms1-text-edit-mode" class="ms1-env-text-edit-switch"'
|
|
. ($blnEdit ? ' checked' : '')
|
|
. ' aria-label="Basculer édition des textes">
|
|
<span class="ms1-env-text-edit-opt' . ($blnEdit ? ' is-active' : '') . '">'
|
|
. '<i class="fa fa-pencil" aria-hidden="true"></i> Textes'
|
|
. '</span>
|
|
</label>
|
|
</span>
|
|
<script>
|
|
(function () {
|
|
var el = document.getElementById("ms1-text-edit-mode");
|
|
if (!el || el.dataset.ms1Bound) return;
|
|
el.dataset.ms1Bound = "1";
|
|
el.addEventListener("change", function () {
|
|
var url = new URL(window.location.href);
|
|
url.searchParams.set("ms1_text_edit", this.checked ? "1" : "0");
|
|
window.location.href = url.toString();
|
|
});
|
|
})();
|
|
</script>';
|
|
}
|
|
|
|
function fxRenderEnvNoticeBar() {
|
|
global $vEnvNotice;
|
|
|
|
$strExtraSwitches = '';
|
|
if (function_exists('fxAdminCanUsePermInspectTools') && fxAdminCanUsePermInspectTools()) {
|
|
$strExtraSwitches .= fxAdminPermInspectSwitchHtml();
|
|
}
|
|
|
|
if (trim($vEnvNotice) === '') {
|
|
if ($strExtraSwitches !== '') {
|
|
echo '<div class="alert alert-secondary py-1 mb-0 text-center sticky-top">' . $strExtraSwitches . '</div>';
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (!fxAdminCanUseTextEditTools()) {
|
|
echo $vEnvNotice;
|
|
if ($strExtraSwitches !== '') {
|
|
echo '<div class="alert alert-secondary py-1 mb-0 text-center sticky-top">' . $strExtraSwitches . '</div>';
|
|
}
|
|
return;
|
|
}
|
|
|
|
$strSwitch = fxAdminTextEditSwitchHtml() . $strExtraSwitches;
|
|
$strHtml = preg_replace('/<\/strong>/', '</strong> ' . $strSwitch, trim($vEnvNotice), 1);
|
|
|
|
if ($strHtml === null || $strHtml === trim($vEnvNotice)) {
|
|
echo $vEnvNotice;
|
|
echo $strSwitch;
|
|
echo fxAdminTradMarkerScriptHtml();
|
|
return;
|
|
}
|
|
|
|
echo $strHtml;
|
|
echo fxAdminTradMarkerScriptHtml();
|
|
}
|
|
|
|
/**
|
|
* Description : Fonction pour ajouter le value dans une formes
|
|
* Parametres : $mem_champ nom du champs ,$mem_defaut,$mem_type add ou mod ,$mem_infos tableau des info
|
|
* Créateur : stephan
|
|
* Date : 13-04-20
|
|
*/
|
|
function fxFormFieldInfo($mem_champ, $mem_type, $mem_infos, $mem_defaut = "", $mem_array = 0) {
|
|
if ($mem_array == 0)
|
|
$mem_value = 'id="' . $mem_champ . '" name="' . $mem_champ . '"';
|
|
else
|
|
$mem_value = 'id="info['.$mem_array.'][' . $mem_champ . ']" name="info['.$mem_array.'][' . $mem_champ . ']"';
|
|
|
|
switch ($mem_type) {
|
|
// AJOUT
|
|
case 'add':
|
|
if (trim($mem_defaut != ''))
|
|
$mem_value = $mem_value . ' value="' . $mem_defaut . '"';
|
|
break;
|
|
case 'mod':
|
|
case 'checkout':
|
|
$mem_value = $mem_value . ' value="' . $mem_infos[$mem_champ] . '"';
|
|
break;
|
|
}
|
|
|
|
return $mem_value;
|
|
}
|
|
|
|
function fxFormFieldCheck($mem_champ, $mem_type, $mem_infos, $mem_valide, $mem_defaut = "",$mem_action="") {
|
|
$mem_value = '';
|
|
|
|
switch ($mem_type) {
|
|
// AJOUT
|
|
case 'add':
|
|
if (trim($mem_defaut != ''))
|
|
$mem_value = 'checked="checked"';
|
|
break;
|
|
case 'mod':
|
|
case 'checkout':
|
|
if($mem_action=="mod")
|
|
{
|
|
if ($mem_infos[$mem_champ] == $mem_valide)
|
|
$mem_value = 'checked';
|
|
else
|
|
$mem_value = 'disabled';
|
|
}else{
|
|
if ($mem_infos[$mem_champ] == $mem_valide)
|
|
$mem_value = 'checked="checked"';
|
|
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
return $mem_value;
|
|
}
|
|
|
|
function fxFormFieldChecklist($mem_champ, $mem_type, $mem_infos, $mem_valide, $mem_defaut) {
|
|
$mem_value = '';
|
|
|
|
switch ($mem_type) {
|
|
// AJOUT
|
|
case 'add':
|
|
case 'addaffilie':
|
|
if ($mem_defaut == $mem_valide)
|
|
$mem_value = 'selected="selected"';
|
|
break;
|
|
case 'mod':
|
|
case 'checkout':
|
|
if ($mem_infos[$mem_champ] == $mem_valide)
|
|
$mem_value = 'selected="selected"';
|
|
break;
|
|
}
|
|
|
|
return $mem_value;
|
|
}
|
|
|
|
function fxSetInfo($strAction, $tabData, $strLangue, $id = 0) {
|
|
global $objDatabase;
|
|
$_SESSION['msg'] = "";
|
|
|
|
switch ($strAction) {
|
|
// AJOUT
|
|
case 'add':
|
|
// former le INSERT
|
|
$tabFieldsValues = fxListFieldsValues($tabData, 'pk_info', 'info', $GLOBALS['arrConDatabaseMain']['db']);
|
|
// vérifie si le info existe
|
|
$sqlValide = "SELECT COUNT(info_clef) from info where info_clef='" . $tabData['info_clef'] . "' and info_prg='" . $tabData['info_prg'] . "' and info_langue='".$tabData['info_langue']."'";
|
|
$nbValide = $objDatabase->fxGetVar($sqlValide);
|
|
if ($nbValide > 0) {
|
|
break;
|
|
}
|
|
// insérer les infos du participants
|
|
$sqlInsert = "INSERT INTO info " . $tabFieldsValues['set'] . ',info_creation=now()';
|
|
$qryInsert = $objDatabase->fxQuery($sqlInsert);
|
|
// récupérer le id ajouté
|
|
$intCompte = $objDatabase->fxGetLastId();
|
|
// $_SESSION['com_id'] = $intCompte;
|
|
break;
|
|
|
|
// MODIFICATION
|
|
case 'mod':
|
|
$tabFieldsValues = fxListFieldsValues($tabData, 'pk_info', 'info', $GLOBALS['arrConDatabaseMain']['db']);
|
|
// verification des champs obligatoire
|
|
// update les infos
|
|
$sqlUpdate = "UPDATE info " . $tabFieldsValues['set'] . ",info_maj=now() where ". $tabFieldsValues['key'];
|
|
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
|
|
// définir le message à affiche
|
|
break;
|
|
|
|
// SUPPRESSION
|
|
case 'del':
|
|
/* PLUS TARD
|
|
$sqlDelete = "DELETE FROM ".$bd." WHERE ".$memid." = " . intval($id);
|
|
$qryDelete = $objDatabase->fxQuery($sqlDelete); */
|
|
}
|
|
}
|
|
|
|
function afficheTexteReplace($mem_tab_replace, $mem_texte) {
|
|
foreach ($mem_tab_replace as $key => $value)
|
|
$mem_texte=str_replace($key, $value, $mem_texte);
|
|
|
|
return $mem_texte;
|
|
}
|
|
|
|
function tabhoraire_var($tabEvenement, $strLangue) {
|
|
$strOutput = '
|
|
<table class="table table-sm table-striped horaire">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-left" style="width: 50%;">
|
|
' . afficheTexte('horaire_col_epreuve', 0) . '
|
|
</th>
|
|
<th class="text-left" style="width: 30%;">
|
|
Date
|
|
</th>
|
|
<th class="text-center" style="width: 20%;">
|
|
' . afficheTexte('horaire_col_heure', 0) . '
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
';
|
|
|
|
foreach ($tabEvenement['epreuves'] as $tabEpreuves) {
|
|
if ($tabEpreuves['tep_id'] == 1) {
|
|
$strOutput .= '
|
|
<tr>
|
|
<td class="text-left">
|
|
<div>
|
|
' . fxUnescape(ucfirst($tabEpreuves['epr_type_' . $strLangue])) . '
|
|
</div>
|
|
<div class="text-muted">
|
|
' . fxUnescape(ucfirst($tabEpreuves['epr_nom_' . $strLangue])) . '
|
|
</div>
|
|
</td>
|
|
<td class="text-left">
|
|
' . fxShowDate($tabEpreuves['epr_date'], $strLangue) . '
|
|
</td>
|
|
<td class="text-center">
|
|
' . fxShowTime($tabEpreuves['epr_heure']) . '
|
|
</td>
|
|
</tr>
|
|
';
|
|
}
|
|
}
|
|
|
|
$strOutput .= '
|
|
</tbody>
|
|
</table>
|
|
';
|
|
|
|
return $strOutput;
|
|
}
|
|
function tabprix_var($tabEvenement, $strLangue, $code, $vDomaine) {
|
|
if (isset($_SESSION['com_info']) && $_SESSION['com_info'] != '')
|
|
$blnIsPromoteur = fxIsPromoteur($_SESSION['com_info']['com_id'], $tabEvenement['general']['eve_id']);
|
|
else
|
|
$blnIsPromoteur = false;
|
|
|
|
$strOutput = '
|
|
<div class="table-responsive">
|
|
<table class="table table-striped reserver">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-left">
|
|
';
|
|
|
|
if (isset($tabEvenement['categorie_prix']) && $tabEvenement['categorie_prix']['cp_id'] != 1)
|
|
$strOutput .= '(' . $tabEvenement['categorie_prix']['cp_details_' . $strLangue] . ')';
|
|
|
|
$strOutput .= '</th>';
|
|
|
|
$x = 1;
|
|
|
|
foreach ($tabEvenement['dates_prix'] as $tabDate) {
|
|
$strOutput .= '
|
|
<th class="text-center" style="width: 150px!important;">
|
|
';
|
|
|
|
if ($tabDate != $tabEvenement['general']['eve_date_debut']) {
|
|
$strOutput .= afficheTexte('prix_jusqu', 0) . '<br>' . fxShowDate($tabDate, $strLangue);
|
|
} else {
|
|
if ($x != 1)
|
|
// patch pour afficher la date de l'evenement pour classique Salomon 2015
|
|
if($tabEvenement['general']['eve_id'] == 183)
|
|
$strOutput .= afficheTexte('prix_jusqu', 0) . '<br>' . strtolower(fxShowDate($tabEvenement['general']['eve_date_limite'], $strLangue));
|
|
else {
|
|
$strOutput .= afficheTexte('prix_jour_evenement', 0);
|
|
}
|
|
}
|
|
|
|
$strOutput .= '</th>';
|
|
$x++;
|
|
}
|
|
|
|
$mem_col = $x;
|
|
$strOutput .= '
|
|
</tr>
|
|
</thead>
|
|
';
|
|
$strCategorie = "";
|
|
|
|
if ($tabEvenement['general']['eve_logged'] == 1 && !isset($_SESSION['com_info'])) { // MSIN-1113
|
|
$strOutput .= '<div class="error-dash"><label class="error-dash">' . afficheTexte('eve_logged', 0) . '</label></div><br>';
|
|
}
|
|
|
|
foreach ($tabEvenement['epreuves'] as $tabEpreuves) {
|
|
if (intval($tabEvenement['general']['te_id']) == 13) {
|
|
if ($tabEpreuves['mst_id'] == 2) {
|
|
$strLabel = 'btn-renew-text';
|
|
} else {
|
|
$strLabel = 'btn-subscribe-text';
|
|
}
|
|
} else {
|
|
$strLabel = 'btn-book-text';
|
|
}
|
|
$strDateLimite = $tabEpreuves['epr_date_limite'] . ' ' . $tabEpreuves['epr_heure_limite'];
|
|
$strOuvertureInscription = $tabEpreuves['epr_date_limite_debut'] . " " . $tabEpreuves['epr_heure_limite_debut'];
|
|
|
|
if ($blnIsPromoteur || $tabEpreuves['epr_hidden'] == 0) {
|
|
if (fxUnescape($tabEpreuves['epr_categorie_' . $strLangue]) != $strCategorie) {
|
|
if (trim($strCategorie) != '') {
|
|
$strOutput .= '</tbody>';
|
|
}
|
|
|
|
$strOutput .= '
|
|
<thead>
|
|
<tr class="bg-transparent">
|
|
<td colspan="' . $mem_col . '">
|
|
<h2>
|
|
' . fxUnescape($tabEpreuves['epr_categorie_' . $strLangue]) . '
|
|
</h2>
|
|
</td>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
';
|
|
}
|
|
|
|
$strCategorie = fxUnescape(ucfirst($tabEpreuves['epr_categorie_' . $strLangue]));
|
|
}
|
|
|
|
|
|
if ($blnIsPromoteur) {
|
|
$strOutput .= '
|
|
<tr>
|
|
<td class="text-left" data-qte="' . $tabEpreuves['epr_qte'] . '">
|
|
<div>
|
|
' . fxUnescape(ucfirst($tabEpreuves['epr_type_' . $strLangue])) . '
|
|
</div>
|
|
<div class="text-muted">
|
|
' . fxUnescape(ucfirst($tabEpreuves['epr_nom_' . $strLangue])) . '
|
|
</div>
|
|
<button id="btn_click_' . $tabEpreuves['epr_id'] . '" name="btn_click_' . $tabEpreuves['epr_id'] . '" class="btn btn-primary rounded-pill mr-2 my-2 reservation" data-toggle="tooltip" onClick="location.href=' . chr(39) . $vDomaine . '/' . afficheTexte('reserver_reserver', 0) . '/' . $code . '/' . fxUnescape($tabEpreuves['epr_id']) . chr(39) . '" title="' . afficheTexte('reserver_inscrire', 0) . '">
|
|
' . afficheTexte($strLabel, 0) . '
|
|
</button>
|
|
</td>
|
|
';
|
|
} else {
|
|
if ($tabEpreuves['epr_hidden'] == 0) {
|
|
if ($strDateLimite >= fxGetDateTime() && $tabEpreuves['epr_non_reservable'] == 0) {
|
|
$strDisabled = '';
|
|
$strSoldOut = '';
|
|
|
|
if ($tabEpreuves['epr_qte_limitee'] == 1 && $tabEpreuves['epr_qte'] <= 0) {
|
|
$strDisabled = 'disabled="disabled"';
|
|
$strSoldOut = ' - <strong class="text-danger">' . afficheTexte('epr_soldout', 0) . '</strong>';
|
|
}
|
|
|
|
$strOutput .= '
|
|
<tr>
|
|
<td class="text-left" data-qte="' . $tabEpreuves['epr_qte'] . '">
|
|
<div>
|
|
' . fxUnescape(ucfirst($tabEpreuves['epr_type_' . $strLangue])) . $strSoldOut . '
|
|
</div>
|
|
';
|
|
|
|
if ($tabEpreuves['epr_nom_' . $strLangue] != '') {
|
|
$strOutput .= '
|
|
<div class="text-muted">
|
|
' . fxUnescape(ucfirst($tabEpreuves['epr_nom_' . $strLangue])) . '
|
|
</div>
|
|
';
|
|
}
|
|
|
|
if (($tabEvenement['general']['eve_logged'] != 1 || isset($_SESSION['com_info'])) && $strOuvertureInscription <= fxGetDateTime()) { // MSIN-1113, MSIN-932
|
|
$strOutput .= '
|
|
<button ' . $strDisabled . ' id="btn_click_' . $tabEpreuves['epr_id'] . '" name="btn_click_' . $tabEpreuves['epr_id'] . '" class="btn btn-primary rounded-pill mr-2 my-2 reservation" data-toggle="tooltip" onClick="location.href=' . chr(39) . $vDomaine . '/' . afficheTexte('reserver_reserver', 0) . '/' . $code . '/' . fxUnescape($tabEpreuves['epr_id']) . chr(39) . '" title="' . afficheTexte('reserver_inscrire', 0) . '">
|
|
' . afficheTexte($strLabel, 0) . '
|
|
</button>
|
|
';
|
|
}
|
|
|
|
$strOutput .= '</td>';
|
|
} else { //MSIN-949
|
|
$strOutput .= '
|
|
<tr>
|
|
<td class="text-left">
|
|
<div>
|
|
';
|
|
|
|
if (strpos($tabEpreuves['epr_nom_' . $strLangue], trim($tabEpreuves['epr_type_' . $strLangue])) == 0)
|
|
$strOutput .= fxUnescape(ucfirst($tabEpreuves['epr_type_' . $strLangue]));
|
|
|
|
$strOutput .= '
|
|
</div>
|
|
<div class=text-muted">
|
|
' . fxUnescape(ucfirst($tabEpreuves['epr_nom_' . $strLangue])) . '
|
|
</div>
|
|
';
|
|
|
|
if ($tabEpreuves['epr_qte_limitee'] == 1 && $tabEpreuves['epr_qte'] < 1) {
|
|
$strOutput .= '
|
|
<div>
|
|
<strong class="text-danger">' . afficheTexte('epr_soldout', 0) . '</strong>
|
|
</div>
|
|
';
|
|
}
|
|
|
|
if ($tabEpreuves['epr_non_reservable'] == 1) {
|
|
$strOutput .= '
|
|
<div>
|
|
<strong class="text-warning">' . afficheTexte('epr_non_reservable', 0) . '</strong>
|
|
</div>
|
|
';
|
|
}
|
|
|
|
$strOutput .= '
|
|
</span>
|
|
</td>
|
|
';
|
|
}
|
|
}
|
|
}
|
|
|
|
$mem_tabdateavant = "";
|
|
|
|
foreach ($tabEvenement['dates_prix'] as $tabDate) {
|
|
if ($tabEpreuves['epr_hidden'] == 0) {
|
|
// définir la class selon la date
|
|
if ($tabDate >= fxGetDate() || $tabDate == $tabEvenement['general']['eve_date_debut'])
|
|
$strClass = 'hilighted';
|
|
else
|
|
$strClass = 'grayed text-muted';
|
|
|
|
$strOutput .= '<td class="' . $strClass . ' text-center">';
|
|
|
|
if (isset($tabEvenement['prix'][$tabEpreuves['epr_id']][$tabDate])) {
|
|
if (floatval($tabEvenement['prix'][$tabEpreuves['epr_id']][$tabDate]['ep_montant_affiche']) > 0) {
|
|
$fltPrix = $tabEvenement['prix'][$tabEpreuves['epr_id']][$tabDate]['ep_montant_affiche'];
|
|
} else {
|
|
$fltPrix = $tabEvenement['prix'][$tabEpreuves['epr_id']][$tabDate]['ep_montant'];
|
|
}
|
|
|
|
// if ($mem_tabdateavant <= $tabEpreuves['epr_date_limite']) {
|
|
if ($tabDate <= $tabEpreuves['epr_date_limite']) {
|
|
if (floatval($fltPrix) != 0)
|
|
$strOutput .= fxShowPrix($fltPrix, $strLangue, 1);
|
|
else
|
|
$strOutput .= afficheTexte('reserver_gratuit', 0);
|
|
} elseif ($tabDate > $tabEpreuves['epr_date_limite']) {
|
|
if (floatval($fltPrix) != 0)
|
|
$strOutput .= fxShowPrix($fltPrix, $strLangue, 1);
|
|
}
|
|
|
|
if ($tabEpreuves['epr_taxes_incluses'] == 1 && $fltPrix != 0)
|
|
$strOutput .= ' * ';
|
|
} else {
|
|
$strOutput .= '-';
|
|
}
|
|
|
|
$strOutput .= '</td>';
|
|
$mem_tabdateavant = $tabDate;
|
|
}
|
|
}
|
|
|
|
$strOutput .= '</tr>';
|
|
}
|
|
|
|
$strOutput .= '
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
';
|
|
|
|
return $strOutput;
|
|
}
|
|
function fxShowTabPrix($tabEvenement, $strLangue, $code, $vDomaine) {
|
|
$blnIsPromoteur = false;
|
|
$blnLogged = false;
|
|
//$intQteWarning = 10; // 10%
|
|
$intQteWarning = 5;
|
|
$intQteAffichee = 0;
|
|
$strCategorie = 'vide';
|
|
$strOutput = $strHeader = $strDisabled = "";
|
|
$strDateEvenement = $tabEvenement['general']['eve_date_debut'];
|
|
|
|
if (isset($_SESSION['com_info']) && $_SESSION['com_info'] != '') {
|
|
$blnIsPromoteur = fxIsPromoteur($_SESSION['com_info']['com_id'], $tabEvenement['general']['eve_id']);
|
|
}
|
|
|
|
if (intval($tabEvenement['general']['eve_logged']) == 1 && !isset($_SESSION['com_info'])) { // si l'événement exige d'être loggé et qu'on l'est pas, afficher un message
|
|
$blnLogged = true;
|
|
$strOutput .= '
|
|
<div class="alert alert-danger">
|
|
' . afficheTexte('eve_logged', 0) . '
|
|
</div>
|
|
';
|
|
}
|
|
|
|
if ($tabEvenement['epreuves'] != null) {
|
|
foreach ($tabEvenement['epreuves'] as $tabEpreuves) {
|
|
$strBadge = $strHeaderLabel = '';
|
|
$strLink = $vDomaine . '/' . afficheTexte('reserver_reserver', 0) . '/' . $code . '/' . fxUnescape($tabEpreuves['epr_id']);
|
|
$strDateLimite = $tabEpreuves['epr_date_limite'] . ' ' . $tabEpreuves['epr_heure_limite'];
|
|
$strOuvertureInscription = $tabEpreuves['epr_date_limite_debut'] . " " . $tabEpreuves['epr_heure_limite_debut'];
|
|
$arrPrixFinal = fxGetEpreuvePrix($tabEpreuves['epr_id'], $strDateEvenement, $blnIsPromoteur, $strLangue);
|
|
//$strlistePrix = '<pre>' . print_r($arrPrixFinal, true) . '</pre>';
|
|
|
|
|
|
|
|
$strlistePrix = fxShowListePrix($arrPrixFinal, $strLangue);
|
|
|
|
if ($strOuvertureInscription > fxGetDateTime()) {
|
|
$blnDisabled = true;
|
|
$strBadge = '
|
|
<div class="bg-warning mb-2 p-1 rounded text-center">
|
|
<strong>
|
|
' . afficheTexte('epr_header_pas_encore_ouvert', 0) . '
|
|
</strong>
|
|
</div>
|
|
';
|
|
} elseif ($strDateLimite < fxGetDateTime()) {
|
|
$blnDisabled = true;
|
|
//$blnIsPromoteur = false;
|
|
$strBadge = '
|
|
<div class="bg-dark p-2 rounded text-center text-white">
|
|
<strong>
|
|
' . afficheTexte('epr_header_plus_reservable', 0) . '
|
|
</strong>
|
|
</div>
|
|
';
|
|
} else {
|
|
$blnDisabled = false;
|
|
}
|
|
|
|
if ($blnIsPromoteur || (/*$strDateLimite >= fxGetDateTime() &&*/ intval($tabEpreuves['epr_hidden']) == 0) && count($arrPrixFinal) > 0) { // si promoteur OU (date limite N'EST PAS passée ET épreuve N'EST PAS CACHÉE), afficher les épreuves
|
|
if (intval($tabEvenement['general']['te_id']) == 13) { // si événement membership
|
|
if ($tabEpreuves['mst_id'] == 2) {
|
|
$strLabel = 'btn-renew-text';
|
|
} else {
|
|
$strLabel = 'btn-subscribe-text';
|
|
}
|
|
// entête par défaut
|
|
$strHeader = '
|
|
<div class="card-header bg-primary text-center text-white">
|
|
<div class="card-title h5 mb-0">
|
|
' . afficheTexte($strLabel, 0) . '
|
|
</div>
|
|
</div>
|
|
';
|
|
} else { // si événement normal
|
|
$strLabel = 'btn-book-text';
|
|
$strHeaderLabel = ($tabEvenement['general']['eve_date_debut'] == $tabEvenement['general']['eve_date_fin']) ? afficheTexte($strLabel, 0) : fxShowDate($tabEpreuves['epr_date'], $strLangue);
|
|
$strHeaderLabel = (intval($tabEvenement['general']['eve_default_header']) == 1) ? afficheTexte($strLabel, 0) : fxShowDate($tabEpreuves['epr_date'], $strLangue);
|
|
// entête par défaut
|
|
$strHeader = '
|
|
<div class="card-header bg-primary text-center text-white">
|
|
<div class="card-title h5 mb-0">
|
|
' . $strHeaderLabel . '
|
|
</div>
|
|
</div>
|
|
';
|
|
}
|
|
|
|
if (fxUnescape($tabEpreuves['epr_categorie_' . $strLangue]) != $strCategorie) {
|
|
if (trim($strCategorie) != 'vide') {
|
|
$strOutput .= '</div>';
|
|
}
|
|
|
|
$strOutput .= '
|
|
<h2 class="border-bottom">
|
|
' . fxUnescape($tabEpreuves['epr_categorie_' . $strLangue]) . '
|
|
</h2>
|
|
<div class="row my-5 row-cols-1 row-cols-md-2 row-cols-lg-3">
|
|
';
|
|
|
|
$intQteAffichee++;
|
|
}
|
|
|
|
$strCategorie = fxUnescape(ucfirst($tabEpreuves['epr_categorie_' . $strLangue]));
|
|
|
|
// gestion des colonnes d'entête
|
|
if ($blnIsPromoteur) { // si promoteur, afficher toutes les épreuves
|
|
$strBadge = '
|
|
<div class="bg-info mb-2 p-1 rounded text-center text-white">
|
|
<strong>
|
|
' . afficheTexte('epr_header_promoter', 0) . '
|
|
<a tabindex="0" class="btn btn-dark rounded-rounded" role="button" data-toggle="popover" title="Liste de prix" data-content="' . htmlspecialchars($strlistePrix) . '" data-html="true">
|
|
$$
|
|
</a>
|
|
</strong>
|
|
</div>
|
|
' . $strBadge;
|
|
} else { // si NON promoteur
|
|
if (intval($tabEpreuves['epr_non_reservable']) == 1) { // si l'éppeuve N'EST PAS réservable
|
|
$blnDisabled = true; // rendre le bouton résever inactif
|
|
$strBadge = '
|
|
<div class="bg-dark mb-2 p-1 rounded text-center text-white">
|
|
<strong>
|
|
' . afficheTexte('epr_header_non_reservable', 0) . '
|
|
</strong>
|
|
</div>
|
|
';
|
|
} else { // si l'éppeuve EST réservable
|
|
if (intval($tabEpreuves['epr_qte_limitee']) == 1) { // si quantité limitée
|
|
if (intval(fx_liste_attente_valideqte(intval($tabEpreuves['epr_id']))) > 0) {
|
|
if (trim($strBadge) == '') {
|
|
if (intval($tabEpreuves['epr_qte']) <= $intQteWarning) { // si quantité restante faible
|
|
$strBadge = '
|
|
<div class="bg-warning mb-2 p-1 rounded text-center">
|
|
<strong>
|
|
' . afficheTexte('epr_header_hurry', 0) . '
|
|
</strong>
|
|
</div>
|
|
';
|
|
}
|
|
}
|
|
} elseif (fx_liste_attente_valideqte(intval($tabEpreuves['epr_id'])) <= 0) { // si tout vendu valide liste_attente avant intval($tabEpreuves['epr_qte']) <= 0
|
|
|
|
|
|
$blnDisabled = true; // rendre le bouton résever inactif
|
|
|
|
|
|
$strBadge = '
|
|
<div class="bg-danger mb-2 p-1 rounded text-center text-white">
|
|
<strong>
|
|
' . afficheTexte('epr_header_soldout', 0) . '
|
|
</strong>
|
|
</div>
|
|
';
|
|
$strBadge = $strBadge . fx_liste_attente_boutonajoute_listeactive($tabEpreuves["epr_id"]);
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$strOutput .= '
|
|
<div class="col mb-3">
|
|
<div class="card h-100" data-qte="' . $tabEpreuves['epr_qte'] . '">
|
|
' . $strHeader . '
|
|
<div class="card-body row">
|
|
<div class="col-6 pr-0">
|
|
<div class="d-flex flex-column h-100">
|
|
<div class="mb-auto">
|
|
<h5 class="card-title">
|
|
' . fxUnescape(ucfirst($tabEpreuves['epr_type_' . $strLangue])) . '
|
|
</h5>
|
|
<div class="card-text text-muted">
|
|
' . fxUnescape(ucfirst($tabEpreuves['epr_nom_' . $strLangue])) . '
|
|
</div>
|
|
</div>
|
|
<div class="card-text">
|
|
';
|
|
|
|
$strOutput .= $strBadge;
|
|
|
|
if ((!$blnDisabled && !$blnLogged) || $blnIsPromoteur) { // Afficher le bouton si on peut réserver
|
|
$strOutput .= '
|
|
<a class="btn btn-primary rounded-pill mr-2 my-2" href="' . $strLink . '" role="button">
|
|
' . afficheTexte($strLabel, 0) . '
|
|
</a>
|
|
';
|
|
}
|
|
|
|
$strprix=fxShowEpreuvePrix($arrPrixFinal, $strLink, $blnDisabled, $blnLogged, $strLangue,$tabEvenement['general']['eve_affichage_frais'] ) ;
|
|
$strprixOutput= $strprix["strOutput"];
|
|
;
|
|
|
|
if($tabEvenement['general']['eve_affichage_frais']==1){
|
|
$strprixfraisOutput = '<div class="card-text text-center text-muted">' .number_format(floatval( $strprix['fltPrixActuel']-$strprix['fltFraisActuel']), 2)."$ ". afficheTexte('text_frais', 0) . ' </div>
|
|
|
|
';}else{
|
|
$strprixfraisOutput="";
|
|
|
|
}
|
|
|
|
|
|
$strOutput .= '
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="border-left col-6 text-center">
|
|
<div class="d-flex flex-column h-100">
|
|
' . $strprixOutput . '
|
|
</div>
|
|
</div>
|
|
</div> ' . $strprixfraisOutput . '
|
|
</div>
|
|
</div>
|
|
';
|
|
}
|
|
}
|
|
|
|
if ($intQteAffichee > 0) {
|
|
$strOutput .= '</div>';
|
|
}
|
|
}
|
|
|
|
return $strOutput;
|
|
}
|
|
function tabprix_var_benevoles($tabEvenement, $strLangue, $code, $vDomaine) {
|
|
$strInfobulle = '';
|
|
$intCtr = 1;
|
|
$blnIsPromoteur = false;
|
|
|
|
if (isset($_SESSION['com_info']) && $_SESSION['com_info'] != '')
|
|
$blnIsPromoteur = fxIsPromoteur($_SESSION['com_info']['com_id'], $tabEvenement['general']['eve_id']);
|
|
|
|
$strOutput = '
|
|
<div class="accordion" id="accordion_event">
|
|
';
|
|
|
|
$strCategorie = "";
|
|
|
|
if ($tabEvenement['general']['eve_logged'] == 1 && !isset($_SESSION['com_info'])) { // MSIN-1113
|
|
$strOutput .= '
|
|
<div class="error-dash mb-3">
|
|
<label class="error-dash">' . afficheTexte('eve_logged', 0) . '</label>
|
|
</div>
|
|
';
|
|
}
|
|
|
|
foreach ($tabEvenement['epreuves'] as $intKey => $tabEpreuves) {
|
|
$strShow = ($intCtr == 1) ? ' show' : '';
|
|
$strShow = '';
|
|
$arrQte = fxGetQteBenevoles($tabEpreuves['epr_id']);
|
|
$strDateLimite = $tabEpreuves['epr_date_limite'] . ' ' . $tabEpreuves['epr_heure_limite'];
|
|
$strOuvertureInscription = $tabEpreuves['epr_date_limite_debut'] . " " . $tabEpreuves['epr_heure_limite_debut'];
|
|
|
|
if ($strDateLimite >= fxGetDateTime()) {
|
|
if (fxUnescape($tabEpreuves['epr_categorie_' . $strLangue]) != $strCategorie) {
|
|
if (trim($strCategorie) != '') {
|
|
$strOutput .= '
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
';
|
|
}
|
|
|
|
$strOutput .= '
|
|
<div class="card box_participant">
|
|
<div class="card-header" id="heading_' . $intKey . '">
|
|
<h2 class="mb-0">
|
|
<button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapse_' . $intKey . '" aria-expanded="true" aria-controls="collapse_' . $intKey . '">
|
|
' . fxUnescape($tabEpreuves['epr_categorie_' . $strLangue]) . '
|
|
</button>
|
|
</h2>
|
|
</div>
|
|
|
|
<div id="collapse_' . $intKey . '" class="collapse' . $strShow . ' aria-labelledby="heading_' . $intKey . '" data-parent="#accordion_event">
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-left">' . afficheTexte('benevoles_details_poste', 0) . '</th>
|
|
<th class="text-center">' . afficheTexte('benevoles_reserves-disponibles', 0) . '</th>
|
|
<th class="text-center">' . afficheTexte('benevoles_reserver', 0) . '</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
';
|
|
}
|
|
|
|
$strCategorie = fxUnescape(ucfirst($tabEpreuves['epr_categorie_' . $strLangue]));
|
|
|
|
if (trim($tabEpreuves['epr_description_' . $strLangue]) != '') {
|
|
$strInfobulle = '
|
|
<button class="btn btn-sm rounded-circle" type="button" data-toggle="popover" data-content="' . htmlspecialchars(fxUnescape(trim($tabEpreuves['epr_description_' . $strLangue]))) . '">
|
|
<i class="fa fa-info-circle fa-2x text-info" aria-hidden="true"></i>
|
|
</button>
|
|
';
|
|
} else {
|
|
$strInfobulle = '';
|
|
}
|
|
|
|
$strOutput .= '
|
|
<tr>
|
|
<td class="text-left">
|
|
<span class="poste">
|
|
' . fxUnescape(ucfirst($tabEpreuves['epr_type_' . $strLangue])) . $strInfobulle . '
|
|
</span><br>
|
|
<span class="heure">' . fxUnescape(ucfirst($tabEpreuves['epr_nom_' . $strLangue])) . ' </span>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="qte">' . $tabEpreuves['epr_qte'] . '</span>
|
|
</td>
|
|
';
|
|
|
|
if ($blnIsPromoteur) {
|
|
$strOutput .= '
|
|
<td class="text-center" data-qte="' . $tabEpreuves['epr_qte'] . '">
|
|
<button id="btn_click_' . $tabEpreuves['epr_id'] . '" name="btn_click_' . $tabEpreuves['epr_id'] . '" class="btn btn-primary rounded-pill" onClick="location.href=' . chr(39) . $vDomaine . '/' . afficheTexte('reserver_reserver', 0) . '/' . $code . '/' . fxUnescape($tabEpreuves['epr_id']) . chr(39) . '" title="' . afficheTexte('reserver_inscrire', 0) . '">' . afficheTexte('benevoles_reserver', 0) . '</button>
|
|
</td>
|
|
';
|
|
} else {
|
|
if ($tabEpreuves['epr_hidden'] == 0) {
|
|
if ($strDateLimite >= fxGetDateTime() && $tabEpreuves['epr_non_reservable'] == 0) {
|
|
$strOutput .= '
|
|
<td class="text-center" data-qte="' . $tabEpreuves['epr_qte'] . '">
|
|
';
|
|
|
|
if ($tabEpreuves['epr_qte_limitee'] == 1 && $tabEpreuves['epr_qte'] <= 0) {
|
|
$strOutput .= '<div class="badge badge-danger text-uppercase">' . afficheTexte('epr_soldout', 0) . '</div>';
|
|
} else {
|
|
if (($tabEvenement['general']['eve_logged'] != 1 || isset($_SESSION['com_info'])) && $strOuvertureInscription <= fxGetDateTime()) { // MSIN-1113, MSIN-932
|
|
$strOutput .= '
|
|
<button class="btn btn-primary rounded-pill" id="btn_click_' . $tabEpreuves['epr_id'] . '" name="btn_click_' . $tabEpreuves['epr_id'] . '" onClick="location.href=' . chr(39) . $vDomaine . '/' . afficheTexte('reserver_reserver', 0) . '/' . $code . '/' . fxUnescape($tabEpreuves['epr_id']) . chr(39) . '" title="' . afficheTexte('reserver_inscrire', 0) . '">
|
|
' . afficheTexte('benevoles_reserver', 0) . '
|
|
</button>
|
|
';
|
|
}
|
|
}
|
|
|
|
$strOutput .= '</td>';
|
|
} else { //MSIN-949<
|
|
$strOutput .= '<td class="text-center"><div>' . afficheTexte('epr_terminee', 0) . '</div>';
|
|
// MSIN-931
|
|
if ($tabEpreuves['epr_qte_limitee'] == 1 && $tabEpreuves['epr_qte'] < 1)
|
|
$strOutput .= '<div class="badge badge-danger text-uppercase">' . afficheTexte('epr_soldout', 0) . '</div>';
|
|
|
|
if ($tabEpreuves['epr_non_reservable'] == 1)
|
|
$strOutput .= '<div class="badge badge-warning text-uppercase">' . afficheTexte('epr_non_reservable', 0) . '</div>';
|
|
|
|
$strOutput .= '</td>';
|
|
}
|
|
}
|
|
}
|
|
|
|
$strOutput .= '</tr>';
|
|
}
|
|
|
|
$intCtr++;
|
|
}
|
|
|
|
$strOutput .= '
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
';
|
|
|
|
return $strOutput;
|
|
}
|
|
|
|
function fxGetEpreuvePrixfraisold($intEpreuve, $strDateEvenement, $blnIsPromoteur, $strLangue) {
|
|
global $objDatabase;
|
|
|
|
$strWhere = (!$blnIsPromoteur) ? ' AND p.ep_prive = 0' : '';
|
|
$arrFinal = array(
|
|
'actuel' => array(),
|
|
'fini' => array()
|
|
);
|
|
|
|
$sqlPrix = "
|
|
SELECT p.*, e.eve_frais, e.tt_id
|
|
FROM inscriptions_epreuves_prix p
|
|
JOIN inscriptions_epreuves ep ON ep.epr_id = p.epr_id
|
|
JOIN inscriptions_panier_evenements e ON e.eve_id = ep.eve_id
|
|
WHERE p.epr_id = " . intval($intEpreuve) . $strWhere . "
|
|
ORDER BY p.ep_date_limite ASC
|
|
";
|
|
$arrPrix = $objDatabase->fxGetResults($sqlPrix);
|
|
|
|
if ($arrPrix != null) {
|
|
$strToday = fxGetDate();
|
|
|
|
foreach ($arrPrix as $arr) {
|
|
|
|
$fltMontant = (floatval($arr['ep_montant_affiche']) > 0)
|
|
? $arr['ep_montant_affiche']
|
|
: $arr['ep_montant'];
|
|
|
|
$strKey = ($strToday <= $arr['ep_date_limite']) ? 'actuel' : 'fini';
|
|
|
|
/* ===== frais / taxes ===== */
|
|
|
|
$fltSousTotal = $fltMontant
|
|
+ $arr['ep_frais_montant']
|
|
+ $arr['ep_frais_tps']
|
|
+ $arr['ep_frais_tvq'];
|
|
|
|
$fltFraisAvantTaxes = 0;
|
|
$fltTotalTaxesFrais = 0;
|
|
$fltPourcent = 0;
|
|
|
|
if ($arr['eve_frais'] > 0) {
|
|
$sqlFrais = "
|
|
SELECT fra_avant_tx, fra_pourcent
|
|
FROM inscriptions_frais
|
|
WHERE fra_actif = 1
|
|
AND fra_montant_max >= " . floatval($fltSousTotal) . "
|
|
AND fra_montant_min <= " . floatval($fltSousTotal) . "
|
|
AND eve_frais = " . intval($arr['eve_frais']);
|
|
$tabFrais = $objDatabase->fxGetRow($sqlFrais);
|
|
|
|
if ($tabFrais) {
|
|
if ($tabFrais['fra_pourcent'] > 0) {
|
|
$fltFraisAvantTaxes = round($fltSousTotal * ($tabFrais['fra_pourcent'] / 100), 2);
|
|
$fltPourcent = $tabFrais['fra_pourcent'];
|
|
} else {
|
|
$fltFraisAvantTaxes = $tabFrais['fra_avant_tx'];
|
|
}
|
|
|
|
if ($arr['tt_id'] > 1) {
|
|
$sqlTaux = "
|
|
SELECT t.tau_taux
|
|
FROM inscriptions_taux t
|
|
JOIN inscriptions_taux_types_taux ttt ON t.tau_id = ttt.tau_id
|
|
WHERE ttt.tt_id = " . intval($arr['tt_id']);
|
|
$tabTaux = $objDatabase->fxGetResults($sqlTaux);
|
|
|
|
if ($tabTaux) {
|
|
foreach ($tabTaux as $tx) {
|
|
$fltTotalTaxesFrais += round($fltFraisAvantTaxes * ($tx['tau_taux'] / 100), 2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$arrFinal[$strKey][] = array(
|
|
|
|
'date_limite' => ($strToday != $strDateEvenement) ? afficheTexte('prix_jusqu', 0) . ' ' . fxShowDate($arr['ep_date_limite'], $strLangue) : afficheTexte('prix_jour_evenement', 0),
|
|
|
|
'montant' => $fltMontant,
|
|
'prive' => $arr['ep_prive'],
|
|
'fra_avant_tx' => $fltFraisAvantTaxes,
|
|
'fra_total' => $fltFraisAvantTaxes + $fltTotalTaxesFrais,
|
|
'fra_pourcent' => $fltPourcent
|
|
);
|
|
}
|
|
}
|
|
|
|
return $arrFinal;
|
|
}
|
|
|
|
|
|
function fxGetEpreuvePrix($intEpreuve, $strDateEvenement, $blnIsPromoteur, $strLangue) {
|
|
global $objDatabase;
|
|
$strWhere = (!$blnIsPromoteur) ? ' AND p.ep_prive = 0' : '';
|
|
$arrFinal = $arrKeys = array(
|
|
'actuel' => array(),
|
|
'fini' => array()
|
|
);
|
|
|
|
|
|
$sqlPrix = "
|
|
SELECT ep_montant, ep_montant_affiche, ep_date_limite, ep_prive
|
|
FROM inscriptions_epreuves_prix
|
|
WHERE epr_id = " . intval($intEpreuve) . $strWhere . "
|
|
ORDER BY ep_date_limite ASC
|
|
";
|
|
//MSIN-4296
|
|
$sqlPrix = "
|
|
SELECT p.*, e.eve_frais, e.tt_id,ep.epr_taxes_incluses
|
|
FROM inscriptions_epreuves_prix p
|
|
left JOIN inscriptions_epreuves ep ON ep.epr_id = p.epr_id
|
|
left JOIN inscriptions_evenements e ON e.eve_id = ep.eve_id
|
|
WHERE p.epr_id = " . intval($intEpreuve) . $strWhere . "
|
|
ORDER BY p.ep_date_limite ASC
|
|
";
|
|
$arrPrix = $objDatabase->fxGetResults($sqlPrix);
|
|
// echosl("sqlPrix");
|
|
// echosl($sqlPrix);
|
|
$flttotal=0;
|
|
if ($arrPrix != null) {
|
|
$strToday = fxGetDate(); // trouver la date du jour
|
|
$intCtr = 1;
|
|
|
|
foreach ($arrPrix as $arr) {
|
|
$fltMontant = (floatval($arr['ep_montant_affiche']) > 0) ? $arr['ep_montant_affiche'] : $arr['ep_montant'];
|
|
$strDateLimite = ($strToday != $strDateEvenement) ? afficheTexte('prix_jusqu', 0) . ' ' . fxShowDate($arr['ep_date_limite'], $strLangue) : afficheTexte('prix_jour_evenement', 0);
|
|
//MSIN-4344
|
|
/* ===== frais / taxes ===== */
|
|
|
|
$fltSousTotal = $fltMontant
|
|
+ $arr['ep_frais_montant']
|
|
+ $arr['ep_frais_tps']
|
|
+ $arr['ep_frais_tvq'];
|
|
|
|
$fltFraisAvantTaxes = 0;
|
|
$fltTotalTaxesFrais = 0;
|
|
$fltPourcent = 0;
|
|
if ($strToday <= $arr['ep_date_limite']) {
|
|
$strKey = 'actuel';
|
|
} else {
|
|
$strKey = 'fini';
|
|
}
|
|
if ($arr['eve_frais'] > 0) {
|
|
//MSIN-4344
|
|
/* ===== frais / taxes ===== */
|
|
|
|
$taxable=1-$arr['epr_taxes_incluses'];
|
|
$result = fxCalculerFrais($objDatabase, $fltSousTotal, $arr['eve_frais'], $arr['tt_id'],$taxable);
|
|
|
|
$fltFraisAvantTaxes = $result['frais_avant_taxes'];
|
|
$flttotal = $result['frais_avant_taxes'];
|
|
$fltPourcent = $result['frais_pourcentage'];
|
|
$flttaxes=0;
|
|
if (isset( $result['taxes_sur_frais'])){
|
|
$flttaxes = $result['taxes_sur_frais'];
|
|
}
|
|
// echosl("fxGetEpreuvePrix");
|
|
// print_rsl($result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$arrFinal[$strKey][] = array(
|
|
'date_limite' => $strDateLimite,
|
|
'montant' => $fltMontant,
|
|
'prive' => $arr['ep_prive'],
|
|
'fra_avant_tx' => $fltFraisAvantTaxes,
|
|
'fra_total' => $flttotal,
|
|
'fra_pourcent' => $fltPourcent
|
|
|
|
);
|
|
|
|
$intCtr++;
|
|
}
|
|
|
|
}
|
|
// echosl("arrFinal");
|
|
|
|
|
|
return $arrFinal;
|
|
}
|
|
function fxShowEpreuvePrix($arrFinal, $strLink, $blnDisabled, $blnLogged, $strLangue,$eve_affichage_frais=0) {
|
|
$strOutput = $strOff = $strDateLimite = '';
|
|
$fltPrixActuel = $fltPrixDernier =$fltFraisActuel= floatval(0);
|
|
|
|
if (count($arrFinal) > 0) {
|
|
$strOutput .= '
|
|
<div class="mb-auto">
|
|
';
|
|
|
|
if (count($arrFinal['actuel']) > 1) {
|
|
|
|
$fltFraisActuel = floatval(reset($arrFinal['actuel'])['fra_total']);
|
|
$fltPrixActuel = floatval(reset($arrFinal['actuel'])['montant']);
|
|
$fltPrixActuel =$fltPrixActuel +$fltFraisActuel;
|
|
$fltFraisDernier = floatval(end($arrFinal['actuel'])['fra_total']);
|
|
$fltPrixDernier = floatval(end($arrFinal['actuel'])['montant']);
|
|
|
|
$fltPrixDernier =$fltPrixDernier +$fltFraisDernier;
|
|
|
|
$strDateLimite = reset($arrFinal['actuel'])['date_limite'];
|
|
} elseif (count($arrFinal['actuel']) == 1) {
|
|
|
|
$fltFraisActuel = $fltFraisDernier = floatval(reset($arrFinal['actuel'])['fra_total']);
|
|
$fltPrixActuel = $fltPrixDernier = floatval(reset($arrFinal['actuel'])['montant']);
|
|
$fltPrixActuel=$fltPrixActuel+ $fltFraisActuel;
|
|
|
|
$strDateLimite = reset($arrFinal['actuel'])['date_limite'];
|
|
} elseif (count($arrFinal['fini']) > 0) {
|
|
|
|
$fltFraisActuel = $fltFraisDernier = floatval(end($arrFinal['fini'])['fra_total']);
|
|
$fltPrixActuel = $fltPrixDernier = floatval(end($arrFinal['fini'])['montant']);
|
|
$fltPrixActuel=$fltPrixActuel+ $fltFraisActuel;
|
|
$strDateLimite = end($arrFinal['fini'])['date_limite'];
|
|
}
|
|
|
|
if ($fltPrixDernier > $fltPrixActuel) {
|
|
$arrPrixSplit = explode('.', number_format($fltPrixDernier, 2));
|
|
$strPrix = '$<span class="mr-1"></span>' . $arrPrixSplit[0] . '<span class="cents">' . $arrPrixSplit[1] . '</span>';
|
|
$strOff .= '
|
|
<span class="badge badge-dark badge-notification" style="text-decoration: line-through;">
|
|
' . $strPrix . '
|
|
</span>
|
|
';
|
|
}
|
|
|
|
if ($fltPrixActuel > 0) {
|
|
$arrPrixSplit = explode('.', number_format(floatval($fltPrixActuel), 2));
|
|
|
|
$strPrix = '$<span class="mr-1"></span>' . $arrPrixSplit[0] . '<span class="cents">' . $arrPrixSplit[1] . '</span>';
|
|
|
|
$strPrix.= '<span class="prix-note">'.afficheTexte('text_frais_inclus', 0).'</span>';
|
|
} else {
|
|
$strPrix = afficheTexte('reserver_gratuit', 0);
|
|
}
|
|
// MSIN-4296 old
|
|
if($eve_affichage_frais==99){
|
|
$strOutput .= '<div class="card-text text-muted">'. afficheTexte('text_frais', 0) .'$' .number_format(floatval($fltFraisActuel), 2). ' </div>
|
|
|
|
';}
|
|
$strOutput .= '<div class="prix-epreuve-actuel">
|
|
<div class="bg-primary rounded-circle text-white position-relative">
|
|
';
|
|
|
|
if (!$blnDisabled && !$blnLogged) { // Afficher le bouton si on peut réserver
|
|
$strOutput .= '<a class="text-reset text-decoration-none" href="' . $strLink . '" role="button">';
|
|
}
|
|
|
|
$strOutput .= $strPrix . $strOff;
|
|
|
|
if (!$blnDisabled && !$blnLogged) { // Afficher le bouton si on peut réserver
|
|
$strOutput .= '</a>';
|
|
}
|
|
|
|
|
|
$strOutput .= '
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="prix-epreuve-date">
|
|
<div class="font-weight-bold mb-1">
|
|
' . afficheTexte('tarifs_valides', 0) . '
|
|
</div>
|
|
<div>
|
|
' . $strDateLimite . '
|
|
</div>
|
|
</div>
|
|
';
|
|
}
|
|
$strReturn['strOutput']=$strOutput;
|
|
$strReturn['fltPrixActuel']=$fltPrixActuel;
|
|
$strReturn['fltFraisActuel']=$fltFraisActuel;
|
|
|
|
|
|
|
|
return $strReturn;
|
|
}
|
|
function fxShowListePrix($arrPrixFinal, $strLangue) {
|
|
$strOutput = '';
|
|
|
|
if (count($arrPrixFinal) > 0) {
|
|
$strOutput .= '<table class="table table-bordered table-condensed">';
|
|
|
|
if (count($arrPrixFinal['actuel']) > 0) {
|
|
foreach($arrPrixFinal['actuel'] as $arr) {
|
|
|
|
$strPrive = (intval($arr['prive']) == 1) ? 'privé' : 'public';
|
|
$strOutput .= '
|
|
<tr class="table-success">
|
|
<td>' . fxShowPrix($arr['montant'], $strLangue) . '</td>
|
|
<td>' . $arr['date_limite'] . '</td>
|
|
<td>' . $strPrive . '</td>
|
|
</tr>
|
|
';
|
|
}
|
|
}
|
|
if (count($arrPrixFinal['fini']) > 0) {
|
|
foreach($arrPrixFinal['fini'] as $arr) {
|
|
$strPrive = (intval($arr['prive']) == 1) ? 'privé' : 'public';
|
|
$strOutput .= '
|
|
<tr class="table-danger">
|
|
<td>' . fxShowPrix($arr['montant'], $strLangue) . '</td>
|
|
<td>' . $arr['date_limite'] . '</td>
|
|
<td>' . $strPrive . '</td>
|
|
</tr>
|
|
';
|
|
}
|
|
}
|
|
|
|
$strOutput .= '</table>';
|
|
}
|
|
|
|
return $strOutput;
|
|
} |