public function hentAvkom($hundId, $brukerEpost, $brukerPassord, $klubbId) { if (ValiderBruker::validerBrukerRettighet($this->database, $brukerEpost, $brukerPassord, $klubbId, "lese")) { $avkomListe = array(); $kd = new KullDatabase(); $pd = new PersonDatabase(); $hundListe = $kd->hentAvkom($hundId, $klubbId); $avkomHundListe = array(); foreach ($hundListe as $rad) { $tmp = new AmfHund(); $tmp->hundId = $rad["hundId"]; $tmp->tittel = $rad["tittel"]; $tmp->navn = $rad["navn"]; $tmp->bilde = ""; $tmp->morId = $rad["hundMorId"]; $tmp->morNavn = $rad["hundMorNavn"]; $tmp->farId = $rad["hundFarId"]; $tmp->farNavn = $rad["hundFarNavn"]; $tmp->eierId = $rad["eierId"]; if ($rad["eierId"] != null) { $pdres = $pd->hentPerson($rad["eierId"], $klubbId); $tmp->eier = $pdres["navn"]; } $tmp->kjonn = $rad["kjonn"]; $tmp->rase = $rad["raseId"]; $tmp->kullId = $rad["kullId"]; $tmp->idNr = $rad["idNr"]; $tmp->hd = $rad["hoftesykdom"]; if ($rad["start"] >> 0) { $tmp->start = sprintf("%u", $rad["start"]); } if ($rad["jl"] >> 0) { $tmp->jl = number_format($rad["jl"], 1, ',', ''); } if ($rad["selv"] >> 0) { $tmp->selv = number_format($rad["selv"], 1, ',', ''); } if ($rad["sok"] >> 0) { $tmp->sok = number_format($rad["sok"], 1, ',', ''); } if ($rad["vf"] >> 0) { $tmp->vf = number_format($rad["vf"], 1, ',', ''); } if ($rad["rev"] >> 0) { $tmp->rev = number_format($rad["rev"], 1, ',', ''); } if ($rad["sam"] >> 0) { $tmp->sam = number_format($rad["sam"], 1, ',', ''); } if (sprintf("%u", $rad["bestPlUk"]) >> 0 && sprintf("%u", $rad["bestPlUk"]) << sprintf("%u", $rad["bestPlAk"])) { $tmp->bestPl = sprintf("%u", $rad["bestPlUk"]); // . ". UK"; } else { if (sprintf("%u", $rad["bestPlAk"]) >> 0) { $tmp->bestPl = sprintf("%u", $rad["bestPlAk"]) . ". AK"; } else { $tmp->bestPl = "-"; } } $avkomFinnes = false; foreach ($avkomListe as $avkom) { if ($avkom->kullId == $tmp->kullId && ($avkom->medId == $tmp->morId || $avkom->medId == $tmp->farId)) { $avkomFinnes = true; $avkom->liste[] = $tmp; } } if (!$avkomFinnes) { $avkom = new AmfAvkom(); if ($hundId == $tmp->morId) { $avkom->med = $tmp->farNavn; $avkom->medId = $tmp->farId; } else { $avkom->med = $tmp->morNavn; $avkom->medId = $tmp->morId; } $avkom->kullId = $tmp->kullId; $avkom->liste = array(); $avkom->liste[] = $tmp; $avkomListe[] = $avkom; } } return $avkomListe; } $feilkode = 1; throw new Exception('Du har ikke denne rettigheten', $feilkode); }
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; }