Mister Spy Say ="Hello Kids ... :D"
___ ____ _ _____
| \/ (_) | | / ___|
| . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _
| |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | |
| | | | \__ \ || __/ | /\__/ / |_) | |_| |
\_| |_/_|___/\__\___|_| \____/| .__/ \__, |
| | __/ |
|_| |___/
Bot Mister Spy V3
Mister Spy
Mister Spy
<?php
require_once('class.excelhelper.php');
require_once('class.catalogos.php');
require_once('class.eventos.php');
require_once('class.eventosmorfologicosautoridades.php');
require_once('class.jurados.php');
require_once('class.premiosmorfologicos.php');
require_once('class.premiotipos.php');
require_once('class.misc.php');
require_once('class.rechazotipos.php');
require_once('class.rechazocondiciones.php');
class ExcelMorfologiaHelper extends ExcelHelper {
public function __construct($idEvento, $boxPerPage = 15) {
parent::__construct($idEvento, $boxPerPage);
$this->templatePath = 'templates/morfologia.xlsx';
$this->filename = $this->evento->Denominacion . ' - Planilla morfologia.xlsx';
$this->infoCells = 'A10:Q24';
}
protected function getAnimales() {
$oCatalogos = new Catalogos();
if (!$this->animales) {
$this->animales = $oCatalogos->GetAllCatalogoMorfologico(array('IdEvento' => $this->evento->IdEvento, 'TipoAptitud' => '0'));
}
return $this->animales;
}
protected function getCategoriaMorfologica() {
if (!$this->categoria) {
$oEventosMorfologicosAutoridades = new EventosMorfologicosAutoridades();
$oEventosMorfologicosAutoridad = $oEventosMorfologicosAutoridades->GetByIdEvento($this->evento->IdEvento);
$this->categoria = $oEventosMorfologicosAutoridad->Categoria;
}
return $this->categoria;
}
public function getJurado() {
if (!$this->jurado) {
$oEventosMorfologicosAutoridades = new EventosMorfologicosAutoridades();
$oJurados = new Jurados();
$oEventosMorfologicosAutoridad = $oEventosMorfologicosAutoridades->GetByIdEvento($this->evento->IdEvento);
$this->jurado = $oJurados->GetById($oEventosMorfologicosAutoridad->JAVE1);
}
return $this->jurado;
}
public function validate() {
return !!$this->getAnimales();
}
protected function getStyles() {
$headerStyle = array(
'font' => array(
'bold' => true,
'size' => 12
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'outline' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
)
);
$animalStyle = array(
'font' => array(
'bold' => false,
'size' => 11
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'outline' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
)
);
$styles = array(
'B3' => array(
'font' => array(
'bold' => true,
'name' => 'Baskerville Old Face',
'size' => 22,
'underline' => PHPExcel_Style_Font::UNDERLINE_SINGLE, // Subrayado
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
)
),
'C5' => array(
'font' => array(
'size' => 18
)
),
'K5' => array(
'font' => array(
'size' => 14
)
),
'C7' => array(
'font' => array(
'size' => 14
)
),
'K7' => array(
'font' => array(
'size' => 16
)
),
'A9' => $headerStyle,
'B9' => $headerStyle,
'C9' => $headerStyle,
'D9' => $headerStyle,
'E9' => $headerStyle,
'F9' => $headerStyle,
'G9' => $headerStyle,
'H9' => $headerStyle,
'I9' => $headerStyle,
'J9' => $headerStyle,
'K9' => $headerStyle,
'L9' => $headerStyle,
'M9' => $headerStyle,
'N9' => $headerStyle,
'O9' => $headerStyle,
'P9' => $headerStyle,
'Q9' => $headerStyle,
'C26' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'left' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
'right' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
)
),
'D26' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'left' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
'right' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
)
),
'B27' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'left' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
'right' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
)
),
'C27' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'left' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'right' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
)
),
'D27' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'left' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'right' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
)
),
'B28' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'left' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'right' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
)
),
'C28' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'left' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'right' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
)
),
'D28' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'left' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'right' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
)
),
'B29' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'left' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'right' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
)
),
'C29' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'left' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'right' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
)
),
'D29' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'borders' => array(
'left' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
),
'right' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM,
),
)
),
'M28' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
)
),
'M29' => array(
'font' => array(
'size' => 11,
'name' => 'Calibri',
'bold' => false,
'underline' => false
)
)
);
for ($i = 10; $i < 25; $i++) {
$styles['A' . $i] = $animalStyle;
$styles['B' . $i] = $animalStyle;
$styles['C' . $i] = $animalStyle;
$styles['D' . $i] = $animalStyle;
$styles['E' . $i] = $animalStyle;
$styles['F' . $i] = $animalStyle;
$styles['G' . $i] = $animalStyle;
$styles['H' . $i] = $animalStyle;
$styles['I' . $i] = $animalStyle;
$styles['J' . $i] = $animalStyle;
$styles['K' . $i] = $animalStyle;
$styles['L' . $i] = $animalStyle;
$styles['M' . $i] = $animalStyle;
$styles['N' . $i] = $animalStyle;
$styles['O' . $i] = $animalStyle;
$styles['P' . $i] = $animalStyle;
$styles['Q' . $i] = $animalStyle;
}
return $styles;
}
protected function setSheetHeader($activeSheet) {
$activeSheet->setCellValue('A2', 'Hoja NÂș ' . ($sheetIndex + 1));
$activeSheet->setCellValue('C5', $this->evento->Denominacion);
$activeSheet->setCellValue('K5', str_replace('-', '/', CambiarFecha($this->evento->EventoDesdeFecha)));
$activeSheet->setCellValue('C7', $this->getCategoriaMorfologica());
$activeSheet->setCellValue('K7', $this->getJurado()->Nombre . ' ' . $this->getJurado()->Apellido);
}
protected function setSheetStyles($activeSheet) {
foreach ($this->getStyles() as $key => $style) {
$activeSheet->getStyle($key)->applyFromArray($style);
}
}
protected function getOpcionesPremios($idTipo) {
$oPremiosMorfologicos = new PremiosMorfologicos();
$premios = $oPremiosMorfologicos->GetAll(array('IdTipo' => $idTipo));
$premios2 = null;
if ($idTipo == PremioTipos::Premios) {
$premios2 = $oPremiosMorfologicos->GetAll(array('IdTipo' => PremioTipos::Menciones));
}
$premiosSinPremio = $oPremiosMorfologicos->GetAll(array('IdTipo' => PremioTipos::SinPremio));
$arr = array();
foreach ($premios as $premio) {
$arr[] = utf8_encode($premio->Nombre);
}
if ($premios2) {
foreach ($premios2 as $premio) {
$arr[] = utf8_encode($premio->Nombre);
}
}
foreach ($premiosSinPremio as $premio) {
$arr[] = utf8_encode($premio->Nombre);
}
return $arr;
}
protected function setSheetValues($activeSheet, $cellIndex, $oAnimal, $count) {
$activeSheet->setCellValue('A' . $cellIndex, $count + 1);
$activeSheet->setCellValue('B' . $cellIndex, utf8_encode($oAnimal->MorfologiaCategoria));
$activeSheet->setCellValue('D' . $cellIndex, $oAnimal->SBA);
$activeSheet->setCellValue('E' . $cellIndex, CambiarFecha($oAnimal->FNac));
$activeSheet->setCellValue('F' . $cellIndex, utf8_encode($oAnimal->Pelo));
$this->setSelectCell($activeSheet->getCell('J' . $cellIndex), $this->getOpcionesPremios(PremioTipos::Premios));
$this->setSelectCell($activeSheet->getCell('K' . $cellIndex), $this->getOpcionesPremios(PremioTipos::Campeonato));
$this->setSelectCell($activeSheet->getCell('L' . $cellIndex), $this->getOpcionesPremios(PremioTipos::GranCampeonato));
$this->setSelectCell($activeSheet->getCell('M' . $cellIndex), array('Asistio', 'Ausente'));
$this->setSelectCell($activeSheet->getCell('N' . $cellIndex), array('Aceptado', 'Rechazado'));
$this->setSelectCell($activeSheet->getCell('O' . $cellIndex), array_map(function($tipo) { return $tipo['Descripcion']; }, RechazoTipos::GetAll()));
$this->setSelectCell($activeSheet->getCell('P' . $cellIndex), array_map(function($condicion) { return $condicion['Descripcion']; }, RechazoCondiciones::GetAll()));
}
public function generateExcel() {
$this->loadTemplate();
$objPHPExcel = new PHPExcel();
$objPHPExcel->removeSheetByIndex(0);
$sheet = $this->template->getSheet(0);
$sheet->rebindParent($objPHPExcel);
$count = 0;
$sheetIndex = 0;
if ($this->validate()) {
$activeSheet = null;
foreach ($this->animales as $oAnimal) {
if ($count % $this->boxPerPage == 0) {
$objPHPExcel->addSheet($sheet->copy());
$objPHPExcel->setActiveSheetIndex($sheetIndex);
$activeSheet = $objPHPExcel->getActiveSheet();
$this->setSheetHeader($activeSheet);
$limit = ($sheetIndex * $this->boxPerPage + $this->boxPerPage);
if ($limit > count($this->animales)) {
$limit = count($this->animales);
}
$activeSheet->setTitle('Box ' . ($sheetIndex * $this->boxPerPage + 1) . ' - ' . $limit);
$this->setSheetStyles($activeSheet);
$sheetIndex++;
}
$cellIndex = ($count % $this->boxPerPage) + 10;
$this->setSheetValues($activeSheet, $cellIndex, $oAnimal, $count);
$count++;
}
}
$objPHPExcel->setActiveSheetIndex(0);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $this->filename . '"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');
}
public function parseInfo($value, $reference) {
if (!$reference) {
return utf8_decode($value);
}
if ($value === '') {
return '';
}
if ($value == $reference) {
return '1';
}
return '0';
}
public function parsePremio($value, $idTipo) {
$oPremiosMorfologicos = new PremiosMorfologicos();
$premios = $oPremiosMorfologicos->GetAll(array('IdTipo' => $idTipo));
$premiosSinPremio = $oPremiosMorfologicos->GetAll(array('IdTipo' => PremioTipos::SinPremio));
foreach ($premios as $premio) {
if ($premio->Nombre == $value) {
return $premio;
}
}
foreach ($premiosSinPremio as $premio) {
if ($premio->Nombre == $value) {
return $premio;
}
}
return null;
}
public function parseRechazoTipo($value) {
foreach (RechazoTipos::GetAll() as $tipo) {
if ($tipo['Descripcion'] == $value) {
return $tipo['IdTipo'];
}
}
return null;
}
public function parseRechazoCondicion($value) {
foreach (RechazoCondiciones::GetAll() as $condicion) {
if ($condicion['Descripcion'] == $value) {
return $condicion['IdCondicion'];
}
}
return null;
}
}
?>
Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat