<?php
  function afficherFormModifInfosCompte()
  {
    global $connexion;
    global $txt;

    $html = '';

    $html .= '<ol class="breadcrumb">';
			$html .= '<li><a href="index.php">Menu</a></li>';
      $html .= '<li class="active">' . $txt['myAccount'] . '</li>';
		$html .= '</ol>';

		$requete = "SELECT * FROM isoactif_t_usager_ecole, t_liste_ecoles_08,t_arse WHERE u_e_id_fk = ID AND a_id_fk = a_id AND u_id = " . escapeValue($_SESSION['usagerEcoleIsoActif']->u_id);
		if(!$resultat = $connexion->query($requete)){ die('There was an error running the query : Get all school info');}
		$ligne = $resultat->fetch_assoc();

	  $html .= '<form name="frmEditAccount" id="frmEditAccount" action="php/update-account.php" method="post">';

			$html .= '<strong style="font-size:22px;">' . $ligne['NOM'] . '</strong>';

			$html .= '<br style="clear:both;" />';
			$html .= '<br style="clear:both;" />';

			// ID de l'école (hidden)
			$html .= '<input type="hidden" name="idEcole" value="' . $ligne['ID'] . '">';

		  // INSTANCE RÉGIONALE RSEQ
			$html .= '<strong>' . $txt['RSEQregion'] . ' : </strong> ' . $ligne['a_nomComplet'];

      $html .= '<br style="clear:both;" />';
			$html .= '<br style="clear:both;" />';

      // INSTANCE RÉGIONALE RSEQ
      $html .= '<strong>' . $txt['sector'] . ' : </strong> ' . $ligne['PRISEC'];

      // Nb tudiants garçons
      $html .= '<div class="form-group">';
        $html .= '<label for="nbEtudiantsGarcons">' . $txt['numStudentsBoys'] . '</label>';
        $html .= '<input class="form-control inputNumber" type="text" name="nbEtudiantsGarcons" style="max-width:100px;" value="' . $ligne['u_e_nb_etud_g'] . '" required>';
      $html .= '</div>';

      // Nb tudiants filles
      $html .= '<div class="form-group">';
        $html .= '<label for="nbEtudiantsFilles">' . $txt['numStudentsGirls'] . '</label>';
        $html .= '<input class="form-control inputNumber" type="text" name="nbEtudiantsFilles" style="max-width:100px;" value="' . $ligne['u_e_nb_etud_f'] . '" required>';
      $html .= '</div>';


      ##### INFORMATIONS PERSONNELLES ##########################################
			$html .= '<p class="top-buffer-20"><strong style="font-size:18px;">' . $txt['personalInfo'] . '</strong></p>';

      // Prénom
      $html .= '<div class="form-group">';
        $html .= '<label for="prenom">' . $txt['firstName'] . '</label>';
        $html .= '<input class="form-control" type="text" name="prenom" style="max-width:400px;" value="' . $ligne['u_prenom'] . '" required>';
      $html .= '</div>';

      // Nom
      $html .= '<div class="form-group">';
        $html .= '<label for="prenom">' . $txt['lastName'] . '</label>';
        $html .= '<input class="form-control" type="text" name="nom" style="max-width:400px;" value="' . $ligne['u_nom'] . '" required>';
      $html .= '</div>';

      // Fonction
      $html .= '<div class="form-group">';
        $html .= '<label for="fonction">' . $txt['function'] . '</label>';
        $html .= '<input class="form-control" type="text" name="fonction" style="max-width:400px;" value="' . $ligne['u_fct'] . '" required>';
      $html .= '</div>';

      // Courriel
      $html .= '<div class="form-group">';
        $html .= '<label for="courriel">' . $txt['email'] . '</label>';
        $html .= '<input class="form-control" type="email" name="courriel" id="courriel" style="max-width:400px;" value="' . $ligne['u_courriel'] . '" required>';
      $html .= '</div>';

      // Courriel (Confirm)
      $html .= '<div class="form-group">';
        $html .= '<label for="courriel">' . $txt['emailConfirm'] . '</label>';
        $html .= '<input class="form-control" type="email" data-match="#courriel" data-match-error="Ne correspond pas" name="courrielConfirm" style="max-width:400px;" value="' . $ligne['u_courriel'] . '" required>';
        $html .= '<div class="help-block with-errors"></div>';
      $html .= '</div>';

      // Tél. travail
      $html .= '<div class="form-group">';
        $html .= '<label for="fonction">' . $txt['phoneWork'] . '</label>';
        $html .= '<input class="form-control" type="text" name="telBur" style="max-width:400px;" value="' . $ligne['u_tel_travail'] . '" required>';
      $html .= '</div>';

      // Tél. résidence
      $html .= '<div class="form-group">';
        $html .= '<label for="fonction">' . $txt['phoneHome'] . '</label>';
        $html .= '<input class="form-control" type="text" name="telRes" style="max-width:400px;" value="' . $ligne['u_tel_residence'] . '">';
      $html .= '</div>';

      // Tél. mobile
      $html .= '<div class="form-group">';
        $html .= '<label for="fonction">' . $txt['phoneMobile'] . '</label>';
        $html .= '<input class="form-control" type="text" name="telCell" style="max-width:400px;" value="' . $ligne['u_tel_cell'] . '">';
      $html .= '</div>';


      $html .= '<input type="hidden" name="currentLogin" value="' . $ligne['u_login'] . '">';

      // Login
      $html .= '<div class="form-group" id="loginFormGroup">';
        $html .= '<label for="fonction">' . $txt['username'] . '</label>';
        $html .= '<input class="form-control" data-minlength="7" type="text" name="login" id="login" style="max-width:400px;" value="' . $ligne['u_login'] . '" required>';
        $html .= '<div class="help-block">' . $txt['pwdMinLength'] . '</div>';
        $html .= '<span id="warningUsernameTaken" class="text-warning" style="display:none;"> <span class="glyphicon glyphicon-exclamation-sign"></span>' . $txt['loginTaken'] . '</span>';
      $html .= '</div>';

      // Pwd
      $html .= '<div class="form-group">';
        $html .= '<label for="fonction">' . $txt['password'] . '</label>';
        $html .= '<input class="form-control" data-minlength="7" type="password" name="password" id="password" value="' . $ligne['u_pwd'] . '" style="max-width:400px;" required>';
        $html .= '<div class="help-block">' . $txt['pwdMinLength'] . '</div>';
      $html .= '</div>';

      // Pwd (Confirm)
      $html .= '<div class="form-group">';
        $html .= '<label for="fonction">' . $txt['confirmPassword'] . '</label>';
        $html .= '<input class="form-control" type="password" name="passwordConfirm" value="' . $ligne['u_pwd'] . '" data-match="#password" data-match-error="' . $txt['doesNotMatch'] . '" style="max-width:400px;" required>';
        $html .= '<div class="help-block with-errors"></div>';
      $html .= '</div>';

			// SUBMIT
      $html .= '<div class="text-center top-buffer-20"><button type="button" id="submitBtn" class="btn btn-primary" onclick="validateEditAccountForm();">' . $txt['submit'] . '</button></div>';
      //$html .= '<div class="text-center top-buffer-20"><button type="submit" id="submitBtn" class="btn btn-primary">Soumettre</button></div>';

		$html .= '</form>';

    //$html .= '<form role="form" name="form-create-account" id="form-create-account" method="post" action="php/create-account.php">';
    //$html .= '</form>';

    $html .= '';

    return $html;
  }
?>
