<?php $__env->startSection('jsPageBottom'); ?>
<script>
    var activeRequest;
    $('.popover-content').popover();
    $('.popover-content').mouseover(function () {

        var order = $(this).data('order');
        
        $('div.popover table').append("<tr id='loader'><td colspan='3' class='col-popover-table-popover'></td><td class='col-popover-table-popover'><div class='loading-spinner'></div></td><td class='col-popover-table-popover'></td></tr>");
        setTimeout(function () {
            if ($('div.popover').length === 1) {
                console.log(order);

                $.ajax({
                    url: "<?php echo route('order.lien.getSearchstatusdue'); ?>/" + order,
                    dataType: 'json',
                    type: 'get',
                    cache: false,
                    beforeSend: function (xhr) {
                        if (activeRequest)
                            activeRequest.abort();

                        activeRequest = xhr;
                    },
                    success: function(result, textStatus, jqXHR) {
//                        console.log(result);
                        if ($('div.popover').length === 1) {
                            
                            var tr = "";
                            $.each(result, function(key, data){
                                tr += "<tr>";
                                tr += "<td class='col-popover-table-popover'>";
                                tr += (data.CompletedOn!=null)?"<input id='popover-checkbox' type='checkbox' name='received' id='received' checked/>":"&nbsp";
                                tr += "</td>";
                                tr += (data.ViolationCount>0)?"<td class='col-popover-table-popover' style='color:red;'>":"<td class='col-popover-table-popover'>";
                                tr += data.SearchTypeShortDesc;
                                tr += "</td>";
                                tr += "<td class='col-popover-table-popover'>";
                                tr += data.date;
                                tr += "</td>";
                                tr += "</tr>";
                            });
                            
                            console.log(tr);
                            $('div.popover table tr#loader').remove();
                            $('div.popover table').append(tr);
                        }
                    },
                })

            }
        }, 500);

    });
</script>
<?php echo HTML::script('admin/template/js/lien.index.js'); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('pageContent'); ?>

