<?php

require_once('functions.php');

?>
<!DOCTYPE html>
<html>

<head>
    <title>NEXUS</title>
    <link rel="shortcut icon" href="../img/favicon.ico" type="image/x-icon">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <!-- Needed from JT -->
    <link rel="stylesheet" href="css/protected.css?v=<?php echo $h_version; ?>">
    <link href="css/jquerysctipttop.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="css/font-awesome-4.7.0/css/font-awesome.min.css">

    <script src="js/jquery-3.3.1.min.js"></script>
    <link rel="stylesheet" href="css/bootstrap.css">
    <script src="js/bootstrap.js"></script>
    <link rel="stylesheet" href="css/style.css?v=<?php echo time(); ?>">
    <script src="js/custom.js?v=<?php echo time(); ?>"></script>
    
    <script src="js/dataTables.min.js"></script>
    <script src="jquery-ui/jquery-ui.min.js"></script>
    <script src="js/jquery.serialize-object.min.js"></script>
    <script src="js/isat_manuals.js?v=<?php echo time(); ?>"></script>
    <script src="js/pdfobject.js"></script>

    <style>
        .sticky-on-top-header {
            top: 87px;
            left: 85px;
            width: 64%;
            z-index: 3;
            background-color: white;
            padding: 0px 0px 15px 0px;
        }

        .sticky-on-top {
            top: 90px;
            left: 67%;
        }

        .table-row {
            padding-top: 21px;
        }

        .table-header-row {
            padding-top: 148px;
        }

        .table-fixed tbody {
            display: block;
            height: 400px;
            overflow-y: auto;
        }

        .table-fixed tr {
            display: block;
        }

        .table-fixed thead>tr>th {
            float: left;
        }

        .proj_info_toggle {
            margin-left: 30px;
            font-size: 14px;
            cursor: pointer;
        }

        .d-inline {
            display: inline-block !important;
        }

        .job-id-margin {
            margin-left: 809px;
        }

        .file-tree-icon {
            position: relative;
            display: table-cell;
            width: 24px;
            height: 24px;
            text-align: center;
            vertical-align: middle;
            font-size: 20px;
            margin: 0px 18px;
        }

        .file-invoice-icon {
            width: 29%;
            margin-left: 36%;
            margin-top: 10%;
            margin-bottom: 10%
        }
    </style>
</head>

