<?php
/*
 * @author: CloudZA(云之安) <2922619853@qq.com>
 * @hitokoto: 一场秋雨一场凉，秋心酌满泪为霜。
 * Copyright (c) 2022 by CloudZA, All Rights Reserved.
 */

include_once 'common.php';
if ( !isset($islogin)) header("Location: /");//非法访问
$title = '修改密码';
include_once 'partials/head.php';
$row = Db::table('app_admin')
         ->find();
?>
<div id="pjax-container">
<!--导航-->
<div class="bg-body-light">
  <div class="content content-full">
    <div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center py-2">
      <div class="flex-grow-1">
        <h1 class="h3 fw-bold mb-2">
          网站信息
        </h1>
      </div>
      <nav class="flex-shrink-0 mt-3 mt-sm-0 ms-sm-3" aria-label="breadcrumb">
        <ol class="breadcrumb breadcrumb-alt">
          <li class="breadcrumb-item">
            <a class="link-fx" href="javascript:void(0)">网站设置</a>
          </li>
          <li class="breadcrumb-item" aria-current="page">
            <?php echo $title ?>
          </li>
        </ol>
      </nav>
    </div>
  </div>
</div>
<!--导航结束-->
<!--内容-->
<div class="content animated fadeIn">
    <div class="block block-rounded">
    <div class="block-header block-header-default">
        <h3 class="block-title"> 管理员信息修改 </h3>
    </div>
     <div class="block-content">
        <form action="" method="POST" onsubmit="return false;">
            <div class="form-group mb-2">
                <label class="form-label fs-sm" for="adminNick">昵称</label>
                <input type="text" name="adminNick" id="adminNick" value="<?php echo $row[ 'usernick' ] ?>" class="form-control" placeholder="登录账号" required />
            </div>
            <div class="form-group mb-2">
                <label class="form-label fs-sm" for="adminQQ">QQ</label>
                <input type="text" name="adminQQ" id="adminQQ" value="<?php echo $row[ 'userqq' ] ?>" class="form-control" placeholder="登录账号" required />
            </div>
            <div class="form-group mb-2">
                <label class="form-label fs-sm" for="adminAccount">登录账号</label>
                <input type="text" name="adminAccount" id="adminAccount" value="<?php echo $row[ 'username' ] ?>" class="form-control" placeholder="登录账号" required />
            </div>
            <div class="form-group mb-2">
                <label class="form-label fs-sm" for="oldPassword">原来密码</label>
                <input type="text" name="oldPassword" id="oldPassword" class="form-control" placeholder="原来的密码" />
            </div>
            <div class="form-group mb-2">
                <label class="form-label fs-sm" for="newPassword">新的密码</label>
                <input type="text" name="newPassword" id="newPassword" class="form-control" placeholder="新的密码，不改请留空" />
            </div>
            <div class="form-group mb-2">
                <label class="form-label fs-sm" for="confirmNewPassword">确认新密码</label>
                <input type="text" name="confirmNewPassword" id="confirmNewPassword" class="form-control" placeholder="确认新密码，不改请留空" />
            </div>

            <div class="row mb-2">
                <div class="col-xl-12 mt-2">
                    <input type="submit" name="submit" id="submit" value="保存" class="btn btn-sm btn-alt-primary form-control" />
                </div>
            </div>
        </form>
    </div>
</div>
    <!--内容结束-->
    <script>
    $('#submit').click(() => {
        app.ajax('ajax.php?act=setAdm', {
            adminNick         : app.getval('#adminNick'),
            adminQQ           : app.getval('#adminQQ'),
            adminAccount      : app.getval('#adminAccount'),
            oldPassword       : app.getval('#oldPassword'),
            newPassword       : app.getval('#newPassword'),
            confirmNewPassword: app.getval('#confirmNewPassword'),
        }, res => {
            if (res.code === 200) {
                app.notify(res.msg, 'success')
                setTimeout(() => {
                    app.pjax('set_adm.php');
                }, 1000);
            }
            else {
                app.notify(res.msg, 'warning')
            }
        })
    });
</script>
</div>
    <?php include_once 'partials/foot.php'; ?>