<div id="center-body">
    <div id="title-background">
        <div id="title-body-check-status">
            <div id="title-check-lien">CHECK STATUS LIEN</div>
            <p class="href-text-right-body-check-lien">If your order was placed BEFORE the 7th of January 2012, <a id="href-text-right-body-check-lien" class="click-here" href="<?php echo URL::route('order.lienhoaboth.index'); ?>">click here</a> to check status of your order.</p><br>
            <p>SEARCH</p>
        </div>
    </div>
    <div id="container-center-check-status">
        <div id="container-form-check-status">
            <div id="column" class="row">
                <?php echo Form::open(['route'=>'order.lien.postindex']); ?>

                <div class="col-sm-3">
                    <p>File Number: </p>
                    <?php echo Form::text('file_number', Input::old('file_number'), ['id'=>"file_number", 'class'=>"form-control"]); ?>

                    <?php /* Form::select('file_number', ["" => "Select"] + ($file_number), Input::old('file_number'), ['id'=>"file_number", 'class'=>"form-control"]) */ ?>
                </div>
                <div class="col-sm-4">
                    <p>Address:</p>
                    <?php echo Form::select('address', ["" => "Select"] + $properties, Input::old('address'), ['id'=>"address", 'class'=>"form-control"]); ?>

                </div>
                <div class="col-md-1">
                    <p>&nbsp;</p>
                    <button id="button-submit-form" name="button-submit-form" type="submit" class="btn btn-default go">GO</button>
                </div>
                <?php echo Form::close(); ?>

            </div>
        </div>
        <div id="show-table">
            <div id="show-table">
                <span id="block" style="<?php echo (isset($orders))?'display:block':'display:none'; ?>">
                    <table class="table table-striped table-bordered table-hover chek-lien" id="table-results">
                        <thead>
                            <tr>
                                <th id="table-top"> <?php echo HTML::link_to_sorting_action('OrderDate', 'Date / Requested'); ?></th>
                                <th id="table-top"> <?php echo HTML::link_to_sorting_action('IsUpdateOrder', 'Order Type'); ?></th>
                                <th id="table-top"> <?php echo HTML::link_to_sorting_action('FileNo', 'File'); ?></th>
                                <th id="table-top"> <?php echo HTML::link_to_sorting_action('StreetNo', 'Address'); ?></th>
                                <th id="table-top"> <?php echo HTML::link_to_sorting_action('CountyID', 'County'); ?></th>
                                <th id="table-top"> <?php echo HTML::link_to_sorting_action('OrderStatusID', 'Status'); ?></th>
                                <th id="table-top"> <?php echo HTML::link_to_sorting_action('OrderCompletedDate', 'Completed Date'); ?></th>
                                <th id="table-top">Download</th>
                                <th id="table-top">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if(isset($orders)): ?>
                            <?php if(sizeof($orders)): ?>
                            <?php foreach($orders as $order): ?>
                            <tr>
                                <td id=""><?php echo $order->requestDate(); ?></td>
                                <td id=""><?php echo ($order->IsUpdateOrder==0)? 'Lien':'Lien Update'; ?></td>
                                <td id=""><?php echo $order->FileNo; ?></td>
                                <td id=""><?php echo $order->Property->StreetNo; ?> <?php echo $order->Property->StreetDirectionName(); ?> <?php echo $order->Property->StreetName; ?> <?php echo $order->Property->StreetTypeName(); ?><br/> <?php echo $order->Property->StreetUnitNo; ?>, <?php echo $order->Property->City->CityName; ?>, <?php echo $order->Property->City->State()->StateCode; ?> <?php echo $order->Property->ZipCode; ?></td>
                                <td id=""><?php echo $order->Property->County->CountyName; ?></td>
                                <td id=""><?php /* dd($order->getOrderSearchAssignment()) */ ?>
                                    <!-- STATUS --><div class='status'>
                                        <?php if($order->OrderStatusID == LienOrderStatus::COMPLETED): ?>
                                        Completed
                                        <?php elseif($order->OrderStatusID != LienOrderStatus::COMPLETED && $order->OrderStatusID != LienOrderStatus::CANCEL): ?>
                                        <a class="popover-content" tabindex="0" data-order="<?php echo $order->OrderID; ?>" data-toggle="popover" data-trigger="hover"  data-content="<?php if($order->OrderStatusID!=LienOrder::ORDERCOMPLETE): ?> <?php echo $__env->make('site.modal-windows.check-lien-popup', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?> <?php endif; ?>">
                                            <?php echo 'Pending<br>View Status'; ?>

                                        </a>
                                        <?php elseif($order->OrderStatusID == LienOrderStatus::CANCEL): ?>
                                        <a class="popover-content" tabindex="0"  data-toggle="popover" data-trigger="hover">Cancelled</a>
                                        <?php endif; ?>                                        
                                    </div>
                                </td>
                                <td align="center"><?php echo $order->getOrderCompletedDate(); ?></td>
                                <?php if($order->OrderStatusID == LienOrderStatus::COMPLETED): ?>
                                <td id=""> <a target="_blank" href="<?php echo route('order.lien.download', [Crypt::encrypt($order->OrderID)]); ?>">Download</a></td>
                                <?php else: ?>
                                <td id="" width="97"> <a href="mailto:status@onesteplien.com?Subject=Check Status: - FileNo - <?php echo $order->FileNo; ?>, Address - <?php echo $order->Property->StreetNo; ?> <?php echo $order->Property->StreetDirectionName(); ?> <?php echo $order->Property->StreetName; ?> <?php echo $order->Property->StreetTypeName(); ?> <?php echo $order->Property->StreetUnitNo; ?>, <?php echo $order->Property->City->CityName; ?>, <?php echo $order->Property->City->State()->StateCode; ?> <?php echo $order->Property->ZipCode; ?>">Contact Us</a></td>
                                <?php endif; ?>
                                <th width="60">
                                    <?php if($order->OrderStatusID == LienOrderStatus::COMPLETED && $pending->count()==0): ?>
                                    <?php echo HTML::linkRoute('order.lien.edit', 'Update', [$order->OrderID]); ?>

                                    <?php elseif($order->OrderStatusID == LienOrderStatus::COMPLETED && $pending->count() > 0): ?>
                                    &nbsp;
                                    <?php elseif($order->OrderStatusID == LienOrderStatus::CANCEL): ?>
                                    <?php echo HTML::linkRoute('order.lien.create', 'Reactivate', [$order->OrderID], array('class' => 'reactivateLien')); ?>

                                    <?php else: ?>
                                    <?php echo HTML::linkRoute('order.lien.cancel', 'Cancel', [$order->OrderID]); ?>

                                    <?php endif; ?>
                                </th>
                            </tr>
                            <?php endforeach; ?>
                            <?php else: ?>

                            <?php endif; ?>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </span>
            </div>
        </div>
        <?php if(isset($orders)): ?>
        <?php echo $orders->links(); ?>

        <?php endif; ?>
    </div>
</div>
<?php echo $__env->make('helpers.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('helpers.base', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>