<? global $vis_language; ?>
<div class="modal-dialog" id="blabDialog">
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">&times;</button>
      <h4 class="modal-title"><? echo $vis_language['TXTEDITFORUM']; ?></h4>
    </div>
    <div class="modal-body">
    <form action="index.php" method="post" target="vis_hidden_frame" name="vis_update_forum_form" id="vis_update_forum_form" class="form-horizontal">
		
        <div class="form-group">
                            <label class="col-sm-3 control-label txt_nowrap"><? echo $vis_language['TXTDOMAIN']; ?></label>
                            <div class="col-sm-9">
                                <select name="vis_domain" id="vis_domain_new" class="form-control input-sm selectpicker"<? if(count($domain_details)>10) echo ' data-live-search="true"';?> ><?
									if($domain_details!=-1) for($i=0;$i<count($domain_details); $i++){
								    $selectDomain = ($domain_details[$i]['domain_id'] == $forumDetails['domain_id'])?'selected="selected"':'';
									echo '<option value="'.$domain_details[$i]['domain_id'].'" '.$selectDomain.' >'.$domain_details[$i]['domain_name'].'</option>';} ?>
									</select>
            </div>
        </div>
        <div class="form-group">
                            <label class="col-sm-3 control-label txt_nowrap"><? echo $vis_language['TXTFORUMCATEGORY']; ?></label>
                            <div class="col-sm-9" id="vis_forum_category_list">
                                <select name="vis_forum_category" id="vis_forum_category_new" class="form-control input-sm selectpicker"<? if(count($forum_category_details)>10) echo ' data-live-search="true"';?>><?
									if($forum_category_details!=-1) for($i=0;$i<count($forum_category_details); $i++){
										$selectForum = ($forum_category_details[$i]['forum_cat_id'] == $forumDetails['forum_cat_id'])?'selected="selected"':'';
									echo '<option value="'.$forum_category_details[$i]['forum_cat_id'].'" '.$selectForum.' >'.$forum_category_details[$i]['category_name'].'</option>';}?>
									</select>
            </div>
        </div>
        <div class="form-group">
                <label class="col-sm-3 control-label txt_nowrap"><? echo $vis_language['TXTVISIBLETO']; ?></label>
               <div class="col-sm-9">
                  <select id="vis_display" name="vis_display" class="form-control input-sm selectpicker"onchange="access_posttopic($(this).val());" >
						<option value="0"<? echo ($forumDetails['display_status']==0)?' selected="selected"':''; ?>><? echo $vis_language['TXTEVERYBODY']; ?></option>
						<option value="1"<? echo ($forumDetails['display_status']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTLOGGEDINCLIENT']; ?></option>
						<option value="2"<? echo ($forumDetails['display_status']==2)?' selected="selected"':''; ?>><? echo $vis_language['TXTSTAFFONLY']; ?></option>
                  </select>
               </div>
        </div>
         <div class="form-group">
               <label class="col-sm-3 control-label"><? echo $vis_language['TXTPOSTTOPIC']; ?></label>
               <div class="col-sm-9" id="vis_post_topic">
				   <select name="vis_access" class="form-control input-sm selectpicker">
					   <option value="0"<? echo ($forumDetails['topic_access']==0)?' selected="selected"':''; ?>><? echo $vis_language['TXTSTAFFONLY']; ?></option>
					   <option value="1"<? echo ($forumDetails['topic_access']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTLOGGEDINCLIENT']; ?></option>
				   </select>
               </div>
            </div>
		<div class="form-group">
				<label class="col-sm-3 control-label txt_nowrap"><? echo $vis_language['TXTSTATUS']; ?></label>
				<div class="col-sm-9">
					<select id="vis_status" name="vis_status" class="form-control input-sm selectpicker">
						<option value="0" <? echo ($forumDetails['forum_status']==0)?' selected="selected"':'';?>><?=$vis_language['TXTPLANNED']?></option>
						<option value="1" <? echo ($forumDetails['forum_status']==1)?' selected="selected"':'';?>><?=$vis_language['TXTINPROGRESS']?></option>
						<option value="2" <? echo ($forumDetails['forum_status']==2)?' selected="selected"':'';?>><?=$vis_language['TXTIMPLEMENTED']?></option>
						<option value="3" <? echo ($forumDetails['forum_status']==3)?' selected="selected"':'';?>><?=$vis_language['TXTSOLVED']?></option>
						<option value="4" <? echo ($forumDetails['forum_status']==4)?' selected="selected"':'';?>><?=$vis_language['TXTUNSOLVED']?></option>
						<option value="5" <? echo ($forumDetails['forum_status']==5)?' selected="selected"':'';?>><?=$vis_language['TXTDIFERRED']?></option>
					</select>
				</div>
			</div>
        <div class="form-group">
                            <label class="col-sm-3 control-label txt_nowrap"><? echo $vis_language['TXTTITLE']; ?></label>
                            <div class="col-sm-9"><input type="text" name="vis_forum_title" id="vis_forum_title" class="form-control" value="<?= htmlentities($forumDetails['forum_title'], ENT_COMPAT, 'UTF-8'); ?>">
                                
            </div>
        </div>
        <div class="form-group">
                            <label class="col-sm-3 control-label txt_nowrap"><? echo $vis_language['TXTDESCRIPTION']; ?></label>
                            <div class="col-sm-9"><textarea name="vis_forum_post_area" id="vis_forum_post_area" class="form-control"  data-minwords="6" rows="2"><?= $forumDetails['description']; ?></textarea>
                                
            </div>
        </div>
          <div class="form-group"> 
				<label class="col-sm-3 control-label"><? echo $vis_language['TXTISTOPICMOVE']; ?></label>
				<div class="col-sm-9">
					<div class="radio i-checks pull-left m-r-lg">
						<label>
						<input type="radio" name="vis_topic_move" id="vis_topic_move"  <? if($forumDetails['is_topic_move']==1) echo 'checked="checked"'; ?> value="1" /><i></i>
						<? echo $vis_language['TXTYES']; ?></label>
					</div>
					<div class="radio i-checks pull-left ">
						<label>
						<input type="radio" name="vis_topic_move" id="vis_topic_move" <? if($forumDetails['is_topic_move']==0) echo 'checked="checked"'; ?> value="0"  /><i></i>
						<? echo $vis_language['TXTNO']; ?></label>
					</div>
				</div>
            </div>
          <? if($language_details!=-1) { ?>
            <div class="form-group">
               <div class="col-sm-12"><h5><? echo $vis_language['MSGLANGTRANSFORFORUM']; ?></h5></div>
            </div>
            <div class="line b-b line-lg pull-in"></div>
            <br/>
            <?
               for($i=0;$i<count($language_details);$i++) { ?>
            <div class="form-group">
               <label class="col-sm-3 control-label"><? echo $language_details[$i]['language_name']; ?></label>
               <div class="col-sm-9">
                  <input class="form-control input-sm" value="<? echo $forum_lang[$language_details[$i]['language_id']]; ?>" type="text" name="vis_language_<? echo $language_details[$i]['language_id']; ?>" type="text" value="" />
               </div>
            </div>
            <?
               } 
               }  ?>
        <input type="hidden" name="vis_forum_id"  id="vis_forum_id"  value='<?= $forumId; ?>' >
		<input type="hidden" name="vis_action_title"  id="vis_action_title"  value='<?= $forumDetails['category_name']; ?>' >
	</form>
    </div>
    <div class="modal-footer">
		<a class="btn btn-default" data-dismiss="modal"><? echo $vis_language['TXTCANCEL']; ?></a>  
		<a class="btn btn-primary" onclick="$(this).visExecution('submit_form',{'vis_module':'forums', 'vis_operation':'update_forum', 'vis_form':'vis_update_forum_form'});"><? echo $vis_language['TXTUPDATE']; ?></a>    
    </div>
  </div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
<script type="text/javascript">
	 $(".selectpicker").selectpicker();
	$("#vis_domain_new").change(function()
	{
		var id=$(this).val();
		$.ajax
		({
		url: 'index.php',
		data: {'vis_module':"forums", 'vis_operation':"add_forum_form" , 'vis_domain_id':id},
		type: "POST",
		success: function(data)
		{
			$("#vis_forum_category_list").html(data);
			$(".selectpicker").selectpicker();
		}
		});
	});
	$(document).ready(function() {
		var vis_visible_to=$("#vis_display").val();
		 if(vis_visible_to==0)
	   $('#vis_post_topic').html('<select name="vis_access" class="form-control input-sm selectpicker"><option value="0"<? echo ($forumDetails['topic_access']==0)?' selected="selected"':''; ?>><? echo $vis_language['TXTSTAFFONLY']; ?></option><option value="1"<? echo ($forumDetails['topic_access']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTLOGGEDINCLIENT']; ?></option></select>');
	   else if(vis_visible_to==1)
	   $('#vis_post_topic').html('<select name="vis_access" class="form-control input-sm selectpicker"><option value="1"<? echo ($forumDetails['topic_access']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTLOGGEDINCLIENT']; ?></option></select>');
	   else if(vis_visible_to==2)
	   $('#vis_post_topic').html('<select name="vis_access" class="form-control input-sm selectpicker"><option value="0"<? echo ($forumDetails['topic_access']==0)?' selected="selected"':''; ?>><? echo $vis_language['TXTSTAFFONLY']; ?></option></select>');
	   $(".selectpicker").selectpicker();
	});
   function access_posttopic(visible_to)
   {
	   if(visible_to==0)
	   $('#vis_post_topic').html('<select name="vis_access" class="form-control input-sm selectpicker"><option value="0"<? echo ($forumDetails['topic_access']==0)?' selected="selected"':''; ?>><? echo $vis_language['TXTSTAFFONLY']; ?></option><option value="1"<? echo ($forumDetails['topic_access']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTLOGGEDINCLIENT']; ?></option></select>');
	   else if(visible_to==1)
	   $('#vis_post_topic').html('<select name="vis_access" class="form-control input-sm selectpicker"><option value="1"<? echo ($forumDetails['topic_access']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTLOGGEDINCLIENT']; ?></option></select>');
	   else if(visible_to==2)
	   $('#vis_post_topic').html('<select name="vis_access" class="form-control input-sm selectpicker"><option value="0"<? echo ($forumDetails['topic_access']==0)?' selected="selected"':''; ?>><? echo $vis_language['TXTSTAFFONLY']; ?></option></select>');
	   $(".selectpicker").selectpicker();
   }
</script>
