<?php

$clause='1=1';

$field='';

$value='';

if($_a=='select'):

    if(isset($etat)){

        $clause=" and etat='$etat";

    }

    if(isset($idUser)){

        $clause=" and idUser='$idUser";

    }

    if(isset($date_creat)){

        $clause=" and date_creat='$date_creat";

    }

    $sql="select * from form where $clause";

    echo json_encode(rows($sql));

endif;

if($_a=='get'):

    $sql="select * from form where id='$id'";

    echo json_encode(row($sql));

endif;

if($_a=='delete'):

    $sql="delete from form where id='$id'";

    execute($sql);

endif;

if($_a=='insert'):

    $sql="insert into form(etat) value('Actif')";

    $id=execute($sql);

    $etat='Actif';

    $_a='update';

endif;

if($_a=='update'):

    $field='';

    $field.=isset($nom)?"nom='$nom',":'';

    $field.=isset($postnom)?"postnom='$postnom',":'';

    $field.=isset($prenom)?"prenom='$prenom',":'';

    $field.=isset($sexe)?"sexe='$sexe',":'';

    $field.=isset($date_nais)?"date_nais='$date_nais',":'';

    $field.=isset($date_arrivee)?"date_arrivee='$date_arrivee',":'';

    $field.=isset($nationalite)?"nationalite='$nationalite',":'';

    $field.=isset($pays_origine)?"pays_origine='$pays_origine',":'';

    $field.=isset($num_passeport)?"num_passeport='$num_passeport',":'';

    $field.=isset($telephone)?"telephone='$telephone',":'';

    $field.=isset($email)?"email='$email',":'';

    $field.=isset($compagnie)?"compagnie='$compagnie',":'';

    $field.=isset($province)?"province='$province',":'';

    $field.=isset($voie_transport)?"voie_transport='$province',":'';

    $field.=isset($num_vol)?"num_vol='$num_vol',":'';

    $field.=isset($num_siege)?"num_siege='$num_siege',":'';

    $field.=isset($destination)?"destination='$destination',":'';

    $field.=isset($pays_visite)?"pays_visite='$pays_visite',":'';

    $field.=isset($fievre)?"fievre='$fievre',":'';

    $field.=isset($sensation_fievre)?"sensation_fievre='$sensation_fievre',":'';

    $field.=isset($test_covid)?"test_covid='$test_covid',":'';

    $field.=isset($toux)?"toux='$toux',":'';

    $field.=isset($frisson)?"frisson='$frisson',":'';

    $field.=isset($difficulte_respiratoire)?"difficulte_respiratoire='$difficulte_respiratoire',":'';

    $field.=isset($adresse)?"adresse='$adresse',":'';

    $field.=isset($concession)?"concession='$concession',":'';

    $field.=isset($adresse_postal)?"adresse_postal='$adresse_postal',":'';

    $field.=isset($etat)?"etat='$etat',":'';

    $sql="update form set $field where id='$id'";

    execute($sql);

    echo $id;

endif;

