<?php
require_once 'connection.php';

$drg = (int)($drg ?? 0);

$result = mysqli_query($con, " SELECT * FROM `details` WHERE drg = $drg ORDER BY drg ASC ");


if (!$result) {
    printf("Error: %s\n", mysqli_error($con));
    exit();
}

while ($row = mysqli_fetch_array($result)) {

    $firstname = $row['firstname'];
    $lastname = $row['lastname'];
    $joint_name = $row['joint_name'];
    $client_email = $row['client_email'];
    $client_mobile = $row['client_mobile'];

    $property_id = $row['property_id'];
    $title_id = $row['title_id'];
    $registered_owner = $row['registered_owner'];
    $budget_low = $row['budget_low'];
    $budget_high = $row['budget_high'];
    $finance_status = $row['finance_status'];
    $copy_title = $row['copy_title'];
    $original_plans = $row['original_plans'];
    $concepts_styles = $row['concepts_styles'];
    $loa_signed = $row['loa_signed'];
    $da_application = $row['da_application'];
    $ba_application = $row['ba_application'];
    $concepts_3d = $row['concepts_3d'];
    $draft_floorPlan = $row['draft_floorPlan'];
    $fire_report = $row['fire_report'];
    $energy_report = $row['energy_report'];
    $tender_set = $row['tender_set'];
    $quantity_survey = $row['quantity_survey'];
    $vr_concepts = $row['vr_concepts'];
    $render_set = $row['render_set'];
    $model_3d = $row['model_3d'];
    $details = $row['details'];
    $signature = $row['signature'];

	$design_style = $row['design_style'];
	$build_type = $row['build_type'];

	$council = $row['council'];
    $elevation = $row['elevation'];

	$total_area = $row['total_area'];

	$scope = $row['scope'];

	$planning_scheme = $row['planning_scheme'];
    $planning_zones = $row['planning_zones'];
	$planning_codes = $row['planning_codes'];
	$plan_data = $row['plan_data'];

	$dealId = $row['dealId'];
    $crm_id = $row['crm_id'];

	$enquiry_date = $row['enquiry_date'];


}

$result = mysqli_query($con, " SELECT * FROM `addresses` WHERE  drg = $drg ORDER BY drg ASC ");

if (!$result) {
    printf("Error: %s\n", mysqli_error($con));
    exit();
}

while ($row = mysqli_fetch_array($result)) {

    $site_address = $row['site_address'];
	$site_address_street = $row['site_address_street'];
    $site_address_town = $row['site_address_town'];
    $site_address_state = $row['site_address_state'];
    $site_address_postcode = $row['site_address_postcode'];

	$site_lat = $row['site_lat'];
	$site_lng = $row['site_lng'];

    $postal_address = $row['postal_address'];
	$postal_address_street = $row['postal_address_street'];
    $postal_address_town = $row['postal_address_town'];
    $postal_address_state = $row['postal_address_state'];
    $postal_address_postcode = $row['postal_address_postcode'];

}