/** * @param IFormInterface $Form * @param string $CredentialKey * @param TblConsumer $tblConsumer * * @return bool|TblToken */ public function createToken(IFormInterface $Form, $CredentialKey, TblConsumer $tblConsumer = null) { try { if (null !== $CredentialKey && !empty($CredentialKey)) { $this->isTokenValid($CredentialKey); if (false === $this->getTokenByIdentifier(substr($CredentialKey, 0, 12))) { (new Data($this->Binding))->createToken(substr($CredentialKey, 0, 12), $tblConsumer); return new Success('Der YubiKey wurde hinzugefügt') . new Redirect('/Setting/Authorization/Token', 3); } else { $Form->setError('CredentialKey', 'Der von Ihnen angegebene YubiKey wurde bereits registriert'); } } elseif (null !== $CredentialKey && empty($CredentialKey)) { $Form->setError('CredentialKey', 'Bitte verwenden Sie Ihren YubiKey um dieses Feld zu befüllen'); } return $Form; } catch (BadOTPException $E) { $Form->setError('CredentialKey', 'Der von Ihnen angegebene YubiKey ist nicht gültig<br/>Bitte verwenden Sie einen YubiKey um dieses Feld zu befüllen'); return $Form; } catch (ReplayedOTPException $E) { $Form->setError('CredentialKey', 'Der von Ihnen angegebene YubiKey wurde bereits verwendet<br/>Bitte verwenden Sie einen YubiKey um dieses Feld neu zu befüllen'); return $Form; } catch (ComponentException $E) { $Form->setError('CredentialKey', 'Der YubiKey konnte nicht überprüft werden<br/>Bitte versuchen Sie es später noch einmal'); return $Form; } }
/** * @param IFormInterface $Form * @param TblPerson $tblPersonFrom * @param int $tblPersonTo * @param array $Type * * @return IFormInterface|string */ public function createRelationshipToPerson(IFormInterface $Form, TblPerson $tblPersonFrom, $tblPersonTo, $Type) { /** * Skip to Frontend */ if (null === $Type) { return $Form; } $Error = false; if (empty($tblPersonTo)) { $Form->appendGridGroup(new FormGroup(new FormRow(new FormColumn(new Danger('Bitte wählen Sie eine Person'))))); $Error = true; } else { $tblPersonTo = Person::useService()->getPersonById($tblPersonTo); if ($tblPersonFrom->getId() == $tblPersonTo->getId()) { $Form->appendGridGroup(new FormGroup(new FormRow(new FormColumn(new Danger('Eine Person kann nur mit einer anderen Person verknüpft werden'))))); $Error = true; } } if (!$Error) { $tblType = $this->getTypeById($Type['Type']); if ((new Data($this->Binding))->addPersonRelationshipToPerson($tblPersonFrom, $tblPersonTo, $tblType, $Type['Remark'])) { return new Success('Die Beziehung wurde erfolgreich hinzugefügt') . new Redirect('/People/Person', 1, array('Id' => $tblPersonFrom->getId())); } else { return new Danger('Die Beziehung konnte nicht hinzugefügt werden') . new Redirect('/People/Person', 10, array('Id' => $tblPersonFrom->getId())); } } return $Form; }
/** * @param IFormInterface $Form * @param TblAccount $tblAccount * @param int $Consumer * * @return IFormInterface|Redirect */ public function updateConsumer(IFormInterface &$Form, TblAccount $tblAccount, $Consumer) { if (null === $Consumer) { return $Form; } $Error = false; if (empty($Consumer)) { $Form->setError('Consumer', 'Bitte wählen Sie einen Mandanten aus'); $Error = true; } if ($Error) { return $Form; } else { $tblConsumer = Consumer::useService()->getConsumerById($Consumer); if (Account::useService()->changeConsumer($tblConsumer, $tblAccount)) { return new Success('Der Mandant wurde erfolgreich geändert') . new Redirect('/Setting/MyAccount', 1); } else { return new Danger('Der Mandant konnte nicht geändert werden') . new Redirect('/Setting/MyAccount', 10); } } }
/** * @param IFormInterface|null $Stage * @param UploadedFile $FileUpload * * @return IFormInterface|string */ public function UploadNow(IFormInterface &$Stage = null, $FileUpload) { /** * Skip to Frontend */ if (false === $FileUpload) { return $Stage; } if (!$FileUpload) { $Stage->setError('FileUpload', 'Bitte wählen Sie eine Datei'); } else { try { $Upload = $this->getUpload('FileUpload', __DIR__)->validateMaxSize('2M')->validateMimeType(array('image/png', 'image/gif', 'image/jpeg', 'image/jpg')); // ->doUpload(); $Dimension = $Upload->getDimensions(); if (!(new Data($this->Binding))->createTestPicture($Upload->getName(), $Upload->getFilename(), $Upload->getExtension(), $Upload->getContent(), $Upload->getMimeType(), $Upload->getSize(), $Dimension['width'], $Dimension['height'])) { $Stage .= new Danger('Der Upload konnte nicht erfasst werden'); // .new Redirect('/Platform/System/Test/Upload', 20); } else { $Stage .= new Success('Der Upload ist erfasst'); // .new Redirect('/Platform/System/Test/Upload', 20); } // unlink($Upload->getLocation().DIRECTORY_SEPARATOR.$Upload->getFilename()); } catch (\Exception $Exception) { $Stage->setError('FileUpload', $Exception->getMessage()); return $Stage; } } return $Stage; }
/** * @param IFormInterface $Form * @param null|string $TicketSubject * @param null|string $TicketMessage * * @return IMessageInterface|IFormInterface */ public function executeCreateTicket(IFormInterface &$Form, $TicketSubject, $TicketMessage) { $Error = false; if (empty($TicketSubject) && null !== $TicketSubject) { $Form->setError('TicketSubject', 'Bitte geben Sie ein Thema ein'); $Error = true; } elseif (null === $TicketSubject) { $Error = true; } else { $Form->setSuccess('TicketSubject', ''); } if (empty($TicketMessage) && null !== $TicketMessage) { $Form->setError('TicketMessage', 'Bitte geben Sie ein Mitteilung ein'); $Error = true; } elseif (null === $TicketMessage) { $Error = true; } else { $Form->setSuccess('TicketMessage', ''); } if ($Error) { /** * Nothing to do */ try { $Youtrack = (new Support(new YouTrack()))->getSupport(); $Form->prependGridGroup($Youtrack->ticketCurrent()); return $Form; } catch (\Exception $E) { return new Danger('Das Support-System konnte nicht geladen werden'); } } else { /** * Submit Ticket */ try { $Youtrack = (new Support(new YouTrack()))->getSupport(); $Youtrack->createTicket(urldecode($TicketSubject), urldecode($TicketMessage)); return new Success('Das Problem wurde erfolgreich dem Support mitgeteilt'); } catch (\Exception $E) { return new Danger('Das Problem konnte nicht übertragen werden'); } } }
/** * @param IFormInterface $Form * @param TblCompany $tblCompany * @param array $Company * * @return IFormInterface|Redirect */ public function updateCompany(IFormInterface $Form = null, TblCompany $tblCompany, $Company) { /** * Skip to Frontend */ if (null === $Company) { return $Form; } $Error = false; if (isset($Company['Name']) && empty($Company['Name'])) { $Form->setError('Company[Name]', 'Bitte geben Sie einen Namen an'); $Error = true; } if (!$Error) { if ((new Data($this->Binding))->updateCompany($tblCompany, $Company['Name'], $Company['Description'])) { // Change Groups if (isset($Company['Group'])) { // Remove all Groups $tblGroupList = Group::useService()->getGroupAllByCompany($tblCompany); foreach ($tblGroupList as $tblGroup) { Group::useService()->removeGroupCompany($tblGroup, $tblCompany); } // Add current Groups foreach ((array) $Company['Group'] as $tblGroup) { Group::useService()->addGroupCompany(Group::useService()->getGroupById($tblGroup), $tblCompany); } } else { // Remove all Groups $tblGroupList = Group::useService()->getGroupAllByCompany($tblCompany); foreach ($tblGroupList as $tblGroup) { Group::useService()->removeGroupCompany($tblGroup, $tblCompany); } } return new Success('Die Firma wurde erfolgreich aktualisiert') . new Redirect('/Corporation/Company', 1, array('Id' => $tblCompany->getId())); } else { return new Danger('Die Firma konnte nicht aktualisiert werden') . new Redirect('/Corporation/Company', 10); } } return $Form; }
/** * @param IFormInterface $Stage * @param TblItem $tblItem * @param $Item * * @return IFormInterface|string */ public function executeEditItem(IFormInterface &$Stage = null, TblItem $tblItem, $Item) { /** * Skip to Frontend */ if (null === $Item) { return $Stage; } $Error = false; if (isset($Item['Name']) && empty($Item['Name'])) { $Stage->setError('Item[Name]', 'Bitte geben Sie einen Namen an'); $Error = true; } if (isset($Item['Price']) && empty($Item['Price'])) { $Stage->setError('Item[Price]', 'Bitte geben Sie einen Preis an'); $Error = true; } if (!$Error) { if ((new Data($this->Binding))->actionEditItem($tblItem, $Item['Name'], $Item['Description'], $Item['Price'], $Item['CostUnit'], $Item['Course'], $Item['ChildRank'])) { $Stage .= new Success('Änderungen gespeichert, die Daten werden neu geladen...') . new Redirect('/Billing/Inventory/Commodity/Item', 1); } else { $Stage .= new Danger('Änderungen konnten nicht gespeichert werden'); } } return $Stage; }
/** * @param IFormInterface $Stage * @param TblInvoiceItem $tblInvoiceItem * @param $InvoiceItem * * @return IFormInterface|string */ public function executeEditInvoiceItem(IFormInterface &$Stage = null, TblInvoiceItem $tblInvoiceItem, $InvoiceItem) { /** * Skip to Frontend */ if (null === $InvoiceItem) { return $Stage; } $Error = false; if (isset($InvoiceItem['Price']) && empty($InvoiceItem['Price'])) { $Stage->setError('InvoiceItem[Price]', 'Bitte geben Sie einen Preis an'); $Error = true; } if (isset($InvoiceItem['Quantity']) && empty($InvoiceItem['Quantity'])) { $Stage->setError('InvoiceItem[Quantity]', 'Bitte geben Sie eine Menge an'); $Error = true; } if (!$Error) { if ((new Data($this->Binding))->actionEditInvoiceItem($tblInvoiceItem, $InvoiceItem['Price'], $InvoiceItem['Quantity'])) { $Stage .= new Success('Änderungen gespeichert, die Daten werden neu geladen...') . new Redirect('/Billing/Bookkeeping/Invoice/IsNotConfirmed/Edit', 1, array('Id' => $tblInvoiceItem->getTblInvoice()->getId())); } else { $Stage .= new Danger('Änderungen konnten nicht gespeichert werden') . new Redirect('/Billing/Bookkeeping/Invoice/IsNotConfirmed/Edit', 2, array('Id' => $tblInvoiceItem->getTblInvoice()->getId())); } } return $Stage; }
/** * @param IFormInterface $Stage * @param TblBasket $tblBasket * @param $Basket * * @return IFormInterface|string */ public function executeCheckBasket(IFormInterface &$Stage = null, TblBasket $tblBasket, $Basket) { /** * Skip to Frontend */ if (null === $Basket) { return $Stage; } $Error = false; if (isset($Basket['Date']) && empty($Basket['Date'])) { $Stage->setError('Basket[Date]', 'Bitte geben Sie ein Fälligkeitsdatum an'); $Error = true; } $ErrorMissing = false; if (!$this->entityBasketItemAllByBasket($tblBasket)) { $Stage .= new Danger("Im Warenkorb befinden sich keine Artikel. Bitte gehen Sie zurück und wählen welche aus"); $ErrorMissing = true; } $tblBasketPersonAllByBasket = $this->entityBasketPersonAllByBasket($tblBasket); if (!$tblBasketPersonAllByBasket) { $Stage .= new Danger("Im Warenkorb befinden sich keine Schüler. Bitte gehen Sie zurück und wählen welche aus"); $ErrorMissing = true; } else { foreach ($tblBasketPersonAllByBasket as $tblBasketPerson) { if (!(new Data($this->Binding))->checkDebtorExistsByPerson($tblBasketPerson->getServiceManagementPerson())) { $Stage .= new Danger("Für den Schüler " . $tblBasketPerson->getServiceManagementPerson()->getFullName() . " gibt es noch keinen relevanten Debitoren. Bitte legen Sie diese zunächst einen an"); $ErrorMissing = true; } } } if ($ErrorMissing) { return $Stage; } if (!$Error) { //destroy TempTables (new Data($this->Binding))->actionDestroyBasketCommodity($tblBasket); Invoice::useService()->executeDestroyTempInvoice($tblBasket); if ((new Data($this->Binding))->checkDebtors($tblBasket, null)) { if (Invoice::useService()->executeCreateInvoiceListFromBasket($tblBasket, $Basket['Date'])) { $Stage .= new Success('Die Rechnungen wurden erfolgreich erstellt') . new Redirect('/Billing/Bookkeeping/Invoice/IsNotConfirmed', 2); } else { $Stage .= new Success('Die Rechnungen konnten nicht erstellt werden') . new Redirect('/Billing/Accounting/Basket', 2); } } else { $Stage .= new Warning('Es konnten nicht alle Debitoren eindeutig zugeordnet werden') . new Redirect('/Billing/Accounting/Basket/Debtor/Select', 2, array('Id' => $tblBasket->getId(), 'Date' => $Basket['Date'])); } } return $Stage; }
/** * @param IFormInterface $Form * @param string $ConsumerAcronym * @param string $ConsumerName * * @return IFormInterface|Redirect */ public function createConsumer(IFormInterface &$Form, $ConsumerAcronym, $ConsumerName) { if (null === $ConsumerName && null === $ConsumerAcronym) { return $Form; } $Error = false; if (null !== $ConsumerAcronym && empty($ConsumerAcronym)) { $Form->setError('ConsumerAcronym', 'Bitte geben Sie ein Mandantenkürzel an'); $Error = true; } if ($this->getConsumerByAcronym($ConsumerAcronym)) { $Form->setError('ConsumerAcronym', 'Das Mandantenkürzel muss einzigartig sein'); $Error = true; } if (null !== $ConsumerName && empty($ConsumerName)) { $Form->setError('ConsumerName', 'Bitte geben Sie einen gültigen Mandantenname ein'); $Error = true; } if ($Error) { return $Form; } else { (new Data($this->Binding))->createConsumer($ConsumerAcronym, $ConsumerName); return new Redirect('/Platform/Gatekeeper/Authorization/Consumer/Create', 0); } }
/** * @param IFormInterface $Form * @param string $CredentialName * @param string $CredentialLock * @param string $CredentialKey * @param TblIdentification $tblIdentification * * @return IFormInterface|Redirect */ public function createSessionCredentialToken(IFormInterface &$Form, $CredentialName, $CredentialLock, $CredentialKey, TblIdentification $tblIdentification) { switch ($this->isCredentialValid($CredentialName, $CredentialLock, $CredentialKey, $tblIdentification)) { case false: if (null !== $CredentialName && empty($CredentialName)) { $Form->setError('CredentialName', 'Bitte geben Sie einen gültigen Benutzernamen ein'); } if (null !== $CredentialName && !empty($CredentialName)) { $Form->setError('CredentialName', 'Bitte geben Sie einen gültigen Benutzernamen ein'); } if (null !== $CredentialLock && empty($CredentialLock)) { $Form->setError('CredentialLock', 'Bitte geben Sie ein gültiges Passwort ein'); } if (null !== $CredentialLock && !empty($CredentialLock)) { $Form->setError('CredentialLock', 'Bitte geben Sie ein gültiges Passwort ein'); } break; case null: $Form->setSuccess('CredentialName', ''); $Form->setSuccess('CredentialLock', ''); $Form->setError('CredentialKey', 'Der von Ihnen angegebene YubiKey ist nicht gültig.' . '<br/>Bitte verwenden Sie Ihren YubiKey um dieses Feld zu befüllen'); break; case true: return new Redirect('/', 0); break; } return $Form; }
/** * @param IFormInterface $Form * @param TblToCompany $tblToCompany * @param TblPerson $tblPersonFrom * @param int $tblCompanyTo * @param array $Type * * @return IFormInterface|string */ public function updateRelationshipToCompany(IFormInterface $Form, TblToCompany $tblToCompany, TblPerson $tblPersonFrom, $tblCompanyTo, $Type) { /** * Skip to Frontend */ if (null === $Type) { return $Form; } $Error = false; if (empty($tblCompanyTo)) { $Form->appendGridGroup(new FormGroup(new FormRow(new FormColumn(new Danger('Bitte wählen Sie eine Firma'))))); $Error = true; } else { $tblCompanyTo = Company::useService()->getCompanyById($tblCompanyTo); } if (!$Error) { $tblType = $this->getTypeById($Type['Type']); // Remove current (new Data($this->Binding))->removeCompanyRelationshipToPerson($tblToCompany); // Add new if ((new Data($this->Binding))->addCompanyRelationshipToPerson($tblCompanyTo, $tblPersonFrom, $tblType, $Type['Remark'])) { return new Success('Die Beziehung wurde erfolgreich geändert') . new Redirect('/People/Person', 1, array('Id' => $tblToCompany->getServiceTblPerson()->getId())); } else { return new Danger('Die Beziehung konnte nicht geändert werden') . new Redirect('/People/Person', 10, array('Id' => $tblToCompany->getServiceTblPerson()->getId())); } } return $Form; }
/** * @param IFormInterface $Form * @param TblToPerson $tblToPerson * @param string $Number * @param array $Type * * @return IFormInterface|string */ public function updatePhoneToPerson(IFormInterface $Form, TblToPerson $tblToPerson, $Number, $Type) { /** * Skip to Frontend */ if (null === $Number) { return $Form; } $Error = false; if (isset($Number) && empty($Number)) { $Form->setError('Number', 'Bitte geben Sie eine gültige Telefonnummer an'); $Error = true; } if (!$Error) { $tblType = $this->getTypeById($Type['Type']); $tblPhone = (new Data($this->Binding))->createPhone($Number); // Remove current (new Data($this->Binding))->removePhoneToPerson($tblToPerson); // Add new if ((new Data($this->Binding))->addPhoneToPerson($tblToPerson->getServiceTblPerson(), $tblPhone, $tblType, $Type['Remark'])) { return new Success('Die Telefonnummer wurde erfolgreich geändert') . new Redirect('/People/Person', 1, array('Id' => $tblToPerson->getServiceTblPerson()->getId())); } else { return new Danger('Die Telefonnummer konnte nicht geändert werden') . new Redirect('/People/Person', 10, array('Id' => $tblToPerson->getServiceTblPerson()->getId())); } } return $Form; }
/** * @param IFormInterface $Form * @param TblCompany $tblCompany * @param array $Street * @param array $City * @param integer $State * @param array $Type * * @return IFormInterface|string */ public function createAddressToCompany(IFormInterface $Form, TblCompany $tblCompany, $Street, $City, $State, $Type) { /** * Skip to Frontend */ if (null === $Street && null === $City && null === $State) { return $Form; } $Error = false; if (isset($Street['Name']) && empty($Street['Name'])) { $Form->setError('Street[Name]', 'Bitte geben Sie eine Strasse an'); $Error = true; } else { $Form->setSuccess('Street[Number]'); } if (isset($Street['Number']) && empty($Street['Number'])) { $Form->setError('Street[Number]', 'Bitte geben Sie eine Hausnummer an'); $Error = true; } else { $Form->setSuccess('Street[Number]'); } if (isset($City['Code']) && !preg_match('!^[0-9]{5}$!is', $City['Code'])) { $Form->setError('City[Code]', 'Bitte geben Sie eine fünfstellige Postleitzahl ein'); $Error = true; } else { $Form->setSuccess('City[Code]'); } if (isset($City['Name']) && empty($City['Name'])) { $Form->setError('City[Name]', 'Bitte geben Sie einen Namen ein'); $Error = true; } else { $Form->setSuccess('City[Name]'); } if (!$Error) { $tblType = $this->getTypeById($Type['Type']); $tblState = $this->getStateById($State); $tblCity = (new Data($this->Binding))->createCity($City['Code'], $City['Name'], $City['District']); $tblAddress = (new Data($this->Binding))->createAddress($tblState, $tblCity, $Street['Name'], $Street['Number'], ''); if ((new Data($this->Binding))->addAddressToCompany($tblCompany, $tblAddress, $tblType, $Type['Remark'])) { return new Success('Die Adresse wurde erfolgreich hinzugefügt') . new Redirect('/Corporation/Company', 1, array('Id' => $tblCompany->getId())); } else { return new Danger('Die Adresse konnte nicht hinzugefügt werden') . new Redirect('/Corporation/Company', 10, array('Id' => $tblCompany->getId())); } } return $Form; }
public function removeResponsibility(IFormInterface $Form, $Responsibility) { /** * Skip to Frontend */ if (null === $Responsibility) { $Form->appendGridGroup(new FormGroup(new FormRow(new FormColumn(new Danger('Bitte wählen Sie den zu entfernenden Schulträger aus'))))); return $Form; } $tblResponsibility = (new Data($this->Binding))->getResponsibilityById($Responsibility); if ((new Data($this->Binding))->removeResponsibility($tblResponsibility)) { return new Success('Der Schulträger wurde erfolgreich entfernt') . new Redirect('/Setting/Consumer/Responsibility', 1); } else { return new Danger('Der Schulträger konnte nicht entfernt werden') . new Redirect('/Setting/Consumer/Responsibility', 10); } }
/** * @param IFormInterface $Form * @param array $Account * * @return IFormInterface */ public function createAccount(IFormInterface $Form, $Account) { if (null === $Account) { return $Form; } $Error = false; $Username = trim($Account['Name']); $Password = trim($Account['Password']); $PasswordSafety = trim($Account['PasswordSafety']); $tblConsumer = GatekeeperConsumer::useService()->getConsumerBySession(); if (!($tblToken = GatekeeperToken::useService()->getTokenById((int) $Account['Token']))) { $tblToken = null; } if (empty($Username)) { $Form->setError('Account[Name]', 'Bitte geben Sie einen Benutzernamen an'); $Error = true; } else { if (preg_match('!^[a-z0-9]{5,}$!is', $Username)) { $Username = $tblConsumer->getAcronym() . '-' . $Username; if (!GatekeeperAccount::useService()->getAccountByUsername($Username)) { $Form->setSuccess('Account[Name]', ''); } else { $Form->setError('Account[Name]', 'Der angegebene Benutzername ist bereits vergeben'); $Error = true; } } else { $Form->setError('Account[Name]', 'Der Benutzername darf nur Buchstaben und Zahlen enthalten und muss mindestens 5 Zeichen lang sein'); $Error = true; } } if (empty($Password)) { $Form->setError('Account[Password]', 'Bitte geben Sie ein Passwort an'); $Error = true; } else { if (strlen($Password) >= 8) { $Form->setSuccess('Account[Password]', ''); } else { $Form->setError('Account[Password]', 'Das Passwort muss mindestens 8 Zeichen lang sein'); $Error = true; } } if (empty($PasswordSafety)) { $Form->setError('Account[PasswordSafety]', 'Bitte geben Sie das Passwort erneut an'); $Error = true; } if ($Password != $PasswordSafety) { $Form->setError('Account[Password]', ''); $Form->setError('Account[PasswordSafety]', 'Die beiden Passworte stimmen nicht überein'); $Error = true; } else { if (!empty($Password) && !empty($PasswordSafety)) { $Form->setSuccess('Account[PasswordSafety]', ''); } else { $Form->setError('Account[PasswordSafety]', ''); } } if (!$Error) { $tblAccount = GatekeeperAccount::useService()->insertAccount($Username, $Password, $tblToken, $tblConsumer); if ($tblAccount) { $tblIdentification = GatekeeperAccount::useService()->getIdentificationById($Account['Identification']); GatekeeperAccount::useService()->addAccountAuthentication($tblAccount, $tblIdentification); if (isset($Account['Role'])) { foreach ((array) $Account['Role'] as $Role) { $tblRole = GatekeeperAccess::useService()->getRoleById($Role); GatekeeperAccount::useService()->addAccountAuthorization($tblAccount, $tblRole); } } if (isset($Account['User'])) { $tblPerson = Person::useService()->getPersonById($Account['User']); GatekeeperAccount::useService()->addAccountPerson($tblAccount, $tblPerson); } return new Success('Das Benutzerkonnto wurde erstellt') . new Redirect('/Setting/Authorization/Account', 3); } else { return new Danger('Das Benutzerkonnto konnte nicht erstellt werden') . new Redirect('/Setting/Authorization/Account', 3); } } return $Form; }
/** * @param IFormInterface $Form * @param TblGroup $tblGroup * @param array $Group * * @return IFormInterface|Redirect */ public function updateGroup(IFormInterface $Form = null, TblGroup $tblGroup, $Group) { /** * Skip to Frontend */ if (null === $Group) { return $Form; } $Error = false; if (isset($Group['Name']) && empty($Group['Name'])) { $Form->setError('Group[Name]', 'Bitte geben Sie einen Namen für die Gruppe an'); $Error = true; } else { $tblGroupTwin = $this->getGroupByName($Group['Name']); if ($tblGroupTwin && $tblGroupTwin->getId() != $tblGroup->getId()) { $Form->setError('Group[Name]', 'Bitte geben Sie einen eineindeutigen Namen für die Gruppe an'); $Error = true; } } if (!$Error) { if ((new Data($this->Binding))->updateGroup($tblGroup, $Group['Name'], $Group['Description'], $Group['Remark'])) { return new Success('Die Änderungen wurden erfolgreich gespeichert') . new Redirect('/People/Group', 1); } else { return new Danger('Die Änderungen konnte nicht gespeichert werden') . new Redirect('/People/Group', 10); } } return $Form; }
/** * @param IFormInterface $Form * @param TblToPerson $tblToPerson * @param string $Address * @param array $Type * * @return IFormInterface|string */ public function updateMailToPerson(IFormInterface $Form, TblToPerson $tblToPerson, $Address, $Type) { /** * Skip to Frontend */ if (null === $Address) { return $Form; } $Error = false; $Address = filter_var($Address, FILTER_VALIDATE_EMAIL); if (isset($Address) && empty($Address)) { $Form->setError('Address', 'Bitte geben Sie eine gültige E-Mail Adresse an'); $Error = true; } if (!$Error) { $tblType = $this->getTypeById($Type['Type']); $tblMail = (new Data($this->Binding))->createMail($Address); // Remove current (new Data($this->Binding))->removeMailToPerson($tblToPerson); // Add new if ((new Data($this->Binding))->addMailToPerson($tblToPerson->getServiceTblPerson(), $tblMail, $tblType, $Type['Remark'])) { return new Success('Die E-Mail Adresse wurde erfolgreich geändert') . new Redirect('/People/Person', 1, array('Id' => $tblToPerson->getServiceTblPerson()->getId())); } else { return new Danger('Die E-Mail Adresse konnte nicht geändert werden') . new Redirect('/People/Person', 10, array('Id' => $tblToPerson->getServiceTblPerson()->getId())); } } return $Form; }
public function removeSchool(IFormInterface $Form, $School) { /** * Skip to Frontend */ if (null === $School) { $Form->appendGridGroup(new FormGroup(new FormRow(new FormColumn(new Danger('Bitte wählen Sie die zu entfernende Schule aus'))))); return $Form; } $tblSchool = (new Data($this->Binding))->getSchoolById($School); if ((new Data($this->Binding))->removeSchool($tblSchool)) { return new Success('Die Schule wurde erfolgreich entfernt') . new Redirect('/Setting/Consumer/School', 1); } else { return new Danger('Die Schule konnte nicht entfernt werden') . new Redirect('/Setting/Consumer/School', 10); } }
/** * @param IFormInterface $Form * @param TblPerson $tblPerson * @param array $Person * * @return IFormInterface|Redirect */ public function updatePerson(IFormInterface $Form = null, TblPerson $tblPerson, $Person) { /** * Skip to Frontend */ if (null === $Person) { return $Form; } $Error = false; if (isset($Person['FirstName']) && empty($Person['FirstName'])) { $Form->setError('Person[FirstName]', 'Bitte geben Sie einen Vornamen an'); $Error = true; } if (isset($Person['LastName']) && empty($Person['LastName'])) { $Form->setError('Person[LastName]', 'Bitte geben Sie einen Nachnamen an'); $Error = true; } if (!$Error) { if ((new Data($this->Binding))->updatePerson($tblPerson, $this->getSalutationById($Person['Salutation']), $Person['Title'], $Person['FirstName'], $Person['SecondName'], $Person['LastName'])) { // Change Groups if (isset($Person['Group'])) { // Remove all Groups $tblGroupList = Group::useService()->getGroupAllByPerson($tblPerson); foreach ($tblGroupList as $tblGroup) { Group::useService()->removeGroupPerson($tblGroup, $tblPerson); } // Add current Groups foreach ((array) $Person['Group'] as $tblGroup) { Group::useService()->addGroupPerson(Group::useService()->getGroupById($tblGroup), $tblPerson); } } else { // Remove all Groups $tblGroupList = Group::useService()->getGroupAllByPerson($tblPerson); foreach ($tblGroupList as $tblGroup) { Group::useService()->removeGroupPerson($tblGroup, $tblPerson); } } return new Success('Die Person wurde erfolgreich aktualisiert') . new Redirect('/People/Person', 1, array('Id' => $tblPerson->getId())); } else { return new Danger('Die Person konnte nicht aktualisiert werden') . new Redirect('/People/Person', 10); } } return $Form; }
/** * @param IFormInterface $Stage * @param $ScoreType * * @return IFormInterface|string */ public function setScoreType(IFormInterface &$Stage = null, $ScoreType) { /** * Skip to Frontend */ if (null === $ScoreType) { return $Stage; } $Error = false; if (isset($ScoreType['Name']) && empty($ScoreType['Name'])) { $Stage->setError('ScoreType[Name]', 'Bitte geben sie einen Zenzurentypnamen an'); $Error = true; } if (isset($ScoreType['Short']) && empty($ScoreType['Short'])) { $Stage->setError('ScoreType[Short]', 'Bitte geben sie eine Abkürzung an'); $Error = true; } if (!$Error) { (new Data($this->Binding))->createScoreType($ScoreType['Name'], $ScoreType['Short']); return new Stage('Das Konto ist erfasst worden') . new Redirect('/Education/Graduation/ScoreType', 0); } return $Stage; }
/** * @param IFormInterface $Stage * @param $Debtor * @param $Id * * @return IFormInterface|string */ public function executeAddDebtor(IFormInterface &$Stage = null, $Debtor, $Id) { /** * Skip to Frontend */ if (null === $Debtor) { return $Stage; } $Error = false; if (isset($Debtor['DebtorNumber']) && empty($Debtor['DebtorNumber'])) { $Stage->setError('Debtor[DebtorNumber]', 'Bitte geben sie die Debitorennummer an'); $Error = true; } if (isset($Debtor['DebtorNumber']) && Banking::useService()->entityDebtorByDebtorNumber($Debtor['DebtorNumber'])) { $Stage->setError('Debtor[DebtorNumber]', 'Die Debitorennummer exisitiert bereits. Bitte geben Sie eine andere Debitorennummer an'); $Error = true; } if (isset($Debtor['LeadTimeFirst']) && empty($Debtor['LeadTimeFirst'])) { $Stage->setError('Debtor[LeadTimeFirst]', 'Bitte geben sie den Ersteinzug an.'); $Error = true; } if (isset($Debtor['LeadTimeFirst']) && !is_numeric($Debtor['LeadTimeFirst'])) { $Stage->setError('Debtor[LeadTimeFirst]', 'Bitte geben sie eine Zahl an.'); $Error = true; } if (isset($Debtor['LeadTimeFollow']) && empty($Debtor['LeadTimeFollow'])) { $Stage->setError('Debtor[LeadTimeFollow]', 'Bitte geben sie den Folgeeinzug an.'); $Error = true; } if (isset($Debtor['LeadTimeFollow']) && !is_numeric($Debtor['LeadTimeFollow'])) { $Stage->setError('Debtor[LeadTimeFollow]', 'Bitte geben sie eine Zahl an.'); $Error = true; } if (isset($Debtor['Reference']) && Banking::useService()->entityReferenceByReference($Debtor['Reference'])) { $Stage->setError('Debtor[Reference]', 'Die Mandatsreferenz exisitiert bereits. Bitte geben Sie eine andere an'); $Error = true; } if (!$Error) { (new Data($this->Binding))->actionAddDebtor($Debtor['DebtorNumber'], $Debtor['LeadTimeFirst'], $Debtor['LeadTimeFollow'], $Debtor['BankName'], $Debtor['Owner'], $Debtor['CashSign'], $Debtor['IBAN'], $Debtor['BIC'], $Debtor['Description'], $Debtor['PaymentType'], Management::servicePerson()->entityPersonById($Id)); //todo if (!empty($Debtor['Reference'])) { (new Data($this->Binding))->actionAddReference($Debtor['Reference'], $Debtor['DebtorNumber'], $Debtor['ReferenceDate'], Commodity::useService()->entityCommodityById($Debtor['Commodity'])); } return new Success('Der Debitor ist erfasst worden') . new Redirect('/Billing/Accounting/Banking', 2); } return $Stage; }
/** * @param IFormInterface $Stage * @param TblCommodity $tblCommodity * @param $Commodity * * @return IFormInterface|string */ public function executeEditCommodity(IFormInterface &$Stage = null, TblCommodity $tblCommodity, $Commodity) { /** * Skip to Frontend */ if (null === $Commodity) { return $Stage; } $Error = false; if (isset($Commodity['Name']) && empty($Commodity['Name'])) { $Stage->setError('Commodity[Name]', 'Bitte geben Sie einen Namen an'); $Error = true; } else { if (isset($Commodity['Name']) && $tblCommodity->getName() !== $Commodity['Name'] && (new Data($this->Binding))->entityCommodityByName($Commodity['Name'])) { $Stage->setError('Commodity[Name]', 'Die Leistung exisitiert bereits. Bitte geben Sie eine anderen Name an'); $Error = true; } } if (!$Error) { if ((new Data($this->Binding))->actionEditCommodity($tblCommodity, $Commodity['Name'], $Commodity['Description'], $this->entityCommodityTypeById($Commodity['Type']))) { $Stage .= new Success('Änderungen gespeichert, die Daten werden neu geladen...') . new Redirect('/Billing/Inventory/Commodity', 1); } else { $Stage .= new Danger('Änderungen konnten nicht gespeichert werden'); } } return $Stage; }
/** * @param IFormInterface $Stage * @param $Account * * @return IFormInterface|string */ public function executeAddAccount(IFormInterface &$Stage = null, $Account) { /** * Skip to Frontend */ if (null === $Account) { return $Stage; } $Error = false; if (isset($Account['Description']) && empty($Account['Description'])) { $Stage->setError('Account[Description]', 'Bitte geben sie eine Beschreibung an'); $Error = true; } if (isset($Account['Number']) && empty($Account['Number'])) { $Stage->setError('Account[Number]', 'Bitte geben sie die Nummer an'); $Error = true; } $Account['IsActive'] = 1; if (!$Error) { (new Data($this->Binding))->actionAddAccount($Account['Number'], $Account['Description'], $Account['IsActive'], (new Data($this->Binding))->entityAccountKeyById($Account['Key']), (new Data($this->Binding))->entityAccountTypeById($Account['Type'])); return new Success('Das Konto ist erfasst worden') . new Redirect('/Billing/Accounting/Account', 2); } return $Stage; }
/** * @param IFormInterface $Form * @param null|string $Name * * @return IFormInterface|Redirect */ public function createRole(IFormInterface $Form, $Name) { if (null !== $Name && empty($Name)) { $Form->setError('Name', 'Bitte geben Sie einen Namen ein'); } if (!empty($Name)) { $Form->setSuccess('Name', 'Die Rolle wurde hinzugefügt'); (new Data($this->Binding))->createRole($Name); return new Redirect('/Platform/Gatekeeper/Authorization/Access/Role', 0); } return $Form; }
/** * @param IFormInterface $Form * @param $SponsorAssociation * * @return IFormInterface|string */ public function removeSponsorAssociation(IFormInterface $Form, $SponsorAssociation) { /** * Skip to Frontend */ if (null === $SponsorAssociation) { $Form->appendGridGroup(new FormGroup(new FormRow(new FormColumn(new Danger('Bitte wählen Sie den zu entfernenden Förderverein aus'))))); return $Form; } $tblSponsorAssociation = (new Data($this->Binding))->getSponsorAssociationById($SponsorAssociation); if ((new Data($this->Binding))->removeSponsorAssociation($tblSponsorAssociation)) { return new Success('Der Förderverein wurde erfolgreich entfernt') . new Redirect('/Setting/Consumer/SponsorAssociation', 1); } else { return new Danger('Der Förderverein konnte nicht entfernt werden') . new Redirect('/Setting/Consumer/SponsorAssociation', 10); } }