Esempio n. 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;
 }
Esempio n. 2
0
 public function hentPerson($personId, $brukerEpost, $brukerPassord, $klubbId)
 {
     //    	if(ValiderBruker::validerBrukerRettighet($this->database, $brukerEpost, $brukerPassord, $klubbId, "Lese"))
     //		{
     $pd = new PersonDatabase();
     $rad = $pd->hentPerson($personId, $klubbId);
     $tmp = new AmfPerson();
     $tmp->personId = $rad["personId"];
     $tmp->navn = $rad["navn"];
     return $tmp;
     //		}
     //		$feilkode = 1;
     //		throw(new Exception('Du har ikke denne rettigheten', $feilkode));
 }
Esempio n. 3
0
 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);
 }