protected function getQueryBuilderByFilter(\Club\UserBundle\Entity\Filter $filter)
 {
     $qb = $this->getQueryBuilder();
     foreach ($filter->getAttributes() as $attr) {
         if ($attr->getValue() != '') {
             switch ($attr->getAttribute()) {
                 case 'name':
                     $qb = $this->filterName($qb, $attr->getValue());
                     break;
                 case 'phone':
                     $qb = $this->filterPhone($qb, $attr->getValue());
                     break;
                 case 'email_address':
                     $qb = $this->filterEmailAddress($qb, $attr->getValue());
                     break;
                 case 'member_number':
                     $qb = $this->filterMemberNumber($qb, $attr->getValue());
                     break;
                 case 'min_age':
                     $qb = $this->filterMinAge($qb, $attr->getValue());
                     break;
                 case 'max_age':
                     $qb = $this->filterMaxAge($qb, $attr->getValue());
                     break;
                 case 'gender':
                     $qb = $this->filterGender($qb, $attr->getValue());
                     break;
                 case 'postal_code':
                     $qb = $this->filterPostalCode($qb, $attr->getValue());
                     break;
                 case 'city':
                     $qb = $this->filterCity($qb, $attr->getValue());
                     break;
                 case 'country':
                     $qb = $this->filterCountry($qb, $attr->getValue());
                     break;
                 case 'active':
                     $qb = $this->filterActive($qb, $attr->getValue());
                     break;
                 case 'has_ticket':
                     $qb = $this->filterHasTicket($qb, $attr->getValue());
                     break;
                 case 'subscription_start':
                     $qb = $this->filterSubscriptionStart($qb, $attr->getValue());
                     break;
                 case 'subscription_from':
                     $qb = $this->filterSubscriptionFrom($qb, $attr->getValue());
                     break;
                 case 'subscription_to':
                     $qb = $this->filterSubscriptionTo($qb, $attr->getValue());
                     break;
                 case 'location':
                     $qb = $this->filterLocation($qb, explode(",", $attr->getValue()));
                     break;
             }
         }
     }
     return $qb;
 }
Example #2
0
 public function activateFilter(\Club\UserBundle\Entity\User $user, \Club\UserBundle\Entity\Filter $filter)
 {
     $old_filter = $this->findActive($user);
     $old_filter->setActive(0);
     $this->_em->persist($old_filter);
     $filter->setActive(1);
     $this->_em->persist($filter);
 }
 /**
  * Build the form filter
  */
 private function buildFormFilter(\Club\UserBundle\Entity\Filter $filter)
 {
     $em = $this->getDoctrine()->getManager();
     $form_filter = new \Club\UserBundle\Filter\UserFilter();
     foreach ($filter->getAttributes() as $attribute) {
         $key = $attribute->getAttribute();
         switch ($key) {
             case 'subscription_start':
                 if ($attribute->getValue() != '') {
                     $form_filter->subscription_start = unserialize($attribute->getValue());
                 }
                 break;
             case 'subscription_from':
                 if ($attribute->getValue() != '') {
                     $form_filter->subscription_from = unserialize($attribute->getValue());
                 }
                 break;
             case 'subscription_to':
                 if ($attribute->getValue() != '') {
                     $form_filter->subscription_to = unserialize($attribute->getValue());
                 }
                 break;
             case 'location':
                 $res = new \Doctrine\Common\Collections\ArrayCollection();
                 $locations = $em->getRepository('ClubUserBundle:Location')->getByIds(explode(",", $attribute->getValue()));
                 foreach ($locations as $location) {
                     $res[] = $location;
                 }
                 $form_filter->location = $res;
                 break;
             default:
                 $form_filter->{$key} = $attribute->getValue();
                 break;
         }
     }
     return $form_filter;
 }
Example #4
0
 /**
  * Build the form filter
  */
 private function buildFormFilter(\Club\UserBundle\Entity\Filter $filter)
 {
     $em = $this->getDoctrine()->getEntityManager();
     $form_filter = new \Club\UserBundle\Filter\UserFilter();
     foreach ($filter->getAttributes() as $attribute) {
         switch ($attribute->getAttribute()->getAttributeName()) {
             case 'name':
                 $form_filter->name = $attribute->getValue();
                 break;
             case 'member_number':
                 $form_filter->member_number = $attribute->getValue();
                 break;
             case 'min_age':
                 $form_filter->min_age = $attribute->getValue();
                 break;
             case 'max_age':
                 $form_filter->max_age = $attribute->getValue();
                 break;
             case 'gender':
                 $form_filter->gender = $attribute->getValue();
                 break;
             case 'postal_code':
                 $form_filter->postal_code = $attribute->getValue();
                 break;
             case 'city':
                 $form_filter->city = $attribute->getValue();
                 break;
             case 'country':
                 $form_filter->country = $em->find('ClubUserBundle:Country', $attribute->getValue());
                 break;
             case 'active':
                 $form_filter->active = $attribute->getValue();
                 break;
             case 'has_ticket':
                 $form_filter->has_ticket = $attribute->getValue();
                 break;
             case 'has_subscription':
                 $form_filter->has_subscription = $attribute->getValue();
                 break;
             case 'location':
                 $res = new \Doctrine\Common\Collections\ArrayCollection();
                 $locations = $em->getRepository('ClubUserBundle:Location')->getByIds(explode(",", $attribute->getValue()));
                 foreach ($locations as $location) {
                     $res[] = $location;
                 }
                 $form_filter->location = $res;
                 break;
         }
     }
     return $form_filter;
 }
 public function deleteAttributes(\Club\UserBundle\Entity\Filter $filter)
 {
     return $this->_em->createQueryBuilder()->delete('ClubUserBundle:FilterAttribute', 'fa')->where('fa.filter = :filter')->setParameter('filter', $filter->getId())->getQuery()->getResult();
 }