<commit_before><?php

namespace AppBundle\Controller;

use AppBundle\Entity\Club;
use AppBundle\Entity\Event;
use AppBundle\Entity\Race;
use AppBundle\Entity\RaceSection;
use AppBundle\Entity\Registration;
use AppBundle\Repository\BillingRepository;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class BillingController extends Controller
{
    /**
     * Lists all clubs that need to pay in this event.
     *
     * @Route("/event/{event}/billing", name="billing_index")
     * @Method("GET")
     */
    public function indexAction(Event $event)
    {
        $em = $this->getDoctrine()->getManager();
        /** @var RaceRepository $raceRepo */
        $raceRepo = $em->getRepository('AppBundle:Race');
        $races = $raceRepo->getAllRacesThatHaveRegistrations($event->getId());
        // create a list of all clubs
        $clubs = array();
        /** @var Race $race */
        foreach ($races as $race) {
            /** @var RaceSection $section */
            foreach($race->getSections() as $section) {
                /** @var Registration $registration */
                foreach($section->getRegistrations() as $registration) {
                    $club = $registration->getTeam()->getClub();
                    if (!in_array($club, $clubs)) {
                        $clubs[] = $club;
                    }
                }
            }
        }
        /** @var BillingRepository $billingRepo */
        $billingRepo = $em->getRepository('AppBundle:Billing');

        return $this->render('billing/index.html.twig', array(
            'clubs' => $clubs,
            'event' => $event,
            'repo' => $billingRepo,
        ));
    }

    /**
     * Lists all races and payment amounts for a specific club.
     *
     * @Route("/event/{event}/billing/{club}", name="billing_show")
     * @Method("GET")
     */
    public function showAction(Event $event, Club $club)
    {
        $em = $this->getDoctrine()->getManager();
        /** @var RaceRepository $raceRepo */
        $raceRepo = $em->getRepository('AppBundle:Race');
        // $paid = $repo->findBy(array('event' => $event->getId(), 'club' => $club->getId()));

        $races = $raceRepo->getAllRacesThatHaveRegistrations($event->getId());
        $billingPositions = array();
        $total = 0.0;
        /** @var Race $race */
        foreach ($races as $race) {
            $price = $race->getPricePerStarter();
            /** @var RaceSection $section */
            foreach($race->getSections() as $section) {
                /** @var Registration $registration */
                foreach($section->getRegistrations() as $registration) {<commit_msg>price per starter is stored as string<commit_after><?php

namespace AppBundle\Controller;

use AppBundle\Entity\Club;
use AppBundle\Entity\Event;
use AppBundle\Entity\Race;
use AppBundle\Entity\RaceSection;
use AppBundle\Entity\Registration;
use AppBundle\Repository\BillingRepository;
use AppBundle\Repository\RaceRepository;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class BillingController extends Controller
{
    /**
     * Lists all clubs that need to pay in this event.
     *
     * @Route("/event/{event}/billing", name="billing_index")
     * @Method("GET")
     */
    public function indexAction(Event $event)
    {
        $em = $this->getDoctrine()->getManager();
        /** @var RaceRepository $raceRepo */
        $raceRepo = $em->getRepository('AppBundle:Race');
        $races = $raceRepo->getAllRacesThatHaveRegistrations($event->getId());
        // create a list of all clubs
        $clubs = array();
        /** @var Race $race */
        foreach ($races as $race) {
            /** @var RaceSection $section */
            foreach($race->getSections() as $section) {
                /** @var Registration $registration */
                foreach($section->getRegistrations() as $registration) {
                    $club = $registration->getTeam()->getClub();
                    if (!in_array($club, $clubs)) {
                        $clubs[] = $club;
                    }
                }
            }
        }
        /** @var BillingRepository $billingRepo */
        $billingRepo = $em->getRepository('AppBundle:Billing');

        return $this->render('billing/index.html.twig', array(
            'clubs' => $clubs,
            'event' => $event,
            'repo' => $billingRepo,
        ));
    }

    /**
     * Lists all races and payment amounts for a specific club.
     *
     * @Route("/event/{event}/billing/{club}", name="billing_show")
     * @Method("GET")
     */
    public function showAction(Event $event, Club $club)
    {
        $em = $this->getDoctrine()->getManager();
        /** @var RaceRepository $raceRepo */
        $raceRepo = $em->getRepository('AppBundle:Race');
        // $paid = $repo->findBy(array('event' => $event->getId(), 'club' => $club->getId()));

        $races = $raceRepo->getAllRacesThatHaveRegistrations($event->getId());
        $billingPositions = array();
        $total = 0.0;

        /** @var Race $race */
        foreach ($races as $race) {
            $priceString = $race->getPricePerStarter();
            $price = floatval(preg_replace("/[^0-9.]/", "", preg_replace("/,/", ".", $priceString)));
            /** @var RaceSection $section */
            foreach($race->getSections() as $section) {
                /** @var Registration $registration */
                foreach($section->getRegistrations() as $registration) {
{'fraction_non_alphanumeric': 0.15255399382927665, 'fraction_numerical': 0.0010284538909838875, 'mean_word_length': 2.3728323699421967, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4661230', 'n_tokens_mistral': 1686, 'n_tokens_neox': 1640, 'n_words': 330}