diff options
author | devega <miguel.vega@sic.uhu.es> | 2020-03-24 12:36:46 +0100 |
---|---|---|
committer | devega <miguel.vega@sic.uhu.es> | 2020-03-24 12:36:46 +0100 |
commit | 7a51e7aeffd72798fcd8cfaa1f27535b5e959b07 (patch) | |
tree | dd19baeca029deaaa6b356bb4884bf9d93728250 /admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Repository/ClientRepository.php | |
parent | aafce73629d6b5f5d0a055e109d6112a4bccbb14 (diff) |
Updated Symfony 3.x to 4.xwebconsole3
- Reorganizado los Repositorios de Symfony
- Registrado los commandos como Servicio
- Actualizado la configuraiĆ³n de Doctrine
- Modificado el fichero update e installer.
Diffstat (limited to 'admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Repository/ClientRepository.php')
-rw-r--r-- | admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Repository/ClientRepository.php | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Repository/ClientRepository.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Repository/ClientRepository.php new file mode 100644 index 00000000..2e4d2c10 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Repository/ClientRepository.php @@ -0,0 +1,99 @@ +<?php + +/* + * This file is part of the Opengnsys Project package. + * + * Created by Miguel Angel de Vega Alcantara on 01/10/18. <miguelangel.devega@sic.uhu.es> + * Copyright (c) 2015 Opengnsys. All rights reserved. + * + */ + +namespace Opengnsys\ServerBundle\Repository; + +use Opengnsys\CoreBundle\Repository\BaseRepository; + +/** + * ClientRepository + * + * This class was generated by the Doctrine ORM. Add your own custom + * repository methods below. + */ +class ClientRepository extends BaseRepository +{ + + public function searchStatus($clients , $ou){ + $qb = $this->createQueryBuilder('o'); + + $qb->select('o.id, o.status'); + + if($ou){ + $qb->andWhere("o.organizationalUnit = :organizationalUnit")->setParameter("organizationalUnit", $ou); + } + + if($clients){ + $qb->andWhere("o.id in (:clients)")->setParameter("clients", $clients); + } + + try { + $objects = $qb->getQuery()->getScalarResult(); + } catch (NoResultException $e) { + $message = sprintf('Unable to find an objects'); + throw new NotFoundHttpException($message, null, 0, $e); + } + return $objects; + } + + public function findByObservable($term = "", $limit = null, $offset = null, $ordered = array(), $selects = array(), $searchs = array(), $matching = array()) + { + $qb = $this->createQueryBuilder('o'); + + if(count($selects) > 0){ + $qb = $this->createSelect($qb, $selects); + }else{ + $qb->select("DISTINCT o.createdAt, o.updatedAt, o.notes, o.name, o.serialno, o.netiface, o.netdriver, o.mac, o.ip, o.status, o.cache, o.idproautoexec, o.oglive, o.id"); + } + + if($term != ""){ + if(count($searchs) > 0){ + $qb = $this->createSearch($qb, $term, $searchs); + }else{ + $qb->andWhere("o.createdAt LIKE :term OR o.updatedAt LIKE :term OR o.notes LIKE :term OR o.name LIKE :term OR o.serialno LIKE :term OR o.netiface LIKE :term OR o.netdriver LIKE :term OR o.mac LIKE :term OR o.ip LIKE :term OR o.status LIKE :term OR o.cache LIKE :term OR o.idproautoexec LIKE :term OR o.oglive LIKE :term OR o.id LIKE :term ")->setParameter('term', '%' . $term . '%'); + } + } + + $qb = $this->createMaching($qb, $matching); + + $qb = $this->createOrdered($qb, $ordered); + + if($limit != null){ + $qb->setMaxResults($limit); + } + + if($offset){ + $qb->setFirstResult($offset); + } + + $entities = $qb->getQuery()->getScalarResult(); + return $entities; + } + + public function countFiltered($term = "", $searchs = array(), $matching = array()) + { + $qb = $this->createQueryBuilder('o'); + + $qb->select("count(DISTINCT o.id)"); + + if($term != ""){ + if(count($searchs) > 0){ + $qb = $this->createSearch($qb, $term, $searchs); + }else{ + $qb->andWhere("o.createdAt LIKE :term OR o.updatedAt LIKE :term OR o.notes LIKE :term OR o.name LIKE :term OR o.serialno LIKE :term OR o.netiface LIKE :term OR o.netdriver LIKE :term OR o.mac LIKE :term OR o.ip LIKE :term OR o.status LIKE :term OR o.cache LIKE :term OR o.idproautoexec LIKE :term OR o.oglive LIKE :term OR o.id LIKE :term ")->setParameter('term', '%' . $term . '%'); + } + } + + $qb = $this->createMaching($qb, $matching); + + $count = $qb->getQuery()->getSingleScalarResult(); + return $count; + } +} |