$contrat->fetch($id);
        $contrat->local_id = GETPOST("local_id");
        $contrat->locataire_id = GETPOST("locataire_id");
        $contrat->date_entree = $datect;
        $contrat->preavis = GETPOST('preavis');
        $contrat->date_fin_preavis = $datectend;
        $contrat->montant_tot = GETPOST("montant_tot");
        $contrat->loy = GETPOST("loy");
        $contrat->charges = GETPOST("charges");
        $contrat->tva = GETPOST("tva");
        $contrat->periode = GETPOST("periode");
        $contrat->depot = GETPOST("depot");
        $contrat->commentaire = GETPOST("commentaire");
        $contrat->proprietaire_id = GETPOST("proprietaire_id");
        $e_contrat = $contrat;
        $res = $contrat->update();
        if ($res >= 0) {
            setEventMessage($langs->trans("SocialContributionAdded"), 'mesgs');
        } else {
            setEventMessage($contrat->error, 'errors');
        }
        header("Location: " . DOL_URL_ROOT . "/immobilier/contrat/fiche_contrat.php?id=" . $contrat->id);
    }
}
/*
 * View
 *
 */
if (GETPOST("action") == 'create') {
    llxheader('', $langs->trans("addcontrat"), '');
    $nbligne = 0;