dol_include_once("/immobilier/class/locataire.class.php");
dol_include_once('/immobilier/lib/immobilier.lib.php');
// Langs
$langs->load("immobilier@immobilier");
$mesg = '';
$action = GETPOST('action');
if (GETPOST("action") == 'add') {
    $locataire = new Locataire($db);
    $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_local = $locataire;
    $res = $locataire->create($user);
    if ($res == 0) {
        Header("Location: " . DOL_URL_ROOT . "/immobilier/locataire.php");
    } else {
        if ($res == -3) {
            $_error = 1;
            $action = "create";
        }
        if ($res == -4) {
            $_error = 2;
            $action = "create";
        }
    }
} elseif (GETPOST("action") == 'maj') {
    $locataire = new Locataire($db, GETPOST('id'));
    $locataire->nom = GETPOST("nom");
dol_include_once("/immobilier/class/locataire.class.php");
// Langs
$langs->load("immobilier@immobilier");
$mesg = '';
$action = GETPOST('action');
if (GETPOST("action") == 'add') {
    $locataire = new Locataire($db);
    $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_local = $locataire;
    $res = $locataire->create();
    if ($res == 0) {
        Header("Location: locataire.php");
    } else {
        if ($res == -3) {
            $_error = 1;
            $action = "create";
        }
        if ($res == -4) {
            $_error = 2;
            $action = "create";
        }
    }
} elseif (GETPOST("action") == 'maj') {
    $locataire = new Locataire($db, GETPOST('id'));
    $locataire->nom = GETPOST("nom");