<script type="text/javascript">
$(document).ready(function(){
	$("#startdate,#enddate").datepicker({
        showButtonPanel: true,
        dateFormat:'yy-mm-dd'
    });

    //推荐月度优秀文章
    $(".best_article").live('click',function(){
        var t_id=$(this).attr('data-taskid');
        var ta_isbest=0;
        var ta_count=$(this).attr('data-count');
        var ta_charge=$(".charge"+t_id).text();
        var total_charge=$("#total_charge").text();
        if ($(this).attr("checked")) {
            ta_charge=Number(ta_charge)+150;
            total_charge=Number(total_charge)+150;
            ta_isbest=1;
        }else{
            ta_charge=Number(ta_charge)-150;
            total_charge=Number(total_charge)-150;
        }
        var url="<?php echo site_url('author/set_task_charge'); ?>";
        $.post(url,{t_id:t_id,ta_count:ta_count,ta_charge:ta_charge,ta_isbest:ta_isbest},function(result){
            var json_obj=eval("("+result+")");
            if (json_obj.name=='ok') {
                $(".charge"+t_id).text(ta_charge);
                $("#total_charge").text(total_charge);
            }else{
                alert('评优设置失败');
            }
        });
    });

    //获取分页数据
    $(".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" style="padding-right: 30px;">
  		<form action="" method="post" id="form-search-tasks" style="background:#f5f5f5;padding:15px;">
            <div class="input-append">
            	<select class="span2" name="taskstatus">
                    <option value="-">所有任务</option>
                    <option value="edit" >进行中任务</option>
                    <option value="review" >待审核任务</option>
                    <option value="reviewed" >未结算任务</option>
                    <option value="complete" >已完成任务</option>
                    <option value="wait" >待审核投稿</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="span2" type="text" id="tasktitle" name="tasktitle" placeholder="task title">
                <select class="span2" name="author">
                	<option value="0" selected="selected">作者</option>
                    <option value="-1">大厅</option>
                	<?php foreach ($author_list as $a) { ?>
                		<option value="<?php echo $a->a_id; ?>"><?php echo $a->a_name; ?></option>
                	<?php } ?>
                </select>
                <select class="span1" 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="ajax_reviewed_tasks" value="1">
                <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/index') ?>');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/index/loadexcel') ?>');">导出到excel</a>
            </div>
        </form>
        <div id="tasks_list">
        <?php $task_type_array=array("edit"=>'进行中任务',"review"=>'待审核任务',"reviewed"=>'未结算任务',"complete"=>'已完成任务',"published"=>'已完成任务',"wait"=>'待审核投稿','unreviewed'=>'未通过审核','refuse'=>'未通过的投稿'); ?>
		<table class="table table-striped">
		  <thead>
			<tr>
			  <th>#</th>
			  <th class="span5">任务名称</th>
			  <th>类型</th>
			  <th>作者</th>
			  <th>编辑</th>
			  <th>发布</th>
			  <th>截止</th>
              <th>修改次数</th>
			  <th>状态</th>
			</tr>
		  </thead>
		  <tbody>
		  <?php foreach($task_list as $k=>$task){ ?>
			<tr>
			  <td><?php echo $k+1; ?></td>
			  <td>
				<?php if(have_unread_sms('task',$task->t_id)){ ?>
					<a href="<?php echo site_url('author/edit_task/'.$task->t_id); ?>#sms"><i class="icon-envelope"></i><?php echo $task->t_title; ?></a>
				<?php }else{ ?>
					<a href="<?php echo site_url('author/edit_task/'.$task->t_id); ?>"><?php echo $task->t_title; ?></a>
				<?php } ?>
				</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->t_expires)); ?></td>
              <td><?php echo $task->t_edit_count; ?></td>
			  <td><?php echo $task_type_array[$task->t_status]; ?></td>
			</tr>
		  <?php } ?>
			
		  </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>