<link rel="stylesheet" href="/js/jquery-ui/smoothness/jquery-ui-1.8.21.custom.css" type="text/css">
<script type="text/javascript" src="/js/jquery-ui/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#startdate,#enddate").datepicker({
        showButtonPanel: true,
        dateFormat:'yy-mm-dd'
    });

    //获取分页数据
    $(".pagination>ul>li>a").live("click",function(event){
  		event.preventDefault();
    	var url=$(this).attr('href');
    	var p_class=$(this).parents('li').attr('class');
    	if (p_class!='active') {
    		$("#form-search-tasks").attr('action',url);
    		$('body,html').animate({scrollTop:0},300);
    		get_ajax_reviewed_list('form-search-tasks','tasks-container',false);
    	};
    })
});

</script>
<div class="row-fluid">
  <div class="span2" style="padding-left:15px;">
	<?php echo $nav_view; ?>
  </div>
	<div class="span8" style="border-right:1px solid #ddd;border-left:1px solid #ddd; min-height:1024px; padding:0 20px;">
  	<?php if(!empty($announce)){ ?>
    <div class="span12 alert alert-error">
      <button type="button" class="close" data-dismiss="alert">×</button>
      <em><strong>announcement: </strong></em><a style="color: #b94a48;" href="<?php echo site_url('taskhall/announce/'.$announce[0]->ta_id); ?>"><?php echo $announce[0]->ta_title;?> >> </a>
    </div>
    <?php } ?>
    <?php if(empty($task_list) and !empty($notice_list)){ ?>
      <p>Need Help to getting started?</p>
      <?php foreach ($notice_list as $k => $a) { ?>
        <p><span><?php echo $k+1; ?>. </span> <a href="<?php echo site_url('taskhall/notice/'.$a->ta_id); ?>"><?php echo $a->ta_title;?></a></p>
      <?php } ?>
    <?php }elseif(!empty($task_list)){ ?>
  	<form action="" method="post" class="span12" id="form-search-tasks" style="margin-left:0; background:#f5f5f5;padding:15px;">
        <div class="input-append">
        	<select class="span2" name="taskstatus">
                    <option value="-">All of my tasks</option>
                    <option value="edit" >Ongoing tasks</option>
                    <option value="review" >Unapproved tasks</option>
                    <option value="reviewed" >Approved tasks</option>
                    <option value="unreviewed" >Rejected tasks</option>
                    <option value="refuse" >Rejected contributions</option>
                    <option value="complete" >Accomplished tasks</option>
            </select>
            <input class="span2" type="text" id="startdate" name="startdate" placeholder="startdate">
            <input class="span2" type="text" id="enddate" name="enddate" placeholder="enddate">
            <input class="span3" type="text" id="tasktitle" name="tasktitle" placeholder="task title">
            <select class="span2" name="tasktype">
                    <option value="-">task type</option>
                    <?php foreach ($this->config->item('auhtor_task_type') as $type_key => $type_value) { ?>
                        <option value="<?php echo $type_value; ?>" ><?php echo $type_value; ?></option>
                    <?php } ?>
                </select>
            <button class="btn" type="button" onclick="$('#form-search-tasks').attr('action', '<?php echo site_url('welcome/index') ?>');get_ajax_reviewed_list('form-search-tasks','tasks-container',false);">Search</button>
        </div>
    </form>

  	<div class="span12" id="tasks-container" style="margin-left:0;">
		<table class="table table-striped">
		  <thead>
			<tr>
			  <th>#</th>
			  <th>Task name</th>
			  <th>Type</th>
			  <th>Sent by</th>
			  <th>Upload</th>
			  <th>End</th>
			  <th>Revisions</th>
        <th>Status</th>
			</tr>
		  </thead>
		  <tbody>
      <?php $status_array=array('edit'=>'Ongoing','unreviewed'=>'Rejected','review'=>'Unapproved','wait'=>'Unapproved','reviewed'=>'Accepted','published'=>'Paid','complete'=>'Paid','refuse'=>'Rejected'); ?>
		  <?php foreach($task_list as $key=>$task){ ?>
			<tr class="">
			  <td><?php echo $key+1; ?></td>
			  <td>
			  <?php if(have_unread_sms('task',$task->t_id)){ ?>
				<a href="<?php echo site_url('welcome/view/'.$task->t_id); ?>#sms"><i class="icon-envelope"></i></a> 
			<?php } ?>
				<a href="<?php echo site_url('welcome/view/'.$task->t_id); ?>"><?php echo $task->t_title; ?></a>
			  </td>
			  <td><?php echo $task->t_td_type; ?></td>
			  <td><?php echo get_author_name($task->t_ht_op_code); ?></td>
			  <td><?php echo date('m/d/Y',strtotime($task->t_datetime)); ?></td>
			  <td><?php echo date('m/d/Y',strtotime($task->t_expires)); ?></td>
			  <td><?php echo $task->t_edit_count; ?></td>
        <td><?php echo $status_array[$task->t_status]; ?></td>
			</tr>
		  <?php } ?>
			
		  </tbody>
		</table> 
		<div class="pagination">
		  <ul><?php echo($page['htmls']);?></ul>
		</div>
  	</div>
    <?php } ?>
  </div>
  <div class="span2" style="padding-right:12px;"><?php echo $rank_view; ?></div>
</div>
