Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 /**
  * @param TblPerson     $tblPerson
  * @param TblSalutation $tblSalutation
  * @param string        $Title
  * @param string        $FirstName
  * @param string        $SecondName
  * @param string        $LastName
  *
  * @return bool
  */
 public function updatePerson(TblPerson $tblPerson, TblSalutation $tblSalutation, $Title, $FirstName, $SecondName, $LastName)
 {
     $Manager = $this->Connection->getEntityManager();
     /** @var TblPerson $Entity */
     $Entity = $Manager->getEntityById('TblPerson', $tblPerson->getId());
     $Protocol = clone $Entity;
     if (null !== $Entity) {
         $Entity->setTblSalutation($tblSalutation);
         $Entity->setTitle($Title);
         $Entity->setFirstName($FirstName);
         $Entity->setSecondName($SecondName);
         $Entity->setLastName($LastName);
         $Manager->saveEntity($Entity);
         Protocol::useService()->createUpdateEntry($this->Connection->getDatabase(), $Protocol, $Entity);
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * @param TblGroup  $tblGroup
  * @param TblPerson $tblPerson
  *
  * @return bool
  */
 public function removeGroupPerson(TblGroup $tblGroup, TblPerson $tblPerson)
 {
     $Manager = $this->Connection->getEntityManager();
     /** @var TblMember $Entity */
     $Entity = $Manager->getEntity('TblMember')->findOneBy(array(TblMember::ATTR_TBL_GROUP => $tblGroup->getId(), TblMember::SERVICE_TBL_PERSON => $tblPerson->getId()));
     if (null !== $Entity) {
         Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
         $Manager->killEntity($Entity);
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * @param TblPerson $tblPerson
  * @param TblMail   $tblMail
  * @param TblType   $tblType
  * @param string    $Remark
  *
  * @return TblToPerson
  */
 public function addMailToPerson(TblPerson $tblPerson, TblMail $tblMail, TblType $tblType, $Remark)
 {
     $Manager = $this->Connection->getEntityManager();
     $Entity = $Manager->getEntity('TblToPerson')->findOneBy(array(TblToPerson::SERVICE_TBL_PERSON => $tblPerson->getId(), TblToPerson::ATT_TBL_MAIL => $tblMail->getId(), TblToPerson::ATT_TBL_TYPE => $tblType->getId()));
     if (null === $Entity) {
         $Entity = new TblToPerson();
         $Entity->setServiceTblPerson($tblPerson);
         $Entity->setTblMail($tblMail);
         $Entity->setTblType($tblType);
         $Entity->setRemark($Remark);
         $Manager->saveEntity($Entity);
         Protocol::useService()->createInsertEntry($this->Connection->getDatabase(), $Entity);
     }
     return $Entity;
 }
Exemplo n.º 5
0
 /**
  * @param TblPerson|null $tblPerson
  */
 public function setServiceTblPerson(TblPerson $tblPerson = null)
 {
     $this->serviceTblPerson = null === $tblPerson ? null : $tblPerson->getId();
 }
Exemplo n.º 6
0
 /**
  * @param TblPerson $tblPerson
  *
  * @return bool|TblToPerson[]
  */
 public function getCompanyRelationshipAllByPerson(TblPerson $tblPerson)
 {
     $EntityList = $this->Connection->getEntityManager()->getEntity('TblToCompany')->findBy(array(TblToCompany::SERVICE_TBL_PERSON => $tblPerson->getId()));
     return empty($EntityList) ? false : $EntityList;
 }
Exemplo n.º 7
0
 /**
  *
  * @param TblPerson $tblPerson
  *
  * @return bool|TblCommon
  */
 public function getCommonByPerson(TblPerson $tblPerson)
 {
     /** @var TblCommon $Entity */
     $Entity = $this->Connection->getEntityManager()->getEntity('TblCommon')->findOneBy(array(TblCommon::SERVICE_TBL_PERSON => $tblPerson->getId()));
     return null === $Entity ? false : $Entity;
 }
Exemplo n.º 8
0
 /**
  * @param TblPerson $tblPerson
  *
  * @return bool|TblCustody
  */
 public function getCustodyByPerson(TblPerson $tblPerson)
 {
     return $this->getCachedEntityBy(__METHOD__, $this->Connection->getEntityManager(), 'TblCustody', array(TblCustody::SERVICE_TBL_PERSON => $tblPerson->getId()));
 }
Exemplo n.º 9
0
 /**
  * @param TblCompany $tblCompany
  * @param TblPerson  $tblPerson
  * @param TblType    $tblType
  * @param string     $Remark
  *
  * @return TblToCompany
  */
 public function addCompanyRelationshipToPerson(TblCompany $tblCompany, TblPerson $tblPerson, TblType $tblType, $Remark)
 {
     $Manager = $this->Connection->getEntityManager();
     $Entity = $Manager->getEntity('TblToCompany')->findOneBy(array(TblToCompany::SERVICE_TBL_COMPANY => $tblCompany->getId(), TblToCompany::SERVICE_TBL_PERSON => $tblPerson->getId(), TblToCompany::ATT_TBL_TYPE => $tblType->getId()));
     if (null === $Entity) {
         $Entity = new TblToCompany();
         $Entity->setServiceTblCompany($tblCompany);
         $Entity->setServiceTblPerson($tblPerson);
         $Entity->setTblType($tblType);
         $Entity->setRemark($Remark);
         $Manager->saveEntity($Entity);
         Protocol::useService()->createInsertEntry($this->Connection->getDatabase(), $Entity);
     }
     return $Entity;
 }
Exemplo n.º 10
0
 /**
  * @param TblPerson $tblPerson
  *
  * @return bool|TblToPerson[]
  */
 public function getAddressAllByPerson(TblPerson $tblPerson)
 {
     /** @var IApiInterface $Cache */
     $Cache = (new Cache(new Memory()))->getCache();
     if (!($Entity = $Cache->getValue(__METHOD__))) {
         $EntityList = $this->Connection->getEntityManager()->getEntity('TblToPerson')->findBy(array(TblToPerson::SERVICE_TBL_PERSON => $tblPerson->getId()));
         $Cache->setValue(__METHOD__, empty($EntityList) ? false : $EntityList, 300);
     }
     return empty($EntityList) ? false : $EntityList;
 }
 /**
  * @param TblPerson|null $tblPerson
  */
 public function setServiceTblPersonAttendingDoctor(TblPerson $tblPerson = null)
 {
     $this->serviceTblPersonAttendingDoctor = null === $tblPerson ? null : $tblPerson->getId();
 }
Exemplo n.º 12
0
 /**
  * @param TblPerson $tblPerson
  *
  * @return bool|TblToPerson[]
  */
 public function getAddressAllByPerson(TblPerson $tblPerson)
 {
     $EntityList = $this->Connection->getEntityManager()->getEntity('TblToPerson')->findBy(array(TblToPerson::SERVICE_TBL_PERSON => $tblPerson->getId()));
     return empty($EntityList) ? false : $EntityList;
 }