Exemplo n.º 1
0
 /**
  * Find similar crosses
  *
  * @param CrossVial $cross
  */
 public function findSimilar(CrossVial $cross)
 {
     $filter = new VialFilter();
     $filter->setAccess('shared');
     $filter->setFilter('all');
     $startDate = clone $cross->getSetupDate();
     $stopDate = clone $cross->getSetupDate();
     $startDate->sub(new \DateInterval('P2W'));
     $stopDate->add(new \DateInterval('P2W'));
     $owner = $this->getObjectManager()->getOwner($cross);
     $qb = $this->getListQueryBuilder($filter);
     $qb->andWhere('e.maleName = :male_name')->andWhere('e.virginName = :virgin_name')->andWhere('e.setupDate > :start_date')->andWhere('e.setupDate <= :stop_date')->orderBy('e.setupDate', 'ASC')->addOrderBy('e.id', 'ASC')->setParameter('male_name', $cross->getUnformattedMaleName())->setParameter('virgin_name', $cross->getUnformattedVirginName())->setParameter('start_date', $startDate->format('Y-m-d'))->setParameter('stop_date', $stopDate->format('Y-m-d'));
     return $this->getAclFilter()->apply($qb, $filter->getPermissions(), $owner)->getResult();
 }
Exemplo n.º 2
0
 /**
  * Find similar injections
  *
  * @param InjectionVial $injection
  */
 public function findSimilar(InjectionVial $injection)
 {
     $filter = new VialFilter();
     $filter->setAccess('shared');
     $filter->setFilter('all');
     $startDate = clone $injection->getSetupDate();
     $stopDate = clone $injection->getSetupDate();
     $startDate->sub(new \DateInterval('P2W'));
     $stopDate->add(new \DateInterval('P2W'));
     $owner = $this->getObjectManager()->getOwner($injection);
     $qb = $this->getListQueryBuilder($filter);
     $qb->andWhere('e.injectionType = :injection_type')->andWhere('e.constructName = :construct_name')->andWhere('e.targetStock = :target_stock')->andWhere('e.setupDate > :start_date')->andWhere('e.setupDate <= :stop_date')->orderBy('e.setupDate', 'ASC')->addOrderBy('e.id', 'ASC')->setParameter('injection_type', $injection->getInjectionType())->setParameter('construct_name', $injection->getConstructName())->setParameter('target_stock', $injection->getTargetStock())->setParameter('start_date', $startDate->format('Y-m-d'))->setParameter('stop_date', $stopDate->format('Y-m-d'));
     return $this->getAclFilter()->apply($qb, $filter->getPermissions(), $owner)->getResult();
 }