<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_list',false);
    	};
    });
});
</script>
<div class="row-fluid">
  <div class="span2">
  
<?php echo $nav_view; ?>
  
  </div>
  <div class="span10">
  	<form action="" method="post" id="form-search-tasks">
            <div class="input-append">
                <input class="span2" type="text" id="startdate" name="startdate" placeholder="startdate">
                <input class="span2" type="text" id="enddate" name="enddate" placeholder="enddate">
                <input class="span2" type="text" id="tasktitle" name="tasktitle" placeholder="task title">
                <select class="span2" name="author">
                	<option value="0" selected="selected">作者</option>
                	<?php foreach ($author_list as $a) { ?>
                		<option value="<?php echo $a->a_id; ?>"><?php echo $a->a_name; ?></option>
                	<?php } ?>
                </select>
                <select class="span2" name="tasktype">
                    <option value="-">类型</option>
                    <?php foreach ($this->config->item('auhtor_task_type') as $type_key => $type_value) { ?>
                        <option value="<?php echo $type_value; ?>" ><?php echo $type_key; ?></option>
                    <?php } ?>
                </select>
                <input type="hidden" name="filetype" id="filetype" value="2">
                <button class="btn" type="button" onclick="$('#form-search-tasks').attr('action', '<?php echo site_url('author/in_complete_tasks') ?>');get_ajax_reviewed_list('form-search-tasks','tasks_list',false);">查询任务</button>
                <a href="#excel_type" role="button" class="btn" data-toggle="modal" onclick="$('#form-search-tasks').attr('action', '<?php echo site_url('author/in_complete_tasks/loadexcel') ?>');">导出到excel</a>
            </div>
        </form>
  	<div id="tasks_list">
		<table class="table table-striped">
		  <thead>
			<tr>
			  <th>#</th>
			  <th>任务名称</th>
			  <th>类型</th>
			  <th>作者</th>
			  <th>编辑</th>
			  <th>发布</th>
			  <th>完成时间</th>
			  <th>修改次数</th>
			  <th>字数</th>
			  <th>金额</th>
			  <th>网址</th>
			</tr>
		  </thead>
		  <tbody>
		  <?php
			$sum_count=0;
			$sum_charge=0;
			foreach($task_list as $key=>$task){ 
				$sum_count+=$task->last_version->ta_count;
				$sum_charge+=$task->last_version->ta_charge;
		  ?>
			<tr>
			  <td><?php echo $key+1; ?></td>
			  <td><a href="<?php echo site_url('author/edit_task/'.$task->t_id); ?>"><?php echo $task->t_title; ?></a></td>
			  <td><?php echo $task->t_td_type; ?></td>
			  <td><?php echo $task->t_a_id==0?'大厅':get_author_name($task->t_a_id); ?></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->last_version->ta_datetime)); ?></td>
			  <td><?php echo $task->t_edit_count; ?></td>
			  <td><?php echo $task->last_version->ta_count; ?></td>
			  <td><?php echo $task->last_version->ta_charge; ?></td>
			  <td>
			  	<?php $site_url='#'; if(isset($task->last_version->ic_sitecode))$site_url=$site_config[$task->last_version->ic_sitecode]['site_url'].$task->last_version->ic_url;?>
			  	<?php if($site_url!='#') { ?><a target="_blank" href="<?php echo $site_url;?>">查看</a><?php } else{echo '#';} ?>
			  </td>
			</tr>
		  <?php } ?>
			 <tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td>总计</td>
				<td><?php echo  $sum_count; ?></td>
				<td><?php echo  $sum_charge; ?></td>
				<td></td>
			  </tr>
		  </tbody>
		</table> 
		<div class="pagination">
		  <ul><?php echo($page['htmls']);?></ul>
		</div>
		</div>
  </div>
</div>

<!-- 选择导出excel的格式 -->
<div id="excel_type" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h4 id="myModalLabel">选择导出文件的编码格式</h4>
  </div>
  <div class="modal-body">
    <label class="radio">
      <input type="radio" name="load_type" value="2" onclick="$('#filetype').val(this.value)" checked>
      GBK格式
    </label>
    <label class="radio">
      <input type="radio" name="load_type" value="1" onclick="$('#filetype').val(this.value)">
      UTF-8格式
    </label>
    <p class="muted"><br>温馨提示: 如果导出的文件出现中文乱码，请使用另一种格式进行导出!</p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
    <button class="btn btn-info" data-dismiss="modal" aria-hidden="true" onclick="$('#form-search-tasks').submit();">开始导出</button>
  </div>
</div>