<? global $vis_language; ?>
 <div class="row">
        <div class="col-md-12">
          <section class="container m-t-md">
			<div class="panel-heading"><div class="wrapper b-b"><h3><? echo $vis_language['TXTADDARTICLE']; ?></h3></div></div>
            <div class="panel-body">
					<div class="col-md-12">
					  <div class="wrapper">
						  <div class="row m-b-sm">
							<label class="col-sm-2 control-label"><? echo $vis_language['TXTTITLE']; ?></label>
                            <div class="col-sm-8"><input type="text" class="form-control input-sm" name="vis_article_title" id="vis_article_title"></div>
						  </div>
						  <div class="row m-b-sm">
							<label class="col-sm-2 control-label"><? echo $vis_language['TXTCONTENT']; ?></label>
							<div class="col-sm-8"><textarea name="vis_article_content" id="vis_new_article_content" class="form-control"></textarea></div>
						  </div>
						  <div class="row m-b-sm">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-6"></div>
                            <div class="col-sm-2 control-label text-right">
                                  <span class="btn btn-link link btn_upload_file vis_font_size_none text-primary" id="vis_attach_file"><?= $vis_language['TXTATTACHFILE']; ?> <input class="form-control" type="file" id="fileupload1"></span>
                                  <div style="display:none;" id="vis_attachments"></div>
                            </div>
						  </div>
                          <div class="row m-b-sm">
							 <label for="Message" class="col-sm-2 control-label"></label>
							 <div id="vis_new_attachments1" class="col-sm-8 p-l-none"></div>
                          </div>
					  <div class="line line-dashed b-b line-lg pull-in"></div>
					  </div> <!-- /.wrapper -->
					</div> <!-- /.col-md-12 -->
					<div class="col-lg-offset-2 col-lg-8 m-b-lg">
                                            <button type="submit" id="btn_submit_atricle" class="btn btn-primary" onclick="submit_form();"><? echo $vis_language['TXTADD']; ?></button>
						  <input type="hidden" name="vis_module" value="selfhelp" />
						  <input type="hidden" name="vis_operation" value="add_carticle" />
						  <input type="hidden" id="vis_category_id" name="vis_category_id" value="<? echo $operation['vis_category_id']; ?>" />
						  <input type="hidden" id="vis_domain_id" name="vis_domain_id" value="<? echo $domain; ?>" />
					</div>
            </div>
          </section>
        </div>
	 </div>
<script>
 var curr_stamp=0;
  function submit_form() {
    if(curr_stamp==0 || (curr_stamp < (Date.now()-10000))){
        curr_stamp = Date.now();
        $.ajax({
           url: 'index.php',
           data: {'vis_module':"selfhelp", 'vis_operation':"add_carticle", 'vis_category_id':$("#vis_category_id").val(), 'vis_domain_id':$("#vis_domain_id").val(), 'vis_article_title':$("#vis_article_title").val(), 'vis_attachments':$("#vis_attachments").html(),'vis_article_content':$("#vis_new_article_content").val()},
           type: "POST",
           dataType: "json",
           success: function(data) { 
               if(data.vis_msg=="1")
               {
                   $(window).scrollTop(0);
                   $("#vis_submit_msg_div").show(); $("#vis_submit_msg_div").html("<?= $vis_language['MSGSUCCOPRT'];?>");
                   setTimeout(function(){window.location = "index.php?/selfhelp/categories"}, 500);
               } else
               {
                   $(window).scrollTop(0);
                   $("#vis_submit_err_div").show(); $("#vis_submit_err_div").html(data.vis_msg);
                   setTimeout(function(){$("#vis_submit_err_div").hide();},10000);
               }			 
           }
       });
    }
}
	function vis_remove_attachment(attach_id){
	 $.ajax({
        url: 'index.php',
        data: {'vis_module':"ticket", 'vis_operation':"remove_attachment", 'vis_attachment_id':attach_id },
        type: "POST",
        success: function(data) {  }
    });
}
	$(function () {
	var url = 'index.php?vis_module=ticket&vis_operation=upload_file';
	$('#fileupload1').fileupload({
		url: url,
		done: function (e, data) {
		$("#vis_new_attachments1").append(data.result);
		}
	});
});
<? if(!defined('VIS_HEAD_MENU_HTML_EDITOR') || VIS_HEAD_MENU_HTML_EDITOR==1) { ?>    
	$(function(){
		$('#vis_new_article_content').redactor({
			buttonSource: true,
            minHeight: 180, // pixels
            maxHeight: 180,
            imageUpload: "index.php?vis_tmpst="+new Date().getTime()+"&vis_module=ticket&vis_operation=upload_file&vis_static_area=editor_image_upload",
            imageUploadParam: 'files',            
            focus: true,
            plugins: ['source'],
			deniedTags: ['html', 'head', 'link', 'body', 'meta', 'script','applet']
		});
	});<? } ?>
	 </script>
<script src="<? echo VIS_PATH_SCRIPT; ?>file-upload/jquery.ui.widget.js"></script>
<script src="<? echo VIS_PATH_SCRIPT; ?>file-upload/jquery.fileupload.js"></script>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
