<?php 
	if (isset($_GET['paged'])) {
		$paged = $_GET['paged'] == 0 ? 1 : $_GET['paged'];
	} else {
		$paged = 1;
	}
	$tasklist = $data->TaskList($paged);
?>
<table class="wp-list-table widefat plugins">
	<thead>
	<tr>
		<td id="cb" class="manage-column column-cb check-column"><label class="screen-reader-text" for="cb-select-all-1">全选</label><input id="cb-select-all-1" type="checkbox"></td>
		<th scope="col" class="manage-column column-name column-primary">任务名称</th>
		<th scope="col" class="manage-column column-description">信息</th>
		<th scope="col" class="manage-column column-description">本次更新</th>
		<th scope="col" class="manage-column column-description">历史更新</th>
		<th scope="col" class="manage-column column-description">操作</th>
	</tr>
	</thead>

	<tbody id="the-list" class="ctspider-list">
	<?php if (!empty($tasklist)) : foreach ($tasklist as $key => $value) :?>
		<tr class="<?php echo $value['state'] == 1 ? 'active' : '' ?> <?php echo 'task-'.$value['id'] ?>">
			<th scope="row" class="check-column">
				<label class="screen-reader-text">选择项目</label><input type="checkbox" name="checked[]" value="revslider/revslider.php">
			</th>
			<td class="plugin-title column-primary">
				<strong><?php echo $value['basic']['task_name'] ?></strong>
				<div class="row-actions visible">

					<span class="activate">
						<a task-id="<?php echo $value['id'] ?>" task-state="<?php echo $value['state'] ?>" class="state" href="javascript:void(0);"><?php echo $value['state'] == 1 ? '暂停' : '启动'; ?></a> | </span>
					<span class="activate"><a href="<?php echo admin_url('admin.php?page=ctspider/wp-ctspider-index.php&id='.$value["id"].'&state=edit') ?>" class="edit">编辑</a> | </span>
					<span class="activate"><a task-id="<?php echo $value['id'] ?>" href="javascript:void(0);" class="delete">删除</a></span>
				</div>
			</td>
			<td class="column-description desc">
				<div class="plugin-description">
					<?php if (!empty($data->LogOne($value['id']))) : ?>
					<p><strong>最新文章 </strong>: <a target="black" class="ct-title" href="<?php echo get_permalink($data->LogOne($value['id'])['post_id']); ?>"><?php echo $data->LogOne($value['id'])['title'] ?></a></p>
					<?php 
						else :
							echo '<p><strong><a target="black" class="ct-title">'.__('暂无数据').'</a></strong></p>';
						endif; 
					?>
				</div>
				<div class="active second plugin-version-author-uri"><strong>上次检测 </strong>: <span class="ct-time"><?php echo gmdate('m-d H:i:s',$value['update_time']) ?></span></div>
			</td>

			<td class="column-description">
				<div class="plugin-description"><p><strong class="update_num"><?php echo $value['update_num'] ?></strong> 篇</p></div>
			</td>

			<td class="column-description">
				<div class="plugin-description"><p><strong class="ct-count"><?php echo $value['post_count'] ?></strong> 篇</p></div>
			</td>

			<td class="column-description">
				<div class="plugin-description ct-update"><p><button class="layui-btn layui-btn-sm <?php echo $value['state'] == 1 ? '' : 'layui-btn-disabled'; ?>" task-id="<?php echo $value['id'] ?>" ><i class="layui-icon layui-anim layui-anim-rotate layui-anim-loop layui-hide">&#xe63d;</i> <span><?php echo $value['state'] == 1 ? '更新' : '已暂停'; ?></span></button></p></div>
			</td>
									
		</tr>  
		<?php endforeach; endif; ?>
	</tbody>
</table>
<?php 
	
?>
<?php if (empty($tasklist)) {
	echo '<a href="'.admin_url('admin.php?page=ctspider/wp-ctspider-index.php').'" class="layui-btn layui-btn-lg layui-btn-normal empty"><i class="layui-icon">&#xe61f;</i> 创建项目</a>';
	return false;
} ?>