<?php
   global $vis_language; 
   $paging_list='';
   for($i=0;$i<$view_info['page_count'];$i++) $paging_list.='<option value="'.$i.'" '.(($language_details['page']==$i)?'selected="selected"':'').'>'.($i+1).'</option>';
   ?> 
<? if($operation['vis_change']!=1) {?>
	<section class="row">
	<div class="col-md-12 m-b-n-xs">
	<div class="pull-right">
    <ul class="pagination-sm pagination" id="pagination-demo"></ul>
	</div>
	<div class="m-t-md col-xs-3 pull-right">
	<div class="input-group b-a b-2x rounded">
			<input class="form-control rounded input-sm no-border" type="text" placeholder="<?php echo $vis_language['TXTSEARCHWORDPHRESES'];?>" value="<?php echo (isset($operation['criteria']))?$operation['criteria']:'';?>" id="search_language_variables">
			<span class="input-group-btn rounded b-l b-3x">
			<button class="btn btn-sm btn-rounded bg-white b-white btn-icon" type="button" onclick="display_language_variables();">
			<i class="vh vh-search"></i>
			</button>
			</span>
		</div>
	</div>
	</div>
</section>
<? } ?>
 <? if($view_info['page_count']>0) {?>
<div id="language_details1">
   <table class="table table-hover b-t b-light m-b-none" >
      <tr>
         <th width="40%"><? echo $vis_language['TXTDEFAULTVARIABLES']; ?></th>
         <th width="60%"><? echo $vis_title; ?></th>
         <th></th>
      </tr>
      <?
         for($i=1; $i<=count($language_variables);$i++)
         {                    
                  echo '<tr><td>'.$language_variables[$i]['english'].'</td><td><input type="text" name="vis_edit_variables_'.$language_variables[$i]['variable_id'].'" id="vis_edit_variables_'.$language_variables[$i]['variable_id'].'" class="form-control input-sm" value = "'.htmlspecialchars($language_variables[$i]['second_decription']).'" ></td>';   
         ?>
          <td align="center"><? if($language_variables[$i]['is_custom']==1) { ?>
         <a class="text-muted" href="javascript:void(0);"  data-toggle="ajaxModal" data-modal-arguments="vis_module=setting&vis_operation=get_localization_delete&vis_variable_id=<? echo $language_variables[$i]['variable_id']; ?>&vis_language_id=<? echo $language_detail[1][0]['language_id']; ?>&vis_langauge_location=<?=$data['vis_location_id']?>&vis_static_area=vis_localization_delete_form" title="<? echo $vis_language['TXTDELETE']; ?>"><i class="vh vh-delete-round"></i></a>
         <? } 
		 } ?>
      </td>
      </tr>
      <input type="hidden" id="vis_criteria" value=""/>
   </table>
   <div class="line b-b line-lg pull-in"></div>
   <br/>
   <div class="form-group">
      <div class="col-sm-4 col-sm-offset-2">
         <button type="button" class="btn btn-primary" onclick="submit_form();"><? echo $vis_language['TXTUPDATE']; ?></button>
      </div>
   </div>
</div>
<? if($operation['vis_change']!=1) {?>
<div class="text-right">
   <ul class="pagination-sm pagination" id="pagination-demo1"></ul>
</div>
<? } ?>
<? 
}
else
{?>
<br/><br/>
<? include(VIS_PATH_TEMPLATE.'no_record_yet.php');
} ?>

<script>
	 <? if($view_info['page_count']>0) {?>
   $('.pagination-sm').twbsPagination({
         totalPages:<?php echo $view_info['page_count']; ?>,
         visiblePages:5,
         onPageClick: function (event, page) {
			 var lang_var = $('#vis_criteria').val();
         $('#language_details1').visExecution('load_operations',{'vis_module':'setting', 'vis_operation':'display_localisation', 'vis_page':page-1 ,'vis_form':'vis_language_variable_form','vis_change':1,'criteria':''+lang_var+'',});
         }
     });<? }?>
/*	$('#search_language_variables').keyup(function(e){
    if(e.keyCode == 13)
    {
       display_language_variables();
    }
   });*/
     function display_language_variables()
    {
		var lang_var = $('#search_language_variables').val();
		if(lang_var.length < 3)
				$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['TXTGLOBALSEARCHERROR'];?>");
		else if(lang_var!="")
		$('#language_details').visExecution('load_operations',{'vis_module':'setting', 'vis_operation':'display_localisation', 'vis_action123':'no_load','criteria':''+lang_var+'','vis_form':'vis_language_variable_form'});
		else
		$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['MSGSERBOX'];?>");
	}
    function submit_form(){
        var var_ids = new Array();
        $("[id^='vis_edit_variables_']").each(function(i){
            var var_id_array=$(this).attr('id').split("vis_edit_variables_");
            var_ids[i++] = var_id_array[1];
         }); 
        $('#vis_global_msg_div').visExecution('submit_form',{'vis_module':'setting', 'vis_operation':'update_language_details', 'vis_form':'vis_language_variable_form','var_ids':var_ids});
    }
</script>
