<repo_name>inabernic/GestiBank<file_sep>/gk-force/src/app/app-routing.module.ts
import { AccueilComponent } from './accueil/accueil.component';
import { InscriptionComponent } from './inscription/inscription.component';
import { ConnexionComponent } from './connexion/connexion.component';
import { EspaceClientComponent } from './espace-client/espace-client.component';
import { CompteClientComponent } from './compte-client/compte-client.component';
import { OperationComponent } from './operation/operation.component';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';


const routes: Routes = [
  { path: 'accueil', component: AccueilComponent },
  { path: 'inscription', component: InscriptionComponent },
  { path: 'connexion', component: ConnexionComponent },
  { path: 'espace-client', component: EspaceClientComponent },
  { path: 'compte-client', component: CompteClientComponent },
  { path: 'operation', component: OperationComponent },
  { path: '', redirectTo: 'accueil', pathMatch: 'full'}

];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})

export class AppRoutingModule { }
<file_sep>/affect.php
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Affect</title>
    <link rel="stylesheet" href="styles.css">
</head>

<form action='save_client.php' method="post">
<?php
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];
	
    global $conn;

    $query="SELECT demande_client.date_demande,demande_client.type_demande,
        client.adresse,client.telephone,client.sit_matrimon, client.id_conseiller,
        utilisateur.nom,utilisateur.prenom,utilisateur.email,utilisateur.pseudonyme,
        utilisateur.password,utilisateur.role
    FROM demande_client
    INNER JOIN client ON client.id_client = demande_client.id_client
    INNER JOIN utilisateur ON client.id_user = utilisateur.id_user
    where client.id_conseiller=-1 or utilisateur.pseudonyme in('', null) or utilisateur.password in('', null)";
        
    if ($result = mysqli_query($conn, $query)) {
        echo "
        <table>
            <tr>
                <th>Nom</th>
                <th>Prenom</th>
                <th>e-mail</th>
                <th>Date Demande</th>
                <th>Type Demande</th>
                <th>Pseudonyme</th>
                <th>Password</th>
                <th>Conseiller</th>
                <th style='border-style: none;'></th>
            </tr>";
        while ($obj = mysqli_fetch_object($result)) {
            echo "<tr>";
            echo "<td>" . $obj->nom . "</td>";
            echo "<td>" . $obj->prenom . "</td>";
            echo "<td>" . $obj->email . "</td>";
            echo "<td>" . $obj->date_demande . "</td>";
            $type_dem = "Ouverture";
            if($obj->type_demande == 1){
                $type_dem = "demande chequier";
            }
            echo "<td>" . $type_dem . "</td>";
            echo "<td> <input name='pseudonyme' type='text' value='" . $obj->pseudonyme . "'></td>";
            echo "<td> <input name='password' type='text' value='" . $obj->password . "'></td>";
            $optionsConseillers = optionsConseillers($obj->id_conseiller);
            echo "<td> <select>" . $optionsConseillers . "</select></td>";
            echo "<td style='border-style: none;'><input type='submit' value='Save' /></td>";
            echo "</tr>";
        }
        echo " </table>";

        mysqli_free_result($result);
    } else {
        echo mysqli_error($conn);
    }

    function optionsConseillers($id_conseiller){
        global $conn;
		$query = "SELECT id_conseiller,mle_conseiller, nom, prenom FROM conseiller INNER JOIN utilisateur ON utilisateur.id_user = conseiller.id_user";
		$response = "";
		if ($result = mysqli_query($conn, $query))
            while($row = mysqli_fetch_array($result))
            {
                $selected_option="";
                if($id_conseiller==$row[0]){
                    $selected_option="selected";
                }
                $response .= "<option ".$selected_option." id='$row[0]'>".$row[1]." | ".$row[2]." ".$row[3]."</option>";
                
        }else {
            echo mysqli_error($conn);
        }
        return $response;
    }


