Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Itoop\Atc\Controller;
- use TYPO3\Flow\Annotations as Flow;
- use TYPO3\Flow\Mvc\Controller\ActionController;
- use Itoop\Atc\Domain\Model\Mitglied;
- /**
- * LoginController
- *
- *
- */
- class SearchController extends \TYPO3\Flow\Mvc\Controller\ActionController {
- /**
- * @Flow\Inject
- * @var \Itoop\Atc\Domain\Repository\MitgliedRepository
- */
- protected $mitgliedRepository;
- /**
- * @Flow\Inject
- * @var \Itoop\Atc\Domain\Repository\BeitragssatzTennisRepository
- */
- protected $beitragssatzTennisRepository;
- /**
- * @Flow\Inject
- * @var \Itoop\Atc\Domain\Repository\BeitragssatzBreitensportRepository
- */
- protected $beitragssatzBreitensportRepository;
- /**
- * @Flow\Inject
- * @var \Itoop\Atc\Domain\Repository\ArchivRepository
- */
- protected $archivRepository;
- /**
- * index action, does only display the form
- */
- public function indexAction() {
- // find all members
- $mitgl = $this->mitgliedRepository->findAll();
- //$this->view->assign('beitragssaetze', $this->beitragssatzRepository->findAll());
- // calculations and automatic property-settings
- //
- // for each member calculate age and update array/property age
- foreach ($mitgl as $P) {
- $this->persistenceManager->whitelistObject($P);
- // Calculate Birthday
- //date in mm.dd.yyyy format; or it can be in other formats as well
- $birthDate = $P->getGeburtsdatum();
- //explode the date to get month, day and year
- $birthDate = explode(".", $birthDate);
- //get age from date or birthdate
- $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[1], $birthDate[0], $birthDate[2]))) > date("md")
- ? ((date("Y") - $birthDate[2]) - 1)
- : (date("Y") - $birthDate[2]));
- $P->setAge("$age");
- // get date of Geburtsdatum and make property Geburtszeit, to be able to sort by birthday
- $BD = $P->getGeburtsdatum();
- // format to timestamp
- $dt = strtotime($BD);
- // set property geburtszeit to every member
- $P->setGeburtszeit("$dt");
- // do the same for Eintrittsdatum
- $ED = $P->getEintrittsdatum();
- $et = strtotime($ED);
- $P->setEintrittszeit("$et");
- $this->mitgliedRepository->update($P);
- //$this->persistenceManager->persistAll();
- // *** Calculate Beitrag ***
- // read out beitragssatz, age and abteilung out of mitglieder
- $BS = $P->getBeitragssatz();
- $ABT = $P->getAbteilung();
- $age = $P->getAge();
- $U13 = 'U13';
- $U22 = 'U22';
- if ($ABT === 'Tennis') {
- // by arbitrary DQL select Beitragssatz out of beitragssatzRepository
- if ($BS !== 'Individual') {
- $abfrage = $this->beitragssatzTennisRepository->findByBeitrag($BS);
- $BSU13 = $this->beitragssatzTennisRepository->findU13($U13);
- $BSU22 = $this->beitragssatzTennisRepository->findU22($U22);
- }
- // Altersstaffel
- if ($age < '13' and $BS == 'Aktiv') {
- $P->setBeitrag($BSU13);
- }
- if ($age > '12' and $age < '22' and $BS === 'Aktiv') {
- $P->setBeitrag($BSU22);
- }
- if ($age > '21' and $BS === 'Aktiv') {
- $P->setBeitrag($abfrage);
- }
- if ($BS === 'Passiv') {
- $P->setBeitrag($abfrage);
- }
- if ($BS === 'Ehepaar') {
- $P->setBeitrag($abfrage);
- }
- // read out trainingssatz out of mitglied
- $TS = $P->getTrainingssatz();
- // by arbitrary DQL select Beitragssatz out of beitragssatzRepository
- if ($TS !== 'Individual' and $TS !=='Kein') {
- $TSABFRAGE = $this->beitragssatzTennisRepository->findByTrainingsbeitrag($TS);
- }
- // if trainingssatz is Training set Traininssatz standard
- if ($TS === 'Training') {
- $P->setTrainingsbeitrag($TSABFRAGE);
- }
- // if Trainingssatz is kein set Trainingsbeitrag 0,00
- if ($TS === 'Kein') {
- $P->setTrainingsbeitrag('0,00');
- }
- }
- if ($ABT == 'Breitensport') {
- // by arbitrary DQL select Beitragssatz out of beitragssatzRepository
- if ($BS != 'individual' and $BS !== 'Ehepaar') {
- $abfrage = $this->beitragssatzBreitensportRepository->findByBeitrag($BS);
- $BSU13 = $this->beitragssatzBreitensportRepository->findU13($U13);
- $BSU21 = $this->beitragssatzBreitensportRepository->findU22($U22);
- }
- // Altersstaffel
- if ($age < '13' and $BS == 'aktiv') {
- $P->setBeitrag($BSU13);
- }
- if ($age > '12' and $age < '22' and $BS == 'aktiv') {
- $P->setBeitrag($BSU22);
- }
- if ($age > '21' and $BS === 'aktiv') {
- $P->setBeitrag($abfrage);
- }
- if ($BS === 'passiv') {
- $P->setBeitrag($abfrage);
- }
- }
- $this->mitgliedRepository->update($P);
- //$this->persistenceManager->persistAll();
- }
- }
- /**
- * @return void
- *
- *
- *
- * @Flow\Validate(argumentName="geburtsdatumab", type="Itoop.Atc:DatumEmptyAllowed")
- * @Flow\Validate(argumentName="geburtsdatumbis", type="Itoop.Atc:DatumEmptyAllowed")
- * @Flow\Validate(argumentName="eintrittab", type="Itoop.Atc:DatumEmptyAllowed")
- * @Flow\Validate(argumentName="eintrittbis", type="Itoop.Atc:DatumEmptyAllowed")
- *
- *
- * @param string $searchin
- * @param string $abteilung
- * @param string $mitgliedsnummer
- * @param string $geschlecht
- * @param string $name
- * @param string $vorname
- * @param string $strasse
- * @param string $plz
- * @param string $ort
- * @param string $geburtsdatumab
- * @param string $geburtsdatumbis
- * @param string $alterab
- * @param string $alterbis
- * @param string $eintrittab
- * @param string $eintrittbis
- * @param string $mandatsreferenz
- * @param string $sequenz
- * @param string $beitragssatz
- * @param string $trainingssatz
- * @param string $iban
- *
- * @return string
- *
- */
- public function resultsAction($searchin, $abteilung, $mitgliedsnummer, $geschlecht, $name, $vorname, $strasse, $plz, $ort, $geburtsdatumab, $geburtsdatumbis, $alterab, $alterbis, $eintrittab, $eintrittbis, $mandatsreferenz, $iban, $sequenz, $beitragssatz, $trainingssatz) {
- if ($abteilung == 'Alle') {
- $abteilung = '%';
- }
- if ($mitgliedsnummer == '') {
- $mitgliedsnummer = '%';
- }
- if ($geschlecht == 'Beide') {
- $geschlecht = '%';
- }
- if ($name == '') {
- $name = '%';
- }
- if ($vorname == '') {
- $vorname = '%';
- }
- if ($strasse == '') {
- $strasse = '%';
- }
- if ($plz == '') {
- $plz = '%';
- }
- if ($ort == '') {
- $ort = '%';
- }
- if ($geburtsdatumab == '') {
- $geburtsdatumab = '01.01.1900';
- }
- if ($geburtsdatumbis == '') {
- $geburtsdatumbis = '31.12.9999';
- }
- if ($alterab == '') {
- $alterab = '0';
- }
- if ($alterbis == '') {
- $alterbis = '200';
- }
- if ($eintrittab == '') {
- $eintrittab = '01.01.1900';
- }
- if ($eintrittbis == '') {
- $eintrittbis = '31.12.3000';
- }
- if ($mandatsreferenz == '') {
- $mandatsreferenz = '%';
- }
- if ($iban == '') {
- $iban = '%';
- }
- if ($sequenz == 'Bitte_waehlen') {
- $sequenz = '%';
- }
- if ($beitragssatz == 'Bitte_waehlen') {
- $beitragssatz = '%';
- }
- if ($trainingssatz == 'Bitte_waehlen') {
- $trainingssatz = '%';
- }
- if ($trainingssatz == 'Kein') {
- $trainingssatz = 'Kein';
- }
- $gzab = strtotime($geburtsdatumab);
- $gzbis = strtotime($geburtsdatumbis);
- $ezab = strtotime($eintrittab);
- $ezbis = strtotime($eintrittbis);
- if ($searchin == 'Mitglieder') {
- if ($trainingssatz == 'Alle') {
- $this->view->assign('mitglieder', $this->mitgliedRepository->searchTraining($abteilung, $mitgliedsnummer, $geschlecht, $name, $vorname, $strasse, $plz, $ort, $gzab, $gzbis, $alterab, $alterbis, $ezab, $ezbis, $mandatsreferenz, $iban, $sequenz, $beitragssatz));
- }
- if ($trainingssatz != 'Alle') {
- $this->view->assign('mitglieder', $this->mitgliedRepository->search($abteilung, $mitgliedsnummer, $geschlecht, $name, $vorname, $strasse, $plz, $ort, $gzab, $gzbis, $alterab, $alterbis, $ezab, $ezbis, $mandatsreferenz, $iban, $sequenz, $beitragssatz, $trainingssatz));
- }
- }
- if ($searchin == 'Archiv') {
- if ($trainingssatz == 'Alle') {
- $this->view->assign('archivs', $this->archivRepository->searchTraining($abteilung, $mitgliedsnummer, $geschlecht, $name, $vorname, $strasse, $plz, $ort, $gzab, $gzbis, $alterab, $alterbis, $ezab, $ezbis, $mandatsreferenz, $iban, $sequenz, $beitragssatz));
- }
- if ($trainingssatz != 'Alle') {
- $this->view->assign('archivs', $this->archivRepository->search($abteilung, $mitgliedsnummer, $geschlecht, $name, $vorname, $strasse, $plz, $ort, $gzab, $gzbis, $alterab, $alterbis, $ezab, $ezbis, $mandatsreferenz, $iban, $sequenz, $beitragssatz, $trainingssatz));
- }
- }
- }
- /**
- * @return \TYPO3\Flow\Error\Message
- */
- protected function getErrorFlashMessage() {
- switch ($this->actionMethodName) {
- case 'resultsAction' :
- return new \TYPO3\Flow\Error\Error('Die Suche konnte nicht ausgeführt werden, weil mindestens ein Feld nicht richtig ausgefüllt wurde.');
- default:
- return parent::getErrorFlashMessage();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment