Created
January 22, 2016 15:29
-
-
Save mrcmorales/ce97768a092f0980c518 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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