Skip to content

Instantly share code, notes, and snippets.

@mrcmorales
Created January 22, 2016 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrcmorales/ce97768a092f0980c518 to your computer and use it in GitHub Desktop.
Save mrcmorales/ce97768a092f0980c518 to your computer and use it in GitHub Desktop.
<?php
namespace Circuit\AppBundle\CsvModel;
use Circuit\AppBundle\Entity\Inscription;
use EasyCSV\Writer;
/**
* Class UserExportCsvWriter.
*/
class InscriptionCsvExport extends Writer
{
protected $properties = [
'Dorsal',
'Tarjeta SI',
'Id. de la base de datos',
'Apellidos',
'Nombre',
'An',
'S',
'Bloque',
'nc',
'Salida',
'Meta',
'Tiempo',
'Estado clas.',
'Nº de club',
'Nombre de club',
'Ciudad',
'Nac',
'Nº de categoría',
'Corto',
'Largo',
'Num1',
'Num2',
'Num3',
'Text1',
'Text2',
'Text3',
'Direc. nominal',
'calle',
'Línea 2',
'CP',
'Ciudad',
'Teléfono',
'Fax',
'E-Mail',
'Id/Club',
'Alquiladas',
'Cuota de inscripción',
'Pagado',
];
/**
* UserExportCsvWriter constructor.
*
* @param $path
* @param string $mode
*/
public function __construct($path, $mode = 'r+')
{
parent::__construct($path, $mode);
$this->setDelimiter(';');
$this->writeRow($this->properties);
}
/**
* @param Inscription $inscription
*/
public function writeInscription(Inscription $inscription)
{
$user = $inscription->getUser();
$race = $inscription->getRace();
$event = $race->getEvent();
$result = $inscription->getResult();
$club = $user->getClub();
$row = [
'',
$user->getChip(),
'',
ucwords(strtolower($user->getLastname())),
ucwords(strtolower($user->getFirstname())),
is_object($user->getDateOfBirth()) ? $user->getDateOfBirth()->format('Y') : '',
'm' === $user->getGender() ? 'H' : 'D',
'',
'',
'00:00:00', // $event->getInscriptionStartAt()->format('H:i'),
'', // $event->getInscriptionEndAt()->format('H:i'),
'', // $result->getTime(),
'',
is_object($club) ? $club->getId() : '',
'-',
is_object($club) ? $club->getName() : '',
'',
$inscription->getCategory(),
$inscription->getCategoryName(),
'',
'',
'',
'',
$user->getDni(),
'',
'',
'',
$user->getAddress(),
'',
$user->getZip(),
$user->getCity(),
$user->getPhone(),
'',
$user->getEmail(),
'',
'',
'',
];
$this->writeRow($row);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment