public function getSumOfShippedItemsByItemId($itemId, $includeStatusDeliveryNote)
    {
        try {
            $qb = $this->createQueryBuilder('shipping')
                ->select('sum(shippingItems.quantity) AS shipped')
                ->join('shipping.shippingItems', 'shippingItems')
                ->join('shippingItems.item', 'item', 'WITH', 'item.id = :itemId')
                ->join('shipping.status', 'status')
                ->groupBy('item.id')
                ->where('status.id = :statusId')
                ->setParameter('itemId', $itemId)
                ->setParameter('statusId', ShippingStatus::STATUS_SHIPPED);
            if ($includeStatusDeliveryNote) {
                $qb->orWhere('status.id = :statusId2')
                    ->setParameter('statusId2', ShippingStatus::STATUS_DELIVERY_NOTE);
            }
            return $qb->getQuery()->getSingleScalarResult();
        } catch (NoResultException $exc) {
            return null;
        }
    }
public function getSumOfShippedItemsByItemId($itemId, $includeStatusDeliveryNote)
    {
        try {
            $qb = $this->createQueryBuilder('shipping')
                ->select('sum(shippingItems.quantity) AS shipped')
                ->join('shipping.shippingItems', 'shippingItems')
                ->join('shippingItems.item', 'item', 'WITH', 'item.id = :itemId')
                ->join('shipping.status', 'status')
                ->groupBy('item.id')
                ->where('status.id = :statusId')
                ->setParameter('itemId', $itemId)
                ->setParameter('statusId', ShippingStatus::STATUS_SHIPPED);
            if ($includeStatusDeliveryNote) {
                $qb->orWhere('status.id = :statusId2')
                    ->setParameter('statusId2', ShippingStatus::STATUS_DELIVERY_NOTE);
            }
            return $qb->getQuery()->getSingleScalarResult();
        } catch (NoResultException $exc) {
            return null;
        }
    }
public function getSumOfShippedItemsByItemId ( $ itemId , $ includeStatusDeliveryNote ) { try { $ qb = $ this -> createQueryBuilder ( 'shipping' ) -> select ( 'sum(shippingItems.quantity) AS shipped' ) -> join ( 'shipping.shippingItems' , 'shippingItems' ) -> join ( 'shippingItems.item' , 'item' , 'WITH' , 'item.id = :itemId' ) -> join ( 'shipping.status' , 'status' ) -> groupBy ( 'item.id' ) -> where ( 'status.id = :statusId' ) -> setParameter ( 'itemId' , $ itemId ) -> setParameter ( 'statusId' , ShippingStatus :: STATUS_SHIPPED ) ; if ( $ includeStatusDeliveryNote ) { $ qb -> orWhere ( 'status.id = :statusId2' ) -> setParameter ( 'statusId2' , ShippingStatus :: STATUS_DELIVERY_NOTE ) ; } return $ qb -> getQuery ( ) -> getSingleScalarResult ( ) ; } catch ( NoResultException $ exc ) { return null ; } }
returns all items that were shipped by itemId
@param $itemId
@param $includeStatusDeliveryNote defines if status deliveryNote should be included
@return int
returns all items that were shipped by itemId