<?php

    $request_json=$_REQUEST["data"];
    $arr = json_decode($request_json, true);
    $file_type = $arr["file_type"];
    $shop_id = $arr["shop_id"];
    $staff_id = $arr["cust_contact"];
    $data = $arr["data"];
    $date = date("Y-m-d");
    
    //include 'common/connection.php';
    $servername = "localhost";
    $username = "finstech_sales";
    $password = "SalesApp@123";
    $dbname = "finstech_salesapp";
    
    try {
      $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
      $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      $sql = "insert into master_documents (shop_id,doc_type,data_b64,staff_id,added_on) 
                values('$shop_id','$file_type','$data','$staff_id','$date')";
      $conn->exec($sql);
      echo "Success";
    } catch(PDOException $e) {
      echo $sql . "<br>" . $e->getMessage();
    }
    $conn = null;
    
?>