<?php
class UE {
	public $nom;
	public $id;
	public $codeue;
	public $semestre;
	public $nbrDeCredit;
	public $ecus;
	public $type_ue;
	public $insertion;
	public function __construct($ue_array) {
		$this->nom = $ue_array['intituleUnite'];
		if ($this->nom == '') {
			$this->nom = 'Pas encore de Nom';
		}

		$this->id 			= $ue_array['idUE'];
		$this->codeue 		= $ue_array['code_unite'];
		$this->semestre 	= $ue_array['semestre'];
		$this->nbrDeCredit 	= $ue_array['credit'];
		$this->type_ue 		= $ue_array['type_ue'];
		$this->insertion 	= $ue_array['insertion'];
		$this->ecus = array();
	}
	public function setEcus($ecus) {
		foreach ($ecus as $key => $ecu) {
			$Ecu = new Ecu($ecu);
			$this->ecus[] = $Ecu;
		}
	}

	public function getCode() {
		return $this->codeue;
	}
	public function getId() {
		return $this->id;
	}
	public function getEcus() {
		return $this->ecus;
	}
	public function getNbrEcus() {
		return count($this->ecus);
	}
	public function getNbrEcusTraite() {
		$i = 0;
		foreach ($this->ecus as $key => $ecu) {
			if($ecu->insertion == 'NO') {
				$i++;
			}
			return $i;
		}
	}
}
class Ecu {
	public $nom;
	public $id;
	public $codeec;
	public $codue;
	public $insertion;
	public function __construct($ecu_array) {
		$this->nom 			= $ecu_array['intituleEcu'];
		$this->id 			= $ecu_array['idEC'];
		$this->codeec 		= $ecu_array['code_ecu'];
		$this->codue 		= $ecu_array['code_unite'];
		$this->insertion 	= $ecu_array['insertion'];
	}
}
