<div class="main-right-box">
    <h5>{lang_admin('order_list')}
        <div class="form-inline pull-right backstage-search">
            <form name="searchform" id="searchform"  action="<?php echo uri();?>" method="post"  onsubmit="return returnform(this)">
                <input type="text" class="form-control" name="search_title" id="search_number" placeholder="{lang_admin('tag')}" value="" />
                <button  class="btn btn-default search-btn" name="submit" type="submit">
                    <i class="glyphicon glyphicon-search"></i>
                </button>
            </form>
        </div>

    </h5>

    <div class="box" id="box">

        <a href="#" onclick="gotourl(this)"
           data-dataurl="{$base_url}/index.php?case=question&act=addtag&admin_dir={get('admin_dir',true)}&site=default"
           class="btn btn-primary" data-dataurlname="{lang_admin('add_topic')}">{lang_admin('add_topic')}</a>
        <div class="blank20"></div>

        <form name="listform" id="listform"  action="<?php echo uri();?>" method="post" onsubmit="return returnform(this);">
            <!--改变的或者新增的分类序号-->
            <input type="hidden" id="cahngenum" name="cahngenum" value=""/>
            <!--改变的或者新增的分类序号-->




            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr class="th">
                        <th class="s_out"><input title="{lang_admin('click_to_select_all_items_on_this_page')}"  onclick="CheckAll(this.form)" type="checkbox" name="chkall" class="checkbox" /> </th>
                        <th class="catid text-center"><!--id-->{lang_admin('id')}</th>
                        <th class="catname"><!--oid-->{lang_admin('topic')}</th>
                        <th class="catname"><!--pname-->{lang_admin('amount')}</th>
                        <th class="catname"><!--pname-->{lang_admin('is_to_index')}</th>
                        <th class="manage">{lang_admin('dosomething')}</th>
                    </tr>

                    </thead>
                    <tbody id="listtable">
                    <?php $index=0;?>
                    {loop $data $d}
                    <?php $index++;?>
                    <tr class="s_out">
                        <input type="hidden" id="id{$index}" name="id{$index}" value="{$d['id']}" >
                        <td ><input onclick="c_chang(this)" type="checkbox"  value="{$d['id']}" name="select[]" class="checkbox" /> </td>
                        <td class="catid text-center">{$d['id']}</td>
                        <td class="catname"><input type="text" name="tagname{$index}" id="tagname{$index}" onchange="setchange('{$index}');" value="{$d['tagname']}" class="form-control "></td>
                        <td class="catname" align="left">{$d['tagnum']}</td>
                        <td class="catname">
                            <select id="is_to_index{$index}" name="is_to_index{$index}" onchange="setchange('{$index}');" class="form-control select is_to_index">
                                <option value="0" {if $d['is_to_index']==0}selected{/if}>否</option>
                                <option value="1"{if $d['is_to_index']==1}selected{/if}>是</option>
                            </select>
                        </td>
                        <td class="manage">
                            <a href="#" onclick="gotourl(this)"
                               data-dataurl="<?php echo url("question/edittag/id/".$d['id']);?>"
                               title="{lang_admin('handle')}" class="btn btn-gray" data-dataurlname="<?php echo lang_admin('edit_topic');?>">{lang_admin('edit')}</a>

                            <div class="btn-group">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    {lang_admin('more')} <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    <li>
                                        <a onclick="if(confirm('{lang_admin('are_you_sure_you_want_to_delete_it')}')){gotourl(this);}" href="#"   data-dataurl="<?php echo url("question/delete/table/tag/id/".$d['id']."/token/$token");?>" title="{lang_admin('delete')}">{lang_admin('delete')}</a>
                                    </li>
                                </ul>
                            </div>
                        </td>
                    </tr>
                    {/loop}

                    </tbody>
                </table>


                <input type="hidden" name="inedx" id="index" value="{$index}">
                <input type="hidden" name="batch" id="batch" value="">
                <input type="button" value="{lang_admin('preservation')}" name="preservation" onclick="this.form.action='<?php echo modify("/act/newadd/table/tag");?>';this.form.batch.value='newadd';returnform(this.form);" class="btn btn-gray"/>
                <input  class="btn btn-gray" type="button" value=" {lang_admin('delete')} " name="delete"
                        onclick="if(getSelect(this.form) && confirm('{lang_admin('do_delete_id_as')}('+getSelect(this.form)+'){lang_admin('is_it_recorded')}')){this.form.action='<?php echo modify('act/batch/table/tag',true);?>'; this.form.batch.value='delete'; returnform(this.form);}"/>
                <input class="btn btn-gray" type="button" id="adding_tag" value=" {lang_admin('add_topic')} "  />
                <div class="blank30"></div>
                <div class="line"></div>
                <div class="page"><?php if(get('table')!='type' && front::get('case')!='field') echo pagination::adminhtml($record_count); ?></div>
                <div class="blank30"></div>
            </div>

        </form>


    <script>
        $(function () {
            $('#adding_tag').click(function() {
                //新增商品栏目
                addingtag();
            });
        });
        //记录修改或者新增的序号
        function setchange(num){
            var cahngenum=$("#cahngenum").val();
            if(cahngenum!=""){
                cahngenum=cahngenum+","+num;
            }else{
                cahngenum=num;
            }
            $("#cahngenum").val(cahngenum);
        }

        //新增
        function addingtag(){
            var index=$("#index").val();
            index=parseInt(index)+1;
            var htmldata="<tr>";
            htmldata+='<td class="s_out"><input  type="checkbox" value="" disabled> </td>';
            htmldata+='<td class="id"></td>';
            htmldata+='<td class="tagname">';
            htmldata+='<input type="text" name="tagname'+index+'" id="tagname'+index+'"  onchange="setchange(\''+index+'\');" value="" class="form-control "> </td>';
            htmldata+='<td class="tagnum"></td>';
            htmldata+='<td class="catname">';
            htmldata+='<select id="is_to_index'+index+'" name="is_to_index'+index+'" onchange="setchange(\''+index+'\');" class="form-control select is_to_index">';
            htmldata+='<option value="0" selected>否</option>';
            htmldata+='<option value="1">是</option>';
            htmldata+=' </select>';
            htmldata+='</td>';
            htmldata+='<td class="manage">';
            htmldata+='<a  href="#" onclick="delcatrgoty(this)" title="{lang_admin("delete")}" class="btn btn-danger">{lang_admin("delete")}</a>';
            htmldata+='</td>';
            htmldata+="</tr>";
            $("#listtable").append(htmldata);
            $("#index").val(index);
        }

        //删除新增的栏目
        function delcatrgoty(obj){
            $(obj).parent().parent().remove();
        }
    </script>

<script type="text/javascript">
    function qk(){
        if(confirm('{lang_admin('do_you_really_want_to_clear_the_records')}')) {
            var inputs = document.getElementsByTagName("input");
            var boxs = [];
            for (let i = 0; i < inputs.length; i++) {
                if (inputs[i].type == "checkbox") {
                    inputs[i].checked=true;
                }
            }

            document.getElementById("listform").action = '<?php echo modify('act/batch',true);?>';
            document.getElementById("batch").value='delete';
        }
    }
</script>
<div class="blank30"></div>
</div>
</div>