<body style="overflow-x: hidden;">
    <div class="main-div" style='font-size: 110%;'>
        <div class='container-fluid mt-4 ml-2' style="margin-top: 180px !important;">
            <div class="row">
                <div class="col-8">
                    <div class='row sticky-on-top-header position-fixed'>
                        <div class='col'>
                            <div class="d-inline">
                                <b id='manual_selection_toggle' class='manual_selection_toggle' data-shown='1'><i class="fa fa-angle-double-down sdf"></i> Manual Selection</b>
                            </div>
                            <div id="isat_manual_selection_expandable">
                                <div class='row text-left' style="margin-top:8px;" id="isat_manual_bcode_options">
                                    <div class='col-sm-4'>
                                        <div class='box_with_text'>
                                            <p class='boxes_text' style='width: 20px'>IBC</p>
                                            <?php
                                            
                                            $api_data = [];
                                            $api_data = [
                                                'token' => $token,
                                                'function' => 'get_bcodes',
                                                'bcode' => '%IBC%',
		                                        'fetch_type' => 'All'
                                            ];
                                            $data = APIcall($api_url, $api_data);
                                            ?>
                                            <table>
                                                <tr>
                                                    <td class='text-left'><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[0]['code']}'> {$data[0]['code']}" ?></td>
                                                    <td class='text-right'><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[1]['code']}'> {$data[1]['code']}" ?></td>

                                                </tr>
                                                <tr>
                                                    <td class='text-left'><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[2]['code']}'> {$data[2]['code']}" ?></td>
                                                    <td class='text-right'><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[3]['code']}'> {$data[3]['code']}" ?></td>
                                                </tr>
                                                <tr>
                                                    <td class='text-left'><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[4]['code']}'> {$data[4]['code']}" ?></td>
                                                    <td class='text-right'><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[5]['code']}'> {$data[5]['code']}" ?></td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                    <div class='col-sm-4'>
                                        <div class='box_with_text'>
                                            <p class='boxes_text' style='width: 24px'>CBC</p>
                                            <?php
                                            $api_data = [];
                                            $api_data = [
                                                'token' => $token,
                                                'function' => 'get_bcodes',
                                                'bcode' => '%CBC%',
                                                'NOT' => 'OSHPD',
		                                        'fetch_type' => 'All'
                                            ];
                                            $data = APIcall($api_url, $api_data);

                                            ?>
                                            <table>
                                                <tr>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[0]['code']}'> {$data[0]['code']}" ?></td>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[1]['code']}'> {$data[1]['code']}" ?></td>

                                                </tr>
                                                <tr>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[2]['code']}'> {$data[2]['code']}" ?></td>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[3]['code']}'> {$data[3]['code']}" ?></td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[4]['code']}'> {$data[4]['code']}" ?></td>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[5]['code']}'> {$data[5]['code']}" ?></td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                    <div class='col-sm-4'>
                                        <div class='box_with_text' style='height: 100%'>
                                            <p class='boxes_text' style='width: 29px;'>HCAi</p>
                                            <?php
                                                // $stmt = $db->prepare("SELECT DISTINCT code_folder FROM ceasatta_cost_calculator.hcai_isat_manual_index
                                                //                 WHERE code_folder NOT LIKE '%All Codes%'
                                                //                 ORDER BY code_folder DESC LIMIT 6");
                                                // $stmt->execute();
                                                // $data = $stmt->fetchAll();

                                                $api_data = [];
                                                $api_data = [
                                                    'token' => $token,
                                                    'function' => 'distinct_hcai_index',
                                                    'bcode' => 'IBC'
                                                ];
                                                $data = APIcall($api_url, $api_data);
                                            ?>
                                            <table>
                                                <tr>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[0]['code_folder']}'> {$data[0]['code_folder']}" ?></td>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[1]['code_folder']}'> {$data[1]['code_folder']}" ?></td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                    <div class='col-sm-3' style="display: none;">
                                        <div class='box_with_text'>
                                            <p class='boxes_text' style='width: 68px'>CBC OSHPD</p>
                                            <?php
                                            $api_data = [];
                                            $api_data = [
                                                'token' => $token,
                                                'function' => 'get_bcodes',
                                                'bcode' => '%OSHPD%',
		                                        'fetch_type' => 'All'
                                            ];
                                            $data = APIcall($api_url, $api_data);

                                            ?>
                                            <table>
                                                <tr>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[0]['code']}'> {$data[0]['code']}" ?></td>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[1]['code']}'> {$data[1]['code']}" ?></td>

                                                </tr>
                                                <tr>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[2]['code']}'> {$data[2]['code']}" ?></td>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[3]['code']}'> {$data[3]['code']}" ?></td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[4]['code']}'> {$data[4]['code']}" ?></td>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[5]['code']}'> {$data[5]['code']}" ?></td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                    <div class='col-sm-3' style="display: none;">
                                        <div class='box_with_text'>
                                            <p class='boxes_text' style='width: 30px'>LABC</p>
                                            <?php
                                            $api_data = [];
                                            $api_data = [
                                                'token' => $token,
                                                'function' => 'get_bcodes',
                                                'bcode' => '%LABC%',
		                                        'fetch_type' => 'All'
                                            ];
                                            $data = APIcall($api_url, $api_data);
                                           
                                            ?>
                                            <table>
                                                <tr>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[0]['code']}'> {$data[0]['code']}" ?></td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[1]['code']}'> {$data[1]['code']}" ?></td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo "<input type='radio' name='bcode[]' class='chk_bcode' value='{$data[2]['code']}'> {$data[2]['code']}" ?></td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                                <br>
                                <div class='box_with_text' id="isat_manual_select_options">
                                    <div class='row p-4'>
                                        <div class='col-1'>
                                            <input type='checkbox' class='setion_select_all'> Select All
                                        </div>
                                        <div class='col-4'>
                                            <?php
                                            $values = array("Introduction", "A SERIES - LAYOUT GUIDELINES OFFSETS AND SETBACKS", "B SERIES - SEISMIC RESTRAINT INSTALLATION DETAILS");
                                            foreach ($values as $val) {
                                                echo "<div class='p-1'><input type='checkbox' class='section' value='$val'> $val</div>";
                                            }
                                            ?>
                                        </div>
                                        <div class='col-4'>
                                            <?php
                                            $values = array("D Series - BRACE ARM ANCHORAGE DETAILS", "E Series - SEISMIC RESTRAINT BRACE ARM ASSEMBLIES", "F Series - ISAT SEISMIC RESTRAINT HARDWARE");
                                            foreach ($values as $val) {
                                                echo "<div class='p-1'><input type='checkbox' class='section' value='$val'> $val</div>";
                                            }
                                            ?>
                                        </div>
                                        <div class='col-3'>
                                            <?php
                                            $values = array("G Series - VERTICAL SUPPORT SYSTEMS", "H Series - GENERAL HARDWARE", "X Series - REFERENCE DOCUMENTS", "R Series - ROOFTOP SUPPORTS");
                                            foreach ($values as $val) {
                                                echo "<div class='p-1'><input type='checkbox' class='section' value='$val'> $val</div>";
                                            }
                                            ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class='row mt-4' id="table_filter_selectios">
                                <div class='col-3 col-offset-3'>
                                    <input type='text' class='form-control keyword' placeholder='Keyword Search'>
                                    <span style='right: 25px;' class="searchclear">X</span>
                                </div>
                                <div id='select_all_mobile' class='col-1 text-center' style="margin-left: 152px;"><input type='checkbox' class='table_select_all' value='Select All'> Select All</div>
                                <div id='filter_selected_mobile' class='col-2 text-center'><input type='checkbox' class='table_filter_selected' value='Filter Selected'> Filter Selected</div>
                                <div id='show_linked_details_mobile' class='col-2 text-center'><input type='checkbox' class='table_show_linked' value='Show Linked Details'> Show Linked Details</div>
                            </div>
                        </div>
                    </div>

                    <div class='row mt-1 table-header-row' id="table-header-row" style="padding-top: 187px;">
                        <div class='col'>
                            <table id="table_fixed_header" class='table table-bordered table-striped position-fixed' style="width: 63%;">
                                <thead>
                                    <tr>
                                        <th style="width: 109px;">Detail No.</th>
                                        <th style="width: 454px;">Description</th>
                                        <th style="width: 122px;">Select</th>
                                        <!-- <th style="width: 133px;">Include Calcs</th> -->
                                    </tr>
                                </thead>
                            </table>
                        </div>
                    </div>

                    <div class='row mt-4 table-row'>
                        <div class='col-8'>
                            <table id='file_table' class='table table-bordered table-striped position-fixed table-fixed' style="width:63%;">

                                <tbody>

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class='col-4 text-center sticky-on-top position-fixed'>
                    <div id='include_linked_detail_mobile' class='row text-center'>
                        <div class='col-2 text-center'><button id='download_button_mobile' class='btn btn-success download_files download_files_only' style="width:113px;">Download</button></div>
                        <div style="margin-left: 40px; margin-top: 5px;"><input type='checkbox' class='details_select' value='Include Linked Detail'></div>
                        <div style="margin-left: 10px; margin-top: 3px;">Include Linked Details in Download</div>
                    </div>
                    <div id='download_row_mobile' class='row mb-1'>
                        <div class='col-1 text-right'><i class="fa fa-arrow-left change_preview" data-inc=-1></i></div>
                        <div id='preview_selected_mobile' class='col-4 text-center'>Preview Selected</div>
                        <div id='change_preview_mobile' class='col-1 text-left'><i class="fa fa-arrow-right change_preview" data-inc=1></i></div>
                    </div>
                    <!--<embed id="pdf_preview" src="">-->
                    <div id="pdf_preview"></div>
                </div>
            </div>

        </div>
    </div>
    <script src='js/sticky-table-headers.js?v=1' type='text/javascript'></script>

</body>

</html>