HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/dvpis2026/dvpis.kaunokolegija.lt/src/Repository/StudentCountProgramPlanRepository.php
<?php

namespace App\Repository;

use Doctrine\ORM\EntityRepository;

/**
 * StudentCountProgramPlanRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class StudentCountProgramPlanRepository extends EntityRepository
{
    public function getAllByHash()
    {
        $results =  $this->getEntityManager()
                        ->createQuery(
                            "SELECT sp 
                                    FROM App:StudentCountProgramPlan sp
                                ORDER BY sp.dataDate ASC"
                        )
                        ->getResult();
        $return = [];
        foreach ($results as $result) {
            $studiesProgram = $result->getStudiesProgram()->getShortName();
            $course = $result->getCourse();
            $return[md5($studiesProgram . "_" . $course)] = $result;
        }

        return $return;
    }

    public function getAllByProgramCourseType()
    {

        $query = $this->createQueryBuilder('spp')
            ->join('spp.studiesProgram', 'sp')
            ->join('sp.department', 'd')
            ->select('spp, sp, d')
            ->addOrderBy('spp.dataDate', 'ASC')
        ;

        $results = $query->getQuery()->getResult();

        $return = [];
        /** @var StudentCountProgramPlan $result */
        foreach ($results as $result) {
            $studiesProgram = $result->getStudiesProgram()->getShortName();
            $course = $result->getCourse();
            $return[$studiesProgram][$course]['NL'] = $result->getCountStudentNl();
            $return[$studiesProgram][$course]['I'] = $result->getCountStudentI();
            $return[$studiesProgram][$course]['Part'] = $result->getCountStudentPart();
            $return[$studiesProgram][$course]['Listener'] = $result->getCountListener();
        }

        return $return;
    }

    public function deleteAll()
    {
        return $this->getEntityManager()
                        ->createQuery(
                            "DELETE App:StudentCountProgramPlan t"
                        )
                        ->execute();
    }
}