<?php $__env->startSection('headCss'); ?>
    <link href="<?php echo e(asset('assets/stylesheets/jquery.fancybox.css')); ?>" rel="stylesheet" type="text/css">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('headJs'); ?>
    <script src="<?php echo e(asset('assets/javascripts/jquery.fancybox.js')); ?>"></script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <div class="col-xs-12">
        <div class="col-xs-offset-3 col-xs-6">
            <div class="col-xs-4">
                <img src="<?php echo e(asset('assets/images/logo.png')); ?>" height="80px"/>
            </div>
            <div class="col-xs-8">
                Willow Park, Wash Road Basildon Essex SS15 4AZ<br/>T: 01268 531099<br/>W: www.rnwholdings.com
            </div>
        </div>
    </div> <!-- / .header -->
    <div class="col-xs-12">
        <hr/>
    </div>

    <div class="panel-body">
        <div class="col-xs-12">
            <div class="col-xs-6 ">
                <form>
                    <div class="row form-group">
                        <label class="col-xs-4 control-label">Quotation Ref:</label>

                        <div class="col-xs-8">
                            <input type="text" id="updateCustomerRef" class="form-control"
                                   value="<?php echo e($quotation['quotationRef']); ?>"/>
                        </div>
                    </div>
                    <div class="row form-group">
                        <label class="col-xs-4 control-label">Job:</label>

                        <div class="col-xs-8">
                            <input id="updateQuotationJob" class="form-control" value="<?php echo e($quotation['jobId']); ?>"/>
                        </div>
                    </div>
                    <div class="row form-group">
                        <label class="col-xs-4 control-label">Customer Ref:</label>

                        <div class="col-xs-8">
                            <input type="text" id="updateCustomerRef" class="form-control"
                                   value="<?php echo e($quotation['customerRef']); ?>"/>
                        </div>
                    </div>
                    <div class="row form-group">
                        <label class="col-xs-4 control-label">Quotation Date:</label>

                        <div class="col-xs-8">
                            <input type="text" id="updateQuotationDate"
                                   value="<?php echo e(date('Y-m-d H:i:s', strtotime($quotation['quotationDate']))); ?>"
                                   class="form-control"/>
                        </div>
                    </div>
            </div>
            <div class="col-xs-6">
                <div class="row form-group">
                    <label class="col-xs-4 control-label">Quotation Type:</label>

                    <div class="col-xs-8">
                        <input type="text" id="updateQuotationType" class="form-control"
                               value="<?php echo e($quotation['quotationType']); ?>"/>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-xs-4 control-label">Lead-in Time:</label>

                    <div class="col-xs-8">
                        <input type="text" id="updateLeadInTime" class="form-control"
                               value="<?php echo e($quotation['leadInTime']); ?>"/>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-xs-4 control-label">Work duration:</label>

                    <div class="col-xs-8">
                        <input type="text" id="updateWorkDuration" class="form-control"
                               value="<?php echo e($quotation['workDuration']); ?>"/>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-xs-4 control-label">Discipline:</label>

                    <div class="col-xs-8">
                        <input type="text" id="updateDiscipline" class="form-control"
                               value="<?php echo e($quotation['discipline']); ?>"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="col-xs-6">
                <div class="row form-group">
                    <label class="col-xs-4 control-label">Client Name:</label>

                    <div class="col-xs-8">
                        <input type="text" id="updateSiteName" class="form-control"
                               value="<?php echo e($quotation['clientName']); ?>"/>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-xs-4 control-label">Building Name:</label>

                    <div class="col-xs-8">
                        <input type="text" id="updateSiteName" class="form-control"
                               value="<?php echo e($quotation['siteName']); ?>"/>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-xs-4 control-label">Building address:</label>

                    <div class="col-xs-8">
                                    <textarea type="text" id="updateSiteAddress" rows="4" class="form-control"
                                              value="<?php echo e($quotation['siteAddress']); ?>"><?php echo e($quotation['siteAddress']); ?></textarea>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="row form-group">
                    <label class="col-xs-4 control-label">Out of hours work required:</label>

                    <div class="col-xs-8">
                        <input type="text" id="updateOutOfHoursWork" class="form-control"
                               value="<?php echo e($quotation['outOfHoursWork']); ?>"/>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-xs-4 control-label">We require another discipline contractor for
                        these works:</label>

                    <div class="col-xs-8">
                        <input type="text" id="updateDisciplineContractor" class="form-control"
                               value="<?php echo e($quotation['disciplineContractor']); ?>"/>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-xs-12">
            <h4>Work detail</h4>

            <p>
                <?php foreach($workDetailLines as $aLine): ?>
                    <?php echo e($aLine); ?><br/>
                <?php endforeach; ?>
            </p>
        </div>

        <div class="col-xs-12">
            <h4>Quotes</h4>

            <div class="table-striped">
                <table cellpadding="0" cellspacing="0" border="0" class="table table-striped">
                    <thead>
                    <tr>
                        <th>Quantity</th>
                        <th>Name</th>
                        <th>Unit Price</th>
                        <th>Mark up &percnt;</th>
                        <th>Unit Time</th>
                        <th>Type</th>
                        <th>Description</th>
                        <th>Line Total (£)</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($quotationItems as $quotationItem): ?>
                        <tr>
                            <td><?php echo e($quotationItem['itemQuantity']); ?></td>
                            <td><?php echo e($quotationItem['itemName']); ?></td>
                            <td>&pound; <?php echo e($quotationItem['itemUnitPrice']); ?></td>
                            <td><?php echo e($quotationItem['itemUnitMargin']); ?> &percnt;</td>
                            <td><?php echo e($quotationItem['itemDuration']); ?></td>
                            <td><?php echo e($quotationItem['itemType']); ?></td>
                            <td><?php echo e($quotationItem['itemDescription']); ?></td>
                            <td>&pound; <?php echo e(number_format($quotationItem['itemTotalPrice'],2)); ?></td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="col-xs-12 text-right">
            <h4><b>Quotation Total: &pound; <?php echo e(number_format($quotation['quotationTotal'], 2)); ?></b></h4>
        </div>

        <div class="col-xs-12">
            <h4>General qualifications to this offer</h4>
            <p>
                <?php foreach($generalQualificationsLines as $aLine): ?>
                    <?php echo e($aLine); ?><br/>
                <?php endforeach; ?>
            </p>
        </div>

        <div class="col-xs-12">
            <hr/>
        </div>

        <div class="col-xs-12">
            <?php foreach($beforeImages as $beforeImage): ?>
                <?php if(!empty($hideConflict)): ?>
                    <div class="col-xs-2 text-center">
                        <img src="<?php echo e(url($beforeImage, $parameters = [], $secure = null)); ?>" class="col-xs-12"/>
                        <p class="col-xs-12" style="overflow-wrap: break-word"><?php echo e(basename(url($beforeImage, $parameters = [], $secure = null))); ?></p>
                    </div>
                <?php else: ?>
                    <a href="<?php echo e(url($beforeImage, $parameters = [], $secure = null)); ?>" class="fancybox">
                        <div class="col-xs-2 text-center">
                            <img src="<?php echo e(url($beforeImage, $parameters = [], $secure = null)); ?>" class="col-xs-12"/>
                            <p class="col-xs-12" style="overflow-wrap: break-word"><?php echo e(basename(url($beforeImage, $parameters = [], $secure = null))); ?></p>
                        </div>
                    </a>
                <?php endif; ?>
            <?php endforeach; ?>
        </div>

        <div class="col-xs-12">
            <hr/>
        </div>

        <div class="col-xs-12">
            <h4>Special Terms</h4>

            <p>
                <?php foreach($additionalTermsLines as $aLine): ?>
                    <?php echo e($aLine); ?><br/>
                <?php endforeach; ?>
            </p>
        </div>

        <div class="col-xs-12">
            <hr/>
        </div>

        <div class="col-xs-12">
            I trust that we have interpreted your requirements correctly. Should you indeed require any further
            information or assistance, please do not hesitate to contact me.
        </div>

        <div class="col-xs-12">
            <br/>
            Yours Sincerely<br/>
            <b><?php echo e($quotation['creator']); ?></b><br/>
            <b><?php echo e($quotation['creatorEmail']); ?></b>
        </div>

        <div class="col-xs-12">
            <br/>
        </div>

        <div class="col-xs-12 list-group-item">
            <div class="panel-body">
                <h4>Your decision on this quotation</h4>

                <?php if(empty($quotation['status']) || $quotation['status']=='AWAITING' || $quotation['status']=='QUOTED'): ?>
                    <div class="row form-group form-inline col-xs-12">
                        <input type="checkbox" class="form-control" id="agreementCheckBox"/>
                <span>
                    * I agree with the terms and condition above and wish to continue with this quotation with the following
                    status.
                </span>
                    </div>

                    <div class="col-xs-12">
                        <div class="col-xs-6">
                            <input type="text" class="form-control" id="printName" placeholder="Enter your name"
                                   value="<?php echo e($quotation['printName']); ?>"/>
                        </div>
                        <div class="col-xs-6">
                            <select id="quotationStatus" data-placeholder="Select a decision" class="form-control">
                                <option value="" selected disabled>Select a decision</option>
                                <option value="APPROVED" <?php echo e($quotation['status']=='APPROVED'?'selected':''); ?>>APPROVE
                                </option>
                                <option value="DECLINED" <?php echo e($quotation['status']=='DECLINED'?'selected':''); ?>>DECLINE
                                </option>
                            </select>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <br/>
                    </div>
                    <div class="col-xs-12">
                        <textarea id="clientNote" placeholder="Please leave a note if you wish." rows="4"
                                  class="form-control"></textarea>
                    </div>
                    <div class="col-xs-12">
                        <br/>
                    </div>
                    <div class="col-xs-12">
                        <a class="btn btn-primary form-control" id="clientQuotationUpdateButton">Confirm Decision and Submit</a>
                    </div>
                <?php else: ?>
                    <div class="col-xs-12">
                        <div class="col-xs-6">
                            <input type="text" class="form-control" id="printName" placeholder="Enter your name"
                                   value="<?php echo e($quotation['printName']); ?>" disabled/>
                        </div>
                        <div class="col-xs-6">
                            <select id="quotationStatus" data-placeholder="Select a decision" class="form-control"
                                    disabled>
                                <option value="" selected disabled>Select a decision</option>
                                <option value="APPROVED" <?php echo e($quotation['status']=='APPROVED'?'selected':''); ?>>APPROVE
                                </option>
                                <option value="DECLINED" <?php echo e($quotation['status']=='DECLINED'?'selected':''); ?>>DECLINE
                                </option>
                            </select>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <br/>
                    </div>
                    <div class="col-xs-12">
                        <textarea id="clientNote" placeholder="Please leave a note if you wish." rows="4"
                                  class="form-control" disabled><?php echo e($quotation['clientNote']); ?></textarea>
                    </div>
                <?php endif; ?>

            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('footerJs'); ?>
    <script type="text/javascript">
        $('body').css("background-color", "#ffffff");
        $('.demo-logo').css("background-color", "#ffffff");

        if ($('#clientQuotationUpdateButton').length > 0) {
            $('#clientQuotationUpdateButton').click(function () {
                if ($('#agreementCheckBox').is(':checked')) {
                    if ($('#printName').val() != '' && $('#quotationStatus').val() != null) {
                        loadingOverlay();
                        $.post('<?php echo e(URL::action("ApiClientController@feedbackQuotation")); ?>', {
                            quotationId: '<?php echo e($quotation["id"]); ?>',
                            printName: $('#printName').val(),
                            clientNote: $('#clientNote').val(),
                            status: $('#quotationStatus').val()
                        }).done(function (data) {
                            loadingRemove();
                            $("#printName").prop('disabled', true);
                            $("#clientNote").prop('disabled', true);
                            $("#quotationStatus").prop('disabled', true);
                            new PNotify({
                                title: 'Feedback Successfully',
                                text: 'We will deal with this case as soon as possible!',
                                type: 'success',
                                icon: 'fa fa-check',
                                hide: false
                            });
                        }).fail(function (data) {
                            loadingRemove();
                            new PNotify({
                                title: 'Feedback Failed',
                                text: 'Please check your network connection!',
                                type: 'error',
                                icon: 'fa fa-times',
                                hide: false
                            });
                        });
                    } else {
                        new PNotify({
                            title: 'Feedback not completed',
                            text: 'Please re-check your input!',
                            type: 'error',
                            icon: 'fa fa-times',
                            hide: false
                        });
                    }
                } else {
                    new PNotify({
                        title: 'Agreement need to be checked',
                        text: 'You must agree with our terms and conditions to process further!',
                        type: 'error',
                        icon: 'fa fa-times',
                        hide: false
                    });
                }
            });
        }

        if ($('.fancybox').length > 0) {
            $('.fancybox').fancybox({
                openEffect: 'fade',
                closeEffect: 'fade'
            });
        }
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.center_plain', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>