File: /var/www/html/owlcrm/storage/framework/views/93662a4addb592e5f95236c71e56e06d.php
<?php $__env->startSection('title', 'OWL CRM Dashboard'); ?>
<?php $__env->startSection('content_header'); ?>
<h1>Task</h1>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<?php if(session('error')): ?>
<h6 class="alert alert-danger">
<?php echo e(session('error')); ?>
</h6>
<?php endif; ?>
<?php if($errors->any()): ?>
<div class="alert alert-danger">
<ul>
<?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<li><?php echo e($error); ?></li>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</ul>
</div>
<?php endif; ?>
<div class="row justify-content-between mb-5">
<div class="col-auto">
<a href="<?php echo e(route('task.index')); ?>" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Back to Task
</a>
</div>
<div class="col-auto">
</div>
<div class="col-auto">
<a href="<?php echo e(route('task.edit', $task->id)); ?>" class="btn btn-primary">
<i class="fas fa-pencil-alt"></i> Edit Task
</a>
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#delete">
<i class="fa fa-trash-alt"></i> Delete Task
</button>
<div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success mt-2">
<input
type="checkbox"
class="custom-control-input toggle-status"
id="paymentSwitch<?php echo e($task->id); ?>"
onchange="updatePaymentStatus(<?php echo e($task->id); ?>, this)"
<?php echo e($task->payment_status ? 'checked disabled' : ''); ?>>
<label class="custom-control-label" for="paymentSwitch<?php echo e($task->id); ?>">
<?php echo e($task->payment_status ? 'Payment Done' : 'Mark as Done'); ?>
</label>
</div>
</div>
</div>
<div class="row">
<!-- Left Column: Task Information -->
<div class="col-12 col-md-6">
<div class="card card-dark">
<div class="card-header">
<h3 class="card-title">Task Information</h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse">
<i class="fas fa-minus"></i>
</button>
</div>
</div>
<div class="card-body">
<ul class="list-group list-group-flush">
<li class="list-group-item"><b>subject:</b>
<?php echo e($task->subject); ?></li>
<li class="list-group-item"><b>Start Date:</b> <?php echo e(formatDate($task->start_date, 'Y/m/d H:i:s')); ?>
</li>
<li class="list-group-item"><b>Due Date:</b> <?php echo e(formatDate($task->due_date, 'Y/m/d H:i:s')); ?></li>
<li class="list-group-item"><b>Priority:</b> <?php echo e($task->priority); ?></li>
<li class="list-group-item"><b>Assigned To:</b>
<?php echo e($task->user->first_name && $task->user->last_name ? $task->user->first_name . $task->user->last_name : 'n/a'); ?>
</li>
<li class="list-group-item"><b>Created By:</b>
<?php echo e($task->created_by_user->first_name && $task->created_by_user->last_name ? $task->created_by_user->first_name . $task->created_by_user->last_name : 'n/a'); ?>
</li>
<li class="list-group-item"><b>Entity Type:</b> <?php echo e($task->entity_type); ?></li>
<li class="list-group-item"><b>State:</b> <?php echo e($task->state); ?></li>
<li class="list-group-item"><b>Status:</b> <?php echo e($task->status == 0 ? 'in-active' : 'active'); ?></li>
</ul>
</div>
</div>
</div>
<div class="col-12 col-md-6">
<div class="card card-dark">
<div class="card-header">
<h3 class="card-title">Task Additional Information</h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse">
<i class="fas fa-minus"></i>
</button>
</div>
</div>
<div class="card-body">
<hr>
<!-- Add Comment Form -->
<form action="<?php echo e(route('comments.store', $task->id)); ?>" method="POST" class="mt-3">
<?php echo csrf_field(); ?>
<div class="form-group">
<textarea name="comment" id="comment" class="form-control" rows="3" placeholder="Add your comment..." required=" this field is required"></textarea>
</div>
<div class="text-right">
<button type="submit" class="btn btn-primary btn-sm">
<i class="fa fa-paper-plane"></i> Submit Comment
</button>
</div>
</form>
<?php $__errorArgs = ['comment'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger">
<strong><?php echo e($message); ?></strong>
</span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
<h5><b>Comments:</b></h5>
<ul class="list-group list-group-flush" id="commentsList">
<?php $__currentLoopData = $task->comments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $comment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<li class="list-group-item px-0">
<div class="comment-box">
<p><i class="fas fa-user mr-2"></i><strong><?php echo e($comment->user->first_name); ?> <?php echo e($comment->user->last_name); ?></strong>
<span class="text-muted">(<?php echo e($comment->created_at->format('Y/m/d H:i:s')); ?>)</span></p>
<p><?php echo e($comment->comment); ?></p>
</div>
</li>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</ul>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><?php echo e($task->name); ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>This will delete this task permanently</p>
<p>Are you sure?</p>
</div>
<div class="modal-footer">
<form method="POST" action="<?php echo e(route('task.destroy', $task->id)); ?>">
<?php echo csrf_field(); ?>
<input type="hidden" name="_method" value="DELETE">
<button type="submit" class="btn btn-danger" id="delete_btn">Yes, Delete</button>
</form>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('css'); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
<script type="text/javascript" >
$(document).on('change', '.toggle-status', function() {
// alert('ngkjhgkljgkjg');
const $this = $(this); // Save reference to the toggle switch
const taskId = $this.data('id');
const isChecked = $this.is(':checked');
const statusLabel = $this.siblings('label');
if (!confirm(`Are you sure you want to ${isChecked ? 'mark as done' : 'mark as not done'}?`)) {
$this.prop('checked', !isChecked); // Revert the change
return;
}
$.ajax({
url: '/task/' + taskId + '/update-payment-status', // Update the route here
method: 'POST',
data: {
_token: '<?php echo e(csrf_token()); ?>',
payment_status: paymentStatus
},
success: function(response) {
console.log(response);
if (response.success) {
// Update the label based on the payment status
$(checkbox).next('label').text(paymentStatus ? 'Payment Done' : 'Mark as Done');
} else {
alert('Failed to update payment status. Please try again.');
}
},
error: function(xhr, status, error) {
console.log(xhr.responseText); // Log any errors from the server
alert('An error occurred. Please try again.');
}
});
});
$(document).ready(function () {
$('#commentForm').on('submit', function (e) {
e.preventDefault();
// Get the task ID
let taskId = "<?php echo e($task->id); ?>";
let comment = $('#comment').val();
let token = $('input[name="_token"]').val();
// Clear previous error
$('#commentError').addClass('d-none').text('');
$.ajax({
url: `/comments/store/${taskId}`,
type: 'POST',
data: {
_token: token,
comment: comment,
},
success: function (response) {
if (response.success) {
// Clear the textarea
$('#comment').val('');
// Append the new comment to the list
$('#commentsList').append(`
<li class="list-group-item px-0">
<div class="comment-box">
<p><i class="fas fa-user mr-2"></i>
<strong>${response.data.user_id}</strong>
<span class="text-muted">(${new Date(response.data.created_at).toLocaleString()})</span>
</p>
<p>${response.data.comment}</p>
</div>
</li>
`);
}
},
error: function (xhr) {
if (xhr.responseJSON && xhr.responseJSON.errors && xhr.responseJSON.errors.comment) {
$('#commentError').removeClass('d-none').text(xhr.responseJSON.errors.comment[0]);
} else {
console.log("An error occurred", xhr);
}
}
});
});
});
console.log("Hi, I'm using the Laravel-AdminLTE package!");
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('adminlte::page', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/owlcrm/resources/views/users/task/show.blade.php ENDPATH**/ ?>