1010 lines
46 KiB
PHP
1010 lines
46 KiB
PHP
<?php
|
|
error_reporting(E_ALL);
|
|
ini_set("display_errors", 0);
|
|
ini_set('max_execution_time', 250);
|
|
|
|
|
|
//$strResultat = fxUpdateFinancesMembership($intEvenement);
|
|
$strResultat =fxUpdateFinancesMembershipall();
|
|
|
|
//$strResultat = fxUpdateFinancesMembership(1103);
|
|
|
|
$mem_tq=649;
|
|
|
|
$arrSum = array();
|
|
$strWhere2 = $strFields2 = '';
|
|
$blnDon = false;
|
|
$intWidthQuestions = $intNbQuestions = 0;
|
|
|
|
// colonne
|
|
$sqlCol = "SELECT *, (SELECT SUM(info_option1) FROM info WHERE info_actif = 1 AND (info_clef = 'rap_finances_membership') AND info_langue = '" . $strLangue . "') AS width FROM info WHERE info_actif = 1 AND (info_clef = 'rap_finances_membership') AND info_langue = '" . $strLangue . "' ORDER BY info_trie";
|
|
$tabCol = $objDatabase->fxGetResults($sqlCol);
|
|
|
|
// produits
|
|
$sqlColProduits = "SELECT pro_id, pro_nom_$strLangue FROM inscriptions_produits_new WHERE eve_id = " . intval($mem_tq);
|
|
$tabColProduits = $objDatabase->fxGetResults($sqlColProduits);
|
|
|
|
|
|
$newTab = [];
|
|
$index = 1;
|
|
if (1==1){
|
|
foreach ($tabColProduits as $ligne) {
|
|
// 1. Ligne montant
|
|
$ligne_montant = $ligne;
|
|
$ligne_montant['type'] = 'montant';
|
|
$newTab[$index++] = $ligne_montant;
|
|
|
|
|
|
// $newTab[$index++] = $ligne_net;
|
|
}
|
|
}
|
|
// Résultat final
|
|
|
|
$tabColProduits=$newTab;
|
|
// Résultat final dans $newTab
|
|
|
|
|
|
// SQL
|
|
$sqlAcheteurs = "
|
|
SELECT
|
|
a.eve_id, (eve_nom_$strLangue) AS eve_nom, a.no_commande, a.no_panier, a.com_nom, a.com_prenom, a.ach_maj, a.TransactionID, s.sta_nom_fr AS statut, p.pai_nom_fr AS paiement, a.ach_total, a.fra_total, a.fra_taxe1, a.fra_taxe2, a.fra_avant_tx,
|
|
IF(a.pai_id = 6,
|
|
0,
|
|
(a.ach_total - a.fra_total)) AS montant_promoteur,
|
|
a.ach_taxe1, a.ach_taxe2, (a.ach_total - (a.fra_total + a.ach_taxe1 + a.ach_taxe2 + a.ach_taxe3)) AS montant_promoteur_avant_tx
|
|
$strFields2
|
|
FROM
|
|
inscriptions_panier_acheteurs a
|
|
JOIN inscriptions_paiements p ON a.pai_id = p.pai_id
|
|
JOIN inscriptions_panier_statuts s ON a.sta_id = s.sta_id
|
|
JOIN inscriptions_evenements e ON e.eve_id = a.eve_id
|
|
";
|
|
|
|
if ($mem_where_tq == "tout") {
|
|
|
|
//MSIN-4277
|
|
$sqlAcheteursxx = "
|
|
WHERE
|
|
a.sta_id = 3
|
|
AND a.pai_id <> 6
|
|
AND (
|
|
a.eve_id = " . intval($intEvenement) . "
|
|
OR
|
|
a.no_panier IN(SELECT DISTINCT(no_panier) FROM inscriptions_panier_produits_new WHERE eve_id = " . intval($intEvenement) . ")
|
|
)
|
|
";
|
|
|
|
|
|
$sqlAcheteurs .= "
|
|
WHERE
|
|
a.sta_id = 3
|
|
|
|
AND (
|
|
a.eve_id = " . intval($intEvenement) . "
|
|
OR
|
|
a.no_panier IN(SELECT DISTINCT(no_panier) FROM inscriptions_panier_produits_new WHERE eve_id = " . intval($intEvenement) . ")
|
|
)
|
|
";
|
|
|
|
|
|
}
|
|
|
|
if ($mem_where_tq == "promoteur") {
|
|
$sqlAcheteurs .= "
|
|
WHERE
|
|
a.sta_id = 3
|
|
AND a.pai_id <> 6
|
|
AND (
|
|
a.eve_id = " . intval($intEvenement) . "
|
|
OR
|
|
a.no_panier IN(SELECT DISTINCT(no_panier) FROM inscriptions_panier_produits_new WHERE eve_id = " . intval($intEvenement) . ")
|
|
)
|
|
";
|
|
|
|
|
|
}
|
|
if ($mem_where_tq == "tq") {
|
|
$sqlAcheteurs .= "
|
|
WHERE
|
|
a.sta_id = 3
|
|
AND a.pai_id <> 6
|
|
AND
|
|
a.eve_id = " . intval($intEvenement);
|
|
|
|
}
|
|
if ($mem_where_tq == "autre") {
|
|
$sqlAcheteurs .= "
|
|
WHERE
|
|
a.sta_id = 3
|
|
AND a.pai_id <> 6
|
|
AND (
|
|
a.eve_id = " . intval($intEvenement) . "
|
|
OR
|
|
a.no_panier IN(SELECT DISTINCT(no_panier) FROM inscriptions_panier_produits_new WHERE eve_id = " . intval($intEvenement) . ")
|
|
) and a.eve_id != " . intval($intEvenement);
|
|
|
|
|
|
|
|
}
|
|
if (isset($strWhere['acheteur']) && trim($strWhere['acheteur']) != '') {
|
|
$sqlAcheteurs .= " AND " . $strWhere['acheteur'];
|
|
} else { // mettre la recherche par défaut:
|
|
// $sqlAcheteurs .= " AND a.ach_maj = '" . fxGetDate() . "'"; // aujourd'hui
|
|
//$sqlAcheteurs .= " AND MONTH(a.ach_maj) = '" . date('m') . "' AND YEAR(a.ach_maj) = '" . date('Y') . "'"; // cse mois-ci
|
|
}
|
|
|
|
/*************
|
|
* SQl COUNT *
|
|
*************/
|
|
$blnPager = true;
|
|
$sqlCount = "SELECT COUNT(*) AS nb " . substr($sqlAcheteurs, strpos($sqlAcheteurs, 'FROM'));
|
|
$intNbTotal = $objDatabase->fxGetVar($sqlCount);
|
|
/*************
|
|
* SQl COUNT *
|
|
*************/
|
|
|
|
if (trim($strOrder) != '') {
|
|
$sqlAcheteurs .= " ORDER BY " . $strOrder;
|
|
} else {
|
|
$sqlAcheteurs .= " ORDER BY a.ach_maj, a.no_panier";
|
|
}
|
|
|
|
/*************
|
|
* SQl LIMIT *
|
|
*************/
|
|
$intNbParPage =3000;
|
|
if ($typeoutput == 'html') {
|
|
$intStart = ($intNbParPage * $intPage) - $intNbParPage;
|
|
// limiter le nombre de ligne à retourner
|
|
if ($intNbParPage > 0)
|
|
$sqlAcheteurs .= " LIMIT " . intval($intStart) . ", " . intval($intNbParPage);
|
|
}
|
|
/*************
|
|
* SQl LIMIT *
|
|
*************/
|
|
|
|
|
|
$tabAcheteurs = $objDatabase->fxGetResults($sqlAcheteurs);
|
|
|
|
if ($blnDon) {
|
|
$sqlQuestions1 = "
|
|
SELECT
|
|
que_id, que_question_" . $strLangue . ", que_rapport_label_" . $strLangue . "
|
|
FROM
|
|
inscriptions_questions
|
|
WHERE
|
|
que_rapport = 1 AND eve_id = " . intval($intEvenement) . "
|
|
ORDER BY
|
|
que_tri, que_id
|
|
";
|
|
$tabQuestions1 = $objDatabase->fxGetResults($sqlQuestions1);
|
|
|
|
if ($tabQuestions1 != null) {
|
|
$intNbQuestions = count($tabQuestions1);
|
|
$intWidthQuestions = $intNbQuestions * 200;
|
|
}
|
|
|
|
$sqlQuestions2 = "
|
|
SELECT
|
|
rq.no_panier, rq.pec_id, rq.par_id, rq.que_id, rq.que_question_" . $strLangue . ", rq.que_choix_" . $strLangue . ", iq.que_rapport_label_" . $strLangue . "
|
|
FROM
|
|
resultats_questions rq, inscriptions_questions iq
|
|
WHERE
|
|
rq.que_id = iq.que_id AND iq.que_rapport = 1 AND iq.eve_id = " . intval($intEvenement) . "
|
|
ORDER BY
|
|
rq.pec_id, rq.par_id, rq.que_id
|
|
";
|
|
$qryQuestions2 = $objDatabase->fxQuery($sqlQuestions2);
|
|
$nbQuestions2 = $objDatabase->fxGetNumRows($qryQuestions2);
|
|
$tabQuestions2 = array();
|
|
|
|
if ($nbQuestions2 > 0) {
|
|
while ($rowQuestions = $objDatabase->fxFetchAssoc($qryQuestions2))
|
|
$tabQuestions2[$rowQuestions['no_panier']][$rowQuestions['que_id']] = $rowQuestions;
|
|
}
|
|
}
|
|
if ($strLangue == 'fr') {
|
|
$strTitreRapport = "Rapport finances ".$strTitreRapportTQ;
|
|
} else {
|
|
$strTitreRapport = "Financial report ".$strTitreRapportTQ;
|
|
}
|
|
if ($typeoutput == 'html') {
|
|
|
|
|
|
$strOutput .= $strWarning;
|
|
$strOutput .= fxShowRapportHeader($strTitreRapport, $strNomEvenement, $arrBoutonExcel);
|
|
}
|
|
|
|
if ($tabAcheteurs != null) {
|
|
$intTotal = count($tabAcheteurs);
|
|
// HEADER
|
|
if ($typeoutput == 'html') { // HTML ICI
|
|
$intWidth = $tabCol[1]['width'];
|
|
|
|
if ($tabColProduits != null) {
|
|
$intWidth += (count($tabColProduits) * 150);
|
|
}
|
|
|
|
$strOutput .= '
|
|
<table class="rapport table" style="width: ' . ($intWidth + $intWidthQuestions) . 'px;">
|
|
<thead>
|
|
<tr>
|
|
';
|
|
|
|
for ($intCtrcol = 1; $intCtrcol <= count($tabCol); $intCtrcol++) {
|
|
$strOutput .= '
|
|
<th style="text-align: center; width: ' . $tabCol[$intCtrcol]['info_option1'] . 'px;">' . $tabCol[$intCtrcol]['info_texte'] . '</th>
|
|
';
|
|
}
|
|
|
|
for ($intCtrcolProduits = 1; $intCtrcolProduits <= count($tabColProduits); $intCtrcolProduits++) {
|
|
$strOutput .= '
|
|
<th style="text-align: center; width: 150px;">' . $tabColProduits[$intCtrcolProduits]['pro_nom_' . $strLangue] . '</th>
|
|
';
|
|
}
|
|
|
|
if ($blnDon) {
|
|
if ($intNbQuestions > 0) {
|
|
for ($intCtrQuestions = 1; $intCtrQuestions <= $intNbQuestions; $intCtrQuestions++) {
|
|
if (trim($tabQuestions1[$intCtrQuestions]['que_rapport_label_' . $strLangue]) != '')
|
|
$strLabel = $tabQuestions1[$intCtrQuestions]['que_rapport_label_' . $strLangue];
|
|
else
|
|
$strLabel = $tabQuestions1[$intCtrQuestions]['que_id'];
|
|
|
|
$strOutput .= '
|
|
<th style="text-align: left; width: 200px;">' . $strLabel . '</th>
|
|
';
|
|
}
|
|
}
|
|
}
|
|
|
|
$strOutput .= '
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
';
|
|
}
|
|
if ($typeoutput == 'excel') { // EXCEL ICI
|
|
$c = 'A';
|
|
$mem_int_ligne_entete = 1;
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_int_ligne_entete, ($strTitreRapport ));
|
|
|
|
|
|
|
|
$mem_int_ligne_entete = 3;
|
|
for ($intCtrcol = 1; $intCtrcol <= count($tabCol); $intCtrcol++) {
|
|
$memtitre = $tabCol[$intCtrcol]['info_texte'];
|
|
$memwidth = $tabCol[$intCtrcol]['info_option1'] / 5;
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension($c)->setWidth($memwidth);
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_int_ligne_entete, ($memtitre));
|
|
$objPHPExcel->getActiveSheet()->getStyle($c . $mem_int_ligne_entete)->getFont()->setBold(true);
|
|
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, $c . $mem_int_ligne_entete);
|
|
++$c;
|
|
}
|
|
for ($intCtrcolProduits = 1; $intCtrcolProduits <= count($tabColProduits); $intCtrcolProduits++) {
|
|
$memtitre = $tabColProduits[$intCtrcolProduits]['pro_nom_' . $strLangue];
|
|
$memwidth = 20;
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension($c)->setWidth($memwidth);
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_int_ligne_entete, ($memtitre));
|
|
$objPHPExcel->getActiveSheet()->getStyle($c . $mem_int_ligne_entete)->getFont()->setBold(true);
|
|
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, $c . $mem_int_ligne_entete);
|
|
++$c;
|
|
}
|
|
if ($blnDon) {
|
|
if ($intNbQuestions > 0) {
|
|
for ($intCtrQuestions = 1; $intCtrQuestions <= $intNbQuestions; $intCtrQuestions++) {
|
|
if ($blnSansAccents) {
|
|
if (trim($tabQuestions1[$intCtrQuestions]['que_rapport_label_' . $strLangue]) != '')
|
|
$memtitre = ucwords(strtolower(fxRemoveAccents($tabQuestions1[$intCtrQuestions]['que_rapport_label_' . $strLangue])));
|
|
else
|
|
$memtitre = $tabQuestions1[$intCtrQuestions]['que_id'];
|
|
} else {
|
|
if (trim($tabQuestions1[$intCtrQuestions]['que_rapport_label_' . $strLangue]) != '')
|
|
$memtitre = $tabQuestions1[$intCtrQuestions]['que_rapport_label_' . $strLangue];
|
|
else
|
|
$memtitre = $tabQuestions1[$intCtrQuestions]['que_id'];
|
|
}
|
|
|
|
$memwidth = 20;
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension($c)->setWidth($memwidth);
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_int_ligne_entete, ($memtitre));
|
|
$objPHPExcel->getActiveSheet()->getStyle($c . $mem_int_ligne_entete)->getFont()->setBold(true);
|
|
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, $c . $mem_int_ligne_entete);
|
|
++$c;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$mem_ligne = 2;
|
|
$arrLignesAcheteurs = array();
|
|
|
|
for ($intCtr = 1; $intCtr <= count($tabAcheteurs); $intCtr++) {
|
|
$arrData = $arrDataEpreuves = $arrDataParticipants = $arrLignesEpreuves = $arrLignesParticipants = array();
|
|
$intNoLigne = 1;
|
|
|
|
$arrLignesAcheteurs[$tabAcheteurs[$intCtr]['no_panier']] = $intNoLigne;
|
|
|
|
// QUERY DES RABAIS
|
|
// $sqlRabais = "SELECT r.rab_id, ra.rab_montant, r.rab_code, r.rab_description_$strLangue AS rabais_description FROM inscriptions_panier_rabais_acheteurs ra, inscriptions_panier_rabais r WHERE ra.no_panier = '" . $objDatabase->fxEscape($tabAcheteurs[$intCtr]['no_panier']) . "' AND r.pra_id = ra.pra_id ORDER BY ra.rab_montant";
|
|
// $arrRabais = $objDatabase->fxGetResults($sqlRabais);
|
|
|
|
|
|
// SL TEST 649
|
|
// $sqlRabais = "SELECT r.rab_id, ra.rab_montant, r.rab_code, r.rab_description_$strLangue AS rabais_description FROM inscriptions_panier_rabais_acheteurs ra, inscriptions_panier_rabais r WHERE ra.no_panier = '" . $objDatabase->fxEscape($tabAcheteurs[$intCtr]['no_panier']) . "' AND r.pra_id = ra.pra_id AND r.rab_description_fr LIKE '%tq%' ORDER BY ra.rab_montant";
|
|
//; $sqlRabais = "SELECT r.rab_id, ra.rab_montant, r.rab_code, r.rab_description_$strLangue AS rabais_description FROM inscriptions_panier_rabais_acheteurs ra, inscriptions_panier_rabais r WHERE ra.no_panier = '" . $objDatabase->fxEscape($tabAcheteurs[$intCtr]['no_panier']) . "' AND r.pra_id = ra.pra_id ORDER BY ra.rab_montant ";
|
|
|
|
|
|
// garde un seul rabais priorise transfert tq
|
|
$sqlRabais = "SELECT
|
|
r.rab_id,
|
|
ra.rab_montant,
|
|
r.rab_code,
|
|
r.rab_description_fr AS rabais_description
|
|
FROM inscriptions_panier_rabais_acheteurs ra
|
|
JOIN inscriptions_panier_rabais r ON r.pra_id = ra.pra_id
|
|
WHERE ra.no_panier = '" . $objDatabase->fxEscape($tabAcheteurs[$intCtr]['no_panier']) . "'
|
|
ORDER BY
|
|
CASE
|
|
WHEN r.rab_description_fr LIKE '%Crédit montant original produit tq%' THEN 0
|
|
ELSE 1
|
|
END,
|
|
ra.rab_montant limit 1";
|
|
|
|
|
|
|
|
|
|
|
|
$colDesc = 'r.rab_description_' . $strLangue; // ex: r.rab_description_fr
|
|
// fonctionne avec les transfert
|
|
$sqlRabaisxx = "
|
|
WITH rab AS (
|
|
SELECT
|
|
r.rab_epreuves,
|
|
r.rab_produits,
|
|
r.rab_id,
|
|
ra.rab_montant,
|
|
r.rab_code,
|
|
{$colDesc} AS rabais_description, -- <- on fige le nom ici
|
|
CASE
|
|
WHEN r.rab_epreuves IS NULL OR r.rab_epreuves = '' THEN 0
|
|
ELSE 1 + LENGTH(r.rab_epreuves) - LENGTH(REPLACE(r.rab_epreuves, ',', ''))
|
|
END AS cnt_ep_list,
|
|
CASE
|
|
WHEN r.rab_produits IS NULL OR r.rab_produits = '' THEN 0
|
|
ELSE 1 + LENGTH(r.rab_produits) - LENGTH(REPLACE(r.rab_produits, ',', ''))
|
|
END AS cnt_pr_list
|
|
FROM inscriptions_panier_rabais_acheteurs ra
|
|
JOIN inscriptions_panier_rabais r ON r.pra_id = ra.pra_id
|
|
WHERE ra.no_panier = '" . $objDatabase->fxEscape($tabAcheteurs[$intCtr]['no_panier']) . "'
|
|
),
|
|
ep AS (
|
|
SELECT r.rab_id, e.epr_id, e.eve_id
|
|
FROM rab r
|
|
JOIN inscriptions_epreuves e
|
|
ON COALESCE(r.rab_epreuves,'') <> ''
|
|
AND FIND_IN_SET(e.epr_id, r.rab_epreuves) > 0
|
|
),
|
|
pr AS (
|
|
SELECT r.rab_id, p.pro_id, p.eve_id
|
|
FROM rab r
|
|
JOIN inscriptions_panier_produits_new p
|
|
ON COALESCE(r.rab_produits,'') <> ''
|
|
AND FIND_IN_SET(p.pro_id, r.rab_produits) > 0
|
|
),
|
|
ep_cnt AS (
|
|
SELECT rab_id, COUNT(DISTINCT epr_id) AS cnt_ep_found
|
|
FROM ep
|
|
GROUP BY rab_id
|
|
),
|
|
pr_cnt AS (
|
|
SELECT rab_id, COUNT(DISTINCT pro_id) AS cnt_pr_found
|
|
FROM pr
|
|
GROUP BY rab_id
|
|
),
|
|
evt AS (
|
|
SELECT rab_id, eve_id FROM ep
|
|
UNION ALL
|
|
SELECT rab_id, eve_id FROM pr
|
|
),
|
|
evt_agg AS (
|
|
SELECT rab_id,
|
|
COUNT(DISTINCT eve_id) AS distinct_events,
|
|
MIN(eve_id) AS unique_eve_id
|
|
FROM evt
|
|
GROUP BY rab_id
|
|
)
|
|
SELECT
|
|
r.rab_id,
|
|
r.rab_montant,
|
|
r.rab_code,
|
|
r.rabais_description
|
|
FROM rab r
|
|
LEFT JOIN ep_cnt ec ON ec.rab_id = r.rab_id
|
|
LEFT JOIN pr_cnt pc ON pc.rab_id = r.rab_id
|
|
LEFT JOIN evt_agg ea ON ea.rab_id = r.rab_id
|
|
WHERE
|
|
COALESCE(ec.cnt_ep_found, 0) = r.cnt_ep_list
|
|
AND COALESCE(pc.cnt_pr_found, 0) = r.cnt_pr_list
|
|
AND COALESCE(ea.distinct_events, 0) = CASE
|
|
WHEN (r.cnt_ep_list + r.cnt_pr_list) = 0 THEN 0
|
|
ELSE 1
|
|
END
|
|
AND (
|
|
ea.unique_eve_id = 649
|
|
OR r.rabais_description LIKE '%tq%' -- <- utiliser l'alias défini
|
|
)
|
|
ORDER BY r.rab_montant;
|
|
";
|
|
|
|
|
|
|
|
$arrRabais = $objDatabase->fxGetResults($sqlRabais);
|
|
|
|
|
|
//print_rsl($arrRabais);
|
|
//echosl( $sqlRabais);
|
|
if ($blnDon) {
|
|
// QUERY DES DONS
|
|
$sqlDonations = "SELECT d.pec_id, d.pd_recu, d.pd_anonyme, d.pd_recu_pdf, CONCAT(d.eve_prefixe, d.pd_recu_numero) AS no_recu, IF(d.par_id <> 0, (SELECT CONCAT(par_prenom, ' ', par_nom) FROM resultats_participants WHERE d.par_id = par_id_original), e.pec_nom_equipe) AS recipiendaire FROM inscriptions_panier_dons d, resultats_epreuves_commandees e WHERE d.pec_id = e.pec_id_original AND d.no_panier = '" . $objDatabase->fxEscape($tabAcheteurs[$intCtr]['no_panier']) . "'";
|
|
$arrDonations = $objDatabase->fxGetResults($sqlDonations);
|
|
}
|
|
|
|
// QUERY DES PRODUITS
|
|
$sqlProduits = "SELECT p.pro_id, p.pec_id, p.par_id, p.pro_nom_$strLangue AS pro_desc, p.pro_prix,p.rab_montant FROM inscriptions_panier_produits_new p WHERE p.no_panier = '" . $objDatabase->fxEscape($tabAcheteurs[$intCtr]['no_panier']) . "' AND eve_id = " . intval($mem_tq);
|
|
$arrProduits = $objDatabase->fxGetResults($sqlProduits);
|
|
|
|
// QUERY DES ÉPREUVVES
|
|
//$sqlEpreuves = "SELECT (ec.pec_montant_don - ec.rab_montant) AS don_epreuve, ec.pec_id, e.epr_nom_$strLangue AS epreuve_nom, e.epr_categorie_$strLangue AS epreuve_categorie, e.epr_type_$strLangue AS epreuve_type, ec.pec_prix FROM inscriptions_panier_epreuves_commandees ec, inscriptions_epreuves e WHERE ec.no_panier = '" . $objDatabase->fxEscape($tabAcheteurs[$intCtr]['no_panier']) . "' AND ec.epr_id = e.epr_id AND ec.eve_id = " . intval($intEvenement);
|
|
$sqlEpreuves = "SELECT (ec.pec_montant_don - ec.rab_montant) AS don_epreuve, ec.pec_id, e.epr_nom_$strLangue AS epreuve_nom, e.epr_categorie_$strLangue AS epreuve_categorie, e.epr_type_$strLangue AS epreuve_type, ec.pec_prix FROM inscriptions_panier_epreuves_commandees ec, inscriptions_epreuves e WHERE ec.no_panier = '" . $objDatabase->fxEscape($tabAcheteurs[$intCtr]['no_panier']) . "' AND ec.epr_id = e.epr_id";
|
|
|
|
/* if (isset($strWhere['epreuves']) && trim($strWhere['epreuves']) != '') {
|
|
$sqlEpreuves .= " AND " . $strWhere['epreuves'];
|
|
} */
|
|
|
|
$arrEpreuves = $objDatabase->fxGetResults($sqlEpreuves);
|
|
|
|
if ($arrEpreuves != null) {
|
|
for ($intCtr2 = 1; $intCtr2 <= count($arrEpreuves); $intCtr2++) {
|
|
$arrDataEpreuves[$intNoLigne] = $arrEpreuves[$intCtr2];
|
|
$arrLignesEpreuves[$arrEpreuves[$intCtr2]['pec_id']] = $intNoLigne;
|
|
|
|
// QUERY DES PARTICIPANTS
|
|
$sqlParticipants = "SELECT p.com_id,p.par_id, p.par_nom_equipe, p.par_nom, p.par_prenom, p.par_naissance, p.par_age, p.par_sexe, p.par_adresse, p.par_ville, (SELECT pro_nom_fr FROM inscriptions_provinces WHERE p.pro_id = pro_id) AS province, (SELECT pay_nom_fr FROM inscriptions_pays WHERE p.pay_id = pay_id) AS pays, p.par_codepostal, p.par_telephone1, p.par_courriel FROM inscriptions_panier_participants p WHERE p.pec_id = " . intval($arrEpreuves[$intCtr2]['pec_id']);
|
|
$arrParticipants = $objDatabase->fxGetResults($sqlParticipants);
|
|
|
|
if ($arrParticipants != null) {
|
|
for ($intCtr3 = 1; $intCtr3 <= count($arrParticipants); $intCtr3++) {
|
|
$arrDataParticipants[$intNoLigne] = $arrParticipants[$intCtr3];
|
|
$arrLignesParticipants[$arrParticipants[$intCtr3]['par_id']] = $intNoLigne;
|
|
$intNoLigne++;
|
|
}
|
|
}
|
|
|
|
if ($intCtr2 == count($arrEpreuves)) {
|
|
$intNoLigne--;
|
|
}
|
|
}
|
|
}
|
|
|
|
// CRÉER LE TABLEAU DE DONNÉES FINAL
|
|
for ($intCtr4 = 1; $intCtr4 <= $intNoLigne; $intCtr4++) {
|
|
$arrShowEachLine = array('no_commande', 'eve_id', 'eve_nom');
|
|
$arrFinanceMembership = null;
|
|
|
|
if (intval($tabAcheteurs[$intCtr]['eve_id']) !== intval($intEvenement)) { // si la commande provient d'un autre événemennt, récupérer les totaux de la table jonction
|
|
|
|
//MSIN-4277
|
|
|
|
//$sqlFinanceMembership = "SELECT ach_total, 0 AS fra_total, 0 AS fra_taxe1, 0 AS fra_taxe2, 0 AS fra_avant_tx, ach_total AS montant_promoteur,rabais_total as rabais_total_member, ach_taxe1, ach_taxe2, (ach_total - (ach_taxe1 + ach_taxe2 + ach_taxe3)) AS montant_promoteur_avant_tx FROM rapport_finances_membership WHERE no_panier = '" . $objDatabase->fxEscape($tabAcheteurs[$intCtr]['no_panier']) . "'";
|
|
$sqlFinanceMembership = "SELECT f.ach_total, 0 AS fra_total, 0 AS fra_taxe1, 0 AS fra_taxe2, 0 AS fra_avant_tx,
|
|
|
|
IF(a.pai_id = 6,
|
|
0,
|
|
f.ach_total ) AS montant_promoteur,
|
|
f.rabais_total as rabais_total_member, f.ach_taxe1, f.ach_taxe2, (f.ach_total - (f.ach_taxe1 + f.ach_taxe2 + f.ach_taxe3)) AS montant_promoteur_avant_tx
|
|
FROM rapport_finances_membership f
|
|
LEFT JOIN inscriptions_panier_acheteurs a ON a.no_panier = f.no_panier
|
|
WHERE f.no_panier = '" . $objDatabase->fxEscape($tabAcheteurs[$intCtr]['no_panier']) . "'";
|
|
|
|
|
|
|
|
$arrFinanceMembership = $objDatabase->fxGetRow($sqlFinanceMembership);
|
|
//echosl($sqlFinanceMembership);
|
|
}
|
|
|
|
for ($intCtrcol = 2; $intCtrcol <= count($tabCol); $intCtrcol++) {
|
|
if ($arrFinanceMembership != null && isset($arrFinanceMembership[$tabCol[$intCtrcol]['info_option2']])) {
|
|
$tabAcheteurs[$intCtr][$tabCol[$intCtrcol]['info_option2']] = $arrFinanceMembership[$tabCol[$intCtrcol]['info_option2']];
|
|
}
|
|
|
|
if (isset($tabAcheteurs[$intCtr][$tabCol[$intCtrcol]['info_option2']]) && ($intCtr4 == 1 || in_array($tabCol[$intCtrcol]['info_option2'], $arrShowEachLine))) {
|
|
$arrData[$intCtr4][$tabCol[$intCtrcol]['info_option2']] = $tabAcheteurs[$intCtr][$tabCol[$intCtrcol]['info_option2']];
|
|
} elseif (isset($arrDataEpreuves[$intCtr4][$tabCol[$intCtrcol]['info_option2']])) {
|
|
if ((intval($tabAcheteurs[$intCtr]['eve_id']) !== intval($intEvenement)) && (trim($tabCol[$intCtrcol]['info_option2']) == 'pec_prix' || trim($tabCol[$intCtrcol]['info_option2']) == 'don_epreuve')) { // enlever le prix des épreuves pr<ovenant d'un événement externe
|
|
$arrData[$intCtr4][$tabCol[$intCtrcol]['info_option2']] = '';
|
|
} else {
|
|
$arrData[$intCtr4][$tabCol[$intCtrcol]['info_option2']] = $arrDataEpreuves[$intCtr4][$tabCol[$intCtrcol]['info_option2']];
|
|
}
|
|
} elseif (isset($arrDataParticipants[$intCtr4][$tabCol[$intCtrcol]['info_option2']])) {
|
|
$arrData[$intCtr4][$tabCol[$intCtrcol]['info_option2']] = $arrDataParticipants[$intCtr4][$tabCol[$intCtrcol]['info_option2']];
|
|
} elseif ($blnDon && isset($arrDonations[$intCtr4][$tabCol[$intCtrcol]['info_option2']])) {
|
|
if ($tabCol[$intCtrcol]['info_option2'] == 'pd_recu_pdf') {
|
|
if ($typeoutput == 'excel') { // EXCEL
|
|
$arrData[$intCtr4][$tabCol[$intCtrcol]['info_option2']] = $vDomaine . '/pdf/dons/' . $arrDonations[$intCtr4][$tabCol[$intCtrcol]['info_option2']];
|
|
}
|
|
if ($typeoutput == 'html') { // HTML
|
|
$arrData[$intCtr4][$tabCol[$intCtrcol]['info_option2']] = '<a href="' . $vDomaine . '/pdf/dons/' . $arrDonations[$intCtr4][$tabCol[$intCtrcol]['info_option2']] . '" target="_blank">' . $arrDonations[$intCtr4][$tabCol[$intCtrcol]['info_option2']] . '</a>';
|
|
}
|
|
} else {
|
|
$arrData[$intCtr4][$tabCol[$intCtrcol]['info_option2']] = $arrDonations[$intCtr4][$tabCol[$intCtrcol]['info_option2']];
|
|
}
|
|
} else {
|
|
$arrData[$intCtr4][$tabCol[$intCtrcol]['info_option2']] = '';
|
|
}
|
|
}
|
|
|
|
|
|
// PRODUITS
|
|
for ($intCtrcolProduits = 1; $intCtrcolProduits <= count($tabColProduits); $intCtrcolProduits++) {
|
|
$arrData[$intCtr4][$tabColProduits[$intCtrcolProduits]['pro_id']] = '';
|
|
}
|
|
if ($blnDon) {
|
|
// QUESTIONS
|
|
if ($intNbQuestions > 0) {
|
|
for ($intCtrQuestions = 1; $intCtrQuestions <= $intNbQuestions; $intCtrQuestions++) {
|
|
if (isset($tabQuestions2[$tabAcheteurs[$intCtr]['no_panier']]) && isset($tabQuestions2[$tabAcheteurs[$intCtr]['no_panier']][$tabQuestions1[$intCtrQuestions]['que_id']]))
|
|
$strValue = $tabQuestions2[$tabAcheteurs[$intCtr]['no_panier']][$tabQuestions1[$intCtrQuestions]['que_id']]['que_choix_' . $strLangue];
|
|
else
|
|
$strValue = '';
|
|
|
|
$arrData[$intCtr4][$tabQuestions1[$intCtrQuestions]['que_id']] = $strValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//print("stop99<pre>".print_r( $arrRabais,true)."</pre>");
|
|
//print("stop3a<pre>".print_r( $arrData,true)."</pre>");
|
|
// RABAIS-DATA
|
|
if ($arrRabais != null) {
|
|
|
|
$ligne = 1;
|
|
// foreach ($arrData as $iddata => $tesm) {
|
|
|
|
$iddata=1;
|
|
foreach ($arrRabais as $id => $rabais) {
|
|
|
|
for ($intCtrcol = 1; $intCtrcol <= count($tabCol); $intCtrcol++) {
|
|
|
|
if (
|
|
$tabCol[$intCtrcol]['info_option2'] != "rab_montant" ||
|
|
($tabCol[$intCtrcol]['info_option2'] == "rab_montant" && $ligne == 1)
|
|
) {
|
|
|
|
if ($tabCol[$intCtrcol]['info_option2'] == 'no_commande') {
|
|
$arrData[$iddata]['no_commande'] = $tabAcheteurs[$intCtr]['no_commande'];
|
|
} elseif (isset($rabais[$tabCol[$intCtrcol]['info_option2']])) {
|
|
$arrData[$iddata][$tabCol[$intCtrcol]['info_option2']] = $rabais[$tabCol[$intCtrcol]['info_option2']];
|
|
|
|
|
|
} elseif (!isset($arrData[$id][$tabCol[$intCtrcol]['info_option2']])) {
|
|
$arrData[$iddata][$tabCol[$intCtrcol]['info_option2']] = '';
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//$arrData[$iddata]["rab_montant"] =$rabais["rab_montant"];
|
|
if(isset($arrFinanceMembership['rabais_total_member'])){
|
|
$arrData[$iddata]["rab_montant"] =$arrFinanceMembership['rabais_total_member'];
|
|
}else{
|
|
$arrData[$iddata]["rab_montant"] =$rabais["rab_montant"];
|
|
}
|
|
|
|
// PRODUITS
|
|
for ($intCtrcolProduits = 1; $intCtrcolProduits <= count($tabColProduits); $intCtrcolProduits++) {
|
|
$arrData[$iddata][$tabColProduits[$intCtrcolProduits]['pro_id']] = '';
|
|
$arrData[$iddata][$tabColProduits[$intCtrcolProduits]['pro_id']."-rabais"] = '';
|
|
$arrData[$iddata][$tabColProduits[$intCtrcolProduits]['pro_id']."-net"] = '';
|
|
}
|
|
}
|
|
$ligne = $ligne + 1;
|
|
// }
|
|
|
|
// version old
|
|
if (1 == 2) {
|
|
foreach ($arrRabais as $id => $rabais) {
|
|
|
|
for ($intCtrcol = 2; $intCtrcol <= count($tabCol); $intCtrcol++) {
|
|
if ($tabCol[$intCtrcol]['info_option2'] == 'no_commande') {
|
|
$arrData[$id]['no_commande'] = $tabAcheteurs[$intCtr]['no_commande'];
|
|
} elseif (isset($rabais[$tabCol[$intCtrcol]['info_option2']])) {
|
|
$arrData[$id][$tabCol[$intCtrcol]['info_option2']] = $rabais[$tabCol[$intCtrcol]['info_option2']];
|
|
} elseif (!isset($arrData[$id][$tabCol[$intCtrcol]['info_option2']])) {
|
|
$arrData[$id][$tabCol[$intCtrcol]['info_option2']] = '';
|
|
}
|
|
}
|
|
// PRODUITS
|
|
for ($intCtrcolProduits = 1; $intCtrcolProduits <= count($tabColProduits); $intCtrcolProduits++) {
|
|
$arrData[$id][$tabColProduits[$intCtrcolProduits]['pro_id']] = '';
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
//print("stop3<pre>".print_r( $arrData,true)."</pre>");
|
|
//print("stop2<pre>".print_r( $arrProduits,true)."</pre>");
|
|
|
|
// sl a voir apres efface rabais
|
|
// PRODUITS-DATA
|
|
if ($arrProduits != null) foreach ($arrProduits as $produit) {
|
|
if ($produit['par_id'] != 0 && isset($arrLignesParticipants[$produit['par_id']])) {
|
|
$intLigne = $arrLignesParticipants[$produit['par_id']];
|
|
} elseif (isset($arrLignesEpreuves[$produit['pec_id']])) {
|
|
$intLigne = $arrLignesEpreuves[$produit['pec_id']];
|
|
} elseif ($arrEpreuves == null) {
|
|
$intLigne = $arrLignesAcheteurs[$tabAcheteurs[$intCtr]['no_panier']];
|
|
} else {
|
|
$intLigne = 0;
|
|
}
|
|
|
|
if ($intLigne != 0) {
|
|
|
|
for ($intCtrcol = 2; $intCtrcol <= count($tabCol); $intCtrcol++) {
|
|
if ($tabCol[$intCtrcol]['info_option2'] !='rab_montant'){
|
|
if ($tabCol[$intCtrcol]['info_option2'] == 'no_commande') {
|
|
$arrData[$intLigne]['no_commande'] = $tabAcheteurs[$intCtr]['no_commande'];
|
|
} elseif (isset($produit[$tabCol[$intCtrcol]['info_option2']])) {
|
|
$arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']] = $produit[$tabCol[$intCtrcol]['info_option2']];
|
|
} elseif (!isset($arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']])) {
|
|
$arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']] = '';
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
$arrData[$intLigne][$produit['pro_id']] = $produit['pro_prix'];
|
|
$arrData[$intLigne][$produit['pro_id']."-rabais"] = $produit['rab_montant']*-1;
|
|
$arrData[$intLigne][$produit['pro_id']."-net"] = $produit['pro_prix']-$produit['rab_montant'];
|
|
}
|
|
}
|
|
|
|
// BODY - PARTICIPANTS
|
|
if ($typeoutput == 'html') { // HTML ICI
|
|
foreach ($arrData as $intLigne => $data) {
|
|
$strClass = ($intCtr & 1) ? '' : ' class="table-secondary"';
|
|
|
|
if (intval($data['eve_id']) !== intval($intEvenement)) {
|
|
$strClass = ' class="table-info"';
|
|
}
|
|
|
|
$strOutput .= '
|
|
<tr' . $strClass . '>
|
|
<td style="text-align: center;">' . ($intCtr + $intStart) . '</td>
|
|
';
|
|
|
|
for ($intCtrcol = 2; $intCtrcol <= count($tabCol); $intCtrcol++) {
|
|
$strValue = '';
|
|
|
|
if (trim($arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']]) != '') {
|
|
switch ($tabCol[$intCtrcol]['info_description']) {
|
|
case 'date':
|
|
$strValue = fxShowDate($arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']], $strLangue);
|
|
break;
|
|
case 'datetime':
|
|
$strValue = fxShowDate($arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']], $strLangue) . ' @ ' . fxShowTime($arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']]);
|
|
break;
|
|
case 'money':
|
|
$strValue = fxShowMoney($arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']], $strLangue);
|
|
|
|
if (!array_key_exists($tabCol[$intCtrcol]['info_option2'], $arrSum))
|
|
$arrSum[$tabCol[$intCtrcol]['info_option2']] = 0;
|
|
|
|
$arrSum[$tabCol[$intCtrcol]['info_option2']] += $arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']];
|
|
break;
|
|
default:
|
|
$strValue = $arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']];
|
|
}
|
|
}
|
|
|
|
$strOutput .= '
|
|
<td style="text-align: ' . $tabCol[$intCtrcol]['info_option3'] . ';">
|
|
' . $strValue . '
|
|
</td>
|
|
';
|
|
}
|
|
|
|
|
|
|
|
// PRODUITS
|
|
|
|
for ($intCtrcolProduits = 1; $intCtrcolProduits <= count($tabColProduits); $intCtrcolProduits++) {
|
|
$strValue = '';
|
|
|
|
if (isset($arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']]) && trim($arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']]) != '') {
|
|
|
|
if ($tabColProduits[$intCtrcolProduits]["type"]=="montant"){
|
|
$strValue = fxShowMoney($arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']], $strLangue);
|
|
|
|
if (!array_key_exists($tabColProduits[$intCtrcolProduits]['pro_id']."-montant", $arrSum)){
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-montant"] = 0;
|
|
}
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-montant"] += $arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']];
|
|
|
|
|
|
}
|
|
if ($tabColProduits[$intCtrcolProduits]["type"]=="rabais"){
|
|
$strValue = fxShowMoney($arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']."-rabais"], $strLangue);
|
|
if (!array_key_exists($tabColProduits[$intCtrcolProduits]['pro_id']."-rabais", $arrSum)){
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-rabais"] = 0;
|
|
}
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-rabais"] += $arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']."-rabais"];
|
|
|
|
}
|
|
if ($tabColProduits[$intCtrcolProduits]["type"]=="net"){
|
|
$strValue = fxShowMoney($arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']."-net"], $strLangue);
|
|
if (!array_key_exists($tabColProduits[$intCtrcolProduits]['pro_id']."-net", $arrSum)){
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-net"] = 0;
|
|
}
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-net"] += $arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']."-net"];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
$strOutput .= '
|
|
<td style="text-align: right;">
|
|
' . $strValue . '
|
|
</td>
|
|
';
|
|
}
|
|
// QUESTIONS
|
|
|
|
|
|
|
|
if ($blnDon) {
|
|
if ($intNbQuestions > 0) {
|
|
for ($intCtrQuestions = 1; $intCtrQuestions <= $intNbQuestions; $intCtrQuestions++) {
|
|
$strValue = '';
|
|
|
|
if (isset($arrData[$intLigne][$tabQuestions1[$intCtrQuestions]['que_id']]) && trim($arrData[$intLigne][$tabQuestions1[$intCtrQuestions]['que_id']]) != '') {
|
|
$strValue = $arrData[$intLigne][$tabQuestions1[$intCtrQuestions]['que_id']];
|
|
}
|
|
|
|
$strOutput .= '
|
|
<td style="text-align: right;">
|
|
' . $strValue . '
|
|
</td>
|
|
';
|
|
}
|
|
}
|
|
}
|
|
|
|
$strOutput .= '</tr>';
|
|
}
|
|
}
|
|
if ($typeoutput == 'excel') { // EXCEL ICI
|
|
foreach ($arrData as $intLigne => $data) {
|
|
$c = 'A';
|
|
$mem_result = ($intCtr + $intStart);
|
|
$mem_align = 'center';
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_ligne, $mem_result);
|
|
$objPHPExcel->getActiveSheet()->getstyle($c . $mem_ligne)->getAlignment()->setHorizontal($mem_align);
|
|
|
|
++$c;
|
|
|
|
for ($intCtrcol = 2; $intCtrcol <= count($tabCol); $intCtrcol++) {
|
|
$mem_result = $arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']];
|
|
$mem_align = $tabCol[$intCtrcol]['info_option3'];
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_ligne, ($mem_result));
|
|
$objPHPExcel->getActiveSheet()->getstyle($c . $mem_ligne)->getAlignment()->setHorizontal($mem_align);
|
|
|
|
++$c;
|
|
|
|
if (trim($arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']]) != '') {
|
|
switch ($tabCol[$intCtrcol]['info_description']) {
|
|
case 'money':
|
|
if (!array_key_exists($tabCol[$intCtrcol]['info_option2'], $arrSum))
|
|
$arrSum[$tabCol[$intCtrcol]['info_option2']] = 0;
|
|
|
|
$arrSum[$tabCol[$intCtrcol]['info_option2']] += $arrData[$intLigne][$tabCol[$intCtrcol]['info_option2']];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
for ($intCtrcolProduits = 1; $intCtrcolProduits <= count($tabColProduits); $intCtrcolProduits++) {
|
|
|
|
|
|
// $mem_result = $arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']];
|
|
if ($tabColProduits[$intCtrcolProduits]["type"]=="montant"){
|
|
$mem_result = $arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']] ;
|
|
|
|
if (!array_key_exists($tabColProduits[$intCtrcolProduits]['pro_id']."-montant", $arrSum)){
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-montant"] = 0;
|
|
}
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-montant"] += $arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']];
|
|
|
|
|
|
}
|
|
if ($tabColProduits[$intCtrcolProduits]["type"]=="rabais"){
|
|
$mem_result = $arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']."-rabais"] ;
|
|
if (!array_key_exists($tabColProduits[$intCtrcolProduits]['pro_id']."-rabais", $arrSum)){
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-rabais"] = 0;
|
|
}
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-rabais"] += $arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']."-rabais"];
|
|
|
|
}
|
|
if ($tabColProduits[$intCtrcolProduits]["type"]=="net"){
|
|
$mem_result = $arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']."-net"] ;
|
|
if (!array_key_exists($tabColProduits[$intCtrcolProduits]['pro_id']."-net", $arrSum)){
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-net"] = 0;
|
|
}
|
|
$arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-net"] += $arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']."-net"];
|
|
|
|
|
|
|
|
|
|
}
|
|
$mem_align = 'right';
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_ligne, ($mem_result));
|
|
$objPHPExcel->getActiveSheet()->getstyle($c . $mem_ligne)->getAlignment()->setHorizontal($mem_align);
|
|
|
|
++$c;
|
|
|
|
// if (!array_key_exists($tabColProduits[$intCtrcolProduits]['pro_id'], $arrSum))
|
|
// $arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']] = 0;
|
|
|
|
// $arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']] += $arrData[$intLigne][$tabColProduits[$intCtrcolProduits]['pro_id']];
|
|
}
|
|
// QUESTIONS
|
|
if ($blnDon) {
|
|
if ($intNbQuestions > 0) {
|
|
for ($intCtrQuestions = 1; $intCtrQuestions <= $intNbQuestions; $intCtrQuestions++) {
|
|
$mem_result = $arrData[$intLigne][$tabQuestions1[$intCtrQuestions]['que_id']];
|
|
$mem_align = 'left';
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_ligne, ($mem_result));
|
|
$objPHPExcel->getActiveSheet()->getstyle($c . $mem_ligne)->getAlignment()->setHorizontal($mem_align);
|
|
|
|
++$c;
|
|
}
|
|
}
|
|
}
|
|
|
|
$mem_ligne++;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (count($arrSum) > 0) {
|
|
if ($typeoutput == 'html') {
|
|
$strOutput .= '
|
|
</tbody>
|
|
<tfoot>
|
|
<tr>
|
|
<th style="text-align: center;"> </th>
|
|
';
|
|
|
|
for ($intCtrcol = 2; $intCtrcol <= count($tabCol); $intCtrcol++) {
|
|
$strValue = '';
|
|
|
|
if (array_key_exists($tabCol[$intCtrcol]['info_option2'], $arrSum)) {
|
|
$strValue = fxShowMoney($arrSum[$tabCol[$intCtrcol]['info_option2']], $strLangue);
|
|
}
|
|
|
|
$strOutput .= '
|
|
<th style="text-align: right;">
|
|
' . $strValue . '
|
|
</th>
|
|
';
|
|
}
|
|
// PRODUITS
|
|
|
|
for ($intCtrcolProduits = 1; $intCtrcolProduits <= count($tabColProduits); $intCtrcolProduits++) {
|
|
$strValue = '';
|
|
|
|
if (array_key_exists($tabColProduits[$intCtrcolProduits]['pro_id']."-".$tabColProduits[$intCtrcolProduits]['type'], $arrSum)) {
|
|
$strValue = fxShowMoney($arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-".$tabColProduits[$intCtrcolProduits]['type']], $strLangue);
|
|
}
|
|
|
|
$strOutput .= '
|
|
<th style="text-align: right;">
|
|
' . $strValue . '
|
|
</th>
|
|
';
|
|
}
|
|
// QUESTIONS
|
|
if ($blnDon) {
|
|
if ($intNbQuestions > 0) {
|
|
for ($intCtrQuestions = 1; $intCtrQuestions <= $intNbQuestions; $intCtrQuestions++) {
|
|
$strOutput .= '
|
|
<th style="text-align: left;">
|
|
|
|
</th>
|
|
';
|
|
}
|
|
}
|
|
}
|
|
|
|
$strOutput .= '
|
|
</tr>
|
|
</tfoot>
|
|
';
|
|
}
|
|
if ($typeoutput == 'excel') { // EXCEL ICI
|
|
$c = 'A';
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_ligne, '');
|
|
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, $c . $mem_ligne);
|
|
++$c;
|
|
|
|
for ($intCtrcol = 2; $intCtrcol <= count($tabCol); $intCtrcol++) {
|
|
|
|
if (array_key_exists($tabCol[$intCtrcol]['info_option2'], $arrSum)) {
|
|
$strValue = $arrSum[$tabCol[$intCtrcol]['info_option2']];
|
|
} else {
|
|
$strValue = '';
|
|
}
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_ligne, $strValue);
|
|
$objPHPExcel->getActiveSheet()->getStyle($c . $mem_ligne)->getFont()->setBold(true);
|
|
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, $c . $mem_ligne);
|
|
++$c;
|
|
}
|
|
for ($intCtrcolProduits = 1; $intCtrcolProduits <= count($tabColProduits); $intCtrcolProduits++) {
|
|
$strValue = '';
|
|
|
|
if (array_key_exists($tabColProduits[$intCtrcolProduits]['pro_id']."-".$tabColProduits[$intCtrcolProduits]['type'], $arrSum)) {
|
|
$strValue = $arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']."-".$tabColProduits[$intCtrcolProduits]['type']] ;
|
|
}
|
|
|
|
//if (array_key_exists($tabColProduits[$intCtrcolProduits]['pro_id'], $arrSum)) {
|
|
// $strValue = $arrSum[$tabColProduits[$intCtrcolProduits]['pro_id']];
|
|
// } else {
|
|
// $strValue = '';
|
|
// }
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_ligne, $strValue);
|
|
$objPHPExcel->getActiveSheet()->getStyle($c . $mem_ligne)->getFont()->setBold(true);
|
|
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, $c . $mem_ligne);
|
|
++$c;
|
|
}
|
|
// QUESTIONS
|
|
if ($blnDon) {
|
|
if ($intNbQuestions > 0) {
|
|
for ($intCtrQuestions = 1; $intCtrQuestions <= $intNbQuestions; $intCtrQuestions++) {
|
|
$strValue = '';
|
|
$objPHPExcel->getActiveSheet()->setCellValue($c . $mem_ligne, $strValue);
|
|
$objPHPExcel->getActiveSheet()->getStyle($c . $mem_ligne)->getFont()->setBold(true);
|
|
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, $c . $mem_ligne);
|
|
++$c;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if ($typeoutput == 'html') { //HTML ICI
|
|
$strOutput .= fxShowRapportEmpty($strLangue);
|
|
}
|
|
}
|
|
|
|
if ($typeoutput == 'html') { // HTML ICI
|
|
$strOutput .= fxShowRapportFooter($arrBoutonExcel);
|
|
}
|
|
|
|
?>
|