| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Setono\SyliusLagersystemPlugin\Repository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\ORM\QueryBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Sylius\Component\Core\OrderCheckoutStates; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Sylius\Component\Core\OrderPaymentStates; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Sylius\Component\Core\OrderShippingStates; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | trait ShipmentRepositoryTrait | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |      * @param string $alias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * @param string $indexBy The index for the from. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * @return QueryBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     abstract public function createQueryBuilder($alias, $indexBy = null); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     public function createLagersystemListQueryBuilder(): QueryBuilder | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |         return $this->createQueryBuilder('shipment') | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |             ->join('shipment.order', 'o') | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |             ->andWhere('o.checkoutState in (:checkoutStates)') | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |             ->setParameter('checkoutStates', [ | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |                 OrderCheckoutStates::STATE_COMPLETED, | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |             ]) | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |             ->andWhere('o.shippingState NOT in (:shippingState)') | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |             ->setParameter('shippingState', [ | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |                 OrderShippingStates::STATE_SHIPPED, | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |             ]) | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |             ->andWhere('o.paymentState in (:paymentState)') | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |             ->setParameter('paymentState', [ | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |                 OrderPaymentStates::STATE_AUTHORIZED, | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |                 OrderPaymentStates::STATE_PARTIALLY_AUTHORIZED, | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |                 OrderPaymentStates::STATE_PAID, | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |                 OrderPaymentStates::STATE_PARTIALLY_PAID, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             ]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 46 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 47 |  |  |  |