<?php
session_start();
    header('Access-Control-Allow-Origin:*');
    header('Content-Type; application/json; charset=utf-8');
    header('Access-control-Allow-Method: POST');
    header('Access-control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-request-With');
    include('db.php');
        $inputdata = json_decode(file_get_contents("php://input"), true);
        
        $deb = $inputdata['deb'];
        $fin = $inputdata['fin'];
        
        //$deb1=DateTime::createFromFormat('d/m/Y', $deb)->format('Y-m-d 00:00:00');
        
        //$fin1=DateTime::createFromFormat('d/m/Y', $fin)->format('Y-m-d 23:59:59');
        
        $pub=$db->prepare('SELECT stock_repas.*, repas.nom, prix_repas.designation, prix_repas.qte_stock, tbl_user.username FROM prix_repas, repas, stock_repas, tbl_user WHERE stock_repas.prix_repas=prix_repas.id AND prix_repas.repas=repas.id AND tbl_user.id=stock_repas.user AND stock_repas.datt BETWEEN ? AND ? AND stock_repas.valid=? ORDER BY stock_repas.id DESC');
        $pub->execute(array($deb,$fin,1));
        $image = $pub->fetchAll();    
        echo(json_encode(['data' => $image]));