<?php
if ($rs['table']) foreach ($rs['table'] as $key => $tval) {
    $tbn = $tval['table'];
?>
    <div id="apps-add-<?php echo $key; ?>-field" class="app-table-list tab-pane">
        <?php if (DB::hasTable($tbn)) { ?>
            <table class="table table-sm table-hover table-bordered">
                <thead class="thead-dark">
                    <tr>
                        <th style="width:100px;">字段</th>
                        <th>数据类型</th>
                        <th>长度</th>
                        <th>主键</th>
                        <th>非空</th>
                        <th>Unsigned</th>
                        <th>自增</th>
                        <th>核对</th>
                        <th>注释</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    $fullFields  = AppsTable::fullFields($tbn);
                    foreach ((array) $fullFields as $field => $value) {
                    ?>
                        <tr>
                            <td field="<?php echo $field; ?>"><b><?php echo $field; ?></b></td>
                            <td><?php echo $value['type']; ?></td>
                            <td><?php echo $value['length']; ?></td>
                            <td><?php if ($value['primary']) { ?>
                                    <font color="green"><i class="fa fa-fw fa-check"></i></font>
                                <?php } ?></td>
                            <td><?php echo $value['null'] ? 'NULL' : 'NOT NULL'; ?></td>
                            <td><?php echo strtoupper($value['unsigned']); ?></td>
                            <td><?php if ($value['auto_increment']) { ?>
                                    <font color="green"><i class="fa fa-fw fa-check"></i></font>
                                <?php } ?></td>
                            <td><?php echo $value['collation']; ?></td>
                            <td><?php echo $value['comment']; ?></td>
                        </tr>
                    <?php } ?>
                </tbody>
            </table>
            <div class="row">
                <div class="col-6">
                    <table class="table table-sm table-bordered bordered">
                        <thead class="bg-light text-black">
                            <tr>
                                <th colspan="2">索引</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $indexes  = AppsTable::getIndex($tbn);
                            foreach ((array) $indexes as $ikey => $ivalue) {
                            ?>
                                <tr>
                                    <td><b><?php echo $ivalue['type']; ?></b></td>
                                    <td><?php echo implode(',', (array) $ivalue['columns']); ?></td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
                <div class="col-6">
                    <table class="table table-sm table-bordered bordered">
                        <thead class="bg-light text-black">
                            <tr>
                                <th colspan="2">表信息</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $status  = AppsTable::getStatus($tbn);
                            foreach ((array) $status as $tskey => $tsvalue) {
                            ?>
                                <tr>
                                    <td><b><?php echo $tskey; ?></b></td>
                                    <td><?php echo $tsvalue; ?></td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        <?php
        } else {
            echo '<div class="alert alert-error">' . $tbn . ' 表不存在</div>';
        }
        ?>
    </div>
<?php }
else { ?>
<?php } ?>