{template 'header.html'}


<!--编辑器-->
<script type="text/javascript" src="{$base_url}/wangeditor/release/wangEditor.min.js"></script>
<script type="text/javascript" src="{$base_url}/common/js/xss/xss.js"></script>

<div class="container">
    <div class="question-box">

        <div class="question-main">


            <form method="post" name="form1" action="{uri()}" onsubmit="return checkform();">


                <div class="user-nav-tab">
                    <h3>
                        <i class="icon-settings"></i>
                        <a href="{url('user/index')}">
                            {lang('membercenter')}
                        </a>
                    </h3>
                    <!-- Nav tabs -->
                    <ul class="nav nav-tabs">
                        <li>
                            <a href="{url('user/edit/table/user')}" class="active">
                                {lang('edituserinfo')}
                            </a>
                        </li>
                        <li>
                            <a href="{url('user/changepassword')}">
                                {lang('changepassword')}
                            </a>
                        </li>

                        <?php if(count(pay::getInstance()->getrows())>1 ||
                        (count(pay::getInstance()->getrows())==1 && count(pay::getInstance()->getrows('pay_code="nopay"'))==0) ){ ?>
                        <li class="dropdown">
                            <a href="#" id="myTabDrop1" class="dropdown-toggle" data-toggle="dropdown" aria-controls="myTabDrop1-contents" aria-expanded="false">{lang('my-finance')} <span class="caret"></span></a>
                            <ul class="dropdown-menu" aria-labelledby="myTabDrop1" id="myTabDrop1-contents">

                                <li>
                                    <a href="{url('manage/consumptionlist/manage/consumption')}">
                                        {lang('recharge_record')}
                                    </a>
                                </li>
                                <li>
                                    <a href="{url('manage/consumptionlist/manage/xfconsumption')}">
                                        {lang('consumption_details')}
                                    </a>
                                </li>
                                <li>
                                    <a href="{url('archive/consumption')}">
                                        {lang('recharge')}
                                    </a>
                                </li>

                                <li>
                                    <a href="{url('manage/orderslist/manage/orders/type/all')}">
                                        {lang('order')}
                                    </a>
                                </li>
                                <li>
                                    <a href="{url('manage/orderslist/manage/orders/type/refund')}">
                                        {lang('refund_record')}
                                    </a>
                                </li>
                            </ul>
                        </li>
                        <?php } ?>

                        <li>
                            <a href="{url('question/questionlist/page/1/myseemid/1')}">
                                {lang('myconcerns')}
                            </a>
                        </li>
                        <li class="active">
                            <a href="{url('question/questionlist/page/1/myquestion/1')}">
                                {lang('myquestion')}
                            </a>
                        </li>

                        <li>
                            <a href="{url('question/draftquestion')}">
                                {lang('drafts')}
                            </a>
                        </li>

                        {if session::get('ver') == 'corp'}
                        <li class="one"><a class="aa toogle" href="{url('manage/collectlist/manage/user')}">{lang('my-collection')}</a></li>
                        {/if}




                    </ul>
                </div>
                <div class="blank60"></div>

                <div class="form-group">
                    <label>{lang('title')}</label>
                    {form::getform('title',$form,$field,$data,'class="form-control"')}
                </div>


                <?php if(count(pay::getInstance()->getrows())>1 ||
                (count(pay::getInstance()->getrows())==1 && count(pay::getInstance()->getrows('pay_code="nopay"'))==0) ){ ?>
                <div class="form-group">
                    <label>{lang('answerreward')}</label>
                    <?php $data['rewardmenoy']=$data['rewardmenoy']?$data['rewardmenoy']:0;?>
                    {form::getform('rewardmenoy',$form,$field,$data,'class="form-control"')}
                    <div class="blank10"></div>
                    <small>{lang('balance')}：{getmenoy()}，<a href="{url('archive/consumption')}" class="btn btn-default btn-xs">{lang('recharge')}
                    </a></small>
                </div>
                <?php } ?>



                <div class="form-group">
                    <label>{lang('special')}</label>
                    {form::getform('typeid',$form,$field,$data,'class="form-control"')}
                </div>


                <div class="form-group">
                    <label>{lang('topic')}</label>
                    <div class="clearfix"></div>
                    <input type="hidden" name="tag" id="tag" value="">
                    <a class="btn btn-default btn-gray" data-toggle="modal" data-target="#myquestiontag" onclick="showquestiontag();">
                        <i class="icon-note"></i>
                        {lang('select')}
                    </a>
                </div>

                <div class="form-group">
                    <label>{lang('user_group')}</label>
                    {form::select('usergroupid',$data['usergroupid'], usergroup::optionall())}
                </div>

                <div class="form-group">
                    <label>{lang('content')}</label>
                    {form::getform('content',$form,$field,$data)}

                </div>



                {if config::get('mobilechk_enable')}
                <script src="{$base_url}/common/plugins/mobilechk/mobilechk.js"></script>
                <div class="form-group">
                    <label>{lang('phone_verification_code')}</label>

                    <div class="input-group">
                            <span class="input-group-addon btn btn-default">
                                <i class="icon-call-end"></i>&nbsp;</span>
                        <input placeholder="{lang('tel')}" type='text' id="tel"  name="tel" value="{lang('tel')}" onfocus="if(this.value=='{lang('tel')}') {this.value=''}" onblur="if(this.value=='') this.value='{lang('tel')}'" tabindex="3" class="form-control"  style="max-width:303px;">
                    </div>
                    <div class="input-group">
                            <span class="input-group-addon btn btn-default">
                                <i class="icon-envelope"></i>&nbsp;</span>
                        <input type='text' placeholder="{lang('please_enter_the_phone_verification_code')}" id="mobilenum" name="mobilenum" class="form-control" placeholder="{lang('verifycode')}" style="max-width:166px;">
                        <span class="input-group-btn pull-left">
						<input id="btm_sendMobileCode" onclick="sendMobileCode();" type="button" value="{lang('send_cell_phone_verification_code')}" class="btn btn-default" />
					  </span>
                    </div>
                </div>
                <script>
                    $(function(){
                        $("#div").attr("style","display: none");
                    });
                    function setusername(obj){
                        $("#username").val($(obj).val());
                    }
                </script>
                {/if}

                {if ($questionconfigdata['question_admin_see'])}
                <div class="form-group">
                    <label>{lang('is_admin_see')}</label>
                    {form::getform('isadminsee',$form,$field,$data,'class="form-control"')}
                </div>

                {/if}
                {if config::get('verifycode')=='1'}
                <div class="form-group">
                    <label>{lang('verifycode')}</label>

                    <div class="input-group">
                        <div class="input-group-btn">
                            <button type="button" class="btn btn1 dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="padding:0px;">{verify()}</button>
                        </div><!-- /btn-group -->
                        <input type='text' id="verify"  tabindex="3"  name="verify" class="form-control" value="{lang('please_enter_code')}" placeholder="{lang('please_enter_code')}" onfocus="if(this.value=='{lang('please_enter_code')}') {this.value=''}" onblur="if(this.value=='') this.value='{lang('please_enter_code')}'" data-errortxt="{lang('please_enter_code')}">
                    </div>
                </div>
                {elseif config::get('verifycode')=='2'}
                <div class="form-group">
                    <label>{lang('verifycode')}</label>
                    <div id="verifycode_embed"></div>

                    <script src="http://api.geetest.com/get.php"></script>
                    <script>
                        var loadGeetest = function(config) {
                            window.gt_captcha_obj = new window.Geetest({
                                gt : config.gt,
                                challenge : config.challenge,
                                product : 'float',
                                offline : !config.success
                            });
                            gt_captcha_obj.appendTo("#verifycode_embed");
                        };

                        $.ajax({
                            url : '{url("tool/geetest")}',
                            type : "get",
                            dataType : 'JSON',
                            success : function(result) {
                                loadGeetest(result)
                            }
                        });
                    </script>
                </div>
                {/if}


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

                <input name="submit" value="1" type="hidden">
                <input type="submit" value="{lang('submit_on')}"   class="btn btn-default btn-blue btn-lg">
                    {if front::$act!='editquestion'}
                    <input type="submit" onclick="$('[name=submit]').val(2);" value="{lang('save_draft')}" class="btn btn-default btn-lg">
                    {/if}

            </form>

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

    <!-- tag弹出框 -->
    <div class="modal fade" id="myquestiontag" 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 tag-modal">
                        {loop $tagdata $questiontag}
                        <div class="col-xs-12 col-xm-6 col-md-4">
                            <div class="row">
                                <a name="tag_select" id="tag{$questiontag['id']}" data-tagid="{$questiontag['id']}" onclick="selecttag(this);">{$questiontag['tagname']}</a>
                            </div>
                        </div>
                        {/loop}
                        <div class="clearfix"></div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" id="confirm_tag" name="confirm_tag" class="btn btn-blue"><?php echo lang('confirm');?></button>
                    <button type="button"  name="close_tag"  id="close_tag" class="btn btn-default" data-dismiss="modal"><?php echo lang_admin("close");?></button>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    var tagdata="{$data['tag']}";  //tag选中的
    var oldtagdara="";    //打开时复制
    //选中tag  和取消 选择
    function selecttag(obj){
        var tagid=$(obj).data("tagid");
        var newtagdata="";
        var deletetag=false;
        if(tagdata!=""){
            var tagdataarry=tagdata.toString().split(",");
            for(var i=0;i<tagdataarry.length;i++)
            {
                if(tagdataarry[i]==tagid){
                    deletetag=true;
                }else{
                    newtagdata+=newtagdata==""?tagdataarry[i]:","+tagdataarry[i];
                }
            }
        }
        if (deletetag){
            $(obj).attr("style","background-color: #00000;");
        } else{
            newtagdata+=newtagdata==""?tagid:","+tagid;
            $(obj).attr("style","background-color: #2698db61;");
        }
        tagdata=newtagdata;
    }
    //打开tag选择框
    function showquestiontag(){
        oldtagdara=tagdata;
        $("[name=tag_select]").attr("style","background-color: #00000;");
        if(tagdata!=""){
            var tagdataarry=tagdata.toString().split(",");
            for(var i=0;i<tagdataarry.length;i++)
            {
                $("#tag"+tagdataarry[i]).attr("style","background-color: #2698db61;");
            }
        }
    }
    //确认选中
    $('[name=confirm_tag]').click(function() {
        $("#tag").val(tagdata);
        //关闭服务器登录弹出框
        $('#myquestiontag').modal('hide');
        $(".modal-backdrop.fade").hide();
    });
    //关闭选中  还原
    $('[name=close_tag]').click(function() {
        tagdata=oldtagdara;
    });
</script>

<script>
    function  checkform() {
        if($("#typeid").val()=="" ) {
            alert("{lang('please_choose')}{lang('type')}");
            $("#type").focus();
            return false;
        }
        if($("#title").val()=="" ) {
            alert("{lang('title')}{lang('on_null')}");
            $("#title").focus();
            return false;
        }
        var oldhtml=editor_content.txt.html();
        var filterHtml = filterXSS(oldhtml);  // 此处进行 xss 攻击过滤
        filterHtml = filterHtml.replace(new RegExp("&lt;","g"), "<");
        filterHtml = filterHtml.replace(new RegExp("&gt;","g"), ">");
        $('[name=content]').val(filterHtml);

    }
</script>




{template 'footer.html'}