?>
</form><file_sep>/demande_inscription.php
<?php
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: *");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];
	
	function getListDemandeUtilisateur(){
        {
            global $conn;
            $query = "SELECT * FROM demande_client";
            $response = array();
            $result = mysqli_query($conn, $query);
            
            while($row = mysqli_fetch_array($result))
            {
            $response[] = $row;
            //	echo $row[0];
            }
            header('Content-Type: application/json');
            echo json_encode($response, JSON_PRETTY_PRINT);
        }<file_sep>/client.php
<?php
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: DELETE");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];

	function getClients()
	{
		global $conn;
		$query = "SELECT * FROM client";
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function getClient($id_client)
	{
		global $conn;
		$query = "SELECT * FROM client";
		if($id_client != 0)
		{
	        $query .= " WHERE id_client=".$id_client." LIMIT 1";
		}
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);	
	}


	function AddClient()
	{
		global $conn;
		/*$name = $_POST["name"];
		$description = $_POST["description"];
		$price = $_POST["price"];
		$category = $_POST["category"];
		$created = date('Y-m-d H:i:s');
		$modified = date('Y-m-d H:i:s');*/

		// GET DATA FORM REQUEST
		$data = json_decode(file_get_contents("php://input"));
		$id_user = $data->id_user;
		$adresse = $data->adresse;
		$id_document = $data->id_document;
		$telephone = $data->telephone;
		$num_enfants = $data->num_enfants;
		$sit_matrimon = $data->sit_matrimon;
		$id_client=-1;
		
		
		echo $query="INSERT INTO client (id_user,adresse, id_document,telephone, num_enfants, sit_matrimon) VALUES('".$id_user."', '".$adresse."', '".$id_document."', '".$telephone."', '".$num_enfants."', '".$sit_matrimon."')";
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'client ajouté avec succès.'
			);
			$id_client=$conn->insert_id;
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'ERREUR!.'. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function updateClient($id_client)
	{
		global $conn;
		$data = json_decode(file_get_contents("php://input"),true);
		$id_conseiller= $data["id_conseiller"];
		$id_user = $data["id_user"];
		$adresse = $data["adresse"];
		$id_document = $data["id_document"];
		$telephone = $data["telephone"];
		$num_enfants = $data["num_enfants"];
		$sit_matrimon = $data["sit_matrimon"];
		$query="UPDATE client SET id_user ='".$id_user."',adresse='".$adresse."', id_document='".id_document."', telephone ='".$telephone."', num_enfants='".$num_enfants."', sit_matrimon='".$sit_matrimon."' WHERE id_client=".$id_client;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'client mis à jour avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'échec de la mise à jour de l_client. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function deleteClient($id_client)
	{
		global $conn;
		$query = "DELETE FROM client WHERE id_client=".$id_client;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'client supprimé avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'La suppression de l_client a échoué. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	// Orchestration des différentes fonctions
	switch($request_method)
	{
		
		case 'GET':
			// Retrive Products
			if(!empty($_GET["id_client"]))
			{
				$id_user=intval($_GET["id_client"]);
				getClient($id_client);
			}
			else
			{
				getClients();
			}
			break;
		default:
			// Invalid Request Method
			header("HTTP/1.0 405 Method Not Allowed");
			break;
			
		case 'POST':
			// Ajouter un produit
			AddClient();
			break;
			
		case 'PUT':
			// Modifier un produit
			$id_client = intval($_GET["id_client"]);
			updateClient($id_client);
			break;
			
		case 'DELETE':
			// Supprimer un produit
			$id_client = intval($_GET["id_client"]);
			deleteClient($id_client);
			break;

	}
?><file_sep>/affectation.php
<form method="post">
<input type="submit" name="submit" value="Affectation">
</form>

<?php
// Connect to database
include("db_connect.php");
$request_method = $_SERVER["REQUEST_METHOD"];


include 'affect.php';
?><file_sep>/gk-force/src/app/app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {FormsModule} from "@angular/forms";
import{HttpClientModule} from '@angular/common/http';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AccueilComponent } from './accueil/accueil.component';
import { InscriptionComponent } from './inscription/inscription.component';
import { ConnexionComponent } from './connexion/connexion.component';
import { EspaceClientComponent } from './espace-client/espace-client.component';
import { CompteClientComponent } from './compte-client/compte-client.component';
import { OperationComponent } from './operation/operation.component';

@NgModule({
  declarations: [
    AppComponent,
    AccueilComponent,
    InscriptionComponent,
    ConnexionComponent,
    EspaceClientComponent,
    CompteClientComponent,
    OperationComponent
    
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpClientModule,
    AppRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
<file_sep>/demande_client.php
<?php
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: *");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];

   //get All Demande_Client
	function getDemandeClients()
	{
		global $conn;
		$query = "SELECT * FROM demande_client";
		$response = array();
		$result = mysqli_query($conn, $query);
		
		while($row = mysqli_fetch_array($result))
		{
		$response[] = $row;
		//	echo $row[0];
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}

	// Récupérer une demande par la référence de la demande
	function getDemandeClient($ref_demande=0)
	{
		global $conn;
		$query = "SELECT * FROM demande_client";
		if($ref_demande != 0)
		{
			$query .= " WHERE ref_demande=".$ref_demande." LIMIT 1";
		}
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}

	//Ajouter un élément dans la table demande_client
	function AddDemandeClients()
	{
		global $conn;
		
		// GET DATA FORM REQUEST
		$data = json_decode(file_get_contents("php://input"));
		$date_demande = $data->date_demande;
		$type_demande = $data->type_demande;
		$id_client = $data->id_client;
		
		
		echo $query="INSERT INTO demande_client(date_demande,type_demande, id_client) VALUES('".$date_demande."', '".$type_demande."', '".$id_client."')";
		if(mysqli_query($conn, $query))
		{
		$response=array(
		'status' => 1,
		'status_message' =>'Votre demande a bien été prise en compte.'
		);
		}
		else
		{
		$response=array(
		'status' => 0,
		'status_message' =>'ERREUR!.'. mysqli_error($conn)
		);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	//mettre à jour un élement dans la table demande_client
	function updateDemandeClients($ref_demande)
	{
		global $conn;
        $data = json_decode(file_get_contents("php://input"),true);

		$date_demande = $data["date_demande"];
		$type_demande = $data["type_demande"];
		$id_client = $data["id_client"];

		$query="UPDATE demande_client SET date_demande='".$date_demande."', type_demande='".$type_demande."', id_client='".$id_client."' WHERE ref_demande=".$ref_demande;
		if(mysqli_query($conn, $query))
		{
		$response=array(
		'status' => 1,
		'status_message' =>'Votre demande a bien été mise à jour avec succès.'
		);
		}
		else
		{
		$response=array(
		'status' => 0,
		'status_message' =>'échec de la mise à jour de votre demande. '. mysqli_error($conn)
		);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}

	// Supprimer un élément
	function deleteDemandeClients($ref_demande)
	{
		global $conn;
		$query = "DELETE FROM demande_client WHERE ref_demande=".$ref_demande;
		if(mysqli_query($conn, $query))
		{
		$response=array(
		'status' => 1,
		'status_message' =>'Demande supprimé avec succès.'
		);
		}
		else
		{
		$response=array(
		'status' => 0,
		'status_message' =>'La suppression de votre demande a échoué. '. mysqli_error($conn)
		);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	// Orchestration des différentes fonctions
	switch($request_method)
	{
		
		case 'GET':
		if(!empty($_GET["ref_demande"]))
		{
		$ref_demande=intval($_GET["ref_demande"]);
		getDemandeClient($ref_demande);
		}
		else
		{
		getDemandeClients();
		}
		break;
		default:
		// Invalid Request Method
		header("HTTP/1.0 405 Method Not Allowed");
		break;
		
		case 'POST':
		// Ajouter une demande 
		AddDemandeClients();
		break;
		
		case 'PUT':
		// Modifier une demande
		$ref_demande= intval($_GET["ref_demande"]);
		updateDemandeClients($ref_demande);
		break;
		
		case 'DELETE':
		// Supprimer une demande
		$ref_demande= intval($_GET["ref_demande"]);
		deleteDemandeClients($ref_demande);
		break;

	}
?><file_sep>/save_client.php
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Sauvegarde</title>
    <link rel="stylesheet" href="styles.css">
</head> 
<?php
$pseudonyme = $_POST["pseudonyme"];
$password = $_POST["<PASSWORD>"];
include("db_connect.php"); 

$query="UPDATE client SET id_conseiller='".$id_conseiller."' WHERE id_client=".$id_client;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Administrateur mis à jour avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'échec de la mise à jour de l_. '. mysqli_error($conn)
			);
		}




?>
<form action='affect.php'>
    <button>Retour</button>
</form><file_sep>/transactions.php
<?php
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: DELETE");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];

	function getTransactions()
	{
		global $conn;
		$query = "SELECT * FROM transactions";
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function getTransaction($num_transaction)
	{
		global $conn;
		$query = "SELECT * FROM transactions";
		if($num_transaction != 0)
		{
			$query .= " WHERE num_transaction=".$num_transaction." LIMIT 1";
		}
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function AddTransaction()
	{
		global $conn;
		
		// GET DATA FROM REQUEST
		$data = json_decode(file_get_contents("php://input"));
		$date_transaction = $data->date_transaction;
		$type_transaction = $data->type_transaction;
		$montant_transaction = $data->montant_transaction;
		$id_client = $data->id_client;
				
		echo $query="INSERT INTO transactions (date_transaction, type_transaction, montant_transaction, id_client) VALUES('".$date_transaction."', '".$type_transaction."', '".$montant_transaction."', '".$id_client."')";
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Transaction ajoutée avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'ERREUR!.'. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function updateTransaction($num_transaction)
	{
		global $conn;
		$data = json_decode(file_get_contents("php://input"),true);
		$date_transaction = $data["date_transaction"];
		$type_transaction = $data["type_transaction"];
		$montant_transaction = $data["montant_transaction"];
		$id_client = $data["id_client"];
		$query="UPDATE transactions SET date_transaction='".$date_transaction."', type_transaction='".$type_transaction."', montant_transaction='".$montant_transaction."', id_client='".$id_client."' WHERE num_transaction=".$num_transaction;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Transaction mise à jour avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'échec de la mise à jour de la transaction. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function deleteTransaction($num_transaction)
	{
		global $conn;
		$query = "DELETE FROM transactions WHERE num_transaction=".$num_transaction;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Transaction supprimée avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'La suppression de la transaction a échoué. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	// Orchestration des différentes fonctions
	switch($request_method)
	{
		
		case 'GET':
			if(!empty($_GET["num_transaction"]))
			{
				$num_transaction=intval($_GET["num_transaction"]);
				getTransaction($num_transaction);
			}
			else
			{
				getTransactions();
			}
			break;
		default:
			// Invalid Request Method
			header("HTTP/1.0 405 Method Not Allowed");
			break;
			
		case 'POST':
			// Ajouter une transaction
			AddTransaction();
			break;
			
		case 'PUT':
			// Modifier une transaction
			$num_transaction = intval($_GET["num_transaction"]);
			updateTransaction($num_transaction);
			break;
			
		case 'DELETE':
			// Supprimer une transaction
			$num_transaction = intval($_GET["num_transaction"]);
			deleteTransaction($num_transaction);
			break;

	}
?><file_sep>/gestionconnexion/deconnexion.php
<html>
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="style.css" media="screen" type="text/css" />
    </head>
    <body style='background:#fff;'>
        <div id="content">
            
           <!-- <a href='bienvenue.php?deconnexion=true'><span>Déconnexion</span></a>-->

            <?php
                session_start();
              /*  if(isset($_GET['deconnexion']))
                { 
                   if($_GET['deconnexion']==true)
                   {  */
              if(isset($_SESSION['deconnexion']))
                { 
                   if($_SESSION['deconnexion']==true)
                   {                      
                      session_unset();
                      header("location:authentification.php");
                   }
                }
                else if($_SESSION['nom'] !== "")
                {
                    $user = $_SESSION['nom'];
                    echo "<br>Bonjour $user, vous êtes connectés";
                   // header("location:authentification.php");
                }
            ?>              
            </form>
            
        </div>
    </body>
</html><file_sep>/gk-force/src/app/compte-client/compte-client.component.ts
import { Component, OnInit } from '@angular/core';
import { Compte } from '../modeles/Compte';
import { CompteService } from '../services/CompteService';

@Component({
  selector: 'app-compte-client',
  templateUrl: './compte-client.component.html',
  styleUrls: ['./compte-client.component.scss'],
  providers: [CompteService]
})
export class CompteClientComponent implements OnInit {

  private compte: Compte[];

  constructor(private serviceCompte:CompteService) { }

  ngOnInit() 
  {
    this.getCompte();
  }

  getCompte()
  {
    this.serviceCompte.findAll().subscribe
    (
      cpt=>{this.compte=cpt;}
    )
  }

}
<file_sep>/compte.php
<?php
	header("charset:utf8");
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: *");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];

	function getComptes()
	{   
		global $conn;
		$query = "SELECT * FROM compte";
		$response = array();
		$result = mysqli_query($conn, $query);
		
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
			
		}
		header('Content-Type: application/json');
	    echo json_encode($response, JSON_PRETTY_PRINT);
		
		
	}
	
	function getCompte($id_compte)
	{
		global $conn;
		$query = "SELECT * FROM compte";
		if($num_compte != 0)
		{
			$query .= " WHERE id_compte=".$id_compte." LIMIT 1";
		}
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function AddCompte()
	{
		global $conn;

		// GET DATA FORM REQUEST
		$data = json_decode(file_get_contents("php://input"));
		$id_compte=$data->id_compte;
		$rib = $data->rib;
		$date_creation = $data->date_creation;
		$solde = $data->solde;
		$type_compte =$data->type_compte;
		$id_client = $data->id_client;
		
		echo $query="INSERT INTO compte(id_compte,rib,date_creation,solde,type_compte,id_client)
		VALUES('".$id_compte."','".$rib."','".$date_creation."', '".$solde."',,'".	$type_compte."' '".$id_client."')";
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Compte ajouté avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'ERREUR!.'. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
		print_r($response);
	}

	function updateCompte($id_compte)
	{
		global $conn;
		$data = json_decode(file_get_contents("php://input"),true);
		$rib = $data["rib"];
		$date_creation = $data["date_creation"];
		$solde = $data["solde"];
		$type_compte =$data["type_compte"];
		$id_client = $data["id_client"];

		$query="UPDATE compte SET rib='".$rib."',date_creation='".$date_creation."', solde=".$solde.",type_compte='".$type_compte."', id_client=".$id_client. " WHERE id_compte=".$id_compte;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Compte mis à jour avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'échec de la mise à jour du compte. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function deleteCompte($id_compte)
	{
		global $conn;
		$query = "DELETE FROM compte WHERE id_compte=".$id_compte;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Compte supprimé avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'La suppression du compte a échoué. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	// Orchestration des différentes fonctions
	switch($request_method)
	{
		
		case 'GET':
			// Retrive Products
			if(!empty($_GET["id_compte"]))
			{
				$id_compte=intval($_GET["id_compte"]);
				getCompte($id_compte);
			}
			else
			{
				getComptes();
			}
			break;
		default:
			// Invalid Request Method
			header("HTTP/1.0 405 Method Not Allowed");
			break;
			
		case 'POST':
			// Ajouter un compte
			AddCompte();
			break;
			
		case 'PUT':
			// Modifier un compte
			$id_compte = intval($_GET["id_compte"]);
			updateCompte($num_compte);
			break;
			
		case 'DELETE':
			// Supprimer un compte
			$id_compte = intval($_GET["id_compte"]);
			deleteCompte($id_compte);
			break;

	}
?><file_sep>/gk-force/src/app/modeles/Compte.ts
export class Compte
{ 
    id_compte : number;
    rib : number;
    date_creation : string;
    solde : number;
    type_compte : number;
    id_client : number;

    constructor(id_compte : number, rib : number, date_creation : string, solde : number,type_compte : number,id_client : number)
    {
        this.id_compte = id_compte;
        this.rib = rib;
        this.date_creation = date_creation;
        this.solde = solde;
        this.type_compte = type_compte;
        this.id_client = id_client;
    }
}<file_sep>/historique.php
<?php
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: DELETE");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];

	function getHistoriques()
	{
		global $conn;
		$query = "SELECT * FROM historique";
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function getHistorique($id_histo=0)
	{
		global $conn;
		$query = "SELECT * FROM historique";
		if($id_histo != 0)
		{
			$query .= " WHERE id_histo=".$id_histo." LIMIT 1";
		}
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function AddHistorique()
	{
		global $conn;
		
		// GET DATA FROM REQUEST
		$data = json_decode(file_get_contents("php://input"));
		$date_operation = $data->date_operation;
		$nature_operation = $data->nature_operation;
		$debit = $data->debit;
		$credit = $data->credit;
		$num_compte = $data->num_compte;
		$num_transaction = $data->num_transaction;
		
		echo $query="INSERT INTO historique(date_operation, nature_operation, debit, credit, num_compte, num_transaction) VALUES('".$date_operation."', '".$nature_operation."', '".$debit."', '".$credit."', '".$num_compte."', '".$num_transaction."')";
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Elément ajouté avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'ERREUR!.'. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function updateHistorique($id_histo)
	{
		global $conn;
		$data = json_decode(file_get_contents("php://input"),true);
		$date_operation = $data["date_operation"];
		$nature_operation = $data["nature_operation"];
		$debit = $data["debit"];
		$credit = $data["credit"];
		$num_compte = $data["num_compte"];
		$num_transaction = $data["num_transaction"];
		$query="UPDATE historique SET date_operation='".$date_operation."', nature_operation='".$nature_operation."', debit='".$debit."', credit='".$credit."', num_compte='".$num_compte."', num_transaction='".$num_transaction."' WHERE id_histo=".$id_histo;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Historique mis à jour avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'échec de la mise à jour de l_historique. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function deleteHistorique($id_histo)
	{
		global $conn;
		$query = "DELETE FROM historique WHERE id_histo=".$id_histo;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Elément supprimé avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'La suppression de l_élément a échoué. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	// Orchestration des différentes fonctions
	switch($request_method)
	{
		
		case 'GET':
			// Récupérer un ou plusieurs éléments dans l'historique
			if(!empty($_GET["id_histo"]))
			{
				$id_histo=intval($_GET["id_histo"]);
				getHistorique($id_histo);
			}
			else
			{
				getHistoriques();
			}
			break;
		default:
			// Invalid Request Method
			header("HTTP/1.0 405 Method Not Allowed");
			break;
			
		case 'POST':
			// Ajouter un élément
			AddHistorique();
			break;
			
		case 'PUT':
			// Modifier un élément
			$id_histo = intval($_GET["id_histo"]);
			updateHistorique($id_histo);
			break;
			
		case 'DELETE':
			// Supprimer un élément
			$id_histo = intval($_GET["id_histo"]);
			deleteHistorique($id_histo);
			break;

	}
?><file_sep>/creer_conseiller.php
<?php
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: *");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];
	
    global $conn;
		
		// Ajouter les informations sur un conseiller
		//$data = json_decode(file_get_contents("php://input"));
			
/* 		$nom = $data->nom;
		$prenom = $data->prenom;
		$email=$data->email;
		$mle_conseiller = $data->mle_conseiller;
		$pseudonyme = $data->pseudonyme;
		$password = $<PASSWORD>;
		$date_deb_contrat = $data->date_deb_contrat; */
	
		$nom = $_POST["nom"];
		$prenom = $_POST["prenom"];
		$email = $_POST["email"];
		$mle_conseiller = $_POST["mle_conseiller"];
		$pseudonyme = $_POST["pseudonyme"];
		$password = $_POST["password"];
		$date_deb_contrat = $_POST["date_deb_contrat"];
		$role =1;
		$id_user=-1;
	
		$query="INSERT INTO utilisateur (nom,prenom,email,pseudonyme,password,role) VALUES('".$nom."', '".$prenom."', '".$email."','".$pseudonyme."','".$password."','".$role."')";	
		if(mysqli_query($conn, $query))
		{
			$id_user=$conn->insert_id;
			$query="INSERT INTO conseiller(date_deb_contrat,id_user,mle_conseiller) VALUES('".$date_deb_contrat."', '".$id_user."', '".$mle_conseiller."')";	
			if(mysqli_query($conn, $query))
					{
						$response=array
						(
							'status' => 1,
							'status_message' =>'Votre demande a bien été prise en compte.'
						);
			}else{
						$response=array
						(
						'status' => 0,
						'status_message' =>'ERREUR!.'. mysqli_error($conn)
						);
						echo $query;
					}	
		}else{
			$response=array
			(
			'status' => 0,
			'status_message' =>'ERREUR!.'. mysqli_error($conn)
			);
		}


		header('Content-Type: application/json');
		echo json_encode($response);
?><file_sep>/conseiller.php
<?php
	header("charset:utf8");
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: *");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];

	function getConseillers()
	{   
		global $conn;
		$query = "SELECT * FROM conseiller";
		$response = array();
		$result = mysqli_query($conn, $query);
		
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
			
		}
		header('Content-Type: application/json');
	    echo json_encode($response, JSON_PRETTY_PRINT);
		
		
	}
	
	function getConseiller($id_conseiller=0)
	{
		global $conn;
		$query = "SELECT * FROM conseiller";
		if($mle_conseiller != 0)
		{
			$query .= " WHERE id_conseiller=".$id_conseiller." LIMIT 1";
		}
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function AddConseiller()
	{
		global $conn;
		/*$date_deb_contrat = $_POST["date_deb_contrat"];
		$id_user = $_POST["id_user"];*/

		// GET DATA FORM REQUEST
		$data = json_decode(file_get_contents("php://input"));
		$mle_conseiller = $data->mle_conseiller;
		$date_deb_contrat = $data->date_deb_contrat;
		$id_user = $data->id_user;
		$id_conseiller=-1;
		
		echo $query="INSERT INTO conseiller(mle_conseiller,date_deb_contrat,id_user)
		VALUES('".$$mle_conseiller."', '".$date_deb_contrat."', '".$id_user."')";
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Conseiller ajouté avec succès.'
			);
			$id_conseiller=$conn->insert_id;
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'ERREUR!.'. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}

	function updateConseiller($id_conseiller)
	{
		global $conn;
		$data = json_decode(file_get_contents("php://input"),true);
		$date_deb_contrat = $data["date_deb_contrat"];
		$mle_conseiller = $data["mle_conseiller"];
		$id_user = $data["id_user"];

		$query="UPDATE conseiller SET date_deb_contrat='".$date_deb_contrat."',mle_conseiller='".$mle_conseiller."',  id_user=".$id_user." WHERE id_conseiller=".$id_conseiller;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				
				'status' => 1,
				'status_message' =>'Conseiller mis à jour avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'échec de la mise à jour du conseiller. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function deleteConseiller($id_conseiller)
	{
		global $conn;
		$query = "DELETE FROM conseiller WHERE id_conseiller=".$id_conseiller;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Conseiller supprimé avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'La suppression du conseiller a échoué. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	// Orchestration des différentes fonctions
	switch($request_method)
	{
		
		case 'GET':
			// Retrive Products
			if(!empty($_GET["id_conseiller"]))
			{
				$id_conseiller=intval($_GET["id_conseiller"]);
				getConseiller($id_conseiller);
			}
			else
			{
				getConseillers();
			}
			break;
		default:
			// Invalid Request Method
			header("HTTP/1.0 405 Method Not Allowed");
			break;
			
		case 'POST':
			// Ajouter un produit
			AddConseiller();
			break;
			
		case 'PUT':
			// Modifier un produit
			$id_conseiller = intval($_GET["id_conseiller"]);
			updateConseiller($id_conseiller);
			break;
			
		case 'DELETE':
			// Supprimer un produit
			$id_conseiller = intval($_GET["id_conseiller"]);
			deleteConseiller($id_conseiller);
			break;

	}
?><file_sep>/adresse.php
<?php
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: DELETE");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];

	function getAdresses()
	{
		global $conn;
		$query = "SELECT * FROM adresse";
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}

	function getAdresse($id_adresse=0)
    {
        global $conn;
		$query = "SELECT * FROM adresse";
		if($id_adresse != 0)
		{
			$query .= " WHERE id_adresse=".$id_adresse." LIMIT 1";
		}
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}

	function AddAdresse()
	{
		global $conn;
		/*$name = $_POST["name"];
		$description = $_POST["description"];
		$price = $_POST["price"];
		$category = $_POST["category"];
		$created = date('Y-m-d H:i:s');
		$modified = date('Y-m-d H:i:s');*/

		// GET DATA FORM REQUEST
		$data = json_decode(file_get_contents("php://input"));
		$num_rue = $data->num_rue;
		$nom_rue = $data->nom_rue;
		$code_postal = $data->code_postal;
		$ville = $data->ville;
		$id_user = $data->id_user;
		
		echo $query="INSERT INTO adresse (num_rue,nom_rue ,code_postal , ville, id_user) VALUES('".$num_rue."', '".$nom_rue."', '".$code_postal."', '".$ville."','".$id_user."')";
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Adresse ajouté avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'ERREUR!.'. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function updateAdresse($id_adresse)
	{
		global $conn;
		$data = json_decode(file_get_contents("php://input"),true);
		$num_rue = $data["num_adresse"];
		$nom_rue = $data["num_rue"];
		$code_postal  = $data["code_postal "];
		$ville = $data["ville"];
		$id_user = $data["id_user"];
		$query="UPDATE adresse SET num_rue ='".$num_rue."', nom_rue='".$nom_rue."', code_postal ='".$code_postal ."', ville='".$ville."', id_user='".$id_user."' WHERE id_adresse =".$id_adresse;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Adresse mis à jour avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'échec de la mise à jour de l_utilisateur. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function deleteAdresse($id_adresse)
	{
		global $conn;
		$query = "DELETE FROM adresee WHERE id_adresse=".$id_adresse;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Adresse supprimé avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'La suppression de l_Adresse a échoué. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	// Orchestration des différentes fonctions
	switch($request_method)
	{
		
		case 'GET':
			// Retrive Products
			if(!empty($_GET["id_adresse"]))
			{
				$id_adresse=intval($_GET["id_adresse"]);
				getAdresse($id_adresse);
			}
			else
			{
				getAdresses();
			}
			break;
		default:
			// Invalid Request Method
			header("HTTP/1.0 405 Method Not Allowed");
			break;
			
		case 'POST':
			// Ajouter un produit
			AddAdresse();
			break;
			
		case 'PUT':
			// Modifier un produit
			$id_adresse = intval($_GET["id_adresse"]);
			updateAdresse($id_adresse);
			break;
			
		case 'DELETE':
			// Supprimer un produit
			$id_adresse = intval($_GET["id_adresse"]);
			deleteAdresee($id_adresse);
			break;

	}
?><file_sep>/utilisateur.php
<?php
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: DELETE");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];

	function getUtilisateurs()
	{
		global $conn;
		$query = "SELECT * FROM utilisateur";
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function getUtilisateur($id_user)
	{
		global $conn;
		$query = "SELECT * FROM utilisateur";
		if($id_user != 0)
		{
			$query .= " WHERE id_user=".$id_user." LIMIT 1";
		}
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function AddUtilisateur()
	{
		global $conn;
		
		// GET DATA FROM REQUEST
		$data = json_decode(file_get_contents("php://input"));
		$nom = $data->nom;
		$email = $data->email;
		$password = $data->password;
		$role = $data->role;
		$id_user=-1;
	
		echo $query="INSERT INTO utilisateur(nom, email, password, role) VALUES('".$nom."', '".$email."','".$password."', '".$role."')";
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Utilisateur ajouté avec succès.'
			);
			$id_user=$conn->insert_id;
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'ERREUR!.'. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
		return id_user;
	}
	
	function updateUtilisateur($id_user)
	{
		global $conn;
		$data = json_decode(file_get_contents("php://input"),true);
		$nom = $data["nom"];
		$email = $data["email"];
		$password = $data["<PASSWORD>"];
		$role = $data["role"];
		$query="UPDATE utilisateur SET nom='".$nom."', email='".$email."', password='".$<PASSWORD>."', role='".$role."' WHERE id_user=".$id_user;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Utilisateur mis à jour avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'échec de la mise à jour de l_utilisateur. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function deleteUtilisateur($id_user)
	{
		global $conn;
		$query = "DELETE FROM utilisateur WHERE id_user=".$id_user;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Utilisateur supprimé avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'La suppression de l_utilisateur a échoué. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	// Orchestration des différentes fonctions
	switch($request_method)
	{
		
		case 'GET':
			// Récupérer un ou plusieurs utilisateurs
			if(!empty($_GET["id_user"]))
			{
				$id_user=intval($_GET["id_user"]);
				getUtilisateur($id_user);
			}
			else
			{
				getUtilisateurs();
			}
			break;
		default:
			// Invalid Request Method
			header("HTTP/1.0 405 Method Not Allowed");
			break;
			
		case 'POST':
			// Ajouter un utilisateur
			AddUtilisateur();
			break;
			
		case 'PUT':
			// Modifier un utilisateur
			$id_user = intval($_GET["id_user"]);
			updateUtilisateur($id_user);
			break;
			
		case 'DELETE':
			// Supprimer un utilisateur
			$id_user = intval($_GET["id_user"]);
			deleteUtilisateur($id_user);
			break;

	}
?><file_sep>/gk-force/src/app/services/CompteService.ts
import {HttpClient}  from "@angular/common/http";
import {Compte} from "../modeles/Compte";
import {Observable} from "rxjs";
import {Injectable} from "@angular/core";

@Injectable()
export class CompteService
{
    private apiUrl='http://localhost/compte';

    constructor(private http: HttpClient){}

    findAll():Observable<Compte[]>
    {
        return this.http.get<Compte[]>(this.apiUrl);
    }

}<file_sep>/notification.php
<?php
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: DELETE");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];

	function getNotifications()
	{
		global $conn;
		$query = "SELECT * FROM notification";
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function getNotification($ref_notif)
	{
		global $conn;
		$query = "SELECT * FROM notification";
		if($ref_notif != 0)
		{
			$query .= " WHERE ref_notif=".$ref_notif." LIMIT 1";
		}
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function AddNotification()
	{
		global $conn;
		
		// GET DATA FROM REQUEST
		$data = json_decode(file_get_contents("php://input"));
		$date_notif = $data->date_notif;
		$message_notif = $data->message_notif;
		$num_transaction = $data->num_transaction;
		$num_compte = $data->num_compte;
		$ref_demande = $data->ref_demande;
		$ref_demande_ouverture = $data->ref_demande_ouverture;
				
		echo $query="INSERT INTO notification(date_notif, message_notif, num_transaction, num_compte, ref_demande, ref_demande_ouverture) VALUES('".$date_notif."', '".$message_notif."', '".$num_transaction."', '".$num_compte."', '".$ref_demande."', '".$ref_demande_ouverture."')";
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Notification ajoutée avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'ERREUR!.'. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function updateNotification($ref_notif)
	{
		global $conn;
		$data = json_decode(file_get_contents("php://input"),true);
		$date_notif = $data["date_notif"];
		$message_notif = $data["message_notif"];
		$num_transaction = $data["num_transaction"];
		$num_compte = $data["num_compte"];
		$ref_demande = $data["ref_demande"];
		$ref_demande_ouverture = $data["ref_demande_ouverture"];
		$query="UPDATE notification SET date_notif='".$date_notif."', message_notif='".$message_notif."', num_transaction='".$num_transaction."', num_compte='".$num_compte."', ref_demande='".$ref_demande."', ref_demande_ouverture='".$ref_demande_ouverture."' WHERE ref_notif=".$ref_notif;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Notification mise à jour avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'échec de la mise à jour de la notification. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function deleteNotification($ref_notif)
	{
		global $conn;
		$query = "DELETE FROM notification WHERE ref_notif=".$ref_notif;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Notification supprimée avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'La suppression de la notification a échoué. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	// Orchestration des différentes fonctions
	switch($request_method)
	{
		
		case 'GET':
			// Récupérer un ou plusieurs utilisateurs
			if(!empty($_GET["ref_notif"]))
			{
				$ref_notif=intval($_GET["ref_notif"]);
				getNotification($ref_notif);
			}
			else
			{
				getNotifications();
			}
			break;
		default:
			// Invalid Request Method
			header("HTTP/1.0 405 Method Not Allowed");
			break;
			
		case 'POST':
			// Ajouter une notification
			AddNotification();
			break;
			
		case 'PUT':
			// Modifier une notification
			$ref_notif = intval($_GET["ref_notif"]);
			updateNotification($ref_notif);
			break;
			
		case 'DELETE':
			// Supprimer une notification
			$ref_notif = intval($_GET["ref_notif"]);
			deleteNotification($ref_notif);
			break;

	}
?><file_sep>/gk-force.sql
-- phpMyAdmin SQL Dump
-- version 4.9.2
-- https://www.phpmyadmin.net/
--
-- Хост: 127.0.0.1:3306
-- Время создания: Дек 01 2019 г., 10:42
-- Версия сервера: 10.4.10-MariaDB
-- Версия PHP: 7.3.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- База данных: `gk-force`
--

-- --------------------------------------------------------

--
-- Структура таблицы `administrateur`
--

DROP TABLE IF EXISTS `administrateur`;
CREATE TABLE IF NOT EXISTS `administrateur` (
  `id_admin` int(11) NOT NULL AUTO_INCREMENT,
  `date_deb_contrat` date NOT NULL,
  `id_conseiller` int(11) NOT NULL,
  PRIMARY KEY (`id_admin`),
  KEY `FK_id_user` (`id_conseiller`)
) ENGINE=MyISAM AUTO_INCREMENT=114 DEFAULT CHARSET=utf8;

--
-- Дамп данных таблицы `administrateur`
--

INSERT INTO `administrateur` (`id_admin`, `date_deb_contrat`, `id_conseiller`) VALUES
(111, '2017-09-23', 11),
(112, '2018-09-23', 12),
(113, '2019-09-23', 13);

-- --------------------------------------------------------

--
-- Структура таблицы `adresse`
--

DROP TABLE IF EXISTS `adresse`;
CREATE TABLE IF NOT EXISTS `adresse` (
  `id_adresse` int(11) NOT NULL AUTO_INCREMENT,
  `num_rue` int(5) NOT NULL,
  `nom_rue` varchar(100) NOT NULL,
  `code_postal` int(10) NOT NULL,
  `ville` varchar(50) NOT NULL,
  `id_user` int(11) NOT NULL,
  PRIMARY KEY (`id_adresse`),
  KEY `FK_id_user` (`id_user`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;

--
-- Дамп данных таблицы `adresse`
--

INSERT INTO `adresse` (`id_adresse`, `num_rue`, `nom_rue`, `code_postal`, `ville`, `id_user`) VALUES
(3, 56, '', 92300, 'Paris', 2),
(1, 46, 'Bellevue', 92100, 'Boulogne', 1),
(4, 23, '<NAME>', 93290, 'Tremblay', 3),
(5, 32, 'avenue des Roses', 92500, '<NAME>', 4),
(6, 50, '<NAME>', 92048, 'Meudon', 5),
(7, 30, 'de Paris', 92072, 'Sevres', 6),
(8, 40, '<NAME>', 92140, 'Clamart', 7);

-- --------------------------------------------------------

--
-- Структура таблицы `client`
--

DROP TABLE IF EXISTS `client`;
CREATE TABLE IF NOT EXISTS `client` (
  `id_client` int(11) NOT NULL AUTO_INCREMENT,
  `id_conseiller` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  `adresse` varchar(250) NOT NULL,
  `telephone` int(14) NOT NULL,
  `num_enfants` int(1) NOT NULL,
  `sit_matrimon` varchar(11) NOT NULL COMMENT 'c-celibat, m-marie, d-divorce, v-veuf',
  PRIMARY KEY (`id_client`),
  KEY `FK_id_user` (`id_user`),
  KEY `mle_conseiller` (`id_conseiller`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Структура таблицы `compte`
--

DROP TABLE IF EXISTS `compte`;
CREATE TABLE IF NOT EXISTS `compte` (
  `id_compte` int(11) NOT NULL AUTO_INCREMENT,
  `rib` int(9) NOT NULL,
  `date_creation` date NOT NULL,
  `solde` int(20) NOT NULL,
  `type_compte` int(1) NOT NULL COMMENT '0- rémunéré, 1-courant',
  `id_client` int(11) NOT NULL,
  PRIMARY KEY (`id_compte`),
  KEY `FK_id_client` (`id_client`)
) ENGINE=MyISAM AUTO_INCREMENT=129 DEFAULT CHARSET=utf8;

--
-- Дамп данных таблицы `compte`
--

INSERT INTO `compte` (`id_compte`, `rib`, `date_creation`, `solde`, `type_compte`, `id_client`) VALUES
(123, 0, '2017-09-25', 500, 0, 1),
(124, 0, '2017-09-25', 500, 0, 1),
(125, 0, '2018-09-24', 1000, 0, 5),
(126, 0, '2019-09-24', 1500, 0, 6),
(127, 0, '2017-09-25', 2000, 0, 5),
(128, 0, '2018-09-26', 2500, 0, 7);

-- --------------------------------------------------------

--
-- Структура таблицы `compte_rem`
--

DROP TABLE IF EXISTS `compte_rem`;
CREATE TABLE IF NOT EXISTS `compte_rem` (
  `id_compte_rem` int(11) NOT NULL AUTO_INCREMENT,
  `taux_interet` float NOT NULL,
  `id_compte` int(11) NOT NULL,
  `facilite_caisse` tinyint(1) NOT NULL COMMENT '0-non,1-oui',
  `montant_debit` decimal(9,0) NOT NULL,
  PRIMARY KEY (`id_compte_rem`),
  KEY `id_compte` (`id_compte`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Структура таблицы `conseiller`
--

DROP TABLE IF EXISTS `conseiller`;
CREATE TABLE IF NOT EXISTS `conseiller` (
  `id_conseiller` int(11) NOT NULL AUTO_INCREMENT,
  `mle_conseiller` int(7) NOT NULL,
  `date_deb_contrat` date NOT NULL,
  `id_user` int(11) NOT NULL,
  PRIMARY KEY (`id_conseiller`),
  KEY `id_user` (`id_user`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Дамп данных таблицы `conseiller`
--

INSERT INTO `conseiller` (`id_conseiller`, `mle_conseiller`, `date_deb_contrat`, `id_user`) VALUES
(1, 0, '2017-09-23', 0),
(2, 0, '2019-09-23', 0);

-- --------------------------------------------------------

--
-- Структура таблицы `demande_client`
--

DROP TABLE IF EXISTS `demande_client`;
CREATE TABLE IF NOT EXISTS `demande_client` (
  `ref_demande` int(11) NOT NULL AUTO_INCREMENT,
  `date_demande` date NOT NULL,
  `type_demande` int(1) NOT NULL COMMENT '0-ouverture, 1-chequier',
  `id_client` int(11) NOT NULL,
  PRIMARY KEY (`ref_demande`),
  KEY `FK_id_client` (`id_client`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

--
-- Дамп данных таблицы `demande_client`
--

INSERT INTO `demande_client` (`ref_demande`, `date_demande`, `type_demande`, `id_client`) VALUES
(1, '2017-11-20', 0, 6),
(2, '2018-11-20', 1, 7),
(3, '2018-11-22', 0, 7),
(4, '2019-09-22', 1, 6);

-- --------------------------------------------------------

--
-- Структура таблицы `document`
--

DROP TABLE IF EXISTS `document`;
CREATE TABLE IF NOT EXISTS `document` (
  `id_document` int(11) NOT NULL AUTO_INCREMENT,
  `type_document` varchar(50) NOT NULL,
  `contenu_document` blob NOT NULL,
  `id_client` int(11) NOT NULL,
  PRIMARY KEY (`id_document`),
  KEY `id_client` (`id_client`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Структура таблицы `notification`
--

DROP TABLE IF EXISTS `notification`;
CREATE TABLE IF NOT EXISTS `notification` (
  `id_notif` int(11) NOT NULL AUTO_INCREMENT,
  `date_notif` date NOT NULL,
  `message_notif` varchar(200) NOT NULL,
  `id_transaction` int(11) NOT NULL,
  `id_compte` int(11) NOT NULL,
  `ref_demande` int(11) NOT NULL,
  PRIMARY KEY (`id_notif`),
  KEY `FK_num_transaction` (`id_transaction`),
  KEY `FK_num_compte` (`id_compte`),
  KEY `FK_ref_demande` (`ref_demande`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Структура таблицы `transactions`
--

DROP TABLE IF EXISTS `transactions`;
CREATE TABLE IF NOT EXISTS `transactions` (
  `id_transaction` int(11) NOT NULL AUTO_INCREMENT,
  `date_transaction` date NOT NULL,
  `type_transaction` char(1) NOT NULL COMMENT 'd-debit, c-credit',
  `montant_transaction` int(11) NOT NULL,
  `id_compte` int(11) NOT NULL,
  PRIMARY KEY (`id_transaction`),
  KEY `FK_id_client` (`id_compte`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Структура таблицы `utilisateur`
--

DROP TABLE IF EXISTS `utilisateur`;
CREATE TABLE IF NOT EXISTS `utilisateur` (
  `id_user` int(11) NOT NULL AUTO_INCREMENT,
  `nom` varchar(30) NOT NULL,
  `prenom` varchar(15) NOT NULL,
  `email` varchar(60) NOT NULL,
  `pseudonyme` varchar(10) NOT NULL,
  `password` varchar(20) NOT NULL,
  `role` int(1) NOT NULL COMMENT '0-client, 1-conseiller, 2-admin',
  PRIMARY KEY (`id_user`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;

--
-- Дамп данных таблицы `utilisateur`
--

INSERT INTO `utilisateur` (`id_user`, `nom`, `prenom`, `email`, `pseudonyme`, `password`, `role`) VALUES
(1, 'Bernic', '', '<EMAIL>', '', 'inulea10', 1),
(2, 'Paterna', '', '<EMAIL>', '', 'Manonegra1988', 0),
(3, 'Rahoui', '', '<EMAIL>', '', 'rahoui', 0),
(4, 'Bellard', '', '<EMAIL>', '', 'bellard', 2),
(5, 'Bernic', '', '<EMAIL>', '', 'bernic', 1),
(6, 'Rahoui', '', '<EMAIL>', '', 'rahoui', 2),
(7, 'Paterna', '', '<EMAIL>', '', 'anne', 0);
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
<file_sep>/administrateur.php
<?php
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: access");
	header("Access-Control-Allow-Methods: *");
	header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
	
	// Connect to database
	include("db_connect.php");
	$request_method = $_SERVER["REQUEST_METHOD"];

	function getAdministrateurs()
	{
		global $conn;
		$query = "SELECT * FROM administrateur";
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function getAdmistrateur($mle_admin)
	{
		global $conn;
		$query = "SELECT * FROM administrateur";
		if($mle_admin != 0)
		{
			$query .= " WHERE mle_admin=".$mle_admin." LIMIT 1";
		}
		$response = array();
		$result = mysqli_query($conn, $query);
		while($row = mysqli_fetch_array($result))
		{
			$response[] = $row;
		}
		header('Content-Type: application/json');
		echo json_encode($response, JSON_PRETTY_PRINT);
	}
	
	function AddAdministrateur()
	{
		global $conn;
		

		// GET DATA FORM REQUEST
		$data = json_decode(file_get_contents("php://input"));
		$fonction = $data->fonction;
		$date_deb_contrat = $data->date_deb_contrat;
		$id_conseiller = $data->id_conseiller;
		
		
		echo $query="INSERT INTO administrateur (fonction , date_deb_contrat, id_conseiller) VALUES('".$fonction ."', '".$date_deb_contrat."', '".$id_conseiller."')";
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>' Administrateur ajouté avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'ERREUR!.'. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function updateAdministrateur($mle_admin)
	{
		global $conn;
		$data = json_decode(file_get_contents("php://input"),true);
		$fonction = $data["fonction"];
		$date_deb_contrat = $data["date_deb_contrat"];
		$id_conseiller = $data["id_conseiller"];
		
		$query="UPDATE administrateur SET fonction='".$fonction."', date_deb_contrat='".$date_deb_contrat."', id_conseiller='".$id_conseiller."' WHERE mle_admin=".$mle_admin;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Administrateur mis à jour avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'échec de la mise à jour de l_. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	function deleteAdministrateur($mle_admin)
	{
		global $conn;
		$query = "DELETE FROM administrateur  WHERE mle_admin=".$mle_admin;
		if(mysqli_query($conn, $query))
		{
			$response=array(
				'status' => 1,
				'status_message' =>'Administrateur supprimé avec succès.'
			);
		}
		else
		{
			$response=array(
				'status' => 0,
				'status_message' =>'La suppression de l_Administrateur a échoué. '. mysqli_error($conn)
			);
		}
		header('Content-Type: application/json');
		echo json_encode($response);
	}
	
	// Orchestration des différentes fonctions
	switch($request_method)
	{
		
		case 'GET':
			// Retrive Products
			if(!empty($_GET["mle_admin"]))
			{
				$mle_admin=intval($_GET["mle_admin"]);
				getAdministrateur($mle_admin);
			}
			else
			{
				getAdministrateurs();
			}
			break;
		default:
			// Invalid Request Method
			header("HTTP/1.0 405 Method Not Allowed");
			break;
			
		case 'POST':
			// Ajouter un produit
			AddAdministrateur();
			break;
			
		case 'PUT':
			// Modifier un produit
			$mle_admin = intval($_GET["mle_admin"]);
			updateAdministrateur($mle_admin);
			break;
			
		case 'DELETE':
			// Supprimer un produit
			$mle_admin = intval($_GET["mle_admin"]);
			deleteAdministrateur($mle_admin);
			break;

	}
?>