<?php if($quotationTableType=='job'): ?>
    <div class="panel panelOverFlow">
        <div class="table-striped">
            <table cellpadding="0" cellspacing="0" border="0" class="table table-striped"
                   id="quotationJobsTable">
                <thead>
                <tr>
                    <th>id</th>
                    <th>Client</th>
                    <th>Building</th>
                    <th>Engineer</th>
                    <th>Type</th>
                    <th>Discipline</th>
                    <th>Status</th>
                    <th>Deadline</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach($quotationJobs as $job): ?>
                    <tr>
                        <td>
                            <a onclick="javascript:generateDashboardJobDetail('<?php echo e(URL::action("JobController@generateJobDetail")); ?>', '<?php echo e($job["id"]); ?>', '<?php echo e(csrf_token()); ?>')"><?php echo e($job['id']); ?></a>
                        </td>
                        <td><?php echo e($job['client']); ?></td>
                        <td><?php echo e($job['building']); ?></td>
                        <td><?php echo e($job['engineers']); ?></td>
                        <td><?php echo e($job['jobType']); ?></td>
                        <td><?php echo e($job['discipline']); ?></td>
                        <td><?php echo e($job['status']); ?></td>
                        <td><?php echo e(date('d/m/Y', strtotime($job['expectStartTime']))); ?></td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>

    <script type="text/javascript">
        var quotationJobsTable =
                $('#quotationJobsTable')
                        .dataTable({
                            bAutoWidth: true,
                            "aoColumns": [
                                {"bSortable": true},
                                {"bSortable": true},
                                {"bSortable": true},
                                {"bSortable": true},
                                {"bSortable": true},
                                {"bSortable": true},
                                {"bSortable": true},
                                {"sType": "date-uk"}
                            ],
                            "aaSorting": [],
                            "iDisplayLength": 10
                        });
        $('#breachJobsTable_wrapper .table-caption').text('Jobs');
        $('#breachJobsTable_wrapper .dataTables_filter input').attr('placeholder', 'Search...');

        function generateDashboardJobDetail(url, id, csrToken) {
            loadingOverlay();
            $.post(url, {
                id: id,
                _token: csrToken
            }).done(function (data) {
                loadingRemove();
                $('#dashboardDetailModalContent').html(data);
                $('#dashboardDetailPanel').modal('show');
            }).fail(function (data) {
                loadingRemove();
                new PNotify({
                    title: 'Reading detail failed!',
                    text: '',
                    type: 'error',
                    icon: 'fa fa-times'
                });
            });
        }

    </script>
<?php endif; ?>

<?php if($quotationTableType=='quotation'): ?>
    <div class="panel panelOverFlow">
        <table cellpadding="0" cellspacing="0" border="0" class="table table-striped"
               id="quotationsTable">
            <thead>
            <tr>
                <th>Quotation Ref</th>
                <th>Client</th>
                <th>Building</th>
                <th>Total £</th>
                <th>Creator</th>
                <th>Date</th>
                <th>Status</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach($quotationJobs as $quotation): ?>
                <tr>
                    <td><a onclick="javascript:generateDashboardQuotationDetail('<?php echo e(URL::action("QuotationController@generateQuotationDetail")); ?>', '<?php echo e($quotation["id"]); ?>', '<?php echo e(csrf_token()); ?>')"><?php echo e($quotation['quotationRef']); ?></a>
                    </td>
                    <td><?php echo e($quotation['clientName']); ?></td>
                    <td><?php echo e($quotation['siteName']); ?></td>
                    <td><?php echo e($quotation['quotationTotal']); ?></td>
                    <td><?php echo e($quotation['creator']); ?></td>
                    <td><?php echo e(date('Y-m-d', strtotime($quotation['quotationDate']))); ?></td>
                    <td><?php echo e($quotation['status']); ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>

    <script type="text/javascript">
        var quotationTable =
                $('#quotationsTable')
                        .dataTable({
                            bAutoWidth: true,
                            "bPaginate": true,
                            "aoColumns": [
                                {"bSortable": true},
                                {"bSortable": true},
                                {"bSortable": true},
                                {"bSortable": true},
                                {"bSortable": true},
                                {"bSortable": true},
                                {"bSortable": true}
                            ],
                            "aaSorting": [],
                            "iDisplayLength": 10
                        });
        $('#quotationsTable_wrapper .table-caption').text('Quotations');
        $('#quotationsTable_wrapper .dataTables_filter input').attr('placeholder', 'Search...');

        function generateDashboardQuotationDetail(url, quotationId, csrToken) {
            loadingOverlay();
            $.post(url, {
                quotationId: quotationId,
                _token: csrToken
            }).done(function (data) {
                loadingRemove();
                $('#dashboardDetailModalContent').html(data);
                $('#dashboardDetailPanel').modal('show');
            }).fail(function (data) {
                loadingRemove();
                new PNotify({
                    title: 'Reading detail failed!',
                    text: '',
                    type: 'error',
                    icon: 'fa fa-times'
                });
            });
        }
    </script>
<?php endif; ?>
