<?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);
        
        $user = $inputdata['user'];
        
        $nbr="";
        
        $pub=$db->prepare('SELECT COUNT(*) AS nbr FROM point_journalier WHERE user=? AND fermeture=?');
        $pub->execute(array($user,0));
        while($pubs=$pub->fetch()){
            $nbr=$pubs['nbr'];
        }
        
        if ($nbr == 0) {
            
            // la caisse n'est pas ouverte
            echo (json_encode(['response' => 0]));
        

         }else {
            // la caisse est ouverte

            echo (json_encode(['response' => 1]));

         }