<style type="text/css">
    @media (max-width: 1366px) {
        .htmldir {
            display: none;
        }
    }
</style>

<div class="main-right-box">
    <h5>{lang_admin('question')}
        <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('title')}" 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">



        <form name="listform" id="listform"  action="<?php echo uri();?>" method="post" onsubmit="return returnform(this);">

            <a href="#" onclick="gotourl(this)"
               data-dataurl="<?php echo url("question/config");?>"
               class="btn btn-primary" data-dataurlname="{lang_admin('to_configure')}">{lang_admin('to_configure')}</a>





            <div class="blank30"></div>

            <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="htmldir text-center"><!--id-->{lang_admin('id')}</th>
                        <th class="catname"><!--oid-->{lang_admin('title')}</th>
                        <th class="htmldir"><!--pname-->{lang_admin('type')}</th>
                        <th class="catname"><!--pname-->{lang_admin('adddate')}</th>
                        <th class="htmldir"><!--pname-->{lang_admin('modification_time')}</th>
                        <th class="htmldir"><!--pname-->{lang_admin('user')}</th>
                        <th class="catname text-center"><!--status-->{lang_admin('state')}</th>
                        <th class="manage">{lang_admin('dosomething')}</th>
                    </tr>

                    </thead>
                    <tbody>
                    {loop $data $d}
                    <tr class="s_out">

                        <td ><input onclick="c_chang(this)" type="checkbox"  value="{$d['id']}" name="select[]" class="checkbox" /> </td>
                        <td class="htmldir text-center">{$d['id']}</td>
                        <td class="catname">{$d['title']}</td>
                        <td class="htmldir" align="left">{$d['type'][typename]}</td>
                        <td class="catname" align="left">{$d['adddate']}</td>
                        <td class="htmldir" align="left">{$d['updatedate']}</td>
                        <td class="htmldir" align="left">{$d['username']}</td>
                        <?php
                        switch($d['state']){
                            case 0:
                                $d['status']=lang_admin('draft');
                                break;
                            case 1:
                                $d['status']=lang_admin('normal');
                                break;
                            case 2:
                                $d['status']=lang_admin('to_be_reviewed');
                                break;
                            case 3:
                                $d['status']=lang_admin('audit_failed');
                                break;
                            case 4:
                                $d['status']=lang_admin('closed');
                                break;
                            default:
                                $d['status']=lang_admin('normal');
                                break;
                        }
                        ?>
                        <td class="catname text-center"><?php echo $d['state']==4?$d['status']:($d['reply_isadopt']?"已采纳":$d['status']);?></td>

                        <td class="manage">
                            {if $d['state']==2}
                            <a href="#" onclick="gotourl(this)"
                               data-dataurl="<?php echo url("question/audit/id/".$d['id']);?>"
                               title="{lang_admin('handle')}" class="btn btn-gray" >{lang_admin('to_examine')}</a>
                           <a href="#"   data-toggle="modal" data-target="#canceladuit"  onclick="$('#question_id').val({$d['id']});"
                               title="{lang_admin('handle')}" class="btn btn-default" data-dataurlname="<?php echo lang_admin('cancel').lang_admin('to_examine');?>">{lang_admin('cancel')}{lang_admin('to_examine')}</a>
                            {else}
                                {if !$d['reply_isadopt']}
                                  <a href="#" onclick="gotourl(this)"
                                   data-dataurl="<?php echo url("question/edit/id/".$d['id']);?>"
                                   title="{lang_admin('handle')}" class="btn btn-gray" data-dataurlname="<?php echo lang_admin('edit');?>">{lang_admin('edit')}</a>
                                {/if}
                            {/if}
                            <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/id/".$d['id']."/token/$token");?>" title="{lang_admin('delete')}">{lang_admin('delete')}</a>
                                    </li>
                                    {if $d['state']==4}
                                    <li role="separator" class="divider"></li>
                                    <li>
                                        <a onclick="gotourl(this);" href="#"   data-dataurl="<?php echo url("question/open/id/".$d['id']);?>" title="{lang_admin('open')}">{lang_admin('open')}</a>
                                    </li>
                                    {else}
                                    <li role="separator" class="divider"></li>
                                    <li>
                                        <a onclick="gotourl(this);" href="#"   data-dataurl="<?php echo url("question/close/id/".$d['id']);?>" title="{lang_admin('close')}">{lang_admin('close')}</a>
                                    </li>
                                    {/if}
                                </ul>
                            </div>
                        </td>
                    </tr>
                    {/loop}

                    </tbody>
                </table>



                <input type="hidden" name="batch" id="batch" value="">
                <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',true);?>'; this.form.batch.value='delete'; returnform(this.form);}"/>
                <input  class="btn btn-default" type="button" value=" {lang_admin('open_question')} " name="open"
                        onclick="if(getSelect(this.form) && confirm('{lang_admin('do_open_id_as')}('+getSelect(this.form)+'){lang_admin('is_it_recorded')}')){this.form.action='<?php echo modify('act/batch',true);?>'; this.form.batch.value='open'; returnform(this.form);}"/>
               <input  class="btn btn-default" type="button" value=" {lang_admin('close_question')} " name="open"
                        onclick="if(getSelect(this.form) && confirm('{lang_admin('do_close_id_as')}('+getSelect(this.form)+'){lang_admin('is_it_recorded')}')){this.form.action='<?php echo modify('act/batch',true);?>'; this.form.batch.value='close'; returnform(this.form);}"/>
                {if $to_examine}
                <input  class="btn btn-default" type="button" value=" {lang_admin('to_examine')} " 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',true);?>'; this.form.batch.value='autid'; returnform(this.form);}"/>
                {/if}
                <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>

    <!-- 取消审核Modal -->
    <div class="modal fade" id="canceladuit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-body" >
                        <div class="blank20"></div>
                        <div class="form-group">
                            <label>{lang_admin('reason_for_failure')}：</label>
                            <input type="hidden" id="question_id" value="0">
                            <textarea name="returncon" id="returncon" class="form-control textarea"></textarea>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" id="confirm_noaudit" class="btn btn-primary"><?php echo lang('confirm');?></button>
                        <button type="button"  name="clos" class="btn btn-danger" data-dismiss="modal"><?php echo lang_admin("close");?></button>
                    </div>
                </div>
            </div>
    </div>
    <script>
        //取消审核
        $('#confirm_noaudit').click(function(){
            var question_id=$("#question_id").val();
            var returncon=$("#returncon").val();
            $.ajax({
                type: "post",
                url: "{url('question/audit/noaudit/1',true)}",
                data: {"id": question_id, "returncon": returncon},
                dataType: 'json',
                async: true,
                success: function (data) {
                    //关闭服务器登录弹出框
                    $('#confirm_noaudit').modal('hide');
                    $(".modal-backdrop.fade").hide();
                    alert(data.message);
                    if (data.state){
                        gotoinurl("{uri()}");
                    }
                }
            });
        });
    </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>
