<?php $__env->startSection('main-body'); ?>
<div class="container-fluid">
    <div class="page-header">
        <div class="row">
            <div class="col-sm-12">
                <h3>Tagline Management</h3>
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="/">Dashboard</a></li>
                    <li class="breadcrumb-item active"><a href="/taglines">Taglines</a></li>
                </ol>
                <?php if($loggedUser->can('create-taglines')): ?>
                <span class="pull-right"><?php echo Html::decode(link_to_Route('taglines.create', '<i class="fa fa-plus"></i> Create Tagline', [], ['class' => 'btn btn-primary'])); ?></span>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12">
            <div class="card">
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-styling" id="tagline-list">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Tagline</th>
                                    <th class="text-center">Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $taglines; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tagline): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td style="max-width: 10%" class="text-center"><?php echo $tagline->id; ?></td>
                                    <td><?php echo $tagline->tagline; ?></td>
                                    <td  style="width: 30%" class="text-center">
                                        <?php echo Form::open(array('route'=>array('taglines.destroy',$tagline->id),'class'=>'d-flex justify-content-around align-items-center','method'=>'DELETE','id'=>'tagline-remove-form-'.$tagline->id)); ?>

                                            <?php if($loggedUser->can('update-taglines')): ?>
                                            <?php echo Html::decode(link_to_Route('taglines.edit','<i class="fa fa-pencil"></i> <span class="d-none d-md-inline"> Edit</span>', $tagline->id, array('class' => 'm-auto text-dark ', 'type' => 'button'))); ?>

                                            <?php endif; ?>
                                            <?php if($loggedUser->can('view-taglines')): ?>
                                            <a href="#" class="m-auto text-dark" type="button" id="<?php echo e($tagline->id); ?>" onclick="viewDetails(this)"><i class="fa fa-eye"></i> <span class="d-none d-md-inline"> View</span></a>
                                            <?php endif; ?>
                                            <?php if($loggedUser->can('delete-taglines')): ?>
                                            <a href="#" class="m-auto text-dark" type="button" id="<?php echo e($tagline->id); ?>" onclick="taglineDelete(this)"><i class="fa fa-trash"></i> <span class="d-none d-md-inline"> Delete</span></a>
                                            <?php endif; ?>
                                        <?php echo Form::close(); ?>

                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php if($loggedUser->can('view-taglines')): ?>
<div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="confirmation" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-md" role="document">
        <div class="modal-content">
            <div class="modal-body" style="padding-left: 50px; padding-top:50px;">
                <div class="row">
                    <h4>tagline Details</h4>
                </div>
                <div class="row p-t-30">
                    <div class="col-lg-12">
                        <div class="form-group">
                            <label>ID: <span id="tagline-id-d"></span></label> <br/>
                            <label>tagline Name: <span id="tagline-name-d"></span></label>
                        </div>
                    </div>
                </div>

                <div class="form-group m-t-30">
                    <span class="pull-right">
                        <?php if($loggedUser->can('update-taglines')): ?>
                        <button type="button" class="btn btn-primary" id="detailsEditBtn" onclick="taglineEdit(this)">Edit</button>
                        <?php endif; ?>
                        <?php if($loggedUser->can('delete-taglines')): ?>
                        <button type="button" class="btn btn-danger" id="detailsDeleteBtn" onclick="taglineDelete(this)">Delete</button>
                        <?php endif; ?>
                        <button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button>
                    </span>
                </div>
            </div>
        </div>
    </div>
</div>
<?php endif; ?>
<?php echo $__env->make('modals.confirmation', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page-script'); ?>

function viewDetails(elem) {
$.ajax({
url: '/taglines/'+elem.id+'/get-tagline-details',
method: 'GET',
success: function(result){
console.log(result);
$('#tagline-id-d').html(result.id);
$('#tagline-name-d').html(result.tagline);

$('#detailsEditBtn').val(result.id);
$('#detailsDeleteBtn').val(result.id);

$('#detailsModal').modal('show');
}
});
}

function taglineEdit(elem) {
window.location.replace('/taglines/'+elem.value+'/edit');
}

function taglineDelete(elem) {
let taglineId = elem.value > 0 ? elem.value : elem.id;

$('#confirmation-title').html("Delete");
$('#confirmation-body').html("Are you sure you want to delete this tagline? This process cannot be undone." );

$('#submit-btn').html('Delete');
$('#submit-btn').removeClass('btn-primary');
$('#submit-btn').addClass('btn-danger');
$('#submit-btn').val(taglineId);

$('#detailsModal').modal('hide');

$('#confirmationModal').modal('show');
}

function submitForm(elem) {
let taglineId = elem.value;

console.log('PROF == ', taglineId);
$.ajax({
url: '/taglines/'+taglineId+'/get-tagline-details',
method: 'GET',
success: function(result){
console.log(result);

if (result.length > 0) {
$('#info-title').html("Unsuccessful");
$('#info-body').html("Unable delete tagline. This tagline are used by one or more users");

$('#confirmationModal').modal('hide');
$('#infoModal').modal('show');
} else {
$('#tagline-remove-form-'+taglineId).submit();
}
}
});
}

<?php echo $__env->make('notifications.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/qa/desxpert-admin/resources/views/taglines/index.blade.php ENDPATH**/ ?>