<div class="table-striped">
    <table cellpadding="0" cellspacing="0" border="0" class="table table-striped">
        <thead>
        <tr>
            <th></th>
            <th>Quantity</th>
            <th>Name</th>
            <th>Unit Price (/Hour/£)</th>
            <th>Hours</th>
            <th>Line Total (£)</th>
            <th>Description</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach($quotationItems as $quotationItem): ?>
            <tr>
                <td>
                    <a onclick="javascript:showDeleteQuotationItem('<?php echo e($quotationItem['id']); ?>')"><i class="fa fa-minus"></i></a>
                    <a id="deleteQuotationItem<?php echo e($quotationItem['id']); ?>" onclick="javascript:deleteQuotationItemEngineer('<?php echo e(URL::action("QuotationController@deleteQuotationItem")); ?>', '<?php echo e($quotationItem['id']); ?>', '<?php echo e(csrf_token()); ?>')">Confirm?</a>
                </td>
                <td><?php echo e($quotationItem['itemQuantity']); ?></td>
                <td><?php echo e($quotationItem['itemName']); ?></td>
                <td><?php echo e($quotationItem['itemUnitPrice']); ?></td>
                <td><?php echo e($quotationItem['itemDuration']); ?></td>
                <td><?php echo e($quotationItem['itemTotalPrice']); ?></td>
                <td><?php echo e($quotationItem['itemDescription']); ?></td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>

<script type="text/javascript">
    if($('a[id^="deleteQuotationItem"]').length>0) {
        $('a[id^="deleteQuotationItem"]').hide();
    }

    function showDeleteQuotationItem(id) {
        $('#deleteQuotationItem'+id).show();
    }

    function deleteQuotationItemEngineer(url, quotationItemId, csrToken) {
        loadingOverlay();
        $.post(url, {
            quotationItemId: quotationItemId,
            _token: csrToken
        }).done(function(data){
            loadingRemove();
            new PNotify({
                title: 'Success',
                text: 'Item deleted successfully!',
                type: 'success',
                icon: 'fa fa-check'
            });
            calculateQuotationLabourSubTotal('<?php echo e(URL::action("QuotationController@calculateQuotationLabourSubTotal")); ?>', $('#addQuotationId').val(), '<?php echo e(csrf_token()); ?>');
            calculateQuotationTotal('<?php echo e(URL::action("QuotationController@calculateQuotationTotal")); ?>', $('#addQuotationId').val(), '<?php echo e(csrf_token()); ?>');
            generateQuotationItemEngineer('<?php echo e(URL::action("QuotationController@generateQuotationItemEngineer")); ?>', $('#addQuotationId').val(), csrToken);
        }).fail(function(data){
            loadingRemove();
            new PNotify({
                title: 'Fail',
                text: 'Item deleting failed!',
                type: 'error',
                icon: 'fa fa-times'
            });
        });
    }
</script>