<?php
use yii\helpers\Url;
use common\models\User;
use yii\widgets\ActiveForm;
use qcbase\models\Auth;

/* @var $this yii\web\View */

?>
<div class="nav">
	<ul class="cc">
		<li class="current"><a href="<?= Url::to(['module/index']) ?>">模块管理</a></li>
	</ul>
</div>


<div class="table_list">
	<?php $mainForm = ActiveForm::begin([ 'id' => 'main-form', 'action' => '']); ?>
		<table width="100%">
			<thead>
				<tr>
					<td width="5%">模块ID</td>
					<td>名称</td>
					<td>简介</td>
					<td>作者</td>
					<td>版本</td>
					<td>安装时间</td>
					<td>更新时间</td>
					<td width="80" align="center">操作</td>
				</tr>
			</thead>
			<?php if (empty($modules)) : ?>
				<tr><td colspan="10" class="tac red">没有发现任何模块...</td></tr>
			<?php else : ?>
				<?php foreach ($modules as $module) : ?>
				<tr>
					<td><?= $module['id'] ?></td>
					<td><?= $module['name'] ?></td>
					<td><?= $module['description'] ?></td>
					<td><?= $module['author'] ?></td>
					<td><?= $module['version'] ?></td>
					<td><?= isset($installs[$module['id']]) ? date('Y-m-d H:i:s', $installs[$module['id']]['install_time']):'' ?></td>
					<td><?= isset($installs[$module['id']]) && !empty($installs[$module['id']]['upgrade_time']) ? date('Y-m-d H:i:s', $installs[$module['id']]['upgrade_time']) : '' ?></td>
					<td align="center" >
                        <?php if (!isset($installs[$module['id']])) : ?>
                            <a href="<?= Url::to(['module/install', 'id' => $module['id']]) ?>" >安装</a>
                        <?php elseif ($installs[$module['id']]['version'] < $module['version']) : ?>
                            <a href="<?= Url::to(['module/upgrade', 'id' => $module['id']]) ?>" >升级</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="<?= Url::to(['module/uninstall', 'id' => $module['id']]) ?>" class="link-delete red" >卸载</a>
                        <?php else : ?>
                            <a href="<?= Url::to(['module/uninstall', 'id' => $module['id']]) ?>" class="red" >卸载</a>
                        <?php endif; ?>
					</td>
				</tr>
				<?php endforeach; ?>
			<?php endif; ?>
			
		</table>
	<?php ActiveForm::end(); ?>
</div>
