<? global $vis_language; ?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
	<div class="col-sm-6">
		<h3 class="m-b-xs text-black"><? echo $vis_language['TXTVIEWS']; ?></h3>
		<ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
			<li><a class="link" href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>"><? echo $vis_language['TXTHOME']; ?></a></li>
			<li><a class="link" href="#/home/view_views/<? echo $vis_language['TXTVIEWS']; ?>"><? echo $vis_language['TXTVIEWS']; ?></a></li>
			<li class="active"><? echo $vis_language['TXTADDVIEW']; ?></li>
		</ul>
	</div>
</section>
 <section class="padder">
 <section class="panel panel-default">
<header class="panel-heading sub_header"><? echo $vis_language['TXTADDVIEW']; ?></header>
<div class="panel-body">
<form class="form-horizontal" method="post" id="vis_views_form" name="vis_views_form">
	<div class="form-group">
		<label class="col-sm-2 control-label"><? echo $vis_language['TXTTITLE']; ?></label>
		<div class="col-sm-10">
			<input class="form-control input-sm" type="text" name="vis_viewname" id="vis_viewname">
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label"><? echo $vis_language['TXTLISTCOUNT']; ?></label>
		<div class="col-sm-10">
			<input class="form-control input-sm" type="text" name="vis_listcount" id="vis_listcount">
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label"><? echo $vis_language['TXTSORTBY']; ?></label>
		<div class="col-sm-3">
			 <select class="form-control input-sm m-b selectpicker" name="vis_sort_by_1" id="vis_sort_by_1">
				<option value=""><? echo $vis_language['TXTSELECT']; ?></option><option value="subject"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="first_name"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="email"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="department_name"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="ticket_status"><? echo $vis_language['TXTSTATUS']; ?></option><option value="ticket_priority"><? echo $vis_language['TXTPRIORITY']; ?></option><option value="ticket_type"><? echo $vis_language['TXTTICKETTYPE']; ?></option><option value="flag_id"><? echo $vis_language['TXTFLAG']; ?></option><option value="modify_date"><? echo $vis_language['TXTLASTACTIVITY']; ?></option><option value="user_replied"><? echo $vis_language['TXTLASTREPLIER']; ?></option><option value="receive_date"><? echo $vis_language['TXTCREATIONDATE']; ?></option><option value="due_time"><? echo $vis_language['TXTDUETIME']; ?></option><option value="attachment_count"><? echo $vis_language['TXTHASATTACHMENT']; ?></option><option value="resolution_time"><? echo $vis_language['TXTRESOLUTIONTIME']; ?> </option>
			</select>
		</div>
		<div class="col-sm-3">
			 <select class="form-control input-sm m-b selectpicker" name="vis_sort_order_1" id="vis_sort_order_1">
				<option value="asc"><? echo $vis_language['TXTASCENDING']; ?></option><option value="desc"><? echo $vis_language['TXTDESCENDING']; ?></option>
			 </select>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label"></label>
		<div class="col-sm-3">
			 <select class="form-control input-sm m-b selectpicker" name="vis_sort_by_2" id="vis_sort_by_2">
				<option value=""><? echo $vis_language['TXTSELECT']; ?></option><option value="subject"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="first_name"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="email"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="department_name"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="ticket_status"><? echo $vis_language['TXTSTATUS']; ?></option><option value="ticket_priority"><? echo $vis_language['TXTPRIORITY']; ?></option><option value="ticket_type"><? echo $vis_language['TXTTICKETTYPE']; ?></option><option value="flag_id"><? echo $vis_language['TXTFLAG']; ?></option><option value="modify_date"><? echo $vis_language['TXTLASTACTIVITY']; ?></option><option value="user_replied"><? echo $vis_language['TXTLASTREPLIER']; ?></option><option value="receive_date"><? echo $vis_language['TXTCREATIONDATE']; ?></option><option value="due_time"><? echo $vis_language['TXTDUETIME']; ?></option><option value="attachment_count"><? echo $vis_language['TXTHASATTACHMENT']; ?></option><option value="resolution_time"><? echo $vis_language['TXTRESOLUTIONTIME']; ?> </option>
			</select>
		</div>
		<div class="col-sm-3">
			 <select class="form-control input-sm m-b selectpicker" name="vis_sort_order_2" id="vis_sort_order_2">
				<option value="asc"><? echo $vis_language['TXTASCENDING']; ?></option><option value="desc"><? echo $vis_language['TXTDESCENDING']; ?></option>
			 </select>
		</div>
	</div>
    <div class="form-group">
		<label class="col-sm-2 control-label"></label>
		<div class="col-sm-3">
			 <select class="form-control input-sm m-b selectpicker" name="vis_sort_by_3" id="vis_sort_by_3">
				<option value=""><? echo $vis_language['TXTSELECT']; ?></option><option value="subject"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="first_name"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="email"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="department_name"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="ticket_status"><? echo $vis_language['TXTSTATUS']; ?></option><option value="ticket_priority"><? echo $vis_language['TXTPRIORITY']; ?></option><option value="ticket_type"><? echo $vis_language['TXTTICKETTYPE']; ?></option><option value="flag_id"><? echo $vis_language['TXTFLAG']; ?></option><option value="modify_date"><? echo $vis_language['TXTLASTACTIVITY']; ?></option><option value="user_replied"><? echo $vis_language['TXTLASTREPLIER']; ?></option><option value="receive_date"><? echo $vis_language['TXTCREATIONDATE']; ?></option><option value="due_time"><? echo $vis_language['TXTDUETIME']; ?></option><option value="attachment_count"><? echo $vis_language['TXTHASATTACHMENT']; ?></option><option value="resolution_time"><? echo $vis_language['TXTRESOLUTIONTIME']; ?> </option>
			</select>
		</div>
		<div class="col-sm-3">
			 <select class="form-control input-sm m-b selectpicker" name="vis_sort_order_3" id="vis_sort_order_3">
				<option value="asc"><? echo $vis_language['TXTASCENDING']; ?></option><option value="desc"><? echo $vis_language['TXTDESCENDING']; ?></option>
			 </select>
		</div>
	</div>
   <?
    $field_selected='';
    $field_available='';
    $count=count($field_list);
    for($i=1;$i<=$count;$i++) {
        if($i%2==0) $field_available.='<li class="" id="vis_field'.$i.'">'.addslashes($vis_language[$field_list[$i]]).'</li>';
        else $field_selected.='<li class="highlight btn-primary" id="vis_field'.$i.'">'.addslashes($vis_language[$field_list[$i]]).'</li>';
    } ?>
    <div class="form-group">
		<label class="col-sm-2 control-label" ><? echo $vis_language['TXTLISTCOLUMN']; ?></label>
		<div class="col-sm-5">
			<section id="connected">
				<div class="col-sm-6">
				<label class="control-label" id="vis_label_lpad"><? echo$vis_language['TXTFIELDSAVAILABLE']; ?></label>
				<ul class="connected list col-sm-3" id="sortable1">
					<? echo $field_available; ?>
				</ul>
				</div>
				<div class="col-sm-6">
				<label class="control-label" id="vis_label_lpad"><? echo $vis_language['TXTFIELDSSELECTED']; ?></label>
				<ul class="connected list no2 col-sm-3" id="sortable2">
					<? echo $field_selected; ?>
				</ul>
				</div>
			</section>
		</div>
	</div>
  <div class="form-group">
	  <label class="col-sm-2 control-label"><? echo $vis_language['TXTSTATUS']; ?></label>
	  <div class="col-sm-1">
		<label class="switch">
		  <input type="checkbox" name="vis_status" id="vis_status" checked="checked">
		  <span></span>
		</label>
	  </div>
	</div>
	<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 onclick="get_selected_fields(this);" class="btn btn-primary" type="button"><? echo $vis_language['TXTADD']; ?></button>
			<input type="hidden" name="vis_list_value" id="vis_list_value" value="0" />
		</div>
	</div>
</form>
</div>
</section>
</section>
	<script>
	$(".selectpicker").selectpicker();
		$(function() {
			$('.sortable').sortable();
			$('.handles').sortable({
				handle: 'span'
			});
			$('.connected').sortable({
				connectWith: '.connected'
			});
			$('.exclude').sortable({
				items: ':not(.disabled)'
			});
		});
	   function get_selected_fields(e){
	     var list_value='';
	     $("#sortable2 [id^='vis_field']").each( function() {
			list_value+=$( this ).attr('id')+',';
		 });
         $('#vis_list_value').val(list_value);
         $(e).visExecution('submit_form',{'vis_module':'home', 'vis_operation':'add_view', 'vis_form':'vis_views_form'});
    }
</script>
