File: /home/undanet/www/PortalEmpleo/src/Repository/DBTribunalAprobacionExamenRepository.php
<?php
namespace PortalEmpleo\Repository;
require __DIR__ . '/../../vendor/autoload.php';
require_once __DIR__ . '/../../bootstrap.php';
use Dotenv\Dotenv;
use PortalEmpleo\Entity\DboCandidato;
use PortalEmpleo\Entity\DboConvocatoria;
use PortalEmpleo\Entity\DboConvocatoriamerito;
use PortalEmpleo\Entity\DboConvocatoriarequisito;
use PortalEmpleo\Entity\DboRol;
use PortalEmpleo\Entity\DboTribunalconvocatoria;
use PortalEmpleo\Entity\DboTribunalvaloracion;
use PortalEmpleo\Entity\DboTribunalAprobacionRequisito;
use PortalEmpleo\Entity\DboTribunalAprobacionExamen;
use PortalEmpleo\Entity\WpUsers;
use PortalEmpleo\Entity\WpUsermeta;
use Doctrine\Common\Collections\Criteria;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class DBTribunalAprobacionExamenRepository extends AbstractController
{
private $dotenv;
private $entityManager;
public function __construct()
{
}
private function loadEnv()
{
try{
$dotenv = Dotenv::createImmutable(__DIR__ . "/../../");
$dotenv->load();
$em = getEntityManager();
return $em;
}
catch (Exception $ex){
echo $exception->getMessage();
return null;
}
}
private function loadEnvWP()
{
try{
$dotenv = Dotenv::createImmutable(__DIR__ . "/../../");
$dotenv->load();
$em = getEntityManagerWP();
return $em;
}
catch (Exception $ex){
echo $exception->getMessage();
return null;
}
}
public function obtenerAprobacionesPorConvocatoria($lang, $codigoconvocatoria)
{
try
{
$entityManager = $this->loadEnv();
$ltrbvlc = $entityManager->getRepository(DboTribunalAprobacionExamen::class)
->createQueryBuilder('c')
->where('c.codigoconvocatoria = :cvt')
->andwhere('c.baja = false')
->setParameter('cvt', $codigoconvocatoria)
->addOrderBy('c.idtribunalaprobacionexamen', 'ASC')
->getQuery()
->execute();
if (!$ltrbvlc) {
return ;
}
$entityManager->getConnection()->close();
return $ltrbvlc;
}
catch (Exception $ex)
{
echo $exception->getMessage();
}
}
public function insertarAprobaciones($tribunalaprobacionexamen)
{
try
{
if(is_object($tribunalaprobacionexamen))
{
$entityManager = $this->loadEnv();
$trbVlc = new DboTribunalAprobacionExamen();
if( $tribunalaprobacionexamen->getIdTribunalAprobacionExamen() != 0 )
$trbVlc = $trbVlc->setIdTribunalAprobacionExamen( $tribunalaprobacionexamen->getIdTribunalAprobacionExamen() );
$trbVlc = $trbVlc->setFecha($tribunalaprobacionexamen->getFecha());
$trbVlc->setEstaAprobado($tribunalaprobacionexamen->getEstaAprobado());
$trbVlc = $trbVlc->setBaja($tribunalaprobacionexamen->getBaja());
$cvt = $entityManager->getRepository(DboConvocatoria::class)->find(($tribunalaprobacionexamen->getCodigoconvocatoria())->getIdconvocatoria());
$entityManager->clear();
if (!$cvt) {
throw $this->createNotFoundException(
'No se encuentra la convocatoria con el id '. ($tribunalaprobacionexamen->getCodigoconvocatoria())->getIdconvocatoria()
);
}
$trbVlc = $trbVlc->setCodigoconvocatoria2($cvt);
$trbcvt = $entityManager->getRepository(DboTribunalconvocatoria::class)->find(($tribunalaprobacionexamen->getCodigotribunalconvocatoria())->getIdtribunalconvocatoria());
$entityManager->clear();
if (!$trbcvt) {
throw $this->createNotFoundException(
'No se encuentra el tribunalconvocatoria con el id '. ($tribunalaprobacionexamen->getCodigotribunalconvocatoria())->getIdtribunalconvocatoria()
);
}
$trbVlc = $trbVlc->setCodigotribunalconvocatoria2($trbcvt);
$entityManager->merge($trbVlc);
$entityManager->flush();
$entityManager->clear();
$entityManager->getConnection()->close();
return $trbVlc;
}
}
catch (Exception $ex)
{
echo $exception->getMessage();
}
}
}
?>