Beispiel #1
0
 /**
  * @param TblTempInvoice $tblTempInvoice
  * @param TblCommodity   $tblCommodity
  *
  * @return TblTempInvoiceCommodity|null
  */
 public function actionCreateTempInvoiceCommodity(TblTempInvoice $tblTempInvoice, TblCommodity $tblCommodity)
 {
     $Manager = $this->Connection->getEntityManager();
     $Entity = $Manager->getEntity('TblTempInvoiceCommodity')->findOneBy(array(TblTempInvoiceCommodity::ATTR_TBL_TEMP_INVOICE => $tblTempInvoice->getId(), TblTempInvoiceCommodity::ATTR_SERVICE_BILLING_COMMODITY => $tblCommodity->getId()));
     if (null === $Entity) {
         $Entity = new TblTempInvoiceCommodity();
         $Entity->setTblTempInvoice($tblTempInvoice);
         $Entity->setServiceBillingCommodity($tblCommodity);
         $Manager->saveEntity($Entity);
         Protocol::useService()->createInsertEntry($this->Connection->getDatabase(), $Entity);
     }
     return $Entity;
 }
 /**
  * @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;
 }
Beispiel #3
0
 /**
  * @param TblDebtor    $tblDebtor
  * @param TblCommodity $tblCommodity
  *
  * @return bool|TblReference
  */
 public function entityReferenceByDebtorAndCommodity(TblDebtor $tblDebtor, TblCommodity $tblCommodity)
 {
     $Entity = $this->Connection->getEntityManager()->getEntity('TblReference')->findOneBy(array(TblReference::ATTR_TBL_DEBTOR => $tblDebtor->getId(), TblReference::ATTR_SERVICE_BILLING_COMMODITY => $tblCommodity->getId(), TblReference::ATTR_IS_VOID => false));
     return null === $Entity ? false : $Entity;
 }
 /**
  * @param null|TblCommodity $tblCommodity
  */
 public function setTblCommodity(TblCommodity $tblCommodity = null)
 {
     $this->tblCommodity = null === $tblCommodity ? null : $tblCommodity->getId();
 }
Beispiel #5
0
 /**
  * @param TblCommodity $tblCommodity
  * @param TblBasket    $tblBasket
  *
  * @return TblBasket
  */
 public function actionDestroyBasketItemsByCommodity(TblBasket $tblBasket, TblCommodity $tblCommodity)
 {
     $Manager = $this->Connection->getEntityManager();
     $tblBasketItemAllByBasket = Basket::useService()->entityBasketItemAllByBasket($tblBasket);
     /** @var TblBasketItem $tblBasketItem */
     foreach ($tblBasketItemAllByBasket as $tblBasketItem) {
         if ($tblBasketItem->getServiceBillingCommodityItem()->getTblCommodity()->getId() == $tblCommodity->getId()) {
             $Entity = $Manager->getEntity('TblBasketItem')->findOneBy(array('Id' => $tblBasketItem->getId()));
             /**@var Element $Entity */
             Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
             $Manager->bulkKillEntity($Entity);
         }
     }
     $Manager->flushCache();
     return $tblBasket;
 }
 /**
  * @param TblCommodity $tblCommodity
  */
 public function setServiceBillingCommodity(TblCommodity $tblCommodity = null)
 {
     $this->serviceBilling_Commodity = null === $tblCommodity ? null : $tblCommodity->getId();
 }
 /**
  * @param Entity\TblCommodity $tblCommodity
  *
  * @return bool
  */
 public function actionRemoveCommodity(TblCommodity $tblCommodity)
 {
     $Manager = $this->Connection->getEntityManager();
     $EntityItems = $Manager->getEntity('TblCommodityItem')->findBy(array(TblCommodityItem::ATTR_TBL_COMMODITY => $tblCommodity->getId()));
     if (null !== $EntityItems) {
         foreach ($EntityItems as $Entity) {
             Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
             $Manager->killEntity($Entity);
         }
     }
     $Entity = $Manager->getEntity('TblCommodity')->findOneBy(array('Id' => $tblCommodity->getId()));
     if (null !== $Entity) {
         /** @var Element $Entity */
         Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
         $Manager->killEntity($Entity);
         return true;
     }
     return false;
 }