<?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 71a - <?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"> <img src="../images/blueprint-full-logo-medium.png" height="50px"> </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>STANDARD OF WORK CERTIFICATE – BUILDING WORK</h3>
                        </td>
                        <td id="codes" width="25%">
                            <h4>Section 103 </h4>
                            <h4>Section 151</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>

                </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%">71a</p>
                        </td>
                    </tr>
                </tbody>
            </table>

            <!-- Details of the Builder  -->
            <table id="heading" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="75%">
                            <h4>Builder details:</h4>
                        </td>
                        <td id="" 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;">Project reference No.</td>
                        <td id="border" width="25%">Bison Job # <span style="color: red;"><?php echo $qId; ?></span></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>

                    <tr>
                        <td width="12.5%">&nbsp;</td>
                        <td id="border" width="40%"><?php //echo $row['39_b_state'];?></td>
                        <td width="0%">&nbsp;</td>
                        <td width="22.5%" style="text-align: right;">Fax No:</td>
                        <td id="border"width="25%"><?php //echo $row['39_b_fax'];?></td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="14.5%">Category:</td>
                        <td id="border" width="30%">Builder - Medium Rise</td>
                        <td width="0%">&nbsp;</td>
                        <td width="12.5%" style="text-align: right;">Email Address:</td>
                        <td id="border" width="42%"><?php echo $lb_email; ?></td>
                    </tr>

                </tbody>
            </table>

            <br />

            <!-- Details of the Owner  -->
            <table id="heading" width="100%" >
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="75%"><h4>Owner details:</h4></td>
                        <td id="" width="25%">&nbsp;</td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="75%" style="font-style: italic;">Note: Copy <b>Must</b> be forwarded to Owner</td>
                        <td id="" width="25%">&nbsp;</td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="12.5%">Owner:</td>
                        <td id="border" width="88%">
                            <?php echo $propertyOwner; ?>
                        </td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="12.5%">Business:</td>
                        <td id="border" width="40%">
                            <?php echo $propertyName ; ?>
                        </td>
                        <td width="0%">&nbsp;</td>
                        <td width="22.5%" style="text-align: right;">Phone No:</td>
                        <td id="border" width="25%">
                            <?php echo $client_mobile; ?>
                        </td>
                    </tr>

                    <tr>
                        <td width="12.5%">Address:</td>
                        <td id="border" width="40%">
                            <?php echo $propertyAddress; ?>
                        </td>
                        <td width="0%">&nbsp;</td>
                        <td width="22.5%" style="text-align: right;">Fax No:</td>
                        <td id="border" width="25%">
                            <?php //echo $row['39_b_fax'];?>
                        </td>
                    </tr>

                </tbody>
            </table>

            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="14.5%">&nbsp;</td>
                        <td width="20%">
                        </td>
                        <td width="0%">&nbsp;</td>
                        <td width="22.5%" style="text-align: right;">Email Address:</td>
                        <td id="border" width="42%">
                            <?php echo $client_email; ?>
                        </td>
                    </tr>

                </tbody>
            </table>

            <br />

            <!-- Building Designer Details  -->
            <table id="heading" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="75%">
                            <h4>Details of Building work:</h4>
                        </td>
                        <td id="" 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="25%" style="text-align: right;">Certificate of Likely Compliance Number:</td>
                        <td id="border" width="25%"><?php echo strtoupper(str_replace('_', '/', $compliance_no)); ?></td>
                        <td width="25%" style="text-align: right;">Permit or Certificate of Likely Compliance Number:</td>
                        <td id="border" width="25%" class="text-uppercase"><?php echo strtoupper(str_replace('_', '/', $permit_no )); ?></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 $site_address; ?></td>
                        <td width="22.5%" style="text-align: right;">Lot No:</td>
                        <td id="border" width="25%"><?php echo str_replace('_', '/', $volumeId) ; ?></td>
                    </tr>

                    <tr>
                        <td width="12.5%">&nbsp;</td>
                        <td id="border" width="40%"></td>
                        <td width="22.5%" style="text-align: right;">PID:</td>
                        <td id="border" width="25%"><?php echo $propertyId; ?></td>
                    </tr>
                </tbody>
            </table>

            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="12.5%">The work:</td>
                        <td id="border" width="87.5%">Proposed new <?php echo $size; ?> ( Approximately <?php echo ($length * $width ); ?>m2 ) - <?php echo $type; ?></td>
                    </tr>
                </tbody>
            </table>

            <br>
            <table class="expand hover" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="12.5%">Use of building:</td>
                        <td id="border" width="40%"><?php echo $type; ?></td>
                        <td width="22.5%" style="text-align: right;">Building Class(es):</td>
                        <td id="border"width="25%"><?php echo $building_class; ?></td>
                    </tr>
                </tbody>
            </table>

            <!-- Standards, codes or guidelines  -->
            <table id="heading" width="100%">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="75%">
                            <h4>Builder Standard of Work Statement:</h4>
                        </td>
                        <td id="" 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>I confirm I am the <span style="font-style: italic;">Licensed Builder</span> responsible for the construction and supervision of the above referenced project. Having supervised and/or carried out the building work, I confirm that:</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><b>Notes.</b></p>
                            <ul>
                                <li>(a) all building work is complete; and</li>
                                <li>(b) all directions given under the Building Act 2016 and Building Regulations 2016 have been complied with; and</li>
                                <li>(c) the building work as constructed is in compliance with the National Construction Code, the approved plans, specifications and conditions of the Certificate of Likely Compliance (or a Building Permit) granted for the work</li>
                            </ul>
                        </td>
                    </tr>
                </tbody>
            </table>

            <?php
            $result = mysqli_query($con, " SELECT * FROM `council_forms` WHERE quote = " . $client_quote . "  AND form_type = 'F71a' ORDER BY date ASC");
            if (!$result) {
                printf("Error: %s\n", mysqli_error($con));
                exit();
            }
            while ($row = mysqli_fetch_array($result)) {
                $signedDate = date('d M Y', strtotime($row['date']));
            }
            ?>
            <table class="expand hover" width="100%" style="border-bottom: none;">
                <thead></thead>
                <tbody width="100%">
                    <tr>
                        <td width="12.5%">Builder:</td>
                        <!-- (builder or owner builder): -->
                        <td id="border" width="28%" style="font-size: 19px; color:blue;">
                            <?php echo $licenced_builder; ?>
                        </td>
                        <td width="1.75%"></td>
                        <td id="border" width="28%" height="40px">
                            <div class="signature"> <img src="images/signature/<?php echo strtolower(str_replace(' ', '_', $licenced_builder)); ?>-signature.png" height="40px" /> </div>
                        </td>
                        <td width="1.75%"></td>
                        <td id="border" width="28%" style="font-size: 19px; 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="100%">
                            <p class="footer">
                                <?php echo $qId; ?> - [Form 71a] - Document Printed on: <?php echo date("dS M Y");?> at <?php echo date("g:i A");?>
                            </p>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

        <!-- End Document -->
    </body>
</html>