<?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);
        
        $numCmd = $inputdata['numCmd'];
        
        require('php-example/mecef.php');
        
        //$emcf_qr_code = $inputdata['emcf_qr_code'];
        //$emcf_date = $inputdata['emcf_date'];
        //$emcf_code_me_ce_fdgi = $inputdata['emcf_code_me_ce_fdgi'];
        //$emcf_counters = $inputdata['emcf_counters'];
        //$emcf_nim = $inputdata['emcf_nim'];
      
 

            $user=$db->prepare('INSERT INTO facturation (num_cmd, emcf_qr_code, emcf_date, emcf_code_me_ce_fdgi, emcf_counters, emcf_nim) VALUES(?,?,?,?,?,?)');

            $req_user = $user->execute(array($numCmd, $qr_code, $date_time, $code_me_ce_fdgi, $counters, $nim));
            
            //$req_user = $user->execute(array($numCmd, 1, 1, 1, 1, 1));

            if ($req_user) {
                //création réussie
                
                echo (json_encode(['response' => 1]));
                
                /*echo (json_encode([
                    'qr_code' => $qr_code, 
                    'dat'=> $date_time,
                    'code_me_ce_fdgi' => $code_me_ce_fdgi,
                    'counters' => $counters,
                    'nim' => $nim
                    ]));*/



            }else{
                // création non réussie

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

                

            }


        