<?php
!defined('IN_ONEZ') && exit('Access Denied');
$G['title']='修改资料';

$login=onez('login')->init($G['this']->cname,0);
$G['userid']=(int)$login['id'];
if($G['userid']){
  $G['user']=$G['this']->data()->open('member')->one("id='$G[userid]'");
}
$form=onez('admin')->widget('form')
  ->set('title',$G['title'])
  ->set('values',$G['user'])
;

onez('form.file');
$form->add(array('label'=>'昵称','type'=>'text','key'=>'nickname','hint'=>'','notempty'=>'昵称不能为空','value'=>''));
$form->add(array('label'=>'头像','type'=>'form.file','key'=>'avatar','hint'=>'','notempty'=>'','value'=>''));

#处理提交
if($onez=$form->submit()){
  if($onez['avatar'] && $onez['avatar']!=$G['user']['avatar']){
    $G['this']->avatar_set($G['userid'],$onez['avatar']);
  }
  $G['this']->data()->open('member')->update($onez,"id='$G[userid]'");
  onez()->ok('修改资料成功','close');
}

onez('admin')->header();
?>
<section class="content-header">
  <h1>
    修改资料
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="<?php echo onez()->href('/')?>">
        <i class="fa fa-dashboard">
        </i>
        管理首页
      </a>
    </li>
    <li class="active">
      <?php echo $G['title'];?>
    </li>
  </ol>
</section>
<section class="content">
<div class="row">
  <div class="col-lg-12">
  
<form method="post" id="form-common" class="">
<div class="box box-info">
  <div class="box-header with-border">
    <h3 class="box-title"><?php echo $G['title']?></h3>
  </div><!-- /.box-header -->
  <div class="box-body">
	  <?php echo $form->code();?>
  </div><!-- /.box-body -->
  <div class="box-footer">
	  <button class="btn btn-success" type="submit">保存修改</button>
  </div>
</div>
<input type="hidden" name="action" value="save">
</form>

  
  </div>
</div>
</section>
<?php 
echo $form->js();
onez('admin')->footer();