<?php
ini_set('display_errors', 1);
// file used to validate book combinations in files
function GetBasicBook($specific_db_conn, $workspace_id, $company_id, $branch_id, $book_id)
{
  $data1 = array();
  $sql = "SELECT act.*,companies.id,companies.company_name,companies.company_address,branch_info.* FROM act_books AS act 
        JOIN companies_info AS companies on act.company_id = companies.id
        JOIN branch_info ON act.branch_id = branch_info.id where act.workspace_id =? and act.company_id =? and branch_id = ? and act.id = ?";
  $stmt = $specific_db_conn->prepare($sql);
  $stmt->execute(array($workspace_id, $company_id, $branch_id, $book_id));
  $result = $stmt->fetchAll();

  if (count($result) == 1) {

    $data1 = array(
      'book_basic_info' => array(
        'book_name' => $result[0]['name'],
        'company_name' => $result[0]['company_name'],
        'company_address' => $result[0]['company_address'],
        'branch_name' => $result[0]['branch_name'],
        'email' => $result[0]['email'],
        'contact_number' => $result[0]['contact_number'],
        'branch_gst' => $result[0]['branch_gst'],
        'branch_address' => $result[0]['branch_address'],
        'adl_email' => $result[0]['adl_email'],
        'adl_contact_number' => $result[0]['adl_contact_number'],
        'website' => $result[0]['website'],
        'base_currency_symbol' => $result[0]['base_currency_symbol'],

        'currency_format' => $result[0]['currency_format'],
        'number_of_decimal_places' => $result[0]['number_of_decimal_places'],
        'book_opening_date' => $result[0]['book_opening_date'],
        'book_closing_date' => $result[0]['book_closing_date'],
        'financial_year_startdate' => $result[0]['financial_year_startdate']
      )
    );
  }
  return $data1;
}
