index.php 7.49 KB
<?php

use yii\helpers\Url;
use app\ht\widgets\LinkPager;
use domain\upgrade\UpgradeStatus;
use domain\upgrade\UpgradeLogStatus;

$this->params['breadcrumbs'][] =  '机器状态统计';
?>
<style>
    .table > tbody > tr > td
    {
        border: white 0px solid;
        border-top: solid 1px #fff;
        border-bottom: 1px solid #fff;
    }
    .table{
        margin-bottom: 0px!important;
    }
</style>
<div class="panel panel-default">
    <div class="panel-body">
        <form action="" method="get" id="search-form" class="filter-form">
            <table width="100%" class="table">
                <tbody>
                <tr >
                    <td width="10%" class="text-right">barcode</td>
                    <td width="10%" class="text-left">
                        <input type="text" class="form-control" name="barcode" style="width: 150px;" placeholder="barcode" value="<?php if (!empty($gets['barcode'])){ echo $gets['barcode']; } ?>">
                    </td>
                    <td width="10%" class="text-right">设备ID</td>
                    <td width="10%" class="text-left">
                        <input type="text" class="form-control" name="device_id" style="width: 150px;" placeholder="设备ID" value="<?php if (!empty($gets['device_id'])){ echo $gets['device_id']; } ?>">
                    </td>
                    <td width="10%" class="text-right">厂商</td>
                    <td width="10%" class="text-left">
                        <input type="text" class="form-control" name="manufacture_name" style="width: 150px;" placeholder="输入厂商" value="<?php if (!empty($gets['manufacture_name'])){ echo $gets['manufacture_name']; } ?>">
                    </td>
                    <td width="10%" class="text-right">机器型号</td>
                    <td width="30%" class="text-left">
                        <input type="text" class="form-control" name="model_name" style="width: 290px;" placeholder="机器型号" value="<?php if (!empty($gets['model_name'])){ echo $gets['model_name']; } ?>">
                    </td>
                </tr>
                <tr>
                    <td class="text-right">软件版本</td>
                    <td class="text-left">
                        <input type="text" class="form-control" name="software_version" style="width: 150px;" placeholder="软件版本" value="<?php if (!empty($gets['software_version'])){ echo $gets['software_version']; } ?>">
                    </td>
                    <td class="text-right">硬件版本</td>
                    <td class="text-left">
                        <input type="text" class="form-control" name="hardware_version" style="width: 150px;" placeholder="硬件版本" value="<?php if (!empty($gets['hardware_version'])){ echo $gets['hardware_version']; } ?>">
                        </select>
                    </td>
                    <td class="text-right">所在城市</td>
                    <td class="text-left">
                        <input type="text" class="form-control" name="city" style="width: 150px;" placeholder="城市" value="<?php if (!empty($gets['city'])){ echo $gets['city']; } ?>">
                    </td>
                    <td class="text-right">时间</td>
                    <td class="text-left">
                        <div class="form-inline">
                            <input type="date" class="form-control" style="width: 140px;" name="createTime" placeholder="起" value="<?php if (!empty($gets['createTime'])){ echo $gets['createTime']; } ?>"> -
                            <input type="date" class="form-control" style="width: 140px;" name="endTime" placeholder="止" value="<?php if (!empty($gets['endTime'])){ echo $gets['endTime']; } ?>">
                        </div>
                    </td>
                </tr>

                <tr class="search">
                    <td colspan="8"  class="text-center">

                        <button type="submit" class="btn btn-primary btncls" id="search"><i class="glyphicon glyphicon-search"></i> 查 询  </button>
                        <a class="btn btn-default btncls" href="<?=Url::toRoute(["/datas/device-stats/index"])?>">重&nbsp;&nbsp;&nbsp;&nbsp;置</a>
                        <a class="btn btn-default" style="float: right;" href="javascript:void(0)" id="btn-export"> 导出数据 </a>&nbsp;&nbsp;
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</div>

<div class="panel panel-default">
    <div  class="panel-body">
        <table class="table table-striped table-bordered"  id="brand-table">
            <thead>
            <tr>
                <th width="10%">设备ID</th>
                <th width="10%">Barcode</th>
                <th width="10%">软件版本</th>
                <th width="10%">硬件版本</th>
                <th width="10%">厂商</th>
                <th width="10%">设备型号</th>
                <th width="10%">所在城市</th>
                <th width="10%">IP地址</th>
                <th width="15%">时间</th>
            </tr>
            </thead>

            <tbody>
            <?php if ($listdata) { ?>
                <?php foreach ($listdata as $item) : ?>
                    <tr>
                        <td style="padding:12px;"><?= (isset($item["device_id"]) ? $item["device_id"] : "-") ?></td>
                        <td style="padding:12px;"><?= (isset($item["barcode"]) ? $item["barcode"] : "-") ?></td>
                        <td style="padding:12px;"><?= (isset($item["software_version"]) ? $item["software_version"] : "-") ?></td>
                        <td style="padding:12px;"><?= (isset($item["hardware_version"]) ? $item["hardware_version"] : "-") ?></td>
                        <td style="padding:12px;"><?= (isset($item["manufacture_name"]) ? $item["manufacture_name"] : "-") ?></td>
                        <td style="padding:12px;"><?= (isset($item["model_name"]) ? $item["model_name"] : "") ?></td>
                        <td style="padding:12px;"><?= empty($item["city"])? '-':$item["city"]?></td>
                        <td style="padding:12px;"><?= $item["ip"]?></td>
                        <td style="padding:12px;"><?= date("Y-m-d H:i:s", $item['timestamp'])?></td>
                    </tr>
                <?php endforeach; ?>
            <?php } else { ?>
            <tr>
                <td colspan="9">
                    <center>暂无记录</center>
                </td>
            </tr>
            <?php } ?>
            </tbody>
        </table>
    </div>

    <div class="panel-footer">
        <div class="hqy-panel-pager">
            <?= LinkPager::widget([
                'pagination' => $pages,
            ]); ?>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
<script>
    window.queryParams = function(params) {
        $("#search-form").find('input[name]').each(function () {
            var val = $(this).val();
            var name = $(this).attr('name');
            if(val){
                params[name] = val;
            }
        });
        return params;
    }
    $(document).ready(function () {
        $('#btn-export').click(function(e){
            var params = {};
            window.queryParams(params);

            $strQuery = "?";
            if (params) {
                for (var p in params) {
                    $strQuery += p + "=" + params[p] + "&";
                }
            }
            $strQuery = $strQuery.substring(0, $strQuery.length-1);
            window.location.href = "export" + $strQuery;
            return false;
        })
    });
</script>