<?php
namespace App\Repository;
use App\Entity\Conversation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Conversation>
*
* @method Conversation|null find($id, $lockMode = null, $lockVersion = null)
* @method Conversation|null findOneBy(array $criteria, array $orderBy = null)
* @method Conversation[] findAll()
* @method Conversation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ConversationRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Conversation::class);
}
public function add(Conversation $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(Conversation $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function getControlConversation($client)
{
$avecTeleconseil = ' ';
if (strlen(trim($teleconseiller)) > 0) $avecTeleconseil = " and H.id_user ='$teleconseiller'";
$avecDate = ' ';
if (strlen($date_debutct) > 0 && ($date_finct) > 0) $avecDate = "and H.created_at BETWEEN '$date_debutct' AND '$date_finct'";
$RQ =$this->_em->createQueryBuilder();
$RQ->select('P.libelle as libelle','COALESCE(Count(H.id),0) as Nbre')
->from(HistoriqueAppel::class, 'H')
->innerJoin('H.id_profession', 'P')
->where("H.statut =1
$avecTeleconseil
$avecDate
")
->groupBy('P.id');
return $RQ->getQuery()
->getResult();
}
// /**
// * @return Conversation[] Returns an array of Conversation objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('c.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Conversation
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}