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

799 lines
37 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: AlexL
* Date: 09/07/2015
* Time: 10:04 AM
*/
require_once 'php/inc_functions.php';
require_once('../fpdf/fpdf.php');
require_once('../fpdf/fpdi.php');
class PDF extends FPDF
{
// Simple table
function BasicTable($header, $data)
{
// Header
foreach ($header as $col)
$this->Cell(40, 7, $col, 1);
$this->Ln();
// Data
foreach ($data as $row) {
foreach ($row as $col)
$this->Cell(40, 6, $col, 1);
$this->Ln();
}
}
function FancyTable($header, $data)
{
// Colors, line width and bold font
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
// Header
$w = array(40, 35, 40, 45);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
$this->Ln();
// Color and font restoration
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
// Data
$fill = false;
foreach($data as $row)
{
$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
$this->Cell($w[2],6,$row[2],'LR',0,'R',$fill);
$this->Cell($w[3],6,$row[3],'LR',0,'R',$fill);
$this->Ln();
$fill = !$fill;
}
// Closing line
$this->Cell(array_sum($w),0,'','T');
}
}
// 13.3
function fxCreateViewByTeamPDF()
{
$sql1 = "SELECT ec.pec_id_original AS pec_id, (SELECT par_nom FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id = 1) AS nom_captain, (SELECT par_prenom FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id = 1) AS prenom_captain, ec.pec_nom_equipe, ec.no_equipe, (SELECT COALESCE(SUM(md_montant), 0) FROM inscriptions_montants_dus WHERE pec_id = ec.pec_id AND (no_commande_paye = '' OR no_commande_paye IS NULL)) AS balance, pe.epr_type_en AS category, ((IF(ec.epr_id = 109, CASE WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 150 THEN 'Under 150' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 189 THEN '150 to 189' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 219 THEN '190 to 219' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) >= 220 THEN '220+' END, '-'))) AS subcategory
FROM resultats_epreuves_commandees ec, inscriptions_panier_epreuves pe
WHERE ec.eve_id = 175 AND ec.is_cancelled = 0 AND ec.pec_actif = 1 AND ec.epr_id = pe.epr_id
ORDER BY nom_captain, prenom_captain;";
$tab1 = $GLOBALS['db']->fxGetResults($sql1);
// var_dump($tab1);
// exit;
$sql2 = "SELECT p.par_nom, p.par_prenom, p.no_bib, p.par_age, (SELECT com_tshirt FROM inscriptions_comptes WHERE com_id = p.com_id) AS tshirt, (CASE p.waiver_cleared WHEN 1 THEN 'yes' ELSE 'no' END) AS waiver, UPPER(SUBSTR(r.rol_nom_en,1,2)) AS role
FROM resultats_participants p, inscriptions_roles r
WHERE p.rol_id = r.rol_id AND p.is_cancelled = 0
ORDER BY p.rol_id, p.par_nom, p.par_prenom;";
// p.pec_id = X
$tab2 = $GLOBALS['db']->fxGetResults($sql2);
$header = array('', '', '');
$data = array();
// $pdf = new PDF();
// $pdf->BasicTable($header,$data);
$pdf = new FPDI();
$pdf->AddPage();
$pdf->Rect(10,10,190,50);
$pdf->Cell(40, 6, $tab1[1]['pec_id'], 1);
// $pdf->Write(5, $pdf->GetX());
$pdf->Output();
?>
<?php
}
// 13.6
function fxCreateRosterLabels()
{
$sqlRosterLabels = "SELECT p.par_nom, p.par_prenom, ec.pec_nom_equipe, ec.no_equipe, p.no_bib, p.par_age, (SELECT com_tshirt FROM inscriptions_comptes WHERE com_id = p.com_id) AS tshirt, (CASE p.waiver_cleared WHEN 1 THEN 'yes' ELSE 'no' END) AS waiver, UPPER(r.rol_nom_en) AS role, (SELECT COALESCE(SUM(md_montant), 0) FROM inscriptions_montants_dus WHERE pec_id = p.pec_id AND (no_commande_paye = '' OR no_commande_paye IS NULL)) AS balance, pe.epr_type_en AS category, ((IF(ec.epr_id = 109, CASE WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 150 THEN 'Under 150' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 189 THEN '150 to 189' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 219 THEN '190 to 219' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) >= 220 THEN '220+' END, '-'))) AS subcategory
FROM resultats_participants p, resultats_epreuves_commandees ec, inscriptions_roles r, inscriptions_panier_epreuves pe
WHERE p.pec_id = ec.pec_id_original AND p.rol_id = r.rol_id AND p.is_cancelled = 0 AND p.eve_id = 175 AND ec.is_cancelled = 0 AND ec.pec_actif = 1 AND ec.epr_id = pe.epr_id AND p.rol_id <= 2
ORDER BY ec.no_equipe, p.rol_id, p.par_nom, p.par_prenom;";
$tabRosterLabels = $GLOBALS['db']->fxGetResults($sqlRosterLabels);
// var_dump($tabRosterLabels[3]);
// exit;
if (count($tabRosterLabels) > 0) {
// initiate FPDI
$pdf = new FPDI();
$pdf->AddPage();
$pdf->setSourceFile('../fpdf/13_6.pdf');
// importer la page 1
$tplIdx = $pdf->importPage(1);
// utiliser le template original
$pdf->useTemplate($tplIdx, null, null, 0, 0, true);
$pdf->SetFont('Arial', '', 12);
$pdf->SetTextColor(128,20,64);
// $start_x_no_equipe = $pdf->GetX();;
$start_x_no_equipe = 20;
// $start_x_no_equipe = 60;
// $start_y_no_equipe = $pdf->GetY();
$start_y_no_equipe = 15;
$start_x_line2 = 20;
$start_y_line2 = 30;
$start_x_line3 = 20;
$start_y_line3 = 24;
$x_no_equipe = $start_x_no_equipe;
$y_no_equipe = $start_y_no_equipe;
$x_line2 = $start_x_line2;
$y_line2 = $start_x_line2;
$x_line3 = $start_x_line3;
$y_line3 = $start_y_line3;
//col 1
for ($i = 1; $i <= count($tabRosterLabels); $i++) {
// populer PDF de gauche a droite
// if($i % 10 == 0)
// $bln = 'true';
// else
// $bln = 'false';
if(!empty($tabRosterLabels[$i]['no_bib']))
$line1 = $tabRosterLabels[$i]['no_bib'];// . $x . " , " . $y;
else
$line = "tbd";
$line2 = strtoupper($tabRosterLabels[$i]['par_nom'] . ", " . $tabRosterLabels[$i]['par_prenom']);
$line3 = strtolower($tabRosterLabels[$i]['role'] . " - " . $tabRosterLabels[$i]['tshirt']);
// $pdf->SetXY($const_col1_x + 40, $int_y_no_equipe +5);// de haut en bas
$pdf->SetXY($x_no_equipe, $y_no_equipe);
$pdf->setFontSize(12);
// $pdf->SetLeftMargin(50);
$pdf->Write(5, $line1);
$pdf->SetFontSize(8);
// $pdf->SetY($y_line2);
$pdf->SetXY($x_line2, $y_line2);
$pdf->Write(5, $line2);
$pdf->Ln(1);
$pdf->SetXY($x_line3, $y_line3);
$pdf->Write(5, $line3);
if($i % 3 != 0) {
$x_no_equipe += 70;
$x_line2 += 70;
$x_line3 += 70;
// $y_no_equipe = $start_y_no_equipe;
}
else{
$x_no_equipe = $start_x_no_equipe;
$y_no_equipe += 25;
$x_line2 = $start_x_line2;
$y_line2 += 25;
$x_line3 = $start_x_line3;
$y_line3 += 25;
}
if($i % 30 == 0){
$pdf->AddPage();
$pdf->setSourceFile('../fpdf/13_6.pdf');
// importer la page 1
$tplIdx = $pdf->importPage(1);
// utiliser le template original
$pdf->useTemplate($tplIdx, null, null, 0, 0, true);
$pdf->SetFont('Arial', '', 12);
$pdf->SetTextColor(128,20,64);
}
}
$pdf->Output();
}
}
//fxCreateRosterLabels();
//fxCreateViewByTeamPDF();
// 13.8
////////////////////////////////////////////////////
// PDF_Label
//
// Class to print labels in Avery or custom formats
//
//
// Copyright (C) 2003 Laurent PASSEBECQ (LPA)
// Based on code by Steve Dillon : steved@mad.scientist.com
//
//-------------------------------------------------------------------
// VERSIONS :
// 1.0 : Initial release
// 1.1 : + : Added unit in the constructor
// + : Now Positions start @ (1, 1).. then the first image @top-left of a page is (1, 1)
// + : Added in the description of a label :
// font-size : defaut char size (can be changed by calling Set_Char_Size(xx);
// paper-size : Size of the paper for this sheet (thanx to Al Canton)
// metric : type of unit used in this description
// You can define your label properties in inches by setting metric to 'in'
// and printing in millimiter by setting unit to 'mm' in constructor.
// Added some labels :
// 5160, 5161, 5162, 5163, 5164 : thanx to Al Canton : acanton@adams-blake.com
// 8600 : thanx to Kunal Walia : kunal@u.washington.edu
// + : Added 3mm to the position of labels to avoid errors
// 1.2 : + : Added Set_Font_Name method
// = : Bug of positioning
// = : Set_Font_Size modified -> Now, just modify the size of the font
// = : Set_Char_Size renamed to Set_Font_Size
////////////////////////////////////////////////////
/**
* PDF_Label - PDF label editing
* @package PDF_Label
* @author Laurent PASSEBECQ <lpasseb@numericable.fr>
* @copyright 2003 Laurent PASSEBECQ
**/
require_once('../fpdf/fpdf.php');
class PDF_Label extends FPDF {
// Private properties
var $_Avery_Name = ''; // Name of format
var $_Margin_Left = 0; // Left margin of labels
var $_Margin_Top = 0; // Top margin of labels
var $_X_Space = 0; // Horizontal space between 2 labels
var $_Y_Space = 0; // Vertical space between 2 labels
var $_X_Number = 0; // Number of labels horizontally
var $_Y_Number = 0; // Number of labels vertically
var $_Width = 0; // Width of label
var $_Height = 0; // Height of label
var $_Char_Size = 10; // Character size
var $_Line_Height = 10; // Default line height
var $_Metric = 'mm'; // Type of metric for labels.. Will help to calculate good values
var $_Metric_Doc = 'mm'; // Type of metric for the document
var $_Font_Name = 'Arial'; // Name of the font
var $_COUNTX = 1;
var $_COUNTY = 1;
// Listing of labels size
var $_Avery_Labels = array (
'5160'=>array('name'=>'5160', 'paper-size'=>'letter', 'metric'=>'mm', 'marginLeft'=>1.762, 'marginTop'=>10.7, 'NX'=>3, 'NY'=>10, 'SpaceX'=>3.175, 'SpaceY'=>0, 'width'=>66.675, 'height'=>25.4, 'font-size'=>8),
'5161'=>array('name'=>'5161', 'paper-size'=>'letter', 'metric'=>'mm', 'marginLeft'=>0.967, 'marginTop'=>10.7, 'NX'=>2, 'NY'=>10, 'SpaceX'=>3.967, 'SpaceY'=>0, 'width'=>101.6, 'height'=>25.4, 'font-size'=>8),
'5162'=>array('name'=>'5162', 'paper-size'=>'letter', 'metric'=>'mm', 'marginLeft'=>0.97, 'marginTop'=>20.224, 'NX'=>2, 'NY'=>7, 'SpaceX'=>4.762, 'SpaceY'=>0, 'width'=>100.807, 'height'=>35.72, 'font-size'=>8),
'5163'=>array('name'=>'5163', 'paper-size'=>'letter', 'metric'=>'mm', 'marginLeft'=>1.762, 'marginTop'=>10.7, 'NX'=>2, 'NY'=>5, 'SpaceX'=>3.175, 'SpaceY'=>0, 'width'=>101.6, 'height'=>50.8, 'font-size'=>8),
'5164'=>array('name'=>'5164', 'paper-size'=>'letter', 'metric'=>'in', 'marginLeft'=>0.148, 'marginTop'=>0.5, 'NX'=>2, 'NY'=>3, 'SpaceX'=>0.2031, 'SpaceY'=>0, 'width'=>4.0, 'height'=>3.33, 'font-size'=>12),
'8600'=>array('name'=>'8600', 'paper-size'=>'letter', 'metric'=>'mm', 'marginLeft'=>7.1, 'marginTop'=>19, 'NX'=>3, 'NY'=>10, 'SpaceX'=>9.5, 'SpaceY'=>3.1, 'width'=>66.6, 'height'=>25.4, 'font-size'=>8),
'L7163'=>array('name'=>'L7163', 'paper-size'=>'A4', 'metric'=>'mm', 'marginLeft'=>5, 'marginTop'=>15, 'NX'=>2, 'NY'=>7, 'SpaceX'=>25, 'SpaceY'=>0, 'width'=>99.1, 'height'=>38.1, 'font-size'=>9)
);
// convert units (in to mm, mm to in)
// $src and $dest must be 'in' or 'mm'
function _Convert_Metric ($value, $src, $dest) {
if ($src != $dest) {
$tab['in'] = 39.37008;
$tab['mm'] = 1000;
return $value * $tab[$dest] / $tab[$src];
} else {
return $value;
}
}
// Give the height for a char size given.
function _Get_Height_Chars($pt) {
// Array matching character sizes and line heights
$_Table_Hauteur_Chars = array(6=>2, 7=>2.5, 8=>3, 9=>4, 10=>5, 11=>6, 12=>7, 13=>8, 14=>9, 15=>10);
if (in_array($pt, array_keys($_Table_Hauteur_Chars))) {
return $_Table_Hauteur_Chars[$pt];
} else {
return 100; // There is a prob..
}
}
function _Set_Format($format) {
$this->_Metric = $format['metric'];
$this->_Avery_Name = $format['name'];
$this->_Margin_Left = $this->_Convert_Metric ($format['marginLeft'], $this->_Metric, $this->_Metric_Doc);
$this->_Margin_Top = $this->_Convert_Metric ($format['marginTop'], $this->_Metric, $this->_Metric_Doc);
$this->_X_Space = $this->_Convert_Metric ($format['SpaceX'], $this->_Metric, $this->_Metric_Doc);
$this->_Y_Space = $this->_Convert_Metric ($format['SpaceY'], $this->_Metric, $this->_Metric_Doc);
$this->_X_Number = $format['NX'];
$this->_Y_Number = $format['NY'];
$this->_Width = $this->_Convert_Metric ($format['width'], $this->_Metric, $this->_Metric_Doc);
$this->_Height = $this->_Convert_Metric ($format['height'], $this->_Metric, $this->_Metric_Doc);
$this->Set_Font_Size($format['font-size']);
}
// Constructor
function PDF_Label ($format, $unit='mm', $posX=1, $posY=1) {
if (is_array($format)) {
// Custom format
$Tformat = $format;
} else {
// Avery format
$Tformat = $this->_Avery_Labels[$format];
}
parent::FPDF('P', $Tformat['metric'], $Tformat['paper-size']);
// $this->setSourceFile('../fpdf/13_6.pdf');
$this->_Set_Format($Tformat);
$this->Set_Font_Name('Arial');
$this->SetMargins(0, 0);
$this->SetAutoPageBreak(false);
$this->_Metric_Doc = $unit;
// Start at the given label position
if ($posX > 1) $posX--; else $posX=0;
if ($posY > 1) $posY--; else $posY=0;
if ($posX >= $this->_X_Number) $posX = $this->_X_Number-1;
if ($posY >= $this->_Y_Number) $posY = $this->_Y_Number-1;
$this->_COUNTX = $posX;
$this->_COUNTY = $posY;
}
// Sets the character size
// This changes the line height too
function Set_Font_Size($pt) {
if ($pt > 3) {
$this->_Char_Size = $pt;
$this->_Line_Height = $this->_Get_Height_Chars($pt);
$this->SetFontSize($this->_Char_Size);
}
}
// Method to change font name
function Set_Font_Name($fontname) {
if ($fontname != '') {
$this->_Font_Name = $fontname;
$this->SetFont($this->_Font_Name);
}
}
// Print a label
// function Add_PDF_Label($str_avery_code, $texte, $texte2) {
function Add_PDF_Label($str_avery_code, $texte, $texte2, $texte3) {
// We are in a new page, then we must add a page
if (($this->_COUNTX ==0) and ($this->_COUNTY==0)) {
$this->AddPage();
}
$_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
$_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
//bib/team #
if($str_avery_code == '5160') {
$this->Set_Font_Size(12);
$this->SetXY($_PosX + 25.5, $_PosY + 5.5);
// $this->SetXY($_PosX + 17, $_PosY + 3);
}
if($str_avery_code == '5163'){
$this->Set_Font_Size(14);
$this->SetFont($this->_Font_Name, 'B');
// $this->SetXY($_PosX + 65, $_PosY + 5.5);
$this->SetXY($_PosX + 65, $_PosY + 5.5);
}
$this->MultiCell($this->_Width, $this->_Line_Height, $texte2);
if($str_avery_code == '5160') {
$this->Set_Font_Size(8);
$this->SetXY($_PosX+8.5, $_PosY+5.5);
// $this->SetXY($_PosX+3, $_PosY+3);
}
if($str_avery_code == '5163') {
$this->Set_Font_Size(8);
$this->SetFont($this->_Font_Name, 'BU');
$this->SetXY($_PosX+3, $_PosY+5.5);
// $this->SetXY($_PosX+3, $_PosY+5);
}
$this->MultiCell($this->_Width, $this->_Line_Height, $texte3);
$this->SetFont($this->_Font_Name);
$this->SetXY($_PosX+8.5, $_PosY+5.5);
// $this->SetXY($_PosX+3, $_PosY+3);
$this->MultiCell($this->_Width, $this->_Line_Height, $texte);
$this->_COUNTY++;
if ($this->_COUNTY == $this->_Y_Number) {
// End of column reached, we start a new one
$this->_COUNTX++;
$this->_COUNTY=0;
}
if ($this->_COUNTX == $this->_X_Number) {
// Page full, we start a new one
$this->_COUNTX=0;
$this->_COUNTY=0;
}
}
}
function fxCreateLabelsIndividual($str_avery_code)
{
$pdf = new PDF_Label($str_avery_code, 'mm', 1, 2);
//$pdf = new PDF_Label('L7163', 'mm', 1, 2);
$pdf->Open();
$pdf->AddPage();
$sqlRosterLabels = "SELECT p.par_nom, p.par_prenom, ec.pec_nom_equipe, ec.no_equipe, p.no_bib, p.par_age, (SELECT com_tshirt FROM inscriptions_comptes WHERE com_id = p.com_id) AS tshirt, (CASE p.waiver_cleared WHEN 1 THEN 'yes' ELSE 'no' END) AS waiver, UPPER(r.rol_nom_en) AS role, (SELECT COALESCE(SUM(md_montant), 0) FROM inscriptions_montants_dus WHERE pec_id = p.pec_id AND (no_commande_paye = '' OR no_commande_paye IS NULL)) AS balance, pe.epr_type_en AS category, ((IF(ec.epr_id = 109, CASE WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 150 THEN 'Under 150' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 189 THEN '150 to 189' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 219 THEN '190 to 219' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) >= 220 THEN '220+' END, '-'))) AS subcategory
FROM resultats_participants p, resultats_epreuves_commandees ec, inscriptions_roles r, inscriptions_panier_epreuves pe
WHERE p.pec_id = ec.pec_id_original AND p.rol_id = r.rol_id AND p.is_cancelled = 0 AND p.eve_id = 175 AND ec.is_cancelled = 0 AND ec.pec_actif = 1 AND ec.epr_id = pe.epr_id AND p.rol_id <= 2
ORDER BY CAST(p.no_bib as SIGNED INTEGER), ec.no_equipe, p.rol_id, p.par_nom, p.par_prenom;";
$tabRosterLabels = $GLOBALS['db']->fxGetResults($sqlRosterLabels);
// Print labels
for ($i = 1; $i <= count($tabRosterLabels); $i++) {
//for($i=1;$i<=40;$i++)
$pdf->Add_PDF_Label($str_avery_code, sprintf("%s\n\n%s\n%s\n", '', $tabRosterLabels[$i]['par_nom'] . ", " . $tabRosterLabels[$i]['par_prenom'], $tabRosterLabels[$i]['role'] . " - " . $tabRosterLabels[$i]['tshirt']), $tabRosterLabels[$i]['no_bib'], '');
// $pdf->Add_PDF_Label(sprintf("%s\n%s\n%s\n%s, %s, %s", "Laurent $i", 'Immeuble Titi', 'av. fragonard', '06000', 'NICE', 'FRANCE'));
}
$pdf->Output();
//$pdf->Output('http://www.ms1inscriptiondev.progiweb.co/fpdf/13_6.pdf');
}
function fxCreateTeamLabels($str_avery_code){
$pdf = new PDF_Label($str_avery_code, 'mm', 1, 2);
$pdf->Open();
$pdf->AddPage();
// data
$sqlTeamData = "SELECT ec.epr_id, ec.pec_id_original AS pec_id, (SELECT par_nom FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id = 1) AS nom_captain, (SELECT par_prenom FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id = 1) AS prenom_captain, ec.pec_nom_equipe, ec.no_equipe, (SELECT COALESCE(SUM(md_montant), 0) FROM inscriptions_montants_dus WHERE pec_id = ec.pec_id AND (no_commande_paye = '' OR no_commande_paye IS NULL)) AS balance, SUBSTR(pe.epr_type_en,1,17) AS category, ((IF(ec.epr_id = 109, CASE WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 150 THEN 'Under 150' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 189 THEN '150 to 189' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 219 THEN '190 to 219' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) >= 220 THEN '220+' END, '-'))) AS subcategory
FROM resultats_epreuves_commandees ec, inscriptions_panier_epreuves pe
WHERE ec.eve_id = 175 AND ec.is_cancelled = 0 AND ec.pec_actif = 1 AND ec.epr_id = pe.epr_id
ORDER BY CAST(ec.no_equipe AS SIGNED INTEGER), nom_captain, prenom_captain;";
$tabTeamData = $GLOBALS['db']->fxGetResults($sqlTeamData);
//var_dump($tabTeamData);
// Print labels
for ($i = 1; $i <= count($tabTeamData); $i++) {
$sqlParticipantsData = "SELECT p.par_nom, p.par_prenom, p.no_bib, p.par_age, (SELECT com_tshirt FROM inscriptions_comptes WHERE com_id = p.com_id) AS tshirt, (CASE p.waiver_cleared WHEN 1 THEN 'yes' ELSE 'no' END) AS waiver, UPPER(SUBSTR(r.rol_nom_en,1,2)) AS role
FROM resultats_participants p, inscriptions_roles r
WHERE p.rol_id = r.rol_id AND p.is_cancelled = 0 AND p.pec_id = " . intval($tabTeamData[$i]['pec_id']) . "
ORDER BY p.rol_id, p.par_nom, p.par_prenom;";
$tabParticipantsData = $GLOBALS['db']->fxGetResults($sqlParticipantsData);
$strTeammates = '';
for($j = 1; $j <= count($tabParticipantsData); $j++){
$strTeammates .= $tabParticipantsData[$j]['no_bib'] . " - " . $tabParticipantsData[$j]['par_prenom'] . " " . $tabParticipantsData[$j]['par_nom'] . " - " . $tabParticipantsData[$j]['role'] . " - " . $tabParticipantsData[$j]['par_age'] . " - " . $tabParticipantsData[$j]['tshirt'] . " - " . $tabParticipantsData[$j]['waiver'] . "\n";
}
$strNoEquipe = $tabTeamData[$i]['no_equipe'] . "\n\n\n";
if($tabTeamData[$i]['epr_id'] == 109)
$strCategory = $tabTeamData[$i]['subcategory'];
// $strCategory = $tabTeamData[$i]['category'] . "(" . $tabTeamData[$i]['subcategory'] . ")";
else
$strCategory = $tabTeamData[$i]['category'];
$pdf->Add_PDF_Label($str_avery_code, sprintf("%s\n\n%s", '',$strTeammates ), $strNoEquipe,$tabTeamData[$i]['prenom_captain'] . " " . $tabTeamData[$i]['nom_captain'] . " - " . $strCategory );
// $pdf->Add_PDF_Label(sprintf("%s\n%s\n%s\n%s, %s, %s", "Laurent $i", 'Immeuble Titi', 'av. fragonard', '06000', 'NICE', 'FRANCE'));
}
$pdf->Output();
}
if(isset($_GET['id'])) {
if($_GET['id'] == '13_7')
fxCreateTeamLabels('5163');
if($_GET['id'] == '13_3')
fxCreate13_3();
if($_GET['id'] == '13_3b')
fxCreate13_3b();
// fxCreateViewByTeamPDF();
}
else
fxCreateLabelsIndividual('5160');
//fxCreateLabelsIndividual('5160');
function fxCreate13_3(){
// 13.3
$sqlTeam = "SELECT ec.pec_id_original AS pec_id, (SELECT par_nom FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id = 1) AS nom_captain, (SELECT par_prenom FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id = 1) AS prenom_captain, ec.pec_nom_equipe, ec.no_equipe, (SELECT COALESCE(SUM(md_montant), 0) FROM inscriptions_montants_dus WHERE pec_id = ec.pec_id AND (no_commande_paye = '' OR no_commande_paye IS NULL)) AS balance, SUBSTR(pe.epr_type_en,1,17) AS category, ((IF(ec.epr_id = 109, CASE WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 150 THEN 'Under 150' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 189 THEN '150 to 189' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 219 THEN '190 to 219' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) >= 220 THEN '220+' END, '-'))) AS subcategory
FROM resultats_epreuves_commandees ec, inscriptions_panier_epreuves pe
WHERE ec.eve_id = 175 AND ec.is_cancelled = 0 AND ec.pec_actif = 1 AND ec.epr_id = pe.epr_id
ORDER BY nom_captain, prenom_captain";
$tabTeam = $GLOBALS['db']->fxGetResults($sqlTeam);
$pdf = new PDF();
////$pdf = new PDF_Label('L7163', 'mm', 1, 2);
//
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont('Arial', '', 12);
$pdf->SetMargins(15, 1);
$nb=0;
// $pdf->SetAutoPageBreak(true, 15);
for($i = 1; $i <= count($tabTeam); $i++) {
$sqlParticipants = "SELECT p.par_nom, p.par_prenom, p.no_bib, p.par_age, (SELECT com_tshirt FROM inscriptions_comptes WHERE com_id = p.com_id) AS tshirt, (CASE p.waiver_cleared WHEN 1 THEN 'yes' ELSE 'no' END) AS waiver, UPPER(SUBSTR(r.rol_nom_en,1,2)) AS role
FROM resultats_participants p, inscriptions_roles r
WHERE p.rol_id = r.rol_id AND p.is_cancelled = 0 AND p.pec_id = " . intval($tabTeam[$i]['pec_id']) . "
ORDER BY p.rol_id, p.par_nom, p.par_prenom";
$tabParticipants = $GLOBALS['db']->fxGetResults($sqlParticipants);
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetXY($pdf->GetX() + 160, $pdf->GetY() + 10);
// team/pec infos
// $pdf->SetXY($pdf->GetX() + 160, $pdf->GetY());
$int_y = $pdf->GetY();
// $pdf->Write(5, $tabTeam[$i]['no_equipe']);
// $pdf->SetXY($pdf->GetX()+160, $pdf->GetY());
$strCat = "CATEGORY: " . $tabTeam[$i]['category'];
$pdf->Ln(5);
$pdf->SetXY($pdf->GetX() + 120, $pdf->GetY());
$pdf->Write(5, $tabTeam[$i]['no_equipe']);
$pdf->SetFont('Arial', '', 10);
$pdf->Ln(5);
$pdf->SetXY($pdf->GetX() + 80, $pdf->GetY());
$pdf->Write(5, $strCat);
if ($tabTeam[$i]['subcategory'] != '-') {
$strSubCat = "SUBCATEGORY: " . $tabTeam[$i]['subcategory'];
$pdf->Ln(5);
$pdf->SetXY($pdf->GetX() + 80, $pdf->GetY());
$pdf->Write(5, $strSubCat);
}
$strBalance = "BALANCE OWING: " . $tabTeam[$i]['balance'];
$pdf->Ln(5);
$pdf->SetXY($pdf->GetX() + 80, $pdf->GetY());
$pdf->Write(5, $strBalance);
// $pdf->Write(3, "CATEGORY: " . $tabTeam[$i]['category']);
$pdf->SetXY($pdf->GetX(), $int_y);
$pdf->Ln(5);
// $pdf->SetXY($pdf->GetX(), $pdf->GetY() - 14);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Write(5, $tabTeam[$i]['nom_captain'] . " " . $tabTeam[$i]['prenom_captain'] . "\n");
$pdf->SetFont('Arial', '', 10);
for ($j = 1; $j <= count($tabParticipants); $j++) {
$pdf->Write(5, $tabParticipants[$j]['par_prenom'] . " " . $tabParticipants[$j]['par_nom'] . " | " . $tabParticipants[$j]['role'] . " | " . $tabParticipants[$j]['par_age'] . " | " . $tabParticipants[$j]['tshirt'] . " | " . $tabParticipants[$j]['waiver'] . "\n");
}
$nb = $nb + 1;
if ($nb == 5)
// if ($nb == 4)
{ $pdf->addpage();
$nb=0;
}
// $pdf->SetXY(10, $pdf->GetY() + 2);
//
// $pdf->SetXY(10, $pdf->GetY() + 10);
// $pdf->Write(5, $tabTeam[$i]['no_equipe'] );
// $pdf->Write(5, $tabTeam[$i]['category'] );
// echo "<div>" . $tabTeam[$i]['no_equipe'] . "</div>";
// echo "<div>" . $tabTeam[$i]['category']. "</div>";
// echo "<div>" . $tabTeam[$i]['subcategory']. "</div>";
// echo "<div>" . $tabTeam[$i]['no_equipe']. "</div>";
}
$pdf->Output();
}
function fxCreate13_3b(){
// 13.3
$sqlTeam = "SELECT ec.pec_id_original AS pec_id, (SELECT par_nom FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id = 1) AS nom_captain, (SELECT par_prenom FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id = 1) AS prenom_captain, ec.pec_nom_equipe, ec.no_equipe, (SELECT COALESCE(SUM(md_montant), 0) FROM inscriptions_montants_dus WHERE pec_id = ec.pec_id AND (no_commande_paye = '' OR no_commande_paye IS NULL)) AS balance, pe.epr_type_en AS category, ((IF(ec.epr_id = 109, CASE WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 150 THEN 'Under 150' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 189 THEN '150 to 189' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) <= 219 THEN '190 to 219' WHEN (SELECT SUM(par_age) FROM resultats_participants WHERE pec_id = ec.pec_id_original AND is_cancelled = 0 AND rol_id <= 2) >= 220 THEN '220+' END, '-'))) AS subcategory
FROM resultats_epreuves_commandees ec, inscriptions_panier_epreuves pe
WHERE ec.eve_id = 175 AND ec.is_cancelled = 0 AND ec.pec_actif = 1 AND ec.epr_id = pe.epr_id
ORDER BY nom_captain, prenom_captain";
$tabTeam = $GLOBALS['db']->fxGetResults($sqlTeam);
$pdf = new PDF();
$pdf->Open();
$pdf->AddPage();
// $pdf->SetMargins(15,50,15);
$pdf->SetTopMargin(30);
$nb=0;
////$pdf = new PDF_Label('L7163', 'mm', 1, 2);
//
// Colors, line width and bold font
$pdf->SetFillColor(255,0,0);
$pdf->SetTextColor(255);
$pdf->SetDrawColor(0,0,0);
$pdf->SetLineWidth(.3);
$pdf->SetFont('Arial','B');
// Header
$width = array(100, 100, 100, 100, 90);
// for($i=0;$i<count($header);$i++)
// $pdf->Cell($w[$i],7,$header[$i],1,0,'C',true);
// $pdf->Ln();
// Color and font restoration
// $pdf->SetFillColor(224,235,255);
$pdf->SetTextColor(0);
$pdf->SetFont('');
// Data
$fill = false;
for($i = 1; $i <= count($tabTeam); $i++)
{
$sqlParticipants = "SELECT p.par_nom, p.par_prenom, p.no_bib, p.par_age, (SELECT com_tshirt FROM inscriptions_comptes WHERE com_id = p.com_id) AS tshirt, (CASE p.waiver_cleared WHEN 1 THEN 'yes' ELSE 'no' END) AS waiver, UPPER(SUBSTR(r.rol_nom_en,1,2)) AS role
FROM resultats_participants p, inscriptions_roles r
WHERE p.rol_id = r.rol_id AND p.is_cancelled = 0 AND p.pec_id = " . intval($tabTeam[$i]['pec_id']) . "
ORDER BY p.rol_id, p.par_nom, p.par_prenom";
$tabParticipants = $GLOBALS['db']->fxGetResults($sqlParticipants);
if ($tabTeam[$i]['subcategory'] != '-') {
$strSubCat = "SUBCATEGORY: " . $tabTeam[$i]['subcategory'];
}
else{
$strSubCat = '';
}
$int_x = $pdf->GetX();
$int_y = $pdf->GetY();
// $pdf->Ln();
$pdf->SetXY($pdf->GetX() + 90, $pdf->GetY());
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell($width[0],4,$tabTeam[$i]['no_equipe'],'1',0,'R',$fill);
$pdf->SetXY($int_x, $pdf->GetY());
$pdf->Cell($width[4],4,$tabTeam[$i]['nom_captain'] . " " . $tabTeam[$i]['prenom_captain'],'1',0,'L',$fill);
$pdf->Ln();
$pdf->SetFont('Arial', '', 10);
$pdf->SetXY($pdf->GetX() + 90, $pdf->GetY());
$pdf->SetFillColor(204, 204, 204);
$pdf->Cell($width[1],4, "CATEGORY: " . $tabTeam[$i]['category'],'1',0,'L',true);
$int_part_y = $pdf->GetY();
$pdf->Ln();
$pdf->SetXY($pdf->GetX() + 90, $pdf->GetY());
$pdf->Cell($width[2],4,$strSubCat,'1',0,'L',true);
$pdf->Ln();
$pdf->SetXY($pdf->GetX() + 90, $pdf->GetY());
$pdf->Cell($width[3],4,"BALANCE OWING: " .$tabTeam[$i]['balance'],'1',0,'L',true);
$pdf->Ln();
$pdf->SetY($int_part_y);
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial', '', 8);
for ($j = 1; $j <= 10; $j++) {
// for ($j = 1; $j <= count($tabParticipants); $j++) {
$pdf->SetXY($pdf->GetX(), $pdf->GetY());
if(isset($tabParticipants[$j])) {
$pdf->Cell(50,4, $tabParticipants[$j]['par_prenom'] . " " . $tabParticipants[$j]['par_nom'], '1', 0, 'L', $fill);
$pdf->SetXY($pdf->GetX(), $pdf->GetY());
$pdf->Cell(10,4, $tabParticipants[$j]['role'], '1', 0, 'C', $fill);
$pdf->Cell(10,4, $tabParticipants[$j]['par_age'], '1', 0, 'C', $fill);
$pdf->Cell(10,4, $tabParticipants[$j]['tshirt'], '1', 0, 'C', $fill);
$pdf->Cell(10,4, $tabParticipants[$j]['waiver'], '1', 0, 'C', $fill);
}
else {
$pdf->Cell($width[4],4, '', '1', 0, 'L', $fill);
}
$pdf->Ln();
}
$pdf->Ln(5);
$fill = !$fill;
$nb = $nb + 1;
// if ($nb == 3)
if ($nb == 5)
{ $pdf->addpage();
$nb=0;
}
}
// Closing line
$pdf->Cell(array_sum($width),0,'','T');
$pdf->Ln(2);
//
// $pdf->SetFont('Arial', '', 12);
// $pdf->SetMargins(15, 1);
// $pdf->SetAutoPageBreak(true, 15);
// for($i = 1; $i <= count($tabTeam); $i++) {
//
// $pdf->SetFont('Arial', 'B', 12);
// $pdf->SetXY($pdf->GetX() + 160, $pdf->GetY() + 10);
// // team/pec infos
//
//// $pdf->SetXY($pdf->GetX() + 160, $pdf->GetY());
//
// $int_y = $pdf->GetY();
//// $pdf->Write(5, $tabTeam[$i]['no_equipe']);
//// $pdf->SetXY($pdf->GetX()+160, $pdf->GetY());
//
//
// $strCat = "CATEGORY: " . $tabTeam[$i]['category'];
// $pdf->Ln(5);
// $pdf->SetFillColor(204,204,204);
// $pdf->SetXY($pdf->GetX() + 80, $pdf->GetY());
//// $pdf->SetXY($pdf->GetX() + 120, $pdf->GetY());
// $pdf->Cell(60,$pdf->GetY(), $tabTeam[$i]['no_equipe'], 1);
//// $pdf->Write(5, $tabTeam[$i]['no_equipe']);
//
// $pdf->SetFont('Arial', '', 10);
// $pdf->Ln(5);
// $pdf->SetXY($pdf->GetX() + 80, $pdf->GetY());
//
// $pdf->Write(5, $strCat);
// if ($tabTeam[$i]['subcategory'] != '-') {
// $strSubCat = "SUBCATEGORY: " . $tabTeam[$i]['subcategory'];
// $pdf->Ln(5);
// $pdf->SetXY($pdf->GetX() + 80, $pdf->GetY());
// $pdf->Write(5, $strSubCat);
// }
//
// $strBalance = "BALANCE OWING: " . $tabTeam[$i]['balance'];
// $pdf->Ln(5);
// $pdf->SetXY($pdf->GetX() + 80, $pdf->GetY());
// $pdf->Write(5, $strBalance);
//
//
//// $pdf->Write(3, "CATEGORY: " . $tabTeam[$i]['category']);
//
//
// $pdf->SetXY($pdf->GetX(), $int_y);
// $pdf->Ln(5);
//// $pdf->SetXY($pdf->GetX(), $pdf->GetY() - 14);
// $pdf->SetFont('Arial', 'B', 12);
// $pdf->Write(5, $tabTeam[$i]['nom_captain'] . " " . $tabTeam[$i]['prenom_captain'] . "\n");
// $pdf->SetFont('Arial', '', 10);
// for ($j = 1; $j <= count($tabParticipants); $j++) {
//
// $pdf->Write(5, $tabParticipants[$j]['par_prenom'] . " " . $tabParticipants[$j]['par_nom'] . " | " . $tabParticipants[$j]['role'] . " | " . $tabParticipants[$j]['par_age'] . " | " . $tabParticipants[$j]['tshirt'] . " | " . $tabParticipants[$j]['waiver'] . "\n");
// }
//
//
// $nb = $nb + 1;
// if ($nb == 4)
// { $pdf->addpage();
// $nb=0;
// }
//
// }
$pdf->Output();
}
?>