}
        if ($res == -4) {
            $_error = 2;
            $action = "create";
        }
    }
} elseif (GETPOST("action") == 'maj') {
    $locataire = new Locataire($db, GETPOST('id'));
    $locataire->nom = GETPOST("nom");
    $locataire->telephone = GETPOST("telephone");
    $locataire->email = GETPOST("email");
    $locataire->adresse = GETPOST("adresse");
    $locataire->commentaire = GETPOST("commentaire");
    $locataire->statut = GETPOST("statut");
    $e_locataire = $locataire;
    $res = $locataire->update($user);
    if ($res >= 0) {
        Header("Location: " . DOL_URL_ROOT . "/immobilier/locataire.php");
    } else {
        $action = 'update';
    }
}
/*
 * Cr�ation d'un locataire
 *
 */
if ($action == 'create') {
    llxheader('', $langs->trans("addlocataire"), '');
    $html = new Form($db);
    $nbligne = 0;
    print '<form action="fiche_locataire.php" method="post">';
        if ($res == -4) {
            $_error = 2;
            $action = "create";
        }
    }
} elseif (GETPOST("action") == 'maj') {
    $locataire = new Locataire($db, GETPOST('id'));
    $locataire->nom = GETPOST("nom");
    $locataire->telephone = GETPOST("telephone");
    $locataire->email = GETPOST("email");
    $locataire->adresse = GETPOST("adresse");
    $locataire->commentaire = GETPOST("commentaire");
    $locataire->statut = GETPOST("statut");
    $locataire->proprietaire_id = GETPOST("proprietaire_id");
    $e_locataire = $locataire;
    $res = $locataire->update();
    if ($res >= 0) {
        Header("Location: locataire.php");
    } else {
        $action = 'update';
    }
}
/*
 * Cr�ation d'un locataire
 *
 */
if ($action == 'create') {
    llxheader('', $langs->trans("addlocataire"), '');
    $html = new Form($db);
    $nbligne = 0;
    /*