<?php

    $request_json=$_REQUEST["data"];
    $arr = json_decode($request_json, true);
    $shop_id = $arr["shop_id"];
    //include 'common/connection.php';
    $servername = "localhost";
    $username = "finstech_sales";
    $password = "SalesApp@123";
    $dbname = "finstech_salesapp";
    
    
    try {
        $conn = mysqli_connect($servername,$username,$password,$dbname);
        if(!$conn)
        {
            trigger_error('Could not Connect' .mysqli_connect_error());
        }
        $sql = "select master_documents.doc_id,b2c_ustomer.name,master_shop.shop_name,master_documents.doc_type,master_documents.added_on from master_documents, master_shop, b2c_ustomer where master_shop.shop_id = master_documents.shop_id and master_documents.staff_id = b2c_ustomer.contact and master_documents.shop_id='$shop_id'";
        $result = mysqli_query($conn, $sql);
        $array = array();
        while($row=mysqli_fetch_assoc($result))
        {
            $array[] = $row;
        }
        echo'{"docs":'.json_encode($array).'}'; 
        $conn = null;
    }catch(PDOException $e) {
        echo $sql . "err" . $e->getMessage();
    }
    $pdo = null;
    
?>