Example #1
0
 private function _lagCuplisteFraProver($prover, $klubbId)
 {
     $hd = new HundDatabase();
     $pd = new PersonDatabase();
     $cupliste = array();
     //går gjennom prøvene
     foreach ($prover as $prove) {
         $finnes = false;
         //går gjennom lista over hunder som allerede er i cuplista
         foreach ($cupliste as $cup) {
             if ($prove->hundId == $cup->hundId) {
                 $finnes = true;
             }
         }
         //legger til hunden i cuplista hvis den ikke finnes der fra før
         if (!$finnes) {
             $tmp = new AmfCup();
             $tmp->hundId = $prove->hundId;
             $hund = $hd->hentKunHund($prove->hundId, $klubbId);
             $tmp->hundNavn = $hund['navn'];
             $tmp->tittel = $hund['tittel'];
             if ($hund['eierId'] != '') {
                 $pdres = $pd->hentPerson($hund['eierId'], $klubbId);
                 $tmp->eier = $pdres['navn'];
             }
             if ($tmp->hundNavn != '') {
                 $cupliste[] = $tmp;
             }
         }
     }
     return $cupliste;
 }
Example #2
0
 public function sokArsgjennomsnitt($hund, $ar, $brukerEpost, $brukerPassord, $klubbId)
 {
     if (ValiderBruker::validerBrukerRettighet($this->database, $brukerEpost, $brukerPassord, $klubbId, "lese")) {
         $hd = new HundDatabase();
         $resultat = $hd->sokArsgjennomsnitt($hund, $ar, $klubbId);
         $ret = array();
         foreach ($resultat as $rad) {
             $tmp = array();
             $tmp["hundId"] = $rad["hundId"];
             $tmp["navn"] = $rad["navn"];
             $tmp["hundFarNavn"] = $rad["hundFarNavn"];
             $tmp["hundFarId"] = $rad["hundFarId"];
             $tmp["hundMorNavn"] = $rad["hundMorNavn"];
             $tmp["hundMorId"] = $rad["hundMorId"];
             if ($rad["es"] >> 0) {
                 $tmp["es"] = number_format($rad["es"], 1, ',', '');
             }
             if ($rad["ms"] >> 0) {
                 $tmp["ms"] = number_format($rad["ms"], 1, ',', '');
             }
             if ($rad["vf"] >> 0) {
                 $tmp["vf"] = number_format($rad["vf"], 1, ',', '');
             }
             if ($rad["eso"] >> 0) {
                 $tmp["eso"] = number_format($rad["eso"], 1, ',', '');
             }
             if ($rad["mso"] >> 0) {
                 $tmp["mso"] = number_format($rad["mso"], 1, ',', '');
             }
             if ($rad["ts"] >> 0) {
                 $tmp["ts"] = number_format($rad["ts"], 1, ',', '');
             }
             if ($rad["starter"] >> 0) {
                 $tmp["starter"] = sprintf("%u", $rad["starter"]);
             }
             if ($rad["jl"] >> 0) {
                 $tmp["jl"] = number_format($rad["jl"], 1, ',', '');
             }
             if ($rad["fa"] >> 0) {
                 $tmp["fa"] = number_format($rad["fa"], 1, ',', '');
             }
             if ($rad["st"] >> 0) {
                 $tmp["st"] = number_format($rad["st"], 1, ',', '');
             }
             if ($rad["selv"] >> 0) {
                 $tmp["ss"] = number_format($rad["selv"], 1, ',', '');
             }
             if ($rad["sok"] >> 0) {
                 $tmp["sb"] = number_format($rad["sok"], 1, ',', '');
             }
             if ($rad["rev"] >> 0) {
                 $tmp["rv"] = number_format($rad["rev"], 1, ',', '');
             }
             if ($rad["sam"] >> 0) {
                 $tmp["sa"] = number_format($rad["sam"], 1, ',', '');
             }
             if (sprintf("%u", $rad["bestePl"]) >> 0) {
                 $tmp["bestePl"] = sprintf("%u", $rad["bestePl"]);
             } else {
                 $tmp["bestePl"] = "-";
             }
             $ret[] = $tmp;
         }
         return $ret;
     }
     $feilkode = 1;
     throw new Exception('Du har ikke denne rettigheten', $feilkode);
 }
