<?php

use iwbvel\classes\services\scheduler\model\Schedule_Job;
use iwbvel\classes\services\scheduler\Job_Presenter;

if (!defined('ABSPATH')) exit; // Exit if accessed directly 

if (!empty($schedule_jobs)):
    $iwbvel_i = 1;
    foreach ($schedule_jobs as $iwbvel_job):
?>
        <tr>
            <td><?php echo intval($iwbvel_i); ?></td>
            <td><?php echo esc_html($iwbvel_job->label); ?></td>
            <td><?php echo wp_kses_post(Job_Presenter::schedules($iwbvel_job)); ?></td>
            <td><?php echo wp_kses_post(Job_Presenter::status($iwbvel_job->status)); ?></td>
            <td>
                <button <?php echo !defined('IWBVE_ACTIVE') ? 'disabled="disabled"' : ''; ?> type="button" class="iwbvel-schedule-jobs-list-action-button" data-id="<?php echo esc_attr($iwbvel_job->id); ?>" data-action="show_edit_items" data-toggle="modal" data-target="#iwbvel-modal-schedule-job-edit-items" title="<?php esc_html_e('Edit Items', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?>"><i class="iwbvel-icon-list1"></i></button>

                <?php if ($iwbvel_job->status == Schedule_Job::PENDING): ?>
                    <button type="button" class="iwbvel-schedule-jobs-list-action-button" data-id="<?php echo esc_attr($iwbvel_job->id); ?>" data-action="edit" data-toggle="modal" data-target="#iwbvel-modal-schedule-edit-job" title="<?php esc_attr_e('Edit', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?>"><i class="iwbvel-icon-edit"></i></button>
                <?php else: ?>
                    <button type="button" class="iwbvel-schedule-jobs-list-action-button" data-id="<?php echo esc_attr($iwbvel_job->id); ?>" data-action="log" data-toggle="modal" data-target="#iwbvel-modal-schedule-job-log" title="<?php esc_attr_e('Log', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?>"><i class="iwbvel-icon-file-text1"></i></button>
                <?php endif; ?>
                <button type="button" class="iwbvel-schedule-jobs-list-action-button" data-id="<?php echo esc_attr($iwbvel_job->id); ?>" data-action="delete" title="<?php esc_attr_e('Delete Job', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?>"><i class="iwbvel-icon-trash-2"></i></button>
                <?php if ($iwbvel_job->status == Schedule_Job::RUNNING): ?>
                    <button type="button" class="iwbvel-schedule-jobs-list-action-button" data-id="<?php echo esc_attr($iwbvel_job->id); ?>" data-action="stop" title="<?php esc_attr_e('Stop Now', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?>"><i class="iwbvel-icon-stop-circle"></i></button>
                <?php endif; ?>
            </td>
        </tr>
    <?php
        $iwbvel_i++;
    endforeach;
else:
    ?>
    <tr>
        <td colspan="100%">No Data Available!</td>
    </tr>
<?php
endif;
?>