public function getPrivilegesRolesNgAction()
 {
     $em = $this->getDoctrine()->getManager();
     $response = new Response(json_encode(array("result" => Role::getPrivilegesRoles($em, true))));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
Ejemplo n.º 2
0
 private function createTariffPrices($em, $parameters)
 {
     $clientRoles = Role::getClientRoles($em);
     foreach ($clientRoles as $role) {
         $price = $this->calculatePrice($em, $role, $parameters->services);
         $tariffPrice = new TariffPrice();
         $tariffPrice->setTariffid($this->getId());
         $tariffPrice->setTariff($this);
         $tariffPrice->setRoleid($role->getId());
         $tariffPrice->setRole($role);
         $tariffPrice->setValue($price);
         $em->persist($tariffPrice);
         $em->flush();
     }
 }
Ejemplo n.º 3
0
 public static function getWorkforce($em, $parameters, $inArray = false)
 {
     $workforceRoles = Role::getWorkforceRoles($em);
     $workforceRolesIds = array_map(function ($role) {
         return $role->getId();
     }, $workforceRoles);
     $qb = $em->getRepository("RenovateMainBundle:User")->createQueryBuilder('u');
     $qb->select('u')->join("u.roles", "r")->where($qb->expr()->in('r.id', $workforceRolesIds))->addOrderBy('u.registered', 'DESC');
     if (isset($parameters['offset']) && isset($parameters['limit'])) {
         $qb->setFirstResult($parameters['offset'])->setMaxResults($parameters['limit']);
     }
     if (isset($parameters['search'])) {
         $qb->where($qb->expr()->orX($qb->expr()->like('u.username', $qb->expr()->literal('%' . $parameters['search'] . '%')), $qb->expr()->like('u.name', $qb->expr()->literal('%' . $parameters['search'] . '%')), $qb->expr()->like('u.surname', $qb->expr()->literal('%' . $parameters['search'] . '%')), $qb->expr()->like('u.patronymic', $qb->expr()->literal('%' . $parameters['search'] . '%')), $qb->expr()->like('u.email', $qb->expr()->literal('%' . $parameters['search'] . '%')), $qb->expr()->like('u.mobilephone', $qb->expr()->literal('%' . $parameters['search'] . '%')), $qb->expr()->like('u.address', $qb->expr()->literal('%' . $parameters['search'] . '%')), $qb->expr()->like('u.adminUnit', $qb->expr()->literal('%' . $parameters['search'] . '%')), $qb->expr()->like('u.owner', $qb->expr()->literal('%' . $parameters['search'] . '%'))));
     }
     $paginator = new Paginator($qb->getQuery(), $fetchJoinCollection = true);
     $c = count($paginator);
     $result['total'] = $c;
     $result['result'] = [];
     if ($inArray) {
         foreach ($paginator as $item) {
             $result['result'][] = $item->getInArray();
         }
     }
     return $result;
 }