예제 #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();
 }
예제 #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();
 }
예제 #3
0
 protected function getVialStatistics($class)
 {
     $om = $this->getObjectManager();
     $repository = $om->getRepository($class);
     $filter = new VialFilter(null, $this->getSecurityContext());
     $filter->setAccess('shared');
     $vials = $repository->getList($filter);
     $stats = array();
     $stats['count'] = count($vials);
     $filter->setFilter('forgot');
     $stats['forgot'] = $repository->getListCount($filter);
     $filter->setFilter('due');
     $stats['due'] = $repository->getListCount($filter);
     $filter->setFilter('overdue');
     $stats['overdue'] = $repository->getListCount($filter);
     return $stats;
 }
예제 #4
0
 /**
  * Edit entity
  *
  * @Route("/edit/{id}")
  * @Template()
  *
  * @param  mixed                                     $id
  * @return Symfony\Component\HttpFoundation\Response
  */
 public function editAction($id)
 {
     $response = parent::editAction($id);
     if (is_array($response)) {
         $om = $this->getObjectManager();
         $filter = new VialFilter(null, $this->getSecurityContext());
         $filter->setAccess('insecure');
         $stock = isset($response['form']) ? $response['form']->vars['value'] : $this->getEntity($id);
         $used = $om->getRepository('VIB\\FliesBundle\\Entity\\StockVial')->getUsedVialCountByStock($stock, $filter);
         $canDelete = $this->getSecurityContext()->isGranted('ROLE_ADMIN') || $used == 0;
         return array_merge($response, array('can_delete' => $canDelete));
     }
     return $response;
 }