<?php
require_once '../connection.php';

$enquiry_date = date("l dS M \'y");

$drg = isset($_GET['drg']) ? $_GET['drg'] : '';

if (!empty($_GET['drg'])) {
    include "../table.php";
}
?>

<!DOCTYPE html>
<html lang="en">
    <head>

        <!-- Basic Page Needs -->
        <meta charset="utf-8">
    	<meta name="viewport" content="width=device-width, initial-scale=1">
        <title><?php echo $title; ?> - Form 39 - <?php echo $street; ?> - <?php echo date("dmY"); ?></title>
        <meta name="description" content="">
        <meta name="author" content="">

        <!-- FONT -->
        <link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">

        <!-- CSS -->
        <link rel="stylesheet" href="../css/forms.css" >
        <link rel="stylesheet" href="../css/forms_print.css" media="print">

        <!-- Favicon -->
        <link rel="shortcut icon" href="../images/blueprint.ico" type="image/x-icon">

    </head>

    <body>
        <!-- Primary Page Layout -->
        <div class="container">

            <!-- !userProfile -->
            <div class="logo" style="width:50%; position:absolute;"> <img src="../images/blueprint-full-logo-medium.png" height="50px"> </div>
            <div class="quote" style="text-align:right; height:50px;"><p style="font-weight:600; font-size:5rem; color:#d6d5d5;"><?php echo $drg; ?></p></div>

            <div style="margin-top:10px;"></div>

            <!-- Form Details  -->
            <table id="top-heading" width="100%" style="border-top:3px solid black;">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td id="title" width="75%">
                            <h3>START-WORK NOTIFICATION AND <br />&ndash; AUTHORISATION – BUILDING WORK</h3>
                        </td>
                        <td id="codes" width="25%">
                            <h4>Section 99 </h4>
                            <h4>Regulation 29</h4>
                        </td>
                    </tr>
                </tbody>
            </table>

            <!-- Council Details  -->
            <table class="expand hover" width="75%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="12.5%">To:</td>
                        <td id="border" width="65%" style="font-weight:bold;"><?php echo $building_surveyor; ?> - <?php echo $bs_company; ?></td>
                        <td width="27.5%">Building Surveyor</td>
                    </tr>

                    <tr>
                        <td width="12.5%">Address:</td>
                        <td id="border" width="65%"><?php echo $bs_address; ?></td>
                        <td width="27.5%">Address</td>
                    </tr>

                    <tr>
                        <td width="12.5%">&nbsp;</td>
                        <td id="border" width="60%"><?php echo $bs_email; ?></td>
                        <td width="27.5%">Contact Details</td>
                    </tr>

                    <tr>
                        <td width="12.5%">&nbsp;</td>
                        <td id="border" width="60%"><?php echo $bs_mobile; ?></td>
                        <td width="27.5%">Phone Number</td>
                    </tr>

                </tbody>
            </table>

            <!-- Form Number  -->
            <table class="expand hover" width="25%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td style="padding: 0px;">
                            <p id="form" width="100%">Form</p>
                            <p id="formNo" width="100%">39</p>
                        </td>
                    </tr>
                </tbody>
            </table>

            <!-- Building Designer Details  -->
            <table id="heading" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="75%">
                            <h4>Building work details:</h4>
                        </td>
                        <td id="codes" width="25%">&nbsp;</td>
                    </tr>
                </tbody>
            </table>

            <br />

            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="20%">Type of work:</td>
                        <td id="border" width="5%" style="text-align: center;"><?php if ($permit_type  == '1'){echo "&#10008";}?></td>
                        <td width="20%">Permit work:</td>
                        <td id="border" width="5%" style="text-align: center;"><?php if ($permit_type == '0'){echo "&#10008";}?></td>
                        <td width="20%">Notifiable work:</td>
                        <td width="25%">(X one applicable.)</td>
                        <td width="5%">&nbsp;</td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="12.5%">Address:</td>
                        <td id="border" width="40%"><?php echo $street; ?></td>
                        <td width="22.5%" style="text-align: right;">Lot No:</td>
                        <td id="border" width="25%"><?php echo $folio; ?></td>
                    </tr>

                    <tr>
                        <td width="12.5%">&nbsp;</td>
                        <td id="border" width="40%"><?php echo $town; ?>, <?php echo $state; ?>, <?php echo $post_code; ?></td>
                        <td width="22.5%" style="text-align: right;">Certificate of title:</td>
                        <td id="border" width="25%"><?php echo $volume; ?></td>
                    </tr>

                    <tr>
                        <td width="12.5%">&nbsp;</td>
                        <td id="border" width="40%">PID: <?php echo $propertyId; ?> ( Volume: <?php echo $volume; ?> Folio: <?php echo $folio; ?> )</td>
                        <td width="22.5%" style="text-align: right;">PID:</td>
                        <td id="border" width="25%"><?php echo $propertyId; ?></td>
                    </tr>

                    <tr>
                        <td width="12.5%">The work:</td>
                        <td id="border" width="45%"><?php echo $size; ?> - <?php echo $type; ?></td>
                        <td width="22.5%" style="text-align: right;">Permit Number or Likely Compliance Number:</td>
                        <td id="border" width="20%" style="text-transform: uppercase;" class="text-uppercase"><?php echo $permit_no; ?></td>
                    </tr>
                </tbody>
            </table>

            <br />

            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="15%">Use of Building:</td>
                        <td id="border" width="50%"><?php echo $building_use; ?></td>
                        <td width="19%" style="text-align: right;">Building Class(es):</td>
                        <td id="border" width="20%"><?php echo $building_class; ?></td>
                    </tr>
                    <tr>
                        <td width="15%">&nbsp;</td>
                        <td width="50%" >&nbsp;</td>
                        <td width="19%" style="text-align: right;">Job # </td>
                        <td id="border" width="20%" style="color: red;"><?php echo $drg; ?></td>
                    </tr>
                </tbody>
            </table>

            <!-- Details of the proposed work  -->
            <table id="heading" width="100%" >
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="75%">
                            <h4>Licensed builder:</h4>
                        </td>
                        <td id="codes" width="25%">&nbsp;</td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="12.5%">Builder:</td>
                        <td id="border" width="40%"><?php echo $licenced_builder; ?></td>
                        <td width="0%">&nbsp;</td>
                        <td width="22.5%" style="text-align: right;">Category:</td>
                        <td id="border" width="25%">Medium Rise</td>
                    </tr>

                    <tr>
                        <td width="12.5%">Business:</td>
                        <td id="border" width="40%"><?php echo $lb_company; ?></td>
                        <td width="0%">&nbsp;</td>
                        <td width="22.5%" style="text-align: right;">Licence No:</td>
                        <td id="border"width="25%"><?php echo $lb_licence; ?></td>
                    </tr>

                    <tr>
                        <td width="12.5%">Address:</td>
                        <td id="border" width="40%"><?php echo $lb_address; ?></td>
                        <td width="0%">&nbsp;</td>
                        <td width="22.5%" style="text-align: right;">Phone No:</td>
                        <td id="border"width="25%"><?php echo $lb_mobile; ?></td>
                    </tr>

                </tbody>
            </table>

            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="19.5%">Accreditation No:</td>
                        <td id="border" width="23%"><?php //echo $row['39_b_accred'];?></td>
                        <td width="0%">&nbsp;</td>
                        <td width="17%" style="text-align: right;">Email Address:</td>
                        <td id="border" width="35%"><?php echo $lb_email; ?></td>
                    </tr>
                </tbody>
            </table>

            <br />

            <!-- Design Documents provided:  -->
            <table id="heading" width="100%" >
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="75%">
                            <h4>Notice details:</h4>
                        </td>
                        <td id="codes" width="25%">&nbsp;</td>
                    </tr>
                </tbody>
            </table>

            <br />

            <!-- Design Documents provided:  -->
            <table class="expand hover" width="100%" style="border-bottom: none;">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="50%" style="text-align: right;"><b>The building work detailed above is to start work on:</b></td>
                        <td contenteditable='true' id="border" width="25%" style="font-size: 15px; color:blue;"> <?php echo date('dS M Y', strtotime($install_date_start)) ;?> </td>
                        <td width="25%">Date</td>
                    </tr>
                </tbody>
            </table>


            <table class="expand hover" width="100%" style="border-bottom: none;">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="12.5%">Applicant:</td> <!-- (builder or owner builder): -->
                        <td id="border" width="28%" style="font-size: 15px; color:blue;"><?php echo $licenced_builder; ?></td>
                        <td width="1.75%"><?php //echo $row['39_SWapplicant'];?></td>
                        <td id="border" width="28%"> <img src="images/signature/<?php echo strtolower(str_replace(' ', '_', $licenced_builder)); ?>-signature.png" height="30px" /> </td>
                        <td width="1.75%"><?php //echo $row['39_SWsign'];?></td>
                        <td id="border" width="28%" style="font-size: 15px; color:blue;"><?php echo $signedDate; ?></td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%" style="border-bottom: none;">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="25%">(builder or owner builder)</td>
                        <td width="75%">&nbsp;</td>
                    </tr>
                </tbody>
            </table>

            <!-- Standards, codes or guidelines  -->
            <table id="heading" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="75%">
                            <h4>Authorisation to start building work:</h4>
                        </td>
                        <td id="codes" width="25%">&nbsp;</td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%" style="border-bottom: none;">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="100%"><p><b>Your authorisation is issued in accordance with the Building Act 2016 and Building Regulations 2016.</b></p></td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%" style="border-bottom: none;">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="20%">Building Surveyor:</td>
                        <td id="border" width="36.5%"><?php echo $building_surveyor; ?></td>
                        <td width="1.75%">&nbsp;</td>
                        <td width="20%">Date</td>
                        <td width="1.75%">&nbsp;</td>
                        <td id="border" width="20%">&nbsp;</td>
                    </tr>
                    <tr>
                        <td width="20%" height="30px">Signed:</td>
                        <td id="border" width="36.5%"></td>
                        <td width="1.75%">&nbsp;</td>
                        <td width="20%">Unique authorisation No</td>
                        <td width="1.75%"></td>
                        <td id="border" width="20%"><?php echo $permit_no; ?></td>
                    </tr>

                </tbody>
            </table>

            <table class="expand hover" width="100%" style="border-bottom: none;">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="25%">(builder or owner builder)</td>
                        <td width="75%">&nbsp;</td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%" style="border-bottom: none;">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="100%">
                            <p><b>Notes.</b></p>
                            <ul>
                                <li>A copy of this Form is to be provided to the Permit Authority within 2 working days of authorisation.</li>
                                <li>If authorisation was given orally, a copy of this form is to be provided to the applicant within 7 days.</li>
                            </ul>
                        </td>
                    </tr>
                </tbody>
            </table>

            <!-- Building Designer Details  -->
            <table id="footer" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="50%">
                            <p style="text-align:left;">Director of Building Control - approved: 1 July 2017</p>
                        </td>
                        <td width="50%">
                            <p style="text-align:right;">Building Act 2016 - Approved Form No 39</p>
                        </td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%" style="border-bottom: none;">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="100%">
                            <p class="footer" style="color:#d6d5d5;" ><?php echo $qId; ?> - [Form 39] - Document Printed on: <?php echo date("dS M Y");?> at <?php echo date("g:i A");?></p>
                        </td>
                    </tr>
                </tbody>
            </table>

        </div>

    </body>
</html>