<? global $vis_language;
 $task_filters=array(2=> $vis_language['TXTMYTASK'],3=> $vis_language['TXTASSIGNEDTASK'],4=> $vis_language['TXTINPROGRESSTASK'],5=>$vis_language['TXTOVERDUETASK'],6=> $vis_language['TXTCOMPLETEDTASK'],7=>$vis_language['TXTCANCELLEDTASK'],8=> $vis_language['TXTLOWPRIORITYTASK'],9=> $vis_language['TXTMEDIUMPRIORITYTASK'],10=>$vis_language['TXTHIGHPRIORITYTASK'],12=> $vis_language['TXTMYFAVOURITES'],14=> $vis_language['TXTNOTSTARTEDTASK']);?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
   <div class="col-sm-3">
      <h3 class="m-b-xs text-black"><? echo $vis_language['TXTTASKS'];?><span id="total_cnt"> (<? echo $task_info['total']; ?>)</span></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>
		 <?
		 if(isset($operation['filter_id']) && $operation['filter_id']!='1'){
			 ?><li><a class="link" href="#/home/view_tasks/<? echo $vis_language['TXTTASKS']; ?>/1"><?echo $vis_language['TXTTASKS'];?></a></li><? 
			 for($i=2;$i<=count($task_filters)+3;$i++){ 
				if($operation['filter_id']==$i){
					?><li class="active"><? echo $task_filters[$i]; ?></li><?
				}elseif($operation['filter_id']==$i && $operation['filter_id']!=$task_filters[$operation['filter_id']]){
					?><li class="active"><? echo $task_filters[$i]; ?></li><?
				}
			 } 
		}else if(isset($operation['criteria']) && $operation['criteria']!=''){?>
			 <li><a href="#/home/view_tasks/<? echo $vis_language['TXTTASKS']; ?>/1" class="link" onclick="location.reload();"><?echo $vis_language['TXTTASKS'];?></a></li>
			  <li class="active"><? echo $vis_language['TXTSEARCHRESULT']; ?> </li>
			 <? 
		} else { 
			?><li class="active"><? echo $vis_language['TXTTASKS']; ?> </li><? 
		} ?>
      </ul>
   </div>
   <div class="padder">
    <div class="m-t-md col-xs-6 pull-right">
		<a class="btn btn-sm btn-primary btn-rounded pull-right m-l" href="javascript:void(0)"  onclick="$('#vis_workpanel_div').visExecution('load_module','Add Task',{'vis_module':'home','vis_operation':'new_task', 'cache':true});"><i class="vh vh-plus"></i><? echo " ".$vis_language['TXTNEW']; ?></a> 
		<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['MSGSEARCHTASK'];?>" value="<?php echo (isset($operation['criteria']))?$operation['criteria']:'';?>" id="search_task">
         <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_tasks();">
         <i class="vh vh-search"></i>
         </button>
         </span>
		</div>
	</div>
   </div>
</section>
    <? if($task_info['total']>0){?>
 <section id="content">
   <section class="hbox stretch">
      <section>
         <section class="vbox">
            <section class="row-2">
                <div class="text-right padder">
                   <ul class="pagination-sm pagination" id="task_pagination"></ul>
                </div>
                <aside class="myTask">
                   <? include(VIS_PATH_TEMPLATE.'tasks_list.php'); ?>
                </aside>
                <div class="text-right padder">
                     <ul class="pagination-sm pagination" id="task_pagination1"></ul>
                </div>
                  <input type="hidden" id="vis_task_filter_id" name="vis_task_filter_id" value="<?echo $operation['filter_id'];?>"/>
            </section>
         </section>
      </section>
   </section>
</section>

<? }else {
	 include(VIS_PATH_TEMPLATE.'no_record_yet.php');
	 }?>
<script>
$( document ).ready(function() {
   $('#search_task').val('<?php echo $operation['criteria']; ?>');
});

   <? if($view_info['page_count']>0) {?>
    $('.pagination-sm').twbsPagination({
          totalPages:<?php echo $view_info['page_count']; ?>,
          visiblePages:3,
          onPageClick: function (event, page) {
          $('.myTask').visExecution('load_operations',{'vis_module':'home', 'vis_operation':'view_tasks', 'vis_page':page-1 ,'vis_form':'vis_task_form','vis_change':1 ,'vis_filter_id':'<? echo (isset($operation['filter_id'])? $operation['filter_id'] : $operation['vis_filter_id']);?>','criteria':'<?=$operation['criteria']; ?>'});
          }
      });<? }?>
      
    function display_tasks()
	{
	   var article = $('#search_task').val();
	   if(article.length < 2)
				$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['TXTGLOBALSEARCHERROR'];?>");
	   else if(article!="")
	   {
	   $('#vis_workpanel_div').visExecution('load_module', '<?echo $vis_language['TXTTASKS']."/1";?>', {'vis_module':'home', 'vis_operation':'view_tasks', 'vis_action':'no_load','criteria':article });
	   }
	   else
	   $("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['MSGSERACHTASKBOX'];?>");
	 }
    $("#vis_task_start_date").datetimepicker({showButtonPanel: true, dateFormat: 'dd-mm-yyyy'});
    $("#vis_task_end_date").datetimepicker({showButtonPanel: true, dateFormat: 'dd-mm-yyyy'});
       $(".selectpicker").selectpicker();
</script>
