<h4 class="mb-4"><i class="fas fa-cog fa-spin me-2"></i><?= lang('admin.system_jobs') ?></h4>
<div class="card"><div class="card-body">
    <table id="jobs-table" class="table table-striped w-100" data-url="/admin/jobs/datatable"
           data-columns='[{"data":"code"},{"data":"name"},{"data":"type"},{"data":"active"},{"data":"last_run"},{"data":"last_status"},{"data":"runs"},{"data":"actions","orderable":false}]'>
        <thead><tr><th>Code</th><th>Name</th><th>Type</th><th>Status</th><th>Last Run</th><th>Result</th><th>Runs</th><th>Actions</th></tr></thead>
    </table>
</div></div>
<?php $__view->push('scripts') ?>
<script>
DataTableHelper.init('jobs-table',{paging:false});
$(document).on('click','.btn-toggle-job',function(){$.post('/admin/jobs/'+$(this).data('id')+'/toggle',{_token:'<?= csrf_token() ?>'},function(r){if(r.success){FormHelper.showToast('success',r.message);DataTableHelper.reload('jobs-table');}else FormHelper.showToast('error',r.message);},'json');});
$(document).on('click','.btn-run-job',function(){if(!confirm('Run this job now?'))return;const btn=$(this);btn.prop('disabled',true).html('<i class="fas fa-spinner fa-spin"></i>');$.post('/admin/jobs/'+$(this).data('id')+'/run',{_token:'<?= csrf_token() ?>'},function(r){btn.prop('disabled',false).html('<i class="fas fa-bolt"></i>');if(r.success){FormHelper.showToast('success',r.message);DataTableHelper.reload('jobs-table');}else FormHelper.showToast('error',r.message);},'json');});
</script>
<?php $__view->endPush() ?>