Example #3
0
 private function hentKullArray($hundId, $klubbId, $aar)
 {
     $hundListe = KullDatabase::hentAarbokAvkom($hundId, $klubbId, $aar, $this->database);
     $avkomListe = array();
     foreach ($hundListe as $tmp) {
         if ($tmp['AARVF'] != "") {
             $tmp['AARVF'] = number_format($tmp['AARVF'], 1, ',', '');
         }
         if ($tmp['AARJAKTL'] != "") {
             $tmp['AARJAKTL'] = number_format($tmp['AARJAKTL'], 1, ',', '');
         }
         if ($tmp['AARFART'] != "") {
             $tmp['AARFART'] = number_format($tmp['AARFART'], 1, ',', '');
         }
         if ($tmp['AARSTIL'] != "") {
             $tmp['AARSTIL'] = number_format($tmp['AARSTIL'], 1, ',', '');
         }
         if ($tmp['AARSELVST'] != "") {
             $tmp['AARSELVST'] = number_format($tmp['AARSELVST'], 1, ',', '');
         }
         if ($tmp['AARSOKBR'] != "") {
             $tmp['AARSOKBR'] = number_format($tmp['AARSOKBR'], 1, ',', '');
         }
         if ($tmp['AARREV'] != "") {
             $tmp['AARREV'] = number_format($tmp['AARREV'], 1, ',', '');
         }
         if ($tmp['AARSAMAR'] != "") {
             $tmp['AARSAMAR'] = number_format($tmp['AARSAMAR'], 1, ',', '');
         }
         if ($tmp['TOTALVF'] != "") {
             $tmp['TOTALVF'] = number_format($tmp['TOTALVF'], 1, ',', '');
         }
         if ($tmp['TOTALJAKTL'] != "") {
             $tmp['TOTALJAKTL'] = number_format($tmp['TOTALJAKTL'], 1, ',', '');
         }
         if ($tmp['TOTALFART'] != "") {
             $tmp['TOTALFART'] = number_format($tmp['TOTALFART'], 1, ',', '');
         }
         if ($tmp['TOTALSTIL'] != "") {
             $tmp['TOTALSTIL'] = number_format($tmp['TOTALSTIL'], 1, ',', '');
         }
         if ($tmp['TOTALSELVST'] != "") {
             $tmp['TOTALSELVST'] = number_format($tmp['TOTALSELVST'], 1, ',', '');
         }
         if ($tmp['TOTALSOKBR'] != "") {
             $tmp['TOTALSOKBR'] = number_format($tmp['TOTALSOKBR'], 1, ',', '');
         }
         if ($tmp['TOTALREV'] != "") {
             $tmp['TOTALREV'] = number_format($tmp['TOTALREV'], 1, ',', '');
         }
         if ($tmp['TOTALSAMAR'] != "") {
             $tmp['TOTALSAMAR'] = number_format($tmp['TOTALSAMAR'], 1, ',', '');
         }
         $total = JaktproveDatabase::hentAarbokJaktproverTotalt($tmp['hundId'], $klubbId, $this->database);
         $tmp['TOTALSTART'] = $total['total'];
         $tmp['aar'] = $aar;
         $avkomFinnes = false;
         for ($i = 0; $i < sizeof($avkomListe); $i++) {
             if ($avkomListe[$i]['kullId'] == $tmp['kullId'] && ($avkomListe[$i]['partnerid'] == $tmp['hundMorId'] || $avkomListe[$i]['partnerid'] == $tmp['hundFarId'])) {
                 $avkomFinnes = true;
                 $avkomListe[$i]['liste'][] = $tmp;
                 $avkomListe[$i]['antallvalper']++;
             }
         }
         if (!$avkomFinnes) {
             $avkom = array();
             if ($hundId == $tmp['hundMorId']) {
                 $avkom['partnernavn'] = $tmp['hundFarNavn'];
                 $avkom['partnertittel'] = $tmp['hundFarTittel'];
                 $avkom['partnerid'] = $tmp['hundFarId'];
                 $avkom['morId'] = $tmp['hundMorId'];
             } else {
                 $avkom['partnernavn'] = $tmp['hundMorNavn'];
                 $avkom['partnertittel'] = $tmp['hundMorTittel'];
                 $avkom['partnerid'] = $tmp['hundMorId'];
                 $avkom['farId'] = $tmp['hundFarId'];
             }
             $avkom['kullfar'] = $tmp['hundFarNavn'];
             $avkom['kullmor'] = $tmp['hundMorNavn'];
             $avkom['fodt'] = Verktoy::konverterDatabaseTilDatDato($tmp['fodt']);
             $avkom['kullId'] = $tmp['kullId'];
             $avkom['liste'] = array();
             $avkom['antallvalper'] = 1;
             $avkom['liste'][] = $tmp;
             $avkomListe[] = $avkom;
         }
     }
     $kullbokstav = "A";
     for ($i = 0; $i < sizeof($avkomListe); $i++) {
         $avkomListe[$i]['kullbokstav'] = $kullbokstav++;
         if (isset($avkomListe[$i]['morId']) && $hundId == $avkomListe[$i]['morId']) {
             $far = HundDatabase::hentAarbokKullHund($avkomListe[$i]['partnerid'], $klubbId, $this->database);
             $mor = HundDatabase::hentAarbokKullHund($hundId, $klubbId, $this->database);
         } else {
             $far = HundDatabase::hentAarbokKullHund($hundId, $klubbId, $this->database);
             $mor = HundDatabase::hentAarbokKullHund($avkomListe[$i]['partnerid'], $klubbId, $this->database);
         }
         $avkomListe[$i]['kullfarfar'] = $far['hundFarNavn'];
         $avkomListe[$i]['kullfarmor'] = $far['hundMorNavn'];
         $avkomListe[$i]['kullmormor'] = $mor['hundFarNavn'];
         $avkomListe[$i]['kullmorfar'] = $mor['hundMorNavn'];
         $kull = null;
         if ($avkomListe[$i]['kullId'] != null) {
             $kull = KullDatabase::hentAarbokKullOppdretter($avkomListe[$i]['kullId'], $klubbId, $this->database);
         }
         if ($kull != null) {
             $avkomListe[$i]['OPPDRETTERNAVN'] = $kull['OPPDRETTERNAVN'];
             $avkomListe[$i]['OPPDRETTERADRESSE'] = $kull['OPPDRETTERADRESSE'];
             $avkomListe[$i]['OPPDRETTERPOSTNR'] = $kull['OPPDRETTERPOSTNR'];
             $avkomListe[$i]['OPPDRETTERSTED'] = $kull['OPPDRETTERSTED'];
             $avkomListe[$i]['OPPDRETTERTLF'] = $kull['OPPDRETTERTLF'];
         }
     }
     return $avkomListe;
 }