 <!doctype html>
  <html class="no-js">
  <head>

    <include file="Common/head" />
    <style type="text/css">
      a.am-text-secondary:visited{color:#3bb4f2;}
      a.am-text-danger:visited{color:#dd514c;}
      .am-btn-default {background-color: #fff;}
      th {text-align:center;}
      tr td{text-align:center;}
      select{padding: 4px;border: 1px solid #ccc;}
      .am-popup-bd {background:#fff;}
      .am-popup-bd img {max-width: 100%}
      .am-u-sm-2 {border-top: 1px solid #ddd;margin-top: 10px;}
      .am-u-sm-10 {border-left: 1px solid #ddd;margin-top: 10px;}
      .am-table>tbody>tr>td.user-info {padding: 1px;text-align: left;}
      .am-table>tbody>tr>td.user-info img{height: 42px}
      myred{color:#dd514c;}
      mygreen {color:#1aad19;}
      mygery {color:#999;}
      .wxgreen {color:#1aad19;}
      .search-div.am-input-group .am-form-field{width:120px;float: right;}
      .search-div select {float: right;}
      .ttt-switch {margin: 0 auto;}

      .am-table>tbody>tr>td.td-img {
        padding: 1px;
        text-align: left;
      }
      .am-table>tbody>tr>td.td-img img {
        height: 42px;
        float: right;
      }

    </style>
  </head>
  <body>
  <include file="Common/header" />

  <div class="am-cf admin">

    <include file="Common/sidebar" nav="$nav" navv="$nav"/>
    <div class="content-page" style="background: white;">

      <div class="admin-content" style="background: white;">
        <div class="admin-content-body">
          <div class="am-cf am-padding">
            <div class="am-fl am-cf">
              <strong class="am-text-primary am-text-lg">Product Management</strong> /
              <small>Category Management / <?php echo $_GET['id']?"Edit":"Add"; ?></small>
            </div>
          </div>
          <hr style="margin-top:0px;">
          <div class="am-u-md-6">
            <form class="am-form am-text-sm" action="" method="POST" id="saveForm" enctype="multipart/form-data">
              <input type="hidden" name="op" value="save" />
              <input type="hidden" name="id" value="{$cat.id}" />
              <div class="am-form-group am-form-inline">
                <div class="am-form-group">
                  <label>Sort<span>(Number Sorting is In Descending Order)</span></label>
                  <input type="text" name="seat_no" value="{$cat.seat_no}">
                </div>
              </div>
              <input type="hidden" name="pid" value="0"/>

              <div class="am-form-group">
                <label>Category Name</label>
                <input type="text" name="title" value="{$cat.title}">
              </div>

              <div class="am-form-group">
                <label>Category Image</label>
                <div for="img" id="chooseImg">
                  <img src="__UPLOADS__/{$cat.img}" id="img_preview" onerror="this.src='__PUBLIC__/img/add.png'" style="width: 70px;height: 70px;">
                  <input type="file" name="img" value="" style="display: none;" accept="image/jpg,image/jpeg,image/png">
                </div>
              </div>


              <div class="am-form-group">
                  <label>Status</label><br>
                  <label class="am-radio-inline">
                    <input type="radio" name="status" value="0" data-am-ucheck <?php if ($cat['status'] == 0) : ?>checked<?php endif;?>> Enable
                  </label>
                  <label class="am-radio-inline">
                    <input type="radio" name="status" value="1" data-am-ucheck <?php if ($cat['status'] == 1) : ?>checked<?php endif;?>> Diable
                  </label>
              </div>

              <div class="am-form-group">
                  <label>Appear in Homescreen</label><br>
                  <label class="am-radio-inline">
                    <input type="radio" name="home_show" value="1" data-am-ucheck <?php if ($cat['home_show'] == 1) : ?>checked<?php endif;?>> Enable
                  </label>
                  <label class="am-radio-inline">
                    <input type="radio" name="home_show" value="0" data-am-ucheck <?php if ($cat['home_show'] == 0) : ?>checked<?php endif;?>> Diable
                  </label>
              </div>


              <button type="button" class="am-btn am-btn-default" id="form_submit">Save</button>
            </form>

          </div>
        </div>
        <script type="text/javascript">
            function layert(content){ layer.open({title:'',content:content,shade:0.2}); }
            $(function(){
                $("#form_submit").on('click',function(){
                    $("#saveForm").submit();
                });
            });
        </script>
        <footer class="admin-content-footer"><hr></footer>
      </div>
    </div>
  </div>
  <include file="Common/footer" />

  <script type="text/javascript">
      $(function(){
          $("#img_preview").click(function(){
            $("input[name=img]").click();
          });
          $("input[name=img]").on('change', function() {
              var reader = new FileReader();
              reader.onload = function(e){
                 $('#img_preview').attr('src', e.target.result);
              }
              if(this.files[0]){
                 reader.readAsDataURL(this.files[0]);
              }else{
                  $('#img_preview').attr('src','');
             }
          });

          // 重置密码
          $(".reset_link").on("click",function(){
              var id=$(this).attr('data-id');
              var name=$(this).attr("data-name");
              var bool = confirm("Confirm reset administrator's password?");
              if (bool) {
                  $("#float_id").val(id);
                  $("#float_name").html(name);
                  $("#shade_div").show();
                  $("#float_div").show();
              };
          });
          $("#btclose").on("click",function(){
              $("#shade_div").hide();
              $("#float_div").hide();
          });
          // 删除
          $(".del_link").on("click",function(){
              var name=$(this).attr("data-name");
              var the_link=$(this).attr("data-url");
              var bool = confirm("Confirm deleting the administrator?");
              if (bool) {
                  location.href = the_link;
              };
          });
      });
  </script>
  </body>

  </html>