<? global $vis_language; ?>
 <div class="table-responsive scroll-x" >
    <table class="table table-hover b-t b-light m-b-none" id="datatable">
			<thead class="table_head">
   <tr>
   <th><? echo $vis_language['TXTQUEUESUMMARY'];?></th>
   <th><? echo $vis_language['TXTTOTALREPORTQUEUE'];?>: <? echo $downloadcounts['totalcount'];?></th>
   <th><? echo $vis_language['TXTMYREPORTQUEUE'];?>: <? echo $downloadcounts['mypendingcount'];?></th>
   <th colspan="5"><? echo $vis_language['TXTMYCOMPLITEDQUEUE'];?>: <? echo $downloadcounts['mycompletedcount'];?></th>
   </tr>
				  <tr>
					 <th><? echo $vis_language['TXTREPORTTITLE']; ?></th>  
      <th><? echo $vis_language['TXTCREATEDBY']; ?></th> 
       <th><? echo $vis_language['TXTCREATIONDATE']; ?></th> 
					 <th><? echo $vis_language['TXTCOMPLETEDDATE'];?></th>
					 <th><? echo $vis_language['TXTSTATUS'];?></th>		
					 <th><? echo $vis_language['TXTOPTIONS'];?></th>
					 <th class="text-center"><? echo $vis_language['TXTEMAIL'];?></th>
      <th></th>          
				  </tr>
			 </thead>
			 <tbody>
				  <? 
					  for($i=0;$i<count($download_list);$i++) { 
					  	 			  	 
							  echo '<tr>';
							  echo '<td class="txt_nowrap">'.$download_list[$i]['export_name'].'</td>';	
									echo '<td class="txt_nowrap">'.$download_list[$i]['first_name'].'</td>';	
							  echo '<td class="txt_nowrap">'.format_datetime($download_list[$i]['receive_date']).'</td>';
							   if($download_list[$i]['is_completed'] == 1)	
							   {					  				
									 $download_list[$i]['is_completed'] = 'Completed';
							 		 echo '<td>'.format_datetime(strtotime($download_list[$i]['request_date'])).'</td>';
									 echo '<td>'.$download_list[$i]['is_completed'].'</td>';
									  if($download_list[$i]['export_type']==0)echo'<td>-</td>';
									 
									 elseif($download_list[$i]['export_type']==1)
									 {
										if($download_list[$i]['file_name']!='')
										echo '<td><a class ="link btn" href="'.VIS_PATH_DOWNLOADS.''.$download_list[$i]['file_name'].'.csv">'.$vis_language['TXTDOWNLOAD'].'</a></td>';
										else echo'<td>-</td>';
								     }else
								     if($download_list[$i]['export_type']==2)
									 {
										if($download_list[$i]['file_name']!='')
											{  	
												$filename=$download_list[$i]['file_name'];
											
												//echo '<td><form method="POST" id="downlod_form" name="downlod_form" ><input type="hidden" name="vis_filename" value="'.$download_list[$i]['file_name'].'" /><input type="hidden" name="vis_module" value="report" /><input type="hidden" name="vis_operation" value="download_html" /><input type="hidden" name="vis_export" value="true" /><input type="submit" name="vis_submit" class="vis_button_export btn-link link btn" value="link" onclick="window.location.href='.$download_list[$i]['file_name'].'"/></form></td>';
								
						
												echo '<td><a class ="link btn" href="'.VIS_PATH_DOWNLOADS.$filename.'.html" download>'.$vis_language['TXTDOWNLOAD'].'</a></td>';
								  	  
											}else {echo'<td>-</td>';}
								     }else
								     if($download_list[$i]['export_type']==3)
									 {
										if($download_list[$i]['file_name']!='')
									
										echo '<td><a class ="link btn" href="'.VIS_PATH_DOWNLOADS.''.$download_list[$i]['file_name'].'.xls">'.$vis_language['TXTDOWNLOAD'].'</a></td>';
										else echo'<td>-</td>';
								     }
								     if($download_list[$i]['send_email']==1 && $download_list[$i]['file_name']!='')
								       {
										  $export=$download_list[$i]['export_id'];
										   //echo '<td><a class ="link btn" href="javascript:void(0);" onclick="email_download_send('.$export.');">Email</a></td>';
										    echo '<td align="center"> <a class="m" title="Send Email"  href="javascript:void(0);" onclick="email_download_send('.$export.');"><i class="vh vh-mail-forward text-muted"></a></td>';
									   }else 
										  echo'<td align="center">-</td>';
										 
									  
							   }
							   else
							   {
							   		 $download_list[$i]['is_completed'] = 'Not Completed';
							   	
							   		 echo '<td style=" text-indent: 50px;">-</td>';
									 echo '<td>'.($download_list[$i]['leftcount']+1).' '.$vis_language['TXTREPORTINQUEUE'].'</td>';
								  	 echo '<td style=" text-indent: 7px;">-</td>';
												echo '<td style=" text-indent: 7px;">-</td>';
								  	 if($download_list[$i]['export_type']==0)echo'<td>-</td>';
							   }
							  echo '<td align="center"> <a class="text-muted" href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=report&vis_operation=delete_queue_link&vis_export_id='.$download_list[$i]['export_id'].'" title="'.$vis_language['TXTDELETE'].'"><i class="vh vh-delete-round"></a></td>';
							  echo '</tr>';	
						  }
					  ?> 
			</tbody>		   
   		 </table>
       </div>
   	 <script>
   	 function email_download_send(export_id){
        $.ajax({
            url: 'index.php',
            data: {'vis_module':"report", 'vis_export':export_id ,'vis_operation':"email_send_download" },
            type: "POST",
            dataType: "json",
            success: function(data) {
                 
                   $("#vis_global_msg_div").visInterface("load_global_message", "<?php echo $vis_language['MSGSUCCOPRT'];?>"); 
                 }
        });
    }
   	 </script>

